From d594180333669e50983daa815d94cfeaa554fd2b Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 3 Nov 2025 12:39:08 +0800 Subject: [PATCH 01/25] remove some unused deps --- Cargo.lock | 9 ++------- Cargo.toml | 1 + programs/drift/Cargo.toml | 7 ++----- programs/pyth/Cargo.toml | 1 - programs/token_faucet/Cargo.toml | 1 - 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e04c98d96..e0952ce1bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -958,7 +958,6 @@ dependencies = [ name = "drift" version = "2.145.1" dependencies = [ - "ahash 0.8.6", "anchor-lang", "anchor-spl", "arrayref", @@ -970,7 +969,6 @@ dependencies = [ "drift-macros", "enumflags2", "hex", - "num-derive 0.3.3", "num-integer", "num-traits", "openbook-v2-light", @@ -986,7 +984,6 @@ dependencies = [ "static_assertions", "switchboard", "switchboard-on-demand", - "thiserror", "uint", ] @@ -1840,7 +1837,6 @@ name = "pyth" version = "0.1.0" dependencies = [ "anchor-lang", - "arrayref", "bytemuck", ] @@ -1879,7 +1875,7 @@ dependencies = [ [[package]] name = "pyth-solana-receiver-sdk" version = "0.3.0" -source = "git+https://github.com/drift-labs/pyth-crosschain?rev=3e8a24ecd0bcf22b787313e2020f4186bb22c729#3e8a24ecd0bcf22b787313e2020f4186bb22c729" +source = "git+https://github.com/drift-labs/pyth-crosschain?rev=d790d1cb4da873a949cf33ff70349b7614b232eb#d790d1cb4da873a949cf33ff70349b7614b232eb" dependencies = [ "anchor-lang", "hex", @@ -1890,7 +1886,7 @@ dependencies = [ [[package]] name = "pythnet-sdk" version = "2.1.0" -source = "git+https://github.com/drift-labs/pyth-crosschain?rev=3e8a24ecd0bcf22b787313e2020f4186bb22c729#3e8a24ecd0bcf22b787313e2020f4186bb22c729" +source = "git+https://github.com/drift-labs/pyth-crosschain?rev=d790d1cb4da873a949cf33ff70349b7614b232eb#d790d1cb4da873a949cf33ff70349b7614b232eb" dependencies = [ "anchor-lang", "bincode", @@ -2972,7 +2968,6 @@ dependencies = [ "anchor-lang", "anchor-spl", "bytemuck", - "solana-program", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 766930deab..f686c06993 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ exclude = [ "deps/serum-dex" ] +resolver = "2" [profile.release] lto = "fat" diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index b2730356e9..d64706801f 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -23,15 +23,13 @@ solana-program = "1.16" anchor-spl = { version = "0.29.0", features = [] } pyth-client = "0.2.2" pyth-lazer-solana-contract = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb", features = ["no-entrypoint"]} -pythnet-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "3e8a24ecd0bcf22b787313e2020f4186bb22c729"} -pyth-solana-receiver-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "3e8a24ecd0bcf22b787313e2020f4186bb22c729"} +pythnet-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb"} +pyth-solana-receiver-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb"} bytemuck = { version = "1.4.0" } borsh = "0.10.3" hex = "0.4.3" num-traits = "0.2" uint = { version = "0.9.1", default-features = false } -num-derive = "0.3" -thiserror = "1.0" num-integer = "0.1.44" arrayref = "0.3.6" base64 = "0.13.0" @@ -43,7 +41,6 @@ static_assertions = "1.1.0" drift-macros = { git = "https://github.com/drift-labs/drift-macros.git", rev = "c57d87" } switchboard = { path = "../switchboard", features = ["no-entrypoint"] } openbook-v2-light = { path = "../openbook_v2", features = ["no-entrypoint"] } -ahash = "=0.8.6" switchboard-on-demand = { path = "../switchboard-on-demand", features = ["no-entrypoint"] } byteorder = "1.4.3" diff --git a/programs/pyth/Cargo.toml b/programs/pyth/Cargo.toml index 1acd07ab7f..ed1b1b8e28 100644 --- a/programs/pyth/Cargo.toml +++ b/programs/pyth/Cargo.toml @@ -18,5 +18,4 @@ anchor-test= [] [dependencies] anchor-lang = "0.29.0" -arrayref = "0.3.6" bytemuck = { version = "1.4.0" } diff --git a/programs/token_faucet/Cargo.toml b/programs/token_faucet/Cargo.toml index 249906b2cb..d553fdc158 100644 --- a/programs/token_faucet/Cargo.toml +++ b/programs/token_faucet/Cargo.toml @@ -16,6 +16,5 @@ anchor-test= [] [dependencies] anchor-lang = "0.29.0" -solana-program = "1.16" anchor-spl = "0.29.0" bytemuck = { version = "1.4.0" } \ No newline at end of file From 80233c03dcf8a546273c2eb097f5269881fdd63a Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Thu, 6 Nov 2025 14:17:54 +0800 Subject: [PATCH 02/25] anchor v0.32.1 + solana-program 2.2.1 update --- Cargo.lock | 3846 +++++++++++------ programs/drift/Cargo.toml | 19 +- programs/drift/src/instructions/if_staker.rs | 4 +- programs/drift/src/instructions/keeper.rs | 7 +- programs/drift/src/instructions/lp_admin.rs | 4 +- .../src/instructions/optional_accounts.rs | 18 +- programs/drift/src/instructions/user.rs | 4 +- programs/drift/src/macros.rs | 20 +- programs/drift/src/math/liquidation/tests.rs | 5 +- programs/drift/src/math/orders/tests.rs | 13 +- programs/drift/src/state/constituent_map.rs | 17 +- programs/drift/src/state/events.rs | 2 +- programs/drift/src/state/load_ref.rs | 12 +- programs/drift/src/state/oracle_map.rs | 12 +- programs/drift/src/state/perp_market_map.rs | 15 +- programs/drift/src/state/revenue_share.rs | 11 +- programs/drift/src/state/revenue_share_map.rs | 9 +- programs/drift/src/state/signed_msg_user.rs | 4 +- .../drift/src/state/signed_msg_user/tests.rs | 8 +- programs/drift/src/state/spot_market_map.rs | 15 +- programs/drift/src/state/user_map.rs | 32 +- programs/drift/src/state/zero_copy.rs | 12 +- programs/drift/src/test_utils.rs | 2 +- programs/openbook_v2/Cargo.toml | 2 +- programs/pyth/Cargo.toml | 2 +- programs/switchboard-on-demand/Cargo.toml | 4 +- programs/switchboard-on-demand/src/lib.rs | 40 +- programs/switchboard/Cargo.toml | 2 +- programs/token_faucet/Cargo.toml | 4 +- 29 files changed, 2572 insertions(+), 1573 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0952ce1bb..128a3eb3d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,33 +1,33 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aead" -version = "0.4.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ + "crypto-common", "generic-array", ] [[package]] name = "aes" -version = "0.7.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "opaque-debug", ] [[package]] name = "aes-gcm-siv" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589c637f0e68c877bbd59a4599bbe849cac8e5f3e4b5a3ebae8f528cd218dcdc" +checksum = "ae0784134ba9375416d469ec31e7c5f9fa94405049cf08c5ce5b4698be673e0d" dependencies = [ "aead", "aes", @@ -40,37 +40,27 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.16", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" dependencies = [ "cfg-if", - "getrandom 0.2.9", "once_cell", "version_check", "zerocopy", ] -[[package]] -name = "aho-corasick" -version = "0.7.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" -dependencies = [ - "memchr", -] - [[package]] name = "alloc-traits" version = "0.1.1" @@ -79,114 +69,120 @@ checksum = "6b2d54853319fd101b8dd81de382bcbf3e03410a64d8928bbee85a3e7dcde483" [[package]] name = "anchor-attribute-access-control" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5f619f1d04f53621925ba8a2e633ba5a6081f2ae14758cbb67f38fd823e0a3e" +checksum = "7a883ca44ef14b2113615fc6d3a85fefc68b5002034e88db37f7f1f802f88aa9" dependencies = [ "anchor-syn", "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "anchor-attribute-account" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f2a3e1df4685f18d12a943a9f2a7456305401af21a07c9fe076ef9ecd6e400" +checksum = "61c4d97763b29030412b4b80715076377edc9cc63bc3c9e667297778384b9fd2" dependencies = [ "anchor-syn", - "bs58 0.5.0", + "bs58 0.5.1", "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "anchor-attribute-constant" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9423945cb55627f0b30903288e78baf6f62c6c8ab28fb344b6b25f1ffee3dca7" +checksum = "aae3328bbf9bbd517a51621b1ba6cbec06cbbc25e8cfc7403bddf69bcf088206" dependencies = [ "anchor-syn", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "anchor-attribute-error" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ed12720033cc3c3bf3cfa293349c2275cd5ab99936e33dd4bf283aaad3e241" +checksum = "cf2398a6d9e16df1ee9d7d37d970a8246756de898c8dd16ef6bdbe4da20cf39a" dependencies = [ "anchor-syn", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "anchor-attribute-event" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eef4dc0371eba2d8c8b54794b0b0eb786a234a559b77593d6f80825b6d2c77a2" +checksum = "f12758f4ec2f0e98d4d56916c6fe95cb23d74b8723dd902c762c5ef46ebe7b65" dependencies = [ "anchor-syn", "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "anchor-attribute-program" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b18c4f191331e078d4a6a080954d1576241c29c56638783322a18d308ab27e4f" +checksum = "8c7193b5af2649813584aae6e3569c46fd59616a96af2083c556b13136c3830f" dependencies = [ + "anchor-lang-idl", "anchor-syn", + "anyhow", + "bs58 0.5.1", + "heck", + "proc-macro2", "quote", - "syn 1.0.92", + "serde_json", + "syn 1.0.109", ] [[package]] name = "anchor-derive-accounts" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de10d6e9620d3bcea56c56151cad83c5992f50d5960b3a9bebc4a50390ddc3c" +checksum = "d332d1a13c0fca1a446de140b656e66110a5e8406977dcb6a41e5d6f323760b0" dependencies = [ "anchor-syn", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "anchor-derive-serde" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4e2e5be518ec6053d90a2a7f26843dbee607583c779e6c8395951b9739bdfbe" +checksum = "8656e4af182edaeae665fa2d2d7ee81148518b5bd0be9a67f2a381bb17da7d46" dependencies = [ "anchor-syn", - "borsh-derive-internal 0.10.3", + "borsh-derive-internal", "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "anchor-derive-space" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecc31d19fa54840e74b7a979d44bcea49d70459de846088a1d71e87ba53c419" +checksum = "dcff2a083560cd79817db07d89a4de39a2c4b2eaa00c1742cf0df49b25ff2bed" dependencies = [ "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "anchor-lang" -version = "0.29.0" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35da4785497388af0553586d55ebdc08054a8b1724720ef2749d313494f2b8ad" +checksum = "e67d85d5376578f12d840c29ff323190f6eecd65b00a0b5f2b2f232751d049cc" dependencies = [ "anchor-attribute-access-control", "anchor-attribute-account", @@ -197,210 +193,119 @@ dependencies = [ "anchor-derive-accounts", "anchor-derive-serde", "anchor-derive-space", - "arrayref", - "base64 0.13.0", + "base64 0.21.7", "bincode", - "borsh 0.10.3", + "borsh 0.10.4", "bytemuck", - "getrandom 0.2.9", - "solana-program", - "thiserror", -] - -[[package]] -name = "anchor-spl" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c4fd6e43b2ca6220d2ef1641539e678bfc31b6cc393cf892b373b5997b6a39a" -dependencies = [ - "anchor-lang", - "solana-program", - "spl-associated-token-account", - "spl-token 4.0.0", - "spl-token-2022", -] - -[[package]] -name = "anchor-syn" -version = "0.29.0" + "solana-account-info 2.3.0", + "solana-clock 2.2.2", + "solana-cpi 2.2.1", + "solana-define-syscall 2.3.0", + "solana-feature-gate-interface", + "solana-instruction 2.3.3", + "solana-instructions-sysvar 2.2.2", + "solana-invoke", + "solana-loader-v3-interface", + "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-sdk-ids 2.2.1", + "solana-system-interface 1.0.0", + "solana-sysvar 2.3.0", + "solana-sysvar-id 2.2.1", + "thiserror 1.0.69", +] + +[[package]] +name = "anchor-lang-idl" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9101b84702fed2ea57bd22992f75065da5648017135b844283a2f6d74f27825" +checksum = "32e8599d21995f68e296265aa5ab0c3cef582fd58afec014d01bd0bce18a4418" dependencies = [ + "anchor-lang-idl-spec", "anyhow", - "bs58 0.5.0", "heck", - "proc-macro2", - "quote", "serde", "serde_json", - "sha2 0.10.8", - "syn 1.0.92", - "thiserror", -] - -[[package]] -name = "anyhow" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" - -[[package]] -name = "ark-bn254" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-std", -] - -[[package]] -name = "ark-ec" -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", - "derivative", - "hashbrown 0.13.2", - "itertools 0.10.5", - "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", - "derivative", - "digest 0.10.7", - "itertools 0.10.5", - "num-bigint", - "num-traits", - "paste", - "rustc_version 0.4.0", - "zeroize", -] - -[[package]] -name = "ark-ff-asm" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" -dependencies = [ - "quote", - "syn 1.0.92", -] - -[[package]] -name = "ark-ff-macros" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.92", + "sha2 0.10.9", ] [[package]] -name = "ark-poly" -version = "0.4.2" +name = "anchor-lang-idl-spec" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +checksum = "2bdf143115440fe621bdac3a29a1f7472e09f6cd82b2aa569429a0c13f103838" dependencies = [ - "ark-ff", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown 0.13.2", + "anyhow", + "serde", ] [[package]] -name = "ark-serialize" -version = "0.4.2" +name = "anchor-spl" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +checksum = "3397ab3fc5b198bbfe55d827ff58bd69f2a8d3f9f71c3732c23c2093fec4d3ef" dependencies = [ - "ark-serialize-derive", - "ark-std", - "digest 0.10.7", - "num-bigint", + "anchor-lang", + "spl-associated-token-account", + "spl-pod", + "spl-token", + "spl-token-2022", + "spl-token-group-interface", + "spl-token-metadata-interface", ] [[package]] -name = "ark-serialize-derive" -version = "0.4.2" +name = "anchor-syn" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +checksum = "b93b69aa7d099b59378433f6d7e20e1008fc10c69e48b220270e5b3f2ec4c8be" dependencies = [ + "anyhow", + "bs58 0.5.1", + "heck", "proc-macro2", "quote", - "syn 1.0.92", -] - -[[package]] -name = "ark-std" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" -dependencies = [ - "num-traits", - "rand 0.8.5", + "serde", + "serde_json", + "sha2 0.10.9", + "syn 1.0.109", + "thiserror 1.0.69", ] [[package]] -name = "array-bytes" -version = "1.4.1" +name = "anyhow" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad284aeb45c13f2fb4f084de4a420ebf447423bdf9386c0540ce33cb3ef4b8c" +checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] -name = "assert_matches" +name = "autocfg" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - -[[package]] -name = "autocfg" -version = "1.0.1" +name = "base16ct" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base64" @@ -410,9 +315,9 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" @@ -420,6 +325,18 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "base64" +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" @@ -431,18 +348,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitmaps" -version = "2.1.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" -dependencies = [ - "typenum", -] +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" [[package]] name = "bitvec" @@ -458,9 +366,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0" dependencies = [ "arrayref", "arrayvec", @@ -476,7 +384,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding", "generic-array", ] @@ -489,124 +396,72 @@ dependencies = [ "generic-array", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - -[[package]] -name = "borsh" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" -dependencies = [ - "borsh-derive 0.9.3", - "hashbrown 0.11.2", -] - [[package]] name = "borsh" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +checksum = "115e54d64eb62cdebad391c19efc9dce4981c690c85a33a12199d99bb9546fee" dependencies = [ - "borsh-derive 0.10.3", + "borsh-derive 0.10.4", "hashbrown 0.13.2", ] [[package]] name = "borsh" -version = "1.1.1" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e3f7359eeed8d454c38bbb25eb89d98b888b1060bbfeed2cda71cb013ff2dc2" +checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce" dependencies = [ - "borsh-derive 1.1.1", + "borsh-derive 1.5.7", "cfg_aliases", ] [[package]] name = "borsh-derive" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" -dependencies = [ - "borsh-derive-internal 0.9.3", - "borsh-schema-derive-internal 0.9.3", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.92", -] - -[[package]] -name = "borsh-derive" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +checksum = "831213f80d9423998dd696e2c5345aba6be7a0bd8cd19e31c5243e13df1cef89" dependencies = [ - "borsh-derive-internal 0.10.3", - "borsh-schema-derive-internal 0.10.3", + "borsh-derive-internal", + "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", "proc-macro2", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "borsh-derive" -version = "1.1.1" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "318d18ba283f9aa5bfef1405996ce66c584127f401be1403729ec88b10adc772" +checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3" dependencies = [ "once_cell", - "proc-macro-crate 1.2.1", + "proc-macro-crate 3.4.0", "proc-macro2", "quote", - "syn 2.0.48", - "syn_derive", + "syn 2.0.109", ] [[package]] name = "borsh-derive-internal" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.92", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.92", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.9.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" +checksum = "65d6ba50644c98714aa2a70d13d7df3cd75cd2b523a2b452bf010443800976b3" dependencies = [ "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "borsh-schema-derive-internal" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +checksum = "276691d96f063427be83e6692b86148e488ebba9f48f77788724ca027ba3b6d4" dependencies = [ "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] @@ -617,18 +472,18 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "tinyvec", ] [[package]] name = "bumpalo" -version = "3.9.1" +version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bv" @@ -642,9 +497,9 @@ dependencies = [ [[package]] name = "bytecheck" -version = "0.6.11" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" dependencies = [ "bytecheck_derive", "ptr_meta", @@ -659,79 +514,71 @@ checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.4.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" +checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.109", ] [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.2.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0b3de4a0c5e67e16066a0715723abd91edc2f9001d09c46e1dca929351e130e" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.0.83" +version = "1.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3" dependencies = [ - "jobserver", - "libc", + "find-msvc-tools", + "shlex", ] [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" - -[[package]] -name = "chrono" -version = "0.4.30" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" -dependencies = [ - "num-traits", -] +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "cipher" -version = "0.3.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ - "generic-array", + "crypto-common", + "inout", ] [[package]] @@ -754,11 +601,17 @@ 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.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "convert_case" @@ -768,140 +621,88 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cpufeatures" -version = "0.2.2" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset 0.6.5", - "once_cell", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "crunchy" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" [[package]] -name = "crypto-common" -version = "0.1.3" +name = "crypto-bigint" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57952ca27b5e3606ff4dd79b0020231aaf9d6aa76dc05fd30137538c50bd3ce8" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array", - "typenum", + "rand_core 0.6.4", + "subtle", + "zeroize", ] [[package]] -name = "crypto-mac" -version = "0.8.0" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "subtle", + "rand_core 0.6.4", + "typenum", ] [[package]] name = "ctr" -version = "0.8.0" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ "cipher", ] [[package]] name = "curve25519-dalek" -version = "3.2.1" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rand_core 0.6.4", + "rustc_version", "serde", "subtle", "zeroize", ] [[package]] -name = "darling" -version = "0.20.3" +name = "curve25519-dalek-derive" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ - "darling_core", - "darling_macro", + "proc-macro2", + "quote", + "syn 2.0.109", ] [[package]] -name = "darling_core" -version = "0.20.3" +name = "der" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.48", -] - -[[package]] -name = "darling_macro" -version = "0.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.48", + "const-oid", + "zeroize", ] [[package]] @@ -910,28 +711,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.92", -] - [[package]] name = "derive_more" -version = "0.99.18" +version = "0.99.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" dependencies = [ "convert_case", "proc-macro2", "quote", - "rustc_version 0.4.0", - "syn 2.0.48", + "rustc_version", + "syn 2.0.109", ] [[package]] @@ -950,6 +740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -961,8 +752,8 @@ dependencies = [ "anchor-lang", "anchor-spl", "arrayref", - "base64 0.13.0", - "borsh 0.10.3", + "base64 0.13.1", + "borsh 0.10.4", "bytemuck", "byteorder", "bytes", @@ -979,7 +770,7 @@ dependencies = [ "pyth-solana-receiver-sdk", "pythnet-sdk", "serum_dex", - "solana-program", + "solana-program 2.2.1", "solana-security-txt", "static_assertions", "switchboard", @@ -993,62 +784,60 @@ version = "0.1.0" source = "git+https://github.com/drift-labs/drift-macros.git?rev=c57d87#c57d87e073d13d43f4d1fb09fe6822915a4ccc11" dependencies = [ "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] -name = "ed25519" -version = "1.5.3" +name = "ecdsa" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", "signature", -] - -[[package]] -name = "ed25519-dalek" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" -dependencies = [ - "curve25519-dalek", - "ed25519", - "rand 0.7.3", - "serde", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "ed25519-dalek-bip32" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d2be62a4061b872c8c0873ee4fc6f101ce7b889d039f019c5fa2af471a59908" -dependencies = [ - "derivation-path", - "ed25519-dalek", - "hmac 0.12.1", - "sha2 0.10.8", + "spki", ] [[package]] name = "either" -version = "1.8.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "ellipsis-macros" -version = "0.1.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598d7f4a52f256bc6d065f0ee1c8dd07275952f9425bdfc1639595c924e1498e" +checksum = "06227214ab163577d89e20ac2b4646ee20fc8a243af83d79fedf16b5100c2f9f" dependencies = [ "bs58 0.4.0", "proc-macro2", "quote", "rustversion", - "solana-program", - "syn 1.0.92", + "solana-program 3.0.0", + "syn 1.0.109", +] + +[[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]] @@ -1068,21 +857,14 @@ checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce" dependencies = [ "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] -name = "env_logger" -version = "0.9.3" +name = "equivalent" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "fast-math" @@ -1099,16 +881,71 @@ 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 = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + [[package]] name = "field-offset" -version = "0.3.4" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" +dependencies = [ + "memoffset", + "rustc_version", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" + +[[package]] +name = "five8" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75b8549488b4715defcb0d8a8a1c1c76a80661b5fa106b4ca0e7fce59d7d875" +dependencies = [ + "five8_core", +] + +[[package]] +name = "five8" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f76610e969fa1784327ded240f1e28a3fd9520c9cec93b636fcf62dd37f772" +dependencies = [ + "five8_core", +] + +[[package]] +name = "five8_const" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" +checksum = "26dec3da8bc3ef08f2c04f61eab298c3ab334523e55f076354d6d6f613799a7b" dependencies = [ - "memoffset 0.6.5", - "rustc_version 0.3.3", + "five8_core", ] +[[package]] +name = "five8_core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2551bf44bc5f776c15044b9b94153a00198be06743e262afaaa61f11ac7523a5" + [[package]] name = "fnv" version = "1.0.7" @@ -1123,13 +960,13 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "generic-array" -version = "0.14.7" +version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" dependencies = [ - "serde", "typenum", "version_check", + "zeroize", ] [[package]] @@ -1139,32 +976,32 @@ 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]] name = "getrandom" -version = "0.2.9" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.11.1+wasi-snapshot-preview1", "wasm-bindgen", ] [[package]] -name = "hashbrown" -version = "0.11.2" +name = "group" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ahash 0.7.6", + "ff", + "rand_core 0.6.4", + "subtle", ] [[package]] @@ -1173,7 +1010,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.8", ] [[package]] @@ -1182,25 +1019,22 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.12", ] [[package]] -name = "heck" -version = "0.3.2" +name = "hashbrown" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" -dependencies = [ - "unicode-segmentation", -] +checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" [[package]] -name = "hermit-abi" -version = "0.1.18" +name = "heck" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ - "libc", + "unicode-segmentation", ] [[package]] @@ -1212,16 +1046,6 @@ dependencies = [ "serde", ] -[[package]] -name = "hmac" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" -dependencies = [ - "crypto-mac", - "digest 0.9.0", -] - [[package]] name = "hmac" version = "0.12.1" @@ -1231,29 +1055,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "hmac-drbg" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" -dependencies = [ - "digest 0.9.0", - "generic-array", - "hmac 0.8.1", -] - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "ieee754" version = "0.2.6" @@ -1261,19 +1062,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9007da9cacbd3e6343da136e98b0d2df013f553d35bdec8b518f07bea768e19c" [[package]] -name = "im" -version = "15.1.0" +name = "indexmap" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" +checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" dependencies = [ - "bitmaps", - "rand_core 0.6.4", - "rand_xoshiro", - "rayon", - "serde", - "sized-chunks", - "typenum", - "version_check", + "equivalent", + "hashbrown 0.16.0", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", ] [[package]] @@ -1287,9 +1091,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.10.5" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" dependencies = [ "either", ] @@ -1305,57 +1109,66 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] -name = "jobserver" -version = "0.1.26" +name = "js-sys" +version = "0.3.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" dependencies = [ - "libc", + "once_cell", + "wasm-bindgen", ] [[package]] -name = "js-sys" -version = "0.3.67" +name = "k256" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ - "wasm-bindgen", + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.9", + "signature", ] [[package]] name = "keccak" -version = "0.1.0" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lib-sokoban" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6295db13f26aaa8bb4fb38e0c9ff50253814aa490eef7b4d6aa106ba6fc843" +checksum = "1acf72a87f85040eb8128c9edbce1ec6e951caf9b07efe15a484edcd8a59e2e5" dependencies = [ "bytemuck", "num-derive 0.3.3", "num-traits", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "libc" -version = "0.2.152" +version = "0.2.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libsecp256k1" @@ -1366,14 +1179,12 @@ dependencies = [ "arrayref", "base64 0.12.3", "digest 0.9.0", - "hmac-drbg", "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", "rand 0.7.3", "serde", "sha2 0.9.9", - "typenum", ] [[package]] @@ -1407,51 +1218,30 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ "scopeguard", ] [[package]] name = "log" -version = "0.4.17" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" [[package]] name = "memchr" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" - -[[package]] -name = "memmap2" -version = "0.5.10" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -1470,9 +1260,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -1484,20 +1274,19 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ - "autocfg", "num-integer", "num-traits", ] [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] @@ -1510,35 +1299,34 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "num-derive" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.109", ] [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -1547,11 +1335,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -1559,112 +1346,61 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "num_enum" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d829733185c1ca374f17e52b762f24f535ec625d2cc1f070e34c8a9068f341b" -dependencies = [ - "num_enum_derive 0.5.11", -] - -[[package]] -name = "num_enum" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" -dependencies = [ - "num_enum_derive 0.6.1", -] - [[package]] name = "num_enum" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" -dependencies = [ - "num_enum_derive 0.7.2", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" -dependencies = [ - "proc-macro-crate 1.2.1", - "proc-macro2", - "quote", - "syn 1.0.92", -] - -[[package]] -name = "num_enum_derive" -version = "0.6.1" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" +checksum = "b1207a7e20ad57b847bbddc6776b968420d38292bbfe2089accff5e19e82454c" dependencies = [ - "proc-macro-crate 1.2.1", - "proc-macro2", - "quote", - "syn 2.0.48", + "num_enum_derive", + "rustversion", ] [[package]] name = "num_enum_derive" -version = "0.7.2" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +checksum = "ff32365de1b6743cb203b710788263c44a03de03802daf96092f2da4fe6ba4d7" dependencies = [ - "proc-macro-crate 1.2.1", + "proc-macro-crate 3.4.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.109", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openbook-v2-light" version = "0.1.0" dependencies = [ "anchor-lang", - "borsh 0.10.3", + "borsh 0.10.4", "bytemuck", ] [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", "parking_lot_core", @@ -1672,30 +1408,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.3" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", -] - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pbkdf2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" -dependencies = [ - "crypto-mac", + "windows-link", ] [[package]] @@ -1709,56 +1430,60 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - -[[package]] -name = "pest" -version = "2.1.3" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" -dependencies = [ - "ucd-trie", -] +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "phoenix-v1" version = "0.2.4" -source = "git+https://github.com/drift-labs/phoenix-v1?rev=7703c5#7703c50cf92f2bb321dcd1e2824e1c041135ec5c" +source = "git+https://github.com/jordy25519/phoenix-v1?branch=master#7a6c68775efe3b5660fc9b2695b0f2054b746ceb" dependencies = [ - "borsh 0.10.3", + "borsh 0.10.4", "bytemuck", "ellipsis-macros", - "itertools 0.10.5", + "itertools 0.12.1", "lib-sokoban", - "num_enum 0.5.9", + "num_enum", "shank", - "solana-program", + "solana-program 2.2.1", "solana-security-txt", "spl-associated-token-account", - "spl-token 3.5.0", + "spl-token", "static_assertions", - "thiserror", + "thiserror 1.0.69", ] [[package]] -name = "polyval" -version = "0.5.3" +name = "pkcs8" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "cfg-if", - "cpufeatures", + "der", + "spki", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures", "opaque-debug", "universal-hash", ] [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro-crate" @@ -1771,43 +1496,18 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" -dependencies = [ - "once_cell", - "thiserror", - "toml", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "proc-macro2", - "quote", - "version_check", + "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] @@ -1829,7 +1529,7 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] @@ -1849,7 +1549,7 @@ checksum = "44de48029c54ec1ca570786b5baeb906b0fc2409c8e0145585e287ee7a526c72" [[package]] name = "pyth-lazer-protocol" version = "0.1.2" -source = "git+https://github.com/drift-labs/pyth-crosschain?rev=d790d1cb4da873a949cf33ff70349b7614b232eb#d790d1cb4da873a949cf33ff70349b7614b232eb" +source = "git+https://github.com/jordy25519/pyth-crosschain?branch=master#688cc38cdcd6976d72db7a63bd75da73d8248804" dependencies = [ "anyhow", "byteorder", @@ -1862,46 +1562,46 @@ dependencies = [ [[package]] name = "pyth-lazer-solana-contract" version = "0.2.0" -source = "git+https://github.com/drift-labs/pyth-crosschain?rev=d790d1cb4da873a949cf33ff70349b7614b232eb#d790d1cb4da873a949cf33ff70349b7614b232eb" +source = "git+https://github.com/jordy25519/pyth-crosschain?branch=master#688cc38cdcd6976d72db7a63bd75da73d8248804" dependencies = [ "anchor-lang", "bytemuck", "byteorder", "pyth-lazer-protocol", - "solana-program", - "thiserror", + "solana-program 2.2.1", + "thiserror 1.0.69", ] [[package]] name = "pyth-solana-receiver-sdk" version = "0.3.0" -source = "git+https://github.com/drift-labs/pyth-crosschain?rev=d790d1cb4da873a949cf33ff70349b7614b232eb#d790d1cb4da873a949cf33ff70349b7614b232eb" +source = "git+https://github.com/jordy25519/pyth-crosschain?branch=master#688cc38cdcd6976d72db7a63bd75da73d8248804" dependencies = [ "anchor-lang", "hex", "pythnet-sdk", - "solana-program", + "solana-program 2.2.1", ] [[package]] name = "pythnet-sdk" version = "2.1.0" -source = "git+https://github.com/drift-labs/pyth-crosschain?rev=d790d1cb4da873a949cf33ff70349b7614b232eb#d790d1cb4da873a949cf33ff70349b7614b232eb" +source = "git+https://github.com/jordy25519/pyth-crosschain?branch=master#688cc38cdcd6976d72db7a63bd75da73d8248804" dependencies = [ "anchor-lang", "bincode", - "borsh 0.10.3", + "borsh 0.10.4", "bytemuck", "byteorder", "fast-math", "hex", "proc-macro2", - "rustc_version 0.4.0", + "rustc_version", "serde", - "sha3 0.10.4", + "sha3", "slow_primes", - "solana-program", - "thiserror", + "solana-program 2.2.1", + "thiserror 1.0.69", ] [[package]] @@ -1915,9 +1615,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] @@ -1987,7 +1687,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.16", ] [[package]] @@ -1999,82 +1699,43 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_xoshiro" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" -dependencies = [ - "rand_core 0.6.4", -] - -[[package]] -name = "rayon" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" -dependencies = [ - "autocfg", - "crossbeam-deque", - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ "bitflags", ] [[package]] -name = "regex" -version = "1.5.4" +name = "rend" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "bytecheck", ] [[package]] -name = "regex-syntax" -version = "0.6.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" - -[[package]] -name = "rend" -version = "0.4.2" +name = "rfc6979" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "bytecheck", + "hmac", + "subtle", ] [[package]] name = "rkyv" -version = "0.7.42" +version = "0.7.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b" dependencies = [ "bitvec", "bytecheck", + "bytes", "hashbrown 0.12.3", "ptr_meta", "rend", @@ -2092,17 +1753,17 @@ checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0" dependencies = [ "proc-macro2", "quote", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] name = "rust_decimal" -version = "1.36.0" +version = "1.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b082d80e3e3cc52b2ed634388d436fe1f4de6af5786cc2de9ba9737527bdf555" +checksum = "35affe401787a9bd846712274d97654355d21b2a2c092a3139aabe31e9022282" dependencies = [ "arrayvec", - "borsh 1.1.1", + "borsh 1.5.7", "bytes", "num-traits", "rand 0.8.5", @@ -2111,53 +1772,38 @@ dependencies = [ "serde_json", ] -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc_version" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" -dependencies = [ - "semver 0.11.0", -] - [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "semver 1.0.18", + "semver", ] [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "safe-transmute" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98a01dab6acf992653be49205bdd549f32f17cb2803e8eacf1560bf97259aae8" +checksum = "3944826ff8fa8093089aba3acb4ef44b9446a99a16f3bf4e74af3f77d340ab7d" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "seahash" @@ -2166,95 +1812,82 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] -name = "semver" -version = "0.11.0" +name = "sec1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "semver-parser", + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", ] [[package]] name = "semver" -version = "1.0.18" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] -name = "semver-parser" -version = "0.10.2" +name = "serde" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ - "pest", + "serde_core", + "serde_derive", ] [[package]] -name = "serde" -version = "1.0.209" +name = "serde_bytes" +version = "0.11.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8" dependencies = [ - "serde_derive", + "serde", + "serde_core", ] [[package]] -name = "serde_bytes" -version = "0.11.14" +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ - "serde", + "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.109", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", + "memchr", "ryu", "serde", -] - -[[package]] -name = "serde_with" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" -dependencies = [ - "serde", - "serde_with_macros", -] - -[[package]] -name = "serde_with_macros" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.48", + "serde_core", ] [[package]] name = "serum_dex" version = "0.5.6" -source = "git+https://github.com/project-serum/serum-dex?rev=85b4f14#85b4f1499017f22da4b355781bdb5973b3b2646f" +source = "git+https://github.com/jordy25519/serum-dex?branch=master#2347e4810ace967ab186202e22b6188b9cab03ba" dependencies = [ "arrayref", "bincode", @@ -2264,13 +1897,13 @@ dependencies = [ "field-offset", "itertools 0.9.0", "num-traits", - "num_enum 0.5.9", + "num_enum", "safe-transmute", "serde", - "solana-program", - "spl-token 3.5.0", + "solana-program 2.2.1", + "spl-token", "static_assertions", - "thiserror", + "thiserror 1.0.69", "without-alloc", ] @@ -2289,9 +1922,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.8" +version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", "cpufeatures", @@ -2300,21 +1933,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" -dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", - "keccak", - "opaque-debug", -] - -[[package]] -name = "sha3" -version = "0.10.4" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaedf34ed289ea47c2b741bb72e5357a209512d67bcd4bda44359e5bf0470f56" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ "digest 0.10.7", "keccak", @@ -2339,7 +1960,7 @@ dependencies = [ "quote", "shank_macro_impl", "shank_render", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] @@ -2352,7 +1973,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 1.0.92", + "syn 1.0.109", ] [[package]] @@ -2366,11 +1987,21 @@ dependencies = [ "shank_macro_impl", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" -version = "1.6.4" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] [[package]] name = "simdutf8" @@ -2378,16 +2009,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" -[[package]] -name = "sized-chunks" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" -dependencies = [ - "bitmaps", - "typenum", -] - [[package]] name = "slow_primes" version = "0.1.14" @@ -2399,427 +2020,1921 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.8.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] -name = "solana-frozen-abi" -version = "1.16.25" +name = "solana-account" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7077f6495ccc313dff49c3e3f3ed03e49058258bae7fee77ac29ba0a474ba82" +checksum = "0f949fe4edaeaea78c844023bfc1c898e0b1f5a100f8a8d2d0f85d0a7b090258" dependencies = [ - "ahash 0.8.6", - "blake3", - "block-buffer 0.10.4", - "bs58 0.4.0", - "bv", - "byteorder", - "cc", - "either", - "generic-array", - "getrandom 0.1.16", - "im", - "lazy_static", - "log", - "memmap2", - "once_cell", - "rand_core 0.6.4", - "rustc_version 0.4.0", - "serde", - "serde_bytes", - "serde_derive", - "serde_json", - "sha2 0.10.8", - "solana-frozen-abi-macro", - "subtle", - "thiserror", + "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", ] [[package]] -name = "solana-frozen-abi-macro" -version = "1.16.25" +name = "solana-account-info" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f516f992211a2ab70de5c367190575c97e02d156f9f1d8b76886d673f30e88a2" +checksum = "c8f5152a288ef1912300fc6efa6c2d1f9bb55d9398eb6c72326360b8063987da" dependencies = [ - "proc-macro2", - "quote", - "rustc_version 0.4.0", - "syn 2.0.48", + "bincode", + "serde", + "solana-program-error 2.2.2", + "solana-program-memory 2.3.1", + "solana-pubkey 2.4.0", ] [[package]] -name = "solana-logger" -version = "1.16.25" +name = "solana-account-info" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b64def674bfaa4a3f8be7ba19c03c9caec4ec028ba62b9a427ec1bf608a2486" +checksum = "82f4691b69b172c687d218dd2f1f23fc7ea5e9aa79df9ac26dab3d8dd829ce48" dependencies = [ - "env_logger", - "lazy_static", - "log", + "bincode", + "serde", + "solana-program-error 3.0.0", + "solana-program-memory 3.0.0", + "solana-pubkey 3.0.0", ] [[package]] -name = "solana-program" -version = "1.16.25" +name = "solana-address" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e92350aa5b42564681655331e7e0b9d5c99a442de317ceeb4741efbbe9a6c05" +checksum = "0a7a457086457ea9db9a5199d719dc8734dc2d0342fad0d8f77633c31eb62f19" dependencies = [ - "ark-bn254", - "ark-ec", - "ark-ff", - "ark-serialize", - "array-bytes", - "base64 0.21.7", - "bincode", - "bitflags", - "blake3", - "borsh 0.10.3", - "borsh 0.9.3", - "bs58 0.4.0", - "bv", + "borsh 1.5.7", "bytemuck", - "cc", - "console_error_panic_hook", - "console_log", + "bytemuck_derive", "curve25519-dalek", - "getrandom 0.2.9", - "itertools 0.10.5", - "js-sys", - "lazy_static", - "libc", - "libsecp256k1", - "log", - "memoffset 0.9.0", - "num-bigint", - "num-derive 0.3.3", - "num-traits", - "parking_lot", - "rand 0.7.3", - "rand_chacha 0.2.2", - "rustc_version 0.4.0", - "rustversion", + "five8 0.2.1", + "five8_const", "serde", - "serde_bytes", "serde_derive", - "serde_json", - "sha2 0.10.8", - "sha3 0.10.4", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-sdk-macro", - "thiserror", - "tiny-bip39", - "wasm-bindgen", - "zeroize", + "solana-atomic-u64 3.0.0", + "solana-define-syscall 3.0.0", + "solana-program-error 3.0.0", + "solana-sanitize 3.0.1", + "solana-sha256-hasher 3.0.1", ] [[package]] -name = "solana-sdk" -version = "1.16.25" +name = "solana-address-lookup-table-interface" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2087e15c92d4d6b3f085dc12fbe9614141c811f90a54cc418240ac30b608133f" +checksum = "d1673f67efe870b64a65cb39e6194be5b26527691ce5922909939961a6e6b395" dependencies = [ - "assert_matches", - "base64 0.21.7", "bincode", - "bitflags", - "borsh 0.10.3", - "bs58 0.4.0", "bytemuck", - "byteorder", - "chrono", - "derivation-path", - "digest 0.10.7", - "ed25519-dalek", - "ed25519-dalek-bip32", - "generic-array", - "hmac 0.12.1", - "itertools 0.10.5", - "js-sys", - "lazy_static", - "libsecp256k1", - "log", - "memmap2", - "num-derive 0.3.3", - "num-traits", - "num_enum 0.6.1", - "pbkdf2 0.11.0", - "qstring", - "rand 0.7.3", - "rand_chacha 0.2.2", - "rustc_version 0.4.0", - "rustversion", "serde", - "serde_bytes", "serde_derive", - "serde_json", - "serde_with", - "sha2 0.10.8", - "sha3 0.10.4", - "solana-frozen-abi", - "solana-frozen-abi-macro", - "solana-logger", - "solana-program", - "solana-sdk-macro", - "thiserror", - "uriparse", - "wasm-bindgen", + "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-sdk-macro" -version = "1.16.25" +name = "solana-address-lookup-table-interface" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0e0e7ee984b0f9179a1d4f4e9e67ce675de2324b5a98b61d2bdb61be3c19bb" +checksum = "e2f56cac5e70517a2f27d05e5100b20de7182473ffd0035b23ea273307905987" dependencies = [ - "bs58 0.4.0", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.48", + "solana-clock 3.0.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.0.0", + "solana-slot-hashes 3.0.0", ] [[package]] -name = "solana-security-txt" -version = "1.1.0" +name = "solana-atomic-u64" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0461f3afb29d8591300b3dd09b5472b3772d65688a2826ad960b8c0d5fa605" +checksum = "d52e52720efe60465b052b9e7445a01c17550666beec855cce66f44766697bc2" +dependencies = [ + "parking_lot", +] [[package]] -name = "solana-zk-token-sdk" -version = "1.16.25" +name = "solana-atomic-u64" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1457c85ab70a518438b9ac2b0c56037b9f6693060dfb617bbb93c7116e4f0c22" +checksum = "a933ff1e50aff72d02173cfcd7511bd8540b027ee720b75f353f594f834216d0" dependencies = [ - "aes-gcm-siv", - "base64 0.21.7", - "bincode", - "bytemuck", - "byteorder", - "curve25519-dalek", - "getrandom 0.1.16", - "itertools 0.10.5", - "lazy_static", - "merlin", - "num-derive 0.3.3", - "num-traits", - "rand 0.7.3", - "serde", - "serde_json", - "sha3 0.9.1", - "solana-program", - "solana-sdk", - "subtle", - "thiserror", - "zeroize", + "parking_lot", ] [[package]] -name = "spl-associated-token-account" -version = "2.2.0" +name = "solana-big-mod-exp" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385e31c29981488f2820b2022d8e731aae3b02e6e18e2fd854e4c9a94dc44fc3" +checksum = "75db7f2bbac3e62cfd139065d15bcda9e2428883ba61fc8d27ccb251081e7567" dependencies = [ - "assert_matches", - "borsh 0.10.3", - "num-derive 0.4.1", + "num-bigint", "num-traits", - "solana-program", - "spl-token 4.0.0", - "spl-token-2022", - "thiserror", + "solana-define-syscall 2.3.0", ] [[package]] -name = "spl-discriminator" -version = "0.1.0" +name = "solana-big-mod-exp" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30c80fb6d791b3925d5ec4bf23a7c169ef5090c013059ec3ed7d0b2c04efa085" +dependencies = [ + "num-bigint", + "num-traits", + "solana-define-syscall 3.0.0", +] + +[[package]] +name = "solana-bincode" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19a3787b8cf9c9fe3dd360800e8b70982b9e5a8af9e11c354b6665dd4a003adc" +dependencies = [ + "bincode", + "serde", + "solana-instruction 2.3.3", +] + +[[package]] +name = "solana-blake3-hasher" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a0801e25a1b31a14494fc80882a036be0ffd290efc4c2d640bfcca120a4672" +dependencies = [ + "blake3", + "solana-define-syscall 2.3.0", + "solana-hash 2.3.0", + "solana-sanitize 2.2.1", +] + +[[package]] +name = "solana-blake3-hasher" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffa2e3bdac3339c6d0423275e45dafc5ac25f4d43bf344d026a3cc9a85e244a6" +dependencies = [ + "blake3", + "solana-define-syscall 3.0.0", + "solana-hash 3.1.0", +] + +[[package]] +name = "solana-borsh" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "718333bcd0a1a7aed6655aa66bef8d7fb047944922b2d3a18f49cbc13e73d004" +dependencies = [ + "borsh 0.10.4", + "borsh 1.5.7", +] + +[[package]] +name = "solana-borsh" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc402b16657abbfa9991cd5cbfac5a11d809f7e7d28d3bb291baeb088b39060e" +dependencies = [ + "borsh 1.5.7", +] + +[[package]] +name = "solana-clock" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bb482ab70fced82ad3d7d3d87be33d466a3498eb8aa856434ff3c0dfc2e2e31" +dependencies = [ + "serde", + "serde_derive", + "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.0.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.0.0", +] + +[[package]] +name = "solana-cpi" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc71126edddc2ba014622fc32d0f5e2e78ec6c5a1e0eb511b85618c09e9ea11" +dependencies = [ + "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.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16238feb63d1cbdf915fb287f29ef7a7ebf81469bd6214f8b72a53866b593f8f" +dependencies = [ + "solana-account-info 3.0.0", + "solana-define-syscall 3.0.0", + "solana-instruction 3.0.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.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", + "solana-define-syscall 2.3.0", + "subtle", + "thiserror 2.0.17", +] + +[[package]] +name = "solana-decode-error" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c781686a18db2f942e70913f7ca15dc120ec38dcab42ff7557db2c70c625a35" +dependencies = [ + "num-traits", +] + +[[package]] +name = "solana-define-syscall" +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-derivation-path" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939756d798b25c5ec3cca10e06212bdca3b1443cb9bb740a38124f58b258737b" +dependencies = [ + "derivation-path", + "qstring", + "uriparse", +] + +[[package]] +name = "solana-epoch-rewards" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b575d3dd323b9ea10bb6fe89bf6bf93e249b215ba8ed7f68f1a3633f384db7" +dependencies = [ + "serde", + "serde_derive", + "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.0.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.0.0", +] + +[[package]] +name = "solana-epoch-schedule" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fce071fbddecc55d727b1d7ed16a629afe4f6e4c217bc8d00af3b785f6f67ed" +dependencies = [ + "serde", + "serde_derive", + "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.0.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.0.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]] +name = "solana-example-mocks" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84461d56cbb8bb8d539347151e0525b53910102e4bced875d49d5139708e39d3" +dependencies = [ + "serde", + "serde_derive", + "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.0.0", + "solana-keccak-hasher 3.0.0", + "solana-message 3.0.1", + "solana-nonce 3.0.0", + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.0.0", + "solana-system-interface 2.0.0", + "thiserror 2.0.17", +] + +[[package]] +name = "solana-feature-gate-interface" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f5c5382b449e8e4e3016fb05e418c53d57782d8b5c30aa372fc265654b956d" +dependencies = [ + "bincode", + "serde", + "serde_derive", + "solana-account", + "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-fee-calculator" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89bc408da0fb3812bc3008189d148b4d3e08252c79ad810b245482a3f70cd8d" +dependencies = [ + "log", + "serde", + "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-hash" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b96e9f0300fa287b545613f007dfe20043d7812bee255f418c1eb649c93b63" +dependencies = [ + "borsh 1.5.7", + "bytemuck", + "bytemuck_derive", + "five8 0.2.1", + "js-sys", + "serde", + "serde_derive", + "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.5.7", + "bytemuck", + "bytemuck_derive", + "five8 1.0.0", + "serde", + "serde_derive", + "solana-atomic-u64 3.0.0", + "solana-sanitize 3.0.1", +] + +[[package]] +name = "solana-instruction" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab5682934bd1f65f8d2c16f21cb532526fcc1a09f796e2cacdb091eee5774ad" +dependencies = [ + "bincode", + "borsh 1.5.7", + "getrandom 0.2.16", + "js-sys", + "num-traits", + "serde", + "serde_derive", + "serde_json", + "solana-define-syscall 2.3.0", + "solana-pubkey 2.4.0", + "wasm-bindgen", +] + +[[package]] +name = "solana-instruction" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df4e8fcba01d7efa647ed20a081c234475df5e11a93acb4393cc2c9a7b99bab" +dependencies = [ + "bincode", + "borsh 1.5.7", + "serde", + "serde_derive", + "solana-define-syscall 3.0.0", + "solana-instruction-error", + "solana-pubkey 3.0.0", +] + +[[package]] +name = "solana-instruction-error" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f0d483b8ae387178d9210e0575b666b05cdd4bd0f2f188128249f6e454d39d" +dependencies = [ + "num-traits", + "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", + "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", + "solana-account-info 3.0.0", + "solana-instruction 3.0.0", + "solana-instruction-error", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", + "solana-sanitize 3.0.1", + "solana-sdk-ids 3.0.0", + "solana-serialize-utils 3.1.0", + "solana-sysvar-id 3.0.0", +] + +[[package]] +name = "solana-invoke" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f5693c6de226b3626658377168b0184e94e8292ff16e3d31d4766e65627565" +dependencies = [ + "solana-account-info 2.3.0", + "solana-define-syscall 2.3.0", + "solana-instruction 2.3.3", + "solana-program-entrypoint 2.3.0", + "solana-stable-layout 2.2.1", +] + +[[package]] +name = "solana-keccak-hasher" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7aeb957fbd42a451b99235df4942d96db7ef678e8d5061ef34c9b34cae12f79" +dependencies = [ + "sha3", + "solana-define-syscall 2.3.0", + "solana-hash 2.3.0", + "solana-sanitize 2.2.1", +] + +[[package]] +name = "solana-keccak-hasher" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57eebd3012946913c8c1b8b43cdf8a6249edb09c0b6be3604ae910332a3acd97" +dependencies = [ + "sha3", + "solana-define-syscall 3.0.0", + "solana-hash 3.1.0", +] + +[[package]] +name = "solana-last-restart-slot" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6360ac2fdc72e7463565cd256eedcf10d7ef0c28a1249d261ec168c1b55cdd" +dependencies = [ + "serde", + "serde_derive", + "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.0.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.0.0", +] + +[[package]] +name = "solana-loader-v2-interface" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8ab08006dad78ae7cd30df8eea0539e207d08d91eaefb3e1d49a446e1c49654" +dependencies = [ + "serde", + "serde_bytes", + "serde_derive", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", +] + +[[package]] +name = "solana-loader-v3-interface" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4be76cfa9afd84ca2f35ebc09f0da0f0092935ccdac0595d98447f259538c2" +dependencies = [ + "serde", + "serde_bytes", + "serde_derive", + "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 = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "706a777242f1f39a83e2a96a2a6cb034cb41169c6ecbee2cf09cb873d9659e7e" +dependencies = [ + "serde", + "serde_bytes", + "serde_derive", + "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-message" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1796aabce376ff74bf89b78d268fa5e683d7d7a96a0a4e4813ec34de49d5314b" +dependencies = [ + "bincode", + "blake3", + "lazy_static", + "serde", + "serde_derive", + "solana-bincode", + "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 = [ + "lazy_static", + "serde", + "serde_derive", + "solana-address", + "solana-hash 3.1.0", + "solana-instruction 3.0.0", + "solana-sanitize 3.0.1", + "solana-sdk-ids 3.0.0", + "solana-short-vec 3.0.0", + "solana-transaction-error 3.0.0", +] + +[[package]] +name = "solana-msg" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36a1a14399afaabc2781a1db09cb14ee4cc4ee5c7a5a3cfcc601811379a8092" +dependencies = [ + "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]] +name = "solana-native-token" +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-nonce" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703e22eb185537e06204a5bd9d509b948f0066f2d1d814a6f475dafb3ddf1325" +dependencies = [ + "serde", + "serde_derive", + "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 = [ + "solana-fee-calculator 3.0.0", + "solana-hash 3.1.0", + "solana-pubkey 3.0.0", + "solana-sha256-hasher 3.0.1", +] + +[[package]] +name = "solana-program" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "586469467e93ceb79048f8d8e3a619bf61d05396ee7de95cb40280301a589d05" +dependencies = [ + "bincode", + "blake3", + "borsh 0.10.4", + "borsh 1.5.7", + "bs58 0.5.1", + "bytemuck", + "console_error_panic_hook", + "console_log", + "getrandom 0.2.16", + "lazy_static", + "log", + "memoffset", + "num-bigint", + "num-derive 0.4.2", + "num-traits", + "rand 0.8.5", + "serde", + "serde_bytes", + "serde_derive", + "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", + "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 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", + "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", + "solana-loader-v3-interface", + "solana-loader-v4-interface", + "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", + "solana-system-interface 1.0.0", + "solana-sysvar 2.3.0", + "solana-sysvar-id 2.2.1", + "solana-vote-interface", + "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.0.0", + "solana-big-mod-exp 3.0.0", + "solana-blake3-hasher 3.0.0", + "solana-borsh 3.0.0", + "solana-clock 3.0.0", + "solana-cpi 3.0.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.0.0", + "solana-instruction-error", + "solana-instructions-sysvar 3.0.0", + "solana-keccak-hasher 3.0.0", + "solana-last-restart-slot 3.0.0", + "solana-msg 3.0.0", + "solana-native-token 3.0.0", + "solana-program-entrypoint 3.1.0", + "solana-program-error 3.0.0", + "solana-program-memory 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.0.0", + "solana-secp256k1-recover 3.0.0", + "solana-serde-varint 3.0.0", + "solana-serialize-utils 3.1.0", + "solana-sha256-hasher 3.0.1", + "solana-short-vec 3.0.0", + "solana-slot-hashes 3.0.0", + "solana-slot-history 3.0.0", + "solana-stable-layout 3.0.0", + "solana-sysvar 3.0.0", + "solana-sysvar-id 3.0.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 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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6557cf5b5e91745d1667447438a1baa7823c6086e4ece67f8e6ebfa7a8f72660" +dependencies = [ + "solana-account-info 3.0.0", + "solana-define-syscall 3.0.0", + "solana-msg 3.0.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", +] + +[[package]] +name = "solana-program-error" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ee2e0217d642e2ea4bee237f37bd61bb02aec60da3647c48ff88f6556ade775" +dependencies = [ + "borsh 1.5.7", + "num-traits", + "serde", + "serde_derive", + "solana-decode-error", + "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.5.7", + "serde", + "serde_derive", +] + +[[package]] +name = "solana-program-memory" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a5426090c6f3fd6cfdc10685322fede9ca8e5af43cd6a59e98bfe4e91671712" +dependencies = [ + "solana-define-syscall 2.3.0", +] + +[[package]] +name = "solana-program-memory" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10e5660c60749c7bfb30b447542529758e4dbcecd31b1e8af1fdc92e2bdde90a" +dependencies = [ + "solana-define-syscall 3.0.0", +] + +[[package]] +name = "solana-program-option" +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 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-pubkey" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b62adb9c3261a052ca1f999398c388f1daf558a1b492f60a6d9e64857db4ff1" +dependencies = [ + "borsh 0.10.4", + "borsh 1.5.7", + "bytemuck", + "bytemuck_derive", + "curve25519-dalek", + "five8 0.2.1", + "five8_const", + "getrandom 0.2.16", + "js-sys", + "num-traits", + "serde", + "serde_derive", + "solana-atomic-u64 2.2.1", + "solana-decode-error", + "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 = [ + "solana-address", +] + +[[package]] +name = "solana-rent" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1aea8fdea9de98ca6e8c2da5827707fb3842833521b528a713810ca685d2480" +dependencies = [ + "serde", + "serde_derive", + "solana-sdk-ids 2.2.1", + "solana-sdk-macro 2.2.1", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-rent" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b702d8c43711e3c8a9284a4f1bbc6a3de2553deb25b0c8142f9a44ef0ce5ddc1" +dependencies = [ + "serde", + "serde_derive", + "solana-sdk-ids 3.0.0", + "solana-sdk-macro 3.0.0", + "solana-sysvar-id 3.0.0", +] + +[[package]] +name = "solana-sanitize" +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-sdk-ids" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5d8b9cc68d5c88b062a33e23a6466722467dde0035152d8fb1afbcdf350a5f" +dependencies = [ + "solana-pubkey 2.4.0", +] + +[[package]] +name = "solana-sdk-ids" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1b6d6aaf60669c592838d382266b173881c65fb1cdec83b37cb8ce7cb89f9ad" +dependencies = [ + "solana-pubkey 3.0.0", +] + +[[package]] +name = "solana-sdk-macro" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86280da8b99d03560f6ab5aca9de2e38805681df34e0bb8f238e69b29433b9df" +dependencies = [ + "bs58 0.5.1", + "proc-macro2", + "quote", + "syn 2.0.109", +] + +[[package]] +name = "solana-sdk-macro" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6430000e97083460b71d9fbadc52a2ab2f88f53b3a4c5e58c5ae3640a0e8c00" +dependencies = [ + "bs58 0.5.1", + "proc-macro2", + "quote", + "syn 2.0.109", +] + +[[package]] +name = "solana-secp256k1-recover" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa3120b6cdaa270f39444f5093a90a7b03d296d362878f7a6991d6de3bbe496" +dependencies = [ + "libsecp256k1", + "solana-define-syscall 2.3.0", + "thiserror 2.0.17", +] + +[[package]] +name = "solana-secp256k1-recover" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "394a4470477d66296af5217970a905b1c5569032a7732c367fb69e5666c8607e" +dependencies = [ + "k256", + "solana-define-syscall 3.0.0", + "thiserror 2.0.17", +] + +[[package]] +name = "solana-security-txt" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "468aa43b7edb1f9b7b7b686d5c3aeb6630dc1708e86e31343499dd5c4d775183" + +[[package]] +name = "solana-seed-derivable" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beb82b5adb266c6ea90e5cf3967235644848eac476c5a1f2f9283a143b7c97f" +dependencies = [ + "solana-derivation-path", +] + +[[package]] +name = "solana-seed-phrase" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36187af2324f079f65a675ec22b31c24919cb4ac22c79472e85d819db9bbbc15" +dependencies = [ + "hmac", + "pbkdf2", + "sha2 0.10.9", +] + +[[package]] +name = "solana-serde-varint" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a7e155eba458ecfb0107b98236088c3764a09ddf0201ec29e52a0be40857113" +dependencies = [ + "serde", +] + +[[package]] +name = "solana-serde-varint" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e5174c57d5ff3c1995f274d17156964664566e2cde18a07bba1586d35a70d3b" +dependencies = [ + "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]] +name = "solana-sha256-hasher" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa3feb32c28765f6aa1ce8f3feac30936f16c5c3f7eb73d63a5b8f6f8ecdc44" +dependencies = [ + "sha2 0.10.9", + "solana-define-syscall 2.3.0", + "solana-hash 2.3.0", +] + +[[package]] +name = "solana-sha256-hasher" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ab77481366a966f895abbc11896d4803d285d258281a992ca89aca3ed0658c" +dependencies = [ + "sha2 0.10.9", + "solana-define-syscall 3.0.0", + "solana-hash 3.1.0", +] + +[[package]] +name = "solana-short-vec" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c54c66f19b9766a56fa0057d060de8378676cb64987533fa088861858fc5a69" +dependencies = [ + "serde", +] + +[[package]] +name = "solana-short-vec" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b69d029da5428fc1c57f7d49101b2077c61f049d4112cd5fb8456567cc7d2638" +dependencies = [ + "serde", +] + +[[package]] +name = "solana-signature" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c8ec8e657aecfc187522fc67495142c12f35e55ddeca8698edbb738b8dbd8c" +dependencies = [ + "five8 0.2.1", + "solana-sanitize 2.2.1", +] + +[[package]] +name = "solana-signer" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c41991508a4b02f021c1342ba00bcfa098630b213726ceadc7cb032e051975b" +dependencies = [ + "solana-pubkey 2.4.0", + "solana-signature", + "solana-transaction-error 2.2.1", +] + +[[package]] +name = "solana-slot-hashes" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c8691982114513763e88d04094c9caa0376b867a29577939011331134c301ce" +dependencies = [ + "serde", + "serde_derive", + "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.0.0", + "solana-sysvar-id 3.0.0", +] + +[[package]] +name = "solana-slot-history" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97ccc1b2067ca22754d5283afb2b0126d61eae734fc616d23871b0943b0d935e" +dependencies = [ + "bv", + "serde", + "serde_derive", + "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.0.0", + "solana-sysvar-id 3.0.0", +] + +[[package]] +name = "solana-stable-layout" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f14f7d02af8f2bc1b5efeeae71bc1c2b7f0f65cd75bcc7d8180f2c762a57f54" +dependencies = [ + "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.0.0", + "solana-pubkey 3.0.0", +] + +[[package]] +name = "solana-stake-interface" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5269e89fde216b4d7e1d1739cf5303f8398a1ff372a81232abbee80e554a838c" +dependencies = [ + "borsh 0.10.4", + "borsh 1.5.7", + "num-traits", + "serde", + "serde_derive", + "solana-clock 2.2.2", + "solana-cpi 2.2.1", + "solana-decode-error", + "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-system-interface" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94d7c18cb1a91c6be5f5a8ac9276a1d7c737e39a21beba9ea710ab4b9c63bc90" +dependencies = [ + "js-sys", + "num-traits", + "serde", + "serde_derive", + "solana-decode-error", + "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", + "solana-msg 3.0.0", + "solana-program-error 3.0.0", + "solana-pubkey 3.0.0", +] + +[[package]] +name = "solana-sysvar" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c3595f95069f3d90f275bb9bd235a1973c4d059028b0a7f81baca2703815db" +dependencies = [ + "base64 0.22.1", + "bincode", + "bytemuck", + "bytemuck_derive", + "lazy_static", + "serde", + "serde_derive", + "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", + "solana-sysvar-id 2.2.1", +] + +[[package]] +name = "solana-sysvar" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63205e68d680bcc315337dec311b616ab32fea0a612db3b883ce4de02e0953f9" +dependencies = [ + "base64 0.22.1", + "bincode", + "bytemuck", + "bytemuck_derive", + "lazy_static", + "serde", + "serde_derive", + "solana-account-info 3.0.0", + "solana-clock 3.0.0", + "solana-define-syscall 3.0.0", + "solana-epoch-rewards 3.0.0", + "solana-epoch-schedule 3.0.0", + "solana-fee-calculator 3.0.0", + "solana-hash 3.1.0", + "solana-instruction 3.0.0", + "solana-last-restart-slot 3.0.0", + "solana-program-entrypoint 3.1.0", + "solana-program-error 3.0.0", + "solana-program-memory 3.0.0", + "solana-pubkey 3.0.0", + "solana-rent 3.0.0", + "solana-sdk-ids 3.0.0", + "solana-sdk-macro 3.0.0", + "solana-slot-hashes 3.0.0", + "solana-slot-history 3.0.0", + "solana-sysvar-id 3.0.0", +] + +[[package]] +name = "solana-sysvar-id" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5762b273d3325b047cfda250787f8d796d781746860d5d0a746ee29f3e8812c1" +dependencies = [ + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", +] + +[[package]] +name = "solana-sysvar-id" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5051bc1a16d5d96a96bc33b5b2ec707495c48fe978097bdaba68d3c47987eb32" +dependencies = [ + "solana-pubkey 3.0.0", + "solana-sdk-ids 3.0.0", +] + +[[package]] +name = "solana-transaction-error" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a9dc8fdb61c6088baab34fc3a8b8473a03a7a5fd404ed8dd502fa79b67cb1" +dependencies = [ + "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 = [ + "solana-instruction-error", + "solana-sanitize 3.0.1", +] + +[[package]] +name = "solana-vote-interface" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b80d57478d6599d30acc31cc5ae7f93ec2361a06aefe8ea79bc81739a08af4c3" +dependencies = [ + "bincode", + "num-derive 0.4.2", + "num-traits", + "serde", + "serde_derive", + "solana-clock 2.2.2", + "solana-decode-error", + "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-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", + "itertools 0.12.1", + "js-sys", + "merlin", + "num-derive 0.4.2", + "num-traits", + "rand 0.8.5", + "serde", + "serde_derive", + "serde_json", + "sha3", + "solana-derivation-path", + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", + "solana-sdk-ids 2.2.1", + "solana-seed-derivable", + "solana-seed-phrase", + "solana-signature", + "solana-signer", + "subtle", + "thiserror 2.0.17", + "wasm-bindgen", + "zeroize", +] + +[[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", + "num-derive 0.4.2", + "num-traits", + "solana-program 2.2.1", + "spl-associated-token-account-client", + "spl-token", + "spl-token-2022", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-associated-token-account-client" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f8349dbcbe575f354f9a533a21f272f3eb3808a49e2fdc1c34393b88ba76cb" +dependencies = [ + "solana-instruction 2.3.3", + "solana-pubkey 2.4.0", +] + +[[package]] +name = "spl-discriminator" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cce5d563b58ef1bb2cdbbfe0dfb9ffdc24903b10ae6a4df2d8f425ece375033f" +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-derive" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadbefec4f3c678215ca72bd71862697bb06b41fd77c0088902dd3203354387b" +checksum = "d9e8418ea6269dcfb01c712f0444d2c75542c04448b480e87de59d2865edc750" dependencies = [ "quote", "spl-discriminator-syn", - "syn 2.0.48", + "syn 2.0.109", ] [[package]] name = "spl-discriminator-syn" -version = "0.1.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e5f2044ca42c8938d54d1255ce599c79a1ffd86b677dfab695caa20f9ffc3f2" +checksum = "5d1dbc82ab91422345b6df40a79e2b78c7bce1ebb366da323572dd60b7076b67" dependencies = [ "proc-macro2", "quote", - "sha2 0.10.8", - "syn 2.0.48", - "thiserror", + "sha2 0.10.9", + "syn 2.0.109", + "thiserror 1.0.69", +] + +[[package]] +name = "spl-elgamal-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65edfeed09cd4231e595616aa96022214f9c9d2be02dea62c2b30d5695a6833a" +dependencies = [ + "bytemuck", + "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", + "spl-pod", + "spl-token-confidential-transfer-proof-extraction", ] [[package]] name = "spl-memo" -version = "4.0.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f180b03318c3dbab3ef4e1e4d46d5211ae3c780940dd0a28695aba4b59a75a" +checksum = "9f09647c0974e33366efeb83b8e2daebb329f0420149e74d3a4bd2c08cf9f7cb" dependencies = [ - "solana-program", + "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.1.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2881dddfca792737c0706fa0175345ab282b1b0879c7d877bad129645737c079" +checksum = "d994afaf86b779104b4a95ba9ca75b8ced3fdb17ee934e38cb69e72afbe17799" dependencies = [ - "borsh 0.10.3", + "borsh 1.5.7", "bytemuck", - "solana-program", - "solana-zk-token-sdk", - "spl-program-error", + "bytemuck_derive", + "num-derive 0.4.2", + "num-traits", + "solana-decode-error", + "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", + "thiserror 2.0.17", ] [[package]] name = "spl-program-error" -version = "0.3.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "249e0318493b6bcf27ae9902600566c689b7dfba9f1bdff5893e92253374e78c" +checksum = "9cdebc8b42553070b75aa5106f071fef2eb798c64a7ec63375da4b1f058688c6" dependencies = [ - "num-derive 0.4.1", + "num-derive 0.4.2", "num-traits", - "solana-program", + "solana-decode-error", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", "spl-program-error-derive", - "thiserror", + "thiserror 2.0.17", ] [[package]] name = "spl-program-error-derive" -version = "0.3.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5269c8e868da17b6552ef35a51355a017bd8e0eae269c201fef830d35fa52c" +checksum = "2a2539e259c66910d78593475540e8072f0b10f0f61d7607bbf7593899ed52d0" dependencies = [ "proc-macro2", "quote", - "sha2 0.10.8", - "syn 2.0.48", + "sha2 0.10.9", + "syn 2.0.109", ] [[package]] name = "spl-tlv-account-resolution" -version = "0.4.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "062e148d3eab7b165582757453632ffeef490c02c86a48bfdb4988f63eefb3b9" +checksum = "1408e961215688715d5a1063cbdcf982de225c45f99c82b4f7d7e1dd22b998d7" dependencies = [ "bytemuck", - "solana-program", + "num-derive 0.4.2", + "num-traits", + "solana-account-info 2.3.0", + "solana-decode-error", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", "spl-discriminator", "spl-pod", "spl-program-error", "spl-type-length-value", + "thiserror 2.0.17", ] [[package]] name = "spl-token" -version = "3.5.0" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e85e168a785e82564160dcb87b2a8e04cee9bfd1f4d488c729d53d6a4bd300d" +checksum = "053067c6a82c705004f91dae058b11b4780407e9ccd6799dc9e7d0fab5f242da" dependencies = [ "arrayref", "bytemuck", - "num-derive 0.3.3", + "num-derive 0.4.2", "num-traits", - "num_enum 0.5.9", - "solana-program", - "thiserror", + "num_enum", + "solana-account-info 2.3.0", + "solana-cpi 2.2.1", + "solana-decode-error", + "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 = "4.0.0" +name = "spl-token-2022" +version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08459ba1b8f7c1020b4582c4edf0f5c7511a5e099a7a97570c9698d4f2337060" +checksum = "31f0dfbb079eebaee55e793e92ca5f433744f4b71ee04880bfd6beefba5973e5" dependencies = [ "arrayref", "bytemuck", - "num-derive 0.3.3", + "num-derive 0.4.2", "num-traits", - "num_enum 0.6.1", - "solana-program", - "thiserror", + "num_enum", + "solana-account-info 2.3.0", + "solana-clock 2.2.2", + "solana-cpi 2.2.1", + "solana-decode-error", + "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 1.0.0", + "solana-sysvar 2.3.0", + "solana-zk-sdk", + "spl-elgamal-registry", + "spl-memo", + "spl-pod", + "spl-token", + "spl-token-confidential-transfer-ciphertext-arithmetic", + "spl-token-confidential-transfer-proof-extraction", + "spl-token-confidential-transfer-proof-generation", + "spl-token-group-interface", + "spl-token-metadata-interface", + "spl-transfer-hook-interface", + "spl-type-length-value", + "thiserror 2.0.17", ] [[package]] -name = "spl-token-2022" -version = "0.9.0" +name = "spl-token-confidential-transfer-ciphertext-arithmetic" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4abf34a65ba420584a0c35f3903f8d727d1f13ababbdc3f714c6b065a686e86" +checksum = "cddd52bfc0f1c677b41493dafa3f2dbbb4b47cf0990f08905429e19dc8289b35" +dependencies = [ + "base64 0.22.1", + "bytemuck", + "solana-curve25519", + "solana-zk-sdk", +] + +[[package]] +name = "spl-token-confidential-transfer-proof-extraction" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe2629860ff04c17bafa9ba4bed8850a404ecac81074113e1f840dbd0ebb7bd6" +dependencies = [ + "bytemuck", + "solana-account-info 2.3.0", + "solana-curve25519", + "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", + "spl-pod", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token-confidential-transfer-proof-generation" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa27b9174bea869a7ebf31e0be6890bce90b1a4288bc2bbf24bd413f80ae3fde" +dependencies = [ + "curve25519-dalek", + "solana-zk-sdk", + "thiserror 2.0.17", +] + +[[package]] +name = "spl-token-group-interface" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5597b4cd76f85ce7cd206045b7dc22da8c25516573d42d267c8d1fd128db5129" dependencies = [ - "arrayref", "bytemuck", - "num-derive 0.4.1", + "num-derive 0.4.2", "num-traits", - "num_enum 0.7.2", - "solana-program", - "solana-zk-token-sdk", - "spl-memo", + "solana-decode-error", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", + "spl-discriminator", "spl-pod", - "spl-token 4.0.0", - "spl-token-metadata-interface", - "spl-transfer-hook-interface", - "spl-type-length-value", - "thiserror", + "thiserror 2.0.17", ] [[package]] name = "spl-token-metadata-interface" -version = "0.2.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c16ce3ba6979645fb7627aa1e435576172dd63088dc7848cb09aa331fa1fe4f" +checksum = "304d6e06f0de0c13a621464b1fd5d4b1bebf60d15ca71a44d3839958e0da16ee" dependencies = [ - "borsh 0.10.3", - "solana-program", + "borsh 1.5.7", + "num-derive 0.4.2", + "num-traits", + "solana-borsh 2.2.1", + "solana-decode-error", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", "spl-discriminator", "spl-pod", - "spl-program-error", "spl-type-length-value", + "thiserror 2.0.17", ] [[package]] name = "spl-transfer-hook-interface" -version = "0.3.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051d31803f873cabe71aec3c1b849f35248beae5d19a347d93a5c9cccc5d5a9b" +checksum = "a7e905b849b6aba63bde8c4badac944ebb6c8e6e14817029cbe1bc16829133bd" dependencies = [ "arrayref", "bytemuck", - "solana-program", + "num-derive 0.4.2", + "num-traits", + "solana-account-info 2.3.0", + "solana-cpi 2.2.1", + "solana-decode-error", + "solana-instruction 2.3.3", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", + "solana-pubkey 2.4.0", "spl-discriminator", "spl-pod", "spl-program-error", "spl-tlv-account-resolution", "spl-type-length-value", + "thiserror 2.0.17", ] [[package]] name = "spl-type-length-value" -version = "0.3.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a468e6f6371f9c69aae760186ea9f1a01c2908351b06a5e0026d21cfc4d7ecac" +checksum = "d417eb548214fa822d93f84444024b4e57c13ed6719d4dcc68eec24fb481e9f5" dependencies = [ "bytemuck", - "solana-program", + "num-derive 0.4.2", + "num-traits", + "solana-account-info 2.3.0", + "solana-decode-error", + "solana-msg 2.2.1", + "solana-program-error 2.2.2", "spl-discriminator", "spl-pod", - "spl-program-error", + "thiserror 2.0.17", ] [[package]] @@ -2828,24 +3943,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "subtle" -version = "2.4.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "switchboard" version = "0.1.0" dependencies = [ "anchor-lang", - "base64 0.13.0", + "base64 0.13.1", ] [[package]] @@ -2853,45 +3962,33 @@ name = "switchboard-on-demand" version = "0.1.0" dependencies = [ "anchor-lang", - "base64 0.13.0", + "base64 0.13.1", "bytemuck", - "solana-program", + "solana-program 2.2.1", ] [[package]] name = "syn" -version = "1.0.92" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "syn" -version = "2.0.48" +version = "2.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "syn_derive" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 2.0.48", -] - [[package]] name = "tap" version = "1.0.1" @@ -2899,58 +3996,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] -name = "termcolor" -version = "1.2.0" +name = "thiserror" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "winapi-util", + "thiserror-impl 1.0.69", ] [[package]] name = "thiserror" -version = "1.0.56" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.17", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.109", ] [[package]] -name = "tiny-bip39" -version = "0.8.2" +name = "thiserror-impl" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ - "anyhow", - "hmac 0.8.1", - "once_cell", - "pbkdf2 0.4.0", - "rand 0.7.3", - "rustc-hash", - "sha2 0.9.9", - "thiserror", - "unicode-normalization", - "wasm-bindgen", - "zeroize", + "proc-macro2", + "quote", + "syn 2.0.109", ] [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" dependencies = [ "tinyvec_macros", ] @@ -2972,74 +4061,92 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.8" +version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ "serde", ] [[package]] -name = "typenum" -version = "1.15.0" +name = "toml_datetime" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" +dependencies = [ + "serde_core", +] [[package]] -name = "ucd-trie" -version = "0.1.4" +name = "toml_edit" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" +checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] [[package]] -name = "uint" -version = "0.9.1" +name = "toml_parser" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", + "winnow", ] [[package]] -name = "unicode-ident" -version = "1.0.8" +name = "typenum" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" [[package]] -name = "unicode-normalization" -version = "0.1.22" +name = "uint" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ - "tinyvec", + "byteorder", + "crunchy", + "hex", + "static_assertions", ] [[package]] -name = "unicode-segmentation" -version = "1.7.1" +name = "unicode-ident" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-segmentation" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "universal-hash" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" dependencies = [ - "generic-array", + "crypto-common", "subtle", ] +[[package]] +name = "unsize" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fa7a7a734c1a5664a662ddcea0b6c9472a21da8888c957c7f1eaa09dba7a939" +dependencies = [ + "autocfg", +] + [[package]] name = "uriparse" version = "0.6.4" @@ -3052,15 +4159,19 @@ dependencies = [ [[package]] name = "uuid" -version = "1.11.0" +version = "1.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" +checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -3070,40 +4181,28 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" dependencies = [ "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" -dependencies = [ - "bumpalo", - "log", "once_cell", - "proc-macro2", - "quote", - "syn 2.0.48", + "rustversion", + "wasm-bindgen-macro", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3111,114 +4210,59 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" dependencies = [ + "bumpalo", "proc-macro2", "quote", - "syn 2.0.48", - "wasm-bindgen-backend", + "syn 2.0.109", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.57" +version = "0.3.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" +checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows-link" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] -name = "windows-sys" -version = "0.36.1" +name = "winnow" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "memchr", ] -[[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" - -[[package]] -name = "windows_i686_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" - -[[package]] -name = "windows_i686_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" - [[package]] name = "without-alloc" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e34736feff52a0b3e5680927e947a4d8fac1f0b80dc8120b080dd8de24d75e2" +checksum = "375db0478b203b950ef10d1cce23cdbe5f30c2454fd9e7673ff56656df23adbb" dependencies = [ "alloc-traits", + "unsize", ] [[package]] @@ -3232,29 +4276,29 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.109", ] [[package]] name = "zeroize" -version = "1.3.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" dependencies = [ "zeroize_derive", ] @@ -3267,5 +4311,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.109", ] diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index d64706801f..8f23889f79 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -18,24 +18,25 @@ default=["mainnet-beta", "no-entrypoint"] drift-rs=[] [dependencies] -anchor-lang = "0.29.0" -solana-program = "1.16" -anchor-spl = { version = "0.29.0", features = [] } +anchor-lang = "0.32.1" +anchor-spl = { version = "0.32.1", features = [] } +# pin to highest version anchor crate allows +solana-program = "=2.2.1" pyth-client = "0.2.2" -pyth-lazer-solana-contract = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb", features = ["no-entrypoint"]} -pythnet-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb"} -pyth-solana-receiver-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb"} +pyth-lazer-solana-contract = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master", features = ["no-entrypoint"]} +pythnet-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master"} +pyth-solana-receiver-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master"} bytemuck = { version = "1.4.0" } borsh = "0.10.3" hex = "0.4.3" -num-traits = "0.2" uint = { version = "0.9.1", default-features = false } num-integer = "0.1.44" +num-traits = "0.2" arrayref = "0.3.6" base64 = "0.13.0" -serum_dex = { git = "https://github.com/project-serum/serum-dex", rev = "85b4f14", version = "0.5.6", features = ["no-entrypoint"] } +serum_dex = { git = "https://github.com/jordy25519/serum-dex", branch = "master", features = ["no-entrypoint"] } enumflags2 = "0.6.4" -phoenix-v1 = { git = "https://github.com/drift-labs/phoenix-v1", rev = "7703c5", version = "0.2.4", features = ["no-entrypoint"] } +phoenix-v1 = { git = "https://github.com/jordy25519/phoenix-v1", branch = "master", features = ["no-entrypoint"] } solana-security-txt = "1.1.0" static_assertions = "1.1.0" drift-macros = { git = "https://github.com/drift-labs/drift-macros.git", rev = "c57d87" } diff --git a/programs/drift/src/instructions/if_staker.rs b/programs/drift/src/instructions/if_staker.rs index 3e2381eb5f..bdc506abe8 100644 --- a/programs/drift/src/instructions/if_staker.rs +++ b/programs/drift/src/instructions/if_staker.rs @@ -504,9 +504,9 @@ pub fn handle_begin_insurance_fund_swap<'c: 'info, 'info>( found_end = true; // must be the SwapEnd instruction - let discriminator = crate::instruction::EndInsuranceFundSwap::discriminator(); + let discriminator = crate::instruction::EndInsuranceFundSwap::DISCRIMINATOR; validate!( - ix.data[0..8] == discriminator, + &ix.data[0..8] == discriminator, ErrorCode::InvalidSwap, "last drift ix must be end of swap" )?; diff --git a/programs/drift/src/instructions/keeper.rs b/programs/drift/src/instructions/keeper.rs index c0c465395a..4963543453 100644 --- a/programs/drift/src/instructions/keeper.rs +++ b/programs/drift/src/instructions/keeper.rs @@ -1032,8 +1032,7 @@ pub fn place_signed_msg_taker_order<'c: 'info, 'info>( &mut builder_order, )?; - let order_params_hash = - base64::encode(solana_program::hash::hash(&signature.try_to_vec().unwrap()).as_ref()); + let order_params_hash = base64::encode(solana_program::hash::hash(signature.as_ref()).as_ref()); emit!(SignedMsgOrderRecord { user: taker_key, @@ -1653,9 +1652,9 @@ pub fn handle_liquidate_spot_with_swap_begin<'c: 'info, 'info>( found_end = true; // must be the SwapEnd instruction - let discriminator = crate::instruction::LiquidateSpotWithSwapEnd::discriminator(); + let discriminator = crate::instruction::LiquidateSpotWithSwapEnd::DISCRIMINATOR; validate!( - ix.data[0..8] == discriminator, + &ix.data[0..8] == discriminator, ErrorCode::InvalidLiquidateSpotWithSwap, "last drift ix must be end of swap" )?; diff --git a/programs/drift/src/instructions/lp_admin.rs b/programs/drift/src/instructions/lp_admin.rs index 28e6026a44..fc6bbfa00a 100644 --- a/programs/drift/src/instructions/lp_admin.rs +++ b/programs/drift/src/instructions/lp_admin.rs @@ -693,9 +693,9 @@ pub fn handle_begin_lp_swap<'c: 'info, 'info>( found_end = true; // must be the SwapEnd instruction - let discriminator = crate::instruction::EndLpSwap::discriminator(); + let discriminator = crate::instruction::EndLpSwap::DISCRIMINATOR; validate!( - ix.data[0..8] == discriminator, + &ix.data[0..8] == discriminator, ErrorCode::InvalidSwap, "last drift ix must be end of swap" )?; diff --git a/programs/drift/src/instructions/optional_accounts.rs b/programs/drift/src/instructions/optional_accounts.rs index c2365bf0ec..3cad877e38 100644 --- a/programs/drift/src/instructions/optional_accounts.rs +++ b/programs/drift/src/instructions/optional_accounts.rs @@ -134,9 +134,8 @@ pub fn get_referrer_and_referrer_stats<'a>( return Ok((None, None)); } - let user_discriminator: [u8; 8] = User::discriminator(); - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &user_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != User::DISCRIMINATOR { return Ok((None, None)); } @@ -165,9 +164,8 @@ pub fn get_referrer_and_referrer_stats<'a>( return Ok((None, None)); } - let user_stats_discriminator: [u8; 8] = UserStats::discriminator(); - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &user_stats_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != UserStats::DISCRIMINATOR { return Ok((None, None)); } @@ -262,9 +260,8 @@ pub fn get_high_leverage_mode_config<'a>( return Ok(None); } - let high_leverage_mode_config_discriminator: [u8; 8] = HighLeverageModeConfig::discriminator(); - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &high_leverage_mode_config_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != HighLeverageModeConfig::DISCRIMINATOR { return Ok(None); } @@ -293,10 +290,9 @@ pub fn get_revenue_share_escrow_account<'a>( return Ok(None); } - let discriminator: [u8; 8] = RevenueShareEscrow::discriminator(); let borrowed_data = account_info.data.borrow(); let account_discriminator = array_ref![&borrowed_data, 0, 8]; - if account_discriminator != &discriminator { + if account_discriminator != RevenueShareEscrow::DISCRIMINATOR { return Ok(None); } diff --git a/programs/drift/src/instructions/user.rs b/programs/drift/src/instructions/user.rs index a7fb0ca854..e75f02ca1c 100644 --- a/programs/drift/src/instructions/user.rs +++ b/programs/drift/src/instructions/user.rs @@ -3606,9 +3606,9 @@ pub fn handle_begin_swap<'c: 'info, 'info>( found_end = true; // must be the SwapEnd instruction - let discriminator = crate::instruction::EndSwap::discriminator(); + let discriminator = crate::instruction::EndSwap::DISCRIMINATOR; validate!( - ix.data[0..8] == discriminator, + &ix.data[0..8] == discriminator, ErrorCode::InvalidSwap, "last drift ix must be end of swap" )?; diff --git a/programs/drift/src/macros.rs b/programs/drift/src/macros.rs index cdd2004825..03daaadd8f 100644 --- a/programs/drift/src/macros.rs +++ b/programs/drift/src/macros.rs @@ -89,32 +89,16 @@ macro_rules! safe_decrement { }}; } -/// Calculate the sha256 digest of anchor encoded `struct` -#[macro_export] -macro_rules! digest_struct { - ($struct:expr) => { - solana_program::hash::hash(&$struct.try_to_vec().unwrap()).to_bytes() - }; -} - -/// Calculate the hexified sha256 digest of anchor encoded `struct` -#[macro_export] -macro_rules! digest_struct_hex { - ($struct:expr) => {{ - hex::encode(digest_struct!($struct)).into_bytes() - }}; -} - /// same as `solana_program::msg!` but it can compile away for off-chain use #[macro_export] macro_rules! msg { ($msg:expr) => { #[cfg(not(feature = "drift-rs"))] - solana_program::msg!($msg) + ::solana_program::msg!($msg) }; ($($arg:tt)*) => { #[cfg(not(feature = "drift-rs"))] - (solana_program::msg!(&format!($($arg)*))); + (::solana_program::msg!(&format!($($arg)*))); } } diff --git a/programs/drift/src/math/liquidation/tests.rs b/programs/drift/src/math/liquidation/tests.rs index 17315dabbf..b968bb6629 100644 --- a/programs/drift/src/math/liquidation/tests.rs +++ b/programs/drift/src/math/liquidation/tests.rs @@ -574,14 +574,13 @@ mod calculate_cumulative_deposit_interest_delta_to_resolve_bankruptcy { } mod validate_transfer_satisfies_limit_price { - use crate::math::constants::{PRICE_PRECISION_U64, QUOTE_PRECISION}; + use crate::math::constants::{LAMPORTS_PER_SOL_U64, PRICE_PRECISION_U64, QUOTE_PRECISION}; use crate::math::liquidation::validate_transfer_satisfies_limit_price; - use anchor_lang::solana_program::native_token::LAMPORTS_PER_SOL; #[test] fn sol_asset_usdc_liability() { let limit_price = PRICE_PRECISION_U64 / 100; // 1 SOL / $100 USD - let asset = LAMPORTS_PER_SOL as u128; + let asset = LAMPORTS_PER_SOL_U64 as u128; let asset_decimals = 9_u32; let liability = 100 * QUOTE_PRECISION; let liability_decimals = 6_u32; diff --git a/programs/drift/src/math/orders/tests.rs b/programs/drift/src/math/orders/tests.rs index 339aa20361..cd790e2519 100644 --- a/programs/drift/src/math/orders/tests.rs +++ b/programs/drift/src/math/orders/tests.rs @@ -462,7 +462,6 @@ mod get_max_fill_amounts { use crate::state::user::{Order, SpotPosition, User}; use crate::test_utils::get_orders; use crate::LAMPORTS_PER_SOL_U64; - use anchor_spl::token::spl_token::solana_program::native_token::LAMPORTS_PER_SOL; #[test] fn fully_collateralized_selling_base() { @@ -493,7 +492,7 @@ mod get_max_fill_amounts { spot_positions, orders: get_orders(Order { direction: PositionDirection::Short, - base_asset_amount: 100 * LAMPORTS_PER_SOL, + base_asset_amount: 100 * LAMPORTS_PER_SOL_U64, ..Order::default() }), ..User::default() @@ -531,7 +530,7 @@ mod get_max_fill_amounts { spot_positions, orders: get_orders(Order { direction: PositionDirection::Short, - base_asset_amount: 100 * LAMPORTS_PER_SOL, + base_asset_amount: 100 * LAMPORTS_PER_SOL_U64, ..Order::default() }), ..User::default() @@ -572,7 +571,7 @@ mod get_max_fill_amounts { spot_positions, orders: get_orders(Order { direction: PositionDirection::Short, - base_asset_amount: 100 * LAMPORTS_PER_SOL, + base_asset_amount: 100 * LAMPORTS_PER_SOL_U64, ..Order::default() }), ..User::default() @@ -614,7 +613,7 @@ mod get_max_fill_amounts { spot_positions, orders: get_orders(Order { direction: PositionDirection::Long, - base_asset_amount: 100 * LAMPORTS_PER_SOL, + base_asset_amount: 100 * LAMPORTS_PER_SOL_U64, ..Order::default() }), ..User::default() @@ -652,7 +651,7 @@ mod get_max_fill_amounts { spot_positions, orders: get_orders(Order { direction: PositionDirection::Long, - base_asset_amount: 100 * LAMPORTS_PER_SOL, + base_asset_amount: 100 * LAMPORTS_PER_SOL_U64, ..Order::default() }), ..User::default() @@ -694,7 +693,7 @@ mod get_max_fill_amounts { spot_positions, orders: get_orders(Order { direction: PositionDirection::Long, - base_asset_amount: 100 * LAMPORTS_PER_SOL, + base_asset_amount: 100 * LAMPORTS_PER_SOL_U64, ..Order::default() }), ..User::default() diff --git a/programs/drift/src/state/constituent_map.rs b/programs/drift/src/state/constituent_map.rs index 57518c0d4b..b3e9bd5aa8 100644 --- a/programs/drift/src/state/constituent_map.rs +++ b/programs/drift/src/state/constituent_map.rs @@ -94,7 +94,6 @@ impl<'a> ConstituentMap<'a> { ) -> DriftResult> { let mut constituent_map: ConstituentMap = ConstituentMap(BTreeMap::new()); - let constituent_discriminator: [u8; 8] = Constituent::discriminator(); while let Some(account_info) = account_info_iter.peek() { if account_info.owner != &crate::ID { break; @@ -114,12 +113,12 @@ impl<'a> ConstituentMap<'a> { break; } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &constituent_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != Constituent::DISCRIMINATOR { msg!( "didnt match account discriminator {:?}, {:?}", account_discriminator, - constituent_discriminator + Constituent::DISCRIMINATOR ); break; } @@ -176,9 +175,8 @@ impl<'a> ConstituentMap<'a> { return Err(ErrorCode::ConstituentCouldNotLoad); } - let constituent_discriminator: [u8; 8] = Constituent::discriminator(); - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &constituent_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != Constituent::DISCRIMINATOR { return Err(ErrorCode::ConstituentCouldNotLoad); } @@ -206,7 +204,6 @@ impl<'a> ConstituentMap<'a> { let account_info_iter = account_info.into_iter(); for account_info in account_info_iter { - let constituent_discriminator: [u8; 8] = Constituent::discriminator(); let data = account_info .try_borrow_data() .or(Err(ErrorCode::ConstituentCouldNotLoad))?; @@ -216,8 +213,8 @@ impl<'a> ConstituentMap<'a> { return Err(ErrorCode::ConstituentCouldNotLoad); } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &constituent_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != Constituent::DISCRIMINATOR { return Err(ErrorCode::ConstituentCouldNotLoad); } diff --git a/programs/drift/src/state/events.rs b/programs/drift/src/state/events.rs index cdf97002e7..7c538b74fc 100644 --- a/programs/drift/src/state/events.rs +++ b/programs/drift/src/state/events.rs @@ -746,7 +746,7 @@ pub fn emit_buffers( ) -> DriftResult { let mut data_writer = std::io::Cursor::new(data_buf); data_writer - .write_all(&::discriminator()) + .write_all(&::DISCRIMINATOR) .safe_unwrap()?; borsh::to_writer(&mut data_writer, &event).safe_unwrap()?; let data_len = data_writer.position() as usize; diff --git a/programs/drift/src/state/load_ref.rs b/programs/drift/src/state/load_ref.rs index 00b4a2f0c7..6983a24e72 100644 --- a/programs/drift/src/state/load_ref.rs +++ b/programs/drift/src/state/load_ref.rs @@ -6,12 +6,12 @@ use std::mem; pub fn load_ref<'a, T: ZeroCopy + Owner>(account_info: &'a AccountInfo) -> Result> { let data = account_info.try_borrow_data()?; - if data.len() < T::discriminator().len() { + if data.len() < T::DISCRIMINATOR.len() { return Err(ErrorCode::AccountDiscriminatorNotFound.into()); } - let disc_bytes = array_ref![data, 0, 8]; - if disc_bytes != &T::discriminator() { + let disc_bytes = &data[..8]; + if disc_bytes != T::DISCRIMINATOR { return Err(ErrorCode::AccountDiscriminatorMismatch.into()); } @@ -24,12 +24,12 @@ pub fn load_ref_mut<'a, T: ZeroCopy + Owner>( account_info: &'a AccountInfo, ) -> Result> { let data = account_info.try_borrow_mut_data()?; - if data.len() < T::discriminator().len() { + if data.len() < T::DISCRIMINATOR.len() { return Err(ErrorCode::AccountDiscriminatorNotFound.into()); } - let disc_bytes = array_ref![data, 0, 8]; - if disc_bytes != &T::discriminator() { + let disc_bytes = &data[..8]; + if disc_bytes != T::DISCRIMINATOR { return Err(ErrorCode::AccountDiscriminatorMismatch.into()); } diff --git a/programs/drift/src/state/oracle_map.rs b/programs/drift/src/state/oracle_map.rs index acbe7c618c..48605e0403 100644 --- a/programs/drift/src/state/oracle_map.rs +++ b/programs/drift/src/state/oracle_map.rs @@ -211,14 +211,14 @@ impl<'a> OracleMap<'a> { UnableToLoadOracle })?; - let account_discriminator = array_ref![data, 0, 8]; + let account_discriminator = &data[..8]; - if account_discriminator == &PrelaunchOracle::discriminator() { + if account_discriminator == PrelaunchOracle::DISCRIMINATOR { let expected_data_len = PrelaunchOracle::SIZE; if data.len() < expected_data_len { break; } - } else if account_discriminator == &PythLazerOracle::discriminator() { + } else if account_discriminator == PythLazerOracle::DISCRIMINATOR { let expected_data_len = PythLazerOracle::SIZE; if data.len() < expected_data_len { break; @@ -277,15 +277,15 @@ impl<'a> OracleMap<'a> { UnableToLoadOracle })?; - let account_discriminator = array_ref![data, 0, 8]; + let account_discriminator = &data[..8]; - if account_discriminator == &PrelaunchOracle::discriminator() { + if account_discriminator == PrelaunchOracle::DISCRIMINATOR { let expected_data_len = PrelaunchOracle::SIZE; if data.len() < expected_data_len { msg!("Unexpected account data len loading oracle"); return Err(UnableToLoadOracle); } - } else if account_discriminator == &PythLazerOracle::discriminator() { + } else if account_discriminator == PythLazerOracle::DISCRIMINATOR { let expected_data_len = PythLazerOracle::SIZE; if data.len() < expected_data_len { msg!("Unexpected account data len loading oracle"); diff --git a/programs/drift/src/state/perp_market_map.rs b/programs/drift/src/state/perp_market_map.rs index 73c6d37d9d..1b41122107 100644 --- a/programs/drift/src/state/perp_market_map.rs +++ b/programs/drift/src/state/perp_market_map.rs @@ -95,7 +95,6 @@ impl<'a> PerpMarketMap<'a> { ) -> DriftResult> { let mut perp_market_map: PerpMarketMap = PerpMarketMap(BTreeMap::new()); - let market_discriminator: [u8; 8] = PerpMarket::discriminator(); while let Some(account_info) = account_info_iter.peek() { let data = account_info .try_borrow_data() @@ -106,8 +105,8 @@ impl<'a> PerpMarketMap<'a> { break; } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &market_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != PerpMarket::DISCRIMINATOR { break; } @@ -154,9 +153,8 @@ impl<'a> PerpMarketMap<'a> { return Err(ErrorCode::CouldNotLoadMarketData); } - let market_discriminator: [u8; 8] = PerpMarket::discriminator(); - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &market_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != &PerpMarket::DISCRIMINATOR { return Err(ErrorCode::CouldNotLoadMarketData); } @@ -197,9 +195,8 @@ impl<'a> PerpMarketMap<'a> { return Err(ErrorCode::CouldNotLoadMarketData); } - let market_discriminator: [u8; 8] = PerpMarket::discriminator(); - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &market_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != PerpMarket::DISCRIMINATOR { return Err(ErrorCode::CouldNotLoadMarketData); } diff --git a/programs/drift/src/state/revenue_share.rs b/programs/drift/src/state/revenue_share.rs index 6d99427054..7997b2fb4e 100644 --- a/programs/drift/src/state/revenue_share.rs +++ b/programs/drift/src/state/revenue_share.rs @@ -1,10 +1,9 @@ use std::cell::{Ref, RefMut}; -use anchor_lang::prelude::Pubkey; -use anchor_lang::*; -use anchor_lang::{account, zero_copy}; +use anchor_lang::prelude::{ + account, zero_copy, AccountInfo, AnchorDeserialize, AnchorSerialize, Discriminator, Pubkey, +}; use borsh::{BorshDeserialize, BorshSerialize}; -use prelude::AccountInfo; use crate::error::{DriftResult, ErrorCode}; use crate::math::casting::Cast; @@ -531,7 +530,7 @@ impl<'a> RevenueShareEscrowLoader<'a> for AccountInfo<'a> { let (discriminator, data) = Ref::map_split(data, |d| d.split_at(8)); validate!( - *discriminator == RevenueShareEscrow::discriminator(), + discriminator.as_ref() == RevenueShareEscrow::DISCRIMINATOR, ErrorCode::DefaultError, "invalid signed_msg user orders discriminator", )?; @@ -557,7 +556,7 @@ impl<'a> RevenueShareEscrowLoader<'a> for AccountInfo<'a> { let (discriminator, data) = RefMut::map_split(data, |d| d.split_at_mut(8)); validate!( - *discriminator == RevenueShareEscrow::discriminator(), + discriminator.as_ref() == RevenueShareEscrow::DISCRIMINATOR, ErrorCode::DefaultError, "invalid signed_msg user orders discriminator", )?; diff --git a/programs/drift/src/state/revenue_share_map.rs b/programs/drift/src/state/revenue_share_map.rs index 2e45195040..912e8a43ea 100644 --- a/programs/drift/src/state/revenue_share_map.rs +++ b/programs/drift/src/state/revenue_share_map.rs @@ -144,9 +144,6 @@ pub fn load_revenue_share_map<'a: 'b, 'b>( ) -> DriftResult> { let mut revenue_share_map = RevenueShareMap::empty(); - let user_discriminator: [u8; 8] = User::discriminator(); - let rev_share_discriminator: [u8; 8] = RevenueShare::discriminator(); - while let Some(account_info) = account_info_iter.peek() { let data = account_info .try_borrow_data() @@ -156,9 +153,9 @@ pub fn load_revenue_share_map<'a: 'b, 'b>( break; } - let account_discriminator = array_ref![data, 0, 8]; + let account_discriminator = &data[..8]; - if account_discriminator == &user_discriminator { + if account_discriminator == User::DISCRIMINATOR { let user_account_info = account_info_iter.next().safe_unwrap()?; let is_writable = user_account_info.is_writable; if !is_writable { @@ -184,7 +181,7 @@ pub fn load_revenue_share_map<'a: 'b, 'b>( continue; } - if account_discriminator == &rev_share_discriminator { + if account_discriminator == RevenueShare::DISCRIMINATOR { let revenue_share_account_info = account_info_iter.next().safe_unwrap()?; let is_writable = revenue_share_account_info.is_writable; if !is_writable { diff --git a/programs/drift/src/state/signed_msg_user.rs b/programs/drift/src/state/signed_msg_user.rs index 953cdd3a6a..2ab4bef97b 100644 --- a/programs/drift/src/state/signed_msg_user.rs +++ b/programs/drift/src/state/signed_msg_user.rs @@ -187,7 +187,7 @@ impl<'a> SignedMsgUserOrdersLoader<'a> for AccountInfo<'a> { let (discriminator, data) = Ref::map_split(data, |d| d.split_at(8)); validate!( - *discriminator == SignedMsgUserOrders::discriminator(), + discriminator.as_ref() == SignedMsgUserOrders::DISCRIMINATOR, ErrorCode::DefaultError, "invalid signed_msg user orders discriminator", )?; @@ -212,7 +212,7 @@ impl<'a> SignedMsgUserOrdersLoader<'a> for AccountInfo<'a> { let (discriminator, data) = RefMut::map_split(data, |d| d.split_at_mut(8)); validate!( - *discriminator == SignedMsgUserOrders::discriminator(), + discriminator.as_ref() == SignedMsgUserOrders::DISCRIMINATOR, ErrorCode::DefaultError, "invalid signed_msg user orders discriminator", )?; diff --git a/programs/drift/src/state/signed_msg_user/tests.rs b/programs/drift/src/state/signed_msg_user/tests.rs index 535a60953b..96af65b096 100644 --- a/programs/drift/src/state/signed_msg_user/tests.rs +++ b/programs/drift/src/state/signed_msg_user/tests.rs @@ -170,7 +170,7 @@ mod zero_copy { } let mut bytes = Vec::with_capacity(8 + orders.try_to_vec().unwrap().len()); - bytes.extend_from_slice(&SignedMsgUserOrders::discriminator()); + bytes.extend_from_slice(&SignedMsgUserOrders::DISCRIMINATOR); bytes.extend_from_slice(&orders.try_to_vec().unwrap()); let pubkey = Pubkey::default(); @@ -211,7 +211,7 @@ mod zero_copy { // invalid discriminator let mut bytes = Vec::with_capacity(8 + orders.try_to_vec().unwrap().len()); bytes.extend_from_slice(&orders.try_to_vec().unwrap()); - bytes.extend_from_slice(&SignedMsgUserOrders::discriminator()); + bytes.extend_from_slice(&SignedMsgUserOrders::DISCRIMINATOR); let orders_account_info = create_account_info(&random_pubkey, false, &mut lamports, &mut bytes, &ID); let result = orders_account_info.load(); @@ -237,7 +237,7 @@ mod zero_copy { } let mut bytes = Vec::with_capacity(8 + orders.try_to_vec().unwrap().len()); - bytes.extend_from_slice(&SignedMsgUserOrders::discriminator()); + bytes.extend_from_slice(&SignedMsgUserOrders::DISCRIMINATOR); bytes.extend_from_slice(&orders.try_to_vec().unwrap()); let pubkey = Pubkey::default(); @@ -279,7 +279,7 @@ mod zero_copy { // invalid discriminator let mut bytes = Vec::with_capacity(8 + orders.try_to_vec().unwrap().len()); bytes.extend_from_slice(&orders.try_to_vec().unwrap()); - bytes.extend_from_slice(&SignedMsgUserOrders::discriminator()); + bytes.extend_from_slice(&SignedMsgUserOrders::DISCRIMINATOR); let orders_account_info = create_account_info(&random_pubkey, true, &mut lamports, &mut bytes, &ID); let result = orders_account_info.load_mut(); diff --git a/programs/drift/src/state/spot_market_map.rs b/programs/drift/src/state/spot_market_map.rs index e93ad8630a..c555a939cc 100644 --- a/programs/drift/src/state/spot_market_map.rs +++ b/programs/drift/src/state/spot_market_map.rs @@ -183,7 +183,6 @@ impl<'a> SpotMarketMap<'a> { let mut spot_market_map: SpotMarketMap = SpotMarketMap(BTreeMap::new(), writable_spot_markets.clone()); - let spot_market_discriminator: [u8; 8] = SpotMarket::discriminator(); while let Some(account_info) = account_info_iter.peek() { let data = account_info .try_borrow_data() @@ -194,8 +193,8 @@ impl<'a> SpotMarketMap<'a> { break; } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &spot_market_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != SpotMarket::DISCRIMINATOR { break; } @@ -232,7 +231,6 @@ impl<'a> SpotMarketMap<'a> { let mut writable_markets = SpotMarketSet::new(); let mut map = BTreeMap::new(); - let spot_market_discriminator: [u8; 8] = SpotMarket::discriminator(); let data = account_info .try_borrow_data() .or(Err(ErrorCode::CouldNotLoadSpotMarketData))?; @@ -242,8 +240,8 @@ impl<'a> SpotMarketMap<'a> { return Err(ErrorCode::CouldNotLoadSpotMarketData); } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &spot_market_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != SpotMarket::DISCRIMINATOR { return Err(ErrorCode::CouldNotLoadSpotMarketData); } @@ -284,7 +282,6 @@ impl<'a> SpotMarketMap<'a> { let account_info_iter = account_info.into_iter(); for account_info in account_info_iter { - let spot_market_discriminator: [u8; 8] = SpotMarket::discriminator(); let data = account_info .try_borrow_data() .or(Err(ErrorCode::CouldNotLoadSpotMarketData))?; @@ -294,8 +291,8 @@ impl<'a> SpotMarketMap<'a> { return Err(ErrorCode::CouldNotLoadSpotMarketData); } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &spot_market_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != SpotMarket::DISCRIMINATOR { return Err(ErrorCode::CouldNotLoadSpotMarketData); } diff --git a/programs/drift/src/state/user_map.rs b/programs/drift/src/state/user_map.rs index 4da2a79b69..8f71c992dc 100644 --- a/programs/drift/src/state/user_map.rs +++ b/programs/drift/src/state/user_map.rs @@ -108,8 +108,6 @@ impl<'a> UserMap<'a> { pub fn load_one<'b: 'a>(account_info: &'b AccountInfo<'a>) -> DriftResult> { let mut user_map = UserMap(BTreeMap::new()); - let user_discriminator: [u8; 8] = User::discriminator(); - let user_key = account_info.key; let data = account_info @@ -121,8 +119,8 @@ impl<'a> UserMap<'a> { return Err(ErrorCode::CouldNotLoadUserData); } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &user_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != User::DISCRIMINATOR { return Err(ErrorCode::CouldNotLoadUserData); } @@ -236,8 +234,6 @@ impl<'a> UserStatsMap<'a> { pub fn load_one<'b: 'a>(account_info: &'b AccountInfo<'a>) -> DriftResult> { let mut user_stats_map = UserStatsMap(BTreeMap::new()); - let user_stats_discriminator: [u8; 8] = UserStats::discriminator(); - let _user_stats_key = account_info.key; let data = account_info @@ -249,8 +245,8 @@ impl<'a> UserStatsMap<'a> { return Err(ErrorCode::DefaultError); } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &user_stats_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != UserStats::DISCRIMINATOR { return Err(ErrorCode::DefaultError); } @@ -280,8 +276,6 @@ pub fn load_user_maps<'a: 'b, 'b>( let mut user_map = UserMap::empty(); let mut user_stats_map = UserStatsMap::empty(); - let user_discriminator: [u8; 8] = User::discriminator(); - let user_stats_discriminator: [u8; 8] = UserStats::discriminator(); while let Some(user_account_info) = account_info_iter.peek() { let user_key = user_account_info.key; @@ -294,8 +288,8 @@ pub fn load_user_maps<'a: 'b, 'b>( break; } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &user_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != User::DISCRIMINATOR { break; } @@ -327,8 +321,8 @@ pub fn load_user_maps<'a: 'b, 'b>( return Err(ErrorCode::InvalidUserStatsAccount); } - let account_discriminator = array_ref![data, 0, 8]; - if account_discriminator != &user_stats_discriminator { + let account_discriminator = &data[..8]; + if account_discriminator != UserStats::DISCRIMINATOR { return Err(ErrorCode::InvalidUserStatsAccount); } @@ -362,8 +356,6 @@ pub fn load_user_map<'a: 'b, 'b>( ) -> DriftResult> { let mut user_map = UserMap::empty(); - let user_discriminator: [u8; 8] = User::discriminator(); - let user_stats_discriminator: [u8; 8] = UserStats::discriminator(); while let Some(user_account_info) = account_info_iter.peek() { let user_key = user_account_info.key; @@ -377,15 +369,15 @@ pub fn load_user_map<'a: 'b, 'b>( break; } - let account_discriminator = array_ref![data, 0, 8]; + let account_discriminator = &data[..8]; - // if it is user stats, for backwards compatability, just move iter forward - if account_discriminator == &user_stats_discriminator { + // if it is user stats, for backwards compatibility, just move iter forward + if account_discriminator == UserStats::DISCRIMINATOR { account_info_iter.next().safe_unwrap()?; continue; } - if account_discriminator != &user_discriminator { + if account_discriminator != User::DISCRIMINATOR { break; } diff --git a/programs/drift/src/state/zero_copy.rs b/programs/drift/src/state/zero_copy.rs index b6a11a383f..d20e1af04e 100644 --- a/programs/drift/src/state/zero_copy.rs +++ b/programs/drift/src/state/zero_copy.rs @@ -79,7 +79,7 @@ pub trait ZeroCopyLoader<'a, T, F> { pub fn load_generic<'a, 'info, F, T>( acct: &'a AccountInfo<'info>, - expected_disc: [u8; 8], + expected_disc: &[u8], program_id: Pubkey, ) -> DriftResult> where @@ -98,7 +98,7 @@ where let (disc, rest) = Ref::map_split(data, |d| d.split_at(8)); validate!( - *disc == expected_disc, + disc.as_ref() == expected_disc, ErrorCode::DefaultError, "invalid discriminator", )?; @@ -115,7 +115,7 @@ where pub fn load_generic_mut<'a, 'info, F, T>( acct: &'a AccountInfo<'info>, - expected_disc: [u8; 8], + expected_disc: &[u8], program_id: Pubkey, ) -> DriftResult> where @@ -132,7 +132,7 @@ where let (disc, rest) = RefMut::map_split(data, |d| d.split_at_mut(8)); validate!( - *disc == expected_disc, + disc.as_ref() == expected_disc, ErrorCode::DefaultError, "invalid discriminator", )?; @@ -160,7 +160,7 @@ macro_rules! impl_zero_copy_loader { > { crate::state::zero_copy::load_generic::<$Fixed, $Elem>( self, - <$Acc as anchor_lang::Discriminator>::discriminator(), + <$Acc as anchor_lang::Discriminator>::DISCRIMINATOR, $ID(), ) } @@ -172,7 +172,7 @@ macro_rules! impl_zero_copy_loader { > { crate::state::zero_copy::load_generic_mut::<$Fixed, $Elem>( self, - <$Acc as anchor_lang::Discriminator>::discriminator(), + <$Acc as anchor_lang::Discriminator>::DISCRIMINATOR, $ID(), ) } diff --git a/programs/drift/src/test_utils.rs b/programs/drift/src/test_utils.rs index f031f6af9d..516d62dbf7 100644 --- a/programs/drift/src/test_utils.rs +++ b/programs/drift/src/test_utils.rs @@ -52,7 +52,7 @@ pub fn get_account_bytes(account: &mut T) -> BytesMut { pub fn get_anchor_account_bytes(account: &mut T) -> BytesMut { let mut bytes = BytesMut::new(); - bytes.extend_from_slice(&T::discriminator()); + bytes.extend_from_slice(&T::DISCRIMINATOR); let data = bytemuck::bytes_of_mut(account); bytes.extend_from_slice(data); bytes diff --git a/programs/openbook_v2/Cargo.toml b/programs/openbook_v2/Cargo.toml index 7a7360a4f3..1191dfa6be 100644 --- a/programs/openbook_v2/Cargo.toml +++ b/programs/openbook_v2/Cargo.toml @@ -18,6 +18,6 @@ cpi = ["no-entrypoint"] [dependencies] -anchor-lang = { version = "0.29.0", features = ["derive"] } +anchor-lang = { version = "0.32.1", features = ["derive"] } borsh = {version = "0.10.3", features = ["const-generics", "default"]} bytemuck = { version = "1.4.0" , features = ["derive", "min_const_generics"]} \ No newline at end of file diff --git a/programs/pyth/Cargo.toml b/programs/pyth/Cargo.toml index ed1b1b8e28..e3ccf01864 100644 --- a/programs/pyth/Cargo.toml +++ b/programs/pyth/Cargo.toml @@ -17,5 +17,5 @@ mainnet-beta=[] anchor-test= [] [dependencies] -anchor-lang = "0.29.0" +anchor-lang = "0.32.1" bytemuck = { version = "1.4.0" } diff --git a/programs/switchboard-on-demand/Cargo.toml b/programs/switchboard-on-demand/Cargo.toml index 0709be9058..8e7876cd99 100644 --- a/programs/switchboard-on-demand/Cargo.toml +++ b/programs/switchboard-on-demand/Cargo.toml @@ -16,9 +16,9 @@ mainnet-beta=[] anchor-test= [] [dependencies] -anchor-lang = "0.29.0" +anchor-lang = "0.32.1" bytemuck = { version = "1.4.0" } -solana-program = "1.16" +solana-program = "2" [dev-dependencies] base64 = "0.13.0" diff --git a/programs/switchboard-on-demand/src/lib.rs b/programs/switchboard-on-demand/src/lib.rs index 80779e43a5..a251ad5e27 100644 --- a/programs/switchboard-on-demand/src/lib.rs +++ b/programs/switchboard-on-demand/src/lib.rs @@ -24,17 +24,17 @@ pub struct CompactResult { #[repr(C)] #[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable)] pub struct CurrentResult { - /// The median value of the submissions needed for quorom size + /// The median value of the submissions needed for quorum size pub value: i128, - /// The standard deviation of the submissions needed for quorom size + /// The standard deviation of the submissions needed for quorum size pub std_dev: i128, - /// The mean of the submissions needed for quorom size + /// The mean of the submissions needed for quorum size pub mean: i128, - /// The range of the submissions needed for quorom size + /// The range of the submissions needed for quorum size pub range: i128, - /// The minimum value of the submissions needed for quorom size + /// The minimum value of the submissions needed for quorum size pub min_value: i128, - /// The maximum value of the submissions needed for quorom size + /// The maximum value of the submissions needed for quorum size pub max_value: i128, /// The number of samples used to calculate this result pub num_samples: u8, @@ -49,7 +49,7 @@ pub struct CurrentResult { pub max_slot: u64, } impl CurrentResult { - /// The median value of the submissions needed for quorom size + /// The median value of the submissions needed for quorum size pub fn value(&self) -> Option { if self.slot == 0 { return None; @@ -57,7 +57,7 @@ impl CurrentResult { Some(self.value) } - /// The standard deviation of the submissions needed for quorom size + /// The standard deviation of the submissions needed for quorum size pub fn std_dev(&self) -> Option { if self.slot == 0 { return None; @@ -65,7 +65,7 @@ impl CurrentResult { Some(self.std_dev) } - /// The mean of the submissions needed for quorom size + /// The mean of the submissions needed for quorum size pub fn mean(&self) -> Option { if self.slot == 0 { return None; @@ -73,7 +73,7 @@ impl CurrentResult { Some(self.mean) } - /// The range of the submissions needed for quorom size + /// The range of the submissions needed for quorum size pub fn range(&self) -> Option { if self.slot == 0 { return None; @@ -81,7 +81,7 @@ impl CurrentResult { Some(self.range) } - /// The minimum value of the submissions needed for quorom size + /// The minimum value of the submissions needed for quorum size pub fn min_value(&self) -> Option { if self.slot == 0 { return None; @@ -89,7 +89,7 @@ impl CurrentResult { Some(self.min_value) } - /// The maximum value of the submissions needed for quorom size + /// The maximum value of the submissions needed for quorum size pub fn max_value(&self) -> Option { if self.slot == 0 { return None; @@ -179,36 +179,34 @@ pub struct PullFeedAccountData { } impl PullFeedAccountData { - pub fn discriminator() -> [u8; 8] { - [196, 27, 108, 196, 10, 215, 219, 40] - } + pub const DISCRIMINATOR: &[u8] = &[196, 27, 108, 196, 10, 215, 219, 40]; - /// The median value of the submissions needed for quorom size + /// The median value of the submissions needed for quorum size pub fn median_value(&self) -> Option { self.result.value() } - /// The standard deviation of the submissions needed for quorom size + /// The standard deviation of the submissions needed for quorum size pub fn std_dev(&self) -> Option { self.result.std_dev() } - /// The mean of the submissions needed for quorom size + /// The mean of the submissions needed for quorum size pub fn mean(&self) -> Option { self.result.mean() } - /// The range of the submissions needed for quorom size + /// The range of the submissions needed for quorum size pub fn range(&self) -> Option { self.result.range() } - /// The minimum value of the submissions needed for quorom size + /// The minimum value of the submissions needed for quorum size pub fn min_value(&self) -> Option { self.result.min_value() } - /// The maximum value of the submissions needed for quorom size + /// The maximum value of the submissions needed for quorum size pub fn max_value(&self) -> Option { self.result.max_value() } diff --git a/programs/switchboard/Cargo.toml b/programs/switchboard/Cargo.toml index 6c6cafb802..e659b127b0 100644 --- a/programs/switchboard/Cargo.toml +++ b/programs/switchboard/Cargo.toml @@ -16,7 +16,7 @@ mainnet-beta=[] anchor-test= [] [dependencies] -anchor-lang = "0.29.0" +anchor-lang = "0.32.1" [dev-dependencies] base64 = "0.13.0" diff --git a/programs/token_faucet/Cargo.toml b/programs/token_faucet/Cargo.toml index d553fdc158..8696f9482e 100644 --- a/programs/token_faucet/Cargo.toml +++ b/programs/token_faucet/Cargo.toml @@ -15,6 +15,6 @@ mainnet-beta=[] anchor-test= [] [dependencies] -anchor-lang = "0.29.0" -anchor-spl = "0.29.0" +anchor-lang = "0.32.1" +anchor-spl = "0.32.1" bytemuck = { version = "1.4.0" } \ No newline at end of file From 6711ed39be5d1960ca3ad3982574bffcee9da92e Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Thu, 6 Nov 2025 14:26:20 +0800 Subject: [PATCH 03/25] remove solana-program v3 --- Cargo.lock | 1506 +++++---------------- programs/switchboard-on-demand/Cargo.toml | 2 +- 2 files changed, 346 insertions(+), 1162 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 128a3eb3d9..bbf258f678 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,18 +49,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "alloc-traits" version = "0.1.1" @@ -197,26 +185,26 @@ dependencies = [ "bincode", "borsh 0.10.4", "bytemuck", - "solana-account-info 2.3.0", - "solana-clock 2.2.2", - "solana-cpi 2.2.1", - "solana-define-syscall 2.3.0", + "solana-account-info", + "solana-clock", + "solana-cpi", + "solana-define-syscall", "solana-feature-gate-interface", - "solana-instruction 2.3.3", - "solana-instructions-sysvar 2.2.2", + "solana-instruction", + "solana-instructions-sysvar", "solana-invoke", "solana-loader-v3-interface", - "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-sdk-ids 2.2.1", - "solana-system-interface 1.0.0", - "solana-sysvar 2.3.0", - "solana-sysvar-id 2.2.1", + "solana-msg", + "solana-program-entrypoint", + "solana-program-error", + "solana-program-memory", + "solana-program-option", + "solana-program-pack", + "solana-pubkey", + "solana-sdk-ids", + "solana-system-interface", + "solana-sysvar", + "solana-sysvar-id", "thiserror 1.0.69", ] @@ -301,12 +289,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base64" version = "0.12.3" @@ -331,12 +313,6 @@ 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" @@ -403,7 +379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115e54d64eb62cdebad391c19efc9dce4981c690c85a33a12199d99bb9546fee" dependencies = [ "borsh-derive 0.10.4", - "hashbrown 0.13.2", + "hashbrown 0.12.3", ] [[package]] @@ -601,12 +577,6 @@ 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" @@ -634,18 +604,6 @@ 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" @@ -695,16 +653,6 @@ dependencies = [ "syn 2.0.109", ] -[[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 = "derivation-path" version = "0.2.0" @@ -740,7 +688,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid", "crypto-common", "subtle", ] @@ -770,7 +717,7 @@ dependencies = [ "pyth-solana-receiver-sdk", "pythnet-sdk", "serum_dex", - "solana-program 2.2.1", + "solana-program", "solana-security-txt", "static_assertions", "switchboard", @@ -787,20 +734,6 @@ dependencies = [ "syn 1.0.109", ] -[[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", - "spki", -] - [[package]] name = "either" version = "1.15.0" @@ -809,37 +742,18 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "ellipsis-macros" -version = "0.3.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06227214ab163577d89e20ac2b4646ee20fc8a243af83d79fedf16b5100c2f9f" +checksum = "0db15a500beac067d37fce7042bbaa349cf1303aadd902f8e0cfde4422d04403" dependencies = [ "bs58 0.4.0", "proc-macro2", "quote", "rustversion", - "solana-program 3.0.0", + "solana-program", "syn 1.0.109", ] -[[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 = "enumflags2" version = "0.6.4" @@ -881,16 +795,6 @@ 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 = [ - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "fiat-crypto" version = "0.2.9" @@ -922,15 +826,6 @@ dependencies = [ "five8_core", ] -[[package]] -name = "five8" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23f76610e969fa1784327ded240f1e28a3fd9520c9cec93b636fcf62dd37f772" -dependencies = [ - "five8_core", -] - [[package]] name = "five8_const" version = "0.1.4" @@ -966,7 +861,6 @@ checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2" dependencies = [ "typenum", "version_check", - "zeroize", ] [[package]] @@ -993,33 +887,13 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff", - "rand_core 0.6.4", - "subtle", -] - [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.8", -] - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.12", + "ahash", ] [[package]] @@ -1123,20 +997,6 @@ dependencies = [ "wasm-bindgen", ] -[[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", -] - [[package]] name = "keccak" version = "0.1.5" @@ -1437,7 +1297,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "phoenix-v1" version = "0.2.4" -source = "git+https://github.com/jordy25519/phoenix-v1?branch=master#7a6c68775efe3b5660fc9b2695b0f2054b746ceb" +source = "git+https://github.com/jordy25519/phoenix-v1?branch=master#fcf37149707a300cf42bfd5106bb675de53c8962" dependencies = [ "borsh 0.10.4", "bytemuck", @@ -1446,7 +1306,7 @@ dependencies = [ "lib-sokoban", "num_enum", "shank", - "solana-program 2.2.1", + "solana-program", "solana-security-txt", "spl-associated-token-account", "spl-token", @@ -1454,16 +1314,6 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der", - "spki", -] - [[package]] name = "polyval" version = "0.6.2" @@ -1568,7 +1418,7 @@ dependencies = [ "bytemuck", "byteorder", "pyth-lazer-protocol", - "solana-program 2.2.1", + "solana-program", "thiserror 1.0.69", ] @@ -1580,7 +1430,7 @@ dependencies = [ "anchor-lang", "hex", "pythnet-sdk", - "solana-program 2.2.1", + "solana-program", ] [[package]] @@ -1600,7 +1450,7 @@ dependencies = [ "serde", "sha3", "slow_primes", - "solana-program 2.2.1", + "solana-program", "thiserror 1.0.69", ] @@ -1717,16 +1567,6 @@ dependencies = [ "bytecheck", ] -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac", - "subtle", -] - [[package]] name = "rkyv" version = "0.7.45" @@ -1811,20 +1651,6 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" -[[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 = "semver" version = "1.0.27" @@ -1900,7 +1726,7 @@ dependencies = [ "num_enum", "safe-transmute", "serde", - "solana-program 2.2.1", + "solana-program", "spl-token", "static_assertions", "thiserror 1.0.69", @@ -1993,16 +1819,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[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 = "simdutf8" version = "0.1.5" @@ -2030,11 +1846,11 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f949fe4edaeaea78c844023bfc1c898e0b1f5a100f8a8d2d0f85d0a7b090258" dependencies = [ - "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-account-info", + "solana-clock", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", ] [[package]] @@ -2045,43 +1861,9 @@ checksum = "c8f5152a288ef1912300fc6efa6c2d1f9bb55d9398eb6c72326360b8063987da" dependencies = [ "bincode", "serde", - "solana-program-error 2.2.2", - "solana-program-memory 2.3.1", - "solana-pubkey 2.4.0", -] - -[[package]] -name = "solana-account-info" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82f4691b69b172c687d218dd2f1f23fc7ea5e9aa79df9ac26dab3d8dd829ce48" -dependencies = [ - "bincode", - "serde", - "solana-program-error 3.0.0", - "solana-program-memory 3.0.0", - "solana-pubkey 3.0.0", -] - -[[package]] -name = "solana-address" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a7a457086457ea9db9a5199d719dc8734dc2d0342fad0d8f77633c31eb62f19" -dependencies = [ - "borsh 1.5.7", - "bytemuck", - "bytemuck_derive", - "curve25519-dalek", - "five8 0.2.1", - "five8_const", - "serde", - "serde_derive", - "solana-atomic-u64 3.0.0", - "solana-define-syscall 3.0.0", - "solana-program-error 3.0.0", - "solana-sanitize 3.0.1", - "solana-sha256-hasher 3.0.1", + "solana-program-error", + "solana-program-memory", + "solana-pubkey", ] [[package]] @@ -2094,23 +1876,11 @@ dependencies = [ "bytemuck", "serde", "serde_derive", - "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 = [ - "solana-clock 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-slot-hashes 3.0.0", + "solana-clock", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", + "solana-slot-hashes", ] [[package]] @@ -2122,15 +1892,6 @@ dependencies = [ "parking_lot", ] -[[package]] -name = "solana-atomic-u64" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a933ff1e50aff72d02173cfcd7511bd8540b027ee720b75f353f594f834216d0" -dependencies = [ - "parking_lot", -] - [[package]] name = "solana-big-mod-exp" version = "2.2.1" @@ -2139,18 +1900,7 @@ checksum = "75db7f2bbac3e62cfd139065d15bcda9e2428883ba61fc8d27ccb251081e7567" dependencies = [ "num-bigint", "num-traits", - "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", - "num-traits", - "solana-define-syscall 3.0.0", + "solana-define-syscall", ] [[package]] @@ -2161,7 +1911,7 @@ checksum = "19a3787b8cf9c9fe3dd360800e8b70982b9e5a8af9e11c354b6665dd4a003adc" dependencies = [ "bincode", "serde", - "solana-instruction 2.3.3", + "solana-instruction", ] [[package]] @@ -2171,20 +1921,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1a0801e25a1b31a14494fc80882a036be0ffd290efc4c2d640bfcca120a4672" dependencies = [ "blake3", - "solana-define-syscall 2.3.0", - "solana-hash 2.3.0", - "solana-sanitize 2.2.1", -] - -[[package]] -name = "solana-blake3-hasher" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffa2e3bdac3339c6d0423275e45dafc5ac25f4d43bf344d026a3cc9a85e244a6" -dependencies = [ - "blake3", - "solana-define-syscall 3.0.0", - "solana-hash 3.1.0", + "solana-define-syscall", + "solana-hash", + "solana-sanitize", ] [[package]] @@ -2197,15 +1936,6 @@ dependencies = [ "borsh 1.5.7", ] -[[package]] -name = "solana-borsh" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc402b16657abbfa9991cd5cbfac5a11d809f7e7d28d3bb291baeb088b39060e" -dependencies = [ - "borsh 1.5.7", -] - [[package]] name = "solana-clock" version = "2.2.2" @@ -2214,22 +1944,9 @@ checksum = "1bb482ab70fced82ad3d7d3d87be33d466a3498eb8aa856434ff3c0dfc2e2e31" dependencies = [ "serde", "serde_derive", - "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.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -2238,26 +1955,12 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dc71126edddc2ba014622fc32d0f5e2e78ec6c5a1e0eb511b85618c09e9ea11" dependencies = [ - "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.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16238feb63d1cbdf915fb287f29ef7a7ebf81469bd6214f8b72a53866b593f8f" -dependencies = [ - "solana-account-info 3.0.0", - "solana-define-syscall 3.0.0", - "solana-instruction 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", - "solana-stable-layout 3.0.0", + "solana-account-info", + "solana-define-syscall", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-stable-layout", ] [[package]] @@ -2269,7 +1972,7 @@ dependencies = [ "bytemuck", "bytemuck_derive", "curve25519-dalek", - "solana-define-syscall 2.3.0", + "solana-define-syscall", "subtle", "thiserror 2.0.17", ] @@ -2289,12 +1992,6 @@ 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-derivation-path" version = "2.2.1" @@ -2314,24 +2011,10 @@ checksum = "86b575d3dd323b9ea10bb6fe89bf6bf93e249b215ba8ed7f68f1a3633f384db7" dependencies = [ "serde", "serde_derive", - "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.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-hash", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -2342,32 +2025,9 @@ checksum = "3fce071fbddecc55d727b1d7ed16a629afe4f6e4c217bc8d00af3b785f6f67ed" dependencies = [ "serde", "serde_derive", - "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.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.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", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -2378,37 +2038,16 @@ checksum = "84461d56cbb8bb8d539347151e0525b53910102e4bced875d49d5139708e39d3" dependencies = [ "serde", "serde_derive", - "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.0.0", - "solana-keccak-hasher 3.0.0", - "solana-message 3.0.1", - "solana-nonce 3.0.0", - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-system-interface 2.0.0", + "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.17", ] @@ -2422,13 +2061,13 @@ dependencies = [ "serde", "serde_derive", "solana-account", - "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", + "solana-account-info", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-system-interface", ] [[package]] @@ -2442,17 +2081,6 @@ 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-hash" version = "2.3.0" @@ -2462,45 +2090,20 @@ dependencies = [ "borsh 1.5.7", "bytemuck", "bytemuck_derive", - "five8 0.2.1", + "five8", "js-sys", "serde", "serde_derive", - "solana-atomic-u64 2.2.1", - "solana-sanitize 2.2.1", + "solana-atomic-u64", + "solana-sanitize", "wasm-bindgen", ] [[package]] -name = "solana-hash" -version = "3.1.0" +name = "solana-instruction" +version = "2.3.3" 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.5.7", - "bytemuck", - "bytemuck_derive", - "five8 1.0.0", - "serde", - "serde_derive", - "solana-atomic-u64 3.0.0", - "solana-sanitize 3.0.1", -] - -[[package]] -name = "solana-instruction" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab5682934bd1f65f8d2c16f21cb532526fcc1a09f796e2cacdb091eee5774ad" +checksum = "bab5682934bd1f65f8d2c16f21cb532526fcc1a09f796e2cacdb091eee5774ad" dependencies = [ "bincode", "borsh 1.5.7", @@ -2510,36 +2113,11 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "solana-define-syscall 2.3.0", - "solana-pubkey 2.4.0", + "solana-define-syscall", + "solana-pubkey", "wasm-bindgen", ] -[[package]] -name = "solana-instruction" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df4e8fcba01d7efa647ed20a081c234475df5e11a93acb4393cc2c9a7b99bab" -dependencies = [ - "bincode", - "borsh 1.5.7", - "serde", - "serde_derive", - "solana-define-syscall 3.0.0", - "solana-instruction-error", - "solana-pubkey 3.0.0", -] - -[[package]] -name = "solana-instruction-error" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f0d483b8ae387178d9210e0575b666b05cdd4bd0f2f188128249f6e454d39d" -dependencies = [ - "num-traits", - "solana-program-error 3.0.0", -] - [[package]] name = "solana-instructions-sysvar" version = "2.2.2" @@ -2547,32 +2125,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0e85a6fad5c2d0c4f5b91d34b8ca47118fc593af706e523cdbedf846a954f57" dependencies = [ "bitflags", - "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", - "solana-account-info 3.0.0", - "solana-instruction 3.0.0", - "solana-instruction-error", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", - "solana-sanitize 3.0.1", - "solana-sdk-ids 3.0.0", - "solana-serialize-utils 3.1.0", - "solana-sysvar-id 3.0.0", + "solana-account-info", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-sanitize", + "solana-sdk-ids", + "solana-serialize-utils", + "solana-sysvar-id", ] [[package]] @@ -2581,11 +2141,11 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58f5693c6de226b3626658377168b0184e94e8292ff16e3d31d4766e65627565" dependencies = [ - "solana-account-info 2.3.0", - "solana-define-syscall 2.3.0", - "solana-instruction 2.3.3", - "solana-program-entrypoint 2.3.0", - "solana-stable-layout 2.2.1", + "solana-account-info", + "solana-define-syscall", + "solana-instruction", + "solana-program-entrypoint", + "solana-stable-layout", ] [[package]] @@ -2595,20 +2155,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7aeb957fbd42a451b99235df4942d96db7ef678e8d5061ef34c9b34cae12f79" dependencies = [ "sha3", - "solana-define-syscall 2.3.0", - "solana-hash 2.3.0", - "solana-sanitize 2.2.1", -] - -[[package]] -name = "solana-keccak-hasher" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57eebd3012946913c8c1b8b43cdf8a6249edb09c0b6be3604ae910332a3acd97" -dependencies = [ - "sha3", - "solana-define-syscall 3.0.0", - "solana-hash 3.1.0", + "solana-define-syscall", + "solana-hash", + "solana-sanitize", ] [[package]] @@ -2619,22 +2168,9 @@ checksum = "4a6360ac2fdc72e7463565cd256eedcf10d7ef0c28a1249d261ec168c1b55cdd" dependencies = [ "serde", "serde_derive", - "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.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -2646,9 +2182,9 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-instruction 2.3.3", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", ] [[package]] @@ -2660,10 +2196,10 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-instruction 2.3.3", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", - "solana-system-interface 1.0.0", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", + "solana-system-interface", ] [[package]] @@ -2675,10 +2211,10 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "solana-instruction 2.3.3", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", - "solana-system-interface 1.0.0", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", + "solana-system-interface", ] [[package]] @@ -2693,51 +2229,24 @@ dependencies = [ "serde", "serde_derive", "solana-bincode", - "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", + "solana-hash", + "solana-instruction", + "solana-pubkey", + "solana-sanitize", + "solana-sdk-ids", + "solana-short-vec", + "solana-system-interface", + "solana-transaction-error", "wasm-bindgen", ] -[[package]] -name = "solana-message" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85666605c9fd727f865ed381665db0a8fc29f984a030ecc1e40f43bfb2541623" -dependencies = [ - "lazy_static", - "serde", - "serde_derive", - "solana-address", - "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-sanitize 3.0.1", - "solana-sdk-ids 3.0.0", - "solana-short-vec 3.0.0", - "solana-transaction-error 3.0.0", -] - [[package]] name = "solana-msg" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36a1a14399afaabc2781a1db09cb14ee4cc4ee5c7a5a3cfcc601811379a8092" dependencies = [ - "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", + "solana-define-syscall", ] [[package]] @@ -2746,12 +2255,6 @@ 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-nonce" version = "2.2.1" @@ -2760,22 +2263,10 @@ checksum = "703e22eb185537e06204a5bd9d509b948f0066f2d1d814a6f475dafb3ddf1325" dependencies = [ "serde", "serde_derive", - "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 = [ - "solana-fee-calculator 3.0.0", - "solana-hash 3.1.0", - "solana-pubkey 3.0.0", - "solana-sha256-hasher 3.0.1", + "solana-fee-calculator", + "solana-hash", + "solana-pubkey", + "solana-sha256-hasher", ] [[package]] @@ -2803,131 +2294,71 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "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-account-info", + "solana-address-lookup-table-interface", + "solana-atomic-u64", + "solana-big-mod-exp", "solana-bincode", - "solana-blake3-hasher 2.2.1", - "solana-borsh 2.2.1", - "solana-clock 2.2.2", - "solana-cpi 2.2.1", + "solana-blake3-hasher", + "solana-borsh", + "solana-clock", + "solana-cpi", "solana-decode-error", - "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-define-syscall", + "solana-epoch-rewards", + "solana-epoch-schedule", + "solana-example-mocks", "solana-feature-gate-interface", - "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-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 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-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 1.0.0", - "solana-sysvar 2.3.0", - "solana-sysvar-id 2.2.1", + "solana-system-interface", + "solana-sysvar", + "solana-sysvar-id", "solana-vote-interface", "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.0.0", - "solana-big-mod-exp 3.0.0", - "solana-blake3-hasher 3.0.0", - "solana-borsh 3.0.0", - "solana-clock 3.0.0", - "solana-cpi 3.0.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.0.0", - "solana-instruction-error", - "solana-instructions-sysvar 3.0.0", - "solana-keccak-hasher 3.0.0", - "solana-last-restart-slot 3.0.0", - "solana-msg 3.0.0", - "solana-native-token 3.0.0", - "solana-program-entrypoint 3.1.0", - "solana-program-error 3.0.0", - "solana-program-memory 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.0.0", - "solana-secp256k1-recover 3.0.0", - "solana-serde-varint 3.0.0", - "solana-serialize-utils 3.1.0", - "solana-sha256-hasher 3.0.1", - "solana-short-vec 3.0.0", - "solana-slot-hashes 3.0.0", - "solana-slot-history 3.0.0", - "solana-stable-layout 3.0.0", - "solana-sysvar 3.0.0", - "solana-sysvar-id 3.0.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 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.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6557cf5b5e91745d1667447438a1baa7823c6086e4ece67f8e6ebfa7a8f72660" -dependencies = [ - "solana-account-info 3.0.0", - "solana-define-syscall 3.0.0", - "solana-msg 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", + "solana-account-info", + "solana-msg", + "solana-program-error", + "solana-pubkey", ] [[package]] @@ -2941,20 +2372,9 @@ dependencies = [ "serde", "serde_derive", "solana-decode-error", - "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.5.7", - "serde", - "serde_derive", + "solana-instruction", + "solana-msg", + "solana-pubkey", ] [[package]] @@ -2963,16 +2383,7 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a5426090c6f3fd6cfdc10685322fede9ca8e5af43cd6a59e98bfe4e91671712" dependencies = [ - "solana-define-syscall 2.3.0", -] - -[[package]] -name = "solana-program-memory" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10e5660c60749c7bfb30b447542529758e4dbcecd31b1e8af1fdc92e2bdde90a" -dependencies = [ - "solana-define-syscall 3.0.0", + "solana-define-syscall", ] [[package]] @@ -2981,28 +2392,13 @@ 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 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", + "solana-program-error", ] [[package]] @@ -3016,30 +2412,21 @@ dependencies = [ "bytemuck", "bytemuck_derive", "curve25519-dalek", - "five8 0.2.1", + "five8", "five8_const", "getrandom 0.2.16", "js-sys", "num-traits", "serde", "serde_derive", - "solana-atomic-u64 2.2.1", + "solana-atomic-u64", "solana-decode-error", - "solana-define-syscall 2.3.0", - "solana-sanitize 2.2.1", - "solana-sha256-hasher 2.3.0", + "solana-define-syscall", + "solana-sanitize", + "solana-sha256-hasher", "wasm-bindgen", ] -[[package]] -name = "solana-pubkey" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8909d399deb0851aa524420beeb5646b115fd253ef446e35fe4504c904da3941" -dependencies = [ - "solana-address", -] - [[package]] name = "solana-rent" version = "2.2.1" @@ -3048,22 +2435,9 @@ checksum = "d1aea8fdea9de98ca6e8c2da5827707fb3842833521b528a713810ca685d2480" dependencies = [ "serde", "serde_derive", - "solana-sdk-ids 2.2.1", - "solana-sdk-macro 2.2.1", - "solana-sysvar-id 2.2.1", -] - -[[package]] -name = "solana-rent" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b702d8c43711e3c8a9284a4f1bbc6a3de2553deb25b0c8142f9a44ef0ce5ddc1" -dependencies = [ - "serde", - "serde_derive", - "solana-sdk-ids 3.0.0", - "solana-sdk-macro 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sdk-ids", + "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] @@ -3072,28 +2446,13 @@ 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-sdk-ids" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c5d8b9cc68d5c88b062a33e23a6466722467dde0035152d8fb1afbcdf350a5f" dependencies = [ - "solana-pubkey 2.4.0", -] - -[[package]] -name = "solana-sdk-ids" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1b6d6aaf60669c592838d382266b173881c65fb1cdec83b37cb8ce7cb89f9ad" -dependencies = [ - "solana-pubkey 3.0.0", + "solana-pubkey", ] [[package]] @@ -3108,18 +2467,6 @@ dependencies = [ "syn 2.0.109", ] -[[package]] -name = "solana-sdk-macro" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6430000e97083460b71d9fbadc52a2ab2f88f53b3a4c5e58c5ae3640a0e8c00" -dependencies = [ - "bs58 0.5.1", - "proc-macro2", - "quote", - "syn 2.0.109", -] - [[package]] name = "solana-secp256k1-recover" version = "2.2.1" @@ -3127,18 +2474,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baa3120b6cdaa270f39444f5093a90a7b03d296d362878f7a6991d6de3bbe496" dependencies = [ "libsecp256k1", - "solana-define-syscall 2.3.0", - "thiserror 2.0.17", -] - -[[package]] -name = "solana-secp256k1-recover" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "394a4470477d66296af5217970a905b1c5569032a7732c367fb69e5666c8607e" -dependencies = [ - "k256", - "solana-define-syscall 3.0.0", + "solana-define-syscall", "thiserror 2.0.17", ] @@ -3177,35 +2513,15 @@ dependencies = [ "serde", ] -[[package]] -name = "solana-serde-varint" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5174c57d5ff3c1995f274d17156964664566e2cde18a07bba1586d35a70d3b" -dependencies = [ - "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", + "solana-instruction", + "solana-pubkey", + "solana-sanitize", ] [[package]] @@ -3215,19 +2531,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa3feb32c28765f6aa1ce8f3feac30936f16c5c3f7eb73d63a5b8f6f8ecdc44" dependencies = [ "sha2 0.10.9", - "solana-define-syscall 2.3.0", - "solana-hash 2.3.0", -] - -[[package]] -name = "solana-sha256-hasher" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ab77481366a966f895abbc11896d4803d285d258281a992ca89aca3ed0658c" -dependencies = [ - "sha2 0.10.9", - "solana-define-syscall 3.0.0", - "solana-hash 3.1.0", + "solana-define-syscall", + "solana-hash", ] [[package]] @@ -3239,23 +2544,14 @@ dependencies = [ "serde", ] -[[package]] -name = "solana-short-vec" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b69d029da5428fc1c57f7d49101b2077c61f049d4112cd5fb8456567cc7d2638" -dependencies = [ - "serde", -] - [[package]] name = "solana-signature" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64c8ec8e657aecfc187522fc67495142c12f35e55ddeca8698edbb738b8dbd8c" dependencies = [ - "five8 0.2.1", - "solana-sanitize 2.2.1", + "five8", + "solana-sanitize", ] [[package]] @@ -3264,9 +2560,9 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c41991508a4b02f021c1342ba00bcfa098630b213726ceadc7cb032e051975b" dependencies = [ - "solana-pubkey 2.4.0", + "solana-pubkey", "solana-signature", - "solana-transaction-error 2.2.1", + "solana-transaction-error", ] [[package]] @@ -3277,22 +2573,9 @@ checksum = "0c8691982114513763e88d04094c9caa0376b867a29577939011331134c301ce" dependencies = [ "serde", "serde_derive", - "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.0.0", - "solana-sysvar-id 3.0.0", + "solana-hash", + "solana-sdk-ids", + "solana-sysvar-id", ] [[package]] @@ -3304,21 +2587,8 @@ dependencies = [ "bv", "serde", "serde_derive", - "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.0.0", - "solana-sysvar-id 3.0.0", + "solana-sdk-ids", + "solana-sysvar-id", ] [[package]] @@ -3327,18 +2597,8 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f14f7d02af8f2bc1b5efeeae71bc1c2b7f0f65cd75bcc7d8180f2c762a57f54" dependencies = [ - "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.0.0", - "solana-pubkey 3.0.0", + "solana-instruction", + "solana-pubkey", ] [[package]] @@ -3352,14 +2612,14 @@ dependencies = [ "num-traits", "serde", "serde_derive", - "solana-clock 2.2.2", - "solana-cpi 2.2.1", + "solana-clock", + "solana-cpi", "solana-decode-error", - "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", + "solana-instruction", + "solana-program-error", + "solana-pubkey", + "solana-system-interface", + "solana-sysvar-id", ] [[package]] @@ -3373,23 +2633,11 @@ dependencies = [ "serde", "serde_derive", "solana-decode-error", - "solana-instruction 2.3.3", - "solana-pubkey 2.4.0", + "solana-instruction", + "solana-pubkey", "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", - "solana-msg 3.0.0", - "solana-program-error 3.0.0", - "solana-pubkey 3.0.0", -] - [[package]] name = "solana-sysvar" version = "2.3.0" @@ -3403,62 +2651,28 @@ dependencies = [ "lazy_static", "serde", "serde_derive", - "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-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 2.2.1", -] - -[[package]] -name = "solana-sysvar" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63205e68d680bcc315337dec311b616ab32fea0a612db3b883ce4de02e0953f9" -dependencies = [ - "base64 0.22.1", - "bincode", - "bytemuck", - "bytemuck_derive", - "lazy_static", - "serde", - "serde_derive", - "solana-account-info 3.0.0", - "solana-clock 3.0.0", - "solana-define-syscall 3.0.0", - "solana-epoch-rewards 3.0.0", - "solana-epoch-schedule 3.0.0", - "solana-fee-calculator 3.0.0", - "solana-hash 3.1.0", - "solana-instruction 3.0.0", - "solana-last-restart-slot 3.0.0", - "solana-program-entrypoint 3.1.0", - "solana-program-error 3.0.0", - "solana-program-memory 3.0.0", - "solana-pubkey 3.0.0", - "solana-rent 3.0.0", - "solana-sdk-ids 3.0.0", - "solana-sdk-macro 3.0.0", - "solana-slot-hashes 3.0.0", - "solana-slot-history 3.0.0", - "solana-sysvar-id 3.0.0", + "solana-sysvar-id", ] [[package]] @@ -3467,18 +2681,8 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5762b273d3325b047cfda250787f8d796d781746860d5d0a746ee29f3e8812c1" dependencies = [ - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", -] - -[[package]] -name = "solana-sysvar-id" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5051bc1a16d5d96a96bc33b5b2ec707495c48fe978097bdaba68d3c47987eb32" -dependencies = [ - "solana-pubkey 3.0.0", - "solana-sdk-ids 3.0.0", + "solana-pubkey", + "solana-sdk-ids", ] [[package]] @@ -3487,18 +2691,8 @@ version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "222a9dc8fdb61c6088baab34fc3a8b8473a03a7a5fd404ed8dd502fa79b67cb1" dependencies = [ - "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 = [ - "solana-instruction-error", - "solana-sanitize 3.0.1", + "solana-instruction", + "solana-sanitize", ] [[package]] @@ -3512,17 +2706,17 @@ dependencies = [ "num-traits", "serde", "serde_derive", - "solana-clock 2.2.2", + "solana-clock", "solana-decode-error", - "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", + "solana-hash", + "solana-instruction", + "solana-pubkey", + "solana-rent", + "solana-sdk-ids", + "solana-serde-varint", + "solana-serialize-utils", + "solana-short-vec", + "solana-system-interface", ] [[package]] @@ -3548,9 +2742,9 @@ dependencies = [ "serde_json", "sha3", "solana-derivation-path", - "solana-instruction 2.3.3", - "solana-pubkey 2.4.0", - "solana-sdk-ids 2.2.1", + "solana-instruction", + "solana-pubkey", + "solana-sdk-ids", "solana-seed-derivable", "solana-seed-phrase", "solana-signature", @@ -3561,16 +2755,6 @@ dependencies = [ "zeroize", ] -[[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" @@ -3580,7 +2764,7 @@ dependencies = [ "borsh 1.5.7", "num-derive 0.4.2", "num-traits", - "solana-program 2.2.1", + "solana-program", "spl-associated-token-account-client", "spl-token", "spl-token-2022", @@ -3593,8 +2777,8 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6f8349dbcbe575f354f9a533a21f272f3eb3808a49e2fdc1c34393b88ba76cb" dependencies = [ - "solana-instruction 2.3.3", - "solana-pubkey 2.4.0", + "solana-instruction", + "solana-pubkey", ] [[package]] @@ -3604,8 +2788,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7398da23554a31660f17718164e31d31900956054f54f52d5ec1be51cb4f4b3" dependencies = [ "bytemuck", - "solana-program-error 2.2.2", - "solana-sha256-hasher 2.3.0", + "solana-program-error", + "solana-sha256-hasher", "spl-discriminator-derive", ] @@ -3640,17 +2824,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65edfeed09cd4231e595616aa96022214f9c9d2be02dea62c2b30d5695a6833a" dependencies = [ "bytemuck", - "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-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", "spl-pod", "spl-token-confidential-transfer-proof-extraction", @@ -3662,12 +2846,12 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f09647c0974e33366efeb83b8e2daebb329f0420149e74d3a4bd2c08cf9f7cb" dependencies = [ - "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", + "solana-account-info", + "solana-instruction", + "solana-msg", + "solana-program-entrypoint", + "solana-program-error", + "solana-pubkey", ] [[package]] @@ -3682,10 +2866,10 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "solana-decode-error", - "solana-msg 2.2.1", - "solana-program-error 2.2.2", - "solana-program-option 2.2.1", - "solana-pubkey 2.4.0", + "solana-msg", + "solana-program-error", + "solana-program-option", + "solana-pubkey", "solana-zk-sdk", "thiserror 2.0.17", ] @@ -3699,8 +2883,8 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "solana-decode-error", - "solana-msg 2.2.1", - "solana-program-error 2.2.2", + "solana-msg", + "solana-program-error", "spl-program-error-derive", "thiserror 2.0.17", ] @@ -3726,12 +2910,12 @@ dependencies = [ "bytemuck", "num-derive 0.4.2", "num-traits", - "solana-account-info 2.3.0", + "solana-account-info", "solana-decode-error", - "solana-instruction 2.3.3", - "solana-msg 2.2.1", - "solana-program-error 2.2.2", - "solana-pubkey 2.4.0", + "solana-instruction", + "solana-msg", + "solana-program-error", + "solana-pubkey", "spl-discriminator", "spl-pod", "spl-program-error", @@ -3750,20 +2934,20 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "num_enum", - "solana-account-info 2.3.0", - "solana-cpi 2.2.1", + "solana-account-info", + "solana-cpi", "solana-decode-error", - "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", + "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.17", ] @@ -3778,24 +2962,24 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "num_enum", - "solana-account-info 2.3.0", - "solana-clock 2.2.2", - "solana-cpi 2.2.1", + "solana-account-info", + "solana-clock", + "solana-cpi", "solana-decode-error", - "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-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-security-txt", - "solana-system-interface 1.0.0", - "solana-sysvar 2.3.0", + "solana-system-interface", + "solana-sysvar", "solana-zk-sdk", "spl-elgamal-registry", "spl-memo", @@ -3830,14 +3014,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe2629860ff04c17bafa9ba4bed8850a404ecac81074113e1f840dbd0ebb7bd6" dependencies = [ "bytemuck", - "solana-account-info 2.3.0", + "solana-account-info", "solana-curve25519", - "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-instruction", + "solana-instructions-sysvar", + "solana-msg", + "solana-program-error", + "solana-pubkey", + "solana-sdk-ids", "solana-zk-sdk", "spl-pod", "thiserror 2.0.17", @@ -3864,10 +3048,10 @@ dependencies = [ "num-derive 0.4.2", "num-traits", "solana-decode-error", - "solana-instruction 2.3.3", - "solana-msg 2.2.1", - "solana-program-error 2.2.2", - "solana-pubkey 2.4.0", + "solana-instruction", + "solana-msg", + "solana-program-error", + "solana-pubkey", "spl-discriminator", "spl-pod", "thiserror 2.0.17", @@ -3882,12 +3066,12 @@ dependencies = [ "borsh 1.5.7", "num-derive 0.4.2", "num-traits", - "solana-borsh 2.2.1", + "solana-borsh", "solana-decode-error", - "solana-instruction 2.3.3", - "solana-msg 2.2.1", - "solana-program-error 2.2.2", - "solana-pubkey 2.4.0", + "solana-instruction", + "solana-msg", + "solana-program-error", + "solana-pubkey", "spl-discriminator", "spl-pod", "spl-type-length-value", @@ -3904,13 +3088,13 @@ dependencies = [ "bytemuck", "num-derive 0.4.2", "num-traits", - "solana-account-info 2.3.0", - "solana-cpi 2.2.1", + "solana-account-info", + "solana-cpi", "solana-decode-error", - "solana-instruction 2.3.3", - "solana-msg 2.2.1", - "solana-program-error 2.2.2", - "solana-pubkey 2.4.0", + "solana-instruction", + "solana-msg", + "solana-program-error", + "solana-pubkey", "spl-discriminator", "spl-pod", "spl-program-error", @@ -3928,10 +3112,10 @@ dependencies = [ "bytemuck", "num-derive 0.4.2", "num-traits", - "solana-account-info 2.3.0", + "solana-account-info", "solana-decode-error", - "solana-msg 2.2.1", - "solana-program-error 2.2.2", + "solana-msg", + "solana-program-error", "spl-discriminator", "spl-pod", "thiserror 2.0.17", @@ -3964,7 +3148,7 @@ dependencies = [ "anchor-lang", "base64 0.13.1", "bytemuck", - "solana-program 2.2.1", + "solana-program", ] [[package]] diff --git a/programs/switchboard-on-demand/Cargo.toml b/programs/switchboard-on-demand/Cargo.toml index 8e7876cd99..02df150f4d 100644 --- a/programs/switchboard-on-demand/Cargo.toml +++ b/programs/switchboard-on-demand/Cargo.toml @@ -18,7 +18,7 @@ anchor-test= [] [dependencies] anchor-lang = "0.32.1" bytemuck = { version = "1.4.0" } -solana-program = "2" +solana-program = "=2.2.1" [dev-dependencies] base64 = "0.13.0" From 234269ebbad95d097dc1dc3acdc89b142f81aad8 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Thu, 6 Nov 2025 23:19:51 +0800 Subject: [PATCH 04/25] update ci cargo and solana version --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a327ad3bee..02fb64a222 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,8 +13,8 @@ defaults: env: CARGO_TERM_COLOR: always - RUST_TOOLCHAIN: 1.70.0 - SOLANA_VERSION: "1.16.27" + RUST_TOOLCHAIN: 1.87.0 + SOLANA_VERSION: "2.2.1" jobs: fmt-clippy: From 64dbde372a91832e7cd849f8eb453299a1dceb4e Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Thu, 6 Nov 2025 23:29:57 +0800 Subject: [PATCH 05/25] fix --- .github/workflows/main.yml | 2 +- programs/drift/src/math/liquidation/tests.rs | 2 +- programs/drift/src/math/orders/tests.rs | 2 +- programs/drift/src/state/perp_market_map.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 02fb64a222..1c17966a45 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ defaults: env: CARGO_TERM_COLOR: always RUST_TOOLCHAIN: 1.87.0 - SOLANA_VERSION: "2.2.1" + SOLANA_VERSION: "1.16.27" jobs: fmt-clippy: diff --git a/programs/drift/src/math/liquidation/tests.rs b/programs/drift/src/math/liquidation/tests.rs index b968bb6629..04c066b76e 100644 --- a/programs/drift/src/math/liquidation/tests.rs +++ b/programs/drift/src/math/liquidation/tests.rs @@ -610,7 +610,7 @@ mod validate_transfer_satisfies_limit_price { let limit_price = PRICE_PRECISION_U64 * 100; // $100 / 1 SOL let asset = 100 * QUOTE_PRECISION; let asset_decimals = 6_u32; - let liability = LAMPORTS_PER_SOL as u128; + let liability = LAMPORTS_PER_SOL_U64 as u128; let liability_decimals = 9_u32; assert!(validate_transfer_satisfies_limit_price( diff --git a/programs/drift/src/math/orders/tests.rs b/programs/drift/src/math/orders/tests.rs index cd790e2519..ffb3d11380 100644 --- a/programs/drift/src/math/orders/tests.rs +++ b/programs/drift/src/math/orders/tests.rs @@ -501,7 +501,7 @@ mod get_max_fill_amounts { let (max_base, max_quote) = get_max_fill_amounts(&user, 0, &base_market, "e_market, true).unwrap(); - assert_eq!(max_base, Some(100 * LAMPORTS_PER_SOL)); + assert_eq!(max_base, Some(100 * LAMPORTS_PER_SOL_U64)); assert_eq!(max_quote, None); } diff --git a/programs/drift/src/state/perp_market_map.rs b/programs/drift/src/state/perp_market_map.rs index 1b41122107..28367fb7ae 100644 --- a/programs/drift/src/state/perp_market_map.rs +++ b/programs/drift/src/state/perp_market_map.rs @@ -154,7 +154,7 @@ impl<'a> PerpMarketMap<'a> { } let account_discriminator = &data[..8]; - if account_discriminator != &PerpMarket::DISCRIMINATOR { + if account_discriminator != PerpMarket::DISCRIMINATOR { return Err(ErrorCode::CouldNotLoadMarketData); } From 926f39c298ffbe4ecda6f0db7dc9b2e05d7448b0 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Fri, 7 Nov 2025 14:04:13 +0800 Subject: [PATCH 06/25] anchor 32.1 install --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c17966a45..bbf357009c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -119,11 +119,11 @@ jobs: uses: actions/cache@v4 with: path: ~/.cargo/bin/anchor - key: ${{ runner.os }}-anchor-cli-0.29.0 + key: ${{ runner.os }}-anchor-cli-0.32.1 - name: Install Anchor CLI if: steps.cache-anchor.outputs.cache-hit != 'true' - run: cargo install --git https://github.com/coral-xyz/anchor --tag v0.29.0 anchor-cli --locked + run: cargo install --git https://github.com/coral-xyz/anchor --tag v0.32.1 anchor-cli --locked - name: Setup node uses: actions/setup-node@v2 From f7c2e7ecf68e37df01124ecbe8d70a4ce801d522 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Fri, 7 Nov 2025 14:25:22 +0800 Subject: [PATCH 07/25] instal libudev --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bbf357009c..3dfa9ac926 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -123,7 +123,9 @@ jobs: - name: Install Anchor CLI if: steps.cache-anchor.outputs.cache-hit != 'true' - run: cargo install --git https://github.com/coral-xyz/anchor --tag v0.32.1 anchor-cli --locked + run: | + apt install libudev-dev + cargo install --git https://github.com/coral-xyz/anchor --tag v0.32.1 anchor-cli --locked - name: Setup node uses: actions/setup-node@v2 From 2abf33d06fe476b2c52511c38a74bac557e76c8e Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 10 Nov 2025 10:42:12 +0800 Subject: [PATCH 08/25] retry --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3dfa9ac926..2e57e66554 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -124,7 +124,7 @@ jobs: - name: Install Anchor CLI if: steps.cache-anchor.outputs.cache-hit != 'true' run: | - apt install libudev-dev + sudo apt install libudev-dev cargo install --git https://github.com/coral-xyz/anchor --tag v0.32.1 anchor-cli --locked - name: Setup node From aed98e1624a9dcc6a984bff96a80ff0f76c94a52 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 10 Nov 2025 14:16:12 +0800 Subject: [PATCH 09/25] overflow-checks true --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index f686c06993..6129c26246 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ resolver = "2" [profile.release] lto = "fat" codegen-units = 1 +overflow-checks = true [profile.release.build-override] opt-level = 3 From 2900d2b8cad97c6de92aa52426c30a22723dc202 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Tue, 18 Nov 2025 09:11:24 +0800 Subject: [PATCH 10/25] anchor 32 (part 2) (#2025) * weow it compiels * update deps --- Cargo.lock | 5 +- programs/drift/Cargo.toml | 6 +- programs/drift/src/controller/amm.rs | 239 +-- programs/drift/src/controller/amm/tests.rs | 807 +++++----- programs/drift/src/controller/funding.rs | 44 +- programs/drift/src/controller/insurance.rs | 319 ++-- .../drift/src/controller/insurance/tests.rs | 331 ++--- programs/drift/src/controller/liquidation.rs | 63 +- .../drift/src/controller/liquidation/tests.rs | 1302 +++++++++-------- programs/drift/src/controller/lp.rs | 30 +- programs/drift/src/controller/orders.rs | 68 +- .../src/controller/orders/amm_jit_tests.rs | 596 ++++---- .../drift/src/controller/orders/fuel_tests.rs | 118 +- programs/drift/src/controller/orders/tests.rs | 1164 ++++++++------- programs/drift/src/controller/pnl.rs | 20 +- .../drift/src/controller/pnl/delisting.rs | 532 +++---- programs/drift/src/controller/pnl/tests.rs | 504 ++++--- programs/drift/src/controller/position.rs | 300 ++-- .../drift/src/controller/position/tests.rs | 664 +++++---- programs/drift/src/controller/repeg.rs | 54 +- programs/drift/src/controller/repeg/tests.rs | 120 +- .../drift/src/controller/revenue_share.rs | 2 +- programs/drift/src/controller/spot_balance.rs | 48 +- .../src/controller/spot_balance/tests.rs | 384 ++--- .../src/controller/spot_position/tests.rs | 8 +- programs/drift/src/instructions/admin.rs | 344 ++--- programs/drift/src/instructions/if_staker.rs | 13 +- programs/drift/src/instructions/keeper.rs | 23 +- programs/drift/src/instructions/lp_admin.rs | 18 +- programs/drift/src/instructions/lp_pool.rs | 66 +- programs/drift/src/instructions/user.rs | 121 +- programs/drift/src/lib.rs | 3 +- programs/drift/src/math/amm.rs | 42 +- programs/drift/src/math/amm/tests.rs | 124 +- programs/drift/src/math/amm_jit.rs | 2 +- programs/drift/src/math/amm_jit/tests.rs | 8 +- programs/drift/src/math/amm_spread.rs | 18 +- programs/drift/src/math/amm_spread/tests.rs | 116 +- programs/drift/src/math/bn.rs | 276 ++++ programs/drift/src/math/cp_curve.rs | 46 +- programs/drift/src/math/cp_curve/tests.rs | 122 +- programs/drift/src/math/fees.rs | 1 + programs/drift/src/math/fees/tests.rs | 4 +- programs/drift/src/math/floor_div.rs | 1 - programs/drift/src/math/fulfillment/tests.rs | 260 ++-- programs/drift/src/math/funding.rs | 26 +- programs/drift/src/math/funding/tests.rs | 125 +- programs/drift/src/math/insurance.rs | 9 +- programs/drift/src/math/insurance/tests.rs | 62 +- programs/drift/src/math/liquidation.rs | 8 +- programs/drift/src/math/liquidation/tests.rs | 16 +- programs/drift/src/math/margin.rs | 8 +- programs/drift/src/math/margin/tests.rs | 576 ++++---- programs/drift/src/math/oracle.rs | 2 +- programs/drift/src/math/oracle/tests.rs | 6 +- programs/drift/src/math/orders/tests.rs | 380 ++--- programs/drift/src/math/position.rs | 6 +- programs/drift/src/math/repeg.rs | 62 +- programs/drift/src/math/repeg/tests.rs | 130 +- programs/drift/src/math/spot_balance.rs | 18 +- programs/drift/src/math/spot_balance/tests.rs | 2 +- programs/drift/src/math/spot_withdraw.rs | 16 +- programs/drift/src/state/amm_cache.rs | 12 +- programs/drift/src/state/constituent_map.rs | 4 +- programs/drift/src/state/events.rs | 6 +- .../src/state/fulfillment_params/serum.rs | 2 +- .../drift/src/state/insurance_fund_stake.rs | 33 +- programs/drift/src/state/load_ref.rs | 1 - programs/drift/src/state/lp_pool.rs | 55 +- programs/drift/src/state/lp_pool/tests.rs | 83 +- programs/drift/src/state/oracle.rs | 10 +- programs/drift/src/state/oracle/tests.rs | 20 +- programs/drift/src/state/oracle_map.rs | 1 - programs/drift/src/state/order_params.rs | 6 +- .../drift/src/state/order_params/tests.rs | 80 +- programs/drift/src/state/perp_market.rs | 171 ++- programs/drift/src/state/perp_market/tests.rs | 28 +- programs/drift/src/state/perp_market_map.rs | 4 +- programs/drift/src/state/revenue_share.rs | 13 +- programs/drift/src/state/revenue_share_map.rs | 4 +- programs/drift/src/state/settle_pnl_mode.rs | 2 +- programs/drift/src/state/signed_msg_user.rs | 8 +- programs/drift/src/state/spot_market.rs | 57 +- programs/drift/src/state/spot_market_map.rs | 8 +- programs/drift/src/state/state.rs | 9 +- programs/drift/src/state/user.rs | 61 +- programs/drift/src/state/user/tests.rs | 76 +- programs/drift/src/state/user_map.rs | 8 +- programs/drift/src/validation/perp_market.rs | 96 +- .../drift/src/validation/sig_verification.rs | 2 +- programs/openbook_v2/src/lib.rs | 1 + programs/pyth/src/lib.rs | 1 + programs/switchboard-on-demand/src/lib.rs | 42 +- programs/switchboard/src/lib.rs | 2 + programs/token_faucet/src/lib.rs | 2 + 95 files changed, 6325 insertions(+), 5371 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c6337d630f..711a28e6f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -728,9 +728,10 @@ dependencies = [ [[package]] name = "drift-macros" version = "0.1.0" -source = "git+https://github.com/drift-labs/drift-macros.git?rev=c57d87#c57d87e073d13d43f4d1fb09fe6822915a4ccc11" +source = "git+https://github.com/drift-labs/drift-macros?rev=92192a1#92192a1efdfa0ddef3ae06e20e24462ea3bbdc0f" dependencies = [ "quote", + "static_assertions", "syn 1.0.109", ] @@ -1713,7 +1714,7 @@ dependencies = [ [[package]] name = "serum_dex" version = "0.5.6" -source = "git+https://github.com/jordy25519/serum-dex?branch=master#2347e4810ace967ab186202e22b6188b9cab03ba" +source = "git+https://github.com/drift-labs/serum-dex?branch=master#2347e4810ace967ab186202e22b6188b9cab03ba" dependencies = [ "arrayref", "bincode", diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index 3fb45115f0..6ab9c48c48 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -27,19 +27,19 @@ pyth-lazer-solana-contract = { git = "https://github.com/jordy25519/pyth-crossch pythnet-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master"} pyth-solana-receiver-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master"} bytemuck = { version = "1.4.0" } -borsh = "0.10.3" +borsh = "0.10.4" hex = "0.4.3" uint = { version = "0.9.1", default-features = false } num-integer = "0.1.44" num-traits = "0.2" arrayref = "0.3.6" base64 = "0.13.0" -serum_dex = { git = "https://github.com/jordy25519/serum-dex", branch = "master", features = ["no-entrypoint"] } +serum_dex = { git = "https://github.com/drift-labs/serum-dex", branch = "master", features = ["no-entrypoint"] } enumflags2 = "0.6.4" phoenix-v1 = { git = "https://github.com/jordy25519/phoenix-v1", branch = "master", features = ["no-entrypoint"] } solana-security-txt = "1.1.0" static_assertions = "1.1.0" -drift-macros = { git = "https://github.com/drift-labs/drift-macros.git", rev = "c57d87" } +drift-macros = { git = "https://github.com/drift-labs/drift-macros", rev = "92192a1" } switchboard = { path = "../switchboard", features = ["no-entrypoint"] } openbook-v2-light = { path = "../openbook_v2", features = ["no-entrypoint"] } switchboard-on-demand = { path = "../switchboard-on-demand", features = ["no-entrypoint"] } diff --git a/programs/drift/src/controller/amm.rs b/programs/drift/src/controller/amm.rs index e25a578bf6..534d7b612f 100644 --- a/programs/drift/src/controller/amm.rs +++ b/programs/drift/src/controller/amm.rs @@ -87,8 +87,8 @@ pub fn swap_base_asset( quote_asset_amount_surplus, ) = calculate_base_swap_output_with_spread(&market.amm, base_asset_swap_amount, direction)?; - market.amm.base_asset_reserve = new_base_asset_reserve; - market.amm.quote_asset_reserve = new_quote_asset_reserve; + market.amm.set_base_asset_reserve(new_base_asset_reserve); + market.amm.set_quote_asset_reserve(new_quote_asset_reserve); Ok(( quote_asset_amount, @@ -114,33 +114,33 @@ pub fn calculate_base_swap_output_with_spread( base_asset_swap_amount.cast()?, base_asset_reserve_with_spread, direction, - amm.sqrt_k, + amm.sqrt_k(), )?; let quote_asset_amount = calculate_quote_asset_amount_swapped( quote_asset_reserve_with_spread, new_quote_asset_reserve_with_spread, direction, - amm.peg_multiplier, + amm.peg_multiplier(), )?; let (new_quote_asset_reserve, new_base_asset_reserve) = amm::calculate_swap_output( base_asset_swap_amount.cast()?, - amm.base_asset_reserve, + amm.base_asset_reserve(), direction, - amm.sqrt_k, + amm.sqrt_k(), )?; // calculate the quote asset surplus by taking the difference between what quote_asset_amount is // with and without spread let quote_asset_amount_surplus = calculate_quote_asset_amount_surplus( new_quote_asset_reserve, - amm.quote_asset_reserve, + amm.quote_asset_reserve(), match direction { SwapDirection::Remove => SwapDirection::Add, SwapDirection::Add => SwapDirection::Remove, }, - amm.peg_multiplier, + amm.peg_multiplier(), quote_asset_amount, direction == SwapDirection::Remove, )?; @@ -160,19 +160,31 @@ pub fn update_spread_reserves(market: &mut PerpMarket) -> DriftResult { calculate_spread_reserves(market, PositionDirection::Short)?; if market.amm.reference_price_offset == 0 { - market.amm.ask_base_asset_reserve = - new_ask_base_asset_reserve.min(market.amm.base_asset_reserve); - market.amm.bid_base_asset_reserve = - new_bid_base_asset_reserve.max(market.amm.base_asset_reserve); - market.amm.ask_quote_asset_reserve = - new_ask_quote_asset_reserve.max(market.amm.quote_asset_reserve); - market.amm.bid_quote_asset_reserve = - new_bid_quote_asset_reserve.min(market.amm.quote_asset_reserve); + market.amm.set_ask_base_asset_reserve( + new_ask_base_asset_reserve.min(market.amm.base_asset_reserve()), + ); + market.amm.set_bid_base_asset_reserve( + new_bid_base_asset_reserve.max(market.amm.base_asset_reserve()), + ); + market.amm.set_ask_quote_asset_reserve( + new_ask_quote_asset_reserve.max(market.amm.quote_asset_reserve()), + ); + market.amm.set_bid_quote_asset_reserve( + new_bid_quote_asset_reserve.min(market.amm.quote_asset_reserve()), + ); } else { - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); } Ok(()) @@ -188,10 +200,10 @@ pub fn update_spreads( let reference_price_offset = if max_ref_offset > 0 { let liquidity_ratio = amm_spread::calculate_inventory_liquidity_ratio_for_reference_price_offset( - market.amm.base_asset_amount_with_amm, - market.amm.base_asset_reserve, - market.amm.min_base_asset_reserve, - market.amm.max_base_asset_reserve, + market.amm.base_asset_amount_with_amm(), + market.amm.base_asset_reserve(), + market.amm.min_base_asset_reserve(), + market.amm.max_base_asset_reserve(), )?; let signed_liquidity_ratio = @@ -233,16 +245,16 @@ pub fn update_spreads( market.amm.last_oracle_reserve_price_spread_pct, market.amm.last_oracle_conf_pct, market.amm.max_spread, - market.amm.quote_asset_reserve, - market.amm.terminal_quote_asset_reserve, - market.amm.peg_multiplier, - market.amm.base_asset_amount_with_amm, + market.amm.quote_asset_reserve(), + market.amm.terminal_quote_asset_reserve(), + market.amm.peg_multiplier(), + market.amm.base_asset_amount_with_amm(), reserve_price, - market.amm.total_fee_minus_distributions, + market.amm.total_fee_minus_distributions(), market.amm.net_revenue_since_last_funding, - market.amm.base_asset_reserve, - market.amm.min_base_asset_reserve, - market.amm.max_base_asset_reserve, + market.amm.base_asset_reserve(), + market.amm.min_base_asset_reserve(), + market.amm.max_base_asset_reserve(), market.amm.mark_std, market.amm.oracle_std, market.amm.long_intensity_volume, @@ -356,13 +368,13 @@ pub fn update_concentration_coef(market: &mut PerpMarket, scale: u128) -> DriftR "invalid new_concentration_coef", )?; - market.amm.concentration_coef = new_concentration_coef; + market.amm.set_concentration_coef(new_concentration_coef); let (_, terminal_quote_reserves, terminal_base_reserves) = amm::calculate_terminal_price_and_reserves(&market.amm)?; validate!( - terminal_quote_reserves == market.amm.terminal_quote_asset_reserve, + terminal_quote_reserves == market.amm.terminal_quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "invalid terminal_quote_reserves", )?; @@ -371,17 +383,21 @@ pub fn update_concentration_coef(market: &mut PerpMarket, scale: u128) -> DriftR // doing so adds ability to improve amm constant product curve's slippage // by increasing k as same factor as scale w/o increasing imbalance risk let (min_base_asset_reserve, max_base_asset_reserve) = - amm::calculate_bid_ask_bounds(market.amm.concentration_coef, terminal_base_reserves)?; + amm::calculate_bid_ask_bounds(market.amm.concentration_coef(), terminal_base_reserves)?; - market.amm.max_base_asset_reserve = max_base_asset_reserve; - market.amm.min_base_asset_reserve = min_base_asset_reserve; + market + .amm + .set_max_base_asset_reserve(max_base_asset_reserve); + market + .amm + .set_min_base_asset_reserve(min_base_asset_reserve); let reserve_price_after = market.amm.reserve_price()?; update_spreads(market, reserve_price_after, None)?; let (max_bids, max_asks) = amm::calculate_market_open_bids_asks(&market.amm)?; validate!( - max_bids > market.amm.base_asset_amount_with_amm && max_asks < market.amm.base_asset_amount_with_amm, + max_bids > market.amm.base_asset_amount_with_amm() && max_asks < market.amm.base_asset_amount_with_amm(), ErrorCode::InvalidConcentrationCoef, "amm.base_asset_amount_with_amm exceeds the unload liquidity available after concentration adjustment" )?; @@ -395,10 +411,10 @@ pub fn formulaic_update_k( funding_imbalance_cost: i128, now: i64, ) -> DriftResult { - let peg_multiplier_before = market.amm.peg_multiplier; - let base_asset_reserve_before = market.amm.base_asset_reserve; - let quote_asset_reserve_before = market.amm.quote_asset_reserve; - let sqrt_k_before = market.amm.sqrt_k; + let peg_multiplier_before = market.amm.peg_multiplier(); + let base_asset_reserve_before = market.amm.base_asset_reserve(); + let quote_asset_reserve_before = market.amm.quote_asset_reserve(); + let sqrt_k_before = market.amm.sqrt_k(); let funding_imbalance_cost_i64 = funding_imbalance_cost.cast::()?; @@ -419,7 +435,9 @@ pub fn formulaic_update_k( 0 }; - if (budget > 0 && market.amm.sqrt_k < MAX_SQRT_K) || (budget < 0 && market.amm.can_lower_k()?) { + if (budget > 0 && market.amm.sqrt_k() < MAX_SQRT_K) + || (budget < 0 && market.amm.can_lower_k()?) + { // single k scale is capped by .1% increase and .1% decrease (regardless of budget) let k_pct_upper_bound = K_BPS_UPDATE_SCALE + MAX_K_BPS_INCREASE * (market.amm.curve_update_intensity as i128) / 100; @@ -433,7 +451,7 @@ pub fn formulaic_update_k( k_pct_lower_bound, )?; - let new_sqrt_k = bn::U192::from(market.amm.sqrt_k) + let new_sqrt_k = bn::U192::from(market.amm.sqrt_k()) .safe_mul(bn::U192::from(k_scale_numerator))? .safe_div(bn::U192::from(k_scale_denominator))?; @@ -446,10 +464,10 @@ pub fn formulaic_update_k( if cost_applied { cp_curve::update_k(market, &update_k_result)?; - let peg_multiplier_after = market.amm.peg_multiplier; - let base_asset_reserve_after = market.amm.base_asset_reserve; - let quote_asset_reserve_after = market.amm.quote_asset_reserve; - let sqrt_k_after = market.amm.sqrt_k; + let peg_multiplier_after = market.amm.peg_multiplier(); + let base_asset_reserve_after = market.amm.base_asset_reserve(); + let quote_asset_reserve_after = market.amm.quote_asset_reserve(); + let sqrt_k_after = market.amm.sqrt_k(); emit!(CurveRecord { ts: now, @@ -463,13 +481,13 @@ pub fn formulaic_update_k( base_asset_reserve_after, quote_asset_reserve_after, sqrt_k_after, - base_asset_amount_long: market.amm.base_asset_amount_long.unsigned_abs(), - base_asset_amount_short: market.amm.base_asset_amount_short.unsigned_abs(), - base_asset_amount_with_amm: market.amm.base_asset_amount_with_amm, + base_asset_amount_long: market.amm.base_asset_amount_long().unsigned_abs(), + base_asset_amount_short: market.amm.base_asset_amount_short().unsigned_abs(), + base_asset_amount_with_amm: market.amm.base_asset_amount_with_amm(), number_of_users: market.number_of_users, adjustment_cost, - total_fee: market.amm.total_fee, - total_fee_minus_distributions: market.amm.total_fee_minus_distributions, + total_fee: market.amm.total_fee(), + total_fee_minus_distributions: market.amm.total_fee_minus_distributions(), oracle_price: market.amm.historical_oracle_data.last_oracle_price, fill_record: market.next_fill_record_id as u128, }); @@ -511,14 +529,14 @@ fn calculate_revenue_pool_transfer( let fee_pool_threshold = amm_fee_pool_token_amount_after .saturating_sub( FEE_POOL_TO_REVENUE_POOL_THRESHOLD - .safe_add(market.amm.total_social_loss)? + .safe_add(market.amm.total_social_loss())? .cast()?, ) .cast()?; let total_liq_fees_for_revenue_pool = market .amm - .total_liquidation_fee + .total_liquidation_fee() .min( market .insurance_claim @@ -544,7 +562,7 @@ fn calculate_revenue_pool_transfer( let revenue_pool_transfer = total_fee_for_if .safe_add(total_liq_fees_for_revenue_pool)? - .saturating_sub(market.amm.total_fee_withdrawn.cast()?) + .saturating_sub(market.amm.total_fee_withdrawn().cast()?) .max(0) .min(fee_pool_threshold) .min(max_revenue_to_settle.cast()?); @@ -566,7 +584,7 @@ fn calculate_revenue_pool_transfer( .cast::()? .min( get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), spot_market, &SpotBalanceType::Deposit, )? @@ -611,9 +629,9 @@ pub fn update_pool_balances( let amm_target_max_fee_pool_token_amount = market .amm - .total_fee_minus_distributions - .safe_add(market.amm.total_liquidation_fee.cast()?)? - .safe_sub(market.amm.total_fee_withdrawn.cast()?)?; + .total_fee_minus_distributions() + .safe_add(market.amm.total_liquidation_fee().cast()?)? + .safe_sub(market.amm.total_fee_withdrawn().cast()?)?; if amm_target_max_fee_pool_token_amount <= amm_fee_pool_token_amount { // owe the market pnl pool before settling user @@ -634,8 +652,8 @@ pub fn update_pool_balances( { let amm_target_min_fee_pool_token_amount = get_total_fee_lower_bound(market)? - .safe_add(market.amm.total_liquidation_fee)? - .safe_sub(market.amm.total_fee_withdrawn)?; + .safe_add(market.amm.total_liquidation_fee())? + .safe_sub(market.amm.total_fee_withdrawn())?; let amm_fee_pool_token_amount = get_token_amount( market.amm.fee_pool.balance(), @@ -672,8 +690,8 @@ pub fn update_pool_balances( let terminal_state_surplus = market .amm - .total_fee_minus_distributions - .safe_sub(market.amm.total_fee_withdrawn.cast()?)?; + .total_fee_minus_distributions() + .safe_sub(market.amm.total_fee_withdrawn().cast()?)?; // market can perform withdraw from revenue pool if spot_market.insurance_fund.last_revenue_settle_ts @@ -704,10 +722,12 @@ pub fn update_pool_balances( &mut market.amm.fee_pool, )?; - market.amm.total_fee_withdrawn = market - .amm - .total_fee_withdrawn - .safe_add(revenue_pool_transfer.unsigned_abs())?; + market.amm.set_total_fee_withdrawn( + market + .amm + .total_fee_withdrawn() + .safe_add(revenue_pool_transfer.unsigned_abs())?, + ); } Ordering::Less => { transfer_revenue_pool_to_spot_balance( @@ -720,10 +740,12 @@ pub fn update_pool_balances( } if revenue_pool_transfer != 0 { - market.amm.total_fee_minus_distributions = market - .amm - .total_fee_minus_distributions - .safe_sub(revenue_pool_transfer)?; + market.amm.set_total_fee_minus_distributions( + market + .amm + .total_fee_minus_distributions() + .safe_sub(revenue_pool_transfer)?, + ); market.insurance_claim.revenue_withdraw_since_last_settle = market .insurance_claim @@ -795,7 +817,7 @@ pub fn update_pnl_pool_and_user_balance( let pnl_to_settle_with_user = if unrealized_pnl_with_fee > 0 { unrealized_pnl_with_fee.min( get_token_amount( - market.pnl_pool.scaled_balance, + market.pnl_pool.scaled_balance(), bank, market.pnl_pool.balance_type(), )? @@ -845,35 +867,42 @@ pub fn move_price( quote_asset_reserve: u128, sqrt_k: u128, ) -> DriftResult { - market.amm.base_asset_reserve = base_asset_reserve; + market.amm.set_base_asset_reserve(base_asset_reserve); let k = bn::U256::from(sqrt_k).safe_mul(bn::U256::from(sqrt_k))?; - market.amm.quote_asset_reserve = k - .safe_div(bn::U256::from(base_asset_reserve))? - .try_to_u128()?; + market.amm.set_quote_asset_reserve( + k.safe_div(bn::U256::from(base_asset_reserve))? + .try_to_u128()?, + ); validate!( - (quote_asset_reserve.cast::()? - market.amm.quote_asset_reserve.cast::()?) + (quote_asset_reserve.cast::()? - market.amm.quote_asset_reserve().cast::()?) .abs() < 100, ErrorCode::InvalidAmmDetected, "quote_asset_reserve passed doesnt reconcile enough {} vs {}", quote_asset_reserve.cast::()?, - market.amm.quote_asset_reserve.cast::()? + market.amm.quote_asset_reserve().cast::()? )?; - market.amm.sqrt_k = sqrt_k; + market.amm.set_sqrt_k(sqrt_k); let (_, terminal_quote_reserves, terminal_base_reserves) = amm::calculate_terminal_price_and_reserves(&market.amm)?; - market.amm.terminal_quote_asset_reserve = terminal_quote_reserves; + market + .amm + .set_terminal_quote_asset_reserve(terminal_quote_reserves); let (min_base_asset_reserve, max_base_asset_reserve) = - amm::calculate_bid_ask_bounds(market.amm.concentration_coef, terminal_base_reserves)?; + amm::calculate_bid_ask_bounds(market.amm.concentration_coef(), terminal_base_reserves)?; - market.amm.max_base_asset_reserve = max_base_asset_reserve; - market.amm.min_base_asset_reserve = min_base_asset_reserve; + market + .amm + .set_max_base_asset_reserve(max_base_asset_reserve); + market + .amm + .set_min_base_asset_reserve(min_base_asset_reserve); let reserve_price_after = market.amm.reserve_price()?; update_spreads(market, reserve_price_after, None)?; @@ -888,48 +917,56 @@ pub fn recenter_perp_market_amm( sqrt_k: u128, ) -> DriftResult { // calculate base/quote reserves for balanced terminal reserves - let swap_direction = if market.amm.base_asset_amount_with_amm > 0 { + let swap_direction = if market.amm.base_asset_amount_with_amm() > 0 { SwapDirection::Remove } else { SwapDirection::Add }; let (new_quote_asset_amount, new_base_asset_amount) = amm::calculate_swap_output( - market.amm.base_asset_amount_with_amm.unsigned_abs(), + market.amm.base_asset_amount_with_amm().unsigned_abs(), sqrt_k, swap_direction, sqrt_k, )?; - market.amm.base_asset_reserve = new_base_asset_amount; + market.amm.set_base_asset_reserve(new_base_asset_amount); let k = bn::U256::from(sqrt_k).safe_mul(bn::U256::from(sqrt_k))?; - market.amm.quote_asset_reserve = k - .safe_div(bn::U256::from(new_base_asset_amount))? - .try_to_u128()?; + market.amm.set_quote_asset_reserve( + k.safe_div(bn::U256::from(new_base_asset_amount))? + .try_to_u128()?, + ); validate!( - (new_quote_asset_amount.cast::()? - market.amm.quote_asset_reserve.cast::()?) - .abs() + (new_quote_asset_amount.cast::()? + - market.amm.quote_asset_reserve().cast::()?) + .abs() < 100, ErrorCode::InvalidAmmDetected, "quote_asset_reserve passed doesnt reconcile enough" )?; - market.amm.sqrt_k = sqrt_k; + market.amm.set_sqrt_k(sqrt_k); // todo: ensure correct terminal state cost for altering sqrt_k - market.amm.peg_multiplier = peg_multiplier; + market.amm.set_peg_multiplier(peg_multiplier); let (_, terminal_quote_reserves, terminal_base_reserves) = amm::calculate_terminal_price_and_reserves(&market.amm)?; - market.amm.terminal_quote_asset_reserve = terminal_quote_reserves; + market + .amm + .set_terminal_quote_asset_reserve(terminal_quote_reserves); let (min_base_asset_reserve, max_base_asset_reserve) = - amm::calculate_bid_ask_bounds(market.amm.concentration_coef, terminal_base_reserves)?; + amm::calculate_bid_ask_bounds(market.amm.concentration_coef(), terminal_base_reserves)?; - market.amm.max_base_asset_reserve = max_base_asset_reserve; - market.amm.min_base_asset_reserve = min_base_asset_reserve; + market + .amm + .set_max_base_asset_reserve(max_base_asset_reserve); + market + .amm + .set_min_base_asset_reserve(min_base_asset_reserve); let reserve_price_after = market.amm.reserve_price()?; update_spreads(market, reserve_price_after, None)?; @@ -945,13 +982,13 @@ pub fn calculate_perp_market_amm_summary_stats( exclude_liquidation_fee: bool, ) -> DriftResult { let pnl_pool_token_amount = get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), spot_market, perp_market.pnl_pool.balance_type(), )?; let fee_pool_token_amount = get_token_amount( - perp_market.amm.fee_pool.scaled_balance, + perp_market.amm.fee_pool.scaled_balance(), spot_market, perp_market.amm.fee_pool.balance_type(), )?; @@ -967,7 +1004,7 @@ pub fn calculate_perp_market_amm_summary_stats( if exclude_liquidation_fee { new_total_fee_minus_distributions = new_total_fee_minus_distributions - .safe_sub(perp_market.amm.total_liquidation_fee.cast()?)?; + .safe_sub(perp_market.amm.total_liquidation_fee().cast()?)?; } Ok(new_total_fee_minus_distributions) diff --git a/programs/drift/src/controller/amm/tests.rs b/programs/drift/src/controller/amm/tests.rs index ba51779f5e..6eb0a5c2ac 100644 --- a/programs/drift/src/controller/amm/tests.rs +++ b/programs/drift/src/controller/amm/tests.rs @@ -10,14 +10,14 @@ use crate::state::perp_market::{InsuranceClaim, PoolBalance}; fn concentration_coef_tests() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 500 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - base_asset_amount_with_amm: -12295081967, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION as i128, + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (500 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + base_asset_amount_with_amm: (-12295081967).into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION as i128).into(), curve_update_intensity: 100, ..AMM::default() }, @@ -28,8 +28,8 @@ fn concentration_coef_tests() { let new_scale = 1; update_concentration_coef(&mut market, new_scale).unwrap(); - assert_eq!(market.amm.min_base_asset_reserve, 353556781219); - assert_eq!(market.amm.max_base_asset_reserve, 707100000000); + assert_eq!(market.amm.min_base_asset_reserve(), 353556781219); + assert_eq!(market.amm.max_base_asset_reserve(), 707100000000); let (orig_open_bids, orig_open_asks) = amm::calculate_market_open_bids_asks(&market.amm).unwrap(); @@ -38,20 +38,20 @@ fn concentration_coef_tests() { let new_scale = 2; update_concentration_coef(&mut market, new_scale).unwrap(); - assert_eq!(market.amm.min_base_asset_reserve, 414215889321); - assert_eq!(market.amm.max_base_asset_reserve, 603550000000); + assert_eq!(market.amm.min_base_asset_reserve(), 414215889321); + assert_eq!(market.amm.max_base_asset_reserve(), 603550000000); let new_scale = 5; update_concentration_coef(&mut market, new_scale).unwrap(); - assert_eq!(market.amm.min_base_asset_reserve, 461748734808); - assert_eq!(market.amm.max_base_asset_reserve, 541420000000); - let new_sqrt_k = market.amm.sqrt_k * new_scale; + assert_eq!(market.amm.min_base_asset_reserve(), 461748734808); + assert_eq!(market.amm.max_base_asset_reserve(), 541420000000); + let new_sqrt_k = market.amm.sqrt_k() * new_scale; let update_k_result = get_update_k_result(&market, bn::U192::from(new_sqrt_k), false).unwrap(); let adjustment_cost = cp_curve::adjust_k_cost(&mut market, &update_k_result).unwrap(); assert_eq!(adjustment_cost, 11_575_563); cp_curve::update_k(&mut market, &update_k_result).unwrap(); - assert_eq!(market.amm.sqrt_k, new_sqrt_k); + assert_eq!(market.amm.sqrt_k(), new_sqrt_k); let (open_bids, open_asks) = amm::calculate_market_open_bids_asks(&market.amm).unwrap(); assert_eq!(open_bids, 207313827452); @@ -66,32 +66,32 @@ fn concentration_coef_tests() { // different default market let mut market_balanced = PerpMarket::default_test(); - assert_eq!(market_balanced.amm.base_asset_amount_with_amm, 0); - assert_eq!(market_balanced.amm.sqrt_k, 100000000000); + assert_eq!(market_balanced.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market_balanced.amm.sqrt_k(), 100000000000); let new_scale = 20; update_concentration_coef(&mut market_balanced, new_scale).unwrap(); - assert_eq!(market_balanced.amm.min_base_asset_reserve, 97971020172); - assert_eq!(market_balanced.amm.max_base_asset_reserve, 102071000000); + assert_eq!(market_balanced.amm.min_base_asset_reserve(), 97971020172); + assert_eq!(market_balanced.amm.max_base_asset_reserve(), 102071000000); let new_scale = AMM_RESERVE_PRECISION; // too large, err assert!(update_concentration_coef(&mut market_balanced, new_scale).is_err()); - assert_eq!(market_balanced.amm.min_base_asset_reserve, 97971020172); - assert_eq!(market_balanced.amm.max_base_asset_reserve, 102071000000); + assert_eq!(market_balanced.amm.min_base_asset_reserve(), 97971020172); + assert_eq!(market_balanced.amm.max_base_asset_reserve(), 102071000000); let new_scale = 140000; // near limit, very little liquidity update_concentration_coef(&mut market_balanced, new_scale).unwrap(); - assert_eq!(market_balanced.amm.min_base_asset_reserve, 99999800000); - assert_eq!(market_balanced.amm.max_base_asset_reserve, 100000200000); + assert_eq!(market_balanced.amm.min_base_asset_reserve(), 99999800000); + assert_eq!(market_balanced.amm.max_base_asset_reserve(), 100000200000); - let new_sqrt_k = market_balanced.amm.sqrt_k * new_scale; + let new_sqrt_k = market_balanced.amm.sqrt_k() * new_scale; let update_k_result = get_update_k_result(&market_balanced, bn::U192::from(new_sqrt_k), false).unwrap(); let adjustment_cost = cp_curve::adjust_k_cost(&mut market_balanced, &update_k_result).unwrap(); assert_eq!(adjustment_cost, 0); cp_curve::update_k(&mut market_balanced, &update_k_result).unwrap(); - assert_eq!(market_balanced.amm.sqrt_k, new_sqrt_k); + assert_eq!(market_balanced.amm.sqrt_k(), new_sqrt_k); let (open_bids, open_asks) = amm::calculate_market_open_bids_asks(&market_balanced.amm).unwrap(); @@ -103,13 +103,13 @@ fn concentration_coef_tests() { fn formualic_k_tests() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - base_asset_amount_with_amm: -12295081967, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION as i128, + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + base_asset_amount_with_amm: (-12295081967).into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION as i128).into(), curve_update_intensity: 100, ..AMM::default() }, @@ -117,14 +117,20 @@ fn formualic_k_tests() { }; let (new_terminal_quote_reserve, new_terminal_base_reserve) = amm::calculate_terminal_reserves(&market.amm).unwrap(); - market.amm.terminal_quote_asset_reserve = new_terminal_quote_reserve; + market + .amm + .set_terminal_quote_asset_reserve(new_terminal_quote_reserve); let (min_base_asset_reserve, max_base_asset_reserve) = - amm::calculate_bid_ask_bounds(market.amm.concentration_coef, new_terminal_base_reserve) + amm::calculate_bid_ask_bounds(market.amm.concentration_coef(), new_terminal_base_reserve) .unwrap(); - market.amm.min_base_asset_reserve = min_base_asset_reserve; - market.amm.max_base_asset_reserve = max_base_asset_reserve; + market + .amm + .set_min_base_asset_reserve(min_base_asset_reserve); + market + .amm + .set_max_base_asset_reserve(max_base_asset_reserve); - let prev_sqrt_k = market.amm.sqrt_k; + let prev_sqrt_k = market.amm.sqrt_k(); // let reserve_price = market.amm.reserve_price().unwrap(); let now = 10000; @@ -139,46 +145,49 @@ fn formualic_k_tests() { // zero funding cost let funding_cost: i128 = 0; formulaic_update_k(&mut market, &oracle_price_data, funding_cost, now).unwrap(); - assert_eq!(prev_sqrt_k, market.amm.sqrt_k); + assert_eq!(prev_sqrt_k, market.amm.sqrt_k()); assert_eq!( - market.amm.total_fee_minus_distributions, + market.amm.total_fee_minus_distributions(), 1000 * QUOTE_PRECISION as i128 ); // positive means amm supossedly paid $500 in funding payments for interval let funding_cost_2: i128 = (500 * QUOTE_PRECISION) as i128; formulaic_update_k(&mut market, &oracle_price_data, funding_cost_2, now).unwrap(); - assert_eq!(market.amm.sqrt_k, 499500000000); // max k decrease (.1%) - assert!(prev_sqrt_k > market.amm.sqrt_k); - assert_eq!(market.amm.total_fee_minus_distributions, 1000014768); //$.014768 acquired from slippage increase + assert_eq!(market.amm.sqrt_k(), 499500000000); // max k decrease (.1%) + assert!(prev_sqrt_k > market.amm.sqrt_k()); + assert_eq!(market.amm.total_fee_minus_distributions(), 1000014768); //$.014768 acquired from slippage increase // negative means amm recieved $500 in funding payments for interval let funding_cost_2: i128 = -((500 * QUOTE_PRECISION) as i128); formulaic_update_k(&mut market, &oracle_price_data, funding_cost_2, now).unwrap(); - assert_eq!(market.amm.sqrt_k, 499999500000); // max k increase (.1%) - assert_eq!(market.amm.total_fee_minus_distributions, 1000000013); //almost full spent from slippage decrease + assert_eq!(market.amm.sqrt_k(), 499999500000); // max k increase (.1%) + assert_eq!(market.amm.total_fee_minus_distributions(), 1000000013); //almost full spent from slippage decrease // negative means amm recieved $.001 in funding payments for interval let funding_cost_2: i128 = -((QUOTE_PRECISION / 1000) as i128); formulaic_update_k(&mut market, &oracle_price_data, funding_cost_2, now).unwrap(); // new numbers bc of increased sqrt_k precision - assert_eq!(market.amm.sqrt_k, 500015999983); // increase k by 1.000033x - assert_eq!(market.amm.total_fee_minus_distributions - 1000000013, -486); // ~$0.000486 spent from slippage decrease + assert_eq!(market.amm.sqrt_k(), 500015999983); // increase k by 1.000033x + assert_eq!( + market.amm.total_fee_minus_distributions() - 1000000013, + -486 + ); // ~$0.000486 spent from slippage decrease } #[test] fn iterative_bounds_formualic_k_tests() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - base_asset_amount_with_amm: -12295081967, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION as i128, + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + base_asset_amount_with_amm: (-12295081967).into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION as i128).into(), curve_update_intensity: 100, ..AMM::default() }, @@ -198,32 +207,32 @@ fn iterative_bounds_formualic_k_tests() { // negative funding cost let mut count = 0; - let mut prev_k = market.amm.sqrt_k; + let mut prev_k = market.amm.sqrt_k(); let mut new_k = 0; while prev_k != new_k && count < 10000 { let funding_cost = -(QUOTE_PRECISION as i128); - prev_k = market.amm.sqrt_k; + prev_k = market.amm.sqrt_k(); formulaic_update_k(&mut market, &oracle_price_data, funding_cost, now).unwrap(); - new_k = market.amm.sqrt_k; + new_k = market.amm.sqrt_k(); count += 1 } - assert_eq!(market.amm.base_asset_amount_with_amm, -12295081967); - assert_eq!(market.amm.sqrt_k, 10958340658498292); - assert_eq!(market.amm.total_fee_minus_distributions, 985_612_320); + assert_eq!(market.amm.base_asset_amount_with_amm(), -12295081967); + assert_eq!(market.amm.sqrt_k(), 10958340658498292); + assert_eq!(market.amm.total_fee_minus_distributions(), 985_612_320); } #[test] fn iterative_no_bounds_formualic_k_tests() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - base_asset_amount_with_amm: -12295081967, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION as i128, + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + base_asset_amount_with_amm: (-12295081967).into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION as i128).into(), curve_update_intensity: 100, ..AMM::default() }, @@ -243,31 +252,31 @@ fn iterative_no_bounds_formualic_k_tests() { // negative funding cost let mut count = 0; - let mut prev_k = market.amm.sqrt_k; + let mut prev_k = market.amm.sqrt_k(); let mut new_k = 0; while prev_k != new_k && count < 100000 && prev_k < MAX_SQRT_K * 99 / 100 { let funding_cost = -((QUOTE_PRECISION * 100000) as i128); - prev_k = market.amm.sqrt_k; + prev_k = market.amm.sqrt_k(); formulaic_update_k(&mut market, &oracle_price_data, funding_cost, now).unwrap(); - new_k = market.amm.sqrt_k; + new_k = market.amm.sqrt_k(); count += 1 } - assert_eq!(market.amm.base_asset_amount_with_amm, -12295081967); - assert_eq!(market.amm.sqrt_k, 991917456633894384209); // below MAX_SQRT_K - assert_eq!(market.amm.total_fee_minus_distributions, 985625029); + assert_eq!(market.amm.base_asset_amount_with_amm(), -12295081967); + assert_eq!(market.amm.sqrt_k(), 991917456633894384209); // below MAX_SQRT_K + assert_eq!(market.amm.total_fee_minus_distributions(), 985625029); } #[test] fn update_pool_balances_test_high_util_borrow() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 5122950819670000, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000, - base_asset_amount_with_amm: -122950819670000, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION as i128, + base_asset_reserve: 5122950819670000.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000.into(), + base_asset_amount_with_amm: (-122950819670000).into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION as i128).into(), curve_update_intensity: 100, ..AMM::default() }, @@ -276,13 +285,13 @@ fn update_pool_balances_test_high_util_borrow() { let now = 33928058; let mut spot_market = SpotMarket { - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), ..SpotMarket::default() }; // 100% util - spot_market.deposit_balance = 10_u128.pow(19_u32); - spot_market.borrow_balance = 10_u128.pow(19_u32); + spot_market.set_deposit_balance(10_u128.pow(19_u32)); + spot_market.set_borrow_balance(10_u128.pow(19_u32)); spot_market.deposit_token_twap = 10_u64.pow(16_u32); // would lead to a borrow @@ -300,7 +309,7 @@ fn update_pool_balances_test_high_util_borrow() { assert_eq!(to_settle_with_user, 0); // util is low => neg settle ok - spot_market.borrow_balance = 0; + spot_market.set_borrow_balance(0); let unsettled_pnl = -100; let to_settle_with_user = update_pool_balances( &mut market, @@ -313,7 +322,7 @@ fn update_pool_balances_test_high_util_borrow() { assert_eq!(to_settle_with_user, unsettled_pnl); // util is high - spot_market.borrow_balance = 10_u128.pow(19_u32); + spot_market.set_borrow_balance(10_u128.pow(19_u32)); // user has a little bit deposited => settle how much they have deposited update_spot_balances( 50, @@ -357,12 +366,12 @@ fn update_pool_balances_test_high_util_borrow() { fn update_pool_balances_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 5122950819670000, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000, - base_asset_amount_with_amm: -122950819670000, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION as i128, + base_asset_reserve: 5122950819670000.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000.into(), + base_asset_amount_with_amm: (-122950819670000).into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION as i128).into(), curve_update_intensity: 100, ..AMM::default() }, @@ -371,11 +380,11 @@ fn update_pool_balances_test() { let now = 33928058; let mut spot_market = SpotMarket { - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), ..SpotMarket::default() }; - spot_market.deposit_balance = 10_u128.pow(19_u32); + spot_market.set_deposit_balance(10_u128.pow(19_u32)); spot_market.deposit_token_twap = 10_u64.pow(16_u32); let spot_position = SpotPosition::default(); @@ -422,7 +431,7 @@ fn update_pool_balances_test() { assert_eq!(pnl_pool_token_amount, 0); assert_eq!(amm_fee_pool_token_amount, 1); - market.amm.total_fee_minus_distributions = 0; + market.amm.set_total_fee_minus_distributions(0); update_pool_balances(&mut market, &mut spot_market, &spot_position, -1, now).unwrap(); let amm_fee_pool_token_amount = get_token_amount( market.amm.fee_pool.balance(), @@ -439,7 +448,9 @@ fn update_pool_balances_test() { assert_eq!(pnl_pool_token_amount, 2); assert_eq!(amm_fee_pool_token_amount, 0); - market.amm.total_fee_minus_distributions = 90_000 * QUOTE_PRECISION as i128; + market + .amm + .set_total_fee_minus_distributions(90_000 * QUOTE_PRECISION as i128); update_pool_balances( &mut market, &mut spot_market, @@ -464,7 +475,7 @@ fn update_pool_balances_test() { assert_eq!(amm_fee_pool_token_amount, 33333333); // negative fee pool - market.amm.total_fee_minus_distributions = -8_008_123_456; + market.amm.set_total_fee_minus_distributions(-8_008_123_456); update_pool_balances( &mut market, @@ -494,29 +505,29 @@ fn update_pool_balances_test() { fn update_pool_balances_fee_to_revenue_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 5122950819670000, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000, - base_asset_amount_with_amm: -122950819670000, - - total_exchange_fee: 10 * QUOTE_PRECISION, - total_fee: 10 * QUOTE_PRECISION as i128, - total_mm_fee: 990 * QUOTE_PRECISION as i128, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION as i128, - total_liquidation_fee: QUOTE_PRECISION, + base_asset_reserve: 5122950819670000.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000.into(), + base_asset_amount_with_amm: (-122950819670000).into(), + + total_exchange_fee: (10 * QUOTE_PRECISION).into(), + total_fee: (10 * QUOTE_PRECISION as i128).into(), + total_mm_fee: (990 * QUOTE_PRECISION as i128).into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION as i128).into(), + total_liquidation_fee: QUOTE_PRECISION.into(), net_revenue_since_last_funding: 10000 * QUOTE_PRECISION as i64, curve_update_intensity: 100, fee_pool: PoolBalance { - scaled_balance: 50 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION, + scaled_balance: (50 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: 50 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION, + scaled_balance: (50 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -530,18 +541,18 @@ fn update_pool_balances_fee_to_revenue_test() { let now = 33928058; let mut spot_market = SpotMarket { - deposit_balance: 100 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: (100 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION).into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), revenue_pool: PoolBalance::default(), ..SpotMarket::default() }; - let prev_fee_pool = market.amm.fee_pool.scaled_balance; - let prev_pnl_pool = market.amm.fee_pool.scaled_balance; - let prev_rev_pool = spot_market.revenue_pool.scaled_balance; + let prev_fee_pool = market.amm.fee_pool.scaled_balance(); + let prev_pnl_pool = market.amm.fee_pool.scaled_balance(); + let prev_rev_pool = spot_market.revenue_pool.scaled_balance(); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); assert_eq!( get_token_amount( @@ -555,7 +566,7 @@ fn update_pool_balances_fee_to_revenue_test() { assert_eq!( get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit ) @@ -566,68 +577,68 @@ fn update_pool_balances_fee_to_revenue_test() { let spot_position = SpotPosition::default(); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.fee_pool.scaled_balance, 50000000000000000); // under FEE_POOL_TO_REVENUE_POOL_THRESHOLD - assert_eq!(market.pnl_pool.scaled_balance, 50000000000000000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.fee_pool.scaled_balance(), 50000000000000000); // under FEE_POOL_TO_REVENUE_POOL_THRESHOLD + assert_eq!(market.pnl_pool.scaled_balance(), 50000000000000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); - assert!(market.amm.fee_pool.scaled_balance == prev_fee_pool); - assert_eq!(market.pnl_pool.scaled_balance, prev_pnl_pool); - assert!(spot_market.revenue_pool.scaled_balance == prev_rev_pool); + assert!(market.amm.fee_pool.scaled_balance() == prev_fee_pool); + assert_eq!(market.pnl_pool.scaled_balance(), prev_pnl_pool); + assert!(spot_market.revenue_pool.scaled_balance() == prev_rev_pool); // add FEE_POOL_TO_REVENUE_POOL_THRESHOLD let prev_fee_pool_2 = (FEE_POOL_TO_REVENUE_POOL_THRESHOLD + 50 * QUOTE_PRECISION) * SPOT_BALANCE_PRECISION; - market.amm.fee_pool.scaled_balance = prev_fee_pool_2; + market.amm.fee_pool.set_scaled_balance(prev_fee_pool_2); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 50000000000000000); - assert_eq!(market.amm.total_fee_withdrawn, 5000000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 5000000000000000); - assert_eq!(market.amm.fee_pool.scaled_balance, 295000000000000000); // > FEE_POOL_TO_REVENUE_POOL_THRESHOLD + assert_eq!(market.pnl_pool.scaled_balance(), 50000000000000000); + assert_eq!(market.amm.total_fee_withdrawn(), 5000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 5000000000000000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 295000000000000000); // > FEE_POOL_TO_REVENUE_POOL_THRESHOLD - assert!(market.amm.fee_pool.scaled_balance < prev_fee_pool_2); - assert_eq!(market.pnl_pool.scaled_balance, prev_pnl_pool); - assert!(spot_market.revenue_pool.scaled_balance > prev_rev_pool); + assert!(market.amm.fee_pool.scaled_balance() < prev_fee_pool_2); + assert_eq!(market.pnl_pool.scaled_balance(), prev_pnl_pool); + assert!(spot_market.revenue_pool.scaled_balance() > prev_rev_pool); market.insurance_claim.quote_max_insurance = 1; // add min insurance update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.total_fee_withdrawn, 5000001); - assert_eq!(spot_market.revenue_pool.scaled_balance, 5000001000000000); + assert_eq!(market.amm.total_fee_withdrawn(), 5000001); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 5000001000000000); market.insurance_claim.quote_max_insurance = 100000000; // add lots of insurance update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.total_fee_withdrawn, 6000000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 6000000000000000); + assert_eq!(market.amm.total_fee_withdrawn(), 6000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 6000000000000000); } #[test] fn update_pool_balances_fee_to_revenue_low_amm_revenue_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 5122950819670000, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000, - base_asset_amount_with_amm: -122950819670000, - - total_exchange_fee: 10 * QUOTE_PRECISION, - total_fee: 10 * QUOTE_PRECISION as i128, - total_mm_fee: 990 * QUOTE_PRECISION as i128, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION as i128, - total_liquidation_fee: QUOTE_PRECISION, + base_asset_reserve: 5122950819670000.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000.into(), + base_asset_amount_with_amm: (-122950819670000).into(), + + total_exchange_fee: (10 * QUOTE_PRECISION).into(), + total_fee: (10 * QUOTE_PRECISION as i128).into(), + total_mm_fee: (990 * QUOTE_PRECISION as i128).into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION as i128).into(), + total_liquidation_fee: QUOTE_PRECISION.into(), net_revenue_since_last_funding: QUOTE_PRECISION as i64, curve_update_intensity: 100, fee_pool: PoolBalance { - scaled_balance: 50 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION, + scaled_balance: (50 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: 50 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION, + scaled_balance: (50 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -641,18 +652,18 @@ fn update_pool_balances_fee_to_revenue_low_amm_revenue_test() { let now = 33928058; let mut spot_market = SpotMarket { - deposit_balance: 100 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: (100 * QUOTE_PRECISION * SPOT_BALANCE_PRECISION).into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), revenue_pool: PoolBalance::default(), ..SpotMarket::default() }; - let prev_fee_pool = market.amm.fee_pool.scaled_balance; - let prev_pnl_pool = market.amm.fee_pool.scaled_balance; - let prev_rev_pool = spot_market.revenue_pool.scaled_balance; + let prev_fee_pool = market.amm.fee_pool.scaled_balance(); + let prev_pnl_pool = market.amm.fee_pool.scaled_balance(); + let prev_rev_pool = spot_market.revenue_pool.scaled_balance(); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); assert_eq!( get_token_amount( @@ -666,7 +677,7 @@ fn update_pool_balances_fee_to_revenue_low_amm_revenue_test() { assert_eq!( get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit ) @@ -677,71 +688,71 @@ fn update_pool_balances_fee_to_revenue_low_amm_revenue_test() { let spot_position = SpotPosition::default(); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.fee_pool.scaled_balance, 50000000000000000); // under FEE_POOL_TO_REVENUE_POOL_THRESHOLD - assert_eq!(market.pnl_pool.scaled_balance, 50000000000000000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.fee_pool.scaled_balance(), 50000000000000000); // under FEE_POOL_TO_REVENUE_POOL_THRESHOLD + assert_eq!(market.pnl_pool.scaled_balance(), 50000000000000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); - assert!(market.amm.fee_pool.scaled_balance == prev_fee_pool); - assert_eq!(market.pnl_pool.scaled_balance, prev_pnl_pool); - assert!(spot_market.revenue_pool.scaled_balance == prev_rev_pool); + assert!(market.amm.fee_pool.scaled_balance() == prev_fee_pool); + assert_eq!(market.pnl_pool.scaled_balance(), prev_pnl_pool); + assert!(spot_market.revenue_pool.scaled_balance() == prev_rev_pool); // add FEE_POOL_TO_REVENUE_POOL_THRESHOLD let prev_fee_pool_2 = (FEE_POOL_TO_REVENUE_POOL_THRESHOLD + 50 * QUOTE_PRECISION) * SPOT_BALANCE_PRECISION; - market.amm.fee_pool.scaled_balance = prev_fee_pool_2; + market.amm.fee_pool.set_scaled_balance(prev_fee_pool_2); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 50000000000000000); - assert_eq!(market.amm.total_fee_withdrawn, 1000000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 1000000000000000); - assert_eq!(market.amm.fee_pool.scaled_balance, 299000000000000000); // > FEE_POOL_TO_REVENUE_POOL_THRESHOLD + assert_eq!(market.pnl_pool.scaled_balance(), 50000000000000000); + assert_eq!(market.amm.total_fee_withdrawn(), 1000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 1000000000000000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 299000000000000000); // > FEE_POOL_TO_REVENUE_POOL_THRESHOLD - assert!(market.amm.fee_pool.scaled_balance < prev_fee_pool_2); - assert_eq!(market.pnl_pool.scaled_balance, prev_pnl_pool); - assert!(spot_market.revenue_pool.scaled_balance > prev_rev_pool); + assert!(market.amm.fee_pool.scaled_balance() < prev_fee_pool_2); + assert_eq!(market.pnl_pool.scaled_balance(), prev_pnl_pool); + assert!(spot_market.revenue_pool.scaled_balance() > prev_rev_pool); market.insurance_claim.quote_max_insurance = 1; // add min insurance market.amm.net_revenue_since_last_funding = 1; update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.total_fee_withdrawn, 1000001); - assert_eq!(spot_market.revenue_pool.scaled_balance, 1000001000000000); + assert_eq!(market.amm.total_fee_withdrawn(), 1000001); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 1000001000000000); market.insurance_claim.quote_max_insurance = 100000000; // add lots of insurance market.amm.net_revenue_since_last_funding = 100000000; update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.total_fee_withdrawn, 6000000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 6000000000000000); + assert_eq!(market.amm.total_fee_withdrawn(), 6000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 6000000000000000); } #[test] fn update_pool_balances_revenue_to_fee_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 5122950819670000, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000, - base_asset_amount_with_amm: -122950819670000, + base_asset_reserve: 5122950819670000.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000.into(), + base_asset_amount_with_amm: (-122950819670000).into(), - total_exchange_fee: 10 * QUOTE_PRECISION, - total_fee: 10 * QUOTE_PRECISION as i128, - total_mm_fee: 990 * QUOTE_PRECISION as i128, - total_fee_minus_distributions: -(10000 * QUOTE_PRECISION as i128), + total_exchange_fee: (10 * QUOTE_PRECISION).into(), + total_fee: (10 * QUOTE_PRECISION as i128).into(), + total_mm_fee: (990 * QUOTE_PRECISION as i128).into(), + total_fee_minus_distributions: (-(10000 * QUOTE_PRECISION as i128)).into(), curve_update_intensity: 100, fee_pool: PoolBalance { - scaled_balance: 50 * SPOT_BALANCE_PRECISION, + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: 50 * SPOT_BALANCE_PRECISION, + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -750,12 +761,12 @@ fn update_pool_balances_revenue_to_fee_test() { let mut now = 33928058; let mut spot_market = SpotMarket { - deposit_balance: 200 * SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), revenue_pool: PoolBalance { market_index: 0, - scaled_balance: 100 * SPOT_BALANCE_PRECISION, + scaled_balance: (100 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, decimals: 6, @@ -763,12 +774,12 @@ fn update_pool_balances_revenue_to_fee_test() { }; let spot_position = SpotPosition::default(); - let prev_fee_pool = market.amm.fee_pool.scaled_balance; - let prev_pnl_pool = market.amm.fee_pool.scaled_balance; - let prev_rev_pool = spot_market.revenue_pool.scaled_balance; - let prev_tfmd = market.amm.total_fee_minus_distributions; + let prev_fee_pool = market.amm.fee_pool.scaled_balance(); + let prev_pnl_pool = market.amm.fee_pool.scaled_balance(); + let prev_rev_pool = spot_market.revenue_pool.scaled_balance(); + let prev_tfmd = market.amm.total_fee_minus_distributions(); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); assert_eq!(spot_market.insurance_fund.revenue_settle_period, 0); spot_market.insurance_fund.revenue_settle_period = 0; @@ -776,11 +787,13 @@ fn update_pool_balances_revenue_to_fee_test() { assert_eq!(res, 0); spot_market.insurance_fund.revenue_settle_period = 1; - spot_market.revenue_pool.scaled_balance = 0; + spot_market.revenue_pool.set_scaled_balance(0); let res = settle_revenue_to_insurance_fund(200000000, 0, &mut spot_market, now + 1, false).unwrap(); assert_eq!(res, 0); - spot_market.revenue_pool.scaled_balance = 100 * SPOT_BALANCE_PRECISION; + spot_market + .revenue_pool + .set_scaled_balance(100 * SPOT_BALANCE_PRECISION); now += 2; assert_eq!( @@ -795,7 +808,7 @@ fn update_pool_balances_revenue_to_fee_test() { assert_eq!( get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit ) @@ -803,51 +816,57 @@ fn update_pool_balances_revenue_to_fee_test() { 200 * QUOTE_PRECISION ); assert_eq!( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), 100 * SPOT_BALANCE_PRECISION ); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); assert_eq!( - market.amm.fee_pool.scaled_balance, + market.amm.fee_pool.scaled_balance(), 5 * SPOT_BALANCE_PRECISION ); - assert_eq!(market.pnl_pool.scaled_balance, 95 * SPOT_BALANCE_PRECISION); assert_eq!( - spot_market.revenue_pool.scaled_balance, + market.pnl_pool.scaled_balance(), + 95 * SPOT_BALANCE_PRECISION + ); + assert_eq!( + spot_market.revenue_pool.scaled_balance(), 100 * SPOT_BALANCE_PRECISION ); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(market.amm.total_fee_minus_distributions, prev_tfmd); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), prev_tfmd); - assert!(market.amm.fee_pool.scaled_balance < prev_fee_pool); - assert_eq!(market.pnl_pool.scaled_balance > prev_pnl_pool, true); + assert!(market.amm.fee_pool.scaled_balance() < prev_fee_pool); + assert_eq!(market.pnl_pool.scaled_balance() > prev_pnl_pool, true); assert_eq!( - spot_market.revenue_pool.scaled_balance == prev_rev_pool, + spot_market.revenue_pool.scaled_balance() == prev_rev_pool, true ); assert_eq!(market.insurance_claim.revenue_withdraw_since_last_settle, 0); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 0); market.insurance_claim.max_revenue_withdraw_per_period = 100000000 * 2; - assert_eq!(spot_market.deposit_balance, 200 * SPOT_BALANCE_PRECISION); + assert_eq!(spot_market.deposit_balance(), 200 * SPOT_BALANCE_PRECISION); assert_eq!( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), 100 * SPOT_BALANCE_PRECISION ); - assert_eq!(market.amm.total_fee_minus_distributions, -10000000000); + assert_eq!(market.amm.total_fee_minus_distributions(), -10000000000); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); assert_eq!( - market.amm.fee_pool.scaled_balance, + market.amm.fee_pool.scaled_balance(), 105 * SPOT_BALANCE_PRECISION ); - assert_eq!(market.pnl_pool.scaled_balance, 95 * SPOT_BALANCE_PRECISION); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(market.amm.total_fee_minus_distributions, -9900000000); + assert_eq!( + market.pnl_pool.scaled_balance(), + 95 * SPOT_BALANCE_PRECISION + ); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), -9900000000); assert_eq!( market.insurance_claim.revenue_withdraw_since_last_settle, 100000000 @@ -855,7 +874,7 @@ fn update_pool_balances_revenue_to_fee_test() { assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, now); let spot_market_vault_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -865,50 +884,61 @@ fn update_pool_balances_revenue_to_fee_test() { // calling multiple times doesnt effect other than fee pool -> pnl pool update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); assert_eq!( - market.amm.fee_pool.scaled_balance, + market.amm.fee_pool.scaled_balance(), 5 * SPOT_BALANCE_PRECISION ); - assert_eq!(market.pnl_pool.scaled_balance, 195 * SPOT_BALANCE_PRECISION); - assert_eq!(market.amm.total_fee_minus_distributions, -9900000000); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); + assert_eq!( + market.pnl_pool.scaled_balance(), + 195 * SPOT_BALANCE_PRECISION + ); + assert_eq!(market.amm.total_fee_minus_distributions(), -9900000000); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); assert_eq!( - market.amm.fee_pool.scaled_balance, + market.amm.fee_pool.scaled_balance(), 5 * SPOT_BALANCE_PRECISION ); - assert_eq!(market.pnl_pool.scaled_balance, 195 * SPOT_BALANCE_PRECISION); - assert_eq!(market.amm.total_fee_minus_distributions, -9900000000); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); + assert_eq!( + market.pnl_pool.scaled_balance(), + 195 * SPOT_BALANCE_PRECISION + ); + assert_eq!(market.amm.total_fee_minus_distributions(), -9900000000); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); // add deposits and revenue to pool - assert_eq!(spot_market.deposit_balance, 200 * SPOT_BALANCE_PRECISION); - spot_market.revenue_pool.scaled_balance = 9900000001000; + assert_eq!(spot_market.deposit_balance(), 200 * SPOT_BALANCE_PRECISION); + spot_market.revenue_pool.set_scaled_balance(9900000001000); let spot_market_backup = spot_market; let market_backup = market; assert!(update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).is_err()); // assert is_err if any way has revenue pool above deposit balances spot_market = spot_market_backup; market = market_backup; - spot_market.deposit_balance += 9900000001000; + spot_market.set_deposit_balance( + spot_market + .deposit_balance() + .safe_add(9900000001000) + .unwrap(), + ); let spot_market_vault_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap() as u64; - assert_eq!(spot_market.deposit_balance, 10100000001000); + assert_eq!(spot_market.deposit_balance(), 10100000001000); assert_eq!(spot_market_vault_amount, 10100000001); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(spot_market.deposit_balance, 10100000001000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 9800000001000); - assert_eq!(market.amm.fee_pool.scaled_balance, 105000000000); - assert_eq!(market.pnl_pool.scaled_balance, 195000000000); - assert_eq!(market.amm.total_fee_minus_distributions, -9800000000); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(spot_market.deposit_balance(), 10100000001000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 9800000001000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 105000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 195000000000); + assert_eq!(market.amm.total_fee_minus_distributions(), -9800000000); + assert_eq!(market.amm.total_fee_withdrawn(), 0); assert_eq!( market.insurance_claim.revenue_withdraw_since_last_settle, market.insurance_claim.max_revenue_withdraw_per_period as i64 @@ -917,11 +947,11 @@ fn update_pool_balances_revenue_to_fee_test() { // calling again only does fee -> pnl pool update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.fee_pool.scaled_balance, 5000000000); - assert_eq!(market.pnl_pool.scaled_balance, 295000000000); - assert_eq!(market.amm.total_fee_minus_distributions, -9800000000); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(spot_market.revenue_pool.scaled_balance, 9800000001000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 5000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 295000000000); + assert_eq!(market.amm.total_fee_minus_distributions(), -9800000000); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 9800000001000); assert_eq!( market.insurance_claim.revenue_withdraw_since_last_settle, market.insurance_claim.max_revenue_withdraw_per_period as i64 @@ -930,11 +960,11 @@ fn update_pool_balances_revenue_to_fee_test() { // calling again does nothing update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.fee_pool.scaled_balance, 5000000000); - assert_eq!(market.pnl_pool.scaled_balance, 295000000000); - assert_eq!(market.amm.total_fee_minus_distributions, -9800000000); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(spot_market.revenue_pool.scaled_balance, 9800000001000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 5000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 295000000000); + assert_eq!(market.amm.total_fee_minus_distributions(), -9800000000); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 9800000001000); assert_eq!( market.insurance_claim.revenue_withdraw_since_last_settle, market.insurance_claim.max_revenue_withdraw_per_period as i64 @@ -943,7 +973,7 @@ fn update_pool_balances_revenue_to_fee_test() { // do a revenue settlement to allow up to max again assert_eq!(spot_market.insurance_fund.last_revenue_settle_ts, 33928059); - assert_eq!(spot_market.deposit_balance, 10100000001000); + assert_eq!(spot_market.deposit_balance(), 10100000001000); spot_market.insurance_fund.total_factor = 1; spot_market.insurance_fund.revenue_settle_period = 1; @@ -958,24 +988,24 @@ fn update_pool_balances_revenue_to_fee_test() { assert_eq!(res, 9800000001); let spot_market_vault_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap() as u64; - assert_eq!(spot_market.deposit_balance, 300000000000); // 100000000 was added to market fee/pnl pool - assert_eq!(spot_market.borrow_balance, 0); + assert_eq!(spot_market.deposit_balance(), 300000000000); // 100000000 was added to market fee/pnl pool + assert_eq!(spot_market.borrow_balance(), 0); assert_eq!(spot_market_vault_amount, 300000000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); assert_eq!( spot_market.insurance_fund.last_revenue_settle_ts, now + 3600 ); // add deposits and revenue to pool - spot_market.revenue_pool.scaled_balance = 9800000001000; + spot_market.revenue_pool.set_scaled_balance(9800000001000); let market_backup = market; let spot_market_backup = spot_market; assert!( @@ -983,13 +1013,18 @@ fn update_pool_balances_revenue_to_fee_test() { ); // assert is_err if any way has revenue pool above deposit balances market = market_backup; spot_market = spot_market_backup; - spot_market.deposit_balance += 9800000000001; + spot_market.set_deposit_balance( + spot_market + .deposit_balance() + .safe_add(9800000000001) + .unwrap(), + ); - assert_eq!(market.amm.fee_pool.scaled_balance, 5000000000); - assert_eq!(market.pnl_pool.scaled_balance, 295000000000); - assert_eq!(market.amm.total_fee_minus_distributions, -9800000000); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(spot_market.revenue_pool.scaled_balance, 9800000001000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 5000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 295000000000); + assert_eq!(market.amm.total_fee_minus_distributions(), -9800000000); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 9800000001000); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 33928060); assert_eq!( spot_market.insurance_fund.last_revenue_settle_ts, @@ -1001,11 +1036,11 @@ fn update_pool_balances_revenue_to_fee_test() { assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 33931660); assert_eq!(spot_market.insurance_fund.last_revenue_settle_ts, 33931660); - assert_eq!(market.amm.fee_pool.scaled_balance, 205000000000); - assert_eq!(market.pnl_pool.scaled_balance, 295000000000); - assert_eq!(market.amm.total_fee_minus_distributions, -9600000000); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(spot_market.revenue_pool.scaled_balance, 9600000001000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 205000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 295000000000); + assert_eq!(market.amm.total_fee_minus_distributions(), -9600000000); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 9600000001000); assert_eq!( market.insurance_claim.revenue_withdraw_since_last_settle, market.insurance_claim.max_revenue_withdraw_per_period as i64 @@ -1016,26 +1051,26 @@ fn update_pool_balances_revenue_to_fee_test() { fn update_pool_balances_revenue_to_fee_devnet_state_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 916769960813655, - quote_asset_reserve: 932609131198775, - sqrt_k: 924655631391254, - peg_multiplier: 20242531, - base_asset_amount_with_amm: 7563264495267, - - quote_asset_amount: -90559143969, - - total_exchange_fee: 18223810834, - total_fee: 130757047337, - total_mm_fee: 112696236155, - total_fee_minus_distributions: 338762376993, - total_fee_withdrawn: 161959731500, - total_liquidation_fee: 152847899222, - total_social_loss: 74768391959, + base_asset_reserve: 916769960813655.into(), + quote_asset_reserve: 932609131198775.into(), + sqrt_k: 924655631391254.into(), + peg_multiplier: 20242531.into(), + base_asset_amount_with_amm: 7563264495267.into(), + + quote_asset_amount: (-90559143969).into(), + + total_exchange_fee: 18223810834.into(), + total_fee: 130757047337.into(), + total_mm_fee: 112696236155.into(), + total_fee_minus_distributions: 338762376993.into(), + total_fee_withdrawn: 161959731500.into(), + total_liquidation_fee: 152847899222.into(), + total_social_loss: 74768391959.into(), curve_update_intensity: 100, net_revenue_since_last_funding: 229827181, fee_pool: PoolBalance { - scaled_balance: 1821 * SPOT_BALANCE_PRECISION, + scaled_balance: (1821 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1043,7 +1078,7 @@ fn update_pool_balances_revenue_to_fee_devnet_state_test() { ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: 381047 * SPOT_BALANCE_PRECISION, + scaled_balance: (381047 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1057,12 +1092,12 @@ fn update_pool_balances_revenue_to_fee_devnet_state_test() { let now = 33928058; let mut spot_market = SpotMarket { - deposit_balance: 200 * SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), revenue_pool: PoolBalance { market_index: 0, - scaled_balance: 100 * SPOT_BALANCE_PRECISION, + scaled_balance: (100 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, decimals: 6, @@ -1070,35 +1105,35 @@ fn update_pool_balances_revenue_to_fee_devnet_state_test() { }; let spot_position = SpotPosition::default(); - let prev_fee_pool = market.amm.fee_pool.scaled_balance; - let prev_pnl_pool = market.amm.fee_pool.scaled_balance; - let prev_rev_pool = spot_market.revenue_pool.scaled_balance; - let prev_tfmd = market.amm.total_fee_minus_distributions; + let prev_fee_pool = market.amm.fee_pool.scaled_balance(); + let prev_pnl_pool = market.amm.fee_pool.scaled_balance(); + let prev_rev_pool = spot_market.revenue_pool.scaled_balance(); + let prev_tfmd = market.amm.total_fee_minus_distributions(); update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.fee_pool.scaled_balance, 1821000000000); - assert_eq!(market.pnl_pool.scaled_balance, 381047000000000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 1821000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 381047000000000); assert_eq!( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), 100 * SPOT_BALANCE_PRECISION ); - assert_eq!(market.amm.total_fee_withdrawn, 161959731500); - assert_eq!(market.amm.total_fee_minus_distributions, prev_tfmd); + assert_eq!(market.amm.total_fee_withdrawn(), 161959731500); + assert_eq!(market.amm.total_fee_minus_distributions(), prev_tfmd); - assert_eq!(market.amm.fee_pool.scaled_balance, prev_fee_pool); - assert_eq!(market.pnl_pool.scaled_balance > prev_pnl_pool, true); + assert_eq!(market.amm.fee_pool.scaled_balance(), prev_fee_pool); + assert_eq!(market.pnl_pool.scaled_balance() > prev_pnl_pool, true); assert_eq!( - spot_market.revenue_pool.scaled_balance == prev_rev_pool, + spot_market.revenue_pool.scaled_balance() == prev_rev_pool, true ); assert_eq!(market.insurance_claim.revenue_withdraw_since_last_settle, 0); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 0); market.insurance_claim.max_revenue_withdraw_per_period = 100000000 * 2; - assert_eq!(spot_market.deposit_balance, 200 * SPOT_BALANCE_PRECISION); + assert_eq!(spot_market.deposit_balance(), 200 * SPOT_BALANCE_PRECISION); assert_eq!( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), 100 * SPOT_BALANCE_PRECISION ); } @@ -1107,26 +1142,26 @@ fn update_pool_balances_revenue_to_fee_devnet_state_test() { fn update_pool_balances_revenue_to_fee_new_market() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 6165301473685, - quote_asset_reserve: 6165301473685, - sqrt_k: 6165301473685, - peg_multiplier: 324000000, - base_asset_amount_with_amm: 0, - - quote_asset_amount: 0, - - total_exchange_fee: 26000, - total_fee: 26000, - total_mm_fee: 0, - total_fee_minus_distributions: 26000, - total_fee_withdrawn: 0, - total_liquidation_fee: 0, - total_social_loss: 0, + base_asset_reserve: 6165301473685.into(), + quote_asset_reserve: 6165301473685.into(), + sqrt_k: 6165301473685.into(), + peg_multiplier: 324000000.into(), + base_asset_amount_with_amm: 0.into(), + + quote_asset_amount: 0.into(), + + total_exchange_fee: 26000.into(), + total_fee: 26000.into(), + total_mm_fee: 0.into(), + total_fee_minus_distributions: 26000.into(), + total_fee_withdrawn: 0.into(), + total_liquidation_fee: 0.into(), + total_social_loss: 0.into(), curve_update_intensity: 100, net_revenue_since_last_funding: 0, fee_pool: PoolBalance { - scaled_balance: 0, + scaled_balance: 0.into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1134,7 +1169,7 @@ fn update_pool_balances_revenue_to_fee_new_market() { ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: 0, + scaled_balance: 0.into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1148,12 +1183,12 @@ fn update_pool_balances_revenue_to_fee_new_market() { let now = 33928058; let mut spot_market = SpotMarket { - deposit_balance: 200 * SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), revenue_pool: PoolBalance { market_index: 0, - scaled_balance: 100 * SPOT_BALANCE_PRECISION, + scaled_balance: (100 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, decimals: 6, @@ -1162,22 +1197,22 @@ fn update_pool_balances_revenue_to_fee_new_market() { let spot_position = SpotPosition::default(); // let prev_fee_pool = market.amm.fee_pool.scaled_balance; - let prev_pnl_pool = market.amm.fee_pool.scaled_balance; - let prev_rev_pool = spot_market.revenue_pool.scaled_balance; + let prev_pnl_pool = market.amm.fee_pool.scaled_balance(); + let prev_rev_pool = spot_market.revenue_pool.scaled_balance(); // let prev_tfmd = market.amm.total_fee_minus_distributions; update_pool_balances(&mut market, &mut spot_market, &spot_position, 0, now).unwrap(); - assert_eq!(market.amm.fee_pool.scaled_balance, 50000000000); // $50 + assert_eq!(market.amm.fee_pool.scaled_balance(), 50000000000); // $50 - assert_eq!(market.pnl_pool.scaled_balance, 0); - assert_eq!(spot_market.revenue_pool.scaled_balance, 50000000000); - assert_eq!(market.amm.total_fee_withdrawn, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 50026000); + assert_eq!(market.pnl_pool.scaled_balance(), 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 50000000000); + assert_eq!(market.amm.total_fee_withdrawn(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 50026000); - assert_eq!(market.pnl_pool.scaled_balance, prev_pnl_pool); + assert_eq!(market.pnl_pool.scaled_balance(), prev_pnl_pool); assert_eq!( - spot_market.revenue_pool.scaled_balance < prev_rev_pool, + spot_market.revenue_pool.scaled_balance() < prev_rev_pool, true ); assert_eq!( @@ -1187,8 +1222,8 @@ fn update_pool_balances_revenue_to_fee_new_market() { assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 33928058); market.insurance_claim.max_revenue_withdraw_per_period = 100000000 * 2; - assert_eq!(spot_market.deposit_balance, 200 * SPOT_BALANCE_PRECISION); - assert_eq!(spot_market.revenue_pool.scaled_balance, 50000000000); + assert_eq!(spot_market.deposit_balance(), 200 * SPOT_BALANCE_PRECISION); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 50000000000); } mod revenue_pool_transfer_tests { @@ -1204,10 +1239,10 @@ mod revenue_pool_transfer_tests { // Set up input parameters let mut market = PerpMarket { amm: AMM { - total_social_loss: 0, - total_liquidation_fee: 0, + total_social_loss: 0.into(), + total_liquidation_fee: 0.into(), net_revenue_since_last_funding: 0, - total_fee_withdrawn: 0, + total_fee_withdrawn: 0.into(), ..AMM::default() }, insurance_claim: InsuranceClaim { @@ -1220,12 +1255,12 @@ mod revenue_pool_transfer_tests { ..PerpMarket::default() }; let mut spot_market = SpotMarket { - deposit_balance: 20020 * SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: (20020 * SPOT_BALANCE_PRECISION).into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), revenue_pool: PoolBalance { market_index: 0, - scaled_balance: 100 * SPOT_BALANCE_PRECISION, + scaled_balance: (100 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, decimals: 6, @@ -1294,8 +1329,8 @@ mod revenue_pool_transfer_tests { // Test case 2: When amm_budget_surplus is greater than zero and max_revenue_to_settle is greater than zero, revenue_pool_transfer should be greater than zero market.amm.net_revenue_since_last_funding = 1000 * QUOTE_PRECISION_I64; - market.amm.total_fee_withdrawn = 500 * QUOTE_PRECISION; - market.amm.total_liquidation_fee = 300 * QUOTE_PRECISION; + market.amm.set_total_fee_withdrawn(500 * QUOTE_PRECISION); + market.amm.set_total_liquidation_fee(300 * QUOTE_PRECISION); market.insurance_claim.quote_max_insurance = 100 * QUOTE_PRECISION_U64; market.insurance_claim.quote_settled_insurance = 50 * QUOTE_PRECISION_U64; market.insurance_claim.revenue_withdraw_since_last_settle = 200 * QUOTE_PRECISION_I64; @@ -1338,8 +1373,8 @@ mod revenue_pool_transfer_tests { let amm_fee_pool_token_amount_after = 500 * QUOTE_PRECISION; let terminal_state_surplus = 1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 20 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 100 * QUOTE_PRECISION; - market.amm.total_exchange_fee = 3000 * QUOTE_PRECISION; + market.amm.set_total_social_loss(100 * QUOTE_PRECISION); + market.amm.set_total_exchange_fee(3000 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1352,7 +1387,7 @@ mod revenue_pool_transfer_tests { let amm_fee_pool_token_amount_after = 500 * QUOTE_PRECISION; let terminal_state_surplus = 1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 1000 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 100 * QUOTE_PRECISION; + market.amm.set_total_social_loss(100 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1365,8 +1400,8 @@ mod revenue_pool_transfer_tests { let amm_fee_pool_token_amount_after = 500 * QUOTE_PRECISION; let terminal_state_surplus = 1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 1000 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 100 * QUOTE_PRECISION; - market.amm.total_liquidation_fee = 800 * QUOTE_PRECISION; + market.amm.set_total_social_loss(100 * QUOTE_PRECISION); + market.amm.set_total_liquidation_fee(800 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1379,8 +1414,8 @@ mod revenue_pool_transfer_tests { let amm_fee_pool_token_amount_after = 500 * QUOTE_PRECISION; let terminal_state_surplus = 1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 1000 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 100 * QUOTE_PRECISION; - market.amm.total_liquidation_fee = 200 * QUOTE_PRECISION; + market.amm.set_total_social_loss(100 * QUOTE_PRECISION); + market.amm.set_total_liquidation_fee(200 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1388,7 +1423,7 @@ mod revenue_pool_transfer_tests { terminal_state_surplus, ); let expected_result: i128 = (amm_fee_pool_token_amount_after - - market.amm.total_social_loss + - market.amm.total_social_loss() - FEE_POOL_TO_REVENUE_POOL_THRESHOLD) as i128; assert_eq!(result.unwrap(), expected_result); @@ -1396,7 +1431,7 @@ mod revenue_pool_transfer_tests { let amm_fee_pool_token_amount_after = 500 * QUOTE_PRECISION; let terminal_state_surplus = 1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 1000 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 600 * QUOTE_PRECISION; + market.amm.set_total_social_loss(600 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1409,7 +1444,7 @@ mod revenue_pool_transfer_tests { let amm_fee_pool_token_amount_after: u128 = 500 * QUOTE_PRECISION; let terminal_state_surplus = 1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 40 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 100 * QUOTE_PRECISION; + market.amm.set_total_social_loss(100 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1422,7 +1457,7 @@ mod revenue_pool_transfer_tests { let amm_fee_pool_token_amount_after = 500 * QUOTE_PRECISION; let terminal_state_surplus = 1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 1000 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 100 * QUOTE_PRECISION; + market.amm.set_total_social_loss(100 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1431,13 +1466,15 @@ mod revenue_pool_transfer_tests { ); assert_eq!(result.unwrap(), 150000000); - spot_market.revenue_pool.scaled_balance = 15000 * SPOT_BALANCE_PRECISION; + spot_market + .revenue_pool + .set_scaled_balance(15000 * SPOT_BALANCE_PRECISION); //Test case 11: claim max_revenue_withdraw_per_period let amm_fee_pool_token_amount_after = 500 * QUOTE_PRECISION; let terminal_state_surplus = -1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 1000 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 100 * QUOTE_PRECISION; + market.amm.set_total_social_loss(100 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1450,7 +1487,7 @@ mod revenue_pool_transfer_tests { let amm_fee_pool_token_amount_after = 500 * QUOTE_PRECISION; let terminal_state_surplus = -1000 * QUOTE_PRECISION_I128; market.insurance_claim.max_revenue_withdraw_per_period = 2000 * QUOTE_PRECISION_U64; - market.amm.total_social_loss = 100 * QUOTE_PRECISION; + market.amm.set_total_social_loss(100 * QUOTE_PRECISION); let result = calculate_revenue_pool_transfer( &market, &spot_market, @@ -1465,20 +1502,20 @@ mod revenue_pool_transfer_tests { // Set up input parameters let mut market = PerpMarket { amm: AMM { - total_social_loss: 0, - total_liquidation_fee: 0, - total_fee_withdrawn: 0, + total_social_loss: 0.into(), + total_liquidation_fee: 0.into(), + total_fee_withdrawn: 0.into(), net_revenue_since_last_funding: 169 * QUOTE_PRECISION_I64, - total_fee_minus_distributions: 1420420420420, - total_exchange_fee: 420420420420, + total_fee_minus_distributions: 1420420420420.into(), + total_exchange_fee: 420420420420.into(), fee_pool: PoolBalance { - scaled_balance: 81000 * SPOT_BALANCE_PRECISION, + scaled_balance: (81000 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: 10000 * SPOT_BALANCE_PRECISION, + scaled_balance: (10000 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, insurance_claim: InsuranceClaim { @@ -1491,13 +1528,13 @@ mod revenue_pool_transfer_tests { ..PerpMarket::default() }; let mut spot_market = SpotMarket { - deposit_balance: 20020 * SPOT_BALANCE_PRECISION, + deposit_balance: (20020 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 20020 * QUOTE_PRECISION_U64, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), revenue_pool: PoolBalance { market_index: 0, - scaled_balance: 10000 * SPOT_BALANCE_PRECISION, + scaled_balance: (10000 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, insurance_fund: InsuranceFund { @@ -1523,7 +1560,7 @@ mod revenue_pool_transfer_tests { assert_eq!(to_settle_with_user, -100); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 100); - assert_eq!(spot_market.revenue_pool.scaled_balance, 10065000000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 10065000000000); // revenue pool not yet settled let now = 10000; @@ -1538,7 +1575,7 @@ mod revenue_pool_transfer_tests { assert_eq!(to_settle_with_user, -100); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 100); - assert_eq!(spot_market.revenue_pool.scaled_balance, 10065000000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 10065000000000); // revenue pool settled but negative revenue for hour spot_market.insurance_fund.last_revenue_settle_ts = 3600 + 100; @@ -1556,7 +1593,7 @@ mod revenue_pool_transfer_tests { assert_eq!(to_settle_with_user, -100); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 100); - assert_eq!(spot_market.revenue_pool.scaled_balance, 10065000000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 10065000000000); // revenue pool settled and positive revenue for hour spot_market.insurance_fund.last_revenue_settle_ts = 3600 + 100; @@ -1574,7 +1611,7 @@ mod revenue_pool_transfer_tests { assert_eq!(to_settle_with_user, -100); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 10000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 10065000169000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 10065000169000); } #[test] @@ -1582,20 +1619,20 @@ mod revenue_pool_transfer_tests { // Set up input parameters let mut market = PerpMarket { amm: AMM { - total_social_loss: 0, - total_liquidation_fee: 0, - total_fee_withdrawn: 0, + total_social_loss: 0.into(), + total_liquidation_fee: 0.into(), + total_fee_withdrawn: 0.into(), net_revenue_since_last_funding: 169 * QUOTE_PRECISION_I64, - total_fee_minus_distributions: -6969696969, - total_exchange_fee: 420420420420, + total_fee_minus_distributions: (-6969696969).into(), + total_exchange_fee: 420420420420.into(), fee_pool: PoolBalance { - scaled_balance: 81000 * SPOT_BALANCE_PRECISION, + scaled_balance: (81000 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: 10000 * SPOT_BALANCE_PRECISION, + scaled_balance: (10000 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, insurance_claim: InsuranceClaim { @@ -1608,13 +1645,13 @@ mod revenue_pool_transfer_tests { ..PerpMarket::default() }; let mut spot_market = SpotMarket { - deposit_balance: 20020000 * SPOT_BALANCE_PRECISION, + deposit_balance: (20020000 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 20020000 * QUOTE_PRECISION_U64, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), revenue_pool: PoolBalance { market_index: 0, - scaled_balance: 10000 * SPOT_BALANCE_PRECISION, + scaled_balance: (10000 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, insurance_fund: InsuranceFund { @@ -1640,7 +1677,7 @@ mod revenue_pool_transfer_tests { assert_eq!(to_settle_with_user, -100); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 100); - assert_eq!(spot_market.revenue_pool.scaled_balance, 9935000000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 9935000000000); // revenue pool not yet settled let now = 10000; @@ -1655,7 +1692,7 @@ mod revenue_pool_transfer_tests { assert_eq!(to_settle_with_user, -100); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 100); - assert_eq!(spot_market.revenue_pool.scaled_balance, 9935000000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 9935000000000); // revenue pool settled and negative/positive revenue for hour irrelevant for withdraw spot_market.insurance_fund.last_revenue_settle_ts = 3600 + 100; @@ -1673,6 +1710,6 @@ mod revenue_pool_transfer_tests { assert_eq!(to_settle_with_user, -100); assert_eq!(market.insurance_claim.last_revenue_withdraw_ts, 10000); - assert_eq!(spot_market.revenue_pool.scaled_balance, 9870000000000); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 9870000000000); } } diff --git a/programs/drift/src/controller/funding.rs b/programs/drift/src/controller/funding.rs index eaa2dd9833..3293bf6d2b 100644 --- a/programs/drift/src/controller/funding.rs +++ b/programs/drift/src/controller/funding.rs @@ -46,9 +46,9 @@ pub fn settle_funding_payment( let amm: &AMM = &market.amm; let amm_cumulative_funding_rate = if user.perp_positions[position_index].base_asset_amount > 0 { - amm.cumulative_funding_rate_long + amm.cumulative_funding_rate_long() } else { - amm.cumulative_funding_rate_short + amm.cumulative_funding_rate_short() }; if amm_cumulative_funding_rate @@ -72,8 +72,8 @@ pub fn settle_funding_payment( market_index: market_position.market_index, funding_payment: market_funding_payment, //10e13 user_last_cumulative_funding: market_position.last_cumulative_funding_rate, //10e14 - amm_cumulative_funding_long: amm.cumulative_funding_rate_long, //10e14 - amm_cumulative_funding_short: amm.cumulative_funding_rate_short, //10e14 + amm_cumulative_funding_long: amm.cumulative_funding_rate_long(), //10e14 + amm_cumulative_funding_short: amm.cumulative_funding_rate_short(), //10e14 base_asset_amount: market_position.base_asset_amount, //10e13 }); @@ -105,9 +105,9 @@ pub fn settle_funding_payments( let amm_cumulative_funding_rate = if user.perp_positions[position_index].base_asset_amount > 0 { - amm.cumulative_funding_rate_long + amm.cumulative_funding_rate_long() } else { - amm.cumulative_funding_rate_short + amm.cumulative_funding_rate_short() }; if amm_cumulative_funding_rate @@ -131,8 +131,8 @@ pub fn settle_funding_payments( market_index: market_position.market_index, funding_payment: market_funding_payment, //1e6 user_last_cumulative_funding: market_position.last_cumulative_funding_rate, //1e9 - amm_cumulative_funding_long: amm.cumulative_funding_rate_long, //1e9 - amm_cumulative_funding_short: amm.cumulative_funding_rate_short, //1e9 + amm_cumulative_funding_long: amm.cumulative_funding_rate_long(), //1e9 + amm_cumulative_funding_short: amm.cumulative_funding_rate_short(), //1e9 base_asset_amount: market_position.base_asset_amount, //1e9 }); @@ -260,15 +260,19 @@ pub fn update_funding_rate( formulaic_update_k(market, oracle_price_data, funding_imbalance_cost, now)?; } - market.amm.cumulative_funding_rate_long = market - .amm - .cumulative_funding_rate_long - .safe_add(funding_rate_long)?; + market.amm.set_cumulative_funding_rate_long( + market + .amm + .cumulative_funding_rate_long() + .safe_add(funding_rate_long)?, + ); - market.amm.cumulative_funding_rate_short = market - .amm - .cumulative_funding_rate_short - .safe_add(funding_rate_short)?; + market.amm.set_cumulative_funding_rate_short( + market + .amm + .cumulative_funding_rate_short() + .safe_add(funding_rate_short)?, + ); market.amm.last_funding_rate = funding_rate; market.amm.last_funding_oracle_twap = oracle_price_twap; @@ -296,13 +300,13 @@ pub fn update_funding_rate( funding_rate, funding_rate_long, funding_rate_short, - cumulative_funding_rate_long: market.amm.cumulative_funding_rate_long, - cumulative_funding_rate_short: market.amm.cumulative_funding_rate_short, + cumulative_funding_rate_long: market.amm.cumulative_funding_rate_long(), + cumulative_funding_rate_short: market.amm.cumulative_funding_rate_short(), mark_price_twap: mid_price_twap, oracle_price_twap, period_revenue: market.amm.net_revenue_since_last_funding, - base_asset_amount_with_amm: market.amm.base_asset_amount_with_amm, - base_asset_amount_with_unsettled_lp: market.amm.base_asset_amount_with_unsettled_lp, + base_asset_amount_with_amm: market.amm.base_asset_amount_with_amm(), + base_asset_amount_with_unsettled_lp: market.amm.base_asset_amount_with_unsettled_lp(), }); market.amm.net_revenue_since_last_funding = 0; diff --git a/programs/drift/src/controller/insurance.rs b/programs/drift/src/controller/insurance.rs index fa53164733..4268ae7043 100644 --- a/programs/drift/src/controller/insurance.rs +++ b/programs/drift/src/controller/insurance.rs @@ -63,13 +63,13 @@ pub fn update_user_stats_if_stake_amount( let if_stake_amount = if if_stake_amount_delta >= 0 { if_shares_to_vault_amount( insurance_fund_stake.checked_if_shares(spot_market)?, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount.safe_add(if_stake_amount_delta.unsigned_abs())?, )? } else { if_shares_to_vault_amount( insurance_fund_stake.checked_if_shares(spot_market)?, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount.safe_sub(if_stake_amount_delta.unsigned_abs())?, )? }; @@ -115,7 +115,7 @@ pub fn add_insurance_fund_stake( admin_deposit: bool, ) -> DriftResult { validate!( - !(insurance_vault_amount == 0 && spot_market.insurance_fund.total_shares != 0), + !(insurance_vault_amount == 0 && spot_market.insurance_fund.total_shares() != 0), ErrorCode::InvalidIFForNewStakes, "Insurance Fund balance should be non-zero for new stakers to enter" )?; @@ -124,12 +124,12 @@ pub fn add_insurance_fund_stake( apply_rebase_to_insurance_fund_stake(insurance_fund_stake, spot_market)?; let if_shares_before = insurance_fund_stake.checked_if_shares(spot_market)?; - let total_if_shares_before = spot_market.insurance_fund.total_shares; - let user_if_shares_before = spot_market.insurance_fund.user_shares; + let total_if_shares_before = spot_market.insurance_fund.total_shares(); + let user_if_shares_before = spot_market.insurance_fund.user_shares(); let n_shares = vault_amount_to_if_shares( amount, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount, )?; @@ -142,11 +142,19 @@ pub fn add_insurance_fund_stake( insurance_fund_stake.increase_if_shares(n_shares, spot_market)?; - spot_market.insurance_fund.total_shares = - spot_market.insurance_fund.total_shares.safe_add(n_shares)?; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_add(n_shares)?, + ); - spot_market.insurance_fund.user_shares = - spot_market.insurance_fund.user_shares.safe_add(n_shares)?; + spot_market.insurance_fund.set_user_shares( + spot_market + .insurance_fund + .user_shares() + .safe_add(n_shares)?, + ); update_user_stats_if_stake_amount( amount.cast()?, @@ -174,8 +182,8 @@ pub fn add_insurance_fund_stake( user_if_shares_before, total_if_shares_before, if_shares_after, - total_if_shares_after: spot_market.insurance_fund.total_shares, - user_if_shares_after: spot_market.insurance_fund.user_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), + user_if_shares_after: spot_market.insurance_fund.user_shares(), }); Ok(()) @@ -186,31 +194,39 @@ pub fn apply_rebase_to_insurance_fund( spot_market: &mut SpotMarket, ) -> DriftResult { if insurance_fund_vault_balance != 0 - && insurance_fund_vault_balance.cast::()? < spot_market.insurance_fund.total_shares + && insurance_fund_vault_balance.cast::()? < spot_market.insurance_fund.total_shares() { let (expo_diff, rebase_divisor) = calculate_rebase_info( - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_fund_vault_balance, )?; - spot_market.insurance_fund.total_shares = spot_market - .insurance_fund - .total_shares - .safe_div(rebase_divisor)?; - spot_market.insurance_fund.user_shares = spot_market - .insurance_fund - .user_shares - .safe_div(rebase_divisor)?; - spot_market.insurance_fund.shares_base = spot_market - .insurance_fund - .shares_base - .safe_add(expo_diff.cast::()?)?; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_div(rebase_divisor)?, + ); + spot_market.insurance_fund.set_user_shares( + spot_market + .insurance_fund + .user_shares() + .safe_div(rebase_divisor)?, + ); + spot_market.insurance_fund.set_shares_base( + spot_market + .insurance_fund + .shares_base() + .safe_add(expo_diff.cast::()?)?, + ); msg!("rebasing insurance fund: expo_diff={}", expo_diff); } - if insurance_fund_vault_balance != 0 && spot_market.insurance_fund.total_shares == 0 { - spot_market.insurance_fund.total_shares = insurance_fund_vault_balance.cast::()?; + if insurance_fund_vault_balance != 0 && spot_market.insurance_fund.total_shares() == 0 { + spot_market + .insurance_fund + .set_total_shares(insurance_fund_vault_balance.cast::()?); } Ok(()) @@ -220,25 +236,25 @@ pub fn apply_rebase_to_insurance_fund_stake( insurance_fund_stake: &mut InsuranceFundStake, spot_market: &mut SpotMarket, ) -> DriftResult { - if spot_market.insurance_fund.shares_base != insurance_fund_stake.if_base { + if spot_market.insurance_fund.shares_base() != insurance_fund_stake.if_base() { validate!( - spot_market.insurance_fund.shares_base > insurance_fund_stake.if_base, + spot_market.insurance_fund.shares_base() > insurance_fund_stake.if_base(), ErrorCode::InvalidIFRebase, "Rebase expo out of bounds" )?; - let expo_diff = (spot_market.insurance_fund.shares_base - insurance_fund_stake.if_base) + let expo_diff = (spot_market.insurance_fund.shares_base() - insurance_fund_stake.if_base()) .cast::()?; let rebase_divisor = 10_u128.pow(expo_diff); msg!( "rebasing insurance fund stake: base: {} -> {} ", - insurance_fund_stake.if_base, - spot_market.insurance_fund.shares_base, + insurance_fund_stake.if_base(), + spot_market.insurance_fund.shares_base(), ); - insurance_fund_stake.if_base = spot_market.insurance_fund.shares_base; + insurance_fund_stake.set_if_base(spot_market.insurance_fund.shares_base()); let old_if_shares = insurance_fund_stake.unchecked_if_shares(); let new_if_shares = old_if_shares.safe_div(rebase_divisor)?; @@ -250,9 +266,11 @@ pub fn apply_rebase_to_insurance_fund_stake( insurance_fund_stake.update_if_shares(new_if_shares, spot_market)?; - insurance_fund_stake.last_withdraw_request_shares = insurance_fund_stake - .last_withdraw_request_shares - .safe_div(rebase_divisor)?; + insurance_fund_stake.set_last_withdraw_request_shares( + insurance_fund_stake + .last_withdraw_request_shares() + .safe_div(rebase_divisor)?, + ); } Ok(()) @@ -267,33 +285,33 @@ pub fn request_remove_insurance_fund_stake( now: i64, ) -> DriftResult { msg!("n_shares {}", n_shares); - insurance_fund_stake.last_withdraw_request_shares = n_shares; + insurance_fund_stake.set_last_withdraw_request_shares(n_shares); apply_rebase_to_insurance_fund(insurance_vault_amount, spot_market)?; apply_rebase_to_insurance_fund_stake(insurance_fund_stake, spot_market)?; let if_shares_before = insurance_fund_stake.checked_if_shares(spot_market)?; - let total_if_shares_before = spot_market.insurance_fund.total_shares; - let user_if_shares_before = spot_market.insurance_fund.user_shares; + let total_if_shares_before = spot_market.insurance_fund.total_shares(); + let user_if_shares_before = spot_market.insurance_fund.user_shares(); validate!( - insurance_fund_stake.last_withdraw_request_shares + insurance_fund_stake.last_withdraw_request_shares() <= insurance_fund_stake.checked_if_shares(spot_market)?, ErrorCode::InvalidInsuranceUnstakeSize, "last_withdraw_request_shares exceeds if_shares {} > {}", - insurance_fund_stake.last_withdraw_request_shares, + insurance_fund_stake.last_withdraw_request_shares(), insurance_fund_stake.checked_if_shares(spot_market)? )?; validate!( - insurance_fund_stake.if_base == spot_market.insurance_fund.shares_base, + insurance_fund_stake.if_base() == spot_market.insurance_fund.shares_base(), ErrorCode::InvalidIFRebase, "if stake base != spot market base" )?; insurance_fund_stake.last_withdraw_request_value = if_shares_to_vault_amount( - insurance_fund_stake.last_withdraw_request_shares, - spot_market.insurance_fund.total_shares, + insurance_fund_stake.last_withdraw_request_shares(), + spot_market.insurance_fund.total_shares(), insurance_vault_amount, )? .min(insurance_vault_amount.saturating_sub(1)); @@ -327,8 +345,8 @@ pub fn request_remove_insurance_fund_stake( user_if_shares_before, total_if_shares_before, if_shares_after, - total_if_shares_after: spot_market.insurance_fund.total_shares, - user_if_shares_after: spot_market.insurance_fund.user_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), + user_if_shares_after: spot_market.insurance_fund.user_shares(), }); insurance_fund_stake.last_withdraw_request_ts = now; @@ -347,17 +365,17 @@ pub fn cancel_request_remove_insurance_fund_stake( apply_rebase_to_insurance_fund_stake(insurance_fund_stake, spot_market)?; let if_shares_before = insurance_fund_stake.checked_if_shares(spot_market)?; - let total_if_shares_before = spot_market.insurance_fund.total_shares; - let user_if_shares_before = spot_market.insurance_fund.user_shares; + let total_if_shares_before = spot_market.insurance_fund.total_shares(); + let user_if_shares_before = spot_market.insurance_fund.user_shares(); validate!( - insurance_fund_stake.if_base == spot_market.insurance_fund.shares_base, + insurance_fund_stake.if_base() == spot_market.insurance_fund.shares_base(), ErrorCode::InvalidIFRebase, "if stake base != spot market base" )?; validate!( - insurance_fund_stake.last_withdraw_request_shares != 0, + insurance_fund_stake.last_withdraw_request_shares() != 0, ErrorCode::InvalidIFUnstakeCancel, "No withdraw request in progress" )?; @@ -367,15 +385,19 @@ pub fn cancel_request_remove_insurance_fund_stake( insurance_fund_stake.decrease_if_shares(if_shares_lost, spot_market)?; - spot_market.insurance_fund.total_shares = spot_market - .insurance_fund - .total_shares - .safe_sub(if_shares_lost)?; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_sub(if_shares_lost)?, + ); - spot_market.insurance_fund.user_shares = spot_market - .insurance_fund - .user_shares - .safe_sub(if_shares_lost)?; + spot_market.insurance_fund.set_user_shares( + spot_market + .insurance_fund + .user_shares() + .safe_sub(if_shares_lost)?, + ); let if_shares_after = insurance_fund_stake.checked_if_shares(spot_market)?; @@ -399,11 +421,11 @@ pub fn cancel_request_remove_insurance_fund_stake( user_if_shares_before, total_if_shares_before, if_shares_after, - total_if_shares_after: spot_market.insurance_fund.total_shares, - user_if_shares_after: spot_market.insurance_fund.user_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), + user_if_shares_after: spot_market.insurance_fund.user_shares(), }); - insurance_fund_stake.last_withdraw_request_shares = 0; + insurance_fund_stake.set_last_withdraw_request_shares(0); insurance_fund_stake.last_withdraw_request_value = 0; insurance_fund_stake.last_withdraw_request_ts = now; @@ -429,10 +451,10 @@ pub fn remove_insurance_fund_stake( apply_rebase_to_insurance_fund_stake(insurance_fund_stake, spot_market)?; let if_shares_before = insurance_fund_stake.checked_if_shares(spot_market)?; - let total_if_shares_before = spot_market.insurance_fund.total_shares; - let user_if_shares_before = spot_market.insurance_fund.user_shares; + let total_if_shares_before = spot_market.insurance_fund.total_shares(); + let user_if_shares_before = spot_market.insurance_fund.user_shares(); - let n_shares = insurance_fund_stake.last_withdraw_request_shares; + let n_shares = insurance_fund_stake.last_withdraw_request_shares(); validate!( n_shares > 0, @@ -447,7 +469,7 @@ pub fn remove_insurance_fund_stake( let amount = if_shares_to_vault_amount( n_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount, )?; @@ -462,14 +484,22 @@ pub fn remove_insurance_fund_stake( .cost_basis .safe_sub(withdraw_amount.cast()?)?; - spot_market.insurance_fund.total_shares = - spot_market.insurance_fund.total_shares.safe_sub(n_shares)?; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_sub(n_shares)?, + ); - spot_market.insurance_fund.user_shares = - spot_market.insurance_fund.user_shares.safe_sub(n_shares)?; + spot_market.insurance_fund.set_user_shares( + spot_market + .insurance_fund + .user_shares() + .safe_sub(n_shares)?, + ); // reset insurance_fund_stake withdraw request info - insurance_fund_stake.last_withdraw_request_shares = 0; + insurance_fund_stake.set_last_withdraw_request_shares(0); insurance_fund_stake.last_withdraw_request_value = 0; insurance_fund_stake.last_withdraw_request_ts = now; @@ -495,8 +525,8 @@ pub fn remove_insurance_fund_stake( user_if_shares_before, total_if_shares_before, if_shares_after, - total_if_shares_after: spot_market.insurance_fund.total_shares, - user_if_shares_after: spot_market.insurance_fund.user_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), + user_if_shares_after: spot_market.insurance_fund.user_shares(), }); Ok(withdraw_amount) @@ -511,8 +541,8 @@ pub fn admin_remove_insurance_fund_stake( ) -> DriftResult { apply_rebase_to_insurance_fund(insurance_vault_amount, spot_market)?; - let total_if_shares_before = spot_market.insurance_fund.total_shares; - let user_if_shares_before = spot_market.insurance_fund.user_shares; + let total_if_shares_before = spot_market.insurance_fund.total_shares(); + let user_if_shares_before = spot_market.insurance_fund.user_shares(); let if_shares_before = total_if_shares_before.safe_sub(user_if_shares_before)?; @@ -526,16 +556,20 @@ pub fn admin_remove_insurance_fund_stake( let withdraw_amount = if_shares_to_vault_amount( n_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount, )?; - spot_market.insurance_fund.total_shares = - spot_market.insurance_fund.total_shares.safe_sub(n_shares)?; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_sub(n_shares)?, + ); let if_shares_after = spot_market .insurance_fund - .total_shares + .total_shares() .safe_sub(user_if_shares_before)?; emit!(InsuranceFundStakeRecord { @@ -549,8 +583,8 @@ pub fn admin_remove_insurance_fund_stake( user_if_shares_before, total_if_shares_before, if_shares_after, - total_if_shares_after: spot_market.insurance_fund.total_shares, - user_if_shares_after: spot_market.insurance_fund.user_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), + user_if_shares_after: spot_market.insurance_fund.user_shares(), }); Ok(withdraw_amount) @@ -567,8 +601,8 @@ pub fn transfer_protocol_insurance_fund_stake( ) -> DriftResult { apply_rebase_to_insurance_fund(insurance_vault_amount, spot_market)?; - let total_if_shares_before = spot_market.insurance_fund.total_shares; - let user_if_shares_before = spot_market.insurance_fund.user_shares; + let total_if_shares_before = spot_market.insurance_fund.total_shares(); + let user_if_shares_before = spot_market.insurance_fund.user_shares(); let if_shares_before = total_if_shares_before.safe_sub(user_if_shares_before)?; let target_if_shares_before = target_insurance_fund_stake.checked_if_shares(spot_market)?; @@ -580,8 +614,12 @@ pub fn transfer_protocol_insurance_fund_stake( n_shares )?; - spot_market.insurance_fund.user_shares = - spot_market.insurance_fund.user_shares.safe_add(n_shares)?; + spot_market.insurance_fund.set_user_shares( + spot_market + .insurance_fund + .user_shares() + .safe_add(n_shares)?, + ); target_insurance_fund_stake.increase_if_shares(n_shares, spot_market)?; @@ -590,27 +628,27 @@ pub fn transfer_protocol_insurance_fund_stake( if spot_market.market_index == QUOTE_SPOT_MARKET_INDEX { user_stats.if_staked_quote_asset_amount = if_shares_to_vault_amount( target_if_shares_after, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount, )?; } else if spot_market.market_index == GOV_SPOT_MARKET_INDEX { user_stats.if_staked_gov_token_amount = if_shares_to_vault_amount( target_if_shares_after, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount, )?; } let withdraw_amount = if_shares_to_vault_amount( n_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount, )?; - let user_if_shares_after = spot_market.insurance_fund.user_shares; + let user_if_shares_after = spot_market.insurance_fund.user_shares(); let protocol_if_shares_after = spot_market .insurance_fund - .total_shares + .total_shares() .safe_sub(user_if_shares_after)?; emit!(InsuranceFundStakeRecord { @@ -624,8 +662,8 @@ pub fn transfer_protocol_insurance_fund_stake( user_if_shares_before, total_if_shares_before, if_shares_after: protocol_if_shares_after, - total_if_shares_after: spot_market.insurance_fund.total_shares, - user_if_shares_after: spot_market.insurance_fund.user_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), + user_if_shares_after: spot_market.insurance_fund.user_shares(), }); emit!(InsuranceFundStakeRecord { @@ -639,8 +677,8 @@ pub fn transfer_protocol_insurance_fund_stake( user_if_shares_before, total_if_shares_before, if_shares_after: target_insurance_fund_stake.checked_if_shares(spot_market)?, - total_if_shares_after: spot_market.insurance_fund.total_shares, - user_if_shares_after: spot_market.insurance_fund.user_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), + user_if_shares_after: spot_market.insurance_fund.user_shares(), }); Ok(withdraw_amount) @@ -735,7 +773,7 @@ pub fn settle_revenue_to_insurance_fund( validate_spot_market_vault_amount(spot_market, spot_market_vault_amount)?; let mut token_amount = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), spot_market, &SpotBalanceType::Deposit, )?; @@ -745,7 +783,7 @@ pub fn settle_revenue_to_insurance_fund( token_amount = depositors_claim.max(0).cast::()?.safe_div(2)?; } - if spot_market.insurance_fund.user_shares > 0 { + if spot_market.insurance_fund.user_shares() > 0 { // only allow MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT or 1/10th of revenue pool to be settled let max_apr_per_revenue_settle: u128 = if spot_market.market_index == GOV_SPOT_MARKET_INDEX { @@ -795,15 +833,19 @@ pub fn settle_revenue_to_insurance_fund( insurance_fund_token_amount .safe_mul(protocol_if_factor.cast()?)? .safe_div(spot_market.insurance_fund.total_factor.cast()?)?, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_vault_amount, )?; - spot_market.insurance_fund.total_shares = - spot_market.insurance_fund.total_shares.safe_add(n_shares)?; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_add(n_shares)?, + ); } - let total_if_shares_before = spot_market.insurance_fund.total_shares; + let total_if_shares_before = spot_market.insurance_fund.total_shares(); update_revenue_pool_balances( insurance_fund_token_amount.cast::()?, @@ -822,7 +864,7 @@ pub fn settle_revenue_to_insurance_fund( vault_amount_before: spot_market_vault_amount, insurance_vault_amount_before: insurance_vault_amount, total_if_shares_before, - total_if_shares_after: spot_market.insurance_fund.total_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), }); insurance_fund_token_amount.cast() @@ -836,14 +878,14 @@ pub fn resolve_perp_pnl_deficit( now: i64, ) -> DriftResult { validate!( - market.amm.total_fee_minus_distributions < 0, + market.amm.total_fee_minus_distributions() < 0, ErrorCode::NoAmmPerpPnlDeficit, "market.amm.total_fee_minus_distributions={} must be negative", - market.amm.total_fee_minus_distributions + market.amm.total_fee_minus_distributions() )?; let pnl_pool_token_amount = get_token_amount( - market.pnl_pool.scaled_balance, + market.pnl_pool.scaled_balance(), spot_market, &SpotBalanceType::Deposit, )?; @@ -866,7 +908,7 @@ pub fn resolve_perp_pnl_deficit( update_spot_market_cumulative_interest(spot_market, None, now)?; - let total_if_shares_before = spot_market.insurance_fund.total_shares; + let total_if_shares_before = spot_market.insurance_fund.total_shares(); let excess_user_pnl_imbalance = if market.unrealized_pnl_max_imbalance > 0 { let net_unsettled_pnl = calculate_net_user_pnl( @@ -931,10 +973,12 @@ pub fn resolve_perp_pnl_deficit( excess_user_pnl_imbalance )?; - market.amm.total_fee_minus_distributions = market - .amm - .total_fee_minus_distributions - .safe_add(insurance_withdraw)?; + market.amm.set_total_fee_minus_distributions( + market + .amm + .total_fee_minus_distributions() + .safe_add(insurance_withdraw)?, + ); market.insurance_claim.revenue_withdraw_since_last_settle = market .insurance_claim @@ -975,7 +1019,7 @@ pub fn resolve_perp_pnl_deficit( vault_amount_before: vault_amount, insurance_vault_amount_before: insurance_vault_amount, total_if_shares_before, - total_if_shares_after: spot_market.insurance_fund.total_shares, + total_if_shares_after: spot_market.insurance_fund.total_shares(), }); insurance_withdraw.cast() @@ -1021,28 +1065,28 @@ pub fn handle_if_end_swap( let out_insurance_fund_vault_amount_before = out_insurance_fund_vault_amount_after.safe_sub(out_amount)?; - let in_if_total_shares_before = in_spot_market.insurance_fund.total_shares; - let out_if_total_shares_before = out_spot_market.insurance_fund.total_shares; - let in_if_user_shares_before = in_spot_market.insurance_fund.user_shares; - let out_if_user_shares_before = out_spot_market.insurance_fund.user_shares; + let in_if_total_shares_before = in_spot_market.insurance_fund.total_shares(); + let out_if_total_shares_before = out_spot_market.insurance_fund.total_shares(); + let in_if_user_shares_before = in_spot_market.insurance_fund.user_shares(); + let out_if_user_shares_before = out_spot_market.insurance_fund.user_shares(); let in_share_price_before = calculate_share_price( - in_spot_market.insurance_fund.total_shares, + in_spot_market.insurance_fund.total_shares(), in_insurance_fund_vault_amount_before, )?; let out_share_price_before = calculate_share_price( - out_spot_market.insurance_fund.total_shares, + out_spot_market.insurance_fund.total_shares(), out_insurance_fund_vault_amount_before, )?; let in_shares = vault_amount_to_if_shares( in_amount, - in_spot_market.insurance_fund.total_shares, + in_spot_market.insurance_fund.total_shares(), in_insurance_fund_vault_amount_before, )?; let out_shares = vault_amount_to_if_shares( out_amount, - out_spot_market.insurance_fund.total_shares, + out_spot_market.insurance_fund.total_shares(), out_insurance_fund_vault_amount_before, )?; @@ -1056,21 +1100,25 @@ pub fn handle_if_end_swap( )?; // increment spot market insurance funds total shares - in_spot_market.insurance_fund.total_shares = in_spot_market - .insurance_fund - .total_shares - .safe_sub(in_shares)?; - out_spot_market.insurance_fund.total_shares = out_spot_market - .insurance_fund - .total_shares - .safe_add(out_shares)?; + in_spot_market.insurance_fund.set_total_shares( + in_spot_market + .insurance_fund + .total_shares() + .safe_sub(in_shares)?, + ); + out_spot_market.insurance_fund.set_total_shares( + out_spot_market + .insurance_fund + .total_shares() + .safe_add(out_shares)?, + ); let in_share_price_after = calculate_share_price( - in_spot_market.insurance_fund.total_shares, + in_spot_market.insurance_fund.total_shares(), in_insurance_fund_vault_amount_after, )?; let out_share_price_after = calculate_share_price( - out_spot_market.insurance_fund.total_shares, + out_spot_market.insurance_fund.total_shares(), out_insurance_fund_vault_amount_after, )?; @@ -1163,10 +1211,10 @@ pub fn handle_if_end_swap( out_if_total_shares_before, in_if_user_shares_before, out_if_user_shares_before, - in_if_total_shares_after: in_spot_market.insurance_fund.total_shares, - out_if_total_shares_after: out_spot_market.insurance_fund.total_shares, - in_if_user_shares_after: in_spot_market.insurance_fund.user_shares, - out_if_user_shares_after: out_spot_market.insurance_fund.user_shares, + in_if_total_shares_after: in_spot_market.insurance_fund.total_shares(), + out_if_total_shares_after: out_spot_market.insurance_fund.total_shares(), + in_if_user_shares_after: in_spot_market.insurance_fund.user_shares(), + out_if_user_shares_after: out_spot_market.insurance_fund.user_shares(), }); Ok(()) @@ -1183,7 +1231,7 @@ pub fn transfer_protocol_if_shares_to_revenue_pool( let shares = vault_amount_to_if_shares( amount, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_fund_vault_amount_before, )?; @@ -1205,8 +1253,9 @@ pub fn transfer_protocol_if_shares_to_revenue_pool( if_rebalance_config.max_transfer_amount()? )?; - spot_market.insurance_fund.total_shares = - spot_market.insurance_fund.total_shares.safe_sub(shares)?; + spot_market + .insurance_fund + .set_total_shares(spot_market.insurance_fund.total_shares().safe_sub(shares)?); update_revenue_pool_balances(amount.cast()?, &SpotBalanceType::Deposit, spot_market)?; diff --git a/programs/drift/src/controller/insurance/tests.rs b/programs/drift/src/controller/insurance/tests.rs index c71948c3d3..04150329b0 100644 --- a/programs/drift/src/controller/insurance/tests.rs +++ b/programs/drift/src/controller/insurance/tests.rs @@ -25,8 +25,8 @@ pub fn basic_stake_if_test() { }; let amount = QUOTE_PRECISION as u64; // $1 let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, ..InsuranceFund::default() @@ -58,8 +58,8 @@ pub fn basic_stake_if_test() { .is_err()); assert_eq!(if_stake.unchecked_if_shares(), amount as u128); - assert_eq!(spot_market.insurance_fund.total_shares, amount as u128); - assert_eq!(spot_market.insurance_fund.shares_base, 0); + assert_eq!(spot_market.insurance_fund.total_shares(), amount as u128); + assert_eq!(spot_market.insurance_fund.shares_base(), 0); request_remove_insurance_fund_stake( if_stake.unchecked_if_shares(), @@ -71,13 +71,13 @@ pub fn basic_stake_if_test() { ) .unwrap(); assert_eq!( - if_stake.last_withdraw_request_shares, + if_stake.last_withdraw_request_shares(), if_stake.unchecked_if_shares() ); assert_eq!(if_stake.last_withdraw_request_value, if_balance - 1); //rounding in favor assert_eq!(if_stake.unchecked_if_shares(), amount as u128); - assert_eq!(spot_market.insurance_fund.total_shares, amount as u128); - assert_eq!(spot_market.insurance_fund.shares_base, 0); + assert_eq!(spot_market.insurance_fund.total_shares(), amount as u128); + assert_eq!(spot_market.insurance_fund.shares_base(), 0); let amount_returned = (remove_insurance_fund_stake( if_balance, @@ -92,10 +92,10 @@ pub fn basic_stake_if_test() { assert_eq!(if_stake.unchecked_if_shares(), 0); assert_eq!(if_stake.cost_basis, 1); - assert_eq!(if_stake.last_withdraw_request_shares, 0); + assert_eq!(if_stake.last_withdraw_request_shares(), 0); assert_eq!(if_stake.last_withdraw_request_value, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 0); - assert_eq!(spot_market.insurance_fund.shares_base, 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); + assert_eq!(spot_market.insurance_fund.shares_base(), 0); assert_eq!(if_balance, 1); add_insurance_fund_stake( @@ -109,9 +109,9 @@ pub fn basic_stake_if_test() { ) .unwrap(); assert_eq!(if_stake.cost_basis, 1234); - assert_eq!(spot_market.insurance_fund.user_shares, 1234); - assert_eq!(spot_market.insurance_fund.total_shares, 1235); // protocol claims the 1 balance - assert_eq!(spot_market.insurance_fund.shares_base, 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 1234); + assert_eq!(spot_market.insurance_fund.total_shares(), 1235); // protocol claims the 1 balance + assert_eq!(spot_market.insurance_fund.shares_base(), 0); } #[test] @@ -124,8 +124,8 @@ pub fn basic_seeded_stake_if_test() { }; let amount = QUOTE_PRECISION as u64; // $1 let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, ..InsuranceFund::default() @@ -133,8 +133,8 @@ pub fn basic_seeded_stake_if_test() { ..SpotMarket::default() }; - assert_eq!(spot_market.insurance_fund.total_shares, 0); - assert_eq!(spot_market.insurance_fund.user_shares, 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); add_insurance_fund_stake( amount, @@ -148,10 +148,10 @@ pub fn basic_seeded_stake_if_test() { .unwrap(); assert_eq!( - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), (1001 * QUOTE_PRECISION) ); // seeded works - assert_eq!(spot_market.insurance_fund.user_shares, QUOTE_PRECISION); + assert_eq!(spot_market.insurance_fund.user_shares(), QUOTE_PRECISION); assert_eq!(if_stake.unchecked_if_shares(), amount as u128); if_balance += amount; @@ -176,7 +176,7 @@ pub fn basic_seeded_stake_if_test() { ) .unwrap(); assert_eq!( - if_stake.last_withdraw_request_shares, + if_stake.last_withdraw_request_shares(), if_stake.unchecked_if_shares() ); assert_eq!(if_stake.last_withdraw_request_value, 1000000); @@ -194,7 +194,7 @@ pub fn basic_seeded_stake_if_test() { assert_eq!(if_stake.unchecked_if_shares(), 0); assert_eq!(if_stake.cost_basis, 0); - assert_eq!(if_stake.last_withdraw_request_shares, 0); + assert_eq!(if_stake.last_withdraw_request_shares(), 0); assert_eq!(if_stake.last_withdraw_request_value, 0); assert_eq!(if_balance, 1000000000); @@ -224,8 +224,8 @@ pub fn large_num_seeded_stake_if_test() { // all funds in revenue pool let mut spot_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, revenue_settle_period: 1, @@ -233,14 +233,14 @@ pub fn large_num_seeded_stake_if_test() { }, revenue_pool: PoolBalance { market_index: 0, - scaled_balance: 100 * SPOT_BALANCE_PRECISION, + scaled_balance: (100 * SPOT_BALANCE_PRECISION).into(), ..PoolBalance::default() }, ..SpotMarket::default() }; - assert_eq!(spot_market.insurance_fund.total_shares, 0); - assert_eq!(spot_market.insurance_fund.user_shares, 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); add_insurance_fund_stake( amount, @@ -253,8 +253,8 @@ pub fn large_num_seeded_stake_if_test() { ) .unwrap(); - assert_eq!(spot_market.insurance_fund.total_shares, 199000199000001); // seeded works - assert_eq!(spot_market.insurance_fund.user_shares, 199000001); + assert_eq!(spot_market.insurance_fund.total_shares(), 199000199000001); // seeded works + assert_eq!(spot_market.insurance_fund.user_shares(), 199000001); assert_eq!(if_stake.unchecked_if_shares(), amount as u128); if_balance += amount; @@ -269,7 +269,7 @@ pub fn large_num_seeded_stake_if_test() { .is_err()); assert_eq!(if_stake.unchecked_if_shares(), amount as u128); let spot_market_vault_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -285,9 +285,9 @@ pub fn large_num_seeded_stake_if_test() { ) .unwrap(); assert_eq!(flow, 11); - assert_eq!(spot_market.revenue_pool.scaled_balance, 90099009901); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 90099009901); let spot_market_vault_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -306,7 +306,7 @@ pub fn large_num_seeded_stake_if_test() { ) .unwrap(); assert_eq!( - if_stake.last_withdraw_request_shares, + if_stake.last_withdraw_request_shares(), if_stake.unchecked_if_shares() ); assert_eq!(if_stake.last_withdraw_request_value, 199000001); @@ -324,13 +324,15 @@ pub fn large_num_seeded_stake_if_test() { assert_eq!(if_stake.unchecked_if_shares(), 0); assert_eq!(if_stake.cost_basis, 0); - assert_eq!(if_stake.last_withdraw_request_shares, 0); + assert_eq!(if_stake.last_withdraw_request_shares(), 0); assert_eq!(if_stake.last_withdraw_request_value, 0); assert_eq!(if_balance, 199000000000011); - assert_eq!(spot_market.insurance_fund.user_shares, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 199000000000000); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 199000000000000); - spot_market.revenue_pool.scaled_balance = 100 * SPOT_BALANCE_PRECISION; + spot_market + .revenue_pool + .set_scaled_balance(100 * SPOT_BALANCE_PRECISION); add_insurance_fund_stake( 199033744205760, @@ -343,7 +345,7 @@ pub fn large_num_seeded_stake_if_test() { ) .unwrap(); assert_eq!(if_stake.cost_basis, 199033744205760); - assert_eq!(spot_market.insurance_fund.user_shares, 199033744205748); + assert_eq!(spot_market.insurance_fund.user_shares(), 199033744205748); add_insurance_fund_stake( 199033744205760, @@ -356,7 +358,7 @@ pub fn large_num_seeded_stake_if_test() { ) .unwrap(); assert_eq!(if_stake.cost_basis, 398067488411520); - assert_eq!(spot_market.insurance_fund.user_shares, 597134982544960); + assert_eq!(spot_market.insurance_fund.user_shares(), 597134982544960); } #[test] @@ -369,8 +371,8 @@ pub fn gains_stake_if_test() { }; let amount = QUOTE_PRECISION as u64; // $1 let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, ..InsuranceFund::default() @@ -494,8 +496,8 @@ pub fn losses_stake_if_test() { }; let amount = QUOTE_PRECISION as u64; // $1 let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, ..InsuranceFund::default() @@ -622,8 +624,8 @@ pub fn escrow_losses_stake_if_test() { }; let amount = (QUOTE_PRECISION * 100_000) as u64; // $100k let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 60 * 60 * 24 * 7, // 7 weeks ..InsuranceFund::default() @@ -654,11 +656,11 @@ pub fn escrow_losses_stake_if_test() { let o = if_shares_to_vault_amount( n_shares / 3, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), if_balance, ) .unwrap(); - assert_eq!(if_stake.last_withdraw_request_shares, 0); + assert_eq!(if_stake.last_withdraw_request_shares(), 0); request_remove_insurance_fund_stake( n_shares / 3, @@ -669,7 +671,7 @@ pub fn escrow_losses_stake_if_test() { now, ) .unwrap(); - assert_eq!(if_stake.last_withdraw_request_shares, 33333333333); + assert_eq!(if_stake.last_withdraw_request_shares(), 33333333333); assert_eq!( if_stake.last_withdraw_request_value, expected_amount_returned @@ -719,12 +721,12 @@ pub fn escrow_gains_stake_if_test() { }; let amount = 100_000_384_939_u64; // $100k + change let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 60 * 60 * 24 * 7, // 7 weeks - total_shares: 1, - user_shares: 0, + total_shares: 1.into(), + user_shares: 0.into(), ..InsuranceFund::default() }, ..SpotMarket::default() @@ -767,11 +769,11 @@ pub fn escrow_gains_stake_if_test() { let n_shares = if_stake.unchecked_if_shares(); let expected_amount_returned = - (if_balance as u128 * n_shares / spot_market.insurance_fund.total_shares) as u64; + (if_balance as u128 * n_shares / spot_market.insurance_fund.total_shares()) as u64; let o = if_shares_to_vault_amount( n_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), if_balance, ) .unwrap(); @@ -802,7 +804,7 @@ pub fn escrow_gains_stake_if_test() { if_balance = if_balance + if_balance / 412; let ideal_amount_returned = - (if_balance as u128 * n_shares / spot_market.insurance_fund.total_shares) as u64; + (if_balance as u128 * n_shares / spot_market.insurance_fund.total_shares()) as u64; // appropriate time for withdraw let amount_returned = (remove_insurance_fund_stake( @@ -813,7 +815,7 @@ pub fn escrow_gains_stake_if_test() { now + 60 * 60 * 24 * 7 + 3254, )) .unwrap(); - assert_eq!(if_stake.last_withdraw_request_shares, 0); + assert_eq!(if_stake.last_withdraw_request_shares(), 0); assert_eq!(if_stake.last_withdraw_request_value, 0); if_balance -= amount_returned; @@ -839,12 +841,12 @@ pub fn drained_stake_if_test_rebase_on_new_add() { let amount = 100_000_384_939_u64; // $100k + change let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 60 * 60 * 24 * 7, // 7 weeks - total_shares: 100_000 * QUOTE_PRECISION, - user_shares: 80_000 * QUOTE_PRECISION, + total_shares: (100_000 * QUOTE_PRECISION).into(), + user_shares: (80_000 * QUOTE_PRECISION).into(), ..InsuranceFund::default() }, ..SpotMarket::default() @@ -875,9 +877,9 @@ pub fn drained_stake_if_test_rebase_on_new_add() { .is_err()); assert_eq!(if_stake.unchecked_if_shares(), 0); - assert_eq!(spot_market.insurance_fund.total_shares, 100_000_000_000); + assert_eq!(spot_market.insurance_fund.total_shares(), 100_000_000_000); assert_eq!( - spot_market.insurance_fund.user_shares, + spot_market.insurance_fund.user_shares(), 80_000 * QUOTE_PRECISION ); @@ -896,27 +898,28 @@ pub fn drained_stake_if_test_rebase_on_new_add() { if_balance += amount; // check rebase math - assert_eq!(spot_market.insurance_fund.total_shares, 1000003849400); - assert_eq!(spot_market.insurance_fund.user_shares, 1000003849398); + assert_eq!(spot_market.insurance_fund.total_shares(), 1000003849400); + assert_eq!(spot_market.insurance_fund.user_shares(), 1000003849398); assert_eq!(if_stake.unchecked_if_shares(), 1000003849390); assert_eq!( - if_stake.unchecked_if_shares() < spot_market.insurance_fund.user_shares, + if_stake.unchecked_if_shares() < spot_market.insurance_fund.user_shares(), true ); assert_eq!( - spot_market.insurance_fund.user_shares - if_stake.unchecked_if_shares(), + spot_market.insurance_fund.user_shares() - if_stake.unchecked_if_shares(), 8 ); - assert_eq!(spot_market.insurance_fund.shares_base, 10); - assert_eq!(if_stake.if_base, 10); + assert_eq!(spot_market.insurance_fund.shares_base(), 10); + assert_eq!(if_stake.if_base(), 10); // check orig if stake is good (on add) - assert_eq!(orig_if_stake.if_base, 0); + assert_eq!(orig_if_stake.if_base(), 0); assert_eq!(orig_if_stake.unchecked_if_shares(), 80000000000); let expected_shares_for_amount = - vault_amount_to_if_shares(1, spot_market.insurance_fund.total_shares, if_balance).unwrap(); + vault_amount_to_if_shares(1, spot_market.insurance_fund.total_shares(), if_balance) + .unwrap(); assert_eq!(expected_shares_for_amount, 10); add_insurance_fund_stake( @@ -930,8 +933,8 @@ pub fn drained_stake_if_test_rebase_on_new_add() { ) .unwrap(); - assert_eq!(spot_market.insurance_fund.shares_base, 10); - assert_eq!(orig_if_stake.if_base, 10); + assert_eq!(spot_market.insurance_fund.shares_base(), 10); + assert_eq!(orig_if_stake.if_base(), 10); assert_eq!( orig_if_stake.unchecked_if_shares(), 80000000000 / 10000000000 + expected_shares_for_amount @@ -947,12 +950,12 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all() { let mut if_balance = 0; let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, - total_shares: 100_000 * QUOTE_PRECISION, - user_shares: 80_000 * QUOTE_PRECISION, + total_shares: (100_000 * QUOTE_PRECISION).into(), + user_shares: (80_000 * QUOTE_PRECISION).into(), ..InsuranceFund::default() }, ..SpotMarket::default() @@ -971,9 +974,9 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all() { assert_eq!(if_balance, 0); // right now other users have claim on a zero balance IF... should not give them your money here - assert_eq!(spot_market.insurance_fund.total_shares, 100_000_000_000); + assert_eq!(spot_market.insurance_fund.total_shares(), 100_000_000_000); assert_eq!( - spot_market.insurance_fund.user_shares, + spot_market.insurance_fund.user_shares(), 80_000 * QUOTE_PRECISION ); @@ -998,8 +1001,8 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all() { // check rebase math assert_eq!(amount_returned, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 20000000000); - assert_eq!(spot_market.insurance_fund.user_shares, 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 20000000000); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); // make non-zero if_balance = 1; @@ -1029,9 +1032,9 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all() { ) .unwrap(); - assert_eq!(spot_market.insurance_fund.shares_base, 9); - assert_eq!(spot_market.insurance_fund.total_shares, 200000000000020); - assert_eq!(spot_market.insurance_fund.user_shares, 200000000000000); + assert_eq!(spot_market.insurance_fund.shares_base(), 9); + assert_eq!(spot_market.insurance_fund.total_shares(), 200000000000020); + assert_eq!(spot_market.insurance_fund.user_shares(), 200000000000000); if_balance += 10_000_000_000_000; assert_eq!(if_balance, 10000000000001); } @@ -1041,12 +1044,12 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all_2() { let mut if_balance = 0; let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, - total_shares: 100_930_021_053, - user_shares: 83_021 * QUOTE_PRECISION + 135723, + total_shares: 100_930_021_053.into(), + user_shares: (83_021 * QUOTE_PRECISION + 135723).into(), ..InsuranceFund::default() }, ..SpotMarket::default() @@ -1085,15 +1088,15 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all_2() { // check rebase math assert_eq!(amount_returned, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 60930021053); - assert_eq!(spot_market.insurance_fund.user_shares, 43021135723); - assert_eq!(spot_market.insurance_fund.shares_base, 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 60930021053); + assert_eq!(spot_market.insurance_fund.user_shares(), 43021135723); + assert_eq!(spot_market.insurance_fund.shares_base(), 0); if_balance = QUOTE_PRECISION as u64; let unstake_amt = if_stake.unchecked_if_shares() / 2; assert_eq!(unstake_amt, 20000000000); - assert_eq!(if_stake.last_withdraw_request_shares, 0); + assert_eq!(if_stake.last_withdraw_request_shares(), 0); assert_eq!(if_stake.last_withdraw_request_value, 0); assert_eq!(if_stake.last_withdraw_request_ts, 0); @@ -1108,20 +1111,20 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all_2() { .unwrap(); // rebase occurs in request - assert_eq!(if_stake.last_withdraw_request_shares, unstake_amt / 1000); + assert_eq!(if_stake.last_withdraw_request_shares(), unstake_amt / 1000); // (that rebase occurs when you pass in shares you wanna unstake) :/ assert_eq!(if_stake.unchecked_if_shares(), 40000000); assert_eq!(if_stake.last_withdraw_request_value, 328245); assert_eq!(if_stake.last_withdraw_request_ts, 10); - assert_eq!(spot_market.insurance_fund.total_shares, 60930021); - assert_eq!(spot_market.insurance_fund.user_shares, 43021135); + assert_eq!(spot_market.insurance_fund.total_shares(), 60930021); + assert_eq!(spot_market.insurance_fund.user_shares(), 43021135); - assert_eq!(spot_market.insurance_fund.shares_base, 3); + assert_eq!(spot_market.insurance_fund.shares_base(), 3); let expected_amount_for_shares = if_shares_to_vault_amount( if_stake.unchecked_if_shares() / 2, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), if_balance, ) .unwrap(); @@ -1131,15 +1134,15 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all_2() { ); let user_expected_amount_for_shares_before_double = if_shares_to_vault_amount( - spot_market.insurance_fund.user_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.user_shares(), + spot_market.insurance_fund.total_shares(), if_balance, ) .unwrap(); let protocol_expected_amount_for_shares_before_double = if_shares_to_vault_amount( - spot_market.insurance_fund.total_shares - spot_market.insurance_fund.user_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares() - spot_market.insurance_fund.user_shares(), + spot_market.insurance_fund.total_shares(), if_balance, ) .unwrap(); @@ -1155,15 +1158,15 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all_2() { if_balance *= 2; // double the IF vault before withdraw let protocol_expected_amount_for_shares_after_double = if_shares_to_vault_amount( - spot_market.insurance_fund.total_shares - spot_market.insurance_fund.user_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares() - spot_market.insurance_fund.user_shares(), + spot_market.insurance_fund.total_shares(), if_balance, ) .unwrap(); let user_expected_amount_for_shares_after_double = if_shares_to_vault_amount( - spot_market.insurance_fund.user_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.user_shares(), + spot_market.insurance_fund.total_shares(), if_balance, ) .unwrap(); @@ -1178,22 +1181,22 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all_2() { .unwrap(); let protocol_expected_amount_for_shares_after_user_withdraw = if_shares_to_vault_amount( - spot_market.insurance_fund.total_shares - spot_market.insurance_fund.user_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares() - spot_market.insurance_fund.user_shares(), + spot_market.insurance_fund.total_shares(), if_balance, ) .unwrap(); // check rebase math assert_eq!(if_stake.unchecked_if_shares(), 20000000); - assert_eq!(if_stake.if_base, spot_market.insurance_fund.shares_base); - assert_eq!(if_stake.last_withdraw_request_shares, 0); + assert_eq!(if_stake.if_base(), spot_market.insurance_fund.shares_base()); + assert_eq!(if_stake.last_withdraw_request_shares(), 0); assert_eq!(if_stake.last_withdraw_request_value, 0); assert_eq!(amount_returned, 328245); - assert_eq!(spot_market.insurance_fund.total_shares, 40930021); - assert_eq!(spot_market.insurance_fund.user_shares, 23021135); - assert_eq!(spot_market.insurance_fund.shares_base, 3); + assert_eq!(spot_market.insurance_fund.total_shares(), 40930021); + assert_eq!(spot_market.insurance_fund.user_shares(), 23021135); + assert_eq!(spot_market.insurance_fund.shares_base(), 3); assert_eq!( protocol_expected_amount_for_shares_after_double, @@ -1231,9 +1234,9 @@ pub fn drained_stake_if_test_rebase_on_old_remove_all_2() { .unwrap(); if_balance += 10_000_000_000_000; - assert_eq!(spot_market.insurance_fund.total_shares, 204650145930021); - assert_eq!(spot_market.insurance_fund.user_shares, 204650128021135); - assert_eq!(spot_market.insurance_fund.shares_base, 3); + assert_eq!(spot_market.insurance_fund.total_shares(), 204650145930021); + assert_eq!(spot_market.insurance_fund.user_shares(), 204650128021135); + assert_eq!(spot_market.insurance_fund.shares_base(), 3); assert_eq!(if_balance, 10000002000000); } @@ -1255,8 +1258,8 @@ pub fn multiple_if_stakes_and_rebase() { let amount = (QUOTE_PRECISION * 100_000) as u64; // $100k let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, ..InsuranceFund::default() @@ -1290,8 +1293,8 @@ pub fn multiple_if_stakes_and_rebase() { // if gets drained if_balance = QUOTE_PRECISION as u64; - assert_eq!(if_stake_1.if_base, 0); - assert_eq!(spot_market.insurance_fund.shares_base, 0); + assert_eq!(if_stake_1.if_base(), 0); + assert_eq!(spot_market.insurance_fund.shares_base(), 0); request_remove_insurance_fund_stake( if_stake_1.unchecked_if_shares(), @@ -1302,8 +1305,8 @@ pub fn multiple_if_stakes_and_rebase() { 0, ) .unwrap(); - assert_eq!(if_stake_1.if_base, 4); - assert_eq!(spot_market.insurance_fund.shares_base, 4); + assert_eq!(if_stake_1.if_base(), 4); + assert_eq!(spot_market.insurance_fund.shares_base(), 4); let amount_returned = (remove_insurance_fund_stake( if_balance, @@ -1316,8 +1319,8 @@ pub fn multiple_if_stakes_and_rebase() { assert_eq!(amount_returned, 500000); if_balance -= amount_returned; - assert_eq!(if_stake_2.if_base, 0); - assert_eq!(spot_market.insurance_fund.shares_base, 4); + assert_eq!(if_stake_2.if_base(), 0); + assert_eq!(spot_market.insurance_fund.shares_base(), 4); request_remove_insurance_fund_stake( if_stake_2.unchecked_if_shares(), if_balance, @@ -1327,15 +1330,15 @@ pub fn multiple_if_stakes_and_rebase() { 0, ) .unwrap(); - assert_eq!(if_stake_2.if_base, 4); - assert_eq!(spot_market.insurance_fund.shares_base, 4); + assert_eq!(if_stake_2.if_base(), 4); + assert_eq!(spot_market.insurance_fund.shares_base(), 4); assert_eq!( - if_stake_2.if_base < spot_market.insurance_fund.total_shares, + if_stake_2.if_base() < spot_market.insurance_fund.total_shares(), true ); assert_eq!( if_stake_2.unchecked_if_shares(), - spot_market.insurance_fund.user_shares + spot_market.insurance_fund.user_shares() ); assert_eq!(if_balance, 500000); @@ -1352,8 +1355,8 @@ pub fn multiple_if_stakes_and_rebase() { if_balance -= amount_returned; assert_eq!(if_balance, 1); - assert_eq!(spot_market.insurance_fund.user_shares, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); } #[test] @@ -1374,8 +1377,8 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { let amount = (QUOTE_PRECISION * 100_000) as u64; // $100k let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, ..InsuranceFund::default() @@ -1395,9 +1398,9 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { if_balance -= amount_returned; assert_eq!(amount_returned, (50 * QUOTE_PRECISION) as u64); - assert_eq!(spot_market.insurance_fund.user_shares, 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); assert_eq!( - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), 50 * QUOTE_PRECISION ); @@ -1430,8 +1433,8 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { // if gets drained if_balance = QUOTE_PRECISION as u64; - assert_eq!(if_stake_1.if_base, 0); - assert_eq!(spot_market.insurance_fund.shares_base, 0); + assert_eq!(if_stake_1.if_base(), 0); + assert_eq!(spot_market.insurance_fund.shares_base(), 0); request_remove_insurance_fund_stake( if_stake_1.unchecked_if_shares(), @@ -1442,8 +1445,8 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { 0, ) .unwrap(); - assert_eq!(if_stake_1.if_base, 4); - assert_eq!(spot_market.insurance_fund.shares_base, 4); + assert_eq!(if_stake_1.if_base(), 4); + assert_eq!(spot_market.insurance_fund.shares_base(), 4); let amount_returned = (remove_insurance_fund_stake( if_balance, @@ -1456,8 +1459,8 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { assert_eq!(amount_returned, 499750); if_balance -= amount_returned; - assert_eq!(if_stake_2.if_base, 0); - assert_eq!(spot_market.insurance_fund.shares_base, 4); + assert_eq!(if_stake_2.if_base(), 0); + assert_eq!(spot_market.insurance_fund.shares_base(), 4); request_remove_insurance_fund_stake( if_stake_2.unchecked_if_shares(), if_balance, @@ -1467,22 +1470,22 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { 0, ) .unwrap(); - assert_eq!(if_stake_2.if_base, 4); - assert_eq!(spot_market.insurance_fund.shares_base, 4); + assert_eq!(if_stake_2.if_base(), 4); + assert_eq!(spot_market.insurance_fund.shares_base(), 4); assert_eq!( - if_stake_2.if_base < spot_market.insurance_fund.total_shares, + if_stake_2.if_base() < spot_market.insurance_fund.total_shares(), true ); assert_eq!( if_stake_2.unchecked_if_shares(), - spot_market.insurance_fund.user_shares + spot_market.insurance_fund.user_shares() ); assert_eq!(if_balance, 500250); // withdraw all let amount_returned = admin_remove_insurance_fund_stake( if_balance, - spot_market.insurance_fund.total_shares - spot_market.insurance_fund.user_shares, + spot_market.insurance_fund.total_shares() - spot_market.insurance_fund.user_shares(), &mut spot_market, 1, Pubkey::default(), @@ -1492,8 +1495,8 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { assert_eq!(amount_returned, 499); assert_eq!( - spot_market.insurance_fund.user_shares, - spot_market.insurance_fund.total_shares + spot_market.insurance_fund.user_shares(), + spot_market.insurance_fund.total_shares() ); // half of it back @@ -1512,8 +1515,8 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { if_balance -= amount_returned; assert_eq!(if_balance, 250); - assert_eq!(spot_market.insurance_fund.user_shares, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); let amount_returned = admin_remove_insurance_fund_stake(if_balance, 250, &mut spot_market, 1, Pubkey::default()) @@ -1521,8 +1524,8 @@ pub fn multiple_if_stakes_and_rebase_and_admin_remove() { // if_balance -= amount_returned; assert_eq!(amount_returned, 250); - assert_eq!(spot_market.insurance_fund.user_shares, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); } #[test] @@ -1536,23 +1539,23 @@ fn test_transfer_protocol_owned_stake() { }; let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, ..InsuranceFund::default() }, ..SpotMarket::default() }; - assert_eq!(spot_market.insurance_fund.user_shares, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); - spot_market.insurance_fund.total_shares = 42210407198; // make price != 1 + spot_market.insurance_fund.set_total_shares(42210407198); // make price != 1 // withdraw half let amount_returned = admin_remove_insurance_fund_stake( if_balance, - spot_market.insurance_fund.total_shares / 2, + spot_market.insurance_fund.total_shares() / 2, &mut spot_market, 1, Pubkey::default(), @@ -1561,8 +1564,8 @@ fn test_transfer_protocol_owned_stake() { if_balance -= amount_returned; assert_eq!(amount_returned, 99500000000_u64); - assert_eq!(spot_market.insurance_fund.user_shares, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 21105203599); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 21105203599); let now = 6969696969; @@ -1576,7 +1579,7 @@ fn test_transfer_protocol_owned_stake() { Pubkey::default(), ) .unwrap(); - assert_eq!(0, spot_market.insurance_fund.user_shares); + assert_eq!(0, spot_market.insurance_fund.user_shares()); assert_eq!(transfer_num_0, 0); let transfer_num_1 = transfer_protocol_insurance_fund_stake( @@ -1589,13 +1592,13 @@ fn test_transfer_protocol_owned_stake() { Pubkey::default(), ) .unwrap(); - assert_eq!(1, spot_market.insurance_fund.user_shares); - assert_eq!(21105203599, spot_market.insurance_fund.total_shares); + assert_eq!(1, spot_market.insurance_fund.user_shares()); + assert_eq!(21105203599, spot_market.insurance_fund.total_shares()); assert_eq!(transfer_num_1, 4); assert!(transfer_protocol_insurance_fund_stake( if_balance, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), &mut if_stake_2, &mut user_stats_2, &mut spot_market, @@ -1606,7 +1609,7 @@ fn test_transfer_protocol_owned_stake() { let transfer_num_2 = transfer_protocol_insurance_fund_stake( if_balance, - spot_market.insurance_fund.total_shares - spot_market.insurance_fund.user_shares, + spot_market.insurance_fund.total_shares() - spot_market.insurance_fund.user_shares(), &mut if_stake_2, &mut user_stats_2, &mut spot_market, @@ -1616,8 +1619,8 @@ fn test_transfer_protocol_owned_stake() { .unwrap(); assert_eq!( - spot_market.insurance_fund.total_shares, - spot_market.insurance_fund.user_shares + spot_market.insurance_fund.total_shares(), + spot_market.insurance_fund.user_shares() ); assert_eq!(transfer_num_2, 99499999995); @@ -1631,7 +1634,7 @@ fn test_transfer_protocol_owned_stake() { assert!(transfer_protocol_insurance_fund_stake( if_balance, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), &mut if_stake_2, &mut user_stats_2, &mut spot_market, diff --git a/programs/drift/src/controller/liquidation.rs b/programs/drift/src/controller/liquidation.rs index 4e5543d313..f695366951 100644 --- a/programs/drift/src/controller/liquidation.rs +++ b/programs/drift/src/controller/liquidation.rs @@ -531,10 +531,10 @@ pub fn liquidate_perp( market.amm.order_step_size )?; - market.amm.total_liquidation_fee = market + let tlf = market.amm.total_liquidation_fee(); + market .amm - .total_liquidation_fee - .safe_add(if_fee.unsigned_abs().cast()?)?; + .set_total_liquidation_fee(tlf.safe_add(if_fee.unsigned_abs().cast()?)?); ( user_existing_position_direction, @@ -672,10 +672,10 @@ pub fn liquidate_perp( maker_order_cumulative_quote_asset_amount_filled: Some(base_asset_value), oracle_price, bit_flags: 0, - taker_existing_quote_entry_amount: taker_existing_quote_entry_amount, - taker_existing_base_asset_amount: taker_existing_base_asset_amount, - maker_existing_quote_entry_amount: maker_existing_quote_entry_amount, - maker_existing_base_asset_amount: maker_existing_base_asset_amount, + taker_existing_quote_entry_amount, + taker_existing_base_asset_amount, + maker_existing_quote_entry_amount, + maker_existing_base_asset_amount, trigger_price: None, builder_idx: None, builder_fee: None, @@ -1103,10 +1103,10 @@ pub fn liquidate_perp_with_fill( let user_position = user.get_perp_position_mut(market_index)?; update_quote_asset_and_break_even_amount(user_position, &mut market, if_fee)?; - market.amm.total_liquidation_fee = market - .amm - .total_liquidation_fee - .safe_add(if_fee.unsigned_abs().cast()?)?; + let total_liquidation_fee = market.amm.total_liquidation_fee(); + market.amm.set_total_liquidation_fee( + total_liquidation_fee.safe_add(if_fee.unsigned_abs().cast()?)?, + ); } let (margin_freed_for_perp_position, margin_calculation_after) = calculate_margin_freed( @@ -3427,20 +3427,20 @@ pub fn resolve_perp_bankruptcy( if loss_to_socialize < 0 { let mut market = perp_market_map.get_ref_mut(&market_index)?; - market.amm.total_social_loss = market + let total_social_loss = market.amm.total_social_loss(); + market .amm - .total_social_loss - .safe_add(loss_to_socialize.unsigned_abs())?; + .set_total_social_loss(total_social_loss.safe_add(loss_to_socialize.unsigned_abs())?); - market.amm.cumulative_funding_rate_long = market - .amm - .cumulative_funding_rate_long - .safe_add(cumulative_funding_rate_delta)?; + let cumulative_funding_rate_long = market.amm.cumulative_funding_rate_long(); + market.amm.set_cumulative_funding_rate_long( + cumulative_funding_rate_long.safe_add(cumulative_funding_rate_delta)?, + ); - market.amm.cumulative_funding_rate_short = market - .amm - .cumulative_funding_rate_short - .safe_sub(cumulative_funding_rate_delta)?; + let cumulative_funding_rate_short = market.amm.cumulative_funding_rate_short(); + market.amm.set_cumulative_funding_rate_short( + cumulative_funding_rate_short.safe_sub(cumulative_funding_rate_delta)?, + ); } // clear bad debt @@ -3600,17 +3600,18 @@ pub fn resolve_spot_bankruptcy( None, )?; - spot_market.cumulative_deposit_interest = spot_market - .cumulative_deposit_interest - .safe_sub(cumulative_deposit_interest_delta)?; + let cumulative_deposit_interest = spot_market.cumulative_deposit_interest(); + spot_market.set_cumulative_deposit_interest( + cumulative_deposit_interest.safe_sub(cumulative_deposit_interest_delta)?, + ); - spot_market.total_social_loss = spot_market - .total_social_loss - .safe_add(borrow_amount.cast()?)?; + let total_social_loss = spot_market.total_social_loss(); + spot_market.set_total_social_loss(total_social_loss.safe_add(borrow_amount.cast()?)?); - spot_market.total_quote_social_loss = spot_market - .total_quote_social_loss - .safe_add(quote_social_loss.unsigned_abs().cast()?)?; + let total_quote_social_loss = spot_market.total_quote_social_loss(); + spot_market.set_total_quote_social_loss( + total_quote_social_loss.safe_add(quote_social_loss.unsigned_abs().cast()?)?, + ); } // exit bankruptcy diff --git a/programs/drift/src/controller/liquidation/tests.rs b/programs/drift/src/controller/liquidation/tests.rs index e8cf21acde..27e29eaf48 100644 --- a/programs/drift/src/controller/liquidation/tests.rs +++ b/programs/drift/src/controller/liquidation/tests.rs @@ -55,19 +55,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -86,7 +86,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -182,7 +182,7 @@ pub mod liquidate_perp { ); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 0); + assert_eq!(market_after.amm.total_liquidation_fee(), 0); } #[test] @@ -204,19 +204,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: 3600, @@ -236,7 +236,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -332,7 +332,7 @@ pub mod liquidate_perp { ); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 0); + assert_eq!(market_after.amm.total_liquidation_fee(), 0); } #[test] @@ -354,19 +354,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: 3600, @@ -385,7 +385,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -488,19 +488,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -520,7 +520,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -615,7 +615,7 @@ pub mod liquidate_perp { assert_eq!(liquidator.perp_positions[0].quote_asset_amount, -49500000); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 0) + assert_eq!(market_after.amm.total_liquidation_fee(), 0) } #[test] @@ -637,19 +637,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -669,7 +669,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -794,7 +794,7 @@ pub mod liquidate_perp { assert_eq!(liquidator.perp_positions[0].quote_asset_amount, -178200000); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 1800000) + assert_eq!(market_after.amm.total_liquidation_fee(), 1800000) } #[test] @@ -816,19 +816,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -849,7 +849,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -994,7 +994,7 @@ pub mod liquidate_perp { ); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, QUOTE_PRECISION); + assert_eq!(market_after.amm.total_liquidation_fee(), QUOTE_PRECISION); } #[test] @@ -1016,19 +1016,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -1048,7 +1048,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -1148,19 +1148,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -1180,7 +1180,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -1280,19 +1280,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -1312,7 +1312,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -1402,7 +1402,7 @@ pub mod liquidate_perp { let market_after = perp_market_map.get_ref(&0).unwrap(); assert_eq!( - market_after.amm.total_liquidation_fee, + market_after.amm.total_liquidation_fee(), QUOTE_PRECISION / 100 ); } @@ -1426,19 +1426,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -1458,7 +1458,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -1703,19 +1703,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -1735,7 +1735,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -1840,19 +1840,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -1872,7 +1872,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -1964,19 +1964,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: 3600, @@ -1997,7 +1997,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -2070,7 +2070,7 @@ pub mod liquidate_perp { let market_after = perp_market_map.get_ref(&0).unwrap(); // .5% * 100 * .95 =$0.475 - assert_eq!(market_after.amm.total_liquidation_fee, 475000); + assert_eq!(market_after.amm.total_liquidation_fee(), 475000); } #[test] @@ -2092,19 +2092,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: 3600, @@ -2125,7 +2125,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -2198,7 +2198,7 @@ pub mod liquidate_perp { let market_after = perp_market_map.get_ref(&0).unwrap(); assert!(!user.is_being_liquidated()); - assert_eq!(market_after.amm.total_liquidation_fee, 41787043); + assert_eq!(market_after.amm.total_liquidation_fee(), 41787043); } #[test] @@ -2220,19 +2220,19 @@ pub mod liquidate_perp { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), funding_period: ONE_HOUR, @@ -2254,7 +2254,7 @@ pub mod liquidate_perp { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -2373,7 +2373,7 @@ pub mod liquidate_perp { assert_eq!(liquidator.perp_positions[0].quote_asset_amount, -149250000); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 750000) + assert_eq!(market_after.amm.total_liquidation_fee(), 750000) } } @@ -2431,21 +2431,21 @@ pub mod liquidate_perp_with_fill { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, order_tick_size: 1, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: 0, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: 0.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -2464,7 +2464,7 @@ pub mod liquidate_perp_with_fill { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -2618,7 +2618,7 @@ pub mod liquidate_perp_with_fill { assert_eq!(liquidator.perp_positions[0].quote_asset_amount, 3600); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 360000); + assert_eq!(market_after.amm.total_liquidation_fee(), 360000); } #[test] @@ -2640,21 +2640,21 @@ pub mod liquidate_perp_with_fill { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, order_tick_size: 1, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: 0, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: 0.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -2673,7 +2673,7 @@ pub mod liquidate_perp_with_fill { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -2827,7 +2827,7 @@ pub mod liquidate_perp_with_fill { assert_eq!(liquidator.perp_positions[0].quote_asset_amount, 3600); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 360000); + assert_eq!(market_after.amm.total_liquidation_fee(), 360000); } #[test] @@ -2851,21 +2851,21 @@ pub mod liquidate_perp_with_fill { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, order_tick_size: 1, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: 0, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: 0.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -2879,15 +2879,15 @@ pub mod liquidate_perp_with_fill { ..PerpMarket::default() }; market.amm.max_fill_reserve_fraction = 1; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let perp_market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -2998,7 +2998,7 @@ pub mod liquidate_perp_with_fill { assert_eq!(liquidator.perp_positions[0].quote_asset_amount, 3587); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 358708); + assert_eq!(market_after.amm.total_liquidation_fee(), 358708); } #[test] @@ -3022,21 +3022,21 @@ pub mod liquidate_perp_with_fill { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, order_tick_size: 1, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: 0, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: 0.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -3050,15 +3050,15 @@ pub mod liquidate_perp_with_fill { ..PerpMarket::default() }; market.amm.max_fill_reserve_fraction = 1; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let perp_market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -3169,7 +3169,7 @@ pub mod liquidate_perp_with_fill { assert_eq!(liquidator.perp_positions[0].quote_asset_amount, 3613); let market_after = perp_market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 361300); + assert_eq!(market_after.amm.total_liquidation_fee(), 361300); } } @@ -3226,11 +3226,11 @@ pub mod liquidate_spot { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -3244,15 +3244,15 @@ pub mod liquidate_spot { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -3369,11 +3369,11 @@ pub mod liquidate_spot { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -3387,15 +3387,15 @@ pub mod liquidate_spot { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 1442 / 10000), @@ -3543,11 +3543,11 @@ pub mod liquidate_spot { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -3561,15 +3561,15 @@ pub mod liquidate_spot { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, if_liquidation_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { @@ -3725,7 +3725,7 @@ pub mod liquidate_spot { let market_after = spot_market_map.get_ref(&1).unwrap(); let market_revenue = get_token_amount( - market_after.revenue_pool.scaled_balance, + market_after.revenue_pool.scaled_balance(), &market_after, &SpotBalanceType::Deposit, ) @@ -3734,7 +3734,7 @@ pub mod liquidate_spot { assert_eq!(market_revenue, 593); assert_eq!( liquidator.spot_positions[1].scaled_balance + user.spot_positions[1].scaled_balance - - market_after.revenue_pool.scaled_balance as u64, + - market_after.revenue_pool.scaled_balance() as u64, SPOT_BALANCE_PRECISION_U64 ); } @@ -3762,11 +3762,11 @@ pub mod liquidate_spot { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -3780,15 +3780,15 @@ pub mod liquidate_spot { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -3889,11 +3889,11 @@ pub mod liquidate_spot { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -3907,15 +3907,15 @@ pub mod liquidate_spot { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -4016,11 +4016,11 @@ pub mod liquidate_spot { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -4034,15 +4034,15 @@ pub mod liquidate_spot { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, if_liquidation_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { @@ -4148,11 +4148,11 @@ pub mod liquidate_spot { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -4166,15 +4166,15 @@ pub mod liquidate_spot { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: 10 * SPOT_BALANCE_PRECISION, - borrow_balance: 10 * SPOT_BALANCE_PRECISION, + deposit_balance: (10 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (10 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, if_liquidation_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { @@ -4378,11 +4378,11 @@ pub mod liquidate_spot { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -4396,15 +4396,15 @@ pub mod liquidate_spot { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, if_liquidation_fee: LIQUIDATION_FEE_PRECISION / 20, historical_oracle_data: HistoricalOracleData { @@ -4418,11 +4418,11 @@ pub mod liquidate_spot { let mut usdt_market = SpotMarket { market_index: 2, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -4506,7 +4506,7 @@ pub mod liquidate_spot { let liability_market = spot_market_map.get_ref(&1).unwrap(); let revenue_pool_token_amount = get_token_amount( - liability_market.revenue_pool.scaled_balance, + liability_market.revenue_pool.scaled_balance(), &liability_market, &SpotBalanceType::Deposit, ) @@ -4579,19 +4579,19 @@ pub mod liquidate_borrow_for_perp_pnl { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -4610,11 +4610,11 @@ pub mod liquidate_borrow_for_perp_pnl { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -4628,15 +4628,15 @@ pub mod liquidate_borrow_for_perp_pnl { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -4734,19 +4734,19 @@ pub mod liquidate_borrow_for_perp_pnl { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -4765,11 +4765,11 @@ pub mod liquidate_borrow_for_perp_pnl { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -4783,15 +4783,15 @@ pub mod liquidate_borrow_for_perp_pnl { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, if_liquidation_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { @@ -4906,7 +4906,7 @@ pub mod liquidate_borrow_for_perp_pnl { let market_after = spot_market_map.get_ref(&1).unwrap(); let market_revenue = get_token_amount( - market_after.revenue_pool.scaled_balance, + market_after.revenue_pool.scaled_balance(), &market_after, &SpotBalanceType::Deposit, ) @@ -4934,19 +4934,19 @@ pub mod liquidate_borrow_for_perp_pnl { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -4964,11 +4964,11 @@ pub mod liquidate_borrow_for_perp_pnl { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -4982,15 +4982,15 @@ pub mod liquidate_borrow_for_perp_pnl { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -5088,19 +5088,19 @@ pub mod liquidate_borrow_for_perp_pnl { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -5119,11 +5119,11 @@ pub mod liquidate_borrow_for_perp_pnl { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -5137,15 +5137,15 @@ pub mod liquidate_borrow_for_perp_pnl { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -5235,19 +5235,19 @@ pub mod liquidate_borrow_for_perp_pnl { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -5266,11 +5266,11 @@ pub mod liquidate_borrow_for_perp_pnl { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -5284,15 +5284,15 @@ pub mod liquidate_borrow_for_perp_pnl { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -5382,19 +5382,19 @@ pub mod liquidate_borrow_for_perp_pnl { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -5413,11 +5413,11 @@ pub mod liquidate_borrow_for_perp_pnl { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -5431,15 +5431,15 @@ pub mod liquidate_borrow_for_perp_pnl { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION / 50, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: (SPOT_BALANCE_PRECISION / 50).into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, if_liquidation_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { @@ -5539,19 +5539,19 @@ pub mod liquidate_borrow_for_perp_pnl { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -5570,11 +5570,11 @@ pub mod liquidate_borrow_for_perp_pnl { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -5588,15 +5588,15 @@ pub mod liquidate_borrow_for_perp_pnl { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, - borrow_balance: 11 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (11 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, if_liquidation_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { @@ -5813,19 +5813,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -5844,11 +5844,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -5862,15 +5862,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -5968,19 +5968,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -6000,11 +6000,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -6018,15 +6018,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -6105,7 +6105,7 @@ pub mod liquidate_perp_pnl_for_deposit { assert_eq!(liquidator.perp_positions[0].quote_asset_amount, -25636363); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_liquidation_fee, 0); + assert_eq!(market_after.amm.total_liquidation_fee(), 0); } #[test] @@ -6127,19 +6127,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -6158,11 +6158,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -6176,15 +6176,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -6282,19 +6282,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -6313,11 +6313,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -6331,15 +6331,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -6429,19 +6429,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -6460,11 +6460,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -6478,15 +6478,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -6576,19 +6576,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -6608,11 +6608,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -6626,15 +6626,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -6732,19 +6732,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -6764,11 +6764,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -6782,15 +6782,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -6965,19 +6965,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -6996,11 +6996,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, asset_tier: AssetTier::Collateral, historical_oracle_data: HistoricalOracleData { @@ -7016,15 +7016,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: 10 * SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: (10 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -7197,19 +7197,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -7228,19 +7228,19 @@ pub mod liquidate_perp_pnl_for_deposit { let mut bonk_market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 8000, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 8000.into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: sol_oracle_price_key, ..AMM::default() }, @@ -7266,11 +7266,11 @@ pub mod liquidate_perp_pnl_for_deposit { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -7284,15 +7284,15 @@ pub mod liquidate_perp_pnl_for_deposit { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (sol_oracle_price.agg.price * 99 / 100), @@ -7476,24 +7476,24 @@ pub mod resolve_perp_bankruptcy { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_long: 5 * BASE_PRECISION_I128, - base_asset_amount_short: -5 * BASE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_long: (5 * BASE_PRECISION_I128).into(), + base_asset_amount_short: (-5 * BASE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, - cumulative_funding_rate_long: 1000 * FUNDING_RATE_PRECISION_I128, - cumulative_funding_rate_short: -1000 * FUNDING_RATE_PRECISION_I128, + cumulative_funding_rate_long: (1000 * FUNDING_RATE_PRECISION_I128).into(), + cumulative_funding_rate_short: (-1000 * FUNDING_RATE_PRECISION_I128).into(), ..AMM::default() }, margin_ratio_initial: 1000, @@ -7509,7 +7509,7 @@ pub mod resolve_perp_bankruptcy { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, historical_oracle_data: HistoricalOracleData { @@ -7567,10 +7567,16 @@ pub mod resolve_perp_bankruptcy { expected_user.total_social_loss = 100000000; let mut expected_market = market; - expected_market.amm.cumulative_funding_rate_long = 1010 * FUNDING_RATE_PRECISION_I128; - expected_market.amm.cumulative_funding_rate_short = -1010 * FUNDING_RATE_PRECISION_I128; - expected_market.amm.total_social_loss = 100000000; - expected_market.amm.quote_asset_amount = -50 * QUOTE_PRECISION_I128; + expected_market + .amm + .set_cumulative_funding_rate_long(1010 * FUNDING_RATE_PRECISION_I128); + expected_market + .amm + .set_cumulative_funding_rate_short(-1010 * FUNDING_RATE_PRECISION_I128); + expected_market.amm.set_total_social_loss(100000000); + expected_market + .amm + .set_quote_asset_amount(-50 * QUOTE_PRECISION_I128); expected_market.number_of_users = 0; resolve_perp_bankruptcy( @@ -7686,26 +7692,26 @@ pub mod resolve_perp_bankruptcy { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_long: 5 * BASE_PRECISION_I128, - base_asset_amount_short: -5 * BASE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_long: (5 * BASE_PRECISION_I128).into(), + base_asset_amount_short: (-5 * BASE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, - cumulative_funding_rate_long: 1000 * FUNDING_RATE_PRECISION_I128, - cumulative_funding_rate_short: -1000 * FUNDING_RATE_PRECISION_I128, + cumulative_funding_rate_long: (1000 * FUNDING_RATE_PRECISION_I128).into(), + cumulative_funding_rate_short: (-1000 * FUNDING_RATE_PRECISION_I128).into(), fee_pool: PoolBalance { - scaled_balance: 50 * SPOT_BALANCE_PRECISION, + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -7723,9 +7729,9 @@ pub mod resolve_perp_bankruptcy { let mut spot_market = SpotMarket { market_index: 0, - deposit_balance: 500 * SPOT_BALANCE_PRECISION, + deposit_balance: (500 * SPOT_BALANCE_PRECISION).into(), oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, ..SpotMarket::default() @@ -7778,12 +7784,18 @@ pub mod resolve_perp_bankruptcy { expected_user.total_social_loss = 100000000; let mut expected_market = market; - expected_market.amm.cumulative_funding_rate_long = 1005 * FUNDING_RATE_PRECISION_I128; - expected_market.amm.cumulative_funding_rate_short = -1005 * FUNDING_RATE_PRECISION_I128; - expected_market.amm.total_social_loss = 50000000; - expected_market.amm.quote_asset_amount = -50 * QUOTE_PRECISION_I128; + expected_market + .amm + .set_cumulative_funding_rate_long(1005 * FUNDING_RATE_PRECISION_I128); + expected_market + .amm + .set_cumulative_funding_rate_short(-1005 * FUNDING_RATE_PRECISION_I128); + expected_market.amm.set_total_social_loss(50000000); + expected_market + .amm + .set_quote_asset_amount(-50 * QUOTE_PRECISION_I128); expected_market.number_of_users = 0; - expected_market.amm.fee_pool.scaled_balance = 0; + expected_market.amm.fee_pool.set_scaled_balance(0); resolve_perp_bankruptcy( 0, @@ -7929,24 +7941,24 @@ pub mod resolve_spot_bankruptcy { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: 5 * BASE_PRECISION_I128, - base_asset_amount_short: -5 * BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: (5 * BASE_PRECISION_I128).into(), + base_asset_amount_short: (-5 * BASE_PRECISION_I128).into(), oracle: oracle_price_key, - cumulative_funding_rate_long: 1000 * FUNDING_RATE_PRECISION_I128, - cumulative_funding_rate_short: -1000 * FUNDING_RATE_PRECISION_I128, + cumulative_funding_rate_long: (1000 * FUNDING_RATE_PRECISION_I128).into(), + cumulative_funding_rate_short: (-1000 * FUNDING_RATE_PRECISION_I128).into(), ..AMM::default() }, margin_ratio_initial: 1000, @@ -7961,12 +7973,12 @@ pub mod resolve_spot_bankruptcy { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 1000 * SPOT_BALANCE_PRECISION, - borrow_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (1000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -8015,11 +8027,11 @@ pub mod resolve_spot_bankruptcy { expected_user.total_social_loss = 100000000; let mut expected_spot_market = spot_market; - expected_spot_market.borrow_balance = 0; - expected_spot_market.cumulative_deposit_interest = - 9 * SPOT_CUMULATIVE_INTEREST_PRECISION / 10; - expected_spot_market.total_social_loss = 100 * QUOTE_PRECISION; - expected_spot_market.total_quote_social_loss = 100 * QUOTE_PRECISION; + expected_spot_market.set_borrow_balance(0); + expected_spot_market + .set_cumulative_deposit_interest(9 * SPOT_CUMULATIVE_INTEREST_PRECISION / 10); + expected_spot_market.set_total_social_loss(100 * QUOTE_PRECISION); + expected_spot_market.set_total_quote_social_loss(100 * QUOTE_PRECISION); resolve_spot_bankruptcy( 0, @@ -8039,7 +8051,7 @@ pub mod resolve_spot_bankruptcy { assert_eq!(expected_spot_market, *spot_market_map.get_ref(&0).unwrap()); let spot_market = spot_market_map.get_ref_mut(&0).unwrap(); - let deposit_balance = spot_market.deposit_balance; + let deposit_balance = spot_market.deposit_balance(); let deposit_token_amount = get_token_amount(deposit_balance, &spot_market, &SpotBalanceType::Deposit).unwrap(); @@ -8095,19 +8107,19 @@ pub mod set_user_status_to_being_liquidated { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -8126,7 +8138,7 @@ pub mod set_user_status_to_being_liquidated { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -8272,19 +8284,19 @@ pub mod set_user_status_to_being_liquidated { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -8303,7 +8315,7 @@ pub mod set_user_status_to_being_liquidated { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -8413,11 +8425,11 @@ pub mod liquidate_spot_with_swap { let mut usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 200 * SPOT_BALANCE_PRECISION, + deposit_balance: (200 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: QUOTE_PRECISION_I64, @@ -8431,15 +8443,15 @@ pub mod liquidate_spot_with_swap { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, if_liquidation_fee: LIQUIDATION_FEE_PRECISION / 100, historical_oracle_data: HistoricalOracleData { @@ -8579,7 +8591,7 @@ pub mod liquidate_spot_with_swap { ); let market_revenue = get_token_amount( - sol_spot_market.revenue_pool.scaled_balance, + sol_spot_market.revenue_pool.scaled_balance(), &sol_spot_market, &SpotBalanceType::Deposit, ) diff --git a/programs/drift/src/controller/lp.rs b/programs/drift/src/controller/lp.rs index 9dc8e3b489..5f967dbbc9 100644 --- a/programs/drift/src/controller/lp.rs +++ b/programs/drift/src/controller/lp.rs @@ -40,25 +40,25 @@ pub fn apply_lp_rebase_to_perp_market( let rebase_divisor: i128 = 10_i128.pow(expo_diff.abs().cast()?); if expo_diff > 0 { - perp_market.amm.base_asset_amount_per_lp = perp_market + perp_market.amm.set_base_asset_amount_per_lp(perp_market .amm - .base_asset_amount_per_lp - .safe_mul(rebase_divisor)?; + .base_asset_amount_per_lp() + .safe_mul(rebase_divisor)?); - perp_market.amm.quote_asset_amount_per_lp = perp_market + perp_market.amm.set_quote_asset_amount_per_lp(perp_market .amm - .quote_asset_amount_per_lp - .safe_mul(rebase_divisor)?; + .quote_asset_amount_per_lp() + .safe_mul(rebase_divisor)?); } else { - perp_market.amm.base_asset_amount_per_lp = perp_market + perp_market.amm.set_base_asset_amount_per_lp(perp_market .amm - .base_asset_amount_per_lp - .safe_div(rebase_divisor)?; + .base_asset_amount_per_lp() + .safe_div(rebase_divisor)?); - perp_market.amm.quote_asset_amount_per_lp = perp_market + perp_market.amm.set_quote_asset_amount_per_lp(perp_market .amm - .quote_asset_amount_per_lp - .safe_div(rebase_divisor)?; + .quote_asset_amount_per_lp() + .safe_div(rebase_divisor)?); } msg!( @@ -260,10 +260,10 @@ pub fn burn_lp_shares( let base_asset_amount = position.remainder_base_asset_amount as i128; // user closes the dust - market.amm.base_asset_amount_with_amm = market + market.amm.set_base_asset_amount_with_amm(market .amm - .base_asset_amount_with_amm - .safe_sub(base_asset_amount)?; + .base_asset_amount_with_amm() + .safe_sub(base_asset_amount)?); market.amm.base_asset_amount_with_unsettled_lp = market .amm diff --git a/programs/drift/src/controller/orders.rs b/programs/drift/src/controller/orders.rs index bc8b3aec4c..da3ac1fca0 100644 --- a/programs/drift/src/controller/orders.rs +++ b/programs/drift/src/controller/orders.rs @@ -391,17 +391,17 @@ pub fn place_perp_order( )?; } - let max_oi = market.amm.max_open_interest; + let max_oi = market.amm.max_open_interest(); if max_oi != 0 && risk_increasing { let oi_plus_order = match params.direction { PositionDirection::Long => market .amm - .base_asset_amount_long + .base_asset_amount_long() .safe_add(order_base_asset_amount.cast()?)? .unsigned_abs(), PositionDirection::Short => market .amm - .base_asset_amount_short + .base_asset_amount_short() .safe_sub(order_base_asset_amount.cast()?)? .unsigned_abs(), }; @@ -1349,7 +1349,7 @@ pub fn fill_perp_order( let market = perp_market_map.get_ref(&market_index)?; let open_interest = market.get_open_interest(); - let max_open_interest = market.amm.max_open_interest; + let max_open_interest = market.amm.max_open_interest(); validate!( max_open_interest == 0 || max_open_interest > open_interest, @@ -2294,16 +2294,24 @@ pub fn fulfill_perp_order_with_amm( } // Increment the protocol's total fee variables - market.amm.total_fee = market.amm.total_fee.safe_add(fee_to_market.cast()?)?; - market.amm.total_exchange_fee = market.amm.total_exchange_fee.safe_add(user_fee.cast()?)?; - market.amm.total_mm_fee = market + market .amm - .total_mm_fee - .safe_add(quote_asset_amount_surplus.cast()?)?; - market.amm.total_fee_minus_distributions = market + .set_total_fee(market.amm.total_fee().safe_add(fee_to_market.cast()?)?); + market .amm - .total_fee_minus_distributions - .safe_add(fee_to_market.cast()?)?; + .set_total_exchange_fee(market.amm.total_exchange_fee().safe_add(user_fee.cast()?)?); + market.amm.set_total_mm_fee( + market + .amm + .total_mm_fee() + .safe_add(quote_asset_amount_surplus.cast()?)?, + ); + market.amm.set_total_fee_minus_distributions( + market + .amm + .total_fee_minus_distributions() + .safe_add(fee_to_market.cast()?)?, + ); market.amm.net_revenue_since_last_funding = market .amm .net_revenue_since_last_funding @@ -2807,15 +2815,21 @@ pub fn fulfill_perp_order_with_match( } // Increment the markets house's total fee variables - market.amm.total_fee = market.amm.total_fee.safe_add(fee_to_market.cast()?)?; - market.amm.total_exchange_fee = market - .amm - .total_exchange_fee - .safe_add(fee_to_market.cast()?)?; - market.amm.total_fee_minus_distributions = market + market .amm - .total_fee_minus_distributions - .safe_add(fee_to_market.cast()?)?; + .set_total_fee(market.amm.total_fee().safe_add(fee_to_market.cast()?)?); + market.amm.set_total_exchange_fee( + market + .amm + .total_exchange_fee() + .safe_add(fee_to_market.cast()?)?, + ); + market.amm.set_total_fee_minus_distributions( + market + .amm + .total_fee_minus_distributions() + .safe_add(fee_to_market.cast()?)?, + ); market.amm.net_revenue_since_last_funding = market .amm .net_revenue_since_last_funding @@ -4986,7 +5000,11 @@ pub fn fulfill_spot_order_with_match( } // Update base market - base_market.total_spot_fee = base_market.total_spot_fee.safe_add(fee_to_market.cast()?)?; + base_market.set_total_spot_fee( + base_market + .total_spot_fee() + .safe_add(fee_to_market.cast()?)?, + ); update_spot_balances( fee_to_market.cast()?, @@ -5154,7 +5172,7 @@ pub fn fulfill_spot_order_with_external_market( )?; let fee_pool_amount = get_token_amount( - base_market.spot_fee_pool.scaled_balance, + base_market.spot_fee_pool.scaled_balance(), quote_market, &SpotBalanceType::Deposit, )?; @@ -5275,7 +5293,11 @@ pub fn fulfill_spot_order_with_external_market( )?; } - base_market.total_spot_fee = base_market.total_spot_fee.safe_add(fee_to_market.cast()?)?; + base_market.set_total_spot_fee( + base_market + .total_spot_fee() + .safe_add(fee_to_market.cast()?)?, + ); let fill_record_id = get_then_update_id!(base_market, next_fill_record_id); let order_action_record = get_order_action_record( diff --git a/programs/drift/src/controller/orders/amm_jit_tests.rs b/programs/drift/src/controller/orders/amm_jit_tests.rs index 87c160b78d..2f4e94b867 100644 --- a/programs/drift/src/controller/orders/amm_jit_tests.rs +++ b/programs/drift/src/controller/orders/amm_jit_tests.rs @@ -115,12 +115,12 @@ pub mod amm_jit { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -145,9 +145,9 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.base_asset_reserve = 0; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_base_asset_reserve(0); + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -155,10 +155,18 @@ pub mod amm_jit { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); // shouldnt throw an error when bids/asks are zero crate::math::amm_jit::calculate_jit_base_asset_amount( @@ -191,12 +199,12 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -221,8 +229,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -230,10 +238,18 @@ pub mod amm_jit { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); assert_eq!(new_bid_quote_asset_reserve, 99000000000); create_anchor_account_info!(market, PerpMarket, market_account_info); @@ -242,7 +258,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -373,8 +389,8 @@ pub mod amm_jit { let market_after = market_map.get_ref(&0).unwrap(); // amm jit doesnt take anything assert_eq!( - market_after.amm.base_asset_amount_with_amm, - market.amm.base_asset_amount_with_amm + market_after.amm.base_asset_amount_with_amm(), + market.amm.base_asset_amount_with_amm() ); } @@ -398,16 +414,16 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: -((AMM_RESERVE_PRECISION / 2) as i128), - base_asset_amount_short: -((AMM_RESERVE_PRECISION / 2) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 90 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + base_asset_amount_short: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (90 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -421,8 +437,8 @@ pub mod amm_jit { ..HistoricalOracleData::default() }, - user_lp_shares: 10 * AMM_RESERVE_PRECISION, // some lps exist - concentration_coef: CONCENTRATION_PRECISION + 1, + user_lp_shares: (10 * AMM_RESERVE_PRECISION).into(), // some lps exist + concentration_coef: (CONCENTRATION_PRECISION + 1).into(), ..AMM::default() }, margin_ratio_initial: 1000, @@ -430,8 +446,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -439,7 +455,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -527,11 +543,11 @@ pub mod amm_jit { let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let order_index = 0; let min_auction_duration = 10; @@ -584,12 +600,12 @@ pub mod amm_jit { // nets to zero let market_after = market_map.get_ref(&0).unwrap(); assert_eq!( - market_after.amm.base_asset_amount_with_amm, + market_after.amm.base_asset_amount_with_amm(), BASE_PRECISION_I128 / 2 ); // make sure lps didnt get anything - assert_eq!(market_after.amm.base_asset_amount_per_lp, 0); + assert_eq!(market_after.amm.base_asset_amount_per_lp(), 0); } #[test] @@ -612,16 +628,16 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: -((AMM_RESERVE_PRECISION / 2) as i128), - base_asset_amount_short: -((AMM_RESERVE_PRECISION / 2) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + base_asset_amount_short: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -635,8 +651,8 @@ pub mod amm_jit { ..HistoricalOracleData::default() }, - user_lp_shares: 10 * AMM_RESERVE_PRECISION, // some lps exist - concentration_coef: CONCENTRATION_PRECISION + 1, + user_lp_shares: (10 * AMM_RESERVE_PRECISION).into(), // some lps exist + concentration_coef: (CONCENTRATION_PRECISION + 1).into(), ..AMM::default() }, margin_ratio_initial: 1000, @@ -644,8 +660,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -653,7 +669,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -741,11 +757,11 @@ pub mod amm_jit { let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let order_index = 0; let min_auction_duration = 10; @@ -789,17 +805,17 @@ pub mod amm_jit { let market_after = market_map.get_ref(&0).unwrap(); // nets to zero - assert_eq!(market_after.amm.base_asset_amount_with_amm, 0); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), 0); // make sure lps didnt get anything - assert_eq!(market_after.amm.base_asset_amount_per_lp, 0); + assert_eq!(market_after.amm.base_asset_amount_per_lp(), 0); let maker = makers_and_referrers.get_ref_mut(&maker_key).unwrap(); let maker_position = &maker.perp_positions[0]; // maker got (full - net_baa) assert_eq!( maker_position.base_asset_amount as i128, - -BASE_PRECISION_I128 * 2 - market.amm.base_asset_amount_with_amm + -BASE_PRECISION_I128 * 2 - market.amm.base_asset_amount_with_amm() ); } @@ -823,16 +839,16 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -854,8 +870,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -863,7 +879,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -951,11 +967,11 @@ pub mod amm_jit { let maker_and_referrer_stats = UserStatsMap::load_one(&maker_stats_account_info).unwrap(); let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let order_index = 0; let min_auction_duration = 10; @@ -999,14 +1015,14 @@ pub mod amm_jit { let market_after = market_map.get_ref(&0).unwrap(); // nets to zero - assert_eq!(market_after.amm.base_asset_amount_with_amm, 0); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), 0); let maker = makers_and_referrers.get_ref_mut(&maker_key).unwrap(); let maker_position = &maker.perp_positions[0]; // maker got (full - net_baa) assert_eq!( maker_position.base_asset_amount as i128, - BASE_PRECISION_I128 * taker_mul as i128 - market.amm.base_asset_amount_with_amm + BASE_PRECISION_I128 * taker_mul as i128 - market.amm.base_asset_amount_with_amm() ); } @@ -1030,16 +1046,16 @@ pub mod amm_jit { // amm is short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), // bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, // bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, // ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, // ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: -((AMM_RESERVE_PRECISION / 2) as i128), - base_asset_amount_short: -((AMM_RESERVE_PRECISION / 2) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_amount_with_amm: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + base_asset_amount_short: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -1063,18 +1079,26 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); assert_eq!(new_bid_quote_asset_reserve, 99000000000); @@ -1084,7 +1108,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -1225,7 +1249,7 @@ pub mod amm_jit { assert_eq!(maker_position.open_orders, 0); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, -1000000000); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), -1000000000); } #[test] @@ -1248,15 +1272,15 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), base_spread: 250, long_spread: 125, short_spread: 125, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -1278,8 +1302,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -1287,10 +1311,18 @@ pub mod amm_jit { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -1298,7 +1330,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -1385,11 +1417,11 @@ pub mod amm_jit { let maker_and_referrer_stats = UserStatsMap::load_one(&maker_stats_account_info).unwrap(); let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let order_index = 0; let min_auction_duration = 10; @@ -1436,11 +1468,12 @@ pub mod amm_jit { let market_after = market_map.get_ref(&0).unwrap(); assert!( - market_after.amm.base_asset_amount_with_amm.abs() - < market.amm.base_asset_amount_with_amm.abs() + market_after.amm.base_asset_amount_with_amm().abs() + < market.amm.base_asset_amount_with_amm().abs() ); - let quote_asset_amount_surplus = market_after.amm.total_mm_fee - market.amm.total_mm_fee; + let quote_asset_amount_surplus = + market_after.amm.total_mm_fee() - market.amm.total_mm_fee(); assert!(quote_asset_amount_surplus > 0); } @@ -1464,24 +1497,24 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), base_spread: 250, long_spread: 125, short_spread: 125, max_spread: 20000, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - user_lp_shares: 20 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + user_lp_shares: (20 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, order_tick_size: 1, oracle: oracle_price_key, amm_jit_intensity: 100, - concentration_coef: CONCENTRATION_PRECISION + 1, + concentration_coef: (CONCENTRATION_PRECISION + 1).into(), historical_oracle_data: HistoricalOracleData { last_oracle_price: (100 * PRICE_PRECISION) as i64, last_oracle_price_twap: (100 * PRICE_PRECISION) as i64, @@ -1497,8 +1530,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -1506,10 +1539,18 @@ pub mod amm_jit { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -1517,7 +1558,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -1604,11 +1645,11 @@ pub mod amm_jit { let maker_and_referrer_stats = UserStatsMap::load_one(&maker_stats_account_info).unwrap(); let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let (base_asset_amount, _) = fulfill_perp_order( &mut taker, @@ -1643,7 +1684,8 @@ pub mod amm_jit { assert_eq!(base_asset_amount, 500000000); // 1/2 base (half of otherwise) let market_after = market_map.get_ref(&0).unwrap(); - let quote_asset_amount_surplus = market_after.amm.total_mm_fee - market.amm.total_mm_fee; + let quote_asset_amount_surplus = + market_after.amm.total_mm_fee() - market.amm.total_mm_fee(); assert_eq!(quote_asset_amount_surplus, 0); @@ -1671,16 +1713,16 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: -((AMM_RESERVE_PRECISION / 2) as i128), - base_asset_amount_short: -((AMM_RESERVE_PRECISION / 2) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + base_asset_amount_short: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -1702,8 +1744,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -1711,10 +1753,18 @@ pub mod amm_jit { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -1722,7 +1772,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -1854,8 +1904,8 @@ pub mod amm_jit { // net baa improves let market_after = market_map.get_ref(&0).unwrap(); assert!( - market_after.amm.base_asset_amount_with_amm.abs() - < market.amm.base_asset_amount_with_amm.abs() + market_after.amm.base_asset_amount_with_amm().abs() + < market.amm.base_asset_amount_with_amm().abs() ); } @@ -1879,16 +1929,16 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: -((AMM_RESERVE_PRECISION / 2) as i128), - base_asset_amount_short: -((AMM_RESERVE_PRECISION / 2) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + base_asset_amount_short: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -1910,8 +1960,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -1919,7 +1969,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -2005,11 +2055,11 @@ pub mod amm_jit { let maker_and_referrer_stats = UserStatsMap::load_one(&maker_stats_account_info).unwrap(); let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let order_index = 0; let min_auction_duration = 10; @@ -2059,16 +2109,17 @@ pub mod amm_jit { assert_eq!(maker_position.base_asset_amount, -BASE_PRECISION_I64 / 2); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, -250000000); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), -250000000); let taker_position = &taker.perp_positions[0]; assert_eq!( taker_position.base_asset_amount, - BASE_PRECISION_I64 + market_after.amm.base_asset_amount_with_amm as i64 + BASE_PRECISION_I64 + market_after.amm.base_asset_amount_with_amm() as i64 ); // market pays extra for trade - let quote_asset_amount_surplus = market_after.amm.total_mm_fee - market.amm.total_mm_fee; + let quote_asset_amount_surplus = + market_after.amm.total_mm_fee() - market.amm.total_mm_fee(); assert!(quote_asset_amount_surplus < 0); } @@ -2092,16 +2143,16 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 100, @@ -2123,8 +2174,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2132,7 +2183,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -2218,11 +2269,11 @@ pub mod amm_jit { let maker_and_referrer_stats = UserStatsMap::load_one(&maker_stats_account_info).unwrap(); let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let order_index = 0; let min_auction_duration = 10; @@ -2276,7 +2327,8 @@ pub mod amm_jit { ); // mm gains from trade - let quote_asset_amount_surplus = market_after.amm.total_mm_fee - market.amm.total_mm_fee; + let quote_asset_amount_surplus = + market_after.amm.total_mm_fee() - market.amm.total_mm_fee(); assert!(quote_asset_amount_surplus < 0); } @@ -2302,12 +2354,12 @@ pub mod amm_jit { let reserves = 5 * AMM_RESERVE_PRECISION; let mut market = PerpMarket { amm: AMM { - base_asset_reserve: reserves, - quote_asset_reserve: reserves, - base_asset_amount_with_amm: -(100 * AMM_RESERVE_PRECISION as i128), - base_asset_amount_short: -(100 * AMM_RESERVE_PRECISION as i128), - sqrt_k: reserves, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: reserves.into(), + quote_asset_reserve: reserves.into(), + base_asset_amount_with_amm: (-(100 * AMM_RESERVE_PRECISION as i128)).into(), + base_asset_amount_short: (-(100 * AMM_RESERVE_PRECISION as i128)).into(), + sqrt_k: reserves.into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2332,8 +2384,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -2341,10 +2393,18 @@ pub mod amm_jit { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2352,7 +2412,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -2415,15 +2475,15 @@ pub mod amm_jit { let maker_and_referrer_stats = UserStatsMap::load_one(&maker_stats_account_info).unwrap(); let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let (mut neg, mut pos, mut none) = (false, false, false); let mut prev_mm_fee = 0; - let mut prev_net_baa = market.amm.base_asset_amount_with_amm; + let mut prev_net_baa = market.amm.base_asset_amount_with_amm(); // track scaling let mut prev_qas = 0; let mut has_set_prev_qas = false; @@ -2519,12 +2579,12 @@ pub mod amm_jit { .unwrap(); let market_after = market_map.get_ref(&0).unwrap(); - let quote_asset_amount_surplus = market_after.amm.total_mm_fee - prev_mm_fee; - prev_mm_fee = market_after.amm.total_mm_fee; + let quote_asset_amount_surplus = market_after.amm.total_mm_fee() - prev_mm_fee; + prev_mm_fee = market_after.amm.total_mm_fee(); // imbalance decreases - assert!(market_after.amm.base_asset_amount_with_amm.abs() < prev_net_baa.abs()); - prev_net_baa = market_after.amm.base_asset_amount_with_amm; + assert!(market_after.amm.base_asset_amount_with_amm().abs() < prev_net_baa.abs()); + prev_net_baa = market_after.amm.base_asset_amount_with_amm(); println!( "slot {} auction: {} surplus: {}", @@ -2584,12 +2644,12 @@ pub mod amm_jit { let reserves = 5 * AMM_RESERVE_PRECISION; let mut market = PerpMarket { amm: AMM { - base_asset_reserve: reserves, - quote_asset_reserve: reserves, - base_asset_amount_with_amm: 100 * AMM_RESERVE_PRECISION as i128, - base_asset_amount_long: 100 * AMM_RESERVE_PRECISION as i128, - sqrt_k: reserves, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: reserves.into(), + quote_asset_reserve: reserves.into(), + base_asset_amount_with_amm: (100 * AMM_RESERVE_PRECISION as i128).into(), + base_asset_amount_long: (100 * AMM_RESERVE_PRECISION as i128).into(), + sqrt_k: reserves.into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1, @@ -2615,8 +2675,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -2624,10 +2684,18 @@ pub mod amm_jit { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2635,7 +2703,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -2699,15 +2767,15 @@ pub mod amm_jit { let maker_and_referrer_stats = UserStatsMap::load_one(&maker_stats_account_info).unwrap(); let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); let (mut neg, mut pos, mut none) = (false, false, false); let mut prev_mm_fee = 0; - let mut prev_net_baa = market.amm.base_asset_amount_with_amm; + let mut prev_net_baa = market.amm.base_asset_amount_with_amm(); // track scaling let mut prev_qas = 0; let mut has_set_prev_qas = false; @@ -2818,12 +2886,12 @@ pub mod amm_jit { .unwrap(); let market_after = market_map.get_ref(&0).unwrap(); - let quote_asset_amount_surplus = market_after.amm.total_mm_fee - prev_mm_fee; - prev_mm_fee = market_after.amm.total_mm_fee; + let quote_asset_amount_surplus = market_after.amm.total_mm_fee() - prev_mm_fee; + prev_mm_fee = market_after.amm.total_mm_fee(); // imbalance decreases or remains the same (damm wont always take on positions) - assert!(market_after.amm.base_asset_amount_with_amm.abs() <= prev_net_baa.abs()); - prev_net_baa = market_after.amm.base_asset_amount_with_amm; + assert!(market_after.amm.base_asset_amount_with_amm().abs() <= prev_net_baa.abs()); + prev_net_baa = market_after.amm.base_asset_amount_with_amm(); println!( "slot {} auction: {} surplus: {}", @@ -2881,16 +2949,16 @@ pub mod amm_jit { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128), - base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -2912,8 +2980,8 @@ pub mod amm_jit { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2921,7 +2989,7 @@ pub mod amm_jit { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -3011,11 +3079,11 @@ pub mod amm_jit { let maker_and_referrer_stats = UserStatsMap::load_one(&maker_stats_account_info).unwrap(); let mut filler_stats = UserStats::default(); - assert_eq!(market.amm.total_fee, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee(), 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_mm_fee, 0); - assert_eq!(market.amm.total_fee_withdrawn, 0); + assert_eq!(market.amm.total_mm_fee(), 0); + assert_eq!(market.amm.total_fee_withdrawn(), 0); assert_eq!(taker.perp_positions[0].open_orders, 1); // fulfill with match @@ -3064,7 +3132,7 @@ pub mod amm_jit { assert_eq!(base_asset_amount, 1000000000); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.total_mm_fee, 2033008); // jit occured even tho maker offered full amount - assert_eq!(market_after.amm.total_fee, 2057287); + assert_eq!(market_after.amm.total_mm_fee(), 2033008); // jit occured even tho maker offered full amount + assert_eq!(market_after.amm.total_fee(), 2057287); } } diff --git a/programs/drift/src/controller/orders/fuel_tests.rs b/programs/drift/src/controller/orders/fuel_tests.rs index 24959f9e3b..3b68848065 100644 --- a/programs/drift/src/controller/orders/fuel_tests.rs +++ b/programs/drift/src/controller/orders/fuel_tests.rs @@ -124,12 +124,12 @@ pub mod fuel_scoring { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -157,8 +157,8 @@ pub mod fuel_scoring { fuel_boost_taker: 50, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -166,10 +166,18 @@ pub mod fuel_scoring { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); assert_eq!(new_bid_quote_asset_reserve, 99000000000); create_anchor_account_info!(market, PerpMarket, market_account_info); @@ -178,7 +186,7 @@ pub mod fuel_scoring { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -313,8 +321,8 @@ pub mod fuel_scoring { let market_after = market_map.get_ref(&0).unwrap(); assert_eq!( - market_after.amm.base_asset_amount_with_amm, - market.amm.base_asset_amount_with_amm + market_after.amm.base_asset_amount_with_amm(), + market.amm.base_asset_amount_with_amm() ); assert_ne!(taker.get_perp_position(0).unwrap().base_asset_amount, 0); let maker_after: std::cell::RefMut = @@ -400,12 +408,12 @@ pub mod fuel_scoring { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -433,8 +441,8 @@ pub mod fuel_scoring { fuel_boost_taker: 50, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -442,10 +450,18 @@ pub mod fuel_scoring { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); assert_eq!(new_bid_quote_asset_reserve, 99000000000); create_anchor_account_info!(market, PerpMarket, market_account_info); @@ -454,7 +470,7 @@ pub mod fuel_scoring { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -471,8 +487,8 @@ pub mod fuel_scoring { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION * 2, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION * 4, + cumulative_deposit_interest: (SPOT_CUMULATIVE_INTEREST_PRECISION * 2).into(), + cumulative_borrow_interest: (SPOT_CUMULATIVE_INTEREST_PRECISION * 4).into(), decimals: 9, initial_asset_weight: SPOT_WEIGHT_PRECISION * 8 / 10, maintenance_asset_weight: SPOT_WEIGHT_PRECISION * 9 / 10, @@ -586,8 +602,8 @@ pub mod fuel_scoring { let market_after = market_map.get_ref(&0).unwrap(); assert_eq!( - market_after.amm.base_asset_amount_with_amm, - market.amm.base_asset_amount_with_amm + market_after.amm.base_asset_amount_with_amm(), + market.amm.base_asset_amount_with_amm() ); assert_eq!(taker.get_perp_position(0).unwrap().base_asset_amount, 0); now += 86400; // one day @@ -670,12 +686,12 @@ pub mod fuel_scoring { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -703,8 +719,8 @@ pub mod fuel_scoring { fuel_boost_taker: 50, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) @@ -712,10 +728,18 @@ pub mod fuel_scoring { let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); assert_eq!(new_bid_quote_asset_reserve, 99000000000); create_anchor_account_info!(market, PerpMarket, market_account_info); @@ -724,7 +748,7 @@ pub mod fuel_scoring { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -817,8 +841,8 @@ pub mod fuel_scoring { let market_after = market_map.get_ref(&0).unwrap(); assert_eq!( - market_after.amm.base_asset_amount_with_amm, - market.amm.base_asset_amount_with_amm + market_after.amm.base_asset_amount_with_amm(), + market.amm.base_asset_amount_with_amm() ); assert_eq!(taker.get_perp_position(0).unwrap().base_asset_amount, 0); now += 86400; // one day diff --git a/programs/drift/src/controller/orders/tests.rs b/programs/drift/src/controller/orders/tests.rs index 5a51991cba..46428f1dbf 100644 --- a/programs/drift/src/controller/orders/tests.rs +++ b/programs/drift/src/controller/orders/tests.rs @@ -137,11 +137,11 @@ pub mod fill_order_protected_maker { let mut market = PerpMarket { paused_operations: PerpOperation::AmmFill as u8, amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -165,25 +165,33 @@ pub mod fill_order_protected_maker { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = i128::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(i128::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -571,12 +579,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(maker_stats.maker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(maker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } @@ -696,12 +704,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(maker_stats.maker_volume_30d, 160 * QUOTE_PRECISION_U64); assert!(maker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -32000); - assert_eq!(market.amm.total_fee, 32000); - assert_eq!(market.amm.total_fee_minus_distributions, 32000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -32000); + assert_eq!(market.amm.total_fee(), 32000); + assert_eq!(market.amm.total_fee_minus_distributions(), 32000); assert_eq!(market.amm.net_revenue_since_last_funding, 32000); } @@ -821,12 +829,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(maker_stats.maker_volume_30d, 180 * QUOTE_PRECISION_U64); assert!(maker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -36000); - assert_eq!(market.amm.total_fee, 36000); - assert_eq!(market.amm.total_fee_minus_distributions, 36000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -36000); + assert_eq!(market.amm.total_fee(), 36000); + assert_eq!(market.amm.total_fee_minus_distributions(), 36000); assert_eq!(market.amm.net_revenue_since_last_funding, 36000); } @@ -946,12 +954,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(maker_stats.maker_volume_30d, 140 * QUOTE_PRECISION_U64); assert!(maker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -28000); - assert_eq!(market.amm.total_fee, 28000); - assert_eq!(market.amm.total_fee_minus_distributions, 28000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -28000); + assert_eq!(market.amm.total_fee(), 28000); + assert_eq!(market.amm.total_fee_minus_distributions(), 28000); assert_eq!(market.amm.net_revenue_since_last_funding, 28000); } @@ -1427,10 +1435,10 @@ pub mod fulfill_order_with_maker_order { assert_eq!(maker_position.quote_break_even_amount, 120072000); assert_eq!(maker_stats.maker_volume_30d, 120 * QUOTE_PRECISION_U64); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -48000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -48000); } #[test] @@ -1539,10 +1547,10 @@ pub mod fulfill_order_with_maker_order { assert_eq!(maker_position.quote_break_even_amount, 120072000); assert_eq!(maker_stats.maker_volume_30d, 120 * QUOTE_PRECISION_U64); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -48000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -48000); } #[test] @@ -1666,12 +1674,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(maker_stats.maker_volume_30d, 150 * QUOTE_PRECISION_U64); assert!(maker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -30000); - assert_eq!(market.amm.total_fee, 30000); - assert_eq!(market.amm.total_fee_minus_distributions, 30000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -30000); + assert_eq!(market.amm.total_fee(), 30000); + assert_eq!(market.amm.total_fee_minus_distributions(), 30000); assert_eq!(market.amm.net_revenue_since_last_funding, 30000); } @@ -1788,12 +1796,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(taker_stats.taker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(taker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } @@ -1911,12 +1919,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(taker_stats.taker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(taker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } @@ -1963,16 +1971,16 @@ pub mod fulfill_order_with_maker_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 10) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 10) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -2077,16 +2085,16 @@ pub mod fulfill_order_with_maker_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 10) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 10) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -2314,12 +2322,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(taker_stats.taker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(taker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } @@ -2467,12 +2475,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(taker_stats.taker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(taker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } @@ -2618,12 +2626,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(taker_stats.taker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(taker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } @@ -2770,12 +2778,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(taker_stats.taker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(taker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } @@ -2903,12 +2911,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(taker_stats.taker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(taker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } @@ -3035,12 +3043,12 @@ pub mod fulfill_order_with_maker_order { assert_eq!(taker_stats.taker_volume_30d, 100 * QUOTE_PRECISION_U64); assert!(taker.orders[0].is_available()); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.base_asset_amount_long, BASE_PRECISION_I128); - assert_eq!(market.amm.base_asset_amount_short, -BASE_PRECISION_I128); - assert_eq!(market.amm.quote_asset_amount, -20000); - assert_eq!(market.amm.total_fee, 20000); - assert_eq!(market.amm.total_fee_minus_distributions, 20000); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.base_asset_amount_long(), BASE_PRECISION_I128); + assert_eq!(market.amm.base_asset_amount_short(), -BASE_PRECISION_I128); + assert_eq!(market.amm.quote_asset_amount(), -20000); + assert_eq!(market.amm.total_fee(), 20000); + assert_eq!(market.amm.total_fee_minus_distributions(), 20000); assert_eq!(market.amm.net_revenue_since_last_funding, 20000); } } @@ -3086,14 +3094,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -3115,8 +3123,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let mut state = State { oracle_guard_rails: OracleGuardRails { @@ -3173,14 +3181,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -3201,8 +3209,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = i128::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(i128::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let mut state = State { min_perp_auction_duration: 1, @@ -3242,14 +3250,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -3270,8 +3278,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -3279,7 +3287,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -3443,10 +3451,10 @@ pub mod fulfill_order { assert_eq!(filler.perp_positions[0].quote_asset_amount, 5012); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, 500000000); - assert_eq!(market_after.amm.base_asset_amount_long, 1000000000); - assert_eq!(market_after.amm.base_asset_amount_short, -500000000); - assert_eq!(market_after.amm.quote_asset_amount, -50281374); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), 500000000); + assert_eq!(market_after.amm.base_asset_amount_long(), 1000000000); + assert_eq!(market_after.amm.base_asset_amount_short(), -500000000); + assert_eq!(market_after.amm.quote_asset_amount(), -50281374); let expected_market_fee = ((taker_stats.fees.total_fee_paid - (maker_stats.fees.total_fee_rebate @@ -3455,9 +3463,9 @@ pub mod fulfill_order { + 1; //todo // assert_eq!(expected_market_fee, 35100); - assert_eq!(market_after.amm.total_fee, expected_market_fee); + assert_eq!(market_after.amm.total_fee(), expected_market_fee); assert_eq!( - market_after.amm.total_fee_minus_distributions, + market_after.amm.total_fee_minus_distributions(), expected_market_fee ); assert_eq!( @@ -3488,14 +3496,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -3516,8 +3524,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -3525,7 +3533,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -3705,14 +3713,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100_050 * PEG_PRECISION / 1000, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100_050 * PEG_PRECISION / 1000).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -3733,8 +3741,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -3742,7 +3750,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -3903,19 +3911,19 @@ pub mod fulfill_order { assert_eq!(filler.perp_positions[0].quote_asset_amount, 5013); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, 500000000); - assert_eq!(market_after.amm.base_asset_amount_long, 1000000000); - assert_eq!(market_after.amm.base_asset_amount_short, -500000000); - assert_eq!(market_after.amm.quote_asset_amount, -50306510); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), 500000000); + assert_eq!(market_after.amm.base_asset_amount_long(), 1000000000); + assert_eq!(market_after.amm.base_asset_amount_short(), -500000000); + assert_eq!(market_after.amm.quote_asset_amount(), -50306510); let expected_market_fee = (taker_stats.fees.total_fee_paid - (maker_stats.fees.total_fee_rebate + filler.perp_positions[0].quote_asset_amount as u64)) as i128; assert_eq!(expected_market_fee, 30128); - assert_eq!(market_after.amm.total_fee, expected_market_fee); + assert_eq!(market_after.amm.total_fee(), expected_market_fee); assert_eq!( - market_after.amm.total_fee_minus_distributions, + market_after.amm.total_fee_minus_distributions(), expected_market_fee ); assert_eq!( @@ -3931,14 +3939,14 @@ pub mod fulfill_order { fn fulfill_with_maker_with_auction_incomplete() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 1, order_tick_size: 1, historical_oracle_data: HistoricalOracleData { @@ -3962,7 +3970,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -4117,12 +4125,12 @@ pub mod fulfill_order { assert_eq!(maker_stats.maker_volume_30d, 50 * QUOTE_PRECISION_U64); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, 0); - assert_eq!(market_after.amm.base_asset_amount_long, 500000000); - assert_eq!(market_after.amm.base_asset_amount_short, -500000000); - assert_eq!(market_after.amm.quote_asset_amount, -10000); - assert_eq!(market_after.amm.total_fee, 10000); - assert_eq!(market_after.amm.total_fee_minus_distributions, 10000); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market_after.amm.base_asset_amount_long(), 500000000); + assert_eq!(market_after.amm.base_asset_amount_short(), -500000000); + assert_eq!(market_after.amm.quote_asset_amount(), -10000); + assert_eq!(market_after.amm.total_fee(), 10000); + assert_eq!(market_after.amm.total_fee_minus_distributions(), 10000); assert_eq!(market_after.amm.net_revenue_since_last_funding, 10000); } @@ -4145,14 +4153,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 10, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -4173,8 +4181,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -4182,7 +4190,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -4283,12 +4291,12 @@ pub mod fulfill_order { assert!(taker.orders[0].is_available()); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, 1000000000); - assert_eq!(market_after.amm.base_asset_amount_long, 1000000000); - assert_eq!(market_after.amm.base_asset_amount_short, 0); - assert_eq!(market_after.amm.quote_asset_amount, -104133674); - assert_eq!(market_after.amm.total_fee, 3123572); - assert_eq!(market_after.amm.total_fee_minus_distributions, 3123572); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), 1000000000); + assert_eq!(market_after.amm.base_asset_amount_long(), 1000000000); + assert_eq!(market_after.amm.base_asset_amount_short(), 0); + assert_eq!(market_after.amm.quote_asset_amount(), -104133674); + assert_eq!(market_after.amm.total_fee(), 3123572); + assert_eq!(market_after.amm.total_fee_minus_distributions(), 3123572); assert_eq!(market_after.amm.net_revenue_since_last_funding, 3123572); } @@ -4312,14 +4320,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -4341,8 +4349,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -4350,7 +4358,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -4514,14 +4522,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -4542,8 +4550,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -4551,7 +4559,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -4699,14 +4707,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -4727,8 +4735,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let reserve_price_before = market.amm.reserve_price().unwrap(); let bid_price = market.amm.bid_price(reserve_price_before).unwrap(); @@ -4740,7 +4748,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -4846,12 +4854,12 @@ pub mod fulfill_order { assert_eq!(taker_stats.maker_volume_30d, 3499697); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, -35032000); - assert_eq!(market_after.amm.base_asset_amount_long, 0); - assert_eq!(market_after.amm.base_asset_amount_short, -35032000); - assert_eq!(market_after.amm.quote_asset_amount, 3500868); - assert_eq!(market_after.amm.total_fee, 1105); - assert_eq!(market_after.amm.total_fee_minus_distributions, 1105); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), -35032000); + assert_eq!(market_after.amm.base_asset_amount_long(), 0); + assert_eq!(market_after.amm.base_asset_amount_short(), -35032000); + assert_eq!(market_after.amm.quote_asset_amount(), 3500868); + assert_eq!(market_after.amm.total_fee(), 1105); + assert_eq!(market_after.amm.total_fee_minus_distributions(), 1105); assert_eq!(market_after.amm.net_revenue_since_last_funding, 1105); let market_after = market_map.get_ref(&0).unwrap(); @@ -4879,14 +4887,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -4907,8 +4915,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u64::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u64::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let reserve_price_before = market.amm.reserve_price().unwrap(); let bid_price = market.amm.bid_price(reserve_price_before).unwrap(); @@ -4920,7 +4928,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -5026,12 +5034,12 @@ pub mod fulfill_order { assert_eq!(taker_stats.maker_volume_30d, 3500096); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, 34966000); - assert_eq!(market_after.amm.base_asset_amount_long, 34966000); - assert_eq!(market_after.amm.base_asset_amount_short, 0); - assert_eq!(market_after.amm.quote_asset_amount, -3498924); - assert_eq!(market_after.amm.total_fee, 1100); - assert_eq!(market_after.amm.total_fee_minus_distributions, 1100); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), 34966000); + assert_eq!(market_after.amm.base_asset_amount_long(), 34966000); + assert_eq!(market_after.amm.base_asset_amount_short(), 0); + assert_eq!(market_after.amm.quote_asset_amount(), -3498924); + assert_eq!(market_after.amm.total_fee(), 1100); + assert_eq!(market_after.amm.total_fee_minus_distributions(), 1100); assert_eq!(market_after.amm.net_revenue_since_last_funding, 1100); let market_after = market_map.get_ref(&0).unwrap(); @@ -5067,15 +5075,15 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -5098,8 +5106,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); market.status = MarketStatus::Active; create_anchor_account_info!(market, PerpMarket, market_account_info); @@ -5108,7 +5116,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -5377,14 +5385,14 @@ pub mod fulfill_order { fn fulfill_users_with_multiple_orders_and_markets() { let mut sol_market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 1, order_tick_size: 1, historical_oracle_data: HistoricalOracleData { @@ -5403,14 +5411,14 @@ pub mod fulfill_order { create_anchor_account_info!(sol_market, PerpMarket, sol_market_account_info); let mut btc_market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 20000 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (20000 * PEG_PRECISION).into(), order_step_size: 1, order_tick_size: 1, historical_oracle_data: HistoricalOracleData { @@ -5437,7 +5445,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -5657,12 +5665,12 @@ pub mod fulfill_order { assert_eq!(maker.orders[0], maker_before.orders[0]); let market_after = market_map.get_ref(&0).unwrap(); - assert_eq!(market_after.amm.base_asset_amount_with_amm, 0); - assert_eq!(market_after.amm.base_asset_amount_long, 500000000); - assert_eq!(market_after.amm.base_asset_amount_short, -500000000); - assert_eq!(market_after.amm.quote_asset_amount, -10000); - assert_eq!(market_after.amm.total_fee, 10000); - assert_eq!(market_after.amm.total_fee_minus_distributions, 10000); + assert_eq!(market_after.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market_after.amm.base_asset_amount_long(), 500000000); + assert_eq!(market_after.amm.base_asset_amount_short(), -500000000); + assert_eq!(market_after.amm.quote_asset_amount(), -10000); + assert_eq!(market_after.amm.total_fee(), 10000); + assert_eq!(market_after.amm.total_fee_minus_distributions(), 10000); assert_eq!(market_after.amm.net_revenue_since_last_funding, 10000); assert_eq!(market_after.amm.last_mark_price_twap_ts, 1); @@ -5712,14 +5720,14 @@ pub mod fulfill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -5740,8 +5748,8 @@ pub mod fulfill_order { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -5749,7 +5757,7 @@ pub mod fulfill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -5960,11 +5968,11 @@ pub mod fill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -5988,25 +5996,33 @@ pub mod fill_order { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = i128::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(i128::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -6161,11 +6177,11 @@ pub mod fill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -6189,25 +6205,33 @@ pub mod fill_order { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = i128::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(i128::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -6341,21 +6365,21 @@ pub mod fill_order { fn expire_order() { let mut market = PerpMarket { amm: AMM { - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 10000000, order_tick_size: 1, - max_base_asset_reserve: 200 * AMM_RESERVE_PRECISION, - min_base_asset_reserve: 50 * AMM_RESERVE_PRECISION, + max_base_asset_reserve: (200 * AMM_RESERVE_PRECISION).into(), + min_base_asset_reserve: (50 * AMM_RESERVE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(PRICE_PRECISION_I64), ..AMM::default() }, @@ -6373,7 +6397,7 @@ pub mod fill_order { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, ..SpotMarket::default() @@ -6500,17 +6524,17 @@ pub mod fill_order { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, order_tick_size: 1, oracle: oracle_price_key, - max_open_interest: 100, + max_open_interest: 100.into(), max_spread: 1000, base_spread: 0, long_spread: 0, @@ -6529,25 +6553,33 @@ pub mod fill_order { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = i128::MAX as u128; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(i128::MAX as u128); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -6705,11 +6737,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -6769,8 +6801,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 100000000); assert_eq!(maker_stats.fees.total_fee_rebate, 30000); - assert_eq!(base_market.total_spot_fee, 20000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 20000000); + assert_eq!(base_market.total_spot_fee(), 20000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 20000000); } #[test] @@ -6830,11 +6862,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 161 * SPOT_BALANCE_PRECISION, + deposit_balance: (161 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -6894,8 +6926,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 160000000); assert_eq!(maker_stats.fees.total_fee_rebate, 48000); - assert_eq!(base_market.total_spot_fee, 32000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 32000000); + assert_eq!(base_market.total_spot_fee(), 32000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 32000000); } #[test] @@ -6955,11 +6987,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7019,8 +7051,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 100000000); assert_eq!(maker_stats.fees.total_fee_rebate, 30000); - assert_eq!(base_market.total_spot_fee, 20000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 20000000); + assert_eq!(base_market.total_spot_fee(), 20000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 20000000); } #[test] @@ -7080,11 +7112,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7144,8 +7176,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 70000000); assert_eq!(maker_stats.fees.total_fee_rebate, 21000); - assert_eq!(base_market.total_spot_fee, 14000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 14000000); + assert_eq!(base_market.total_spot_fee(), 14000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 14000000); } #[test] @@ -7205,11 +7237,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7304,11 +7336,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7403,11 +7435,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7502,11 +7534,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7601,11 +7633,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7677,8 +7709,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 100000000); assert_eq!(maker_stats.fees.total_fee_rebate, 30000); - assert_eq!(base_market.total_spot_fee, 20000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 20000000); + assert_eq!(base_market.total_spot_fee(), 20000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 20000000); } #[test] @@ -7738,11 +7770,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7814,8 +7846,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 100000000); assert_eq!(maker_stats.fees.total_fee_rebate, 30000); - assert_eq!(base_market.total_spot_fee, 20000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 20000000); + assert_eq!(base_market.total_spot_fee(), 20000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 20000000); } #[test] @@ -7877,11 +7909,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -7941,8 +7973,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 100000000); assert_eq!(maker_stats.fees.total_fee_rebate, 30000); - assert_eq!(base_market.total_spot_fee, 20000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 20000000); + assert_eq!(base_market.total_spot_fee(), 20000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 20000000); } #[test] @@ -8000,11 +8032,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -8064,8 +8096,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 100000000); assert_eq!(maker_stats.fees.total_fee_rebate, 30000); - assert_eq!(base_market.total_spot_fee, 20000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 20000000); + assert_eq!(base_market.total_spot_fee(), 20000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 20000000); } #[test] @@ -8123,11 +8155,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -8187,8 +8219,8 @@ pub mod fulfill_spot_order_with_match { assert_eq!(maker_stats.maker_volume_30d, 100000000); assert_eq!(maker_stats.fees.total_fee_rebate, 30000); - assert_eq!(base_market.total_spot_fee, 20000); - assert_eq!(base_market.spot_fee_pool.scaled_balance, 20000000); + assert_eq!(base_market.total_spot_fee(), 20000); + assert_eq!(base_market.spot_fee_pool.scaled_balance(), 20000000); } #[test] @@ -8247,11 +8279,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -8344,11 +8376,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: 0, + deposit_balance: 0.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -8441,12 +8473,12 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), deposit_token_twap: SPOT_BALANCE_PRECISION as u64, ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 101 * QUOTE_PRECISION_U64, ..SpotMarket::default_quote_market() @@ -8541,11 +8573,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 0, + deposit_balance: 0.into(), ..SpotMarket::default_quote_market() }; @@ -8638,12 +8670,12 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), deposit_token_twap: SPOT_BALANCE_PRECISION as u64, ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 100 * QUOTE_PRECISION_U64, ..SpotMarket::default_quote_market() }; @@ -8737,12 +8769,12 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), deposit_token_twap: SPOT_BALANCE_PRECISION as u64, ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 0, + deposit_balance: 0.into(), deposit_token_twap: 0, ..SpotMarket::default_quote_market() }; @@ -8836,12 +8868,12 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), deposit_token_twap: SPOT_BALANCE_PRECISION as u64, ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 100 * QUOTE_PRECISION_U64, ..SpotMarket::default_quote_market() }; @@ -8935,11 +8967,11 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: 0, + deposit_balance: 0.into(), ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -9032,12 +9064,12 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), deposit_token_twap: SPOT_BALANCE_PRECISION as u64, ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 101 * QUOTE_PRECISION_U64, ..SpotMarket::default_quote_market() }; @@ -9131,14 +9163,14 @@ pub mod fulfill_spot_order_with_match { }; let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), utilization_twap: SPOT_UTILIZATION_PRECISION as u64, ..SpotMarket::default_base_market() }; let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, - borrow_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (101 * SPOT_BALANCE_PRECISION).into(), utilization_twap: SPOT_UTILIZATION_PRECISION as u64, ..SpotMarket::default_quote_market() }; @@ -9445,7 +9477,7 @@ pub mod fulfill_spot_order { let mut base_market = SpotMarket { market_index: 1, - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(100 * PRICE_PRECISION_I64), ..SpotMarket::default_base_market() @@ -9453,7 +9485,7 @@ pub mod fulfill_spot_order { create_anchor_account_info!(base_market, SpotMarket, base_market_account_info); let mut second_base_market = SpotMarket { market_index: 2, - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), historical_oracle_data: HistoricalOracleData::default_price(100 * PRICE_PRECISION_I64), ..SpotMarket::default_base_market() }; @@ -9464,7 +9496,7 @@ pub mod fulfill_spot_order { ); let mut quote_market = SpotMarket { market_index: 0, - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; create_anchor_account_info!(quote_market, SpotMarket, quote_market_account_info); @@ -9717,7 +9749,7 @@ pub mod fulfill_spot_order { let mut base_market = SpotMarket { market_index: 1, - deposit_balance: 2 * SPOT_BALANCE_PRECISION, + deposit_balance: (2 * SPOT_BALANCE_PRECISION).into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(100 * PRICE_PRECISION_I64), ..SpotMarket::default_base_market() @@ -9725,7 +9757,7 @@ pub mod fulfill_spot_order { create_anchor_account_info!(base_market, SpotMarket, base_market_account_info); let mut quote_market = SpotMarket { market_index: 0, - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; create_anchor_account_info!(quote_market, SpotMarket, quote_market_account_info); @@ -10004,7 +10036,7 @@ pub mod fulfill_spot_order { let mut base_market = SpotMarket { market_index: 1, - deposit_balance: 10 * SPOT_BALANCE_PRECISION, + deposit_balance: (10 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 10 * LAMPORTS_PER_SOL_U64, oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(100 * PRICE_PRECISION_I64), @@ -10013,7 +10045,7 @@ pub mod fulfill_spot_order { create_anchor_account_info!(base_market, SpotMarket, base_market_account_info); let mut quote_market = SpotMarket { market_index: 0, - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; create_anchor_account_info!(quote_market, SpotMarket, quote_market_account_info); @@ -10192,13 +10224,13 @@ pub mod fill_spot_order { let perp_market_map = PerpMarketMap::empty(); let mut base_market = SpotMarket { - deposit_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), historical_oracle_data: HistoricalOracleData::default_price(PRICE_PRECISION_I64), ..SpotMarket::default_base_market() }; create_anchor_account_info!(base_market, SpotMarket, base_market_account_info); let mut quote_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; create_anchor_account_info!(quote_market, SpotMarket, quote_market_account_info); @@ -10374,15 +10406,15 @@ pub mod force_cancel_orders { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), // bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, // bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, // ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, // ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -10406,27 +10438,35 @@ pub mod force_cancel_orders { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - deposit_balance: SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -10436,9 +10476,9 @@ pub mod force_cancel_orders { let mut sol_spot_market = SpotMarket { market_index: 1, - deposit_balance: SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), oracle: oracle_price_key, ..SpotMarket::default_base_market() }; @@ -10668,11 +10708,11 @@ pub mod get_maker_orders_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -10696,25 +10736,33 @@ pub mod get_maker_orders_info { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -10858,11 +10906,11 @@ pub mod get_maker_orders_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -10886,25 +10934,33 @@ pub mod get_maker_orders_info { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -11049,11 +11105,11 @@ pub mod get_maker_orders_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -11077,25 +11133,33 @@ pub mod get_maker_orders_info { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -11226,11 +11290,11 @@ pub mod get_maker_orders_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -11254,25 +11318,33 @@ pub mod get_maker_orders_info { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -11477,11 +11549,11 @@ pub mod get_maker_orders_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -11505,25 +11577,33 @@ pub mod get_maker_orders_info { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -11670,11 +11750,11 @@ pub mod get_maker_orders_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 100, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -11698,25 +11778,33 @@ pub mod get_maker_orders_info { ..PerpMarket::default() }; market.status = MarketStatus::Active; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let (new_ask_base_asset_reserve, new_ask_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Long) .unwrap(); let (new_bid_base_asset_reserve, new_bid_quote_asset_reserve) = crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -11919,7 +12007,7 @@ pub mod get_spot_maker_orders_info { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -11929,7 +12017,7 @@ pub mod get_spot_maker_orders_info { create_anchor_account_info!(spot_market, SpotMarket, spot_market_account_info); let mut base_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), oracle: oracle_price_key, ..SpotMarket::default_base_market() }; @@ -12076,7 +12164,7 @@ pub mod get_spot_maker_orders_info { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -12086,7 +12174,7 @@ pub mod get_spot_maker_orders_info { create_anchor_account_info!(spot_market, SpotMarket, spot_market_account_info); let mut base_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), oracle: oracle_price_key, ..SpotMarket::default_base_market() }; @@ -12235,7 +12323,7 @@ pub mod get_spot_maker_orders_info { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -12245,7 +12333,7 @@ pub mod get_spot_maker_orders_info { create_anchor_account_info!(spot_market, SpotMarket, spot_market_account_info); let mut base_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), oracle: oracle_price_key, ..SpotMarket::default_base_market() }; @@ -12379,7 +12467,7 @@ pub mod get_spot_maker_orders_info { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -12389,7 +12477,7 @@ pub mod get_spot_maker_orders_info { create_anchor_account_info!(spot_market, SpotMarket, spot_market_account_info); let mut base_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), oracle: oracle_price_key, ..SpotMarket::default_base_market() }; @@ -12601,7 +12689,7 @@ pub mod get_spot_maker_orders_info { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -12611,7 +12699,7 @@ pub mod get_spot_maker_orders_info { create_anchor_account_info!(spot_market, SpotMarket, spot_market_account_info); let mut base_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), oracle: oracle_price_key, ..SpotMarket::default_base_market() }; @@ -12762,7 +12850,7 @@ pub mod get_spot_maker_orders_info { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -12772,7 +12860,7 @@ pub mod get_spot_maker_orders_info { create_anchor_account_info!(spot_market, SpotMarket, spot_market_account_info); let mut base_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), oracle: oracle_price_key, ..SpotMarket::default_base_market() }; diff --git a/programs/drift/src/controller/pnl.rs b/programs/drift/src/controller/pnl.rs index 98add9fa67..ba85a8a489 100644 --- a/programs/drift/src/controller/pnl.rs +++ b/programs/drift/src/controller/pnl.rs @@ -68,8 +68,8 @@ pub fn settle_pnl( update_spot_market_cumulative_interest(spot_market, None, now)?; tvl_before = spot_market.get_tvl()?; - deposits_balance_before = spot_market.deposit_balance; - borrows_balance_before = spot_market.borrow_balance; + deposits_balance_before = spot_market.deposit_balance(); + borrows_balance_before = spot_market.borrow_balance(); } let mut market = perp_market_map.get_ref_mut(&market_index)?; @@ -220,13 +220,13 @@ pub fn settle_pnl( } let pnl_pool_token_amount = get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), spot_market, perp_market.pnl_pool.balance_type(), )?; let fraction_of_fee_pool_token_amount = get_token_amount( - perp_market.amm.fee_pool.scaled_balance, + perp_market.amm.fee_pool.scaled_balance(), spot_market, perp_market.amm.fee_pool.balance_type(), )? @@ -256,8 +256,8 @@ pub fn settle_pnl( )?; // if the spot market balance has changed, we have to fail if we are in try settle mode - if (spot_market.deposit_balance != deposits_balance_before - || spot_market.borrow_balance != borrows_balance_before) + if (spot_market.deposit_balance() != deposits_balance_before + || spot_market.borrow_balance() != borrows_balance_before) && mode == SettlePnlMode::TrySettle { msg!("Spot market balance has changed, switch to MUST_SETTLE mode"); @@ -554,10 +554,10 @@ pub fn settle_expired_position( update_settled_pnl(user, position_index, pnl_to_settle_with_user.cast()?)?; - perp_market.amm.base_asset_amount_with_amm = perp_market - .amm - .base_asset_amount_with_amm - .safe_add(position_delta.base_asset_amount.cast()?)?; + let base_asset_amount_with_amm = perp_market.amm.base_asset_amount_with_amm(); + perp_market.amm.set_base_asset_amount_with_amm( + base_asset_amount_with_amm.safe_add(position_delta.base_asset_amount.cast()?)?, + ); let quote_asset_amount_after = user.perp_positions[position_index].quote_asset_amount; diff --git a/programs/drift/src/controller/pnl/delisting.rs b/programs/drift/src/controller/pnl/delisting.rs index db148230f0..b33b7d02d3 100644 --- a/programs/drift/src/controller/pnl/delisting.rs +++ b/programs/drift/src/controller/pnl/delisting.rs @@ -78,16 +78,16 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -100,8 +100,8 @@ pub mod delisting_test { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -109,7 +109,7 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, ..SpotMarket::default() @@ -192,16 +192,16 @@ pub mod delisting_test { // net users are long let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -212,7 +212,7 @@ pub mod delisting_test { last_oracle_price_twap_5min: (99 * PRICE_PRECISION) as i64, ..HistoricalOracleData::default() }, - quote_asset_amount: -(QUOTE_PRECISION_I128 * 50), //longs have $100 cost basis + quote_asset_amount: (-(QUOTE_PRECISION_I128 * 50)).into(), //longs have $100 cost basis ..AMM::default() }, margin_ratio_initial: 1000, @@ -222,8 +222,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -231,7 +231,7 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, ..SpotMarket::default() @@ -302,16 +302,16 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -322,7 +322,7 @@ pub mod delisting_test { last_oracle_price_twap_5min: (99 * PRICE_PRECISION) as i64, ..HistoricalOracleData::default() }, - quote_asset_amount: -(QUOTE_PRECISION_I128 * 10), //longs have $20 cost basis + quote_asset_amount: (-(QUOTE_PRECISION_I128 * 10)).into(), //longs have $20 cost basis ..AMM::default() }, margin_ratio_initial: 1000, @@ -332,8 +332,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -341,7 +341,7 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, ..SpotMarket::default() @@ -415,16 +415,16 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -435,8 +435,8 @@ pub mod delisting_test { last_oracle_price_twap_5min: (99 * PRICE_PRECISION) as i64, ..HistoricalOracleData::default() }, - total_fee_minus_distributions: -(100000 * QUOTE_PRECISION_I128), // down $100k - quote_asset_amount: -(QUOTE_PRECISION_I128 * 10), //longs have $20 cost basis + total_fee_minus_distributions: (-(100000 * QUOTE_PRECISION_I128)).into(), // down $100k + quote_asset_amount: (-(QUOTE_PRECISION_I128 * 10)).into(), //longs have $20 cost basis ..AMM::default() }, margin_ratio_initial: 1000, @@ -446,8 +446,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -455,7 +455,7 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, ..SpotMarket::default() @@ -529,16 +529,16 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: -((AMM_RESERVE_PRECISION / 2) as i128), - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: (-((AMM_RESERVE_PRECISION / 2) as i128)).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -549,8 +549,8 @@ pub mod delisting_test { last_oracle_price_twap_5min: (99 * PRICE_PRECISION) as i64, ..HistoricalOracleData::default() }, - total_fee_minus_distributions: -(100000 * QUOTE_PRECISION_I128), // down $100k - quote_asset_amount: (QUOTE_PRECISION_I128 * 10), //shorts have $20 cost basis + total_fee_minus_distributions: (-(100000 * QUOTE_PRECISION_I128)).into(), // down $100k + quote_asset_amount: (QUOTE_PRECISION_I128 * 10).into(), //shorts have $20 cost basis ..AMM::default() }, margin_ratio_initial: 1000, @@ -560,8 +560,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -569,7 +569,7 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, ..SpotMarket::default() @@ -639,16 +639,16 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -659,8 +659,8 @@ pub mod delisting_test { last_oracle_price_twap_5min: (99 * PRICE_PRECISION) as i64, ..HistoricalOracleData::default() }, - quote_asset_amount: -(QUOTE_PRECISION_I128 * 10), //longs have $20 cost basis - total_fee_minus_distributions: 0, + quote_asset_amount: (-(QUOTE_PRECISION_I128 * 10)).into(), //longs have $20 cost basis + total_fee_minus_distributions: 0.into(), ..AMM::default() }, number_of_users_with_base: 1, @@ -669,7 +669,7 @@ pub mod delisting_test { margin_ratio_maintenance: 500, status: MarketStatus::Initialized, pnl_pool: PoolBalance { - scaled_balance: (1000 * SPOT_BALANCE_PRECISION), + scaled_balance: (1000 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -677,8 +677,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -686,14 +686,14 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, - borrow_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -801,7 +801,7 @@ pub mod delisting_test { assert_eq!(margin_requirement, 10000); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 1000000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 1000000000000); assert_eq!(taker.spot_positions[0].scaled_balance, 100000000000); assert_eq!(taker.perp_positions[0].quote_asset_amount, -10000000); drop(market); @@ -822,7 +822,7 @@ pub mod delisting_test { assert_eq!(taker.spot_positions[0].scaled_balance, 139450500000); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 960549500000); + assert_eq!(market.pnl_pool.scaled_balance(), 960549500000); drop(market); assert_eq!(taker.perp_positions[0].open_orders, 0); @@ -858,16 +858,16 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 2) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 2) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 2) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -879,8 +879,8 @@ pub mod delisting_test { ..HistoricalOracleData::default() }, - quote_asset_amount: (QUOTE_PRECISION_I128 * 10), //longs have -$20 cost basis - total_fee_minus_distributions: 0, + quote_asset_amount: (QUOTE_PRECISION_I128 * 10).into(), //longs have -$20 cost basis + total_fee_minus_distributions: 0.into(), ..AMM::default() }, number_of_users_with_base: 1, @@ -889,7 +889,7 @@ pub mod delisting_test { margin_ratio_maintenance: 500, status: MarketStatus::Initialized, pnl_pool: PoolBalance { - scaled_balance: (1000 * SPOT_BALANCE_PRECISION), + scaled_balance: (1000 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -897,8 +897,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -906,14 +906,14 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, - borrow_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1021,7 +1021,7 @@ pub mod delisting_test { assert_eq!(margin_requirement, 10000); // settlement in margin now let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 1000000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 1000000000000); assert_eq!(taker.spot_positions[0].scaled_balance, 100000000000); assert_eq!(taker.perp_positions[0].quote_asset_amount, 10000000); drop(market); @@ -1042,7 +1042,7 @@ pub mod delisting_test { assert_eq!(taker.spot_positions[0].scaled_balance, 159450500000); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 940549500000); + assert_eq!(market.pnl_pool.scaled_balance(), 940549500000); drop(market); assert_eq!(taker.perp_positions[0].open_orders, 0); @@ -1081,16 +1081,16 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION * 2000) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION * 2000) as i128, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION * 2000) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION * 2000) as i128).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -1102,8 +1102,8 @@ pub mod delisting_test { ..HistoricalOracleData::default() }, - quote_asset_amount: (QUOTE_PRECISION_I128 * 20 * 2000), //longs have -$20 cost basis - total_fee_minus_distributions: 0, + quote_asset_amount: (QUOTE_PRECISION_I128 * 20 * 2000).into(), //longs have -$20 cost basis + total_fee_minus_distributions: 0.into(), ..AMM::default() }, number_of_users_with_base: 1, @@ -1112,7 +1112,7 @@ pub mod delisting_test { margin_ratio_maintenance: 500, status: MarketStatus::Initialized, pnl_pool: PoolBalance { - scaled_balance: (1000 * SPOT_BALANCE_PRECISION), + scaled_balance: (1000 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1120,8 +1120,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -1129,14 +1129,14 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, - borrow_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1228,7 +1228,7 @@ pub mod delisting_test { assert_eq!(margin_requirement, 10000); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 1000000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 1000000000000); assert_eq!(taker.spot_positions[0].scaled_balance, 100000000000); assert_eq!(taker.perp_positions[0].quote_asset_amount, 40000000000); drop(market); @@ -1248,8 +1248,8 @@ pub mod delisting_test { assert_eq!(taker.spot_positions[0].scaled_balance > 100000000000, true); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 39002002000); // no settle fee since base_asse_value=0 (since price is negative) - assert_eq!(market.amm.fee_pool.scaled_balance, 0); + assert_eq!(market.pnl_pool.scaled_balance(), 39002002000); // no settle fee since base_asse_value=0 (since price is negative) + assert_eq!(market.amm.fee_pool.scaled_balance(), 0); drop(market); assert_eq!(taker.perp_positions[0].open_orders, 0); @@ -1285,17 +1285,17 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION * 1000) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION * 2000) as i128, - base_asset_amount_short: -((AMM_RESERVE_PRECISION * 1000) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION * 1000) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION * 2000) as i128).into(), + base_asset_amount_short: (-((AMM_RESERVE_PRECISION * 1000) as i128)).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -1307,8 +1307,9 @@ pub mod delisting_test { ..HistoricalOracleData::default() }, - quote_asset_amount: -(QUOTE_PRECISION_I128 * 20 * 1000 - QUOTE_PRECISION_I128), - total_fee_minus_distributions: 0, + quote_asset_amount: (-(QUOTE_PRECISION_I128 * 20 * 1000 - QUOTE_PRECISION_I128)) + .into(), + total_fee_minus_distributions: 0.into(), ..AMM::default() }, number_of_users_with_base: 2, @@ -1317,7 +1318,7 @@ pub mod delisting_test { margin_ratio_maintenance: 500, status: MarketStatus::Initialized, pnl_pool: PoolBalance { - scaled_balance: (1000 * SPOT_BALANCE_PRECISION), + scaled_balance: (1000 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1325,8 +1326,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -1334,14 +1335,14 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 300000 * SPOT_BALANCE_PRECISION, - borrow_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (300000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1350,15 +1351,15 @@ pub mod delisting_test { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (oracle_price.agg.price * 99 / 100), @@ -1532,7 +1533,7 @@ pub mod delisting_test { .unwrap(); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 1000000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 1000000000000); let orig_short_balance = shorter.spot_positions[0].scaled_balance; @@ -1582,8 +1583,8 @@ pub mod delisting_test { assert_eq!(shorter_loss, 1019997999000); //$1020 loss let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 2019997999000); //$2020 - assert_eq!(market.amm.fee_pool.scaled_balance, 0); + assert_eq!(market.pnl_pool.scaled_balance(), 2019997999000); //$2020 + assert_eq!(market.amm.fee_pool.scaled_balance(), 0); drop(market); assert_eq!(shorter.perp_positions[0].open_orders, 0); @@ -1610,7 +1611,7 @@ pub mod delisting_test { assert_eq!(margin_requirement, 10000); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 2019997999000); + assert_eq!(market.pnl_pool.scaled_balance(), 2019997999000); assert_eq!(longer.spot_positions[0].scaled_balance, 20000000000000); assert_eq!(longer.perp_positions[0].quote_asset_amount, -40001000000); drop(market); @@ -1631,8 +1632,8 @@ pub mod delisting_test { assert_eq!(longer.spot_positions[0].scaled_balance, 21955000002000); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 64997997000); //fee from settling - assert_eq!(market.amm.fee_pool.scaled_balance, 0); + assert_eq!(market.pnl_pool.scaled_balance(), 64997997000); //fee from settling + assert_eq!(market.amm.fee_pool.scaled_balance(), 0); drop(market); assert_eq!(longer.perp_positions[0].open_orders, 0); @@ -1651,7 +1652,7 @@ pub mod delisting_test { let market = market_map.get_ref_mut(&0).unwrap(); assert_eq!(market.number_of_users_with_base, 0); - assert_eq!(market.amm.quote_asset_amount, 2000000); + assert_eq!(market.amm.quote_asset_amount(), 2000000); drop(market); settle_expired_position( 0, @@ -1675,12 +1676,12 @@ pub mod delisting_test { assert_eq!(liq.spot_positions[0].scaled_balance > 0, true); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), 0); assert_eq!(market.number_of_users_with_base, 0); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.quote_asset_amount, 0); - assert_eq!(market.amm.total_social_loss, 0); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.quote_asset_amount(), 0); + assert_eq!(market.amm.total_social_loss(), 0); drop(market); } @@ -1710,17 +1711,17 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: -((AMM_RESERVE_PRECISION * 800) as i128), - base_asset_amount_long: (AMM_RESERVE_PRECISION * 200) as i128, - base_asset_amount_short: -((AMM_RESERVE_PRECISION * 1000) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: (-((AMM_RESERVE_PRECISION * 800) as i128)).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION * 200) as i128).into(), + base_asset_amount_short: (-((AMM_RESERVE_PRECISION * 1000) as i128)).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -1732,9 +1733,10 @@ pub mod delisting_test { ..HistoricalOracleData::default() }, - quote_asset_amount: (QUOTE_PRECISION_I128 * 200) - + (QUOTE_PRECISION_I128 * 97 * 1000), - total_fee_minus_distributions: 0, + quote_asset_amount: ((QUOTE_PRECISION_I128 * 200) + + (QUOTE_PRECISION_I128 * 97 * 1000)) + .into(), + total_fee_minus_distributions: 0.into(), ..AMM::default() }, number_of_users_with_base: 2, @@ -1742,7 +1744,7 @@ pub mod delisting_test { margin_ratio_maintenance: 500, status: MarketStatus::Initialized, pnl_pool: PoolBalance { - scaled_balance: (1000 * SPOT_BALANCE_PRECISION), + scaled_balance: (1000 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1750,8 +1752,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -1759,15 +1761,15 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, - borrow_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1776,15 +1778,15 @@ pub mod delisting_test { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (oracle_price.agg.price * 99 / 100), @@ -1960,7 +1962,7 @@ pub mod delisting_test { assert_eq!(margin_requirement, 10000); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 1000000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 1000000000000); assert_eq!(longer.spot_positions[0].scaled_balance, 20000000000000); assert_eq!(longer.perp_positions[0].quote_asset_amount, 2000000000); let longer_balance_before = longer.spot_positions[0].scaled_balance; @@ -1988,8 +1990,8 @@ pub mod delisting_test { ); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 1000000000000); - assert_eq!(market.amm.fee_pool.scaled_balance, 0); + assert_eq!(market.pnl_pool.scaled_balance(), 1000000000000); + assert_eq!(market.amm.fee_pool.scaled_balance(), 0); drop(market); } @@ -2094,17 +2096,17 @@ pub mod delisting_test { // net users are short let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - base_asset_amount_with_amm: -((AMM_RESERVE_PRECISION * 800) as i128), - base_asset_amount_long: (AMM_RESERVE_PRECISION * 200) as i128, - base_asset_amount_short: -((AMM_RESERVE_PRECISION * 1000) as i128), - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + base_asset_amount_with_amm: (-((AMM_RESERVE_PRECISION * 800) as i128)).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION * 200) as i128).into(), + base_asset_amount_short: (-((AMM_RESERVE_PRECISION * 1000) as i128)).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -2116,8 +2118,8 @@ pub mod delisting_test { ..HistoricalOracleData::default() }, - quote_asset_amount: QUOTE_PRECISION_I128 * (97 * 1000 + 200), - total_fee_minus_distributions: 0, + quote_asset_amount: (QUOTE_PRECISION_I128 * (97 * 1000 + 200)).into(), + total_fee_minus_distributions: 0.into(), ..AMM::default() }, number_of_users_with_base: 2, @@ -2126,7 +2128,7 @@ pub mod delisting_test { margin_ratio_maintenance: 500, status: MarketStatus::Initialized, pnl_pool: PoolBalance { - scaled_balance: (1000 * SPOT_BALANCE_PRECISION), + scaled_balance: (1000 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -2134,8 +2136,8 @@ pub mod delisting_test { ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2143,15 +2145,15 @@ pub mod delisting_test { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 40000 * SPOT_BALANCE_PRECISION, - borrow_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (40000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -2160,15 +2162,15 @@ pub mod delisting_test { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (oracle_price.agg.price * 99 / 100), @@ -2338,7 +2340,7 @@ pub mod delisting_test { .unwrap(); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 1000000000000); + assert_eq!(market.pnl_pool.scaled_balance(), 1000000000000); let orig_short_balance = shorter.spot_positions[0].scaled_balance; @@ -2386,10 +2388,10 @@ pub mod delisting_test { assert_eq!(longer.perp_positions[0].quote_asset_amount, 200000000); assert_eq!( - market.amm.base_asset_amount_long + market.amm.base_asset_amount_short, + market.amm.base_asset_amount_long() + market.amm.base_asset_amount_short(), -800000000000 ); - assert_eq!(market.amm.quote_asset_amount, 97200000000); + assert_eq!(market.amm.quote_asset_amount(), 97200000000); drop(market); @@ -2456,17 +2458,17 @@ pub mod delisting_test { assert_eq!(longer.perp_positions[0].quote_asset_amount, 200000000); assert_eq!( - market.amm.base_asset_amount_long + market.amm.base_asset_amount_short, + market.amm.base_asset_amount_long() + market.amm.base_asset_amount_short(), -800000000000 ); - assert_eq!(market.amm.quote_asset_amount, 97200000000); + assert_eq!(market.amm.quote_asset_amount(), 97200000000); assert_eq!(shorter.perp_positions[0].base_asset_amount, 0); assert_eq!(shorter.perp_positions[0].quote_asset_amount, -23250001000); assert_eq!( liquidator.perp_positions[0].base_asset_amount as i128, - market.amm.base_asset_amount_short + market.amm.base_asset_amount_short() ); assert_eq!( liquidator.perp_positions[0].quote_asset_amount, @@ -2476,10 +2478,10 @@ pub mod delisting_test { assert_eq!( longer.perp_positions[0].base_asset_amount as i128, - market.amm.base_asset_amount_long + market.amm.base_asset_amount_long() ); - assert_eq!(market.amm.quote_asset_amount, 97200000000); + assert_eq!(market.amm.quote_asset_amount(), 97200000000); drop(market); } @@ -2511,10 +2513,10 @@ pub mod delisting_test { let mut market = market_map.get_ref_mut(&0).unwrap(); let oracle_price_data = oracle_map.get_price_data(&market.oracle_id()).unwrap(); - assert_eq!(market.amm.quote_asset_amount, 97200000000); + assert_eq!(market.amm.quote_asset_amount(), 97200000000); - assert_eq!(market.amm.cumulative_funding_rate_long, 0); - assert_eq!(market.amm.cumulative_funding_rate_short, 0); + assert_eq!(market.amm.cumulative_funding_rate_long(), 0); + assert_eq!(market.amm.cumulative_funding_rate_short(), 0); let strict_quote_price = StrictOraclePrice::test(QUOTE_PRECISION_I64); let (perp_margin_requirement, weighted_pnl, _, _, _) = @@ -2544,17 +2546,17 @@ pub mod delisting_test { assert_eq!(longer.perp_positions[0].quote_asset_amount, 200000000); assert_eq!( - market.amm.base_asset_amount_long + market.amm.base_asset_amount_short, + market.amm.base_asset_amount_long() + market.amm.base_asset_amount_short(), -800000000000 ); - assert_eq!(market.amm.quote_asset_amount, 97200000000); + assert_eq!(market.amm.quote_asset_amount(), 97200000000); assert_eq!(shorter.perp_positions[0].base_asset_amount, 0); assert_eq!(shorter.perp_positions[0].quote_asset_amount, -23249001000); assert_eq!( liquidator.perp_positions[0].base_asset_amount as i128, - market.amm.base_asset_amount_short + market.amm.base_asset_amount_short() ); assert_eq!( @@ -2564,11 +2566,11 @@ pub mod delisting_test { assert_eq!( longer.perp_positions[0].base_asset_amount as i128, - market.amm.base_asset_amount_long + market.amm.base_asset_amount_long() ); assert_eq!(longer.perp_positions[0].quote_asset_amount, 200000000); - assert_eq!(market.amm.quote_asset_amount, 201000000 + 96999000000); + assert_eq!(market.amm.quote_asset_amount(), 201000000 + 96999000000); // add a liq fee now market.liquidator_fee = 10000; @@ -2603,10 +2605,10 @@ pub mod delisting_test { let market = market_map.get_ref_mut(&0).unwrap(); let oracle_price_data = oracle_map.get_price_data(&market.oracle_id()).unwrap(); - assert_eq!(market.amm.quote_asset_amount, 20000010000 + 77199990000); + assert_eq!(market.amm.quote_asset_amount(), 20000010000 + 77199990000); - assert_eq!(market.amm.cumulative_funding_rate_long, 0); - assert_eq!(market.amm.cumulative_funding_rate_short, 0); + assert_eq!(market.amm.cumulative_funding_rate_long(), 0); + assert_eq!(market.amm.cumulative_funding_rate_short(), 0); let strict_quote_price = StrictOraclePrice::test(QUOTE_PRECISION_I64); let (perp_margin_requirement, weighted_pnl, _, _, _) = @@ -2636,17 +2638,17 @@ pub mod delisting_test { assert_eq!(longer.perp_positions[0].quote_asset_amount, 200000000); assert_eq!( - market.amm.base_asset_amount_long + market.amm.base_asset_amount_short, + market.amm.base_asset_amount_long() + market.amm.base_asset_amount_short(), -800000000000 ); - assert_eq!(market.amm.quote_asset_amount, 97200000000); + assert_eq!(market.amm.quote_asset_amount(), 97200000000); assert_eq!(shorter.perp_positions[0].base_asset_amount, 0); assert_eq!(shorter.perp_positions[0].quote_asset_amount, -3449991000); assert_eq!( liquidator.perp_positions[0].base_asset_amount as i128, - market.amm.base_asset_amount_short + market.amm.base_asset_amount_short() ); assert_eq!( liquidator.perp_positions[0].quote_asset_amount, @@ -2655,12 +2657,12 @@ pub mod delisting_test { assert_eq!( longer.perp_positions[0].base_asset_amount as i128, - market.amm.base_asset_amount_long + market.amm.base_asset_amount_long() ); assert_eq!(longer.perp_positions[0].quote_asset_amount, 200000000,); - assert_eq!(market.amm.quote_asset_amount, 20000010000 + 77199990000); - assert_eq!(market.amm.total_social_loss, 0); + assert_eq!(market.amm.quote_asset_amount(), 20000010000 + 77199990000); + assert_eq!(market.amm.total_social_loss(), 0); drop(market); } @@ -2734,16 +2736,16 @@ pub mod delisting_test { assert_eq!(shorter_loss, 20000000000000); //$16629 loss let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.amm.total_social_loss, 3449991000); - assert_eq!(market.amm.base_asset_amount_long, 200000000000); - assert_eq!(market.amm.base_asset_amount_short, 0); - assert_eq!(market.amm.base_asset_amount_with_amm, 200000000000); + assert_eq!(market.amm.total_social_loss(), 3449991000); + assert_eq!(market.amm.base_asset_amount_long(), 200000000000); + assert_eq!(market.amm.base_asset_amount_short(), 0); + assert_eq!(market.amm.base_asset_amount_with_amm(), 200000000000); - assert_eq!(market.amm.cumulative_funding_rate_long, 17249955000); - assert_eq!(market.amm.cumulative_funding_rate_short, -17249955000); + assert_eq!(market.amm.cumulative_funding_rate_long(), 17249955000); + assert_eq!(market.amm.cumulative_funding_rate_short(), -17249955000); - assert_eq!(market.pnl_pool.scaled_balance, 20920260001000); //$20920 - assert_eq!(market.amm.fee_pool.scaled_balance, 0); + assert_eq!(market.pnl_pool.scaled_balance(), 20920260001000); //$20920 + assert_eq!(market.amm.fee_pool.scaled_balance(), 0); drop(market); assert_eq!(shorter.perp_positions[0].open_orders, 0); @@ -2794,22 +2796,22 @@ pub mod delisting_test { .unwrap(); let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 20920260001000); + assert_eq!(market.pnl_pool.scaled_balance(), 20920260001000); assert_eq!(longer.spot_positions[0].scaled_balance, 20000000000000); assert_eq!(longer.perp_positions[0].quote_asset_amount, 200000000); assert_eq!(longer.perp_positions[0].quote_asset_amount, 200000000); assert_eq!(longer.perp_positions[0].last_cumulative_funding_rate, 0); - assert_eq!(market.amm.cumulative_funding_rate_long, 17249955000); + assert_eq!(market.amm.cumulative_funding_rate_long(), 17249955000); let longer_funding_payment = calculate_funding_payment( - market.amm.cumulative_funding_rate_long, + market.amm.cumulative_funding_rate_long(), &longer.perp_positions[0], ) .unwrap(); assert_eq!(longer_funding_payment, -3449991000); - assert_eq!(market.amm.quote_asset_amount, 200000000); - assert_eq!(market.amm.total_social_loss, 3449991000); + assert_eq!(market.amm.quote_asset_amount(), 200000000); + assert_eq!(market.amm.total_social_loss(), 3449991000); drop(market); @@ -2832,25 +2834,25 @@ pub mod delisting_test { assert_eq!(longer.spot_positions[0].scaled_balance, 40775959200000); //$40775 let market = market_map.get_ref_mut(&0).unwrap(); - assert_eq!(market.pnl_pool.scaled_balance, 144300801000); // fees collected - assert_eq!(market.amm.fee_pool.scaled_balance, 0); + assert_eq!(market.pnl_pool.scaled_balance(), 144300801000); // fees collected + assert_eq!(market.amm.fee_pool.scaled_balance(), 0); assert_eq!(market.number_of_users_with_base, 0); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), 0); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); - assert_eq!(market.amm.quote_asset_amount, 0); + assert_eq!(market.amm.quote_asset_amount(), 0); - assert_eq!(market.amm.total_social_loss, 3449991000); + assert_eq!(market.amm.total_social_loss(), 3449991000); let oracle_price_data = oracle_map.get_price_data(&market.oracle_id()).unwrap(); assert_eq!(oracle_price_data.price, 100 * PRICE_PRECISION_I64); let net_pnl = calculate_net_user_pnl(&market.amm, oracle_price_data.price).unwrap(); assert_eq!(net_pnl, 3449991000); assert_eq!(market.amm.net_unsettled_funding_pnl, 3449991000); //todo? - assert_eq!(market.amm.quote_asset_amount_per_lp, 0); + assert_eq!(market.amm.quote_asset_amount_per_lp(), 0); drop(market); diff --git a/programs/drift/src/controller/pnl/tests.rs b/programs/drift/src/controller/pnl/tests.rs index 4a35df4e49..3fee1d5440 100644 --- a/programs/drift/src/controller/pnl/tests.rs +++ b/programs/drift/src/controller/pnl/tests.rs @@ -66,20 +66,20 @@ pub fn user_no_position() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -95,7 +95,7 @@ pub fn user_no_position() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -107,10 +107,10 @@ pub fn user_no_position() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default() }; create_anchor_account_info!(spot_market, SpotMarket, spot_market_account_info); @@ -184,20 +184,20 @@ pub fn user_does_not_meet_maintenance_requirement() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -213,7 +213,7 @@ pub fn user_does_not_meet_maintenance_requirement() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -226,11 +226,11 @@ pub fn user_does_not_meet_maintenance_requirement() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -309,20 +309,20 @@ pub fn user_does_not_meet_strict_maintenance_requirement() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -338,7 +338,7 @@ pub fn user_does_not_meet_strict_maintenance_requirement() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -351,11 +351,11 @@ pub fn user_does_not_meet_strict_maintenance_requirement() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData { last_oracle_price_twap_5min: PRICE_PRECISION_I64 / 2, ..HistoricalOracleData::default_price(QUOTE_PRECISION_I64) @@ -451,20 +451,20 @@ pub fn user_unsettled_negative_pnl() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -481,7 +481,7 @@ pub fn user_unsettled_negative_pnl() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -494,11 +494,11 @@ pub fn user_unsettled_negative_pnl() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -530,8 +530,12 @@ pub fn user_unsettled_negative_pnl() { expected_user.spot_positions[0].scaled_balance = 50 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 100 * SPOT_BALANCE_PRECISION; - expected_market.amm.quote_asset_amount = -100 * QUOTE_PRECISION_I128; + expected_market + .pnl_pool + .set_scaled_balance(100 * SPOT_BALANCE_PRECISION); + expected_market + .amm + .set_quote_asset_amount(-100 * QUOTE_PRECISION_I128); expected_market.number_of_users = 0; settle_pnl( @@ -588,20 +592,20 @@ pub fn user_unsettled_positive_pnl_more_than_pool() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -617,7 +621,7 @@ pub fn user_unsettled_positive_pnl_more_than_pool() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -630,11 +634,11 @@ pub fn user_unsettled_positive_pnl_more_than_pool() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -666,8 +670,10 @@ pub fn user_unsettled_positive_pnl_more_than_pool() { expected_user.spot_positions[0].scaled_balance = 150 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 0; - expected_market.amm.quote_asset_amount = -200 * QUOTE_PRECISION_I128; + expected_market.pnl_pool.set_scaled_balance(0); + expected_market + .amm + .set_quote_asset_amount(-200 * QUOTE_PRECISION_I128); settle_pnl( 0, @@ -723,20 +729,20 @@ pub fn user_unsettled_positive_pnl_less_than_pool() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -753,7 +759,7 @@ pub fn user_unsettled_positive_pnl_less_than_pool() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -766,11 +772,11 @@ pub fn user_unsettled_positive_pnl_less_than_pool() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -802,8 +808,12 @@ pub fn user_unsettled_positive_pnl_less_than_pool() { expected_user.spot_positions[0].scaled_balance = 125 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 25 * SPOT_BALANCE_PRECISION; - expected_market.amm.quote_asset_amount = -175 * QUOTE_PRECISION_I128; + expected_market + .pnl_pool + .set_scaled_balance(25 * SPOT_BALANCE_PRECISION); + expected_market + .amm + .set_quote_asset_amount(-175 * QUOTE_PRECISION_I128); expected_market.number_of_users = 0; settle_pnl( @@ -861,22 +871,22 @@ pub fn market_fee_pool_receives_portion() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, - total_fee_minus_distributions: QUOTE_PRECISION_I128, + total_fee_minus_distributions: QUOTE_PRECISION_I128.into(), historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, last_oracle_price_twap_5min: oracle_price.agg.price, @@ -892,7 +902,7 @@ pub fn market_fee_pool_receives_portion() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -905,11 +915,11 @@ pub fn market_fee_pool_receives_portion() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -941,9 +951,16 @@ pub fn market_fee_pool_receives_portion() { expected_user.spot_positions[0].scaled_balance = 100 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 149 * SPOT_BALANCE_PRECISION; - expected_market.amm.fee_pool.scaled_balance = SPOT_BALANCE_PRECISION; - expected_market.amm.quote_asset_amount = -50 * QUOTE_PRECISION_I128; + expected_market + .pnl_pool + .set_scaled_balance(149 * SPOT_BALANCE_PRECISION); + expected_market + .amm + .fee_pool + .set_scaled_balance(SPOT_BALANCE_PRECISION); + expected_market + .amm + .set_quote_asset_amount(-50 * QUOTE_PRECISION_I128); expected_market.number_of_users = 0; settle_pnl( @@ -1000,24 +1017,24 @@ pub fn market_fee_pool_pays_back_to_pnl_pool() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, - total_fee_minus_distributions: QUOTE_PRECISION_I128, + total_fee_minus_distributions: QUOTE_PRECISION_I128.into(), fee_pool: PoolBalance { - scaled_balance: (2 * SPOT_BALANCE_PRECISION), + scaled_balance: (2 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1036,7 +1053,7 @@ pub fn market_fee_pool_pays_back_to_pnl_pool() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1049,11 +1066,11 @@ pub fn market_fee_pool_pays_back_to_pnl_pool() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1085,9 +1102,16 @@ pub fn market_fee_pool_pays_back_to_pnl_pool() { expected_user.spot_positions[0].scaled_balance = 100 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 151 * SPOT_BALANCE_PRECISION; - expected_market.amm.fee_pool.scaled_balance = SPOT_BALANCE_PRECISION; - expected_market.amm.quote_asset_amount = -50 * QUOTE_PRECISION_I128; + expected_market + .pnl_pool + .set_scaled_balance(151 * SPOT_BALANCE_PRECISION); + expected_market + .amm + .fee_pool + .set_scaled_balance(SPOT_BALANCE_PRECISION); + expected_market + .amm + .set_quote_asset_amount(-50 * QUOTE_PRECISION_I128); expected_market.number_of_users = 0; settle_pnl( @@ -1144,20 +1168,20 @@ pub fn user_long_positive_unrealized_pnl_up_to_max_positive_pnl() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 151 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (151 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -1173,7 +1197,7 @@ pub fn user_long_positive_unrealized_pnl_up_to_max_positive_pnl() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1186,11 +1210,11 @@ pub fn user_long_positive_unrealized_pnl_up_to_max_positive_pnl() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1225,8 +1249,10 @@ pub fn user_long_positive_unrealized_pnl_up_to_max_positive_pnl() { expected_user.spot_positions[0].scaled_balance = 150 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 0; - expected_market.amm.quote_asset_amount = -200 * QUOTE_PRECISION_I128; + expected_market.pnl_pool.set_scaled_balance(0); + expected_market + .amm + .set_quote_asset_amount(-200 * QUOTE_PRECISION_I128); settle_pnl( 0, @@ -1282,20 +1308,20 @@ pub fn user_long_positive_unrealized_pnl_up_to_max_positive_pnl_price_breached() let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 121 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (121 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -1311,7 +1337,7 @@ pub fn user_long_positive_unrealized_pnl_up_to_max_positive_pnl_price_breached() status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1324,11 +1350,11 @@ pub fn user_long_positive_unrealized_pnl_up_to_max_positive_pnl_price_breached() let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1363,8 +1389,10 @@ pub fn user_long_positive_unrealized_pnl_up_to_max_positive_pnl_price_breached() expected_user.spot_positions[0].cumulative_deposits = 50 * QUOTE_PRECISION_I64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 0; - expected_market.amm.quote_asset_amount = -200 * QUOTE_PRECISION_I128; + expected_market.pnl_pool.set_scaled_balance(0); + expected_market + .amm + .set_quote_asset_amount(-200 * QUOTE_PRECISION_I128); assert!(settle_pnl( 0, @@ -1417,20 +1445,20 @@ pub fn user_long_negative_unrealized_pnl() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 51 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (51 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: -150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (-150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -1446,7 +1474,7 @@ pub fn user_long_negative_unrealized_pnl() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1459,11 +1487,11 @@ pub fn user_long_negative_unrealized_pnl() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1498,8 +1526,12 @@ pub fn user_long_negative_unrealized_pnl() { expected_user.spot_positions[0].scaled_balance = 50 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 100 * SPOT_BALANCE_PRECISION; - expected_market.amm.quote_asset_amount = -100 * QUOTE_PRECISION_I128; + expected_market + .pnl_pool + .set_scaled_balance(100 * SPOT_BALANCE_PRECISION); + expected_market + .amm + .set_quote_asset_amount(-100 * QUOTE_PRECISION_I128); settle_pnl( 0, @@ -1555,20 +1587,20 @@ pub fn user_short_positive_unrealized_pnl_up_to_max_positive_pnl() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 51 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (51 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -1584,7 +1616,7 @@ pub fn user_short_positive_unrealized_pnl_up_to_max_positive_pnl() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1597,11 +1629,11 @@ pub fn user_short_positive_unrealized_pnl_up_to_max_positive_pnl() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1636,8 +1668,10 @@ pub fn user_short_positive_unrealized_pnl_up_to_max_positive_pnl() { expected_user.spot_positions[0].scaled_balance = 150 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 0; - expected_market.amm.quote_asset_amount = 100 * QUOTE_PRECISION_I128; + expected_market.pnl_pool.set_scaled_balance(0); + expected_market + .amm + .set_quote_asset_amount(100 * QUOTE_PRECISION_I128); settle_pnl( 0, @@ -1693,20 +1727,20 @@ pub fn user_short_negative_unrealized_pnl() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -1722,7 +1756,7 @@ pub fn user_short_negative_unrealized_pnl() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1735,11 +1769,11 @@ pub fn user_short_negative_unrealized_pnl() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -1774,8 +1808,12 @@ pub fn user_short_negative_unrealized_pnl() { expected_user.spot_positions[0].scaled_balance = 50 * SPOT_BALANCE_PRECISION_U64; let mut expected_market = market; - expected_market.pnl_pool.scaled_balance = 100 * SPOT_BALANCE_PRECISION; - expected_market.amm.quote_asset_amount = 200 * QUOTE_PRECISION_I128; + expected_market + .pnl_pool + .set_scaled_balance(100 * SPOT_BALANCE_PRECISION); + expected_market + .amm + .set_quote_asset_amount(200 * QUOTE_PRECISION_I128); settle_pnl( 0, @@ -1832,20 +1870,20 @@ pub fn user_invalid_oracle_position() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, curve_update_intensity: 100, historical_oracle_data: HistoricalOracleData { @@ -1862,7 +1900,7 @@ pub fn user_invalid_oracle_position() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -1872,11 +1910,11 @@ pub fn user_invalid_oracle_position() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), historical_oracle_data: HistoricalOracleData::default_price(QUOTE_PRECISION_I64), ..SpotMarket::default() }; @@ -2053,20 +2091,20 @@ pub fn is_price_divergence_ok_on_invalid_oracle() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 150 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, - base_asset_amount_long: BASE_PRECISION_I128, + quote_asset_amount: (150 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), + base_asset_amount_long: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price.agg.price, @@ -2082,7 +2120,7 @@ pub fn is_price_divergence_ok_on_invalid_oracle() { status: MarketStatus::Active, liquidator_fee: LIQUIDATION_FEE_PRECISION / 100, pnl_pool: PoolBalance { - scaled_balance: (50 * SPOT_BALANCE_PRECISION), + scaled_balance: (50 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, diff --git a/programs/drift/src/controller/position.rs b/programs/drift/src/controller/position.rs index 6b6ec530d5..b6debc088e 100644 --- a/programs/drift/src/controller/position.rs +++ b/programs/drift/src/controller/position.rs @@ -1,6 +1,8 @@ use crate::msg; -use anchor_lang::prelude::*; -use borsh::{BorshDeserialize, BorshSerialize}; +use anchor_lang::prelude::{ + borsh::{BorshDeserialize, BorshSerialize}, + *, +}; use crate::controller; use crate::controller::amm::SwapDirection; @@ -193,139 +195,183 @@ pub fn update_position_and_market( market.number_of_users_with_base = market.number_of_users_with_base.saturating_sub(1); } - market.amm.quote_asset_amount = market - .amm - .quote_asset_amount - .safe_add(delta.quote_asset_amount.cast()?)?; + market.amm.set_quote_asset_amount( + market + .amm + .quote_asset_amount() + .safe_add(delta.quote_asset_amount.cast()?)?, + ); match update_type { PositionUpdateType::Open | PositionUpdateType::Increase => { if new_base_asset_amount > 0 { - market.amm.base_asset_amount_long = market - .amm - .base_asset_amount_long - .safe_add(delta.base_asset_amount.cast()?)?; - market.amm.quote_entry_amount_long = market - .amm - .quote_entry_amount_long - .safe_add(delta.quote_asset_amount.cast()?)?; - market.amm.quote_break_even_amount_long = + market.amm.set_base_asset_amount_long( + market + .amm + .base_asset_amount_long() + .safe_add(delta.base_asset_amount.cast()?)?, + ); + market.amm.set_quote_entry_amount_long( market .amm - .quote_break_even_amount_long - .safe_add(delta.quote_asset_amount.cast()?)?; + .quote_entry_amount_long() + .safe_add(delta.quote_asset_amount.cast()?)?, + ); + market.amm.set_quote_break_even_amount_long( + market + .amm + .quote_break_even_amount_long() + .safe_add(delta.quote_asset_amount.cast()?)?, + ); } else { - market.amm.base_asset_amount_short = market - .amm - .base_asset_amount_short - .safe_add(delta.base_asset_amount.cast()?)?; - market.amm.quote_entry_amount_short = market - .amm - .quote_entry_amount_short - .safe_add(delta.quote_asset_amount.cast()?)?; - market.amm.quote_break_even_amount_short = market - .amm - .quote_break_even_amount_short - .safe_add(delta.quote_asset_amount.cast()?)?; + market.amm.set_base_asset_amount_short( + market + .amm + .base_asset_amount_short() + .safe_add(delta.base_asset_amount.cast()?)?, + ); + market.amm.set_quote_entry_amount_short( + market + .amm + .quote_entry_amount_short() + .safe_add(delta.quote_asset_amount.cast()?)?, + ); + market.amm.set_quote_break_even_amount_short( + market + .amm + .quote_break_even_amount_short() + .safe_add(delta.quote_asset_amount.cast()?)?, + ); } } PositionUpdateType::Reduce | PositionUpdateType::Close => { if position.base_asset_amount > 0 { - market.amm.base_asset_amount_long = market - .amm - .base_asset_amount_long - .safe_add(delta.base_asset_amount.cast()?)?; - market.amm.quote_entry_amount_long = market.amm.quote_entry_amount_long.safe_sub( - position - .quote_entry_amount - .safe_sub(new_quote_entry_amount)? - .cast()?, - )?; - market.amm.quote_break_even_amount_long = - market.amm.quote_break_even_amount_long.safe_sub( + market.amm.set_base_asset_amount_long( + market + .amm + .base_asset_amount_long() + .safe_add(delta.base_asset_amount.cast()?)?, + ); + market.amm.set_quote_entry_amount_long( + market.amm.quote_entry_amount_long().safe_sub( + position + .quote_entry_amount + .safe_sub(new_quote_entry_amount)? + .cast()?, + )?, + ); + market.amm.set_quote_break_even_amount_long( + market.amm.quote_break_even_amount_long().safe_sub( position .quote_break_even_amount .safe_sub(new_quote_break_even_amount)? .cast()?, - )?; + )?, + ); } else { - market.amm.base_asset_amount_short = market - .amm - .base_asset_amount_short - .safe_add(delta.base_asset_amount.cast()?)?; - market.amm.quote_entry_amount_short = - market.amm.quote_entry_amount_short.safe_sub( + market.amm.set_base_asset_amount_short( + market + .amm + .base_asset_amount_short() + .safe_add(delta.base_asset_amount.cast()?)?, + ); + market.amm.set_quote_entry_amount_short( + market.amm.quote_entry_amount_short().safe_sub( position .quote_entry_amount .safe_sub(new_quote_entry_amount)? .cast()?, - )?; - market.amm.quote_break_even_amount_short = - market.amm.quote_break_even_amount_short.safe_sub( + )?, + ); + market.amm.set_quote_break_even_amount_short( + market.amm.quote_break_even_amount_short().safe_sub( position .quote_break_even_amount .safe_sub(new_quote_break_even_amount)? .cast()?, - )?; + )?, + ); } } PositionUpdateType::Flip => { if new_base_asset_amount > 0 { - market.amm.base_asset_amount_short = market - .amm - .base_asset_amount_short - .safe_sub(position.base_asset_amount.cast()?)?; - market.amm.base_asset_amount_long = market - .amm - .base_asset_amount_long - .safe_add(new_base_asset_amount.cast()?)?; - - market.amm.quote_entry_amount_short = market - .amm - .quote_entry_amount_short - .safe_sub(position.quote_entry_amount.cast()?)?; - market.amm.quote_entry_amount_long = market - .amm - .quote_entry_amount_long - .safe_add(new_quote_entry_amount.cast()?)?; - - market.amm.quote_break_even_amount_short = market - .amm - .quote_break_even_amount_short - .safe_sub(position.quote_break_even_amount.cast()?)?; - market.amm.quote_break_even_amount_long = + market.amm.set_base_asset_amount_short( + market + .amm + .base_asset_amount_short() + .safe_sub(position.base_asset_amount.cast()?)?, + ); + market.amm.set_base_asset_amount_long( + market + .amm + .base_asset_amount_long() + .safe_add(new_base_asset_amount.cast()?)?, + ); + + market.amm.set_quote_entry_amount_short( market .amm - .quote_break_even_amount_long - .safe_add(new_quote_break_even_amount.cast()?)?; + .quote_entry_amount_short() + .safe_sub(position.quote_entry_amount.cast()?)?, + ); + market.amm.set_quote_entry_amount_long( + market + .amm + .quote_entry_amount_long() + .safe_add(new_quote_entry_amount.cast()?)?, + ); + + market.amm.set_quote_break_even_amount_short( + market + .amm + .quote_break_even_amount_short() + .safe_sub(position.quote_break_even_amount.cast()?)?, + ); + market.amm.set_quote_break_even_amount_long( + market + .amm + .quote_break_even_amount_long() + .safe_add(new_quote_break_even_amount.cast()?)?, + ); } else { - market.amm.base_asset_amount_long = market - .amm - .base_asset_amount_long - .safe_sub(position.base_asset_amount.cast()?)?; - market.amm.base_asset_amount_short = market - .amm - .base_asset_amount_short - .safe_add(new_base_asset_amount.cast()?)?; - - market.amm.quote_entry_amount_long = market - .amm - .quote_entry_amount_long - .safe_sub(position.quote_entry_amount.cast()?)?; - market.amm.quote_entry_amount_short = market - .amm - .quote_entry_amount_short - .safe_add(new_quote_entry_amount.cast()?)?; - - market.amm.quote_break_even_amount_long = + market.amm.set_base_asset_amount_long( market .amm - .quote_break_even_amount_long - .safe_sub(position.quote_break_even_amount.cast()?)?; - market.amm.quote_break_even_amount_short = market - .amm - .quote_break_even_amount_short - .safe_add(new_quote_break_even_amount.cast()?)?; + .base_asset_amount_long() + .safe_sub(position.base_asset_amount.cast()?)?, + ); + market.amm.set_base_asset_amount_short( + market + .amm + .base_asset_amount_short() + .safe_add(new_base_asset_amount.cast()?)?, + ); + + market.amm.set_quote_entry_amount_long( + market + .amm + .quote_entry_amount_long() + .safe_sub(position.quote_entry_amount.cast()?)?, + ); + market.amm.set_quote_entry_amount_short( + market + .amm + .quote_entry_amount_short() + .safe_add(new_quote_entry_amount.cast()?)?, + ); + + market.amm.set_quote_break_even_amount_long( + market + .amm + .quote_break_even_amount_long() + .safe_sub(position.quote_break_even_amount.cast()?)?, + ); + market.amm.set_quote_break_even_amount_short( + market + .amm + .quote_break_even_amount_short() + .safe_add(new_quote_break_even_amount.cast()?)?, + ); } } } @@ -334,20 +380,20 @@ pub fn update_position_and_market( match position.get_direction() { PositionDirection::Long if position.base_asset_amount != 0 => { validate!( - position.last_cumulative_funding_rate.cast::()? == market.amm.cumulative_funding_rate_long, + position.last_cumulative_funding_rate.cast::()? == market.amm.cumulative_funding_rate_long(), ErrorCode::InvalidPositionLastFundingRate, "position.last_cumulative_funding_rate {} market.amm.cumulative_funding_rate_long {}", position.last_cumulative_funding_rate.cast::()?, - market.amm.cumulative_funding_rate_long, + market.amm.cumulative_funding_rate_long(), )?; } PositionDirection::Short => { validate!( - position.last_cumulative_funding_rate == market.amm.cumulative_funding_rate_short.cast::()?, + position.last_cumulative_funding_rate == market.amm.cumulative_funding_rate_short().cast::()?, ErrorCode::InvalidPositionLastFundingRate, "position.last_cumulative_funding_rate {} market.amm.cumulative_funding_rate_short {}", position.last_cumulative_funding_rate, - market.amm.cumulative_funding_rate_short, + market.amm.cumulative_funding_rate_short(), )?; } _ => {} @@ -362,10 +408,10 @@ pub fn update_position_and_market( ) { if new_base_asset_amount > 0 { position.last_cumulative_funding_rate = - market.amm.cumulative_funding_rate_long.cast()?; + market.amm.cumulative_funding_rate_long().cast()?; } else { position.last_cumulative_funding_rate = - market.amm.cumulative_funding_rate_short.cast()?; + market.amm.cumulative_funding_rate_short().cast()?; } } @@ -424,16 +470,18 @@ pub fn update_position_with_base_asset_amount( &position_delta, )?; - market.amm.base_asset_amount_with_amm = market - .amm - .base_asset_amount_with_amm - .safe_add(position_delta.base_asset_amount.cast()?)?; + market.amm.set_base_asset_amount_with_amm( + market + .amm + .base_asset_amount_with_amm() + .safe_add(position_delta.base_asset_amount.cast()?)?, + ); validate!( - market.amm.base_asset_amount_with_amm.unsigned_abs() <= MAX_BASE_ASSET_AMOUNT_WITH_AMM, + market.amm.base_asset_amount_with_amm().unsigned_abs() <= MAX_BASE_ASSET_AMOUNT_WITH_AMM, ErrorCode::InvalidAmmDetected, "market.amm.base_asset_amount_with_amm={} cannot exceed MAX_BASE_ASSET_AMOUNT_WITH_AMM", - market.amm.base_asset_amount_with_amm + market.amm.base_asset_amount_with_amm() )?; controller::amm::update_spread_reserves(market)?; @@ -490,7 +538,9 @@ pub fn update_quote_asset_amount( position.quote_asset_amount = position.quote_asset_amount.safe_add(delta)?; - market.amm.quote_asset_amount = market.amm.quote_asset_amount.safe_add(delta.cast()?)?; + market + .amm + .set_quote_asset_amount(market.amm.quote_asset_amount().safe_add(delta.cast()?)?); if position.quote_asset_amount == 0 && position.base_asset_amount == 0 { market.number_of_users = market.number_of_users.saturating_sub(1); @@ -510,18 +560,18 @@ pub fn update_quote_break_even_amount( position.quote_break_even_amount = position.quote_break_even_amount.safe_add(delta)?; match position.get_direction() { - PositionDirection::Long => { - market.amm.quote_break_even_amount_long = market + PositionDirection::Long => market.amm.set_quote_break_even_amount_long( + market .amm - .quote_break_even_amount_long - .safe_add(delta.cast()?)? - } - PositionDirection::Short => { - market.amm.quote_break_even_amount_short = market + .quote_break_even_amount_long() + .safe_add(delta.cast()?)?, + ), + PositionDirection::Short => market.amm.set_quote_break_even_amount_short( + market .amm - .quote_break_even_amount_short - .safe_add(delta.cast()?)? - } + .quote_break_even_amount_short() + .safe_add(delta.cast()?)?, + ), } Ok(()) diff --git a/programs/drift/src/controller/position/tests.rs b/programs/drift/src/controller/position/tests.rs index 390e8502a5..684469c4b5 100644 --- a/programs/drift/src/controller/position/tests.rs +++ b/programs/drift/src/controller/position/tests.rs @@ -71,12 +71,12 @@ fn amm_pool_balance_liq_fees_example() { ); let mut spot_market = SpotMarket { - cumulative_deposit_interest: 11425141382, - cumulative_borrow_interest: 12908327537, + cumulative_deposit_interest: 11425141382.into(), + cumulative_borrow_interest: 12908327537.into(), decimals: 6, ..SpotMarket::default() }; - spot_market.deposit_balance = 10_u128.pow(19_u32); + spot_market.set_deposit_balance(10_u128.pow(19_u32)); spot_market.deposit_token_twap = 10_u64.pow(16_u32); let spot_position = SpotPosition::default(); @@ -85,11 +85,14 @@ fn amm_pool_balance_liq_fees_example() { let mut perp_market = perp_market_loader.load_mut().unwrap(); // assert_eq!(perp_market.amm.oracle, Pubkey::default()); - assert_eq!(perp_market.pnl_pool.scaled_balance, 0); - assert_eq!(perp_market.amm.fee_pool.scaled_balance, 1349764971875250); - let fee_before = perp_market.amm.fee_pool.scaled_balance; + assert_eq!(perp_market.pnl_pool.scaled_balance(), 0); + assert_eq!(perp_market.amm.fee_pool.scaled_balance(), 1349764971875250); + let fee_before = perp_market.amm.fee_pool.scaled_balance(); - assert_eq!(perp_market.amm.total_fee_minus_distributions, 1276488252050); + assert_eq!( + perp_market.amm.total_fee_minus_distributions(), + 1276488252050 + ); let new_total_fee_minus_distributions = crate::controller::amm::calculate_perp_market_amm_summary_stats( @@ -100,11 +103,19 @@ fn amm_pool_balance_liq_fees_example() { ) .unwrap(); let fee_difference = new_total_fee_minus_distributions - .safe_sub(perp_market.amm.total_fee_minus_distributions) + .safe_sub(perp_market.amm.total_fee_minus_distributions()) .unwrap(); - perp_market.amm.total_fee = perp_market.amm.total_fee.saturating_add(fee_difference); - perp_market.amm.total_mm_fee = perp_market.amm.total_mm_fee.saturating_add(fee_difference); - perp_market.amm.total_fee_minus_distributions = new_total_fee_minus_distributions; + let total_fee = perp_market.amm.total_fee(); + perp_market + .amm + .set_total_fee(total_fee.saturating_add(fee_difference)); + let total_mm_fee = perp_market.amm.total_mm_fee(); + perp_market + .amm + .set_total_mm_fee(total_mm_fee.saturating_add(fee_difference)); + perp_market + .amm + .set_total_fee_minus_distributions(new_total_fee_minus_distributions); assert_eq!(new_total_fee_minus_distributions, 640881949608); @@ -138,7 +149,7 @@ fn amm_pool_balance_liq_fees_example() { assert_eq!(fee_pool_token_amount, 1276764026200); // 1.27M // assert_eq!(perp_market.amm.fee_pool.scaled_balance, fee_before + 1000000000); // pre change - assert!(perp_market.amm.fee_pool.scaled_balance < fee_before); // post change + assert!(perp_market.amm.fee_pool.scaled_balance() < fee_before); // post change } } @@ -204,7 +215,7 @@ fn amm_pred_expiry_price_yes_market_example() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -223,7 +234,7 @@ fn amm_pred_expiry_price_yes_market_example() { { let mut perp_market = perp_market_loader.load_mut().unwrap(); perp_market.amm.historical_oracle_data.last_oracle_price = 1_000_000; - perp_market.amm.base_asset_amount_with_amm = 0; + perp_market.amm.set_base_asset_amount_with_amm(0); market_index = perp_market.market_index; assert_eq!(perp_market.expiry_ts, 1725559200); @@ -317,7 +328,7 @@ fn amm_pred_expiry_price_market_example() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -336,7 +347,7 @@ fn amm_pred_expiry_price_market_example() { { let mut perp_market = perp_market_loader.load_mut().unwrap(); market_index = perp_market.market_index; - perp_market.amm.base_asset_amount_with_amm = 0; + perp_market.amm.set_base_asset_amount_with_amm(0); perp_market.amm.historical_oracle_data.last_oracle_price = 1; assert_eq!(perp_market.expiry_ts, 1725559200); @@ -429,7 +440,7 @@ fn amm_pred_settle_market_example() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, @@ -511,15 +522,18 @@ fn amm_pred_market_example() { assert_eq!(max_bids, 3_824_624_394_874); // 3824 shares assert_eq!(max_asks, -5_241_195_799_744); // -5000 shares - assert_eq!(perp_market.amm.sqrt_k, 56_649_660_613_272); + assert_eq!(perp_market.amm.sqrt_k(), 56_649_660_613_272); let (optimal_peg, fee_budget, _check_lower_bound) = repeg::calculate_optimal_peg_and_budget(&perp_market, &mm_oracle_price_data).unwrap(); - assert_eq!(perp_market.amm.terminal_quote_asset_reserve, 56405211622548); - assert_eq!(perp_market.amm.quote_asset_reserve, 56933567973708); assert_eq!( - perp_market.amm.quote_asset_reserve - perp_market.amm.terminal_quote_asset_reserve, + perp_market.amm.terminal_quote_asset_reserve(), + 56405211622548 + ); + assert_eq!(perp_market.amm.quote_asset_reserve(), 56933567973708); + assert_eq!( + perp_market.amm.quote_asset_reserve() - perp_market.amm.terminal_quote_asset_reserve(), 528356351160 ); @@ -589,10 +603,10 @@ fn amm_ref_price_decay_tail_test() { assert_eq!(max_ref_offset, 10000); let liquidity_ratio = crate::math::amm_spread::calculate_inventory_liquidity_ratio( - perp_market.amm.base_asset_amount_with_amm, - perp_market.amm.base_asset_reserve, - perp_market.amm.max_base_asset_reserve, - perp_market.amm.min_base_asset_reserve, + perp_market.amm.base_asset_amount_with_amm(), + perp_market.amm.base_asset_reserve(), + perp_market.amm.max_base_asset_reserve(), + perp_market.amm.min_base_asset_reserve(), ) .unwrap(); @@ -766,10 +780,10 @@ fn amm_ref_price_offset_decay_logic() { let max_ref_offset = perp_market.amm.get_max_reference_price_offset().unwrap(); let liquidity_ratio = crate::math::amm_spread::calculate_inventory_liquidity_ratio( - perp_market.amm.base_asset_amount_with_amm, - perp_market.amm.base_asset_reserve, - perp_market.amm.max_base_asset_reserve, - perp_market.amm.min_base_asset_reserve, + perp_market.amm.base_asset_amount_with_amm(), + perp_market.amm.base_asset_reserve(), + perp_market.amm.max_base_asset_reserve(), + perp_market.amm.min_base_asset_reserve(), ) .unwrap(); @@ -941,10 +955,10 @@ fn amm_negative_ref_price_offset_decay_logic() { let max_ref_offset = perp_market.amm.get_max_reference_price_offset().unwrap(); let liquidity_ratio = crate::math::amm_spread::calculate_inventory_liquidity_ratio( - perp_market.amm.base_asset_amount_with_amm, - perp_market.amm.base_asset_reserve, - perp_market.amm.max_base_asset_reserve, - perp_market.amm.min_base_asset_reserve, + perp_market.amm.base_asset_amount_with_amm(), + perp_market.amm.base_asset_reserve(), + perp_market.amm.max_base_asset_reserve(), + perp_market.amm.min_base_asset_reserve(), ) .unwrap(); @@ -1101,7 +1115,7 @@ fn amm_perp_ref_offset() { AccountLoader::try_from(&perp_market_account_info).unwrap(); let mut perp_market = perp_market_loader.load_mut().unwrap(); - perp_market.amm.base_asset_amount_with_amm = 40000000000; // override old LP related fields + perp_market.amm.set_base_asset_amount_with_amm(40000000000); // override old LP related fields let reserve_price = perp_market.amm.reserve_price().unwrap(); let (b1, a1) = perp_market.amm.bid_ask_price(reserve_price).unwrap(); @@ -1121,16 +1135,16 @@ fn amm_perp_ref_offset() { .last_oracle_price_twap_ts, 1741207620 ); - assert_eq!(perp_market.amm.bid_base_asset_reserve, 4674304094737516); - assert_eq!(perp_market.amm.ask_base_asset_reserve, 4631420570932586); + assert_eq!(perp_market.amm.bid_base_asset_reserve(), 4674304094737516); + assert_eq!(perp_market.amm.ask_base_asset_reserve(), 4631420570932586); let max_ref_offset = perp_market.amm.get_max_reference_price_offset().unwrap(); let liquidity_ratio = crate::math::amm_spread::calculate_inventory_liquidity_ratio( - perp_market.amm.base_asset_amount_with_amm, - perp_market.amm.base_asset_reserve, - perp_market.amm.max_base_asset_reserve, - perp_market.amm.min_base_asset_reserve, + perp_market.amm.base_asset_amount_with_amm(), + perp_market.amm.base_asset_reserve(), + perp_market.amm.max_base_asset_reserve(), + perp_market.amm.min_base_asset_reserve(), ) .unwrap(); @@ -1205,8 +1219,8 @@ fn amm_perp_ref_offset() { assert_eq!(perp_market.amm.max_spread, 90000); assert_eq!(r, 7101599); - assert_eq!(perp_market.amm.bid_base_asset_reserve, 4675159724262455); - assert_eq!(perp_market.amm.ask_base_asset_reserve, 4672813088646692); + assert_eq!(perp_market.amm.bid_base_asset_reserve(), 4675159724262455); + assert_eq!(perp_market.amm.ask_base_asset_reserve(), 4672813088646692); crate::validation::perp_market::validate_perp_market(&perp_market).unwrap(); @@ -1269,8 +1283,8 @@ fn test_position_entry_sim() { }; let mut market = PerpMarket { amm: AMM { - cumulative_funding_rate_long: 1, - sqrt_k: 1, + cumulative_funding_rate_long: 1.into(), + sqrt_k: 1.into(), order_step_size: (BASE_PRECISION_I64 / 10) as u64, ..AMM::default() }, @@ -1325,8 +1339,8 @@ fn increase_long_from_no_position() { }; let mut market = PerpMarket { amm: AMM { - cumulative_funding_rate_long: 1, - sqrt_k: 1, + cumulative_funding_rate_long: 1.into(), + sqrt_k: 1.into(), order_step_size: 1, ..AMM::default() }, @@ -1345,14 +1359,14 @@ fn increase_long_from_no_position() { assert_eq!(existing_position.last_cumulative_funding_rate, 1); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 1); - assert_eq!(market.amm.base_asset_amount_short, 0); - assert_eq!(market.amm.base_asset_amount_with_amm, 0); - assert_eq!(market.amm.quote_asset_amount, -1); - assert_eq!(market.amm.quote_entry_amount_long, -1); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, -1); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 1); + assert_eq!(market.amm.base_asset_amount_short(), 0); + assert_eq!(market.amm.base_asset_amount_with_amm(), 0); + assert_eq!(market.amm.quote_asset_amount(), -1); + assert_eq!(market.amm.quote_entry_amount_long(), -1); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), -1); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -1364,7 +1378,7 @@ fn increase_short_from_no_position() { }; let mut market = PerpMarket { amm: AMM { - cumulative_funding_rate_short: 1, + cumulative_funding_rate_short: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 0, @@ -1382,13 +1396,13 @@ fn increase_short_from_no_position() { assert_eq!(existing_position.last_cumulative_funding_rate, 1); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -1); - assert_eq!(market.amm.quote_asset_amount, 1); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 1); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 1); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -1); + assert_eq!(market.amm.quote_asset_amount(), 1); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 1); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 1); } #[test] @@ -1407,13 +1421,13 @@ fn increase_long() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 1, - base_asset_amount_long: 1, - base_asset_amount_short: 0, - quote_asset_amount: -1, - quote_break_even_amount_long: -2, - quote_entry_amount_long: -1, - cumulative_funding_rate_long: 1, + base_asset_amount_with_amm: 1.into(), + base_asset_amount_long: 1.into(), + base_asset_amount_short: 0.into(), + quote_asset_amount: (-1).into(), + quote_break_even_amount_long: (-2).into(), + quote_entry_amount_long: (-1).into(), + cumulative_funding_rate_long: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1431,15 +1445,15 @@ fn increase_long() { assert_eq!(existing_position.last_cumulative_funding_rate, 1); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 2); - assert_eq!(market.amm.base_asset_amount_short, 0); - assert_eq!(market.amm.quote_asset_amount, -2); - assert_eq!(market.amm.quote_entry_amount_long, -2); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, -3); - assert_eq!(market.amm.quote_break_even_amount_short, 0); - - assert_eq!(market.amm.base_asset_amount_with_amm, 1); // todo: update_position_and_market doesnt modify this properly? + assert_eq!(market.amm.base_asset_amount_long(), 2); + assert_eq!(market.amm.base_asset_amount_short(), 0); + assert_eq!(market.amm.quote_asset_amount(), -2); + assert_eq!(market.amm.quote_entry_amount_long(), -2); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), -3); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); + + assert_eq!(market.amm.base_asset_amount_with_amm(), 1); // todo: update_position_and_market doesnt modify this properly? } #[test] @@ -1458,12 +1472,12 @@ fn increase_short() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_short: -1, - base_asset_amount_long: 0, - quote_asset_amount: 1, - quote_entry_amount_short: 1, - quote_break_even_amount_short: 2, - cumulative_funding_rate_short: 1, + base_asset_amount_short: (-1).into(), + base_asset_amount_long: 0.into(), + quote_asset_amount: 1.into(), + quote_entry_amount_short: 1.into(), + quote_break_even_amount_short: 2.into(), + cumulative_funding_rate_short: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1481,13 +1495,13 @@ fn increase_short() { assert_eq!(existing_position.last_cumulative_funding_rate, 1); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -2); - assert_eq!(market.amm.quote_asset_amount, 2); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 2); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 3); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -2); + assert_eq!(market.amm.quote_asset_amount(), 2); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 2); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 3); } #[test] @@ -1506,13 +1520,13 @@ fn reduce_long_profitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 10, - base_asset_amount_long: 10, - base_asset_amount_short: 0, - quote_asset_amount: -10, - quote_entry_amount_long: -10, - quote_break_even_amount_long: -12, - cumulative_funding_rate_long: 1, + base_asset_amount_with_amm: 10.into(), + base_asset_amount_long: 10.into(), + base_asset_amount_short: 0.into(), + quote_asset_amount: (-10).into(), + quote_entry_amount_long: (-10).into(), + quote_break_even_amount_long: (-12).into(), + cumulative_funding_rate_long: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1530,14 +1544,14 @@ fn reduce_long_profitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 1); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 9); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 9); + assert_eq!(market.amm.base_asset_amount_short(), 0); // assert_eq!(market.amm.base_asset_amount_with_amm, 9); - assert_eq!(market.amm.quote_asset_amount, -5); - assert_eq!(market.amm.quote_entry_amount_long, -9); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, -11); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.quote_asset_amount(), -5); + assert_eq!(market.amm.quote_entry_amount_long(), -9); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), -11); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -1556,13 +1570,13 @@ fn reduce_long_unprofitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 10, - base_asset_amount_long: 10, - base_asset_amount_short: 0, - quote_asset_amount: -100, - quote_entry_amount_long: -100, - quote_break_even_amount_long: -200, - cumulative_funding_rate_long: 1, + base_asset_amount_with_amm: 10.into(), + base_asset_amount_long: 10.into(), + base_asset_amount_short: 0.into(), + quote_asset_amount: (-100).into(), + quote_entry_amount_long: (-100).into(), + quote_break_even_amount_long: (-200).into(), + cumulative_funding_rate_long: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1580,14 +1594,14 @@ fn reduce_long_unprofitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 1); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 9); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 9); + assert_eq!(market.amm.base_asset_amount_short(), 0); // assert_eq!(market.amm.base_asset_amount_with_amm, 9); - assert_eq!(market.amm.quote_asset_amount, -95); - assert_eq!(market.amm.quote_entry_amount_long, -90); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, -180); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.quote_asset_amount(), -95); + assert_eq!(market.amm.quote_entry_amount_long(), -90); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), -180); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -1606,14 +1620,14 @@ fn flip_long_to_short_profitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 10, - base_asset_amount_long: 10, - base_asset_amount_short: 0, - quote_asset_amount: -10, - quote_break_even_amount_long: -12, - quote_entry_amount_long: -10, - cumulative_funding_rate_short: 2, - cumulative_funding_rate_long: 1, + base_asset_amount_with_amm: 10.into(), + base_asset_amount_long: 10.into(), + base_asset_amount_short: 0.into(), + quote_asset_amount: (-10).into(), + quote_break_even_amount_long: (-12).into(), + quote_entry_amount_long: (-10).into(), + cumulative_funding_rate_short: 2.into(), + cumulative_funding_rate_long: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1631,14 +1645,14 @@ fn flip_long_to_short_profitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 2); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -1); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -1); // assert_eq!(market.amm.base_asset_amount_with_amm, -1); - assert_eq!(market.amm.quote_asset_amount, 12); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 2); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 2); + assert_eq!(market.amm.quote_asset_amount(), 12); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 2); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 2); } #[test] @@ -1657,14 +1671,14 @@ fn flip_long_to_short_unprofitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 10, - base_asset_amount_long: 10, - base_asset_amount_short: 0, - quote_asset_amount: -10, - quote_break_even_amount_long: -12, - quote_entry_amount_long: -10, - cumulative_funding_rate_short: 2, - cumulative_funding_rate_long: 1, + base_asset_amount_with_amm: 10.into(), + base_asset_amount_long: 10.into(), + base_asset_amount_short: 0.into(), + quote_asset_amount: (-10).into(), + quote_break_even_amount_long: (-12).into(), + quote_entry_amount_long: (-10).into(), + cumulative_funding_rate_short: 2.into(), + cumulative_funding_rate_long: 1.into(), order_step_size: 1, ..AMM::default() }, @@ -1683,14 +1697,14 @@ fn flip_long_to_short_unprofitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 2); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -1); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -1); // assert_eq!(market.amm.base_asset_amount_with_amm, -1); - assert_eq!(market.amm.quote_asset_amount, 0); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 1); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 1); + assert_eq!(market.amm.quote_asset_amount(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 1); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 1); } #[test] @@ -1709,12 +1723,12 @@ fn reduce_short_profitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_long: 0, - base_asset_amount_short: -10, - quote_asset_amount: 100, - quote_entry_amount_short: 100, - quote_break_even_amount_short: 200, - cumulative_funding_rate_short: 1, + base_asset_amount_long: 0.into(), + base_asset_amount_short: (-10).into(), + quote_asset_amount: 100.into(), + quote_entry_amount_short: 100.into(), + quote_break_even_amount_short: 200.into(), + cumulative_funding_rate_short: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1732,13 +1746,13 @@ fn reduce_short_profitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 1); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -9); - assert_eq!(market.amm.quote_asset_amount, 95); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 90); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 180); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -9); + assert_eq!(market.amm.quote_asset_amount(), 95); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 90); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 180); } #[test] @@ -1757,12 +1771,12 @@ fn decrease_short_unprofitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_long: 0, - base_asset_amount_short: -10, - quote_asset_amount: 100, - quote_entry_amount_short: 100, - quote_break_even_amount_short: 200, - cumulative_funding_rate_short: 1, + base_asset_amount_long: 0.into(), + base_asset_amount_short: (-10).into(), + quote_asset_amount: 100.into(), + quote_entry_amount_short: 100.into(), + quote_break_even_amount_short: 200.into(), + cumulative_funding_rate_short: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1780,13 +1794,13 @@ fn decrease_short_unprofitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 1); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -9); - assert_eq!(market.amm.quote_asset_amount, 85); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 90); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 180); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -9); + assert_eq!(market.amm.quote_asset_amount(), 85); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 90); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 180); } #[test] @@ -1805,14 +1819,14 @@ fn flip_short_to_long_profitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: -10, - base_asset_amount_long: 0, - base_asset_amount_short: -10, - quote_asset_amount: 100, - quote_entry_amount_short: 100, - quote_break_even_amount_short: 200, - cumulative_funding_rate_long: 2, - cumulative_funding_rate_short: 1, + base_asset_amount_with_amm: (-10).into(), + base_asset_amount_long: 0.into(), + base_asset_amount_short: (-10).into(), + quote_asset_amount: 100.into(), + quote_entry_amount_short: 100.into(), + quote_break_even_amount_short: 200.into(), + cumulative_funding_rate_long: 2.into(), + cumulative_funding_rate_short: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1830,14 +1844,14 @@ fn flip_short_to_long_profitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 2); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 1); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 1); + assert_eq!(market.amm.base_asset_amount_short(), 0); // assert_eq!(market.amm.base_asset_amount_with_amm, 1); - assert_eq!(market.amm.quote_asset_amount, 40); - assert_eq!(market.amm.quote_entry_amount_long, -6); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, -6); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.quote_asset_amount(), 40); + assert_eq!(market.amm.quote_entry_amount_long(), -6); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), -6); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -1856,14 +1870,14 @@ fn flip_short_to_long_unprofitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: -10, - base_asset_amount_long: 0, - base_asset_amount_short: -10, - quote_asset_amount: 100, - quote_entry_amount_short: 100, - quote_break_even_amount_short: 200, - cumulative_funding_rate_long: 2, - cumulative_funding_rate_short: 1, + base_asset_amount_with_amm: (-10).into(), + base_asset_amount_long: 0.into(), + base_asset_amount_short: (-10).into(), + quote_asset_amount: 100.into(), + quote_entry_amount_short: 100.into(), + quote_break_even_amount_short: 200.into(), + cumulative_funding_rate_long: 2.into(), + cumulative_funding_rate_short: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 1, @@ -1881,14 +1895,14 @@ fn flip_short_to_long_unprofitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 2); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 1); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 1); + assert_eq!(market.amm.base_asset_amount_short(), 0); // assert_eq!(market.amm.base_asset_amount_with_amm, 1); - assert_eq!(market.amm.quote_asset_amount, -20); - assert_eq!(market.amm.quote_entry_amount_long, -11); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, -11); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.quote_asset_amount(), -20); + assert_eq!(market.amm.quote_entry_amount_long(), -11); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), -11); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -1907,12 +1921,12 @@ fn close_long_profitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 11, - base_asset_amount_long: 11, - quote_asset_amount: -11, - quote_entry_amount_long: -11, - quote_break_even_amount_long: -13, - cumulative_funding_rate_long: 1, + base_asset_amount_with_amm: 11.into(), + base_asset_amount_long: 11.into(), + quote_asset_amount: (-11).into(), + quote_entry_amount_long: (-11).into(), + quote_break_even_amount_long: (-13).into(), + cumulative_funding_rate_long: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 2, @@ -1930,15 +1944,15 @@ fn close_long_profitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 0); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 1); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 1); + assert_eq!(market.amm.base_asset_amount_short(), 0); // assert_eq!(market.amm.base_asset_amount_with_amm, 1); // not 5 because quote asset amount long was -11 not -10 before - assert_eq!(market.amm.quote_asset_amount, 4); - assert_eq!(market.amm.quote_entry_amount_long, -1); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, -1); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.quote_asset_amount(), 4); + assert_eq!(market.amm.quote_entry_amount_long(), -1); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), -1); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -1957,12 +1971,12 @@ fn close_long_unprofitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 11, - base_asset_amount_long: 11, - quote_asset_amount: -11, - quote_entry_amount_long: -11, - quote_break_even_amount_long: -13, - cumulative_funding_rate_long: 1, + base_asset_amount_with_amm: 11.into(), + base_asset_amount_long: 11.into(), + quote_asset_amount: (-11).into(), + quote_entry_amount_long: (-11).into(), + quote_break_even_amount_long: (-13).into(), + cumulative_funding_rate_long: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 2, @@ -1980,14 +1994,14 @@ fn close_long_unprofitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 0); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 1); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 1); + assert_eq!(market.amm.base_asset_amount_short(), 0); // assert_eq!(market.amm.base_asset_amount_with_amm, 1); - assert_eq!(market.amm.quote_asset_amount, -6); - assert_eq!(market.amm.quote_entry_amount_long, -1); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, -1); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.quote_asset_amount(), -6); + assert_eq!(market.amm.quote_entry_amount_long(), -1); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), -1); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -2006,11 +2020,11 @@ fn close_short_profitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_short: -11, - quote_asset_amount: 11, - quote_entry_amount_short: 11, - quote_break_even_amount_short: 13, - cumulative_funding_rate_short: 1, + base_asset_amount_short: (-11).into(), + quote_asset_amount: 11.into(), + quote_entry_amount_short: 11.into(), + quote_break_even_amount_short: 13.into(), + cumulative_funding_rate_short: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 2, @@ -2028,13 +2042,13 @@ fn close_short_profitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 0); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -1); - assert_eq!(market.amm.quote_asset_amount, 6); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 1); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 1); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -1); + assert_eq!(market.amm.quote_asset_amount(), 6); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 1); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 1); } #[test] @@ -2053,11 +2067,11 @@ fn close_short_unprofitable() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_short: -11, - quote_asset_amount: 11, - quote_entry_amount_short: 11, - quote_break_even_amount_short: 13, - cumulative_funding_rate_short: 1, + base_asset_amount_short: (-11).into(), + quote_asset_amount: 11.into(), + quote_entry_amount_short: 11.into(), + quote_break_even_amount_short: 13.into(), + cumulative_funding_rate_short: 1.into(), ..AMM::default_test() }, number_of_users_with_base: 2, @@ -2075,13 +2089,13 @@ fn close_short_unprofitable() { assert_eq!(existing_position.last_cumulative_funding_rate, 0); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -1); - assert_eq!(market.amm.quote_asset_amount, -4); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 1); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 1); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -1); + assert_eq!(market.amm.quote_asset_amount(), -4); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 1); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 1); } #[test] @@ -2100,12 +2114,12 @@ fn close_long_with_quote_break_even_amount_less_than_quote_asset_amount() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 11, - base_asset_amount_long: 11, - quote_asset_amount: -11, - quote_entry_amount_long: -8, - quote_break_even_amount_long: -9, - cumulative_funding_rate_long: 1, + base_asset_amount_with_amm: 11.into(), + base_asset_amount_long: 11.into(), + quote_asset_amount: (-11).into(), + quote_entry_amount_long: (-8).into(), + quote_break_even_amount_long: (-9).into(), + cumulative_funding_rate_long: 1.into(), order_step_size: 1, ..AMM::default() }, @@ -2124,14 +2138,14 @@ fn close_long_with_quote_break_even_amount_less_than_quote_asset_amount() { assert_eq!(existing_position.last_cumulative_funding_rate, 0); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 1); - assert_eq!(market.amm.base_asset_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 1); + assert_eq!(market.amm.base_asset_amount_short(), 0); // assert_eq!(market.amm.base_asset_amount_with_amm, 1); - assert_eq!(market.amm.quote_asset_amount, -6); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.quote_asset_amount(), -6); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -2150,11 +2164,11 @@ fn close_short_with_quote_break_even_amount_more_than_quote_asset_amount() { }; let mut market = PerpMarket { amm: AMM { - base_asset_amount_short: -11, - quote_asset_amount: 11, - quote_entry_amount_short: 15, - quote_break_even_amount_short: 17, - cumulative_funding_rate_short: 1, + base_asset_amount_short: (-11).into(), + quote_asset_amount: 11.into(), + quote_entry_amount_short: 15.into(), + quote_break_even_amount_short: 17.into(), + cumulative_funding_rate_short: 1.into(), order_step_size: 1, ..AMM::default() }, @@ -2173,13 +2187,13 @@ fn close_short_with_quote_break_even_amount_more_than_quote_asset_amount() { assert_eq!(existing_position.last_cumulative_funding_rate, 0); assert_eq!(market.number_of_users_with_base, 1); - assert_eq!(market.amm.base_asset_amount_long, 0); - assert_eq!(market.amm.base_asset_amount_short, -1); - assert_eq!(market.amm.quote_asset_amount, -4); - assert_eq!(market.amm.quote_entry_amount_long, 0); - assert_eq!(market.amm.quote_entry_amount_short, 0); - assert_eq!(market.amm.quote_break_even_amount_long, 0); - assert_eq!(market.amm.quote_break_even_amount_short, 0); + assert_eq!(market.amm.base_asset_amount_long(), 0); + assert_eq!(market.amm.base_asset_amount_short(), -1); + assert_eq!(market.amm.quote_asset_amount(), -4); + assert_eq!(market.amm.quote_entry_amount_long(), 0); + assert_eq!(market.amm.quote_entry_amount_short(), 0); + assert_eq!(market.amm.quote_break_even_amount_long(), 0); + assert_eq!(market.amm.quote_break_even_amount_short(), 0); } #[test] @@ -2215,15 +2229,21 @@ fn update_amm_near_boundary() { OracleMap::load_one(&jto_market_account_info, slot, None).unwrap(); let mut perp_market = perp_market_loader.load_mut().unwrap(); - assert_eq!(perp_market.amm.base_asset_amount_with_amm, 23831444927173); + assert_eq!(perp_market.amm.base_asset_amount_with_amm(), 23831444927173); assert_eq!( - perp_market.amm.base_asset_amount_with_unsettled_lp, + perp_market.amm.base_asset_amount_with_unsettled_lp(), 562555072827 ); - perp_market.amm.base_asset_amount_with_amm += - perp_market.amm.base_asset_amount_with_unsettled_lp; - perp_market.amm.base_asset_amount_with_unsettled_lp = 0; + let base_asset_amount_with_amm = perp_market.amm.base_asset_amount_with_amm; + let base_asset_amount_with_unsettled_lp = perp_market.amm.base_asset_amount_with_unsettled_lp(); + perp_market.amm.set_base_asset_amount_with_amm( + base_asset_amount_with_amm + .as_i128() + .safe_add(base_asset_amount_with_unsettled_lp) + .unwrap(), + ); + perp_market.amm.set_base_asset_amount_with_unsettled_lp(0); println!("perp_market: {:?}", perp_market.amm.last_update_slot); let oracle_price_data = oracle_map.get_price_data(&perp_market.oracle_id()).unwrap(); @@ -2334,7 +2354,7 @@ fn recenter_amm_1() { assert_eq!(cost, 2538958); - let inv = perp_market.amm.base_asset_amount_with_amm; + let inv = perp_market.amm.base_asset_amount_with_amm(); assert_eq!(inv, 24521505718700); let (_, _, r1_orig, r2_orig) = calculate_base_swap_output_with_spread( @@ -2347,15 +2367,15 @@ fn recenter_amm_1() { assert_eq!(r1_orig, 334835274409); assert_eq!(r2_orig, 704841208); - let current_k = perp_market.amm.sqrt_k; - let _current_peg = perp_market.amm.peg_multiplier; + let current_k = perp_market.amm.sqrt_k(); + let _current_peg = perp_market.amm.peg_multiplier(); let new_k = (current_k * 900000) / 100; recenter_perp_market_amm(&mut perp_market, oracle_price_data.price as u128, new_k).unwrap(); - assert_eq!(perp_market.amm.sqrt_k, new_k); + assert_eq!(perp_market.amm.sqrt_k(), new_k); assert_eq!( - perp_market.amm.peg_multiplier, + perp_market.amm.peg_multiplier(), oracle_price_data.price as u128 ); @@ -2420,9 +2440,9 @@ fn recenter_amm_2() { ); // previous values - assert_eq!(perp_market.amm.peg_multiplier, 5); - assert_eq!(perp_market.amm.quote_asset_reserve, 64381518181749930705); - assert_eq!(perp_market.amm.base_asset_reserve, 307161425106214); + assert_eq!(perp_market.amm.peg_multiplier(), 5); + assert_eq!(perp_market.amm.quote_asset_reserve(), 64381518181749930705); + assert_eq!(perp_market.amm.base_asset_reserve(), 307161425106214); let oracle_price_data = oracle_map .get_price_data(&(oracle_price_key, OracleSource::Pyth)) @@ -2442,7 +2462,7 @@ fn recenter_amm_2() { assert_eq!(cost, 0); - let inv = perp_market.amm.base_asset_amount_with_amm; + let inv = perp_market.amm.base_asset_amount_with_amm(); assert_eq!(inv, -291516212); let (_, _, r1_orig, r2_orig) = calculate_base_swap_output_with_spread( @@ -2455,34 +2475,40 @@ fn recenter_amm_2() { assert_eq!(r1_orig, 326219); assert_eq!(r2_orig, 20707); - let current_k = perp_market.amm.sqrt_k; - let _current_peg = perp_market.amm.peg_multiplier; + let current_k = perp_market.amm.sqrt_k(); + let _current_peg = perp_market.amm.peg_multiplier(); let new_k = current_k * 2; // refusal to decrease further assert_eq!(current_k, current_k); - assert_eq!(perp_market.amm.user_lp_shares, current_k - 1); + assert_eq!(perp_market.amm.user_lp_shares(), current_k - 1); assert_eq!( perp_market.amm.get_lower_bound_sqrt_k().unwrap(), perp_market.amm.min_order_size as u128 ); - perp_market.amm.base_asset_amount_with_amm += - perp_market.amm.base_asset_amount_with_unsettled_lp; - perp_market.amm.base_asset_amount_with_unsettled_lp = 0; + let base_asset_amount_with_amm = perp_market.amm.base_asset_amount_with_amm; + let base_asset_amount_with_unsettled_lp = perp_market.amm.base_asset_amount_with_unsettled_lp; + perp_market.amm.set_base_asset_amount_with_amm( + base_asset_amount_with_amm + .as_i128() + .safe_add(base_asset_amount_with_unsettled_lp.as_i128()) + .unwrap(), + ); + perp_market.amm.set_base_asset_amount_with_unsettled_lp(0); recenter_perp_market_amm(&mut perp_market, oracle_price_data.price as u128, new_k).unwrap(); - assert_eq!(perp_market.amm.sqrt_k, new_k); + assert_eq!(perp_market.amm.sqrt_k(), new_k); assert_eq!( - perp_market.amm.peg_multiplier, + perp_market.amm.peg_multiplier(), oracle_price_data.price as u128 ); - assert_eq!(perp_market.amm.peg_multiplier, 1_120_000); + assert_eq!(perp_market.amm.peg_multiplier(), 1_120_000); // assert_eq!(perp_market.amm.quote_asset_reserve, 140625455708483789 * 2); // assert_eq!(perp_market.amm.base_asset_reserve, 140625456291516213 * 2); - assert_eq!(perp_market.amm.base_asset_reserve, 281254004000000002); - assert_eq!(perp_market.amm.quote_asset_reserve, 281247820033992278); + assert_eq!(perp_market.amm.base_asset_reserve(), 281254004000000002); + assert_eq!(perp_market.amm.quote_asset_reserve(), 281247820033992278); crate::validation::perp_market::validate_perp_market(&perp_market).unwrap(); @@ -2498,15 +2524,15 @@ fn recenter_amm_2() { assert_eq!(r2, 22129); let new_scale = 2; - let new_sqrt_k = perp_market.amm.sqrt_k * new_scale; + let new_sqrt_k = perp_market.amm.sqrt_k() * new_scale; let update_k_result = get_update_k_result(&perp_market, U192::from(new_sqrt_k), false).unwrap(); let adjustment_cost = adjust_k_cost(&mut perp_market, &update_k_result).unwrap(); assert_eq!(adjustment_cost, 19035); update_k(&mut perp_market, &update_k_result).unwrap(); - assert_eq!(perp_market.amm.sqrt_k, new_sqrt_k); - assert_eq!(perp_market.amm.user_lp_shares, current_k - 1); + assert_eq!(perp_market.amm.sqrt_k(), new_sqrt_k); + assert_eq!(perp_market.amm.user_lp_shares(), current_k - 1); assert_eq!( perp_market.amm.get_lower_bound_sqrt_k().unwrap(), 3092000000000 @@ -2555,16 +2581,18 @@ fn test_move_amm() { // let perp_market_old = market_map.get_ref(&4).unwrap(); let mut perp_market = market_map.get_ref_mut(&9).unwrap(); - perp_market.amm.base_asset_amount_with_amm = -3092 * BASE_PRECISION as i128; + perp_market + .amm + .set_base_asset_amount_with_amm(-3092 * BASE_PRECISION as i128); println!( "perp_market latest slot: {:?}", perp_market.amm.last_update_slot ); // previous values - assert_eq!(perp_market.amm.peg_multiplier, 5); - assert_eq!(perp_market.amm.quote_asset_reserve, 64381518181749930705); - assert_eq!(perp_market.amm.base_asset_reserve, 307161425106214); + assert_eq!(perp_market.amm.peg_multiplier(), 5); + assert_eq!(perp_market.amm.quote_asset_reserve(), 64381518181749930705); + assert_eq!(perp_market.amm.base_asset_reserve(), 307161425106214); let oracle_price_data = oracle_map .get_price_data(&(oracle_price_key, OracleSource::Pyth)) @@ -2584,7 +2612,7 @@ fn test_move_amm() { assert_eq!(cost, 0); - let inv = perp_market.amm.base_asset_amount_with_amm; + let inv = perp_market.amm.base_asset_amount_with_amm(); assert_eq!(inv, -3092000000000); let (_, _, r1_orig, r2_orig) = calculate_base_swap_output_with_spread( @@ -2596,9 +2624,9 @@ fn test_move_amm() { assert_eq!(r1_orig, 3489128798); assert_eq!(r2_orig, 215737299); - let current_bar = perp_market.amm.base_asset_reserve; - let _current_qar = perp_market.amm.quote_asset_reserve; - let current_k = perp_market.amm.sqrt_k; + let current_bar = perp_market.amm.base_asset_reserve(); + let _current_qar = perp_market.amm.quote_asset_reserve(); + let current_k = perp_market.amm.sqrt_k(); let inc_numerator = BASE_PRECISION + BASE_PRECISION / 100; let new_k = current_k * inc_numerator / BASE_PRECISION; @@ -2612,6 +2640,6 @@ fn test_move_amm() { ) .unwrap(); crate::validation::perp_market::validate_perp_market(&perp_market).unwrap(); - assert_eq!(perp_market.amm.sqrt_k, new_k); - assert_eq!(perp_market.amm.peg_multiplier, 5); // still same + assert_eq!(perp_market.amm.sqrt_k(), new_k); + assert_eq!(perp_market.amm.peg_multiplier(), 5); // still same } diff --git a/programs/drift/src/controller/repeg.rs b/programs/drift/src/controller/repeg.rs index f41af93fdc..7685b9ff6d 100644 --- a/programs/drift/src/controller/repeg.rs +++ b/programs/drift/src/controller/repeg.rs @@ -49,7 +49,7 @@ pub fn repeg( ) -> DriftResult { // for adhoc admin only repeg - if new_peg_candidate == market.amm.peg_multiplier { + if new_peg_candidate == market.amm.peg_multiplier() { return Err(ErrorCode::InvalidRepegRedundant); } let (terminal_price_before, _terminal_quote_reserves, _terminal_base_reserves) = @@ -91,7 +91,7 @@ pub fn repeg( // modify market's total fee change and peg change let cost_applied = apply_cost_to_market(market, adjustment_cost, true)?; if cost_applied { - market.amm.peg_multiplier = new_peg_candidate; + market.amm.set_peg_multiplier(new_peg_candidate); } else { return Err(ErrorCode::InvalidRepegProfitability); } @@ -201,12 +201,14 @@ pub fn _update_amm( cp_curve::update_k( market, &UpdateKResult { - sqrt_k: repegged_market.amm.sqrt_k, - base_asset_reserve: repegged_market.amm.base_asset_reserve, - quote_asset_reserve: repegged_market.amm.quote_asset_reserve, + sqrt_k: repegged_market.amm.sqrt_k(), + base_asset_reserve: repegged_market.amm.base_asset_reserve(), + quote_asset_reserve: repegged_market.amm.quote_asset_reserve(), }, )?; - market.amm.peg_multiplier = repegged_market.amm.peg_multiplier; + market + .amm + .set_peg_multiplier(repegged_market.amm.peg_multiplier()); amm_update_cost = repegged_cost; } else { msg!("amm_not_successfully_updated = true (repeg cost not applied for check_lower_bound={})", check_lower_bound); @@ -291,28 +293,34 @@ pub fn apply_cost_to_market( // Reduce pnl to quote asset precision and take the absolute value if cost > 0 { let new_total_fee_minus_distributions = - market.amm.total_fee_minus_distributions.safe_sub(cost)?; + market.amm.total_fee_minus_distributions().safe_sub(cost)?; let fee_reserved_for_protocol = repeg::get_total_fee_lower_bound(market)? - .safe_add(market.amm.total_liquidation_fee)? - .safe_sub(market.amm.total_fee_withdrawn)? + .safe_add(market.amm.total_liquidation_fee())? + .safe_sub(market.amm.total_fee_withdrawn())? .cast::()?; // Only a portion of the protocol fees are allocated to repegging // This checks that the total_fee_minus_distributions does not decrease too much after repeg if check_lower_bound { if new_total_fee_minus_distributions >= fee_reserved_for_protocol { - market.amm.total_fee_minus_distributions = new_total_fee_minus_distributions; + market + .amm + .set_total_fee_minus_distributions(new_total_fee_minus_distributions); } else { return Ok(false); } } else { - market.amm.total_fee_minus_distributions = new_total_fee_minus_distributions; + market + .amm + .set_total_fee_minus_distributions(new_total_fee_minus_distributions); } } else { - market.amm.total_fee_minus_distributions = market - .amm - .total_fee_minus_distributions - .safe_add(cost.abs())?; + market.amm.set_total_fee_minus_distributions( + market + .amm + .total_fee_minus_distributions() + .safe_add(cost.abs())?, + ); } market.amm.net_revenue_since_last_funding = market @@ -349,24 +357,24 @@ pub fn settle_expired_market( )?; validate!( - market.amm.base_asset_amount_with_unsettled_lp == 0, + market.amm.base_asset_amount_with_unsettled_lp() == 0, ErrorCode::MarketSettlementRequiresSettledLP, "Outstanding LP in market" )?; let spot_market = &mut spot_market_map.get_ref_mut("E_SPOT_MARKET_INDEX)?; let fee_reserved_for_protocol = repeg::get_total_fee_lower_bound(market)? - .safe_add(market.amm.total_liquidation_fee)? - .safe_sub(market.amm.total_fee_withdrawn)? + .safe_add(market.amm.total_liquidation_fee())? + .safe_sub(market.amm.total_fee_withdrawn())? .cast::()?; let budget = market .amm - .total_fee_minus_distributions + .total_fee_minus_distributions() .safe_sub(fee_reserved_for_protocol)? .max(0); let available_fee_pool = get_token_amount( - market.amm.fee_pool.scaled_balance, + market.amm.fee_pool.scaled_balance(), spot_market, &SpotBalanceType::Deposit, )? @@ -400,7 +408,7 @@ pub fn settle_expired_market( K_BPS_UPDATE_SCALE, )?; - let new_sqrt_k = bn::U192::from(market.amm.sqrt_k) + let new_sqrt_k = bn::U192::from(market.amm.sqrt_k()) .safe_mul(bn::U192::from(k_scale_numerator))? .safe_div(bn::U192::from(k_scale_denominator))? .min(bn::U192::from(MAX_SQRT_K)); @@ -447,13 +455,13 @@ pub fn settle_expired_market( )?; let pnl_pool_token_amount = get_token_amount( - market.pnl_pool.scaled_balance, + market.pnl_pool.scaled_balance(), spot_market, market.pnl_pool.balance_type(), )?; let fee_pool_token_amount = get_token_amount( - market.amm.fee_pool.scaled_balance, + market.amm.fee_pool.scaled_balance(), spot_market, market.amm.fee_pool.balance_type(), )?; diff --git a/programs/drift/src/controller/repeg/tests.rs b/programs/drift/src/controller/repeg/tests.rs index cc369c25e1..534bb23a4d 100644 --- a/programs/drift/src/controller/repeg/tests.rs +++ b/programs/drift/src/controller/repeg/tests.rs @@ -18,12 +18,12 @@ use crate::state::user::MarketType; pub fn update_amm_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 65 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 63015384615, - terminal_quote_asset_reserve: 64 * AMM_RESERVE_PRECISION, - sqrt_k: 64 * AMM_RESERVE_PRECISION, - peg_multiplier: 19_400 * PEG_PRECISION, - base_asset_amount_with_amm: -(AMM_RESERVE_PRECISION as i128), + base_asset_reserve: (65 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: 63015384615.into(), + terminal_quote_asset_reserve: (64 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (64 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (19_400 * PEG_PRECISION).into(), + base_asset_amount_with_amm: (-(AMM_RESERVE_PRECISION as i128)).into(), mark_std: PRICE_PRECISION as u64, last_mark_price_twap_ts: 0, historical_oracle_data: HistoricalOracleData { @@ -35,7 +35,7 @@ pub fn update_amm_test() { base_spread: 250, curve_update_intensity: 100, max_spread: 55500, - concentration_coef: 31020710, //unrealistic but for poc + concentration_coef: 31020710.into(), //unrealistic but for poc ..AMM::default() }, status: MarketStatus::Initialized, @@ -48,10 +48,14 @@ pub fn update_amm_test() { // market.amm.terminal_quote_asset_reserve = new_terminal_quote_reserve; assert_eq!(new_terminal_quote_reserve, 64000000000); let (min_base_asset_reserve, max_base_asset_reserve) = - amm::calculate_bid_ask_bounds(market.amm.concentration_coef, new_terminal_base_reserve) + amm::calculate_bid_ask_bounds(market.amm.concentration_coef(), new_terminal_base_reserve) .unwrap(); - market.amm.min_base_asset_reserve = min_base_asset_reserve; - market.amm.max_base_asset_reserve = max_base_asset_reserve; + market + .amm + .set_min_base_asset_reserve(min_base_asset_reserve); + market + .amm + .set_max_base_asset_reserve(max_base_asset_reserve); let state = State { oracle_guard_rails: OracleGuardRails { @@ -104,7 +108,7 @@ pub fn update_amm_test() { let cost_of_update = _update_amm(&mut market, &mm_oracle_price_data, &state, now, slot).unwrap(); - assert_eq!(market.amm.sqrt_k, 63936000000); + assert_eq!(market.amm.sqrt_k(), 63936000000); let is_oracle_valid = oracle::oracle_validity( MarketType::Perp, market.market_index, @@ -150,8 +154,8 @@ pub fn update_amm_test() { .unwrap(); assert!(too_diverge); - let profit = market.amm.total_fee_minus_distributions; - let peg = market.amm.peg_multiplier; + let profit = market.amm.total_fee_minus_distributions(); + let peg = market.amm.peg_multiplier(); assert_eq!(-cost_of_update, profit); assert!(is_oracle_valid); assert!(profit < 0); @@ -184,15 +188,15 @@ pub fn update_amm_test() { pub fn update_amm_test_bad_oracle() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 65 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 630153846154000, - terminal_quote_asset_reserve: 64 * AMM_RESERVE_PRECISION, - sqrt_k: 64 * AMM_RESERVE_PRECISION, - peg_multiplier: 19_400_000, - base_asset_amount_with_amm: -(AMM_RESERVE_PRECISION as i128), + base_asset_reserve: (65 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: 630153846154000.into(), + terminal_quote_asset_reserve: (64 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (64 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 19_400_000.into(), + base_asset_amount_with_amm: (-(AMM_RESERVE_PRECISION as i128)).into(), mark_std: PRICE_PRECISION as u64, last_mark_price_twap_ts: 0, - concentration_coef: 1020710, + concentration_coef: 1020710.into(), historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: 19_400 * PRICE_PRECISION_I64, ..HistoricalOracleData::default() @@ -263,7 +267,7 @@ pub fn update_amm_larg_conf_test() { let slot = 81680085; let mut market = PerpMarket::default_btc_test(); - assert_eq!(market.amm.base_asset_amount_with_amm, -1000000000); + assert_eq!(market.amm.base_asset_amount_with_amm(), -1000000000); let state = State { oracle_guard_rails: OracleGuardRails { @@ -332,7 +336,7 @@ pub fn update_amm_larg_conf_test() { assert_eq!(mrk, 18849999999); assert_eq!(market.amm.long_spread, 2237); - assert_eq!(market.amm.peg_multiplier, 19443664550); + assert_eq!(market.amm.peg_multiplier(), 19443664550); assert_eq!(market.amm.short_spread, 26454); // add move lower @@ -345,16 +349,16 @@ pub fn update_amm_larg_conf_test() { }; let fee_budget = calculate_fee_pool(&market).unwrap(); - assert_eq!(market.amm.total_fee_minus_distributions, 42992787); + assert_eq!(market.amm.total_fee_minus_distributions(), 42992787); assert_eq!(fee_budget, 42992787); let optimal_peg = calculate_peg_from_target_price( - market.amm.quote_asset_reserve, - market.amm.base_asset_reserve, + market.amm.quote_asset_reserve(), + market.amm.base_asset_reserve(), oracle_price_data.price as u64, ) .unwrap(); - assert_eq!(market.amm.peg_multiplier, 19443664550); + assert_eq!(market.amm.peg_multiplier(), 19443664550); assert_eq!(optimal_peg, 19412719726); let optimal_peg_cost = calculate_repeg_cost(&market.amm, optimal_peg).unwrap(); @@ -412,9 +416,11 @@ pub fn update_amm_larg_conf_w_neg_tfmd_test() { let slot = 81680085; let mut market = PerpMarket::default_btc_test(); - market.amm.concentration_coef = 1414213; - market.amm.total_fee_minus_distributions = -(10000 * QUOTE_PRECISION as i128); - assert_eq!(market.amm.base_asset_amount_with_amm, -1000000000); + market.amm.set_concentration_coef(1414213); + market + .amm + .set_total_fee_minus_distributions(-(10000 * QUOTE_PRECISION as i128)); + assert_eq!(market.amm.base_asset_amount_with_amm(), -1000000000); let state = State { oracle_guard_rails: OracleGuardRails { @@ -448,25 +454,25 @@ pub fn update_amm_larg_conf_w_neg_tfmd_test() { assert_eq!(market.amm.long_spread, 0); assert_eq!(market.amm.short_spread, 0); assert_eq!(market.amm.last_update_slot, 0); - assert_eq!(market.amm.sqrt_k, 64000000000); - let prev_peg_multiplier = market.amm.peg_multiplier; - let prev_total_fee_minus_distributions = market.amm.total_fee_minus_distributions; + assert_eq!(market.amm.sqrt_k(), 64000000000); + let prev_peg_multiplier = market.amm.peg_multiplier(); + let prev_total_fee_minus_distributions = market.amm.total_fee_minus_distributions(); let cost_of_update = _update_amm(&mut market, &mm_oracle_price_data, &state, now, slot).unwrap(); assert!(market.amm.is_recent_oracle_valid(slot).unwrap()); assert_eq!(cost_of_update, -42992787); // amm wins when price increases - assert_eq!(market.amm.sqrt_k, 64000000000); - assert_eq!(market.amm.base_asset_reserve, 65000000000); - assert_eq!(market.amm.quote_asset_reserve, 63015384615); - assert_eq!(market.amm.terminal_quote_asset_reserve, 64000000000); - assert_eq!(market.amm.min_base_asset_reserve, 45254851991); - assert_eq!(market.amm.max_base_asset_reserve, 90509632000); - assert_eq!(market.amm.peg_multiplier, 19443664550); - assert_eq!(market.amm.peg_multiplier > prev_peg_multiplier, true); - assert_eq!(market.amm.total_fee_minus_distributions, -9957007213); + assert_eq!(market.amm.sqrt_k(), 64000000000); + assert_eq!(market.amm.base_asset_reserve(), 65000000000); + assert_eq!(market.amm.quote_asset_reserve(), 63015384615); + assert_eq!(market.amm.terminal_quote_asset_reserve(), 64000000000); + assert_eq!(market.amm.min_base_asset_reserve(), 45254851991); + assert_eq!(market.amm.max_base_asset_reserve(), 90509632000); + assert_eq!(market.amm.peg_multiplier(), 19443664550); + assert_eq!(market.amm.peg_multiplier() > prev_peg_multiplier, true); + assert_eq!(market.amm.total_fee_minus_distributions(), -9957007213); assert_eq!( - market.amm.total_fee_minus_distributions > prev_total_fee_minus_distributions, + market.amm.total_fee_minus_distributions() > prev_total_fee_minus_distributions, true ); @@ -529,37 +535,37 @@ pub fn update_amm_larg_conf_w_neg_tfmd_test() { .unwrap(); let fee_budget = calculate_fee_pool(&market).unwrap(); - assert_eq!(market.amm.total_fee_minus_distributions, -9957007213); + assert_eq!(market.amm.total_fee_minus_distributions(), -9957007213); assert_eq!(fee_budget, 0); let optimal_peg = calculate_peg_from_target_price( - market.amm.quote_asset_reserve, - market.amm.base_asset_reserve, + market.amm.quote_asset_reserve(), + market.amm.base_asset_reserve(), oracle_price_data.price as u64, ) .unwrap(); - assert_eq!(market.amm.peg_multiplier, 19443664550); + assert_eq!(market.amm.peg_multiplier(), 19443664550); assert_eq!(optimal_peg, 19412719726); let optimal_peg_cost = calculate_repeg_cost(&market.amm, optimal_peg).unwrap(); assert_eq!(optimal_peg_cost, 30468749); - let prev_peg_multiplier = market.amm.peg_multiplier; - let prev_total_fee_minus_distributions = market.amm.total_fee_minus_distributions; + let prev_peg_multiplier = market.amm.peg_multiplier(); + let prev_total_fee_minus_distributions = market.amm.total_fee_minus_distributions(); let cost_of_update = _update_amm(&mut market, &mm_oracle_price_data, &state, now, slot).unwrap(); assert_eq!(cost_of_update, 21459587); // amm loses when price decreases (given users are net short) - assert_eq!(market.amm.sqrt_k, 63936000000); // k lowered since cost_of_update is positive and total_fee_minus_distributions negative - assert_eq!(market.amm.base_asset_reserve, 64935000065); - assert_eq!(market.amm.quote_asset_reserve, 62952369167); - assert_eq!(market.amm.terminal_quote_asset_reserve, 63936999950); - assert_eq!(market.amm.min_base_asset_reserve, 45208890078); - assert_eq!(market.amm.max_base_asset_reserve, 90417708246); - assert_eq!(market.amm.peg_multiplier, 19421869997); - assert_eq!(market.amm.peg_multiplier < prev_peg_multiplier, true); + assert_eq!(market.amm.sqrt_k(), 63936000000); // k lowered since cost_of_update is positive and total_fee_minus_distributions negative + assert_eq!(market.amm.base_asset_reserve(), 64935000065); + assert_eq!(market.amm.quote_asset_reserve(), 62952369167); + assert_eq!(market.amm.terminal_quote_asset_reserve(), 63936999950); + assert_eq!(market.amm.min_base_asset_reserve(), 45208890078); + assert_eq!(market.amm.max_base_asset_reserve(), 90417708246); + assert_eq!(market.amm.peg_multiplier(), 19421869997); + assert_eq!(market.amm.peg_multiplier() < prev_peg_multiplier, true); // assert_eq!(market.amm.total_fee_minus_distributions, -9978167413); assert_eq!( - market.amm.total_fee_minus_distributions < prev_total_fee_minus_distributions, + market.amm.total_fee_minus_distributions() < prev_total_fee_minus_distributions, true ); diff --git a/programs/drift/src/controller/revenue_share.rs b/programs/drift/src/controller/revenue_share.rs index 61681cd7a4..8adedabd26 100644 --- a/programs/drift/src/controller/revenue_share.rs +++ b/programs/drift/src/controller/revenue_share.rs @@ -70,7 +70,7 @@ pub fn sweep_completed_revenue_share_for_market<'a>( } let pnl_pool_token_amount = get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), quote_spot_market, perp_market.pnl_pool.balance_type(), )?; diff --git a/programs/drift/src/controller/spot_balance.rs b/programs/drift/src/controller/spot_balance.rs index f8e1b625e9..95f06c19e1 100644 --- a/programs/drift/src/controller/spot_balance.rs +++ b/programs/drift/src/controller/spot_balance.rs @@ -39,13 +39,13 @@ pub fn update_spot_market_twap_stats( let from_start = max(1_i64, SPOT_MARKET_TOKEN_TWAP_WINDOW.safe_sub(since_last)?); let deposit_token_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), spot_market, &SpotBalanceType::Deposit, )?; let borrow_token_amount = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), spot_market, &SpotBalanceType::Borrow, )?; @@ -151,18 +151,22 @@ pub fn update_spot_market_cumulative_interest( deposit_interest.safe_sub(deposit_interest_for_stakers)?; if deposit_interest_for_lenders > 0 { - spot_market.cumulative_deposit_interest = spot_market - .cumulative_deposit_interest - .safe_add(deposit_interest_for_lenders)?; - - spot_market.cumulative_borrow_interest = spot_market - .cumulative_borrow_interest - .safe_add(borrow_interest)?; + spot_market.set_cumulative_deposit_interest( + spot_market + .cumulative_deposit_interest() + .safe_add(deposit_interest_for_lenders)?, + ); + + spot_market.set_cumulative_borrow_interest( + spot_market + .cumulative_borrow_interest() + .safe_add(borrow_interest)?, + ); spot_market.last_interest_ts = now.cast()?; // add deposit_interest_for_stakers as balance for revenue_pool let token_amount = get_interest_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), spot_market, deposit_interest_for_stakers, )?; @@ -172,10 +176,10 @@ pub fn update_spot_market_cumulative_interest( emit!(SpotInterestRecord { ts: now, market_index: spot_market.market_index, - deposit_balance: spot_market.deposit_balance, - cumulative_deposit_interest: spot_market.cumulative_deposit_interest, - borrow_balance: spot_market.borrow_balance, - cumulative_borrow_interest: spot_market.cumulative_borrow_interest, + deposit_balance: spot_market.deposit_balance(), + cumulative_deposit_interest: spot_market.cumulative_deposit_interest(), + borrow_balance: spot_market.borrow_balance(), + cumulative_borrow_interest: spot_market.cumulative_borrow_interest(), optimal_utilization: spot_market.optimal_utilization, optimal_borrow_rate: spot_market.optimal_borrow_rate, max_borrow_rate: spot_market.max_borrow_rate, @@ -261,13 +265,13 @@ pub fn update_spot_balances( if is_leaving_drift && update_direction == &SpotBalanceType::Borrow { let deposit_token_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), spot_market, &SpotBalanceType::Deposit, )?; let borrow_token_amount = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), spot_market, &SpotBalanceType::Borrow, )?; @@ -302,10 +306,10 @@ pub fn transfer_spot_balances( if from_spot_balance.balance_type() == &SpotBalanceType::Deposit { validate!( - spot_market.deposit_balance >= from_spot_balance.balance(), + spot_market.deposit_balance() >= from_spot_balance.balance(), ErrorCode::InvalidSpotMarketState, "spot_market.deposit_balance={} lower than individual spot balance={}", - spot_market.deposit_balance, + spot_market.deposit_balance(), from_spot_balance.balance() )?; } @@ -435,10 +439,10 @@ fn increase_spot_balance( ) -> DriftResult { match balance_type { SpotBalanceType::Deposit => { - spot_market.deposit_balance = spot_market.deposit_balance.safe_add(delta)? + spot_market.set_deposit_balance(spot_market.deposit_balance().safe_add(delta)?) } SpotBalanceType::Borrow => { - spot_market.borrow_balance = spot_market.borrow_balance.safe_add(delta)? + spot_market.set_borrow_balance(spot_market.borrow_balance().safe_add(delta)?) } } @@ -452,10 +456,10 @@ fn decrease_spot_balance( ) -> DriftResult { match balance_type { SpotBalanceType::Deposit => { - spot_market.deposit_balance = spot_market.deposit_balance.safe_sub(delta)? + spot_market.set_deposit_balance(spot_market.deposit_balance().safe_sub(delta)?) } SpotBalanceType::Borrow => { - spot_market.borrow_balance = spot_market.borrow_balance.safe_sub(delta)? + spot_market.set_borrow_balance(spot_market.borrow_balance().safe_sub(delta)?) } } diff --git a/programs/drift/src/controller/spot_balance/tests.rs b/programs/drift/src/controller/spot_balance/tests.rs index b1c19153c1..844b90925a 100644 --- a/programs/drift/src/controller/spot_balance/tests.rs +++ b/programs/drift/src/controller/spot_balance/tests.rs @@ -72,19 +72,19 @@ fn test_daily_withdraw_limits() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -102,14 +102,14 @@ fn test_daily_withdraw_limits() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64 / 2, status: MarketStatus::Active, @@ -120,15 +120,15 @@ fn test_daily_withdraw_limits() { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 10, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), deposit_token_twap: (SPOT_BALANCE_PRECISION * 10) as u64, borrow_token_twap: 0, @@ -159,11 +159,11 @@ fn test_daily_withdraw_limits() { let amount: u64 = QUOTE_PRECISION as u64; assert_eq!( - spot_market.cumulative_deposit_interest, + spot_market.cumulative_deposit_interest(), SPOT_CUMULATIVE_INTEREST_PRECISION ); assert_eq!( - spot_market.cumulative_borrow_interest, + spot_market.cumulative_borrow_interest(), SPOT_CUMULATIVE_INTEREST_PRECISION ); @@ -181,13 +181,13 @@ fn test_daily_withdraw_limits() { .is_err()); spot_market = spot_market_backup; user = user_backup; - assert_eq!(spot_market.deposit_balance, SPOT_BALANCE_PRECISION); + assert_eq!(spot_market.deposit_balance(), SPOT_BALANCE_PRECISION); // .50 * .2 = .1 assert_eq!(spot_market.deposit_token_twap, 500000); assert_eq!(user.spot_positions[0].scaled_balance, 1000000000); - assert_eq!(spot_market.deposit_balance, 1000000000); - assert_eq!(spot_market.borrow_balance, 0); + assert_eq!(spot_market.deposit_balance(), 1000000000); + assert_eq!(spot_market.borrow_balance(), 0); assert_eq!((amount / 2), 500000); update_spot_balances_and_cumulative_deposits_with_limits( (amount / 2) as u128, @@ -198,8 +198,8 @@ fn test_daily_withdraw_limits() { .unwrap(); assert_eq!(user.spot_positions[0].scaled_balance, 499999999); assert_eq!(spot_market.deposit_token_twap, 500000); - assert_eq!(spot_market.deposit_balance, 499999999); - assert_eq!(spot_market.borrow_balance, 0); + assert_eq!(spot_market.deposit_balance(), 499999999); + assert_eq!(spot_market.borrow_balance(), 0); // .50 * .25 = .125 update_spot_balances_and_cumulative_deposits_with_limits( @@ -222,7 +222,7 @@ fn test_daily_withdraw_limits() { .is_err()); spot_market = spot_market_backup; user = user_backup; - assert_eq!(spot_market.deposit_balance, 375001998); + assert_eq!(spot_market.deposit_balance(), 375001998); assert_eq!(user.spot_positions[0].scaled_balance, 375001998); assert_eq!(user.spot_positions[0].market_index, 0); @@ -245,7 +245,7 @@ fn test_daily_withdraw_limits() { &mut user, ) .unwrap(); - assert_eq!(spot_market.deposit_balance, 100000375001998); + assert_eq!(spot_market.deposit_balance(), 100000375001998); assert_eq!(user.spot_positions[0].scaled_balance, 100000375001998); assert_eq!(user.spot_positions[1].scaled_balance, 0); @@ -268,7 +268,7 @@ fn test_daily_withdraw_limits() { }), ..User::default() }; - sol_spot_market.deposit_balance = 50 * SPOT_BALANCE_PRECISION; + sol_spot_market.set_deposit_balance(50 * SPOT_BALANCE_PRECISION); sol_spot_market.deposit_token_twap = (500 * SPOT_BALANCE_PRECISION) as u64; sol_spot_market.optimal_utilization = 1_000_000 as u32; //20% APR @@ -344,8 +344,8 @@ fn test_daily_withdraw_limits() { ) .unwrap(); - assert_eq!(sol_spot_market.deposit_balance, 50000000000); - assert_eq!(sol_spot_market.borrow_balance, 8000000002); + assert_eq!(sol_spot_market.deposit_balance(), 50000000000); + assert_eq!(sol_spot_market.borrow_balance(), 8000000002); assert_eq!(sol_spot_market.borrow_token_twap, 0); update_spot_market_cumulative_interest(&mut sol_spot_market, None, now + 3655 * 24).unwrap(); @@ -419,14 +419,14 @@ fn test_check_withdraw_limits() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64 / 2, status: MarketStatus::Active, @@ -437,15 +437,15 @@ fn test_check_withdraw_limits() { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 10, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: 2 * SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: (2 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, deposit_token_twap: 28_000_000_000_u64, status: MarketStatus::Active, @@ -512,8 +512,8 @@ fn test_check_withdraw_limits_below_optimal_utilization() { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: 1020 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, - cumulative_borrow_interest: 1222 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + cumulative_deposit_interest: (1020 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), + cumulative_borrow_interest: (1222 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), optimal_utilization: 700000, optimal_borrow_rate: 60000, @@ -524,8 +524,8 @@ fn test_check_withdraw_limits_below_optimal_utilization() { maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: 200_000 * SPOT_BALANCE_PRECISION, // 200k sol - borrow_balance: 100_000 * SPOT_BALANCE_PRECISION, + deposit_balance: (200_000 * SPOT_BALANCE_PRECISION).into(), // 200k sol + borrow_balance: (100_000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, deposit_token_twap: 204000000000000_u64, borrow_token_twap: 122200000000000_u64, @@ -541,13 +541,13 @@ fn test_check_withdraw_limits_below_optimal_utilization() { ); // below optimal util let deposit_tokens_1 = get_token_amount( - sol_spot_market.deposit_balance, + sol_spot_market.deposit_balance(), &sol_spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_1 = get_token_amount( - sol_spot_market.borrow_balance, + sol_spot_market.borrow_balance(), &sol_spot_market, &SpotBalanceType::Borrow, ) @@ -584,11 +584,11 @@ fn test_check_withdraw_limits_below_optimal_utilization() { assert_eq!(valid_withdraw, true); // ensure it fails due to higher min_dep above - sol_spot_market.deposit_balance = 174571428571428 / 1020 * 1000; + sol_spot_market.set_deposit_balance(174571428571428 / 1020 * 1000); sol_spot_market.utilization_twap = 100000; let deposit_tokens_1 = get_token_amount( - sol_spot_market.deposit_balance, + sol_spot_market.deposit_balance(), &sol_spot_market, &SpotBalanceType::Deposit, ) @@ -613,8 +613,8 @@ fn test_check_withdraw_limits_above_optimal_utilization() { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: 1020 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, - cumulative_borrow_interest: 1222 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + cumulative_deposit_interest: (1020 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), + cumulative_borrow_interest: (1222 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), optimal_utilization: 700000, // 70% optimal_borrow_rate: 60000, // 6% @@ -625,8 +625,8 @@ fn test_check_withdraw_limits_above_optimal_utilization() { maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: 200_000 * SPOT_BALANCE_PRECISION, // 200k sol - borrow_balance: 160_000 * SPOT_BALANCE_PRECISION, + deposit_balance: (200_000 * SPOT_BALANCE_PRECISION).into(), // 200k sol + borrow_balance: (160_000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, deposit_token_twap: 204000000000000_u64, borrow_token_twap: 199200000000000_u64, @@ -642,13 +642,13 @@ fn test_check_withdraw_limits_above_optimal_utilization() { ); // below optimal util let deposit_tokens_1 = get_token_amount( - sol_spot_market.deposit_balance, + sol_spot_market.deposit_balance(), &sol_spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_1 = get_token_amount( - sol_spot_market.borrow_balance, + sol_spot_market.borrow_balance(), &sol_spot_market, &SpotBalanceType::Borrow, ) @@ -711,7 +711,7 @@ fn test_check_withdraw_limits_above_optimal_utilization() { assert_eq!(valid_withdraw, true); // now ensure it fails due to higher min_dep above - sol_spot_market.deposit_balance = min_dep / 1020 * 1000; + sol_spot_market.set_deposit_balance(min_dep / 1020 * 1000); let valid_withdraw = check_withdraw_limits(&sol_spot_market, None, None).unwrap(); assert_eq!(valid_withdraw, false); } @@ -735,19 +735,19 @@ fn check_fee_collection() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -765,13 +765,13 @@ fn check_fee_collection() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64, optimal_utilization: SPOT_UTILIZATION_PRECISION_U32 / 2, @@ -787,15 +787,15 @@ fn check_fee_collection() { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 10, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, insurance_fund: InsuranceFund { revenue_settle_period: 1, @@ -827,8 +827,8 @@ fn check_fee_collection() { spot_market.insurance_fund.total_factor = 1000; //1_000_000 assert_eq!(spot_market.utilization_twap, 0); - assert_eq!(spot_market.deposit_balance, 1000000000); - assert_eq!(spot_market.borrow_balance, 0); + assert_eq!(spot_market.deposit_balance(), 1000000000); + assert_eq!(spot_market.borrow_balance(), 0); let amount = QUOTE_PRECISION / 4; update_spot_balances_and_cumulative_deposits_with_limits( @@ -842,33 +842,33 @@ fn check_fee_collection() { assert_eq!(user.total_deposits, 0); assert_eq!(user.total_withdraws, 0); - assert_eq!(spot_market.deposit_balance, 1000000000); - assert_eq!(spot_market.borrow_balance, 125000001); + assert_eq!(spot_market.deposit_balance(), 1000000000); + assert_eq!(spot_market.borrow_balance(), 125000001); assert_eq!(spot_market.utilization_twap, 0); update_spot_market_cumulative_interest(&mut spot_market, None, now + 100).unwrap(); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); - assert_eq!(spot_market.cumulative_deposit_interest, 10000019799); - assert_eq!(spot_market.cumulative_borrow_interest, 10000158551); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); + assert_eq!(spot_market.cumulative_deposit_interest(), 10000019799); + assert_eq!(spot_market.cumulative_borrow_interest(), 10000158551); assert_eq!(spot_market.last_interest_ts, 100); assert_eq!(spot_market.last_twap_ts, 100); assert_eq!(spot_market.utilization_twap, 143); let deposit_tokens_1 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_1 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let if_tokens_1 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Borrow, ) @@ -884,24 +884,24 @@ fn check_fee_collection() { assert_eq!(spot_market.last_twap_ts, 7500); assert_eq!(spot_market.utilization_twap, 10846); - assert_eq!(spot_market.cumulative_deposit_interest, 10001484937); - assert_eq!(spot_market.cumulative_borrow_interest, 10011891454); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); + assert_eq!(spot_market.cumulative_deposit_interest(), 10001484937); + assert_eq!(spot_market.cumulative_borrow_interest(), 10011891454); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); let deposit_tokens_2 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_2 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let if_tokens_2 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Borrow, ) @@ -926,24 +926,24 @@ fn check_fee_collection() { now = now + 750 + (60 * 60 * 24 * 365); - assert_eq!(spot_market.cumulative_deposit_interest, 16257818378); - assert_eq!(spot_market.cumulative_borrow_interest, 60112684636); - assert_eq!(spot_market.revenue_pool.scaled_balance, 385045); + assert_eq!(spot_market.cumulative_deposit_interest(), 16257818378); + assert_eq!(spot_market.cumulative_borrow_interest(), 60112684636); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 385045); let deposit_tokens_3 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_3 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let if_tokens_3 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Borrow, ) @@ -964,7 +964,7 @@ fn check_fee_collection() { ); // settle IF pool to 100% utilization boundary - assert_eq!(spot_market.revenue_pool.scaled_balance, 385045); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 385045); assert_eq!(spot_market.utilization_twap, 462004); spot_market.insurance_fund.revenue_settle_period = 1; @@ -978,26 +978,26 @@ fn check_fee_collection() { .unwrap(); assert_eq!(settle_amount, 626); - assert_eq!(spot_market.insurance_fund.user_shares, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); assert_eq!(if_tokens_3 - (settle_amount as u128), 1689); - assert_eq!(spot_market.revenue_pool.scaled_balance, 0); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 0); assert_eq!(spot_market.utilization_twap, 462005); let deposit_tokens_4 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_4 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let if_tokens_4 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -1026,19 +1026,19 @@ fn check_fee_collection() { .unwrap(); let deposit_tokens_5 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_5 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let _if_tokens_5 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -1070,13 +1070,13 @@ fn check_fee_collection() { .unwrap(); let deposit_tokens_6 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_6 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) @@ -1108,19 +1108,19 @@ fn check_fee_collection_larger_nums() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -1138,13 +1138,13 @@ fn check_fee_collection_larger_nums() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 1000000 * SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: (1000000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64 / 2, optimal_utilization: SPOT_UTILIZATION_PRECISION_U32 / 2, @@ -1158,15 +1158,15 @@ fn check_fee_collection_larger_nums() { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 10, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: SPOT_BALANCE_PRECISION.into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, ..SpotMarket::default() }; @@ -1194,10 +1194,10 @@ fn check_fee_collection_larger_nums() { assert_eq!(spot_market.utilization_twap, 0); assert_eq!( - spot_market.deposit_balance, + spot_market.deposit_balance(), 1000000 * SPOT_BALANCE_PRECISION ); - assert_eq!(spot_market.borrow_balance, 0); + assert_eq!(spot_market.borrow_balance(), 0); let amount = 540510 * QUOTE_PRECISION; update_spot_balances( @@ -1210,37 +1210,37 @@ fn check_fee_collection_larger_nums() { .unwrap(); assert_eq!( - spot_market.deposit_balance, + spot_market.deposit_balance(), 1000000 * SPOT_BALANCE_PRECISION ); - assert_eq!(spot_market.borrow_balance, 540510000000001); + assert_eq!(spot_market.borrow_balance(), 540510000000001); assert_eq!(spot_market.utilization_twap, 0); update_spot_market_cumulative_interest(&mut spot_market, None, now + 100).unwrap(); let br = calculate_borrow_rate(&spot_market, spot_market.get_utilization().unwrap()).unwrap(); assert_eq!(br, 20173678); - assert_eq!(spot_market.revenue_pool.scaled_balance, 3457492406); - assert_eq!(spot_market.cumulative_deposit_interest, 10000311188); - assert_eq!(spot_market.cumulative_borrow_interest, 10000639702); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 3457492406); + assert_eq!(spot_market.cumulative_deposit_interest(), 10000311188); + assert_eq!(spot_market.cumulative_borrow_interest(), 10000639702); assert_eq!(spot_market.last_interest_ts, 100); assert_eq!(spot_market.last_twap_ts, 100); assert_eq!(spot_market.utilization_twap, 624); let deposit_tokens_1 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_1 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let if_tokens_1 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -1256,24 +1256,24 @@ fn check_fee_collection_larger_nums() { assert_eq!(spot_market.last_twap_ts, 7500); assert_eq!(spot_market.utilization_twap, 46964); - assert_eq!(spot_market.cumulative_deposit_interest, 10023340555); - assert_eq!(spot_market.cumulative_borrow_interest, 10047980763); - assert_eq!(spot_market.revenue_pool.scaled_balance, 258744322775); + assert_eq!(spot_market.cumulative_deposit_interest(), 10023340555); + assert_eq!(spot_market.cumulative_borrow_interest(), 10047980763); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 258744322775); let deposit_tokens_2 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_2 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let if_tokens_2 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -1300,24 +1300,24 @@ fn check_fee_collection_larger_nums() { assert_eq!(spot_market.get_utilization().unwrap(), 961580); - assert_eq!(spot_market.cumulative_deposit_interest, 108608729074); - assert_eq!(spot_market.cumulative_borrow_interest, 212759822472); - assert_eq!(spot_market.revenue_pool.scaled_balance, 101141669831135); + assert_eq!(spot_market.cumulative_deposit_interest(), 108608729074); + assert_eq!(spot_market.cumulative_borrow_interest(), 212759822472); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 101141669831135); let deposit_tokens_3 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_3 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let if_tokens_3 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -1340,7 +1340,7 @@ fn check_fee_collection_larger_nums() { // settle IF pool to 100% utilization boundary // only half of depositors available claim was settled (to protect vault) - assert_eq!(spot_market.revenue_pool.scaled_balance, 101141669831135); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 101141669831135); spot_market.insurance_fund.revenue_settle_period = 1; let settle_amount = settle_revenue_to_insurance_fund( deposit_tokens_3 as u64, @@ -1351,29 +1351,29 @@ fn check_fee_collection_larger_nums() { ) .unwrap(); assert_eq!(settle_amount, 229739282275); - assert_eq!(spot_market.insurance_fund.user_shares, 0); - assert_eq!(spot_market.insurance_fund.total_shares, 0); + assert_eq!(spot_market.insurance_fund.user_shares(), 0); + assert_eq!(spot_market.insurance_fund.total_shares(), 0); if_balance_2 += settle_amount; assert_eq!(if_balance_2, 229739282275); assert_eq!(if_tokens_3 - (settle_amount as u128), 868747539403); // w/ update interest for settle_spot_market_to_if - assert_eq!(spot_market.revenue_pool.scaled_balance, 79996002243946); + assert_eq!(spot_market.revenue_pool.scaled_balance(), 79996002243946); assert_eq!(spot_market.utilization_twap, 961580); let deposit_tokens_4 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), &spot_market, &SpotBalanceType::Deposit, ) .unwrap(); let borrow_tokens_4 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), &spot_market, &SpotBalanceType::Borrow, ) .unwrap(); let if_tokens_4 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), &spot_market, &SpotBalanceType::Deposit, ) @@ -1388,13 +1388,13 @@ fn test_multi_stage_borrow_rate_curve() { let spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 1_000_000 * SPOT_BALANCE_PRECISION, - borrow_balance: 0, + deposit_balance: (1_000_000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64 / 2, optimal_utilization: SPOT_UTILIZATION_PRECISION_U32 * 70 / 100, // 70% @@ -1525,15 +1525,15 @@ fn attempt_borrow_with_massive_upnl() { // sol coin let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, - quote_asset_amount: 50 * QUOTE_PRECISION_I128, - base_asset_amount_with_amm: BASE_PRECISION_I128, + quote_asset_amount: (50 * QUOTE_PRECISION_I128).into(), + base_asset_amount_with_amm: BASE_PRECISION_I128.into(), oracle: oracle_price_key, historical_oracle_data: HistoricalOracleData::default_price(oracle_price.agg.price), ..AMM::default() @@ -1553,14 +1553,14 @@ fn attempt_borrow_with_massive_upnl() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100_000_000 * SPOT_BALANCE_PRECISION, //$100M usdc - borrow_balance: 0, + deposit_balance: (100_000_000 * SPOT_BALANCE_PRECISION).into(), //$100M usdc + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64 / 2, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), status: MarketStatus::Active, @@ -1572,15 +1572,15 @@ fn attempt_borrow_with_massive_upnl() { market_index: 1, oracle_source: OracleSource::Pyth, oracle: oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 10, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, - deposit_balance: 100 * SPOT_BALANCE_PRECISION, - borrow_balance: SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: SPOT_BALANCE_PRECISION.into(), liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, status: MarketStatus::Active, @@ -1682,13 +1682,13 @@ fn check_usdc_spot_market_twap() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100_000_000 * SPOT_BALANCE_PRECISION, //$100M usdc - borrow_balance: 0, + deposit_balance: (100_000_000 * SPOT_BALANCE_PRECISION).into(), //$100M usdc + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64 / 2, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), status: MarketStatus::Active, @@ -1827,13 +1827,13 @@ fn check_spot_market_max_borrow_fraction() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100_000_000 * SPOT_BALANCE_PRECISION, //$100M usdc - borrow_balance: 0, + deposit_balance: (100_000_000 * SPOT_BALANCE_PRECISION).into(), //$100M usdc + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64 / 2, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), status: MarketStatus::Active, @@ -1851,7 +1851,7 @@ fn check_spot_market_max_borrow_fraction() { .validate_max_token_deposits_and_borrows(true) .is_ok()); - spot_market.borrow_balance = spot_market.deposit_balance; + spot_market.set_borrow_balance(spot_market.deposit_balance()); assert!(spot_market .validate_max_token_deposits_and_borrows(true) .is_ok()); @@ -1861,27 +1861,27 @@ fn check_spot_market_max_borrow_fraction() { assert!(spot_market .validate_max_token_deposits_and_borrows(true) .is_err()); - spot_market.borrow_balance = spot_market.deposit_balance / 100; + spot_market.set_borrow_balance(spot_market.deposit_balance() / 100); assert!(spot_market .validate_max_token_deposits_and_borrows(true) .is_err()); - spot_market.borrow_balance = spot_market.deposit_balance / (10000 - 2); // just above 10000th + spot_market.set_borrow_balance(spot_market.deposit_balance() / (10000 - 2)); // just above 10000th assert!(spot_market .validate_max_token_deposits_and_borrows(true) .is_err()); - spot_market.borrow_balance = spot_market.deposit_balance / (10000); // exactly 10000th of deposit + spot_market.set_borrow_balance(spot_market.deposit_balance() / (10000)); // exactly 10000th of deposit assert!(spot_market .validate_max_token_deposits_and_borrows(true) .is_ok()); - spot_market.borrow_balance = spot_market.deposit_balance / (10000 + 1); // < 10000th of deposit + spot_market.set_borrow_balance(spot_market.deposit_balance() / (10000 + 1)); // < 10000th of deposit assert!(spot_market .validate_max_token_deposits_and_borrows(true) .is_ok()); - spot_market.borrow_balance = spot_market.deposit_balance / 100000; // 1/10th of 10000 + spot_market.set_borrow_balance(spot_market.deposit_balance() / 100000); // 1/10th of 10000 assert!(spot_market .validate_max_token_deposits_and_borrows(true) .is_ok()); @@ -1896,13 +1896,13 @@ fn check_spot_market_min_borrow_rate() { let mut spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 100_000_000 * SPOT_BALANCE_PRECISION, //$100M usdc - borrow_balance: 0, + deposit_balance: (100_000_000 * SPOT_BALANCE_PRECISION).into(), //$100M usdc + borrow_balance: 0.into(), deposit_token_twap: QUOTE_PRECISION_U64 / 2, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), status: MarketStatus::Active, @@ -1928,28 +1928,28 @@ fn check_spot_market_min_borrow_rate() { assert_eq!(accum_interest.deposit_interest, 0); spot_market.min_borrow_rate = 1; // .5% - spot_market.borrow_balance = spot_market.deposit_balance / 100; + spot_market.set_borrow_balance(spot_market.deposit_balance() / 100); let accum_interest = calculate_accumulated_interest(&spot_market, now + 10000).unwrap(); assert_eq!(accum_interest.borrow_interest, 15903); assert_eq!(accum_interest.deposit_interest, 159); spot_market.min_borrow_rate = 10; // 5% - spot_market.borrow_balance = spot_market.deposit_balance / 100; + spot_market.set_borrow_balance(spot_market.deposit_balance() / 100); let accum_interest = calculate_accumulated_interest(&spot_market, now + 10000).unwrap(); assert_eq!(accum_interest.borrow_interest, 159025); assert_eq!(accum_interest.deposit_interest, 1590); spot_market.min_borrow_rate = 10; // 5% - spot_market.borrow_balance = spot_market.deposit_balance / 100; + spot_market.set_borrow_balance(spot_market.deposit_balance() / 100); let accum_interest = calculate_accumulated_interest(&spot_market, now + 1000000).unwrap(); assert_eq!(accum_interest.borrow_interest, 15855372); assert_eq!(accum_interest.deposit_interest, 158553); spot_market.min_borrow_rate = 200; // 100% - spot_market.borrow_balance = spot_market.deposit_balance / 100; + spot_market.set_borrow_balance(spot_market.deposit_balance() / 100); let accum_interest = calculate_accumulated_interest(&spot_market, now + 1000000).unwrap(); assert_eq!(accum_interest.borrow_interest, 317107433); diff --git a/programs/drift/src/controller/spot_position/tests.rs b/programs/drift/src/controller/spot_position/tests.rs index 9618d09969..fc2d3002a7 100644 --- a/programs/drift/src/controller/spot_position/tests.rs +++ b/programs/drift/src/controller/spot_position/tests.rs @@ -31,7 +31,7 @@ mod update_spot_position_balance { fn borrow() { let mut user = User::default(); let mut spot_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -55,7 +55,7 @@ mod update_spot_position_balance { let mut user2 = User::default(); let mut spot_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; @@ -111,12 +111,12 @@ mod update_spot_position_balance { }; let mut spot_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_quote_market() }; let mut sol_market = SpotMarket { - deposit_balance: 101 * SPOT_BALANCE_PRECISION, + deposit_balance: (101 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default_base_market() }; diff --git a/programs/drift/src/instructions/admin.rs b/programs/drift/src/instructions/admin.rs index 14de7e9216..1d67df8e8c 100644 --- a/programs/drift/src/instructions/admin.rs +++ b/programs/drift/src/instructions/admin.rs @@ -1,5 +1,5 @@ use crate::{msg, FeatureBitFlags}; -use anchor_lang::prelude::*; +use anchor_lang::prelude::{borsh::BorshDeserialize, *}; use anchor_spl::token_2022::Token2022; use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; use phoenix::quantities::WrapperU64; @@ -313,7 +313,7 @@ pub fn handle_initialize_spot_market( mint: ctx.accounts.spot_market_mint.key(), vault: ctx.accounts.spot_market_vault.key(), revenue_pool: PoolBalance { - scaled_balance: 0, + scaled_balance: 0.into(), market_index: spot_market_index, ..PoolBalance::default() }, // in base asset @@ -321,16 +321,16 @@ pub fn handle_initialize_spot_market( optimal_utilization, optimal_borrow_rate, max_borrow_rate, - deposit_balance: 0, - borrow_balance: 0, + deposit_balance: 0.into(), + borrow_balance: 0.into(), max_token_deposits: 0, deposit_token_twap: 0, borrow_token_twap: 0, utilization_twap: 0, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - total_social_loss: 0, - total_quote_social_loss: 0, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + total_social_loss: 0.into(), + total_quote_social_loss: 0.into(), last_interest_ts: now, last_twap_ts: now, initial_asset_weight, @@ -348,7 +348,7 @@ pub fn handle_initialize_spot_market( next_fill_record_id: 1, next_deposit_record_id: 1, spot_fee_pool: PoolBalance::default(), // in quote asset - total_spot_fee: 0, + total_spot_fee: 0.into(), orders_enabled: spot_market_index != 0, paused_operations: 0, if_paused_operations: 0, @@ -1007,16 +1007,16 @@ pub fn handle_initialize_perp_market( amm: AMM { oracle: *ctx.accounts.oracle.key, oracle_source, - base_asset_reserve: amm_base_asset_reserve, - quote_asset_reserve: amm_quote_asset_reserve, - terminal_quote_asset_reserve: amm_quote_asset_reserve, - ask_base_asset_reserve: amm_base_asset_reserve, - ask_quote_asset_reserve: amm_quote_asset_reserve, - bid_base_asset_reserve: amm_base_asset_reserve, - bid_quote_asset_reserve: amm_quote_asset_reserve, - cumulative_funding_rate_long: 0, - cumulative_funding_rate_short: 0, - total_social_loss: 0, + base_asset_reserve: amm_base_asset_reserve.into(), + quote_asset_reserve: amm_quote_asset_reserve.into(), + terminal_quote_asset_reserve: amm_quote_asset_reserve.into(), + ask_base_asset_reserve: amm_base_asset_reserve.into(), + ask_quote_asset_reserve: amm_quote_asset_reserve.into(), + bid_base_asset_reserve: amm_base_asset_reserve.into(), + bid_quote_asset_reserve: amm_quote_asset_reserve.into(), + cumulative_funding_rate_long: 0.into(), + cumulative_funding_rate_short: 0.into(), + total_social_loss: 0.into(), last_funding_rate: 0, last_funding_rate_long: 0, last_funding_rate_short: 0, @@ -1026,17 +1026,17 @@ pub fn handle_initialize_perp_market( last_mark_price_twap: init_reserve_price, last_mark_price_twap_5min: init_reserve_price, last_mark_price_twap_ts: now, - sqrt_k: amm_base_asset_reserve, - concentration_coef, - min_base_asset_reserve, - max_base_asset_reserve, - peg_multiplier: amm_peg_multiplier, - total_fee: 0, - total_fee_withdrawn: 0, - total_fee_minus_distributions: 0, - total_mm_fee: 0, - total_exchange_fee: 0, - total_liquidation_fee: 0, + sqrt_k: amm_base_asset_reserve.into(), + concentration_coef: concentration_coef.into(), + min_base_asset_reserve: min_base_asset_reserve.into(), + max_base_asset_reserve: max_base_asset_reserve.into(), + peg_multiplier: amm_peg_multiplier.into(), + total_fee: 0.into(), + total_fee_withdrawn: 0.into(), + total_fee_minus_distributions: 0.into(), + total_mm_fee: 0.into(), + total_exchange_fee: 0.into(), + total_liquidation_fee: 0.into(), net_revenue_since_last_funding: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price: oracle_price, @@ -1061,15 +1061,15 @@ pub fn handle_initialize_perp_market( max_spread, last_bid_price_twap: init_reserve_price, last_ask_price_twap: init_reserve_price, - base_asset_amount_with_amm: 0, - base_asset_amount_long: 0, - base_asset_amount_short: 0, - quote_asset_amount: 0, - quote_entry_amount_long: 0, - quote_entry_amount_short: 0, - quote_break_even_amount_long: 0, - quote_break_even_amount_short: 0, - max_open_interest, + base_asset_amount_with_amm: 0.into(), + base_asset_amount_long: 0.into(), + base_asset_amount_short: 0.into(), + quote_asset_amount: 0.into(), + quote_entry_amount_long: 0.into(), + quote_entry_amount_short: 0.into(), + quote_break_even_amount_long: 0.into(), + quote_break_even_amount_short: 0.into(), + max_open_interest: max_open_interest.into(), mark_std: 0, oracle_std: 0, volume_24h: 0, @@ -1079,13 +1079,13 @@ pub fn handle_initialize_perp_market( last_trade_ts: now, curve_update_intensity, fee_pool: PoolBalance::default(), - base_asset_amount_per_lp: 0, - quote_asset_amount_per_lp: 0, + base_asset_amount_per_lp: 0.into(), + quote_asset_amount_per_lp: 0.into(), last_update_slot: clock_slot, // lp stuff - base_asset_amount_with_unsettled_lp: 0, - user_lp_shares: 0, + base_asset_amount_with_unsettled_lp: 0.into(), + user_lp_shares: 0.into(), amm_jit_intensity, last_oracle_valid: false, @@ -1250,16 +1250,16 @@ pub fn handle_delete_initialized_spot_market( "spot_market.status != Initialized", )?; validate!( - spot_market.deposit_balance == 0, + spot_market.deposit_balance() == 0, ErrorCode::InvalidMarketAccountforDeletion, "spot_market.number_of_users={} != 0", - spot_market.deposit_balance, + spot_market.deposit_balance(), )?; validate!( - spot_market.borrow_balance == 0, + spot_market.borrow_balance() == 0, ErrorCode::InvalidMarketAccountforDeletion, "spot_market.borrow_balance={} != 0", - spot_market.borrow_balance, + spot_market.borrow_balance(), )?; validate!( spot_market.market_index == market_index, @@ -1557,20 +1557,20 @@ pub fn handle_move_amm_price( perp_market.market_index ); - let base_asset_reserve_before = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve; - let sqrt_k_before = perp_market.amm.sqrt_k; - let max_base_asset_reserve_before = perp_market.amm.max_base_asset_reserve; - let min_base_asset_reserve_before = perp_market.amm.min_base_asset_reserve; + let base_asset_reserve_before = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve(); + let sqrt_k_before = perp_market.amm.sqrt_k(); + let max_base_asset_reserve_before = perp_market.amm.max_base_asset_reserve(); + let min_base_asset_reserve_before = perp_market.amm.min_base_asset_reserve(); controller::amm::move_price(perp_market, base_asset_reserve, quote_asset_reserve, sqrt_k)?; validate_perp_market(perp_market)?; - let base_asset_reserve_after = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_after = perp_market.amm.quote_asset_reserve; - let sqrt_k_after = perp_market.amm.sqrt_k; - let max_base_asset_reserve_after = perp_market.amm.max_base_asset_reserve; - let min_base_asset_reserve_after = perp_market.amm.min_base_asset_reserve; + let base_asset_reserve_after = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_after = perp_market.amm.quote_asset_reserve(); + let sqrt_k_after = perp_market.amm.sqrt_k(); + let max_base_asset_reserve_after = perp_market.amm.max_base_asset_reserve(); + let min_base_asset_reserve_after = perp_market.amm.min_base_asset_reserve(); msg!( "base_asset_reserve {} -> {}", @@ -1616,22 +1616,22 @@ pub fn handle_recenter_perp_market_amm( perp_market.market_index ); - let base_asset_reserve_before = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve; - let sqrt_k_before = perp_market.amm.sqrt_k; - let peg_multiplier_before = perp_market.amm.peg_multiplier; - let max_base_asset_reserve_before = perp_market.amm.max_base_asset_reserve; - let min_base_asset_reserve_before = perp_market.amm.min_base_asset_reserve; + let base_asset_reserve_before = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve(); + let sqrt_k_before = perp_market.amm.sqrt_k(); + let peg_multiplier_before = perp_market.amm.peg_multiplier(); + let max_base_asset_reserve_before = perp_market.amm.max_base_asset_reserve(); + let min_base_asset_reserve_before = perp_market.amm.min_base_asset_reserve(); controller::amm::recenter_perp_market_amm(perp_market, peg_multiplier, sqrt_k)?; validate_perp_market(perp_market)?; - let base_asset_reserve_after = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_after = perp_market.amm.quote_asset_reserve; - let sqrt_k_after = perp_market.amm.sqrt_k; - let peg_multiplier_after = perp_market.amm.peg_multiplier; - let max_base_asset_reserve_after = perp_market.amm.max_base_asset_reserve; - let min_base_asset_reserve_after = perp_market.amm.min_base_asset_reserve; + let base_asset_reserve_after = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_after = perp_market.amm.quote_asset_reserve(); + let sqrt_k_after = perp_market.amm.sqrt_k(); + let peg_multiplier_after = perp_market.amm.peg_multiplier(); + let max_base_asset_reserve_after = perp_market.amm.max_base_asset_reserve(); + let min_base_asset_reserve_after = perp_market.amm.min_base_asset_reserve(); msg!( "base_asset_reserve {} -> {}", @@ -1690,12 +1690,12 @@ pub fn handle_recenter_perp_market_amm_crank( perp_market.market_index ); - let base_asset_reserve_before = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve; - let sqrt_k_before = perp_market.amm.sqrt_k; - let peg_multiplier_before = perp_market.amm.peg_multiplier; - let max_base_asset_reserve_before = perp_market.amm.max_base_asset_reserve; - let min_base_asset_reserve_before = perp_market.amm.min_base_asset_reserve; + let base_asset_reserve_before = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve(); + let sqrt_k_before = perp_market.amm.sqrt_k(); + let peg_multiplier_before = perp_market.amm.peg_multiplier(); + let max_base_asset_reserve_before = perp_market.amm.max_base_asset_reserve(); + let min_base_asset_reserve_before = perp_market.amm.min_base_asset_reserve(); let mut sqrt_k = sqrt_k_before; let peg_multiplier: u128 = oracle_price.cast()?; @@ -1716,12 +1716,12 @@ pub fn handle_recenter_perp_market_amm_crank( controller::amm::recenter_perp_market_amm(perp_market, peg_multiplier, sqrt_k)?; validate_perp_market(perp_market)?; - let base_asset_reserve_after = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_after = perp_market.amm.quote_asset_reserve; - let sqrt_k_after = perp_market.amm.sqrt_k; - let peg_multiplier_after = perp_market.amm.peg_multiplier; - let max_base_asset_reserve_after = perp_market.amm.max_base_asset_reserve; - let min_base_asset_reserve_after = perp_market.amm.min_base_asset_reserve; + let base_asset_reserve_after = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_after = perp_market.amm.quote_asset_reserve(); + let sqrt_k_after = perp_market.amm.sqrt_k(); + let peg_multiplier_after = perp_market.amm.peg_multiplier(); + let max_base_asset_reserve_after = perp_market.amm.max_base_asset_reserve(); + let min_base_asset_reserve_after = perp_market.amm.min_base_asset_reserve(); msg!( "base_asset_reserve {} -> {}", @@ -1836,28 +1836,39 @@ pub fn handle_update_perp_market_amm_summary_stats( msg!( "total_fee_minus_distributions: {:?} -> {:?}", - perp_market.amm.total_fee_minus_distributions, + perp_market.amm.total_fee_minus_distributions(), new_total_fee_minus_distributions, ); let fee_difference = new_total_fee_minus_distributions - .safe_sub(perp_market.amm.total_fee_minus_distributions)?; + .safe_sub(perp_market.amm.total_fee_minus_distributions())?; msg!( "perp_market.amm.total_fee: {} -> {}", - perp_market.amm.total_fee, - perp_market.amm.total_fee.saturating_add(fee_difference) + perp_market.amm.total_fee(), + perp_market.amm.total_fee().saturating_add(fee_difference) ); msg!( "perp_market.amm.total_mm_fee: {} -> {}", - perp_market.amm.total_mm_fee, - perp_market.amm.total_mm_fee.saturating_add(fee_difference) + perp_market.amm.total_mm_fee(), + perp_market + .amm + .total_mm_fee() + .saturating_add(fee_difference) ); - perp_market.amm.total_fee = perp_market.amm.total_fee.saturating_add(fee_difference); - perp_market.amm.total_mm_fee = perp_market.amm.total_mm_fee.saturating_add(fee_difference); - perp_market.amm.total_fee_minus_distributions = new_total_fee_minus_distributions; + let total_fee = perp_market.amm.total_fee(); + perp_market + .amm + .set_total_fee(total_fee.saturating_add(fee_difference)); + let total_mm_fee = perp_market.amm.total_mm_fee(); + perp_market + .amm + .set_total_mm_fee(total_mm_fee.saturating_add(fee_difference)); + perp_market + .amm + .set_total_fee_minus_distributions(new_total_fee_minus_distributions); } validate_perp_market(perp_market)?; @@ -1903,13 +1914,13 @@ pub fn handle_settle_expired_market_pools_to_revenue_pool( )?; validate!( - perp_market.amm.base_asset_amount_long == 0 - && perp_market.amm.base_asset_amount_short == 0 + perp_market.amm.base_asset_amount_long() == 0 + && perp_market.amm.base_asset_amount_short() == 0 && perp_market.number_of_users_with_base == 0, ErrorCode::DefaultError, "outstanding base_asset_amounts must be balanced {} {} {}", - perp_market.amm.base_asset_amount_long, - perp_market.amm.base_asset_amount_short, + perp_market.amm.base_asset_amount_long(), + perp_market.amm.base_asset_amount_short(), perp_market.number_of_users_with_base )?; @@ -1946,12 +1957,12 @@ pub fn handle_settle_expired_market_pools_to_revenue_pool( )?; let fee_pool_token_amount = get_token_amount( - perp_market.amm.fee_pool.scaled_balance, + perp_market.amm.fee_pool.scaled_balance(), spot_market, &SpotBalanceType::Deposit, )?; let pnl_pool_token_amount = get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), spot_market, &SpotBalanceType::Deposit, )?; @@ -2006,17 +2017,17 @@ pub fn handle_deposit_into_perp_market_fee_pool<'c: 'info, 'info>( msg!( "perp_market.amm.total_fee_minus_distributions: {:?} -> {:?}", - perp_market.amm.total_fee_minus_distributions, + perp_market.amm.total_fee_minus_distributions(), perp_market .amm - .total_fee_minus_distributions + .total_fee_minus_distributions() .safe_add(amount.cast()?)?, ); - perp_market.amm.total_fee_minus_distributions = perp_market + let total_fee_minus_distributions = perp_market.amm.total_fee_minus_distributions(); + perp_market .amm - .total_fee_minus_distributions - .safe_add(amount.cast()?)?; + .set_total_fee_minus_distributions(total_fee_minus_distributions.safe_add(amount.cast()?)?); let quote_spot_market = &mut load_mut!(ctx.accounts.quote_spot_market)?; @@ -2121,11 +2132,11 @@ pub fn handle_deposit_into_spot_market_vault<'c: 'info, 'info>( let token_precision = spot_market.get_precision(); - let cumulative_deposit_interest_before = spot_market.cumulative_deposit_interest; + let cumulative_deposit_interest_before = spot_market.cumulative_deposit_interest(); let cumulative_deposit_interest_after = deposit_token_amount_after .safe_mul(SPOT_CUMULATIVE_INTEREST_PRECISION)? - .safe_div(spot_market.deposit_balance)? + .safe_div(spot_market.deposit_balance())? .safe_mul(SPOT_BALANCE_PRECISION)? .safe_div(token_precision.cast()?)?; @@ -2137,7 +2148,7 @@ pub fn handle_deposit_into_spot_market_vault<'c: 'info, 'info>( cumulative_deposit_interest_before )?; - spot_market.cumulative_deposit_interest = cumulative_deposit_interest_after; + spot_market.set_cumulative_deposit_interest(cumulative_deposit_interest_after); controller::token::receive( &ctx.accounts.token_program, @@ -2161,7 +2172,7 @@ pub fn handle_deposit_into_spot_market_vault<'c: 'info, 'info>( emit!(SpotMarketVaultDepositRecord { ts: Clock::get()?.unix_timestamp, market_index: spot_market.market_index, - deposit_balance: spot_market.deposit_balance, + deposit_balance: spot_market.deposit_balance(), cumulative_deposit_interest_before, cumulative_deposit_interest_after, deposit_token_amount_before: deposit_token_amount_before.cast()?, @@ -2192,10 +2203,10 @@ pub fn handle_repeg_amm_curve(ctx: Context, new_peg_candidate: u128) .. } = get_oracle_price(&perp_market.amm.oracle_source, price_oracle, clock.slot)?; - let peg_multiplier_before = perp_market.amm.peg_multiplier; - let base_asset_reserve_before = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve; - let sqrt_k_before = perp_market.amm.sqrt_k; + let peg_multiplier_before = perp_market.amm.peg_multiplier(); + let base_asset_reserve_before = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve(); + let sqrt_k_before = perp_market.amm.sqrt_k(); let oracle_validity_rails = &ctx.accounts.state.oracle_guard_rails; @@ -2207,10 +2218,10 @@ pub fn handle_repeg_amm_curve(ctx: Context, new_peg_candidate: u128) oracle_validity_rails, )?; - let peg_multiplier_after = perp_market.amm.peg_multiplier; - let base_asset_reserve_after = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_after = perp_market.amm.quote_asset_reserve; - let sqrt_k_after = perp_market.amm.sqrt_k; + let peg_multiplier_after = perp_market.amm.peg_multiplier(); + let base_asset_reserve_after = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_after = perp_market.amm.quote_asset_reserve(); + let sqrt_k_after = perp_market.amm.sqrt_k(); msg!( "perp_market.amm.peg_multiplier {} -> {}", @@ -2248,12 +2259,12 @@ pub fn handle_repeg_amm_curve(ctx: Context, new_peg_candidate: u128) base_asset_reserve_after, quote_asset_reserve_after, sqrt_k_after, - base_asset_amount_long: perp_market.amm.base_asset_amount_long.unsigned_abs(), - base_asset_amount_short: perp_market.amm.base_asset_amount_short.unsigned_abs(), - base_asset_amount_with_amm: perp_market.amm.base_asset_amount_with_amm, + base_asset_amount_long: perp_market.amm.base_asset_amount_long().unsigned_abs(), + base_asset_amount_short: perp_market.amm.base_asset_amount_short().unsigned_abs(), + base_asset_amount_with_amm: perp_market.amm.base_asset_amount_with_amm(), number_of_users: perp_market.number_of_users, - total_fee: perp_market.amm.total_fee, - total_fee_minus_distributions: perp_market.amm.total_fee_minus_distributions, + total_fee: perp_market.amm.total_fee(), + total_fee_minus_distributions: perp_market.amm.total_fee_minus_distributions(), adjustment_cost, oracle_price, fill_record: 0, @@ -2372,23 +2383,23 @@ pub fn handle_update_k(ctx: Context, sqrt_k: u128) -> Result<()> { let perp_market = &mut load_mut!(ctx.accounts.perp_market)?; msg!("updating k for perp market {}", perp_market.market_index); - let base_asset_amount_long = perp_market.amm.base_asset_amount_long.unsigned_abs(); - let base_asset_amount_short = perp_market.amm.base_asset_amount_short.unsigned_abs(); - let base_asset_amount_with_amm = perp_market.amm.base_asset_amount_with_amm; + let base_asset_amount_long = perp_market.amm.base_asset_amount_long().unsigned_abs(); + let base_asset_amount_short = perp_market.amm.base_asset_amount_short().unsigned_abs(); + let base_asset_amount_with_amm = perp_market.amm.base_asset_amount_with_amm(); let number_of_users = perp_market.number_of_users_with_base; let price_before = math::amm::calculate_price( - perp_market.amm.quote_asset_reserve, - perp_market.amm.base_asset_reserve, - perp_market.amm.peg_multiplier, + perp_market.amm.quote_asset_reserve(), + perp_market.amm.base_asset_reserve(), + perp_market.amm.peg_multiplier(), )?; - let peg_multiplier_before = perp_market.amm.peg_multiplier; - let base_asset_reserve_before = perp_market.amm.base_asset_reserve; - let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve; - let sqrt_k_before = perp_market.amm.sqrt_k; + let peg_multiplier_before = perp_market.amm.peg_multiplier(); + let base_asset_reserve_before = perp_market.amm.base_asset_reserve(); + let quote_asset_reserve_before = perp_market.amm.quote_asset_reserve(); + let sqrt_k_before = perp_market.amm.sqrt_k(); - let k_increasing = sqrt_k > perp_market.amm.sqrt_k; + let k_increasing = sqrt_k > perp_market.amm.sqrt_k(); let new_sqrt_k_u192 = bn::U192::from(sqrt_k); @@ -2415,9 +2426,9 @@ pub fn handle_update_k(ctx: Context, sqrt_k: u128) -> Result<()> { if adjustment_cost > 0 { let max_cost = perp_market .amm - .total_fee_minus_distributions + .total_fee_minus_distributions() .safe_sub(get_total_fee_lower_bound(perp_market)?.cast()?)? - .safe_sub(perp_market.amm.total_fee_withdrawn.cast()?)?; + .safe_sub(perp_market.amm.total_fee_withdrawn().cast()?)?; validate!( adjustment_cost <= max_cost, @@ -2429,16 +2440,16 @@ pub fn handle_update_k(ctx: Context, sqrt_k: u128) -> Result<()> { } validate!( - !k_increasing || perp_market.amm.sqrt_k < MAX_SQRT_K, + !k_increasing || perp_market.amm.sqrt_k() < MAX_SQRT_K, ErrorCode::InvalidUpdateK, "cannot increase sqrt_k={} past MAX_SQRT_K", - perp_market.amm.sqrt_k + perp_market.amm.sqrt_k() )?; - perp_market.amm.total_fee_minus_distributions = perp_market - .amm - .total_fee_minus_distributions - .safe_sub(adjustment_cost)?; + let total_fee_minus_distributions = perp_market.amm.total_fee_minus_distributions(); + perp_market.amm.set_total_fee_minus_distributions( + total_fee_minus_distributions.safe_sub(adjustment_cost)?, + ); perp_market.amm.net_revenue_since_last_funding = perp_market .amm @@ -2448,9 +2459,9 @@ pub fn handle_update_k(ctx: Context, sqrt_k: u128) -> Result<()> { let amm = &perp_market.amm; let price_after = math::amm::calculate_price( - amm.quote_asset_reserve, - amm.base_asset_reserve, - amm.peg_multiplier, + amm.quote_asset_reserve(), + amm.base_asset_reserve(), + amm.peg_multiplier(), )?; let price_change_too_large = price_before @@ -2469,24 +2480,29 @@ pub fn handle_update_k(ctx: Context, sqrt_k: u128) -> Result<()> { return Err(ErrorCode::InvalidUpdateK.into()); } - let k_sqrt_check = bn::U192::from(amm.base_asset_reserve) - .safe_mul(bn::U192::from(amm.quote_asset_reserve))? + let k_sqrt_check = bn::U192::from(amm.base_asset_reserve()) + .safe_mul(bn::U192::from(amm.quote_asset_reserve()))? .integer_sqrt() .try_to_u128()?; let k_err = k_sqrt_check .cast::()? - .safe_sub(amm.sqrt_k.cast::()?)?; + .safe_sub(amm.sqrt_k().cast::()?)?; if k_err.unsigned_abs() > 100 { - msg!("k_err={:?}, {:?} != {:?}", k_err, k_sqrt_check, amm.sqrt_k); + msg!( + "k_err={:?}, {:?} != {:?}", + k_err, + k_sqrt_check, + amm.sqrt_k() + ); return Err(ErrorCode::InvalidUpdateK.into()); } - let peg_multiplier_after = amm.peg_multiplier; - let base_asset_reserve_after = amm.base_asset_reserve; - let quote_asset_reserve_after = amm.quote_asset_reserve; - let sqrt_k_after = amm.sqrt_k; + let peg_multiplier_after = amm.peg_multiplier(); + let base_asset_reserve_after = amm.base_asset_reserve(); + let quote_asset_reserve_after = amm.quote_asset_reserve(); + let sqrt_k_after = amm.sqrt_k(); msg!( "perp_market.amm.peg_multiplier {} -> {}", @@ -2512,8 +2528,8 @@ pub fn handle_update_k(ctx: Context, sqrt_k: u128) -> Result<()> { sqrt_k_after ); - let total_fee = amm.total_fee; - let total_fee_minus_distributions = amm.total_fee_minus_distributions; + let total_fee = amm.total_fee(); + let total_fee_minus_distributions = amm.total_fee_minus_distributions(); let OraclePriceData { price: oracle_price, @@ -3497,9 +3513,9 @@ pub fn handle_update_perp_market_concentration_coef( let perp_market = &mut load_mut!(ctx.accounts.perp_market)?; msg!("perp market {}", perp_market.market_index); - let prev_concentration_coef = perp_market.amm.concentration_coef; + let prev_concentration_coef = perp_market.amm.concentration_coef(); controller::amm::update_concentration_coef(perp_market, concentration_scale)?; - let new_concentration_coef = perp_market.amm.concentration_coef; + let new_concentration_coef = perp_market.amm.concentration_coef(); msg!( "perp_market.amm.concentration_coef: {} -> {}", @@ -3560,10 +3576,10 @@ pub fn handle_update_perp_market_reference_price_offset_deadband_pct( let liquidity_ratio = crate::math::amm_spread::calculate_inventory_liquidity_ratio_for_reference_price_offset( - perp_market.amm.base_asset_amount_with_amm, - perp_market.amm.base_asset_reserve, - perp_market.amm.min_base_asset_reserve, - perp_market.amm.max_base_asset_reserve, + perp_market.amm.base_asset_amount_with_amm(), + perp_market.amm.base_asset_reserve(), + perp_market.amm.min_base_asset_reserve(), + perp_market.amm.max_base_asset_reserve(), )?; let signed_liquidity_ratio = liquidity_ratio.safe_mul( @@ -4113,11 +4129,11 @@ pub fn handle_update_perp_market_max_open_interest( msg!( "perp_market.amm.max_open_interest: {:?} -> {:?}", - perp_market.amm.max_open_interest, + perp_market.amm.max_open_interest(), max_open_interest ); - perp_market.amm.max_open_interest = max_open_interest; + perp_market.amm.set_max_open_interest(max_open_interest); Ok(()) } @@ -4584,10 +4600,10 @@ pub fn handle_update_protocol_if_shares_transfer_config( if let Some(max_transfer_per_epoch) = max_transfer_per_epoch { msg!( "max_transfer_per_epoch: {:?} -> {:?}", - config.max_transfer_per_epoch, + config.max_transfer_per_epoch(), max_transfer_per_epoch ); - config.max_transfer_per_epoch = max_transfer_per_epoch; + config.set_max_transfer_per_epoch(max_transfer_per_epoch); } else { msg!("max_transfer_per_epoch: unchanged"); } @@ -4951,10 +4967,10 @@ pub fn handle_admin_deposit<'c: 'info, 'info>( direction: DepositDirection::Deposit, amount, oracle_price, - market_deposit_balance: spot_market.deposit_balance, - market_withdraw_balance: spot_market.borrow_balance, - market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest, - market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest, + market_deposit_balance: spot_market.deposit_balance(), + market_withdraw_balance: spot_market.borrow_balance(), + market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest(), + market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest(), total_deposits_after, total_withdraws_after, market_index, diff --git a/programs/drift/src/instructions/if_staker.rs b/programs/drift/src/instructions/if_staker.rs index bdc506abe8..2b706de701 100644 --- a/programs/drift/src/instructions/if_staker.rs +++ b/programs/drift/src/instructions/if_staker.rs @@ -95,7 +95,7 @@ pub fn handle_add_insurance_fund_stake<'c: 'info, 'info>( )?; validate!( - insurance_fund_stake.last_withdraw_request_shares == 0 + insurance_fund_stake.last_withdraw_request_shares() == 0 && insurance_fund_stake.last_withdraw_request_value == 0, ErrorCode::IFWithdrawRequestInProgress, "withdraw request in progress" @@ -187,14 +187,14 @@ pub fn handle_request_remove_insurance_fund_stake( )?; validate!( - insurance_fund_stake.last_withdraw_request_shares == 0, + insurance_fund_stake.last_withdraw_request_shares() == 0, ErrorCode::IFWithdrawRequestInProgress, "Withdraw request is already in progress" )?; let n_shares = math::insurance::vault_amount_to_if_shares( amount, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), ctx.accounts.insurance_fund_vault.amount, )?; @@ -236,7 +236,7 @@ pub fn handle_cancel_request_remove_insurance_fund_stake( )?; validate!( - insurance_fund_stake.last_withdraw_request_shares != 0, + insurance_fund_stake.last_withdraw_request_shares() != 0, ErrorCode::NoIFWithdrawRequestInProgress, "No withdraw request in progress" )?; @@ -343,7 +343,8 @@ pub fn handle_transfer_protocol_if_shares( transfer_config.update_epoch(now)?; transfer_config.validate_transfer(shares)?; - transfer_config.current_epoch_transfer += shares; + let current_epoch_transfer = transfer_config.current_epoch_transfer(); + transfer_config.set_current_epoch_transfer(current_epoch_transfer.safe_add(shares)?); let mut if_stake = ctx.accounts.insurance_fund_stake.load_mut()?; let mut user_stats = ctx.accounts.user_stats.load_mut()?; @@ -862,7 +863,7 @@ pub fn handle_deposit_into_insurance_fund_stake<'c: 'info, 'info>( )?; validate!( - insurance_fund_stake.last_withdraw_request_shares == 0 + insurance_fund_stake.last_withdraw_request_shares() == 0 && insurance_fund_stake.last_withdraw_request_value == 0, ErrorCode::IFWithdrawRequestInProgress, "withdraw request in progress" diff --git a/programs/drift/src/instructions/keeper.rs b/programs/drift/src/instructions/keeper.rs index 21d3e871e3..fb11cf1c43 100644 --- a/programs/drift/src/instructions/keeper.rs +++ b/programs/drift/src/instructions/keeper.rs @@ -3411,12 +3411,12 @@ pub fn handle_settle_perp_to_lp_pool<'c: 'info, 'info>( quote_owed_from_lp: cached_info.quote_owed_from_lp_pool, quote_constituent_token_balance: quote_constituent.vault_token_balance, fee_pool_balance: get_token_amount( - perp_market.amm.fee_pool.scaled_balance, + perp_market.amm.fee_pool.scaled_balance(), quote_market, &SpotBalanceType::Deposit, )?, pnl_pool_balance: get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), quote_market, &SpotBalanceType::Deposit, )?, @@ -3503,7 +3503,7 @@ pub fn handle_settle_perp_to_lp_pool<'c: 'info, 'info>( .last_exchange_fees .safe_sub(cached_info.last_settle_amm_ex_fees)? .cast::()?, - lp_aum: lp_pool.last_aum, + lp_aum: lp_pool.last_aum(), lp_price: lp_pool.get_price(lp_pool.token_supply)?, lp_pool: lp_pool_key, }); @@ -3525,14 +3525,19 @@ pub fn handle_settle_perp_to_lp_pool<'c: 'info, 'info>( // Update LP pool stats match settlement_result.direction { SettlementDirection::FromLpPool => { - lp_pool.cumulative_quote_sent_to_perp_markets = lp_pool - .cumulative_quote_sent_to_perp_markets - .saturating_add(settlement_result.amount_transferred as u128); + let cumulative_quote_sent = lp_pool.cumulative_quote_sent_to_perp_markets(); + lp_pool.set_cumulative_quote_sent_to_perp_markets( + cumulative_quote_sent + .saturating_add(settlement_result.amount_transferred as u128), + ); } SettlementDirection::ToLpPool => { - lp_pool.cumulative_quote_received_from_perp_markets = lp_pool - .cumulative_quote_received_from_perp_markets - .saturating_add(settlement_result.amount_transferred as u128); + let cumulative_quote_received = + lp_pool.cumulative_quote_received_from_perp_markets(); + lp_pool.set_cumulative_quote_received_from_perp_markets( + cumulative_quote_received + .saturating_add(settlement_result.amount_transferred as u128), + ); } SettlementDirection::None => {} } diff --git a/programs/drift/src/instructions/lp_admin.rs b/programs/drift/src/instructions/lp_admin.rs index 0e5225d832..428661c9a4 100644 --- a/programs/drift/src/instructions/lp_admin.rs +++ b/programs/drift/src/instructions/lp_admin.rs @@ -17,7 +17,7 @@ use crate::state::spot_market::SpotMarket; use crate::state::state::State; use crate::validate; use crate::{controller, load_mut}; -use anchor_lang::prelude::*; +use anchor_lang::prelude::{borsh::BorshDeserialize, *}; use anchor_lang::Discriminator; use anchor_spl::associated_token::AssociatedToken; use anchor_spl::token::Token; @@ -61,20 +61,20 @@ pub fn handle_initialize_lp_pool( constituent_target_base: ctx.accounts.constituent_target_base.key(), constituent_correlations: ctx.accounts.constituent_correlations.key(), constituents: 0, - max_aum, - last_aum: 0, + max_aum: max_aum.into(), + last_aum: 0.into(), last_aum_slot: 0, max_settle_quote_amount: max_settle_quote_amount_per_market, _padding: 0, - total_mint_redeem_fees_paid: 0, + total_mint_redeem_fees_paid: 0.into(), bump: ctx.bumps.lp_pool, min_mint_fee, token_supply: 0, mint_redeem_id: 1, settle_id: 1, quote_consituent_index: 0, - cumulative_quote_sent_to_perp_markets: 0, - cumulative_quote_received_from_perp_markets: 0, + cumulative_quote_sent_to_perp_markets: 0.into(), + cumulative_quote_received_from_perp_markets: 0.into(), gamma_execution: 2, volatility: 4, xi: 2, @@ -431,12 +431,12 @@ pub fn handle_update_lp_pool_params<'info>( if let Some(max_aum) = lp_pool_params.max_aum { validate!( - max_aum >= lp_pool.max_aum, + max_aum >= lp_pool.max_aum(), ErrorCode::DefaultError, "new max_aum must be greater than or equal to current max_aum" )?; - msg!("max_aum: {:?} -> {:?}", lp_pool.max_aum, max_aum); - lp_pool.max_aum = max_aum; + msg!("max_aum: {:?} -> {:?}", lp_pool.max_aum(), max_aum); + lp_pool.set_max_aum(max_aum); } Ok(()) diff --git a/programs/drift/src/instructions/lp_pool.rs b/programs/drift/src/instructions/lp_pool.rs index 3108af7ca9..287946ee0e 100644 --- a/programs/drift/src/instructions/lp_pool.rs +++ b/programs/drift/src/instructions/lp_pool.rs @@ -376,13 +376,13 @@ pub fn handle_lp_pool_swap<'c: 'info, 'info>( in_constituent.constituent_index, &in_spot_market, in_oracle.price, - lp_pool.last_aum, + lp_pool.last_aum(), )?; let out_target_weight = constituent_target_base.get_target_weight( out_constituent.constituent_index, &out_spot_market, out_oracle.price, - lp_pool.last_aum, + lp_pool.last_aum(), )?; let in_target_datum = constituent_target_base.get(in_constituent.constituent_index as u32); let in_target_position_slot_delay = slot.saturating_sub(in_target_datum.last_position_slot); @@ -463,20 +463,20 @@ pub fn handle_lp_pool_swap<'c: 'info, 'info>( in_constituent_index: in_constituent.constituent_index, out_oracle_price: out_oracle.price, in_oracle_price: in_oracle.price, - last_aum: lp_pool.last_aum, + last_aum: lp_pool.last_aum(), last_aum_slot: lp_pool.last_aum_slot, in_market_current_weight: in_constituent.get_weight( in_oracle.price, &in_spot_market, 0, - lp_pool.last_aum, + lp_pool.last_aum(), )?, in_market_target_weight: in_target_weight, out_market_current_weight: out_constituent.get_weight( out_oracle.price, &out_spot_market, 0, - lp_pool.last_aum, + lp_pool.last_aum(), )?, out_market_target_weight: out_target_weight, in_swap_id, @@ -722,15 +722,15 @@ pub fn handle_lp_pool_add_liquidity<'c: 'info, 'info>( update_spot_market_cumulative_interest(&mut in_spot_market, Some(&in_oracle), now)?; - msg!("aum: {}", lp_pool.last_aum); - let in_target_weight = if lp_pool.last_aum == 0 { + msg!("aum: {}", lp_pool.last_aum()); + let in_target_weight = if lp_pool.last_aum() == 0 { PERCENTAGE_PRECISION_I64 // 100% weight if no aum } else { constituent_target_base.get_target_weight( in_constituent.constituent_index, &in_spot_market, in_oracle.price, - lp_pool.last_aum, // TODO: add in_amount * in_oracle to est post add_liquidity aum + lp_pool.last_aum(), // TODO: add in_amount * in_oracle to est post add_liquidity aum )? }; @@ -817,14 +817,17 @@ pub fn handle_lp_pool_add_liquidity<'c: 'info, 'info>( let mut lp_pool = ctx.accounts.lp_pool.load_mut()?; - lp_pool.last_aum = lp_pool.last_aum.safe_add( - in_amount - .cast::()? - .safe_mul(in_oracle.price.cast::()?)? - .safe_div(10_u128.pow(in_spot_market.decimals))?, - )?; + let last_aum = lp_pool.last_aum(); + lp_pool.set_last_aum( + last_aum.safe_add( + in_amount + .cast::()? + .safe_mul(in_oracle.price.cast::()?)? + .safe_div(10_u128.pow(in_spot_market.decimals))?, + )?, + ); - if lp_pool.last_aum > lp_pool.max_aum { + if lp_pool.last_aum() > lp_pool.max_aum() { return Err(ErrorCode::MaxDlpAumBreached.into()); } @@ -864,13 +867,13 @@ pub fn handle_lp_pool_add_liquidity<'c: 'info, 'info>( lp_fee: lp_fee_amount, lp_price: lp_price_after, mint_redeem_id, - last_aum: lp_pool.last_aum, + last_aum: lp_pool.last_aum(), last_aum_slot: lp_pool.last_aum_slot, in_market_current_weight: in_constituent.get_weight( in_oracle.price, &in_spot_market, 0, - lp_pool.last_aum, + lp_pool.last_aum(), )?, in_market_target_weight: in_target_weight, lp_pool: lp_pool_key, @@ -938,15 +941,15 @@ pub fn handle_view_lp_pool_add_liquidity_fees<'c: 'info, 'info>( return Err(ErrorCode::InvalidOracle.into()); } - msg!("aum: {}", lp_pool.last_aum); - let in_target_weight = if lp_pool.last_aum == 0 { + msg!("aum: {}", lp_pool.last_aum()); + let in_target_weight = if lp_pool.last_aum() == 0 { PERCENTAGE_PRECISION_I64 // 100% weight if no aum } else { constituent_target_base.get_target_weight( in_constituent.constituent_index, &in_spot_market, in_oracle.price, - lp_pool.last_aum, // TODO: add in_amount * in_oracle to est post add_liquidity aum + lp_pool.last_aum(), // TODO: add in_amount * in_oracle to est post add_liquidity aum )? }; @@ -1094,7 +1097,7 @@ pub fn handle_lp_pool_remove_liquidity<'c: 'info, 'info>( out_constituent.constituent_index, &out_spot_market, out_oracle.price, - lp_pool.last_aum, // TODO: remove out_amount * out_oracle to est post remove_liquidity aum + lp_pool.last_aum(), // TODO: remove out_amount * out_oracle to est post remove_liquidity aum )?; let dlp_total_supply = ctx.accounts.lp_mint.supply; @@ -1219,12 +1222,15 @@ pub fn handle_lp_pool_remove_liquidity<'c: 'info, 'info>( let mut lp_pool = ctx.accounts.lp_pool.load_mut()?; - lp_pool.last_aum = lp_pool.last_aum.safe_sub( - out_amount_net_fees - .cast::()? - .safe_mul(out_oracle.price.cast::()?)? - .safe_div(10_u128.pow(out_spot_market.decimals))?, - )?; + let last_aum = lp_pool.last_aum(); + lp_pool.set_last_aum( + last_aum.safe_sub( + out_amount_net_fees + .cast::()? + .safe_mul(out_oracle.price.cast::()?)? + .safe_div(10_u128.pow(out_spot_market.decimals))?, + )?, + ); ctx.accounts.constituent_out_token_account.reload()?; ctx.accounts.lp_mint.reload()?; @@ -1262,13 +1268,13 @@ pub fn handle_lp_pool_remove_liquidity<'c: 'info, 'info>( lp_fee: lp_fee_amount, lp_price: lp_price_after, mint_redeem_id, - last_aum: lp_pool.last_aum, + last_aum: lp_pool.last_aum(), last_aum_slot: lp_pool.last_aum_slot, in_market_current_weight: out_constituent.get_weight( out_oracle.price, &out_spot_market, 0, - lp_pool.last_aum, + lp_pool.last_aum(), )?, in_market_target_weight: out_target_weight, lp_pool: lp_pool_key, @@ -1346,7 +1352,7 @@ pub fn handle_view_lp_pool_remove_liquidity_fees<'c: 'info, 'info>( out_constituent.constituent_index, &out_spot_market, out_oracle.price, - lp_pool.last_aum, + lp_pool.last_aum(), )?; let dlp_total_supply = ctx.accounts.lp_mint.supply; diff --git a/programs/drift/src/instructions/user.rs b/programs/drift/src/instructions/user.rs index e75f02ca1c..336fc076a9 100644 --- a/programs/drift/src/instructions/user.rs +++ b/programs/drift/src/instructions/user.rs @@ -1,8 +1,14 @@ use std::convert::TryFrom; use std::ops::DerefMut; -use anchor_lang::prelude::*; -use anchor_lang::Discriminator; +use anchor_lang::{ + prelude::{ + borsh::{BorshDeserialize, BorshSerialize}, + *, + }, + solana_program::sysvar::instructions, + Discriminator, +}; use anchor_spl::{ token::Token, token_2022::Token2022, @@ -115,8 +121,6 @@ use crate::validation::user::validate_user_deletion; use crate::validation::whitelist::validate_whitelist_token; use crate::{controller, math}; use crate::{load_mut, ExchangeStatus}; -use anchor_lang::solana_program::sysvar::instructions; -use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::sysvar::instructions::ID as IX_ID; use super::optional_accounts::get_high_leverage_mode_config; @@ -393,10 +397,8 @@ pub fn handle_initialize_fuel_overflow<'c: 'info, 'info>( .load_init() .or(Err(ErrorCode::UnableToLoadAccountLoader))?; - *fuel_overflow = FuelOverflow { - authority: ctx.accounts.authority.key(), - ..FuelOverflow::default() - }; + *fuel_overflow = FuelOverflow::default(); + fuel_overflow.authority = ctx.accounts.authority.key(); user_stats.update_fuel_overflow_status(true); Ok(()) @@ -424,12 +426,12 @@ pub fn handle_sweep_fuel<'c: 'info, 'info>( user_stats_fuel_positions: user_stats.fuel_positions, user_stats_fuel_taker: user_stats.fuel_taker, user_stats_fuel_maker: user_stats.fuel_maker, - fuel_overflow_fuel_insurance: fuel_overflow.fuel_insurance, - fuel_overflow_fuel_deposits: fuel_overflow.fuel_deposits, - fuel_overflow_fuel_borrows: fuel_overflow.fuel_borrows, - fuel_overflow_fuel_positions: fuel_overflow.fuel_positions, - fuel_overflow_fuel_taker: fuel_overflow.fuel_taker, - fuel_overflow_fuel_maker: fuel_overflow.fuel_maker, + fuel_overflow_fuel_insurance: fuel_overflow.fuel_insurance(), + fuel_overflow_fuel_deposits: fuel_overflow.fuel_deposits(), + fuel_overflow_fuel_borrows: fuel_overflow.fuel_borrows(), + fuel_overflow_fuel_positions: fuel_overflow.fuel_positions(), + fuel_overflow_fuel_taker: fuel_overflow.fuel_taker(), + fuel_overflow_fuel_maker: fuel_overflow.fuel_maker(), }); fuel_overflow.update_from_user_stats(&user_stats, clock.unix_timestamp.cast()?)?; @@ -459,24 +461,24 @@ pub fn handle_reset_fuel_season<'c: 'info, 'info>( user_stats_fuel_positions: user_stats.fuel_positions, user_stats_fuel_taker: user_stats.fuel_taker, user_stats_fuel_maker: user_stats.fuel_maker, - fuel_overflow_fuel_insurance: fuel_overflow.fuel_insurance, - fuel_overflow_fuel_deposits: fuel_overflow.fuel_deposits, - fuel_overflow_fuel_borrows: fuel_overflow.fuel_borrows, - fuel_overflow_fuel_positions: fuel_overflow.fuel_positions, - fuel_overflow_fuel_taker: fuel_overflow.fuel_taker, - fuel_overflow_fuel_maker: fuel_overflow.fuel_maker, + fuel_overflow_fuel_insurance: fuel_overflow.fuel_insurance(), + fuel_overflow_fuel_deposits: fuel_overflow.fuel_deposits(), + fuel_overflow_fuel_borrows: fuel_overflow.fuel_borrows(), + fuel_overflow_fuel_positions: fuel_overflow.fuel_positions(), + fuel_overflow_fuel_taker: fuel_overflow.fuel_taker(), + fuel_overflow_fuel_maker: fuel_overflow.fuel_maker(), }); fuel_overflow.update_from_user_stats(&user_stats, clock.unix_timestamp.cast()?)?; emit!(FuelSeasonRecord { ts: clock.unix_timestamp.cast()?, authority: ctx.accounts.authority.key(), - fuel_insurance: fuel_overflow.fuel_insurance, - fuel_deposits: fuel_overflow.fuel_deposits, - fuel_borrows: fuel_overflow.fuel_borrows, - fuel_positions: fuel_overflow.fuel_positions, - fuel_taker: fuel_overflow.fuel_taker, - fuel_maker: fuel_overflow.fuel_maker, + fuel_insurance: fuel_overflow.fuel_insurance(), + fuel_deposits: fuel_overflow.fuel_deposits(), + fuel_borrows: fuel_overflow.fuel_borrows(), + fuel_positions: fuel_overflow.fuel_positions(), + fuel_taker: fuel_overflow.fuel_taker(), + fuel_maker: fuel_overflow.fuel_maker(), fuel_total: fuel_overflow.total_fuel()?, }); fuel_overflow.reset_fuel(clock.unix_timestamp.cast()?); @@ -806,10 +808,10 @@ pub fn handle_deposit<'c: 'info, 'info>( direction: DepositDirection::Deposit, amount, oracle_price, - market_deposit_balance: spot_market.deposit_balance, - market_withdraw_balance: spot_market.borrow_balance, - market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest, - market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest, + market_deposit_balance: spot_market.deposit_balance(), + market_withdraw_balance: spot_market.borrow_balance(), + market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest(), + market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest(), total_deposits_after, total_withdraws_after, market_index, @@ -962,10 +964,10 @@ pub fn handle_withdraw<'c: 'info, 'info>( oracle_price, amount, market_index, - market_deposit_balance: spot_market.deposit_balance, - market_withdraw_balance: spot_market.borrow_balance, - market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest, - market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest, + market_deposit_balance: spot_market.deposit_balance(), + market_withdraw_balance: spot_market.borrow_balance(), + market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest(), + market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest(), total_deposits_after: user.total_deposits, total_withdraws_after: user.total_withdraws, explanation: deposit_explanation, @@ -1132,10 +1134,10 @@ pub fn handle_transfer_deposit<'c: 'info, 'info>( amount, oracle_price, market_index, - market_deposit_balance: spot_market.deposit_balance, - market_withdraw_balance: spot_market.borrow_balance, - market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest, - market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest, + market_deposit_balance: spot_market.deposit_balance(), + market_withdraw_balance: spot_market.borrow_balance(), + market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest(), + market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest(), total_deposits_after: from_user.total_deposits, total_withdraws_after: from_user.total_withdraws, explanation: DepositExplanation::Transfer, @@ -1196,10 +1198,10 @@ pub fn handle_transfer_deposit<'c: 'info, 'info>( amount, oracle_price, market_index, - market_deposit_balance: spot_market.deposit_balance, - market_withdraw_balance: spot_market.borrow_balance, - market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest, - market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest, + market_deposit_balance: spot_market.deposit_balance(), + market_withdraw_balance: spot_market.borrow_balance(), + market_cumulative_deposit_interest: spot_market.cumulative_deposit_interest(), + market_cumulative_borrow_interest: spot_market.cumulative_borrow_interest(), total_deposits_after, total_withdraws_after, explanation: DepositExplanation::Transfer, @@ -1407,11 +1409,12 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( amount: deposit_transfer, oracle_price: deposit_from_oracle_price_data.price, market_index: deposit_from_market_index, - market_deposit_balance: deposit_from_spot_market.deposit_balance, - market_withdraw_balance: deposit_from_spot_market.borrow_balance, + market_deposit_balance: deposit_from_spot_market.deposit_balance(), + market_withdraw_balance: deposit_from_spot_market.borrow_balance(), market_cumulative_deposit_interest: deposit_from_spot_market - .cumulative_deposit_interest, - market_cumulative_borrow_interest: deposit_from_spot_market.cumulative_borrow_interest, + .cumulative_deposit_interest(), + market_cumulative_borrow_interest: deposit_from_spot_market + .cumulative_borrow_interest(), total_deposits_after: from_user.total_deposits, total_withdraws_after: from_user.total_withdraws, explanation: DepositExplanation::Transfer, @@ -1442,10 +1445,11 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( amount: deposit_transfer, oracle_price: deposit_to_oracle_price_data.price, market_index: deposit_to_market_index, - market_deposit_balance: deposit_to_spot_market.deposit_balance, - market_withdraw_balance: deposit_to_spot_market.borrow_balance, - market_cumulative_deposit_interest: deposit_to_spot_market.cumulative_deposit_interest, - market_cumulative_borrow_interest: deposit_to_spot_market.cumulative_borrow_interest, + market_deposit_balance: deposit_to_spot_market.deposit_balance(), + market_withdraw_balance: deposit_to_spot_market.borrow_balance(), + market_cumulative_deposit_interest: deposit_to_spot_market + .cumulative_deposit_interest(), + market_cumulative_borrow_interest: deposit_to_spot_market.cumulative_borrow_interest(), total_deposits_after: to_user.total_deposits, total_withdraws_after: to_user.total_withdraws, explanation: DepositExplanation::Transfer, @@ -1508,10 +1512,11 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( amount: borrow_transfer, oracle_price: borrow_from_oracle_price_data.price, market_index: borrow_from_market_index, - market_deposit_balance: borrow_from_spot_market.deposit_balance, - market_withdraw_balance: borrow_from_spot_market.borrow_balance, - market_cumulative_deposit_interest: borrow_from_spot_market.cumulative_deposit_interest, - market_cumulative_borrow_interest: borrow_from_spot_market.cumulative_borrow_interest, + market_deposit_balance: borrow_from_spot_market.deposit_balance(), + market_withdraw_balance: borrow_from_spot_market.borrow_balance(), + market_cumulative_deposit_interest: borrow_from_spot_market + .cumulative_deposit_interest(), + market_cumulative_borrow_interest: borrow_from_spot_market.cumulative_borrow_interest(), total_deposits_after: from_user.total_deposits, total_withdraws_after: from_user.total_withdraws, explanation: DepositExplanation::Transfer, @@ -1542,10 +1547,10 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( amount: borrow_transfer, oracle_price: borrow_to_oracle_price_data.price, market_index: borrow_to_market_index, - market_deposit_balance: borrow_to_spot_market.deposit_balance, - market_withdraw_balance: borrow_to_spot_market.borrow_balance, - market_cumulative_deposit_interest: borrow_to_spot_market.cumulative_deposit_interest, - market_cumulative_borrow_interest: borrow_to_spot_market.cumulative_borrow_interest, + market_deposit_balance: borrow_to_spot_market.deposit_balance(), + market_withdraw_balance: borrow_to_spot_market.borrow_balance(), + market_cumulative_deposit_interest: borrow_to_spot_market.cumulative_deposit_interest(), + market_cumulative_borrow_interest: borrow_to_spot_market.cumulative_borrow_interest(), total_deposits_after: to_user.total_deposits, total_withdraws_after: to_user.total_withdraws, explanation: DepositExplanation::Transfer, diff --git a/programs/drift/src/lib.rs b/programs/drift/src/lib.rs index 2dfdf04f7e..cf1a726f27 100644 --- a/programs/drift/src/lib.rs +++ b/programs/drift/src/lib.rs @@ -1,8 +1,9 @@ +#![allow(unexpected_cfgs)] #![allow(clippy::too_many_arguments)] #![allow(clippy::bool_assert_comparison)] #![allow(clippy::comparison_chain)] -use anchor_lang::prelude::*; +use anchor_lang::prelude::{borsh::BorshDeserialize, *}; use instructions::*; #[cfg(test)] diff --git a/programs/drift/src/math/amm.rs b/programs/drift/src/math/amm.rs index 914dffe621..82573fe83f 100644 --- a/programs/drift/src/math/amm.rs +++ b/programs/drift/src/math/amm.rs @@ -63,9 +63,9 @@ pub fn calculate_bid_ask_bounds( } pub fn calculate_market_open_bids_asks(amm: &AMM) -> DriftResult<(i128, i128)> { - let base_asset_reserve = amm.base_asset_reserve; - let min_base_asset_reserve = amm.min_base_asset_reserve; - let max_base_asset_reserve = amm.max_base_asset_reserve; + let base_asset_reserve = amm.base_asset_reserve(); + let min_base_asset_reserve = amm.min_base_asset_reserve(); + let max_base_asset_reserve = amm.max_base_asset_reserve(); let (max_bids, max_asks) = _calculate_market_open_bids_asks( base_asset_reserve, @@ -712,16 +712,16 @@ pub fn calculate_quote_asset_amount_swapped( } pub fn calculate_terminal_reserves(amm: &AMM) -> DriftResult<(u128, u128)> { - let swap_direction = if amm.base_asset_amount_with_amm > 0 { + let swap_direction = if amm.base_asset_amount_with_amm() > 0 { SwapDirection::Add } else { SwapDirection::Remove }; let (new_quote_asset_amount, new_base_asset_amount) = calculate_swap_output( - amm.base_asset_amount_with_amm.unsigned_abs(), - amm.base_asset_reserve, + amm.base_asset_amount_with_amm().unsigned_abs(), + amm.base_asset_reserve(), swap_direction, - amm.sqrt_k, + amm.sqrt_k(), )?; Ok((new_quote_asset_amount, new_base_asset_amount)) @@ -733,7 +733,7 @@ pub fn calculate_terminal_price_and_reserves(amm: &AMM) -> DriftResult<(u64, u12 let terminal_price = calculate_price( new_quote_asset_amount, new_base_asset_amount, - amm.peg_multiplier, + amm.peg_multiplier(), )?; Ok(( @@ -844,20 +844,20 @@ pub fn calculate_amm_available_liquidity( amm: &AMM, order_direction: &PositionDirection, ) -> DriftResult { - let max_fill_size: u64 = (amm.base_asset_reserve / amm.max_fill_reserve_fraction as u128) + let max_fill_size: u64 = (amm.base_asset_reserve() / amm.max_fill_reserve_fraction as u128) .min(u64::MAX as u128) .cast()?; // one fill can only take up to half of side's liquidity let max_base_asset_amount_on_side = match order_direction { PositionDirection::Long => { - amm.base_asset_reserve - .saturating_sub(amm.min_base_asset_reserve) + amm.base_asset_reserve() + .saturating_sub(amm.min_base_asset_reserve()) / 2 } PositionDirection::Short => { - amm.max_base_asset_reserve - .saturating_sub(amm.base_asset_reserve) + amm.max_base_asset_reserve() + .saturating_sub(amm.base_asset_reserve()) / 2 } } @@ -870,7 +870,7 @@ pub fn calculate_amm_available_liquidity( } pub fn calculate_net_user_cost_basis(amm: &AMM) -> DriftResult { - amm.quote_asset_amount + amm.quote_asset_amount() .safe_add(amm.quote_asset_amount_with_unsettled_lp.cast()?)? .safe_add(amm.net_unsettled_funding_pnl.cast()?) } @@ -883,8 +883,8 @@ pub fn calculate_net_user_pnl(amm: &AMM, oracle_price: i64) -> DriftResult )?; let net_user_base_asset_value = amm - .base_asset_amount_with_amm - .safe_add(amm.base_asset_amount_with_unsettled_lp)? + .base_asset_amount_with_amm() + .safe_add(amm.base_asset_amount_with_unsettled_lp())? .safe_mul(oracle_price.cast()?)? .safe_div(PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO.cast()?)?; @@ -896,7 +896,7 @@ pub fn calculate_expiry_price( target_price: i64, total_excess_balance: i128, ) -> DriftResult { - if amm.base_asset_amount_with_amm.abs() < amm.order_step_size.cast::()? { + if amm.base_asset_amount_with_amm().abs() < amm.order_step_size.cast::()? { return Ok(target_price); } // net_baa * price + net_quote <= 0 @@ -905,13 +905,13 @@ pub fn calculate_expiry_price( // net_user_unrealized_pnl negative = surplus in market // net_user_unrealized_pnl positive = expiry price needs to differ from oracle let best_expiry_price = -(amm - .quote_asset_amount - .safe_sub(total_excess_balance.cast::()?)? + .quote_asset_amount() + .safe_sub(total_excess_balance)? .safe_mul(PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO_I128)? - .safe_div(amm.base_asset_amount_with_amm)?) + .safe_div(amm.base_asset_amount_with_amm())?) .cast::()?; - let expiry_price = if amm.base_asset_amount_with_amm >= 0 { + let expiry_price = if amm.base_asset_amount_with_amm() >= 0 { // net longs only get as high as oracle_price best_expiry_price.min(target_price).saturating_sub(1) } else { diff --git a/programs/drift/src/math/amm/tests.rs b/programs/drift/src/math/amm/tests.rs index 938dc1e0c0..e458b0fdfa 100644 --- a/programs/drift/src/math/amm/tests.rs +++ b/programs/drift/src/math/amm/tests.rs @@ -26,47 +26,55 @@ fn calculate_amm_available_guards() { }; assert_eq!(market.amm.net_revenue_since_last_funding, 0); - assert_eq!(market.amm.total_fee_minus_distributions, 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 0); assert_eq!(!market.has_too_much_drawdown().unwrap(), true); market.amm.net_revenue_since_last_funding = -100_000_000_000; - market.amm.total_fee_minus_distributions = 100_000_000_000; + market + .amm + .set_total_fee_minus_distributions(100_000_000_000); assert_eq!(!market.has_too_much_drawdown().unwrap(), false); market.amm.net_revenue_since_last_funding = -10_000_000_000; - market.amm.total_fee_minus_distributions = 100_000_000_000; + market + .amm + .set_total_fee_minus_distributions(100_000_000_000); assert_eq!(!market.has_too_much_drawdown().unwrap(), false); market.amm.net_revenue_since_last_funding = -5_000_000_000; - market.amm.total_fee_minus_distributions = 100_000_000_000; + market + .amm + .set_total_fee_minus_distributions(100_000_000_000); assert_eq!(!market.has_too_much_drawdown().unwrap(), false); market.amm.net_revenue_since_last_funding = -1_000_000_000; - market.amm.total_fee_minus_distributions = 100_000_000_000; + market + .amm + .set_total_fee_minus_distributions(100_000_000_000); assert_eq!(!market.has_too_much_drawdown().unwrap(), true); market.amm.net_revenue_since_last_funding = -1_000_000_000; - market.amm.total_fee_minus_distributions = 1_000_000; + market.amm.set_total_fee_minus_distributions(1_000_000); assert_eq!(!market.has_too_much_drawdown().unwrap(), true); market.amm.net_revenue_since_last_funding = -6_000_000_000; - market.amm.total_fee_minus_distributions = 1_000_000; + market.amm.set_total_fee_minus_distributions(1_000_000); assert_eq!(!market.has_too_much_drawdown().unwrap(), false); market.amm.net_revenue_since_last_funding = -5_000; - market.amm.total_fee_minus_distributions = -9279797219; + market.amm.set_total_fee_minus_distributions(-9279797219); assert_eq!(!market.has_too_much_drawdown().unwrap(), true); // too small net_revenue_since_last_funding drawdown market.amm.net_revenue_since_last_funding = -88_000_000_000; - market.amm.total_fee_minus_distributions = -9279797219; + market.amm.set_total_fee_minus_distributions(-9279797219); assert_eq!(!market.has_too_much_drawdown().unwrap(), false); // too small net_revenue_since_last_funding drawdown } @@ -79,9 +87,9 @@ fn calculate_net_user_pnl_test() { let px = 32 * PRICE_PRECISION; let amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: PEG_PRECISION, + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: PEG_PRECISION.into(), historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: px as i64, last_oracle_price_twap_ts: prev, @@ -142,13 +150,13 @@ fn calculate_expiry_price_long_imbalance_with_loss_test() { let market = PerpMarket { market_index: 0, amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 22_100_000_000, - base_asset_amount_with_amm: (12295081967_i128), + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 22_100_000_000.into(), + base_asset_amount_with_amm: (12295081967_i128).into(), max_spread: 1000, - quote_asset_amount: market_position.quote_asset_amount as i128 * 2, + quote_asset_amount: (market_position.quote_asset_amount as i128 * 2).into(), // assume someone else has other half same entry, ..AMM::default() }, @@ -225,13 +233,13 @@ fn calculate_expiry_price_long_imbalance_test() { let market = PerpMarket { market_index: 0, amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 22_100_000_000, - base_asset_amount_with_amm: (12295081967_i128), + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 22_100_000_000.into(), + base_asset_amount_with_amm: (12295081967_i128).into(), max_spread: 1000, - quote_asset_amount: market_position.quote_asset_amount as i128 * 2, + quote_asset_amount: (market_position.quote_asset_amount as i128 * 2).into(), // assume someone else has other half same entry, ..AMM::default() }, @@ -291,9 +299,9 @@ fn calculate_expiry_price_test() { let px = 32 * PRICE_PRECISION; let amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: PEG_PRECISION, + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: PEG_PRECISION.into(), historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: px as i64, last_oracle_price_twap_ts: prev, @@ -342,13 +350,13 @@ fn calculate_expiry_price_test() { let market = PerpMarket { market_index: 0, amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 22_100_000_000, - base_asset_amount_with_amm: -(12295081967_i128), + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 22_100_000_000.into(), + base_asset_amount_with_amm: (-(12295081967_i128)).into(), max_spread: 1000, - quote_asset_amount: market_position.quote_asset_amount as i128 * 2, + quote_asset_amount: (market_position.quote_asset_amount as i128 * 2).into(), // assume someone else has other half same entry, ..AMM::default() }, @@ -408,9 +416,9 @@ fn calc_delayed_mark_twap_tests() { let prev = 1656682258; let now = prev + 60; let mut amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: PRICE_PRECISION, + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: PRICE_PRECISION.into(), base_spread: 655, //base spread is .065%, max_spread: 65535, //base spread is 6.5% mark_std: PRICE_PRECISION as u64, @@ -428,7 +436,7 @@ fn calc_delayed_mark_twap_tests() { ..AMM::default() }; let px = 22850 * PRICE_PRECISION as i64; - amm.peg_multiplier = px as u128; + amm.set_peg_multiplier(px as u128); let trade_direction = PositionDirection::Long; update_mark_twap_from_estimates(&mut amm, now, Some(px as u64), Some(trade_direction), None) .unwrap(); @@ -448,9 +456,9 @@ fn calc_mark_std_tests() { let prev = 1656682258; let mut now = prev + 60; let mut amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: PRICE_PRECISION, + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: PRICE_PRECISION.into(), base_spread: 65535, //max base spread is 6.5% mark_std: PRICE_PRECISION as u64, historical_oracle_data: HistoricalOracleData { @@ -502,7 +510,7 @@ fn calc_mark_std_tests() { update_oracle_price_twap(&mut amm, now, &mm_oracle_price_data, None, None).unwrap(); - amm.peg_multiplier = px as u128; + amm.set_peg_multiplier(px as u128); let trade_direction = PositionDirection::Long; update_mark_twap_from_estimates(&mut amm, now, Some(px), Some(trade_direction), None) .unwrap(); @@ -527,7 +535,7 @@ fn calc_mark_std_tests() { let mut px: u64 = 31_936_658; let stop_time = now + 3600 * 2; assert_eq!(amm.reserve_price().unwrap(), 39397); - amm.peg_multiplier = 31_986_658; + amm.set_peg_multiplier(31_986_658); assert_eq!(amm.reserve_price().unwrap(), 31986658); amm.historical_oracle_data.last_oracle_price = 31986658; @@ -536,7 +544,7 @@ fn calc_mark_std_tests() { if now % 15 == 0 { px = 31_986_658; //31.98 amm.historical_oracle_data.last_oracle_price = (px - 1000000) as i64; - amm.peg_multiplier = px as u128; + amm.set_peg_multiplier(px as u128); let amm_reserve_price = amm.reserve_price().unwrap(); let (amm_bid_price, amm_ask_price) = amm.bid_ask_price(amm_reserve_price).unwrap(); msg!("bid={:?} ask={:?}", amm_bid_price, amm_ask_price); @@ -550,7 +558,7 @@ fn calc_mark_std_tests() { } if now % 189 == 0 { px = 31_883_651; //31.88 - amm.peg_multiplier = px as u128; + amm.set_peg_multiplier(px as u128); amm.historical_oracle_data.last_oracle_price = (px + 1000000) as i64; let amm_reserve_price = amm.reserve_price().unwrap(); @@ -575,7 +583,7 @@ fn calc_mark_std_tests() { now += 1; if now % 2 == 1 { px = 31_986_658; //31.98 - amm.peg_multiplier = px as u128; + amm.set_peg_multiplier(px as u128); amm.historical_oracle_data.last_oracle_price = (px - 1000000) as i64; let trade_direction = PositionDirection::Long; @@ -584,7 +592,7 @@ fn calc_mark_std_tests() { } if now % 2 == 0 { px = 31_883_651; //31.88 - amm.peg_multiplier = px as u128; + amm.set_peg_multiplier(px as u128); amm.historical_oracle_data.last_oracle_price = (px + 1000000) as i64; let trade_direction = PositionDirection::Short; @@ -626,9 +634,9 @@ fn update_mark_twap_tests() { // $40 everything init let mut amm = AMM { - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: 40 * PEG_PRECISION, + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (40 * PEG_PRECISION).into(), base_spread: 800, max_spread: 10000, long_spread: 0, @@ -767,9 +775,9 @@ fn calc_oracle_twap_tests() { let px = 32 * PRICE_PRECISION; let mut amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: PEG_PRECISION, + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: PEG_PRECISION.into(), historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: px as i64, last_oracle_price_twap_ts: prev, @@ -889,9 +897,9 @@ fn calc_oracle_twap_clamp_update_tests() { // $13 everything init let mut amm = AMM { - quote_asset_reserve: 200 * AMM_RESERVE_PRECISION, - base_asset_reserve: 200 * AMM_RESERVE_PRECISION, - peg_multiplier: 13 * PEG_PRECISION, + quote_asset_reserve: (200 * AMM_RESERVE_PRECISION).into(), + base_asset_reserve: (200 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (13 * PEG_PRECISION).into(), base_spread: 0, long_spread: 0, short_spread: 0, @@ -978,9 +986,9 @@ fn test_last_oracle_conf_update() { let now = prev + 1; let mut amm = AMM { - quote_asset_reserve: 200 * AMM_RESERVE_PRECISION, - base_asset_reserve: 200 * AMM_RESERVE_PRECISION, - peg_multiplier: 13 * PEG_PRECISION, + quote_asset_reserve: (200 * AMM_RESERVE_PRECISION).into(), + base_asset_reserve: (200 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (13 * PEG_PRECISION).into(), base_spread: 0, long_spread: 0, short_spread: 0, diff --git a/programs/drift/src/math/amm_jit.rs b/programs/drift/src/math/amm_jit.rs index 2d2c22c0fd..1f62b7c209 100644 --- a/programs/drift/src/math/amm_jit.rs +++ b/programs/drift/src/math/amm_jit.rs @@ -132,7 +132,7 @@ pub fn calculate_clamped_jit_base_asset_amount( // bound it; dont flip the net_baa let max_amm_base_asset_amount = market .amm - .base_asset_amount_with_amm + .base_asset_amount_with_amm() .unsigned_abs() .cast::()?; diff --git a/programs/drift/src/math/amm_jit/tests.rs b/programs/drift/src/math/amm_jit/tests.rs index 5e3488741d..ddd34aea22 100644 --- a/programs/drift/src/math/amm_jit/tests.rs +++ b/programs/drift/src/math/amm_jit/tests.rs @@ -5,7 +5,7 @@ use crate::state::perp_market::AMM; fn balanced_market_zero_jit() { let market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 0, + base_asset_amount_with_amm: 0.into(), amm_jit_intensity: 100, ..AMM::default_test() }, @@ -22,7 +22,7 @@ fn balanced_market_zero_jit() { fn balanced_market_zero_intensity() { let market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 100, + base_asset_amount_with_amm: 100.into(), amm_jit_intensity: 0, ..AMM::default_test() }, @@ -39,7 +39,7 @@ fn balanced_market_zero_intensity() { fn balanced_market_full_intensity() { let market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 100, + base_asset_amount_with_amm: 100.into(), amm_jit_intensity: 100, ..AMM::default_test() }, @@ -56,7 +56,7 @@ fn balanced_market_full_intensity() { fn balanced_market_half_intensity() { let market = PerpMarket { amm: AMM { - base_asset_amount_with_amm: 100, + base_asset_amount_with_amm: 100.into(), amm_jit_intensity: 50, ..AMM::default_test() }, diff --git a/programs/drift/src/math/amm_spread.rs b/programs/drift/src/math/amm_spread.rs index 7007722932..161df0688a 100644 --- a/programs/drift/src/math/amm_spread.rs +++ b/programs/drift/src/math/amm_spread.rs @@ -27,7 +27,7 @@ pub fn calculate_base_asset_amount_to_trade_to_price( limit_price: u64, direction: PositionDirection, ) -> DriftResult<(u64, PositionDirection)> { - let invariant_sqrt_u192 = U192::from(amm.sqrt_k); + let invariant_sqrt_u192 = U192::from(amm.sqrt_k()); let invariant = invariant_sqrt_u192.safe_mul(invariant_sqrt_u192)?; validate!( @@ -39,7 +39,7 @@ pub fn calculate_base_asset_amount_to_trade_to_price( let new_base_asset_reserve_squared = invariant .safe_mul(U192::from(PRICE_PRECISION))? .safe_div(U192::from(limit_price))? - .safe_mul(U192::from(amm.peg_multiplier))? + .safe_mul(U192::from(amm.peg_multiplier()))? .safe_div(U192::from(PEG_PRECISION))?; let new_base_asset_reserve = new_base_asset_reserve_squared @@ -50,7 +50,7 @@ pub fn calculate_base_asset_amount_to_trade_to_price( let (spread_base_asset_reserve, _) = get_spread_reserves(amm, direction)?; spread_base_asset_reserve } else { - amm.base_asset_reserve + amm.base_asset_reserve() }; if new_base_asset_reserve > base_asset_reserve_before { @@ -519,8 +519,8 @@ pub fn calculate_spread( pub fn get_spread_reserves(amm: &AMM, direction: PositionDirection) -> DriftResult<(u128, u128)> { let (base_asset_reserve, quote_asset_reserve) = match direction { - PositionDirection::Long => (amm.ask_base_asset_reserve, amm.ask_quote_asset_reserve), - PositionDirection::Short => (amm.bid_base_asset_reserve, amm.bid_quote_asset_reserve), + PositionDirection::Long => (amm.ask_base_asset_reserve(), amm.ask_quote_asset_reserve()), + PositionDirection::Short => (amm.bid_base_asset_reserve(), amm.bid_quote_asset_reserve()), }; Ok((base_asset_reserve, quote_asset_reserve)) @@ -548,7 +548,7 @@ pub fn calculate_spread_reserves( BID_ASK_SPREAD_PRECISION_I128 / (spread_with_offset / 2).cast::()?; market .amm - .quote_asset_reserve + .quote_asset_reserve() .cast::()? .safe_div(quote_reserve_divisor)? } else { @@ -558,12 +558,12 @@ pub fn calculate_spread_reserves( let mut quote_asset_reserve = if quote_asset_reserve_delta > 0 { market .amm - .quote_asset_reserve + .quote_asset_reserve() .safe_add(quote_asset_reserve_delta.unsigned_abs())? } else { market .amm - .quote_asset_reserve + .quote_asset_reserve() .safe_sub(quote_asset_reserve_delta.unsigned_abs())? }; @@ -577,7 +577,7 @@ pub fn calculate_spread_reserves( ); } - let invariant_sqrt_u192 = U192::from(market.amm.sqrt_k); + let invariant_sqrt_u192 = U192::from(market.amm.sqrt_k()); let invariant = invariant_sqrt_u192.safe_mul(invariant_sqrt_u192)?; let base_asset_reserve = invariant diff --git a/programs/drift/src/math/amm_spread/tests.rs b/programs/drift/src/math/amm_spread/tests.rs index ac57fb45df..fa861c8428 100644 --- a/programs/drift/src/math/amm_spread/tests.rs +++ b/programs/drift/src/math/amm_spread/tests.rs @@ -194,12 +194,12 @@ mod test { fn calculate_reference_price_offset_deadband_tests() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: AMM_RESERVE_PRECISION * 11, - quote_asset_reserve: AMM_RESERVE_PRECISION * 10, - sqrt_k: AMM_RESERVE_PRECISION * 10, - peg_multiplier: 34_000_000, - min_base_asset_reserve: AMM_RESERVE_PRECISION * 7, - max_base_asset_reserve: AMM_RESERVE_PRECISION * 14, + base_asset_reserve: (AMM_RESERVE_PRECISION * 11).into(), + quote_asset_reserve: (AMM_RESERVE_PRECISION * 10).into(), + sqrt_k: (AMM_RESERVE_PRECISION * 10).into(), + peg_multiplier: 34_000_000.into(), + min_base_asset_reserve: (AMM_RESERVE_PRECISION * 7).into(), + max_base_asset_reserve: (AMM_RESERVE_PRECISION * 14).into(), base_spread: 1000, max_spread: 20_000, curve_update_intensity: 110, @@ -219,12 +219,14 @@ mod test { let reserve_price = 4216 * 10000; - market.amm.base_asset_amount_with_amm = (AMM_RESERVE_PRECISION * 7 / 20) as i128; + market + .amm + .set_base_asset_amount_with_amm((AMM_RESERVE_PRECISION * 7 / 20) as i128); let inventory_ratio = calculate_inventory_liquidity_ratio_for_reference_price_offset( - market.amm.base_asset_amount_with_amm, - market.amm.base_asset_reserve, - market.amm.min_base_asset_reserve, - market.amm.max_base_asset_reserve, + market.amm.base_asset_amount_with_amm(), + market.amm.base_asset_reserve(), + market.amm.min_base_asset_reserve(), + market.amm.max_base_asset_reserve(), ) .unwrap(); assert_eq!(inventory_ratio, 100000); // 10% @@ -232,12 +234,16 @@ mod test { market.amm.reference_price_offset_deadband_pct = 10; // 10% // If inventory exceeds threshold positive ref price offset - market.amm.base_asset_amount_with_amm = (AMM_RESERVE_PRECISION * 8 / 20) as i128; + market + .amm + .set_base_asset_amount_with_amm((AMM_RESERVE_PRECISION * 8 / 20) as i128); let (_l, _s) = update_spreads(&mut market, reserve_price as u64, None).unwrap(); assert!(market.amm.reference_price_offset > 0); // If inventory is small, goes to 0 - market.amm.base_asset_amount_with_amm = (AMM_RESERVE_PRECISION * 6 / 20) as i128; + market + .amm + .set_base_asset_amount_with_amm((AMM_RESERVE_PRECISION * 6 / 20) as i128); let (_l, _s) = update_spreads(&mut market, reserve_price as u64, None).unwrap(); assert_eq!(market.amm.reference_price_offset, 0); @@ -246,13 +252,17 @@ mod test { market.amm.last_24h_avg_funding_rate = -1; market.amm.last_mark_price_twap_5min = 4216 * 10000 - 2 * 10000; market.amm.last_mark_price_twap = 4216 * 10000 - 2 * 10000; - market.amm.base_asset_amount_with_amm = (AMM_RESERVE_PRECISION * 8 / 20) as i128 * -1; + market + .amm + .set_base_asset_amount_with_amm((AMM_RESERVE_PRECISION * 8 / 20) as i128 * -1); let (_l, _s) = update_spreads(&mut market, reserve_price as u64, None).unwrap(); println!("ref offset: {}", market.amm.reference_price_offset); assert!(market.amm.reference_price_offset < 0); // Same for short pos - market.amm.base_asset_amount_with_amm = (AMM_RESERVE_PRECISION * 6 / 20) as i128 * -1; + market + .amm + .set_base_asset_amount_with_amm((AMM_RESERVE_PRECISION * 6 / 20) as i128 * -1); let (_l, _s) = update_spreads(&mut market, reserve_price as u64, None).unwrap(); assert_eq!(market.amm.reference_price_offset, 0); } @@ -440,10 +450,10 @@ mod test { assert_eq!(short_spread5, 500); let amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - sqrt_k: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: PEG_PRECISION, + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: PEG_PRECISION.into(), long_spread: long_spread5, short_spread: short_spread5, max_spread: 1000, @@ -472,9 +482,9 @@ mod test { assert_eq!(max_ref_offset, 25000); // 250 bps (5% of max spread) let orig_price = calculate_price( - amm.quote_asset_reserve, - amm.base_asset_reserve, - amm.peg_multiplier, + amm.quote_asset_reserve(), + amm.base_asset_reserve(), + amm.peg_multiplier(), ) .unwrap(); assert_eq!(orig_price, 1000000); @@ -487,13 +497,13 @@ mod test { assert_eq!(qar_l, 2027397260); assert_eq!(qar_s, 1999500000); - assert!(qar_l > amm.quote_asset_reserve); - assert!(bar_l < amm.base_asset_reserve); - assert!(qar_s < amm.quote_asset_reserve); - assert!(bar_s > amm.base_asset_reserve); + assert!(qar_l > amm.quote_asset_reserve()); + assert!(bar_l < amm.base_asset_reserve()); + assert!(qar_s < amm.quote_asset_reserve()); + assert!(bar_s > amm.base_asset_reserve()); - let l_price = calculate_price(qar_l, bar_l, amm.peg_multiplier).unwrap(); - let s_price = calculate_price(qar_s, bar_s, amm.peg_multiplier).unwrap(); + let l_price = calculate_price(qar_l, bar_l, amm.peg_multiplier()).unwrap(); + let s_price = calculate_price(qar_s, bar_s, amm.peg_multiplier()).unwrap(); assert_eq!(l_price, 1027584); assert_eq!(s_price, 999500); assert!(l_price > s_price); @@ -503,19 +513,19 @@ mod test { let (bar_l, qar_l) = calculate_spread_reserves(&market, PositionDirection::Long).unwrap(); let (bar_s, qar_s) = calculate_spread_reserves(&market, PositionDirection::Short).unwrap(); - assert_eq!(amm.quote_asset_reserve, 2000000000); + assert_eq!(amm.quote_asset_reserve(), 2000000000); assert_eq!(qar_s, 2000500000); // down - assert!(qar_l > amm.quote_asset_reserve); - assert!(bar_l < amm.base_asset_reserve); - assert!(qar_s > amm.quote_asset_reserve); - assert!(bar_s < amm.base_asset_reserve); + assert!(qar_l > amm.quote_asset_reserve()); + assert!(bar_l < amm.base_asset_reserve()); + assert!(qar_s > amm.quote_asset_reserve()); + assert!(bar_s < amm.base_asset_reserve()); assert_eq!(bar_s, 1999500124); // up assert_eq!(bar_l, 1971830986); // down assert_eq!(qar_l, 2028571428); // up - let l_price = calculate_price(qar_l, bar_l, amm.peg_multiplier).unwrap(); - let s_price = calculate_price(qar_s, bar_s, amm.peg_multiplier).unwrap(); + let l_price = calculate_price(qar_l, bar_l, amm.peg_multiplier()).unwrap(); + let s_price = calculate_price(qar_s, bar_s, amm.peg_multiplier()).unwrap(); assert_eq!(l_price, 1028775); assert_eq!(s_price, 1000500); assert!(l_price > s_price); @@ -524,17 +534,17 @@ mod test { let (bar_l, qar_l) = calculate_spread_reserves(&market, PositionDirection::Long).unwrap(); let (bar_s, qar_s) = calculate_spread_reserves(&market, PositionDirection::Short).unwrap(); - assert!(qar_l > amm.quote_asset_reserve); - assert!(bar_l < amm.base_asset_reserve); - assert!(qar_s < amm.quote_asset_reserve); - assert!(bar_s > amm.base_asset_reserve); + assert!(qar_l > amm.quote_asset_reserve()); + assert!(bar_l < amm.base_asset_reserve()); + assert!(qar_s < amm.quote_asset_reserve()); + assert!(bar_s > amm.base_asset_reserve()); assert_eq!(bar_s, 2001501501); // up assert_eq!(bar_l, 1974025974); // up assert_eq!(qar_l, 2026315789); // down assert_eq!(qar_s, 1998499625); // down - let l_price = calculate_price(qar_l, bar_l, amm.peg_multiplier).unwrap(); - let s_price = calculate_price(qar_s, bar_s, amm.peg_multiplier).unwrap(); + let l_price = calculate_price(qar_l, bar_l, amm.peg_multiplier()).unwrap(); + let s_price = calculate_price(qar_s, bar_s, amm.peg_multiplier()).unwrap(); assert_eq!(l_price, 1026488); assert_eq!(s_price, 998500); assert!(l_price > s_price); @@ -1668,10 +1678,10 @@ mod test { #[test] fn calculate_prediction_market_spread_tests_low_price() { let amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - sqrt_k: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: PEG_PRECISION / 30, // .02 + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (PEG_PRECISION / 30).into(), // .02 long_spread: 10000, short_spread: 10000, base_spread: 10000, @@ -1697,7 +1707,7 @@ mod test { crate::math::amm::calculate_price( new_ask_quote_asset_reserve, new_ask_base_asset_reserve, - market.amm.peg_multiplier, + market.amm.peg_multiplier(), ) .unwrap(), 50001 // over .05 @@ -1707,7 +1717,7 @@ mod test { crate::math::amm::calculate_price( new_bid_quote_asset_reserve, new_bid_base_asset_reserve, - market.amm.peg_multiplier, + market.amm.peg_multiplier(), ) .unwrap(), 33000 @@ -1717,10 +1727,10 @@ mod test { #[test] fn calculate_prediction_market_spread_tests_high_price() { let amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - sqrt_k: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: PEG_PRECISION - PEG_PRECISION / 1000, // .999 + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (PEG_PRECISION - PEG_PRECISION / 1000).into(), // .999 long_spread: 10000, short_spread: 10000, base_spread: 10000, @@ -1746,7 +1756,7 @@ mod test { crate::math::amm::calculate_price( new_ask_quote_asset_reserve, new_ask_base_asset_reserve, - market.amm.peg_multiplier, + market.amm.peg_multiplier(), ) .unwrap(), 1000000 // exactly $1 @@ -1756,7 +1766,7 @@ mod test { crate::math::amm::calculate_price( new_bid_quote_asset_reserve, new_bid_base_asset_reserve, - market.amm.peg_multiplier, + market.amm.peg_multiplier(), ) .unwrap(), 949981 // under .95 diff --git a/programs/drift/src/math/bn.rs b/programs/drift/src/math/bn.rs index 0218b2a5a3..09ab7b117f 100644 --- a/programs/drift/src/math/bn.rs +++ b/programs/drift/src/math/bn.rs @@ -12,6 +12,282 @@ use uint::construct_uint; use crate::error::DriftResult; +pub mod compat { + #![allow(non_camel_case_types)] + use anchor_lang::prelude::borsh::{BorshDeserialize, BorshSerialize}; + use bytemuck::{Pod, Zeroable}; + use std::{ + cmp::Ordering, + convert::TryFrom, + ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}, + }; + + use crate::{error::DriftResult, math::casting::Cast}; + + /// `u128` with legacy bit layout + #[derive(Copy, Clone, PartialEq, Eq, Debug, Default, BorshSerialize, BorshDeserialize)] + pub struct u128([u8; 16]); + + impl std::fmt::Display for self::u128 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(&self.as_u128(), f) + } + } + + impl PartialOrd for self::u128 { + fn partial_cmp(&self, other: &Self) -> Option { + self.as_u128().partial_cmp(&other.as_u128()) + } + } + + impl PartialOrd for self::i128 { + fn partial_cmp(&self, other: &Self) -> Option { + self.as_i128().partial_cmp(&other.as_i128()) + } + } + + // Safety: u128 is a transparent wrapper around [u8; 16], which is Pod + Zeroable + unsafe impl Pod for self::u128 {} + unsafe impl Zeroable for self::u128 {} + impl u128 { + pub const ONE: Self = u128(1_u128.to_le_bytes()); + pub const ZERO: Self = u128(0_u128.to_le_bytes()); + /// convert to std u128 + #[inline] + pub fn as_u128(self) -> std::primitive::u128 { + std::primitive::u128::from_le_bytes(self.0) + } + pub const fn one() -> Self { + Self::ONE + } + pub const fn zero() -> Self { + Self::ZERO + } + pub fn cast>(&self) -> DriftResult { + self.as_u128().cast() + } + } + impl From for u128 { + fn from(value: std::primitive::u128) -> Self { + u128(value.to_le_bytes()) + } + } + impl From for std::primitive::u128 { + fn from(value: u128) -> Self { + value.as_u128() + } + } + + impl num_traits::Zero for self::u128 { + fn zero() -> Self { + Self::ZERO + } + fn is_zero(&self) -> bool { + self.0 == Self::ZERO.0 + } + } + + // Arithmetic operations for u128 - using From/Into conversions + impl Add for u128 { + type Output = Self; + #[inline(always)] + fn add(self, other: Self) -> Self { + let a: std::primitive::u128 = self.into(); + let b: std::primitive::u128 = other.into(); + Self::from(a + b) + } + } + impl AddAssign for u128 { + #[inline(always)] + fn add_assign(&mut self, other: Self) { + *self = *self + other; + } + } + impl Sub for u128 { + type Output = Self; + #[inline(always)] + fn sub(self, other: Self) -> Self { + let a: std::primitive::u128 = self.into(); + let b: std::primitive::u128 = other.into(); + Self::from(a - b) + } + } + impl SubAssign for u128 { + #[inline(always)] + fn sub_assign(&mut self, other: Self) { + *self = *self - other; + } + } + impl Mul for u128 { + type Output = Self; + #[inline(always)] + fn mul(self, other: Self) -> Self { + let a: std::primitive::u128 = self.into(); + + let b: std::primitive::u128 = other.into(); + Self::from(a * b) + } + } + impl MulAssign for u128 { + #[inline(always)] + fn mul_assign(&mut self, other: Self) { + *self = *self * other; + } + } + impl Div for u128 { + type Output = Self; + #[inline(always)] + fn div(self, other: Self) -> Self { + let a: std::primitive::u128 = self.into(); + + let b: std::primitive::u128 = other.into(); + Self::from(a / b) + } + } + impl DivAssign for u128 { + #[inline(always)] + fn div_assign(&mut self, other: Self) { + *self = *self / other; + } + } + + /// `i128` with legacy bit layout + #[derive(Copy, Clone, PartialEq, Eq, Debug, Default, BorshSerialize, BorshDeserialize)] + pub struct i128([u8; 16]); + + impl std::fmt::Display for self::i128 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(&self.as_i128(), f) + } + } + + // Safety: i128 is a transparent wrapper around [u8; 16], which is Pod + Zeroable + unsafe impl Pod for self::i128 {} + unsafe impl Zeroable for self::i128 {} + impl i128 { + pub const ONE: Self = i128(1_i128.to_le_bytes()); + pub const ZERO: Self = i128(0_i128.to_le_bytes()); + + pub const fn one() -> Self { + Self::ONE + } + pub const fn zero() -> Self { + Self::ZERO + } + + pub fn abs(&self) -> std::primitive::i128 { + self.as_i128().abs() + } + + pub fn unsigned_abs(&self) -> std::primitive::u128 { + self.as_i128().unsigned_abs() + } + + /// convert to std i128 + #[inline] + pub fn as_i128(self) -> std::primitive::i128 { + std::primitive::i128::from_le_bytes(self.0) + } + + pub fn cast>(&self) -> DriftResult { + self.as_i128().cast() + } + } + + impl num_traits::Zero for self::i128 { + fn zero() -> Self { + Self::ZERO + } + fn is_zero(&self) -> bool { + self.0 == Self::ZERO.0 + } + } + + impl std::ops::Neg for self::i128 { + type Output = std::primitive::i128; + fn neg(self) -> Self::Output { + self.as_i128().neg() + } + } + + impl From for i128 { + fn from(value: std::primitive::i128) -> Self { + i128(value.to_le_bytes()) + } + } + impl From for std::primitive::i128 { + fn from(value: i128) -> Self { + value.as_i128() + } + } + + // Arithmetic operations for i128 - using From/Into conversions + impl Add for i128 { + type Output = Self; + #[inline(always)] + fn add(self, other: Self) -> Self { + let a: std::primitive::i128 = self.into(); + + let b: std::primitive::i128 = other.into(); + Self::from(a + b) + } + } + impl AddAssign for i128 { + #[inline(always)] + fn add_assign(&mut self, other: Self) { + *self = *self + other; + } + } + impl Sub for i128 { + type Output = Self; + #[inline(always)] + fn sub(self, other: Self) -> Self { + let a: std::primitive::i128 = self.into(); + + let b: std::primitive::i128 = other.into(); + Self::from(a - b) + } + } + impl SubAssign for i128 { + #[inline(always)] + fn sub_assign(&mut self, other: Self) { + *self = *self - other; + } + } + impl Mul for i128 { + type Output = Self; + #[inline(always)] + fn mul(self, other: Self) -> Self { + let a: std::primitive::i128 = self.into(); + + let b: std::primitive::i128 = other.into(); + Self::from(a * b) + } + } + impl MulAssign for i128 { + #[inline(always)] + fn mul_assign(&mut self, other: Self) { + *self = *self * other; + } + } + impl Div for i128 { + type Output = Self; + #[inline(always)] + fn div(self, other: Self) -> Self { + let a: std::primitive::i128 = self.into(); + + let b: std::primitive::i128 = other.into(); + Self::from(a / b) + } + } + impl DivAssign for i128 { + #[inline(always)] + fn div_assign(&mut self, other: Self) { + *self = *self / other; + } + } +} + construct_uint! { /// 256-bit unsigned integer. pub struct U256(4); diff --git a/programs/drift/src/math/cp_curve.rs b/programs/drift/src/math/cp_curve.rs index 2ac13376f9..2a76fc6086 100644 --- a/programs/drift/src/math/cp_curve.rs +++ b/programs/drift/src/math/cp_curve.rs @@ -41,11 +41,11 @@ pub fn calculate_budgeted_k_scale( )?; let (numerator, denominator) = _calculate_budgeted_k_scale( - market.amm.base_asset_reserve, - market.amm.quote_asset_reserve, + market.amm.base_asset_reserve(), + market.amm.quote_asset_reserve(), budget, - market.amm.peg_multiplier, - market.amm.base_asset_amount_with_amm, + market.amm.peg_multiplier(), + market.amm.base_asset_amount_with_amm(), k_pct_upper_bound, k_pct_lower_bound, )?; @@ -176,7 +176,7 @@ pub fn adjust_k_cost( // Find the net market value before adjusting k let (current_net_market_value, _) = calculate_base_asset_value_and_pnl( - market_clone.amm.base_asset_amount_with_amm, + market_clone.amm.base_asset_amount_with_amm(), 0, &market_clone.amm, )?; @@ -184,7 +184,7 @@ pub fn adjust_k_cost( update_k(&mut market_clone, update_k_result)?; let (_new_net_market_value, cost) = calculate_base_asset_value_and_pnl( - market_clone.amm.base_asset_amount_with_amm, + market_clone.amm.base_asset_amount_with_amm(), current_net_market_value, &market_clone.amm, )?; @@ -201,12 +201,12 @@ pub fn adjust_k_cost_and_update( ) -> DriftResult { // Find the net market value before adjusting k let current_net_market_value = - calculate_base_asset_value(market.amm.base_asset_amount_with_amm, &market.amm)?; + calculate_base_asset_value(market.amm.base_asset_amount_with_amm(), &market.amm)?; update_k(market, update_k_result)?; let (_new_net_market_value, cost) = calculate_base_asset_value_and_pnl( - market.amm.base_asset_amount_with_amm, + market.amm.base_asset_amount_with_amm(), current_net_market_value, &market.amm, )?; @@ -227,7 +227,7 @@ pub fn get_update_k_result( ) -> DriftResult { let sqrt_k_ratio_precision = bn::U192::from(AMM_RESERVE_PRECISION); - let old_sqrt_k = bn::U192::from(market.amm.sqrt_k); + let old_sqrt_k = bn::U192::from(market.amm.sqrt_k()); let mut sqrt_k_ratio = new_sqrt_k .safe_mul(sqrt_k_ratio_precision)? .safe_div(old_sqrt_k)?; @@ -253,14 +253,14 @@ pub fn get_update_k_result( // only allow too small when market is in reduce only mode if market.status != MarketStatus::ReduceOnly && new_sqrt_k < old_sqrt_k - && market.amm.base_asset_amount_with_amm.unsigned_abs() > sqrt_k + && market.amm.base_asset_amount_with_amm().unsigned_abs() > sqrt_k { // todo, check less lp_tokens as well msg!("new_sqrt_k too small relative to market imbalance"); return Err(ErrorCode::InvalidUpdateK); } - let base_asset_reserve = bn::U192::from(market.amm.base_asset_reserve) + let base_asset_reserve = bn::U192::from(market.amm.base_asset_reserve()) .safe_mul(sqrt_k_ratio)? .safe_div(sqrt_k_ratio_precision)? .try_to_u128()?; @@ -280,18 +280,28 @@ pub fn get_update_k_result( } pub fn update_k(market: &mut PerpMarket, update_k_result: &UpdateKResult) -> DriftResult { - market.amm.base_asset_reserve = update_k_result.base_asset_reserve; - market.amm.quote_asset_reserve = update_k_result.quote_asset_reserve; - market.amm.sqrt_k = update_k_result.sqrt_k; + market + .amm + .set_base_asset_reserve(update_k_result.base_asset_reserve); + market + .amm + .set_quote_asset_reserve(update_k_result.quote_asset_reserve); + market.amm.set_sqrt_k(update_k_result.sqrt_k); let (new_terminal_quote_reserve, new_terminal_base_reserve) = amm::calculate_terminal_reserves(&market.amm)?; - market.amm.terminal_quote_asset_reserve = new_terminal_quote_reserve; + market + .amm + .set_terminal_quote_asset_reserve(new_terminal_quote_reserve); let (min_base_asset_reserve, max_base_asset_reserve) = - amm::calculate_bid_ask_bounds(market.amm.concentration_coef, new_terminal_base_reserve)?; - market.amm.min_base_asset_reserve = min_base_asset_reserve; - market.amm.max_base_asset_reserve = max_base_asset_reserve; + amm::calculate_bid_ask_bounds(market.amm.concentration_coef(), new_terminal_base_reserve)?; + market + .amm + .set_min_base_asset_reserve(min_base_asset_reserve); + market + .amm + .set_max_base_asset_reserve(max_base_asset_reserve); let reserve_price_after = market.amm.reserve_price()?; crate::controller::amm::update_spreads(market, reserve_price_after, None)?; diff --git a/programs/drift/src/math/cp_curve/tests.rs b/programs/drift/src/math/cp_curve/tests.rs index b6c8b667b7..6b4379b3bf 100644 --- a/programs/drift/src/math/cp_curve/tests.rs +++ b/programs/drift/src/math/cp_curve/tests.rs @@ -10,9 +10,9 @@ use crate::state::perp_market::AMM; fn k_update_results_bound_flag() { let init_reserves = 100 * AMM_RESERVE_PRECISION; let amm = AMM { - sqrt_k: init_reserves, - base_asset_reserve: init_reserves, - quote_asset_reserve: init_reserves, + sqrt_k: init_reserves.into(), + base_asset_reserve: init_reserves.into(), + quote_asset_reserve: init_reserves.into(), ..AMM::default() }; let market = PerpMarket { @@ -32,18 +32,18 @@ fn k_update_results_bound_flag() { fn calculate_k_tests_with_spread() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - base_asset_amount_with_amm: -12295081967, + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + base_asset_amount_with_amm: (-12295081967).into(), ..AMM::default() }, ..PerpMarket::default() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); market.amm.base_spread = 10; market.amm.long_spread = 5; market.amm.short_spread = 5; @@ -55,21 +55,29 @@ fn calculate_k_tests_with_spread() { crate::math::amm_spread::calculate_spread_reserves(&market, PositionDirection::Short) .unwrap(); - market.amm.ask_base_asset_reserve = new_ask_base_asset_reserve; - market.amm.bid_base_asset_reserve = new_bid_base_asset_reserve; - market.amm.ask_quote_asset_reserve = new_ask_quote_asset_reserve; - market.amm.bid_quote_asset_reserve = new_bid_quote_asset_reserve; + market + .amm + .set_ask_base_asset_reserve(new_ask_base_asset_reserve); + market + .amm + .set_bid_base_asset_reserve(new_bid_base_asset_reserve); + market + .amm + .set_ask_quote_asset_reserve(new_ask_quote_asset_reserve); + market + .amm + .set_bid_quote_asset_reserve(new_bid_quote_asset_reserve); validate!( - market.amm.bid_base_asset_reserve >= market.amm.base_asset_reserve - && market.amm.bid_quote_asset_reserve <= market.amm.quote_asset_reserve, + market.amm.bid_base_asset_reserve() >= market.amm.base_asset_reserve() + && market.amm.bid_quote_asset_reserve() <= market.amm.quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "market index {} amm bid reserves invalid: {} -> {}, quote: {} -> {}", market.market_index, - market.amm.bid_base_asset_reserve, - market.amm.base_asset_reserve, - market.amm.bid_quote_asset_reserve, - market.amm.quote_asset_reserve + market.amm.bid_base_asset_reserve(), + market.amm.base_asset_reserve(), + market.amm.bid_quote_asset_reserve(), + market.amm.quote_asset_reserve() ) .unwrap(); @@ -79,14 +87,14 @@ fn calculate_k_tests_with_spread() { update_k(&mut market, &update_k_result).unwrap(); validate!( - market.amm.bid_base_asset_reserve >= market.amm.base_asset_reserve - && market.amm.bid_quote_asset_reserve <= market.amm.quote_asset_reserve, + market.amm.bid_base_asset_reserve() >= market.amm.base_asset_reserve() + && market.amm.bid_quote_asset_reserve() <= market.amm.quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "bid reserves out of wack: {} -> {}, quote: {} -> {}", - market.amm.bid_base_asset_reserve, - market.amm.base_asset_reserve, - market.amm.bid_quote_asset_reserve, - market.amm.quote_asset_reserve + market.amm.bid_base_asset_reserve(), + market.amm.base_asset_reserve(), + market.amm.bid_quote_asset_reserve(), + market.amm.quote_asset_reserve() ) .unwrap(); } @@ -103,12 +111,12 @@ fn calculate_k_with_rounding() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve, - quote_asset_reserve, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - sqrt_k: 10000000000000000000, - peg_multiplier, - base_asset_amount_with_amm, + base_asset_reserve: base_asset_reserve.into(), + quote_asset_reserve: quote_asset_reserve.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + sqrt_k: 10000000000000000000.into(), + peg_multiplier: peg_multiplier.into(), + base_asset_amount_with_amm: base_asset_amount_with_amm.into(), ..AMM::default() }, ..PerpMarket::default() @@ -132,7 +140,7 @@ fn calculate_k_with_rounding() { let k_scale_numerator: u128 = 373175; let k_scale_denominator: u128 = 340980; - let new_sqrt_k = bn::U192::from(market.amm.sqrt_k) + let new_sqrt_k = bn::U192::from(market.amm.sqrt_k()) .safe_mul(bn::U192::from(k_scale_numerator)) .unwrap() .safe_div(bn::U192::from(k_scale_denominator)) @@ -149,12 +157,12 @@ fn calculate_k_with_rounding() { fn calculate_k_tests() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - base_asset_amount_with_amm: -12295081967, + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + base_asset_amount_with_amm: (-12295081967).into(), ..AMM::default() }, ..PerpMarket::default() @@ -167,7 +175,7 @@ fn calculate_k_tests() { // new terminal reserves are balanced, terminal price = peg) assert_eq!(t_qar, 500 * AMM_RESERVE_PRECISION); assert_eq!(t_bar, 500 * AMM_RESERVE_PRECISION); - assert_eq!(t_price as u128, market.amm.peg_multiplier); + assert_eq!(t_price as u128, market.amm.peg_multiplier()); assert_eq!(update_k_up.sqrt_k, 501 * AMM_RESERVE_PRECISION); assert_eq!(update_k_up.base_asset_reserve, 513319672130); @@ -175,7 +183,7 @@ fn calculate_k_tests() { // cost to increase k is always positive when imbalanced let cost = adjust_k_cost_and_update(&mut market, &update_k_up).unwrap(); - assert_eq!(market.amm.terminal_quote_asset_reserve, 500975411043); + assert_eq!(market.amm.terminal_quote_asset_reserve(), 500975411043); assert!(cost > 0); assert_eq!(cost, 29448); @@ -279,11 +287,11 @@ fn calculate_k_tests() { fn calculate_k_tests_wrapper_fcn() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: AMM_RESERVE_PRECISION * 55414, - quote_asset_reserve: AMM_RESERVE_PRECISION * 55530, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 36365000, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION * 66) as i128, + base_asset_reserve: (AMM_RESERVE_PRECISION * 55414).into(), + quote_asset_reserve: (AMM_RESERVE_PRECISION * 55530).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 36365000.into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION * 66) as i128).into(), ..AMM::default() }, ..PerpMarket::default() @@ -309,13 +317,13 @@ fn calculate_k_tests_wrapper_fcn() { fn amm_spread_adj_logic() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - terminal_quote_asset_reserve: 999900009999000 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 50_000_000_000, - base_asset_amount_with_amm: (AMM_RESERVE_PRECISION / 10) as i128, - base_asset_amount_long: (AMM_RESERVE_PRECISION / 10) as i128, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + terminal_quote_asset_reserve: (999900009999000 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50_000_000_000.into(), + base_asset_amount_with_amm: ((AMM_RESERVE_PRECISION / 10) as i128).into(), + base_asset_amount_long: ((AMM_RESERVE_PRECISION / 10) as i128).into(), order_step_size: 5, base_spread: 100, max_spread: 10000, @@ -329,8 +337,10 @@ fn amm_spread_adj_logic() { // todo fix this - market.amm.base_asset_amount_per_lp = 1; - market.amm.quote_asset_amount_per_lp = -QUOTE_PRECISION_I64 as i128; + market.amm.set_base_asset_amount_per_lp(1); + market + .amm + .set_quote_asset_amount_per_lp(-QUOTE_PRECISION_I64 as i128); let reserve_price = market.amm.reserve_price().unwrap(); update_spreads(&mut market, reserve_price, None).unwrap(); diff --git a/programs/drift/src/math/fees.rs b/programs/drift/src/math/fees.rs index 8431be24bf..d227f1cf18 100644 --- a/programs/drift/src/math/fees.rs +++ b/programs/drift/src/math/fees.rs @@ -265,6 +265,7 @@ fn calculate_filler_reward( let min_time_filler_reward = filler_reward_structure .time_based_reward_lower_bound + .as_u128() .safe_mul( multiplier .cast::()? diff --git a/programs/drift/src/math/fees/tests.rs b/programs/drift/src/math/fees/tests.rs index 296f3bfce5..d24470c161 100644 --- a/programs/drift/src/math/fees/tests.rs +++ b/programs/drift/src/math/fees/tests.rs @@ -53,7 +53,7 @@ mod calculate_fee_for_taker_and_maker { let mut fee_structure = FeeStructure::test_default(); fee_structure .filler_reward_structure - .time_based_reward_lower_bound = 10000000000000000; // big number + .time_based_reward_lower_bound = 10000000000000000.into(); // big number let FillFees { user_fee: taker_fee, @@ -1020,7 +1020,7 @@ mod calcuate_fee_tiers { filler_reward_structure: OrderFillerRewardStructure { reward_numerator: 10, reward_denominator: FEE_PERCENTAGE_DENOMINATOR, - time_based_reward_lower_bound: 10_000, // 1 cent + time_based_reward_lower_bound: 10_000.into(), // 1 cent }, flat_filler_fee: 10_000, referrer_reward_epoch_upper_bound: MAX_REFERRER_REWARD_EPOCH_UPPER_BOUND, diff --git a/programs/drift/src/math/floor_div.rs b/programs/drift/src/math/floor_div.rs index fb1fa0ed2a..9e07ed8c68 100644 --- a/programs/drift/src/math/floor_div.rs +++ b/programs/drift/src/math/floor_div.rs @@ -12,7 +12,6 @@ macro_rules! checked_impl { #[inline] fn checked_floor_div(&self, rhs: $t) -> Option<$t> { let quotient = self.checked_div(rhs)?; - let remainder = self.checked_rem(rhs)?; if remainder != <$t>::zero() { diff --git a/programs/drift/src/math/fulfillment/tests.rs b/programs/drift/src/math/fulfillment/tests.rs index 005bbefa63..c99da241d8 100644 --- a/programs/drift/src/math/fulfillment/tests.rs +++ b/programs/drift/src/math/fulfillment/tests.rs @@ -14,14 +14,14 @@ mod determine_perp_fulfillment_methods { fn amm_available_and_taker_doesnt_cross_maker() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -41,8 +41,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Long, @@ -69,14 +69,14 @@ mod determine_perp_fulfillment_methods { fn amm_available_and_maker_better_than_amm() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -96,8 +96,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Long, @@ -130,14 +130,14 @@ mod determine_perp_fulfillment_methods { fn amm_available_and_amm_better_than_maker() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -157,8 +157,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Long, @@ -198,14 +198,14 @@ mod determine_perp_fulfillment_methods { fn maker_amm_maker_amm_maker_ask() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -225,8 +225,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Long, @@ -264,14 +264,14 @@ mod determine_perp_fulfillment_methods { fn maker_maker_amm_ask() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -291,8 +291,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Long, @@ -337,14 +337,14 @@ mod determine_perp_fulfillment_methods { fn amm_maker_amm_maker_amm_ask() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -364,8 +364,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Long, @@ -404,14 +404,14 @@ mod determine_perp_fulfillment_methods { fn maker_amm_maker_amm_maker_bid() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -431,8 +431,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Short, @@ -470,14 +470,14 @@ mod determine_perp_fulfillment_methods { fn maker_maker_amm_bid() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -497,8 +497,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Short, @@ -535,14 +535,14 @@ mod determine_perp_fulfillment_methods { fn amm_maker_amm_maker_amm_bid() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -562,8 +562,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Short, @@ -602,14 +602,14 @@ mod determine_perp_fulfillment_methods { fn no_asks() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -629,8 +629,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Long, @@ -660,14 +660,14 @@ mod determine_perp_fulfillment_methods { fn no_bids() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -687,8 +687,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { direction: PositionDirection::Short, @@ -718,14 +718,14 @@ mod determine_perp_fulfillment_methods { fn amm_available_and_maker_crosses() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -745,8 +745,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { post_only: true, @@ -774,14 +774,14 @@ mod determine_perp_fulfillment_methods { fn amm_available_and_maker_doesnt_cross() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 10000000, @@ -801,8 +801,8 @@ mod determine_perp_fulfillment_methods { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); let taker_order = Order { post_only: true, diff --git a/programs/drift/src/math/funding.rs b/programs/drift/src/math/funding.rs index c723cb37bb..09c915027d 100644 --- a/programs/drift/src/math/funding.rs +++ b/programs/drift/src/math/funding.rs @@ -27,7 +27,7 @@ pub fn calculate_funding_rate_long_short( ) -> DriftResult<(i128, i128, i128)> { // Calculate the funding payment owed by the net_market_position if funding is not capped // If the net market position owes funding payment, the protocol receives payment - let settled_net_market_position = market.amm.base_asset_amount_with_amm; + let settled_net_market_position = market.amm.base_asset_amount_with_amm(); let net_market_position_funding_payment = calculate_funding_payment_in_quote_precision(funding_rate, settled_net_market_position)?; @@ -35,10 +35,12 @@ pub fn calculate_funding_rate_long_short( // If the uncapped_funding_pnl is positive, the protocol receives money. if uncapped_funding_pnl >= 0 { - market.amm.total_fee_minus_distributions = market - .amm - .total_fee_minus_distributions - .safe_add(uncapped_funding_pnl)?; + market.amm.set_total_fee_minus_distributions( + market + .amm + .total_fee_minus_distributions() + .safe_add(uncapped_funding_pnl)?, + ); market.amm.net_revenue_since_last_funding = market .amm @@ -53,7 +55,7 @@ pub fn calculate_funding_rate_long_short( let new_total_fee_minus_distributions = market .amm - .total_fee_minus_distributions + .total_fee_minus_distributions() .safe_add(capped_funding_pnl)?; // protocol is paying part of funding imbalance @@ -67,7 +69,9 @@ pub fn calculate_funding_rate_long_short( return Err(ErrorCode::InvalidFundingProfitability); } } - market.amm.total_fee_minus_distributions = new_total_fee_minus_distributions; + market + .amm + .set_total_fee_minus_distributions(new_total_fee_minus_distributions); market.amm.net_revenue_since_last_funding = market .amm .net_revenue_since_last_funding @@ -107,9 +111,9 @@ fn calculate_capped_funding_rate( let funding_payment_from_users = calculate_funding_payment_in_quote_precision( funding_rate, if funding_rate > 0 { - market.amm.base_asset_amount_long + market.amm.base_asset_amount_long() } else { - market.amm.base_asset_amount_short + market.amm.base_asset_amount_short() }, )?; @@ -122,13 +126,13 @@ fn calculate_capped_funding_rate( // longs receive calculate_funding_rate_from_pnl_limit( funding_rate_pnl_limit, - market.amm.base_asset_amount_long, + market.amm.base_asset_amount_long(), )? } else { // shorts receive calculate_funding_rate_from_pnl_limit( funding_rate_pnl_limit, - market.amm.base_asset_amount_short, + market.amm.base_asset_amount_short(), )? } } else { diff --git a/programs/drift/src/math/funding/tests.rs b/programs/drift/src/math/funding/tests.rs index fb46a5cbce..b8771fb492 100644 --- a/programs/drift/src/math/funding/tests.rs +++ b/programs/drift/src/math/funding/tests.rs @@ -63,15 +63,15 @@ fn balanced_funding_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: sqrt_k, - quote_asset_reserve: sqrt_k, - sqrt_k, - peg_multiplier: px, - base_asset_amount_with_amm: 0, - base_asset_amount_long: 12295081967, - base_asset_amount_short: -12295081967, - total_exchange_fee: (count * 1000000783) / 2888, - total_fee_minus_distributions: (count * 1000000783) as i128, + base_asset_reserve: sqrt_k.into(), + quote_asset_reserve: sqrt_k.into(), + sqrt_k: sqrt_k.into(), + peg_multiplier: px.into(), + base_asset_amount_with_amm: 0.into(), + base_asset_amount_long: 12295081967.into(), + base_asset_amount_short: (-12295081967).into(), + total_exchange_fee: ((count * 1000000783) / 2888).into(), + total_fee_minus_distributions: ((count * 1000000783) as i128).into(), last_mark_price_twap: (px * 999 / 1000) as u64, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (px * 1001 / 1000) as i64, @@ -115,15 +115,15 @@ fn balanced_funding_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: sqrt_k, - quote_asset_reserve: sqrt_k, - sqrt_k, - peg_multiplier: px, - base_asset_amount_with_amm: 0, - base_asset_amount_long: 7845926098328, - base_asset_amount_short: -7845926098328, - total_exchange_fee: (count * 1000000783) / 2888, - total_fee_minus_distributions: (count * 1000000783) as i128, + base_asset_reserve: sqrt_k.into(), + quote_asset_reserve: sqrt_k.into(), + sqrt_k: sqrt_k.into(), + peg_multiplier: px.into(), + base_asset_amount_with_amm: 0.into(), + base_asset_amount_long: 7845926098328.into(), + base_asset_amount_short: (-7845926098328).into(), + total_exchange_fee: ((count * 1000000783) / 2888).into(), + total_fee_minus_distributions: ((count * 1000000783) as i128).into(), last_mark_price_twap: (px * 999 / 1000) as u64, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (px * 888 / 1000) as i64, @@ -172,15 +172,15 @@ fn capped_sym_funding_test() { // more shorts than longs, positive funding, 1/3 of fee pool too small let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - base_asset_amount_with_amm: -12295081967, - base_asset_amount_long: 12295081967, - base_asset_amount_short: -12295081967 * 2, - total_exchange_fee: QUOTE_PRECISION / 2, - total_fee_minus_distributions: (QUOTE_PRECISION as i128) / 2, + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + base_asset_amount_with_amm: (-12295081967).into(), + base_asset_amount_long: 12295081967.into(), + base_asset_amount_short: (-12295081967 * 2).into(), + total_exchange_fee: (QUOTE_PRECISION / 2).into(), + total_fee_minus_distributions: ((QUOTE_PRECISION as i128) / 2).into(), last_mark_price_twap: 50 * PRICE_PRECISION_U64, historical_oracle_data: HistoricalOracleData { @@ -212,20 +212,20 @@ fn capped_sym_funding_test() { assert_eq!(short_funding, 24222164); // only spend 1/3 of fee pool, ((.5-.416667)) * 3 < .25 - assert_eq!(market.amm.total_fee_minus_distributions, 416667); + assert_eq!(market.amm.total_fee_minus_distributions(), 416667); // more longs than shorts, positive funding, amm earns funding market = PerpMarket { amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - base_asset_amount_with_amm: 12295081967, - base_asset_amount_long: 12295081967 * 2, - base_asset_amount_short: -12295081967, - total_exchange_fee: QUOTE_PRECISION / 2, - total_fee_minus_distributions: (QUOTE_PRECISION as i128) / 2, + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + base_asset_amount_with_amm: 12295081967.into(), + base_asset_amount_long: (12295081967 * 2).into(), + base_asset_amount_short: (-12295081967).into(), + total_exchange_fee: (QUOTE_PRECISION / 2).into(), + total_fee_minus_distributions: ((QUOTE_PRECISION as i128) / 2).into(), last_mark_price_twap: 50 * PRICE_PRECISION_U64, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: (49 * PRICE_PRECISION) as i64, @@ -246,7 +246,7 @@ fn capped_sym_funding_test() { assert_eq!(long_funding, balanced_funding); assert_eq!(long_funding, short_funding); - let new_fees = market.amm.total_fee_minus_distributions; + let new_fees = market.amm.total_fee_minus_distributions(); assert!(new_fees > QUOTE_PRECISION as i128 / 2); assert_eq!(new_fees, 1012295); // made over $.50 } @@ -285,16 +285,16 @@ fn max_funding_rates() { amm: AMM { oracle: oracle_price_key, - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - base_asset_amount_with_amm: -12295081967, //~12 - base_asset_amount_long: 12295081967, - base_asset_amount_short: -12295081967 * 2, - base_asset_amount_with_unsettled_lp: -((AMM_RESERVE_PRECISION * 500) as i128), //wowsers - total_exchange_fee: QUOTE_PRECISION / 2, - total_fee_minus_distributions: ((QUOTE_PRECISION * 99999) as i128), + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + base_asset_amount_with_amm: (-12295081967).into(), //~12 + base_asset_amount_long: 12295081967.into(), + base_asset_amount_short: (-12295081967 * 2).into(), + base_asset_amount_with_unsettled_lp: (-((AMM_RESERVE_PRECISION * 500) as i128)).into(), //wowsers + total_exchange_fee: (QUOTE_PRECISION / 2).into(), + total_fee_minus_distributions: ((QUOTE_PRECISION * 99999) as i128).into(), last_mark_price_twap: 50 * PRICE_PRECISION_U64, historical_oracle_data: HistoricalOracleData { @@ -372,15 +372,16 @@ fn unsettled_funding_pnl() { amm: AMM { oracle: oracle_price_key, - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 50000000, - base_asset_amount_with_amm: -12295081967 + -((AMM_RESERVE_PRECISION * 500) as i128), //~ 12 - 500 - base_asset_amount_long: 12295081967, - base_asset_amount_short: -12295081967 * 2, - total_exchange_fee: QUOTE_PRECISION / 2, - total_fee_minus_distributions: ((QUOTE_PRECISION * 99999) as i128), + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 50000000.into(), + base_asset_amount_with_amm: (-12295081967 + -((AMM_RESERVE_PRECISION * 500) as i128)) + .into(), //~ 12 - 500 + base_asset_amount_long: 12295081967.into(), + base_asset_amount_short: (-12295081967 * 2).into(), + total_exchange_fee: (QUOTE_PRECISION / 2).into(), + total_fee_minus_distributions: ((QUOTE_PRECISION * 99999) as i128).into(), last_mark_price_twap: 50 * PRICE_PRECISION_U64, historical_oracle_data: HistoricalOracleData { @@ -455,7 +456,7 @@ fn unsettled_funding_pnl() { ) .unwrap(); assert_eq!(block_funding_rate_update, false); - assert_eq!(market.amm.total_fee_minus_distributions, 99999000000); + assert_eq!(market.amm.total_fee_minus_distributions(), 99999000000); let did_succeed = update_funding_rate( 0, @@ -477,14 +478,14 @@ fn unsettled_funding_pnl() { 51000000 ); - assert_eq!(market.amm.cumulative_funding_rate_long, -140002666); // negative funding - assert_eq!(market.amm.cumulative_funding_rate_short, -140002666); + assert_eq!(market.amm.cumulative_funding_rate_long(), -140002666); // negative funding + assert_eq!(market.amm.cumulative_funding_rate_short(), -140002666); assert_eq!(market.amm.last_funding_rate, -140002666); assert_eq!(market.amm.last_24h_avg_funding_rate, -140002666 / 24 + 1); assert_eq!(market.amm.last_funding_rate_ts, now); assert_eq!(market.amm.net_revenue_since_last_funding, 0); // back to 0 - assert_eq!(market.amm.total_fee_minus_distributions, 100070722677); //71.722677 gain - assert_eq!(market.amm.total_fee, 0); + assert_eq!(market.amm.total_fee_minus_distributions(), 100070722677); //71.722677 gain + assert_eq!(market.amm.total_fee(), 0); assert_ne!(market.amm.net_unsettled_funding_pnl, 0); // important: imbalanced market adds funding rev assert_eq!(market.amm.net_unsettled_funding_pnl, -71722677); // users up diff --git a/programs/drift/src/math/insurance.rs b/programs/drift/src/math/insurance.rs index 4658f97db6..10329814c6 100644 --- a/programs/drift/src/math/insurance.rs +++ b/programs/drift/src/math/insurance.rs @@ -87,18 +87,21 @@ pub fn calculate_if_shares_lost( spot_market: &SpotMarket, insurance_fund_vault_balance: u64, ) -> DriftResult { - let n_shares = insurance_fund_stake.last_withdraw_request_shares; + let n_shares = insurance_fund_stake.last_withdraw_request_shares(); let amount = if_shares_to_vault_amount( n_shares, - spot_market.insurance_fund.total_shares, + spot_market.insurance_fund.total_shares(), insurance_fund_vault_balance, )?; let if_shares_lost = if amount > insurance_fund_stake.last_withdraw_request_value { let new_n_shares = vault_amount_to_if_shares( insurance_fund_stake.last_withdraw_request_value, - spot_market.insurance_fund.total_shares.safe_sub(n_shares)?, + spot_market + .insurance_fund + .total_shares() + .safe_sub(n_shares)?, insurance_fund_vault_balance .safe_sub(insurance_fund_stake.last_withdraw_request_value)?, )?; diff --git a/programs/drift/src/math/insurance/tests.rs b/programs/drift/src/math/insurance/tests.rs index 46287cedb3..69cb54095f 100644 --- a/programs/drift/src/math/insurance/tests.rs +++ b/programs/drift/src/math/insurance/tests.rs @@ -101,12 +101,12 @@ pub fn basic_stake_if_test() { pub fn if_shares_lost_test() { let _amount = QUOTE_PRECISION as u64; // $1 let mut spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), insurance_fund: InsuranceFund { unstaking_period: 0, - total_shares: 1000 * QUOTE_PRECISION, - user_shares: 1000 * QUOTE_PRECISION, + total_shares: (1000 * QUOTE_PRECISION).into(), + user_shares: (1000 * QUOTE_PRECISION).into(), ..InsuranceFund::default() }, ..SpotMarket::default() @@ -116,7 +116,7 @@ pub fn if_shares_lost_test() { if_stake .update_if_shares(100 * QUOTE_PRECISION, &spot_market) .unwrap(); - if_stake.last_withdraw_request_shares = 100 * QUOTE_PRECISION; + if_stake.set_last_withdraw_request_shares(100 * QUOTE_PRECISION); if_stake.last_withdraw_request_value = ((100 * QUOTE_PRECISION) - 1) as u64; let if_balance = (1000 * QUOTE_PRECISION) as u64; @@ -126,14 +126,38 @@ pub fn if_shares_lost_test() { assert_eq!(lost_shares, 2); let if_balance = if_balance + (100 * QUOTE_PRECISION) as u64; - spot_market.insurance_fund.total_shares += 100 * QUOTE_PRECISION; - spot_market.insurance_fund.user_shares += 100 * QUOTE_PRECISION; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_add(100 * QUOTE_PRECISION) + .unwrap(), + ); + spot_market.insurance_fund.set_user_shares( + spot_market + .insurance_fund + .user_shares() + .safe_add(100 * QUOTE_PRECISION) + .unwrap(), + ); let lost_shares = calculate_if_shares_lost(&if_stake, &spot_market, if_balance).unwrap(); assert_eq!(lost_shares, 2); // giving up $5 of gains let if_balance = if_balance - (100 * QUOTE_PRECISION) as u64; - spot_market.insurance_fund.total_shares -= 100 * QUOTE_PRECISION; - spot_market.insurance_fund.user_shares -= 100 * QUOTE_PRECISION; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_sub(100 * QUOTE_PRECISION) + .unwrap(), + ); + spot_market.insurance_fund.set_user_shares( + spot_market + .insurance_fund + .user_shares() + .safe_sub(100 * QUOTE_PRECISION) + .unwrap(), + ); let lost_shares = calculate_if_shares_lost(&if_stake, &spot_market, if_balance).unwrap(); assert_eq!(lost_shares, 2); // giving up $5 of gains @@ -150,19 +174,13 @@ pub fn if_shares_lost_test() { // take back gain and total_if_shares alter w/o user alter let if_balance = (2100 * QUOTE_PRECISION) as u64; - spot_market.insurance_fund.total_shares *= 2; + spot_market.insurance_fund.set_total_shares( + spot_market + .insurance_fund + .total_shares() + .safe_mul(2) + .unwrap(), + ); let lost_shares = calculate_if_shares_lost(&if_stake, &spot_market, if_balance).unwrap(); assert_eq!(lost_shares, 5_000_001); // giving up $5 of gains - - let if_balance = (2100 * QUOTE_PRECISION * 10) as u64; - - let expected_gain_if_no_loss = if_balance * 100 / 2000; - assert_eq!(expected_gain_if_no_loss, 1_050_000_000); - let lost_shares = calculate_if_shares_lost(&if_stake, &spot_market, if_balance).unwrap(); - assert_eq!(lost_shares, 90_909_092); // giving up $5 of gains - assert_eq!( - (9090908 * if_balance / ((spot_market.insurance_fund.total_shares - lost_shares) as u64)) - < if_stake.last_withdraw_request_value, - true - ); } diff --git a/programs/drift/src/math/liquidation.rs b/programs/drift/src/math/liquidation.rs index dbe608ceaa..229575f10f 100644 --- a/programs/drift/src/math/liquidation.rs +++ b/programs/drift/src/math/liquidation.rs @@ -265,9 +265,9 @@ pub fn calculate_funding_rate_deltas_to_resolve_bankruptcy( ) -> DriftResult { let total_base_asset_amount = market .amm - .base_asset_amount_long + .base_asset_amount_long() .abs() - .safe_add(market.amm.base_asset_amount_short.abs())?; + .safe_add(market.amm.base_asset_amount_short().abs())?; validate!( total_base_asset_amount != 0, @@ -286,13 +286,13 @@ pub fn calculate_cumulative_deposit_interest_delta_to_resolve_bankruptcy( spot_market: &SpotMarket, ) -> DriftResult { let total_deposits = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), spot_market, &SpotBalanceType::Deposit, )?; spot_market - .cumulative_deposit_interest + .cumulative_deposit_interest() .safe_mul(borrow)? .safe_div_ceil(total_deposits) .or(Ok(0)) diff --git a/programs/drift/src/math/liquidation/tests.rs b/programs/drift/src/math/liquidation/tests.rs index 04c066b76e..4566d017a6 100644 --- a/programs/drift/src/math/liquidation/tests.rs +++ b/programs/drift/src/math/liquidation/tests.rs @@ -503,8 +503,8 @@ mod calculate_funding_rate_deltas_to_resolve_bankruptcy { let loss = -QUOTE_PRECISION_I128; let market = PerpMarket { amm: AMM { - base_asset_amount_long: 0, - base_asset_amount_short: 0, + base_asset_amount_long: 0.into(), + base_asset_amount_short: 0.into(), ..AMM::default() }, ..PerpMarket::default() @@ -518,8 +518,8 @@ mod calculate_funding_rate_deltas_to_resolve_bankruptcy { let loss = -100 * QUOTE_PRECISION_I128; let market = PerpMarket { amm: AMM { - base_asset_amount_long: 7 * BASE_PRECISION_I128, - base_asset_amount_short: -4 * BASE_PRECISION_I128, + base_asset_amount_long: (7 * BASE_PRECISION_I128).into(), + base_asset_amount_short: (-4 * BASE_PRECISION_I128).into(), ..AMM::default() }, ..PerpMarket::default() @@ -543,8 +543,8 @@ mod calculate_cumulative_deposit_interest_delta_to_resolve_bankruptcy { fn zero_total_deposits() { let loss = 100 * QUOTE_PRECISION; let spot_market = SpotMarket { - deposit_balance: 0, - cumulative_deposit_interest: 1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000, + deposit_balance: 0.into(), + cumulative_deposit_interest: (1111 * SPOT_CUMULATIVE_INTEREST_PRECISION / 1000).into(), ..SpotMarket::default() }; @@ -559,8 +559,8 @@ mod calculate_cumulative_deposit_interest_delta_to_resolve_bankruptcy { fn non_zero_total_deposits() { let loss = 11 * QUOTE_PRECISION; let spot_market = SpotMarket { - deposit_balance: 120 * SPOT_BALANCE_PRECISION, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + deposit_balance: (120 * SPOT_BALANCE_PRECISION).into(), + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, ..SpotMarket::default() }; diff --git a/programs/drift/src/math/margin.rs b/programs/drift/src/math/margin.rs index fc31624842..ebeb029dca 100644 --- a/programs/drift/src/math/margin.rs +++ b/programs/drift/src/math/margin.rs @@ -154,9 +154,9 @@ pub fn calculate_perp_position_value_and_pnl( // the funding must be calculated before calculated the unrealized pnl w simulated lp position let unrealized_funding = calculate_funding_payment( if market_position.base_asset_amount > 0 { - market.amm.cumulative_funding_rate_long + market.amm.cumulative_funding_rate_long() } else { - market.amm.cumulative_funding_rate_short + market.amm.cumulative_funding_rate_short() }, market_position, )?; @@ -1060,9 +1060,9 @@ pub fn calculate_user_equity( let unrealized_funding = calculate_funding_payment( if market_position.base_asset_amount > 0 { - market.amm.cumulative_funding_rate_long + market.amm.cumulative_funding_rate_long() } else { - market.amm.cumulative_funding_rate_short + market.amm.cumulative_funding_rate_short() }, market_position, )?; diff --git a/programs/drift/src/math/margin/tests.rs b/programs/drift/src/math/margin/tests.rs index d4b1eefd2e..155068212f 100644 --- a/programs/drift/src/math/margin/tests.rs +++ b/programs/drift/src/math/margin/tests.rs @@ -195,34 +195,34 @@ mod test { decimals: 9, imf_factor: 0, scale_initial_asset_weight_start: 500_000 * QUOTE_PRECISION_U64, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), ..SpotMarket::default() }; let oracle_price = 25 * PRICE_PRECISION_I64; - sol_spot_market.deposit_balance = SPOT_BALANCE_PRECISION; + sol_spot_market.set_deposit_balance(SPOT_BALANCE_PRECISION); let asset_weight = sol_spot_market .get_scaled_initial_asset_weight(oracle_price) .unwrap(); assert_eq!(asset_weight, 9000); - sol_spot_market.deposit_balance = 20000 * SPOT_BALANCE_PRECISION; + sol_spot_market.set_deposit_balance(20000 * SPOT_BALANCE_PRECISION); let asset_weight = sol_spot_market .get_scaled_initial_asset_weight(oracle_price) .unwrap(); assert_eq!(asset_weight, 9000); - sol_spot_market.deposit_balance = 40000 * SPOT_BALANCE_PRECISION; + sol_spot_market.set_deposit_balance(40000 * SPOT_BALANCE_PRECISION); let asset_weight = sol_spot_market .get_scaled_initial_asset_weight(oracle_price) .unwrap(); assert_eq!(asset_weight, 4500); - sol_spot_market.deposit_balance = 60000 * SPOT_BALANCE_PRECISION; + sol_spot_market.set_deposit_balance(60000 * SPOT_BALANCE_PRECISION); let asset_weight = sol_spot_market .get_scaled_initial_asset_weight(oracle_price) .unwrap(); @@ -235,11 +235,11 @@ mod test { let mut market = PerpMarket { market_index: 0, amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 22_100_000_000, - base_asset_amount_with_amm: -(12295081967_i128), + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 22_100_000_000.into(), + base_asset_amount_with_amm: (-(12295081967_i128)).into(), max_spread: 1000, ..AMM::default() }, @@ -443,11 +443,11 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -457,8 +457,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -534,11 +534,11 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -548,8 +548,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -625,13 +625,13 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -641,15 +641,15 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, initial_liability_weight: 12 * SPOT_WEIGHT_PRECISION / 10, maintenance_liability_weight: 11 * SPOT_WEIGHT_PRECISION / 10, liquidator_fee: LIQUIDATION_FEE_PRECISION / 1000, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), ..SpotMarket::default() }; create_anchor_account_info!(sol_spot_market, SpotMarket, sol_spot_market_account_info); @@ -716,14 +716,14 @@ mod calculate_margin_requirement_and_total_collateral { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -739,11 +739,11 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -753,8 +753,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -913,14 +913,14 @@ mod calculate_margin_requirement_and_total_collateral { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -936,11 +936,11 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -950,8 +950,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1098,14 +1098,14 @@ mod calculate_margin_requirement_and_total_collateral { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -1121,11 +1121,11 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1135,8 +1135,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1224,14 +1224,14 @@ mod calculate_margin_requirement_and_total_collateral { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -1247,11 +1247,11 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1261,8 +1261,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION / 99, // big loss - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: (SPOT_CUMULATIVE_INTEREST_PRECISION / 99).into(), // big loss + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1347,14 +1347,14 @@ mod calculate_margin_requirement_and_total_collateral { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -1370,11 +1370,11 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1384,8 +1384,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1520,11 +1520,11 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap_5min: PRICE_PRECISION_I64 * 9 / 10, @@ -1537,8 +1537,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1614,14 +1614,14 @@ mod calculate_margin_requirement_and_total_collateral { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -1637,12 +1637,12 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1652,8 +1652,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1731,14 +1731,14 @@ mod calculate_margin_requirement_and_total_collateral { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -1754,12 +1754,12 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1769,8 +1769,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1843,14 +1843,14 @@ mod calculate_margin_requirement_and_total_collateral { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -1866,12 +1866,12 @@ mod calculate_margin_requirement_and_total_collateral { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1881,8 +1881,8 @@ mod calculate_margin_requirement_and_total_collateral { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1985,14 +1985,14 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -2008,11 +2008,11 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -2022,8 +2022,8 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -2096,14 +2096,14 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -2120,11 +2120,11 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -2134,8 +2134,8 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -2253,14 +2253,14 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -2276,11 +2276,11 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -2290,8 +2290,8 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -2379,11 +2379,11 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::PythStableCoin, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), oracle: usdc_oracle_price_key, @@ -2394,8 +2394,8 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { market_index: 1, oracle_source: OracleSource::Pyth, oracle: usdc_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -2530,13 +2530,13 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::PythStableCoin, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, - borrow_balance: 1000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), + borrow_balance: (1000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), oracle: usdc_oracle_price_key, @@ -2547,8 +2547,8 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { market_index: 1, oracle_source: OracleSource::Pyth, oracle: usdc_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -2676,11 +2676,11 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::PythStableCoin, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_price(usdc_price), oracle: usdc_oracle_price_key, @@ -2691,8 +2691,8 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { market_index: 1, oracle_source: OracleSource::Pyth, oracle: usdc_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -2711,14 +2711,14 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -2830,14 +2830,14 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -2853,11 +2853,11 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -2867,8 +2867,8 @@ mod calculate_margin_requirement_and_total_collateral_and_liability_info { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -2970,11 +2970,11 @@ mod calculate_max_withdrawable_amount { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -2984,8 +2984,8 @@ mod calculate_max_withdrawable_amount { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3056,12 +3056,12 @@ mod calculate_max_withdrawable_amount { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, liquidator_fee: 0, @@ -3073,8 +3073,8 @@ mod calculate_max_withdrawable_amount { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3144,12 +3144,12 @@ mod calculate_max_withdrawable_amount { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), initial_liability_weight: SPOT_WEIGHT_PRECISION, maintenance_liability_weight: SPOT_WEIGHT_PRECISION, liquidator_fee: 0, @@ -3161,8 +3161,8 @@ mod calculate_max_withdrawable_amount { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3260,11 +3260,11 @@ mod validate_spot_margin_trading { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; @@ -3273,8 +3273,8 @@ mod validate_spot_margin_trading { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3343,11 +3343,11 @@ mod validate_spot_margin_trading { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; @@ -3356,8 +3356,8 @@ mod validate_spot_margin_trading { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3426,11 +3426,11 @@ mod validate_spot_margin_trading { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; @@ -3439,8 +3439,8 @@ mod validate_spot_margin_trading { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3509,11 +3509,11 @@ mod validate_spot_margin_trading { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; @@ -3522,8 +3522,8 @@ mod validate_spot_margin_trading { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3592,11 +3592,11 @@ mod validate_spot_margin_trading { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; @@ -3605,8 +3605,8 @@ mod validate_spot_margin_trading { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3675,11 +3675,11 @@ mod validate_spot_margin_trading { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; @@ -3688,8 +3688,8 @@ mod validate_spot_margin_trading { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3755,14 +3755,14 @@ mod validate_spot_margin_trading { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -3780,11 +3780,11 @@ mod validate_spot_margin_trading { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; @@ -3793,8 +3793,8 @@ mod validate_spot_margin_trading { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -3902,14 +3902,14 @@ mod calculate_user_equity { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -3930,8 +3930,8 @@ mod calculate_user_equity { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -3939,11 +3939,11 @@ mod calculate_user_equity { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -4000,14 +4000,14 @@ mod calculate_user_equity { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -4028,8 +4028,8 @@ mod calculate_user_equity { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -4037,11 +4037,11 @@ mod calculate_user_equity { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -4101,11 +4101,11 @@ mod calculate_user_equity { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -4115,8 +4115,8 @@ mod calculate_user_equity { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -4354,11 +4354,11 @@ mod pools { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), pool_id: 1, @@ -4487,14 +4487,14 @@ mod get_margin_calculation_for_disable_high_leverage_mode { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 101 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_step_size: 10000000, oracle: sol_oracle_price_key, ..AMM::default() @@ -4510,11 +4510,11 @@ mod get_margin_calculation_for_disable_high_leverage_mode { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -4524,8 +4524,8 @@ mod get_margin_calculation_for_disable_high_leverage_mode { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, diff --git a/programs/drift/src/math/oracle.rs b/programs/drift/src/math/oracle.rs index 92bf2a47e8..8ec3555a02 100644 --- a/programs/drift/src/math/oracle.rs +++ b/programs/drift/src/math/oracle.rs @@ -1,4 +1,4 @@ -use borsh::{BorshDeserialize, BorshSerialize}; +use anchor_lang::prelude::borsh::{BorshDeserialize, BorshSerialize}; use crate::error::{DriftResult, ErrorCode}; use crate::math::amm; diff --git a/programs/drift/src/math/oracle/tests.rs b/programs/drift/src/math/oracle/tests.rs index adf34a28b4..29ea89984b 100644 --- a/programs/drift/src/math/oracle/tests.rs +++ b/programs/drift/src/math/oracle/tests.rs @@ -15,9 +15,9 @@ fn calculate_oracle_valid() { let px = 32 * PRICE_PRECISION; let amm = AMM { - base_asset_reserve: 2 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 2 * AMM_RESERVE_PRECISION, - peg_multiplier: 33 * PEG_PRECISION, + base_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (2 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (33 * PEG_PRECISION).into(), historical_oracle_data: HistoricalOracleData { last_oracle_price_twap_5min: px as i64, last_oracle_price_twap: (px as i64) - 1000, diff --git a/programs/drift/src/math/orders/tests.rs b/programs/drift/src/math/orders/tests.rs index ffb3d11380..26a82f87d9 100644 --- a/programs/drift/src/math/orders/tests.rs +++ b/programs/drift/src/math/orders/tests.rs @@ -466,7 +466,7 @@ mod get_max_fill_amounts { #[test] fn fully_collateralized_selling_base() { let base_market = SpotMarket { - deposit_balance: 4 * 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (4 * 100 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 4 * 100 * LAMPORTS_PER_SOL_U64, ..SpotMarket::default_base_market() }; @@ -546,7 +546,7 @@ mod get_max_fill_amounts { #[test] fn selling_base_with_borrow_liquidity_greater_than_order() { let base_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 100 * SPOT_BALANCE_PRECISION as u64, ..SpotMarket::default_base_market() }; @@ -588,7 +588,7 @@ mod get_max_fill_amounts { fn fully_collateralized_selling_quote() { let base_market = SpotMarket::default_base_market(); let quote_market = SpotMarket { - deposit_balance: 4 * 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (4 * 100 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 4 * 100 * QUOTE_PRECISION_U64, ..SpotMarket::default_quote_market() }; @@ -668,7 +668,7 @@ mod get_max_fill_amounts { fn selling_quote_with_borrow_liquidity_greater_than_order() { let base_market = SpotMarket::default_base_market(); let quote_market = SpotMarket { - deposit_balance: 100 * SPOT_BALANCE_PRECISION, + deposit_balance: (100 * SPOT_BALANCE_PRECISION).into(), deposit_token_twap: 100 * QUOTE_PRECISION_U64, ..SpotMarket::default_quote_market() @@ -1108,11 +1108,11 @@ mod calculate_max_spot_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1122,8 +1122,8 @@ mod calculate_max_spot_order_size { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1215,11 +1215,11 @@ mod calculate_max_spot_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1229,8 +1229,8 @@ mod calculate_max_spot_order_size { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1323,11 +1323,11 @@ mod calculate_max_spot_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1337,8 +1337,8 @@ mod calculate_max_spot_order_size { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1430,11 +1430,11 @@ mod calculate_max_spot_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1444,8 +1444,8 @@ mod calculate_max_spot_order_size { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1520,11 +1520,11 @@ mod calculate_max_spot_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1534,8 +1534,8 @@ mod calculate_max_spot_order_size { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1628,11 +1628,11 @@ mod calculate_max_spot_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1642,8 +1642,8 @@ mod calculate_max_spot_order_size { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1736,11 +1736,11 @@ mod calculate_max_spot_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1750,8 +1750,8 @@ mod calculate_max_spot_order_size { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1844,11 +1844,11 @@ mod calculate_max_spot_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -1858,8 +1858,8 @@ mod calculate_max_spot_order_size { market_index: 1, oracle_source: OracleSource::Pyth, oracle: sol_oracle_price_key, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, initial_asset_weight: 8 * SPOT_WEIGHT_PRECISION / 10, maintenance_asset_weight: 9 * SPOT_WEIGHT_PRECISION / 10, @@ -1985,14 +1985,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2013,8 +2013,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2022,11 +2022,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -2107,14 +2107,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2135,8 +2135,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2144,11 +2144,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -2212,14 +2212,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2240,8 +2240,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2249,11 +2249,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -2334,14 +2334,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2362,8 +2362,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2371,11 +2371,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -2439,14 +2439,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2467,8 +2467,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2476,11 +2476,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -2562,14 +2562,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2590,8 +2590,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2599,11 +2599,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -2685,14 +2685,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2714,8 +2714,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2723,11 +2723,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -2808,14 +2808,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2836,8 +2836,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2845,11 +2845,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -2931,14 +2931,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -2959,8 +2959,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -2968,11 +2968,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -3054,14 +3054,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -3083,8 +3083,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -3092,11 +3092,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -3177,14 +3177,14 @@ mod calculate_max_perp_order_size { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -3208,8 +3208,8 @@ mod calculate_max_perp_order_size { status: MarketStatus::Active, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); create_anchor_account_info!(market, PerpMarket, market_account_info); let market_map = PerpMarketMap::load_one(&market_account_info, true).unwrap(); @@ -3217,11 +3217,11 @@ mod calculate_max_perp_order_size { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 10000 * SPOT_BALANCE_PRECISION, + deposit_balance: (10000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: PRICE_PRECISION_I64, @@ -3974,9 +3974,9 @@ pub mod get_price_for_perp_order { #[test] fn bid_crosses_vamm_ask() { let amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_tick_size: 100000, short_spread: BID_ASK_SPREAD_PRECISION_U128 as u32 / 100, ..AMM::default() @@ -4005,9 +4005,9 @@ pub mod get_price_for_perp_order { #[test] fn bid_doesnt_cross_vamm_ask() { let amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_tick_size: 100000, short_spread: BID_ASK_SPREAD_PRECISION_U128 as u32 / 100, ..AMM::default() @@ -4030,9 +4030,9 @@ pub mod get_price_for_perp_order { #[test] fn ask_crosses_vamm_ask() { let amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_tick_size: 100000, long_spread: BID_ASK_SPREAD_PRECISION_U128 as u32 / 100, ..AMM::default() @@ -4061,9 +4061,9 @@ pub mod get_price_for_perp_order { #[test] fn ask_doesnt_cross_vamm_ask() { let amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), order_tick_size: 100000, long_spread: BID_ASK_SPREAD_PRECISION_U128 as u32 / 100, ..AMM::default() @@ -4498,14 +4498,14 @@ mod fallback_price_logic { fn test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - bid_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - ask_quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + bid_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + ask_quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), max_slippage_ratio: 50, max_fill_reserve_fraction: 100, order_step_size: 1000, @@ -4527,8 +4527,8 @@ mod fallback_price_logic { status: MarketStatus::Initialized, ..PerpMarket::default_test() }; - market.amm.max_base_asset_reserve = u128::MAX; - market.amm.min_base_asset_reserve = 0; + market.amm.set_max_base_asset_reserve(u128::MAX); + market.amm.set_min_base_asset_reserve(0); // fallback are wide from oracle cause twaps arent set on amm let result = market diff --git a/programs/drift/src/math/position.rs b/programs/drift/src/math/position.rs index e40c75205d..288e1ed1ce 100644 --- a/programs/drift/src/math/position.rs +++ b/programs/drift/src/math/position.rs @@ -37,9 +37,9 @@ pub fn calculate_base_asset_value(base_asset_amount: i128, amm: &AMM) -> DriftRe let swap_direction = swap_direction_to_close_position(base_asset_amount); let (base_asset_reserve, quote_asset_reserve) = - (amm.base_asset_reserve, amm.quote_asset_reserve); + (amm.base_asset_reserve(), amm.quote_asset_reserve()); - let amm_lp_shares = amm.sqrt_k; + let amm_lp_shares = amm.sqrt_k(); let (new_quote_asset_reserve, _new_base_asset_reserve) = amm::calculate_swap_output( base_asset_amount.unsigned_abs(), @@ -52,7 +52,7 @@ pub fn calculate_base_asset_value(base_asset_amount: i128, amm: &AMM) -> DriftRe quote_asset_reserve, new_quote_asset_reserve, swap_direction, - amm.peg_multiplier, + amm.peg_multiplier(), )?; Ok(base_asset_value) diff --git a/programs/drift/src/math/repeg.rs b/programs/drift/src/math/repeg.rs index 995e425f64..ac6e9af8f5 100644 --- a/programs/drift/src/math/repeg.rs +++ b/programs/drift/src/math/repeg.rs @@ -92,9 +92,9 @@ pub fn calculate_repeg_validity( // if oracle is valid: check on size/direction of repeg if oracle_is_valid { let reserve_price_after = amm::calculate_price( - market.amm.quote_asset_reserve, - market.amm.base_asset_reserve, - market.amm.peg_multiplier, + market.amm.quote_asset_reserve(), + market.amm.base_asset_reserve(), + market.amm.peg_multiplier(), )?; let oracle_conf_band_top = oracle_price_u128.safe_add(oracle_conf)?; @@ -179,18 +179,18 @@ pub fn adjust_peg_cost( ) -> DriftResult<(PerpMarket, i128)> { let mut market_clone = *market; - let cost = if new_peg_candidate != market_clone.amm.peg_multiplier { + let cost = if new_peg_candidate != market_clone.amm.peg_multiplier() { // Find the net market value before adjusting peg let (current_net_market_value, _) = calculate_base_asset_value_and_pnl( - market_clone.amm.base_asset_amount_with_amm, + market_clone.amm.base_asset_amount_with_amm(), 0, &market_clone.amm, )?; - market_clone.amm.peg_multiplier = new_peg_candidate; + market_clone.amm.set_peg_multiplier(new_peg_candidate); let (_new_net_market_value, cost) = calculate_base_asset_value_and_pnl( - market_clone.amm.base_asset_amount_with_amm, + market_clone.amm.base_asset_amount_with_amm(), current_net_market_value, &market_clone.amm, )?; @@ -203,13 +203,13 @@ pub fn adjust_peg_cost( } pub fn calculate_repeg_cost(amm: &AMM, new_peg: u128) -> DriftResult { - amm.quote_asset_reserve + amm.quote_asset_reserve() .cast::()? - .safe_sub(amm.terminal_quote_asset_reserve.cast()?)? + .safe_sub(amm.terminal_quote_asset_reserve().cast()?)? .safe_mul( new_peg .cast::()? - .safe_sub(amm.peg_multiplier.cast()?)?, + .safe_sub(amm.peg_multiplier().cast()?)?, )? .safe_div(AMM_RESERVE_PRECISION_I128) } @@ -249,17 +249,17 @@ pub fn adjust_amm( let curve_update_intensity = min(market.amm.curve_update_intensity, 100_u8).cast::()?; // return early - if optimal_peg == market.amm.peg_multiplier || curve_update_intensity == 0 { + if optimal_peg == market.amm.peg_multiplier() || curve_update_intensity == 0 { return Ok((Box::new(*market), 0)); } let delta_peg = optimal_peg .cast::()? - .safe_sub(market.amm.peg_multiplier.cast()?)?; // PEG_PRECISION + .safe_sub(market.amm.peg_multiplier().cast()?)?; // PEG_PRECISION let mut per_peg_cost = calculate_per_peg_cost( - market.amm.quote_asset_reserve, - market.amm.terminal_quote_asset_reserve, + market.amm.quote_asset_reserve(), + market.amm.terminal_quote_asset_reserve(), )?; // PEG_PRECISION let budget_i128 = budget.cast::()?; @@ -299,8 +299,8 @@ pub fn adjust_amm( let new_sqrt_k = market .amm - .sqrt_k - .safe_sub(market.amm.sqrt_k.safe_div(1000)?)? + .sqrt_k() + .safe_sub(market.amm.sqrt_k().safe_div(1000)?)? .max(new_sqrt_k_lower_bound); let update_k_result = @@ -309,8 +309,8 @@ pub fn adjust_amm( let adjustment_cost = cp_curve::adjust_k_cost_and_update(&mut market_clone, &update_k_result)?; per_peg_cost = calculate_per_peg_cost( - market_clone.amm.quote_asset_reserve, - market_clone.amm.terminal_quote_asset_reserve, + market_clone.amm.quote_asset_reserve(), + market_clone.amm.terminal_quote_asset_reserve(), )?; adjustment_cost @@ -327,13 +327,13 @@ pub fn adjust_amm( new_peg = if budget_delta_peg > 0 { market .amm - .peg_multiplier + .peg_multiplier() .safe_add(budget_delta_peg_magnitude) .unwrap_or(u128::MAX) - } else if market.amm.peg_multiplier > budget_delta_peg_magnitude { + } else if market.amm.peg_multiplier() > budget_delta_peg_magnitude { market .amm - .peg_multiplier + .peg_multiplier() .safe_sub(budget_delta_peg_magnitude)? } else { 1 @@ -341,7 +341,7 @@ pub fn adjust_amm( cost = calculate_repeg_cost(&market_clone.amm, new_peg)?; } - market_clone.amm.peg_multiplier = new_peg; + market_clone.amm.set_peg_multiplier(new_peg); Ok((market_clone, cost)) } @@ -357,8 +357,8 @@ pub fn calculate_optimal_peg_and_budget( let target_price_i64 = mm_oracle_price_data.get_price(); let target_price = target_price_i64.cast()?; let mut optimal_peg = calculate_peg_from_target_price( - market.amm.quote_asset_reserve, - market.amm.base_asset_reserve, + market.amm.quote_asset_reserve(), + market.amm.base_asset_reserve(), target_price, )?; @@ -389,8 +389,8 @@ pub fn calculate_optimal_peg_and_budget( reserve_price_before.safe_sub(mark_adj)? }; optimal_peg = calculate_peg_from_target_price( - market.amm.quote_asset_reserve, - market.amm.base_asset_reserve, + market.amm.quote_asset_reserve(), + market.amm.base_asset_reserve(), target_price.cast()?, )?; @@ -407,16 +407,16 @@ pub fn calculate_optimal_peg_and_budget( pub fn calculate_fee_pool(market: &PerpMarket) -> DriftResult { let total_fee_minus_distributions_lower_bound = get_total_fee_lower_bound(market)? - .safe_add(market.amm.total_liquidation_fee)? - .safe_sub(market.amm.total_fee_withdrawn)? + .safe_add(market.amm.total_liquidation_fee())? + .safe_sub(market.amm.total_fee_withdrawn())? .cast::() .unwrap_or(0); let fee_pool = - if market.amm.total_fee_minus_distributions > total_fee_minus_distributions_lower_bound { + if market.amm.total_fee_minus_distributions() > total_fee_minus_distributions_lower_bound { market .amm - .total_fee_minus_distributions + .total_fee_minus_distributions() .safe_sub(total_fee_minus_distributions_lower_bound)? .cast()? } else { @@ -430,7 +430,7 @@ pub fn get_total_fee_lower_bound(market: &PerpMarket) -> DriftResult { // market to retain half of exchange fees let total_fee_lower_bound = market .amm - .total_exchange_fee + .total_exchange_fee() .safe_mul(SHARE_OF_FEES_ALLOCATED_TO_DRIFT_NUMERATOR)? .safe_div(SHARE_OF_FEES_ALLOCATED_TO_DRIFT_DENOMINATOR)?; diff --git a/programs/drift/src/math/repeg/tests.rs b/programs/drift/src/math/repeg/tests.rs index 0619d0b35f..5ff027965d 100644 --- a/programs/drift/src/math/repeg/tests.rs +++ b/programs/drift/src/math/repeg/tests.rs @@ -33,19 +33,19 @@ fn calc_peg_tests() { fn calculate_optimal_peg_and_budget_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 65 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 63015384615, - terminal_quote_asset_reserve: 64 * AMM_RESERVE_PRECISION, - sqrt_k: 64 * AMM_RESERVE_PRECISION, - peg_multiplier: 19_400_000_000, - base_asset_amount_with_amm: -(AMM_RESERVE_PRECISION as i128), + base_asset_reserve: (65 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: 63015384615.into(), + terminal_quote_asset_reserve: (64 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (64 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 19_400_000_000.into(), + base_asset_amount_with_amm: (-(AMM_RESERVE_PRECISION as i128)).into(), mark_std: PRICE_PRECISION as u64, last_mark_price_twap_ts: 0, base_spread: 250, curve_update_intensity: 100, max_spread: 500 * 100, - total_exchange_fee: QUOTE_PRECISION, - total_fee_minus_distributions: (40 * QUOTE_PRECISION) as i128, + total_exchange_fee: QUOTE_PRECISION.into(), + total_fee_minus_distributions: ((40 * QUOTE_PRECISION) as i128).into(), ..AMM::default() }, margin_ratio_initial: 500, @@ -173,22 +173,26 @@ fn calculate_optimal_peg_and_budget_test() { assert_eq!(budget, 39500000); assert!(check_lb); - market.amm.base_asset_amount_with_amm = AMM_RESERVE_PRECISION as i128; + market + .amm + .set_base_asset_amount_with_amm(AMM_RESERVE_PRECISION as i128); - let swap_direction = if market.amm.base_asset_amount_with_amm > 0 { + let swap_direction = if market.amm.base_asset_amount_with_amm() > 0 { SwapDirection::Add } else { SwapDirection::Remove }; let (new_terminal_quote_reserve, _new_terminal_base_reserve) = amm::calculate_swap_output( - market.amm.base_asset_amount_with_amm.unsigned_abs(), - market.amm.base_asset_reserve, + market.amm.base_asset_amount_with_amm().unsigned_abs(), + market.amm.base_asset_reserve(), swap_direction, - market.amm.sqrt_k, + market.amm.sqrt_k(), ) .unwrap(); - market.amm.terminal_quote_asset_reserve = new_terminal_quote_reserve; + market + .amm + .set_terminal_quote_asset_reserve(new_terminal_quote_reserve); // negative target_price_gap exceeding max_spread (not in favor of vAMM) let oracle_price_data = OraclePriceData { @@ -218,21 +222,21 @@ fn calculate_optimal_peg_and_budget_test() { fn calculate_optimal_peg_and_budget_2_test() { let mut market = PerpMarket { amm: AMM { - base_asset_reserve: 2270516211133, - quote_asset_reserve: 2270925669621, - terminal_quote_asset_reserve: 2270688451627, - sqrt_k: 2270720931148, - peg_multiplier: 17723081263, - base_asset_amount_with_amm: 237200000, + base_asset_reserve: 2270516211133.into(), + quote_asset_reserve: 2270925669621.into(), + terminal_quote_asset_reserve: 2270688451627.into(), + sqrt_k: 2270720931148.into(), + peg_multiplier: 17723081263.into(), + base_asset_amount_with_amm: 237200000.into(), mark_std: 43112524, last_mark_price_twap_ts: 0, base_spread: 250, curve_update_intensity: 100, max_spread: 500 * 100, - total_exchange_fee: 298628987, - total_fee_minus_distributions: -242668966, - total_fee_withdrawn: 124247717, - concentration_coef: 1020710, + total_exchange_fee: 298628987.into(), + total_fee_minus_distributions: (-242668966).into(), + total_fee_withdrawn: 124247717.into(), + concentration_coef: 1020710.into(), historical_oracle_data: HistoricalOracleData { last_oracle_price_twap: 17765940050, last_oracle_price_twap_5min: 17763317077, @@ -246,12 +250,18 @@ fn calculate_optimal_peg_and_budget_2_test() { }; let (new_terminal_quote_reserve, new_terminal_base_reserve) = amm::calculate_terminal_reserves(&market.amm).unwrap(); - market.amm.terminal_quote_asset_reserve = new_terminal_quote_reserve; + market + .amm + .set_terminal_quote_asset_reserve(new_terminal_quote_reserve); let (min_base_asset_reserve, max_base_asset_reserve) = - amm::calculate_bid_ask_bounds(market.amm.concentration_coef, new_terminal_base_reserve) + amm::calculate_bid_ask_bounds(market.amm.concentration_coef(), new_terminal_base_reserve) .unwrap(); - market.amm.min_base_asset_reserve = min_base_asset_reserve; - market.amm.max_base_asset_reserve = max_base_asset_reserve; + market + .amm + .set_min_base_asset_reserve(min_base_asset_reserve); + market + .amm + .set_max_base_asset_reserve(max_base_asset_reserve); let oracle_price_data = OraclePriceData { price: (17_800 * PRICE_PRECISION) as i64, @@ -310,12 +320,12 @@ fn calc_adjust_amm_tests_repeg_in_favour() { // btc-esque market let market = PerpMarket { amm: AMM { - base_asset_reserve: 65 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 63015384615, - terminal_quote_asset_reserve: 64 * AMM_RESERVE_PRECISION, - sqrt_k: 64 * AMM_RESERVE_PRECISION, - peg_multiplier: 19_400_000_000, - base_asset_amount_with_amm: AMM_RESERVE_PRECISION as i128, + base_asset_reserve: (65 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: 63015384615.into(), + terminal_quote_asset_reserve: (64 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (64 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 19_400_000_000.into(), + base_asset_amount_with_amm: (AMM_RESERVE_PRECISION as i128).into(), mark_std: PRICE_PRECISION as u64, last_mark_price_twap_ts: 0, curve_update_intensity: 100, @@ -328,16 +338,16 @@ fn calc_adjust_amm_tests_repeg_in_favour() { let px = 20_401_125_456; let optimal_peg = calculate_peg_from_target_price( - market.amm.quote_asset_reserve, - market.amm.base_asset_reserve, + market.amm.quote_asset_reserve(), + market.amm.base_asset_reserve(), px, ) .unwrap(); - assert!(optimal_peg > market.amm.peg_multiplier); + assert!(optimal_peg > market.amm.peg_multiplier()); let (repegged_market, _amm_update_cost) = adjust_amm(&market, optimal_peg, 0, true).unwrap(); assert_eq!(_amm_update_cost, -1618354580); - assert_eq!(repegged_market.amm.peg_multiplier, optimal_peg); + assert_eq!(repegged_market.amm.peg_multiplier(), optimal_peg); let post_price = repegged_market.amm.reserve_price().unwrap(); assert_eq!(post_price - prev_price, 1593456817); // todo: (15934564582252/1e4 - 1615699103 is the slippage cost?) @@ -349,21 +359,21 @@ fn calc_adjust_amm_tests_sufficent_fee_for_repeg() { let mut market = PerpMarket { amm: AMM { order_step_size: 1000, - base_asset_reserve: 60437939720095, - quote_asset_reserve: 60440212459368, - terminal_quote_asset_reserve: 60439072663003, - sqrt_k: 60439076079049, - peg_multiplier: 34353000, - base_asset_amount_with_amm: AMM_RESERVE_PRECISION as i128, + base_asset_reserve: 60437939720095.into(), + quote_asset_reserve: 60440212459368.into(), + terminal_quote_asset_reserve: 60439072663003.into(), + sqrt_k: 60439076079049.into(), + peg_multiplier: 34353000.into(), + base_asset_amount_with_amm: (AMM_RESERVE_PRECISION as i128).into(), last_mark_price_twap: 34128370, last_mark_price_twap_ts: 165705, curve_update_intensity: 100, base_spread: 1000, - total_fee_minus_distributions: 304289, - total_fee: 607476, - total_exchange_fee: 0, // new fee pool lowerbound + total_fee_minus_distributions: 304289.into(), + total_fee: 607476.into(), + total_exchange_fee: 0.into(), // new fee pool lowerbound funding_period: 3600, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), ..AMM::default() }, @@ -376,29 +386,35 @@ fn calc_adjust_amm_tests_sufficent_fee_for_repeg() { }; let (new_terminal_quote_reserve, new_terminal_base_reserve) = amm::calculate_terminal_reserves(&market.amm).unwrap(); - market.amm.terminal_quote_asset_reserve = new_terminal_quote_reserve; + market + .amm + .set_terminal_quote_asset_reserve(new_terminal_quote_reserve); let (min_base_asset_reserve, max_base_asset_reserve) = - amm::calculate_bid_ask_bounds(market.amm.concentration_coef, new_terminal_base_reserve) + amm::calculate_bid_ask_bounds(market.amm.concentration_coef(), new_terminal_base_reserve) .unwrap(); - market.amm.min_base_asset_reserve = min_base_asset_reserve; - market.amm.max_base_asset_reserve = max_base_asset_reserve; + market + .amm + .set_min_base_asset_reserve(min_base_asset_reserve); + market + .amm + .set_max_base_asset_reserve(max_base_asset_reserve); let px = 35768 * PRICE_PRECISION_U64 / 1000; let optimal_peg = calculate_peg_from_target_price( - market.amm.quote_asset_reserve, - market.amm.base_asset_reserve, + market.amm.quote_asset_reserve(), + market.amm.base_asset_reserve(), px, ) .unwrap(); - assert!(optimal_peg > market.amm.peg_multiplier); + assert!(optimal_peg > market.amm.peg_multiplier()); let fee_budget = calculate_fee_pool(&market).unwrap(); assert!(fee_budget > 0); let (repegged_market, _amm_update_cost) = adjust_amm(&market, optimal_peg, fee_budget, true).unwrap(); // insufficient fee to repeg - let new_peg = repegged_market.amm.peg_multiplier; - let old_peg = market.amm.peg_multiplier; + let new_peg = repegged_market.amm.peg_multiplier(); + let old_peg = market.amm.peg_multiplier(); assert!(new_peg > old_peg); assert_eq!(new_peg, 34657283); assert_eq!(_amm_update_cost, 304289); diff --git a/programs/drift/src/math/spot_balance.rs b/programs/drift/src/math/spot_balance.rs index da5261a487..c89378ebce 100644 --- a/programs/drift/src/math/spot_balance.rs +++ b/programs/drift/src/math/spot_balance.rs @@ -22,8 +22,8 @@ pub fn get_spot_balance( let precision_increase = 10_u128.pow(19_u32.safe_sub(spot_market.decimals)?); let cumulative_interest = match balance_type { - SpotBalanceType::Deposit => spot_market.cumulative_deposit_interest, - SpotBalanceType::Borrow => spot_market.cumulative_borrow_interest, + SpotBalanceType::Deposit => spot_market.cumulative_deposit_interest(), + SpotBalanceType::Borrow => spot_market.cumulative_borrow_interest(), }; let mut balance = token_amount @@ -45,8 +45,8 @@ pub fn get_token_amount( let precision_decrease = 10_u128.pow(19_u32.safe_sub(spot_market.decimals)?); let cumulative_interest = match balance_type { - SpotBalanceType::Deposit => spot_market.cumulative_deposit_interest, - SpotBalanceType::Borrow => spot_market.cumulative_borrow_interest, + SpotBalanceType::Deposit => spot_market.cumulative_deposit_interest(), + SpotBalanceType::Borrow => spot_market.cumulative_borrow_interest(), }; let token_amount = match balance_type { @@ -111,12 +111,12 @@ pub fn calculate_utilization( pub fn calculate_spot_market_utilization(spot_market: &SpotMarket) -> DriftResult { let deposit_token_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), spot_market, &SpotBalanceType::Deposit, )?; let borrow_token_amount = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), spot_market, &SpotBalanceType::Borrow, )?; @@ -161,14 +161,14 @@ pub fn calculate_accumulated_interest( .safe_div(SPOT_UTILIZATION_PRECISION)?; let borrow_interest = spot_market - .cumulative_borrow_interest + .cumulative_borrow_interest() .safe_mul(modified_borrow_rate)? .safe_div(ONE_YEAR)? .safe_div(SPOT_RATE_PRECISION)? .safe_add(1)?; let deposit_interest = spot_market - .cumulative_deposit_interest + .cumulative_deposit_interest() .safe_mul(modified_deposit_rate)? .safe_div(ONE_YEAR)? .safe_div(SPOT_RATE_PRECISION)?; @@ -206,7 +206,7 @@ pub fn calculate_borrow_rate(spot_market: &SpotMarket, utilization: u128) -> Dri let segment_end = bp; let segment_range = segment_end.safe_sub(segment_start)?; let segment_rate_total = total_extra_rate - .safe_mul(weight as u128)? + .safe_mul(weight)? .safe_div(weights_divisor)?; if utilization <= segment_end { diff --git a/programs/drift/src/math/spot_balance/tests.rs b/programs/drift/src/math/spot_balance/tests.rs index 5fbe7427a4..d9dffd9ff1 100644 --- a/programs/drift/src/math/spot_balance/tests.rs +++ b/programs/drift/src/math/spot_balance/tests.rs @@ -7,7 +7,7 @@ mod test { #[test] fn bonk() { let spot_market = SpotMarket { - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 5, ..SpotMarket::default_quote_market() }; diff --git a/programs/drift/src/math/spot_withdraw.rs b/programs/drift/src/math/spot_withdraw.rs index 9f0b3e0b5a..dc64c73696 100644 --- a/programs/drift/src/math/spot_withdraw.rs +++ b/programs/drift/src/math/spot_withdraw.rs @@ -153,12 +153,12 @@ pub fn check_withdraw_limits( // calculates min/max deposit/borrow amounts permitted for immediate withdraw // takes the stricter of absolute caps on level changes and utilization changes vs 24hr moving averrages let deposit_token_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), spot_market, &SpotBalanceType::Deposit, )?; let borrow_token_amount = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), spot_market, &SpotBalanceType::Borrow, )?; @@ -231,13 +231,13 @@ pub fn get_max_withdraw_for_market_with_token_amount( is_leaving_drift: bool, ) -> DriftResult { let deposit_token_amount = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), spot_market, &SpotBalanceType::Deposit, )?; let borrow_token_amount = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), spot_market, &SpotBalanceType::Borrow, )?; @@ -308,20 +308,20 @@ pub fn get_max_withdraw_for_market_with_token_amount( pub fn validate_spot_balances(spot_market: &SpotMarket) -> DriftResult { let depositors_amount: u64 = get_token_amount( - spot_market.deposit_balance, + spot_market.deposit_balance(), spot_market, &SpotBalanceType::Deposit, )? .cast()?; let borrowers_amount: u64 = get_token_amount( - spot_market.borrow_balance, + spot_market.borrow_balance(), spot_market, &SpotBalanceType::Borrow, )? .cast()?; let revenue_amount: u64 = get_token_amount( - spot_market.revenue_pool.scaled_balance, + spot_market.revenue_pool.scaled_balance(), spot_market, &SpotBalanceType::Deposit, )? @@ -338,7 +338,7 @@ pub fn validate_spot_balances(spot_market: &SpotMarket) -> DriftResult { revenue_amount, depositors_amount, depositors_claim, - spot_market.deposit_balance + spot_market.deposit_balance() )?; Ok(depositors_claim) diff --git a/programs/drift/src/state/amm_cache.rs b/programs/drift/src/state/amm_cache.rs index 1e485b2289..06003edff1 100644 --- a/programs/drift/src/state/amm_cache.rs +++ b/programs/drift/src/state/amm_cache.rs @@ -313,13 +313,13 @@ impl<'a> AccountZeroCopyMut<'a, CacheInfo, AmmCacheFixed> { let cached_info = self.get_mut(perp_market.market_index as u32); let fee_pool_token_amount = get_token_amount( - perp_market.amm.fee_pool.scaled_balance, + perp_market.amm.fee_pool.scaled_balance(), "e_market, perp_market.amm.fee_pool.balance_type(), )?; let net_pnl_pool_token_amount = get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), "e_market, perp_market.pnl_pool.balance_type(), )? @@ -338,15 +338,15 @@ impl<'a> AccountZeroCopyMut<'a, CacheInfo, AmmCacheFixed> { { cached_info.last_fee_pool_token_amount = fee_pool_token_amount; cached_info.last_net_pnl_pool_token_amount = net_pnl_pool_token_amount; - cached_info.last_exchange_fees = perp_market.amm.total_exchange_fee; - cached_info.last_settle_amm_ex_fees = perp_market.amm.total_exchange_fee; + cached_info.last_exchange_fees = perp_market.amm.total_exchange_fee(); + cached_info.last_settle_amm_ex_fees = perp_market.amm.total_exchange_fee(); cached_info.last_settle_amm_pnl = net_pnl_pool_token_amount; return Ok(()); } let exchange_fee_delta = perp_market .amm - .total_exchange_fee + .total_exchange_fee() .saturating_sub(cached_info.last_exchange_fees); let amount_to_send_to_lp_pool = amm_amount_available @@ -366,7 +366,7 @@ impl<'a> AccountZeroCopyMut<'a, CacheInfo, AmmCacheFixed> { cached_info.last_fee_pool_token_amount = fee_pool_token_amount; cached_info.last_net_pnl_pool_token_amount = net_pnl_pool_token_amount; - cached_info.last_exchange_fees = perp_market.amm.total_exchange_fee; + cached_info.last_exchange_fees = perp_market.amm.total_exchange_fee(); Ok(()) } diff --git a/programs/drift/src/state/constituent_map.rs b/programs/drift/src/state/constituent_map.rs index b3e9bd5aa8..8ea2e5b63b 100644 --- a/programs/drift/src/state/constituent_map.rs +++ b/programs/drift/src/state/constituent_map.rs @@ -23,7 +23,7 @@ pub struct ConstituentMap<'a>(pub BTreeMap>) impl<'a> ConstituentMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref(&self, constituent_index: &u16) -> DriftResult> { + pub fn get_ref(&self, constituent_index: &u16) -> DriftResult> { let loader = match self.0.get(constituent_index) { Some(loader) => loader, None => { @@ -56,7 +56,7 @@ impl<'a> ConstituentMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref_mut(&self, market_index: &u16) -> DriftResult> { + pub fn get_ref_mut(&self, market_index: &u16) -> DriftResult> { let loader = match self.0.get(market_index) { Some(loader) => loader, None => { diff --git a/programs/drift/src/state/events.rs b/programs/drift/src/state/events.rs index 7c538b74fc..1c5438362c 100644 --- a/programs/drift/src/state/events.rs +++ b/programs/drift/src/state/events.rs @@ -1,5 +1,7 @@ -use anchor_lang::prelude::*; -use borsh::{BorshDeserialize, BorshSerialize}; +use anchor_lang::prelude::{ + borsh::{BorshDeserialize, BorshSerialize}, + *, +}; use crate::controller::position::PositionDirection; use crate::error::{DriftResult, ErrorCode::InvalidOrder}; diff --git a/programs/drift/src/state/fulfillment_params/serum.rs b/programs/drift/src/state/fulfillment_params/serum.rs index fa30f65eac..5c9eae93a5 100644 --- a/programs/drift/src/state/fulfillment_params/serum.rs +++ b/programs/drift/src/state/fulfillment_params/serum.rs @@ -65,7 +65,7 @@ pub struct SerumContext<'a, 'b> { } impl<'a, 'b> SerumContext<'a, 'b> { - pub fn load_serum_market(&self) -> DriftResult { + pub fn load_serum_market(&self) -> DriftResult> { Market::load(self.serum_market, self.serum_program.key, false).map_err(|e| { msg!("{:?}", e); ErrorCode::InvalidSerumMarket diff --git a/programs/drift/src/state/insurance_fund_stake.rs b/programs/drift/src/state/insurance_fund_stake.rs index 25d81f4b0d..35a2d47cc4 100644 --- a/programs/drift/src/state/insurance_fund_stake.rs +++ b/programs/drift/src/state/insurance_fund_stake.rs @@ -3,16 +3,16 @@ use crate::error::ErrorCode; use crate::math::constants::EPOCH_DURATION; use crate::math::safe_math::SafeMath; use crate::math_error; -use crate::safe_decrement; -use crate::safe_increment; use crate::state::spot_market::SpotMarket; use crate::state::traits::Size; use crate::validate; use anchor_lang::prelude::*; +use drift_macros::legacy_layout; #[cfg(test)] mod tests; +#[legacy_layout] #[account(zero_copy(unsafe))] #[derive(Default, Eq, PartialEq, Debug)] #[repr(C)] @@ -39,24 +39,24 @@ impl InsuranceFundStake { InsuranceFundStake { authority, market_index, - last_withdraw_request_shares: 0, + last_withdraw_request_shares: 0.into(), last_withdraw_request_value: 0, last_withdraw_request_ts: 0, cost_basis: 0, - if_base: 0, + if_base: 0.into(), last_valid_ts: now, - if_shares: 0, + if_shares: 0.into(), padding: [0; 14], } } fn validate_base(&self, spot_market: &SpotMarket) -> DriftResult { validate!( - self.if_base == spot_market.insurance_fund.shares_base, + self.if_base == spot_market.insurance_fund.shares_base().into(), ErrorCode::InvalidIFRebase, "if stake bases mismatch. user base: {} market base {}", self.if_base, - spot_market.insurance_fund.shares_base + spot_market.insurance_fund.shares_base() )?; Ok(()) @@ -64,33 +64,35 @@ impl InsuranceFundStake { pub fn checked_if_shares(&self, spot_market: &SpotMarket) -> DriftResult { self.validate_base(spot_market)?; - Ok(self.if_shares) + Ok(self.if_shares()) } pub fn unchecked_if_shares(&self) -> u128 { - self.if_shares + self.if_shares() } pub fn increase_if_shares(&mut self, delta: u128, spot_market: &SpotMarket) -> DriftResult { self.validate_base(spot_market)?; - safe_increment!(self.if_shares, delta); + let if_shares = self.if_shares.as_u128(); + self.set_if_shares(if_shares.checked_add(delta).ok_or_else(math_error!())?); Ok(()) } pub fn decrease_if_shares(&mut self, delta: u128, spot_market: &SpotMarket) -> DriftResult { self.validate_base(spot_market)?; - safe_decrement!(self.if_shares, delta); + let if_shares = self.if_shares.as_u128(); + self.set_if_shares(if_shares.checked_sub(delta).ok_or_else(math_error!())?); Ok(()) } pub fn update_if_shares(&mut self, new_shares: u128, spot_market: &SpotMarket) -> DriftResult { self.validate_base(spot_market)?; - self.if_shares = new_shares; - + self.set_if_shares(new_shares); Ok(()) } } +#[legacy_layout] #[account(zero_copy(unsafe))] #[derive(Default, Eq, PartialEq, Debug)] #[repr(C)] @@ -130,7 +132,7 @@ impl ProtocolIfSharesTransferConfig { .next_epoch_ts .safe_add(EPOCH_DURATION.safe_mul(n_epoch_durations)?)?; - self.current_epoch_transfer = 0; + self.set_current_epoch_transfer(0); } Ok(()) @@ -139,7 +141,8 @@ impl ProtocolIfSharesTransferConfig { pub fn validate_transfer(&self, requested_transfer: u128) -> DriftResult { let max_transfer = self .max_transfer_per_epoch - .saturating_sub(self.current_epoch_transfer); + .as_u128() + .saturating_sub(self.current_epoch_transfer.as_u128()); validate!( requested_transfer < max_transfer, diff --git a/programs/drift/src/state/load_ref.rs b/programs/drift/src/state/load_ref.rs index 6983a24e72..4cac5d4c63 100644 --- a/programs/drift/src/state/load_ref.rs +++ b/programs/drift/src/state/load_ref.rs @@ -1,6 +1,5 @@ use anchor_lang::prelude::*; use anchor_lang::ZeroCopy; -use arrayref::array_ref; use std::cell::{Ref, RefMut}; use std::mem; diff --git a/programs/drift/src/state/lp_pool.rs b/programs/drift/src/state/lp_pool.rs index f975ce9e81..cdc03fe29c 100644 --- a/programs/drift/src/state/lp_pool.rs +++ b/programs/drift/src/state/lp_pool.rs @@ -16,8 +16,11 @@ use crate::state::oracle_map::OracleMap; use crate::state::paused_operations::ConstituentLpOperation; use crate::state::spot_market_map::SpotMarketMap; use crate::state::user::MarketType; -use anchor_lang::prelude::*; -use borsh::{BorshDeserialize, BorshSerialize}; +use anchor_lang::prelude::{ + borsh::{BorshDeserialize, BorshSerialize}, + *, +}; +use drift_macros::legacy_layout; use enumflags2::BitFlags; use super::oracle::OraclePriceData; @@ -59,6 +62,7 @@ pub const MAX_ORACLE_STALENESS_FOR_TARGET_CALC: u64 = 10u64; #[cfg(test)] mod tests; +#[legacy_layout] #[account(zero_copy(unsafe))] #[derive(Debug)] #[repr(C)] @@ -138,11 +142,11 @@ impl Default for LPPool { whitelist_mint: Pubkey::default(), constituent_target_base: Pubkey::default(), constituent_correlations: Pubkey::default(), - max_aum: 0, - last_aum: 0, - cumulative_quote_sent_to_perp_markets: 0, - cumulative_quote_received_from_perp_markets: 0, - total_mint_redeem_fees_paid: 0, + max_aum: 0.into(), + last_aum: 0.into(), + cumulative_quote_sent_to_perp_markets: 0.into(), + cumulative_quote_received_from_perp_markets: 0.into(), + total_mint_redeem_fees_paid: 0.into(), last_aum_slot: 0, max_settle_quote_amount: 0, _padding: 0, @@ -180,6 +184,7 @@ impl LPPool { // TODO: assuming mint decimals = quote decimals = 6 Ok(self .last_aum + .as_u128() .safe_mul(PRICE_PRECISION)? .safe_div(supply as u128)?) } @@ -297,7 +302,7 @@ impl LPPool { in_target_weight: i64, dlp_total_supply: u64, ) -> DriftResult<(u64, u128, i64, i128)> { - let (mut in_fee_pct, out_fee_pct) = if self.last_aum == 0 { + let (mut in_fee_pct, out_fee_pct) = if self.last_aum == 0.into() { (0, 0) } else { self.get_swap_fees( @@ -341,7 +346,7 @@ impl LPPool { } else { token_amount_usd .safe_mul(dlp_total_supply as u128)? - .safe_div(self.last_aum)? + .safe_div(self.last_aum.into())? .safe_div(token_precision_denominator)? }; @@ -399,6 +404,7 @@ impl LPPool { // Apply proportion to AUM and convert to token amount let out_amount = self .last_aum + .as_u128() .safe_mul(proportion)? .safe_mul(token_precision_denominator)? .safe_div(PERCENTAGE_PRECISION)? @@ -625,7 +631,12 @@ impl LPPool { let trade_ratio: i128 = notional_trade_size .abs() .safe_mul(PERCENTAGE_PRECISION_I128)? - .safe_div(self.last_aum.max(MIN_AUM_EXECUTION_FEE).cast::()?)?; + .safe_div( + self.last_aum + .as_u128() + .max(MIN_AUM_EXECUTION_FEE) + .cast::()?, + )?; // Linear fee computation amount let in_fee_execution_linear = @@ -708,15 +719,17 @@ impl LPPool { self.target_position_delay_fee_bps_per_10_slots, )?; - Ok(oracle_uncertainty_fee + oracle_uncertainty_fee .safe_add(position_uncertainty_fee)? - .cast::()?) + .cast::() } pub fn record_mint_redeem_fees(&mut self, amount: i64) -> DriftResult { self.total_mint_redeem_fees_paid = self .total_mint_redeem_fees_paid - .safe_add(amount.cast::()?)?; + .as_i128() + .safe_add(amount as i128)? + .into(); Ok(()) } @@ -832,7 +845,7 @@ impl LPPool { } let aum_u128 = aum.max(0).cast::()?; - self.last_aum = aum_u128; + self.set_last_aum(aum_u128); self.last_aum_slot = slot; Ok((aum_u128, crypto_delta, derivative_groups)) @@ -847,6 +860,7 @@ impl LPPool { } } +#[legacy_layout] #[zero_copy(unsafe)] #[derive(Default, Eq, PartialEq, Debug, BorshDeserialize, BorshSerialize)] #[repr(C)] @@ -875,16 +889,16 @@ impl SpotBalance for ConstituentSpotBalance { } fn balance(&self) -> u128 { - self.scaled_balance + self.scaled_balance.into() } fn increase_balance(&mut self, delta: u128) -> DriftResult { - self.scaled_balance = self.scaled_balance.safe_add(delta)?; + self.set_scaled_balance(self.scaled_balance().safe_add(delta)?); Ok(()) } fn decrease_balance(&mut self, delta: u128) -> DriftResult { - self.scaled_balance = self.scaled_balance.safe_sub(delta)?; + self.set_scaled_balance(self.scaled_balance().safe_sub(delta)?); Ok(()) } @@ -896,7 +910,7 @@ impl SpotBalance for ConstituentSpotBalance { impl ConstituentSpotBalance { pub fn get_token_amount(&self, spot_market: &SpotMarket) -> DriftResult { - get_token_amount(self.scaled_balance, spot_market, &self.balance_type) + get_token_amount(self.scaled_balance.into(), spot_market, &self.balance_type) } pub fn get_signed_token_amount(&self, spot_market: &SpotMarket) -> DriftResult { @@ -905,6 +919,7 @@ impl ConstituentSpotBalance { } } +#[legacy_layout] #[account(zero_copy(unsafe))] #[derive(Debug)] #[repr(C)] @@ -990,7 +1005,7 @@ impl Default for Constituent { mint: Pubkey::default(), lp_pool: Pubkey::default(), vault: Pubkey::default(), - total_swap_fees: 0, + total_swap_fees: 0.into(), spot_balance: ConstituentSpotBalance::default(), last_spot_balance_token_amount: 0, cumulative_spot_interest_accrued_token_amount: 0, @@ -1096,7 +1111,7 @@ impl Constituent { } pub fn record_swap_fees(&mut self, amount: i128) -> DriftResult { - self.total_swap_fees = self.total_swap_fees.safe_add(amount)?; + self.total_swap_fees = self.total_swap_fees.as_i128().safe_add(amount)?.into(); Ok(()) } diff --git a/programs/drift/src/state/lp_pool/tests.rs b/programs/drift/src/state/lp_pool/tests.rs index 3e76383af9..c090342007 100644 --- a/programs/drift/src/state/lp_pool/tests.rs +++ b/programs/drift/src/state/lp_pool/tests.rs @@ -581,7 +581,7 @@ mod swap_tests { out_volatility: u64, ) { let lp_pool = LPPool { - last_aum: 1_000_000_000_000, + last_aum: 1_000_000_000_000.into(), target_oracle_delay_fee_bps_per_10_slots: 2, target_position_delay_fee_bps_per_10_slots: 10, ..LPPool::default() @@ -596,10 +596,12 @@ mod swap_tests { ..OraclePriceData::default() }; - let in_notional = (in_current_weight as u128) * lp_pool.last_aum / PERCENTAGE_PRECISION; + let in_notional = + (in_current_weight as u128) * lp_pool.last_aum.as_u128() / PERCENTAGE_PRECISION; let in_token_amount = in_notional * 10_u128.pow(in_decimals) / oracle_0.price as u128; - let out_notional = (out_current_weight as u128) * lp_pool.last_aum / PERCENTAGE_PRECISION; + let out_notional = + (out_current_weight as u128) * lp_pool.last_aum.as_u128() / PERCENTAGE_PRECISION; let out_token_amount = out_notional * 10_u128.pow(out_decimals) / oracle_1.price as u128; let constituent_0 = Constituent { @@ -748,7 +750,7 @@ mod swap_tests { max_weight_deviation: PERCENTAGE_PRECISION_I64 / 10, // 10% spot_market_index: 0, spot_balance: ConstituentSpotBalance { - scaled_balance: 500_000, + scaled_balance: 500_000.into(), cumulative_deposits: 1_000_000, balance_type: SpotBalanceType::Deposit, market_index: 0, @@ -762,7 +764,7 @@ mod swap_tests { let spot_market = SpotMarket { market_index: 0, decimals: 6, - cumulative_deposit_interest: 10_000_000_000_000, + cumulative_deposit_interest: 10_000_000_000_000.into(), ..SpotMarket::default() }; @@ -810,7 +812,7 @@ mod swap_tests { volatility: u64, ) { let lp_pool = LPPool { - last_aum, + last_aum: last_aum.into(), _padding: 0, min_mint_fee: 0, ..LPPool::default() @@ -834,7 +836,7 @@ mod swap_tests { max_weight_deviation: PERCENTAGE_PRECISION_I64 / 10, spot_market_index: 0, spot_balance: ConstituentSpotBalance { - scaled_balance: 0, + scaled_balance: 0.into(), cumulative_deposits: 0, balance_type: SpotBalanceType::Deposit, market_index: 0, @@ -1002,7 +1004,7 @@ mod swap_tests { volatility: u64, ) { let lp_pool = LPPool { - last_aum, + last_aum: last_aum.into(), _padding: 0, min_mint_fee: 100, // 1 bps ..LPPool::default() @@ -1026,7 +1028,7 @@ mod swap_tests { max_weight_deviation: PERCENTAGE_PRECISION_I64 / 10, spot_market_index: 0, spot_balance: ConstituentSpotBalance { - scaled_balance: 0, + scaled_balance: 0.into(), cumulative_deposits: 0, balance_type: SpotBalanceType::Deposit, market_index: 0, @@ -1213,7 +1215,7 @@ mod swap_tests { out_target_weight: i64, ) -> (u128, u128, i128, i128, i128, i128) { let lp_pool = LPPool { - last_aum: 1_000_000_000_000, + last_aum: 1_000_000_000_000.into(), ..LPPool::default() }; @@ -1231,16 +1233,18 @@ mod swap_tests { let in_token_amount = in_notional * 10_i128.pow(6) / oracle_0.price as i128; let in_spot_balance = if in_token_amount > 0 { ConstituentSpotBalance { - scaled_balance: (in_token_amount.abs() as u128) - * (SPOT_BALANCE_PRECISION / 10_u128.pow(6)), + scaled_balance: ((in_token_amount.abs() as u128) + * (SPOT_BALANCE_PRECISION / 10_u128.pow(6))) + .into(), balance_type: SpotBalanceType::Deposit, market_index: 0, ..ConstituentSpotBalance::default() } } else { ConstituentSpotBalance { - scaled_balance: (in_token_amount.abs() as u128) - * (SPOT_BALANCE_PRECISION / 10_u128.pow(6)), + scaled_balance: ((in_token_amount.abs() as u128) + * (SPOT_BALANCE_PRECISION / 10_u128.pow(6))) + .into(), balance_type: SpotBalanceType::Borrow, market_index: 0, ..ConstituentSpotBalance::default() @@ -1252,16 +1256,18 @@ mod swap_tests { let out_token_amount = out_notional * 10_i128.pow(6) / oracle_1.price as i128; let out_spot_balance = if out_token_amount > 0 { ConstituentSpotBalance { - scaled_balance: (out_token_amount.abs() as u128) - * (SPOT_BALANCE_PRECISION / 10_u128.pow(6)), + scaled_balance: ((out_token_amount.abs() as u128) + * (SPOT_BALANCE_PRECISION / 10_u128.pow(6))) + .into(), balance_type: SpotBalanceType::Deposit, market_index: 0, ..ConstituentSpotBalance::default() } } else { ConstituentSpotBalance { - scaled_balance: (out_token_amount.abs() as u128) - * (SPOT_BALANCE_PRECISION / 10_u128.pow(6)), + scaled_balance: ((out_token_amount.abs() as u128) + * (SPOT_BALANCE_PRECISION / 10_u128.pow(6))) + .into(), balance_type: SpotBalanceType::Deposit, market_index: 0, ..ConstituentSpotBalance::default() @@ -1589,7 +1595,7 @@ mod swap_fee_tests { #[test] fn test_lp_pool_get_linear_fee_execution() { let lp_pool = LPPool { - last_aum: 10_000_000 * QUOTE_PRECISION, // $10,000,000 + last_aum: (10_000_000 * QUOTE_PRECISION).into(), // $10,000,000 ..LPPool::default() }; @@ -1610,7 +1616,7 @@ mod swap_fee_tests { #[test] fn test_lp_pool_get_quadratic_fee_execution() { let lp_pool = LPPool { - last_aum: 10_000_000 * QUOTE_PRECISION, // $10,000,000 + last_aum: (10_000_000 * QUOTE_PRECISION).into(), // $10,000,000 ..LPPool::default() }; @@ -1631,7 +1637,7 @@ mod swap_fee_tests { #[test] fn test_lp_pool_get_quadratic_fee_inventory() { let lp_pool = LPPool { - last_aum: 10_000_000 * QUOTE_PRECISION, // $10,000,000 + last_aum: (10_000_000 * QUOTE_PRECISION).into(), // $10,000,000 ..LPPool::default() }; @@ -1657,7 +1663,7 @@ mod swap_fee_tests { #[test] fn test_target_delays() { let lp_pool = LPPool { - last_aum: 10_000_000 * QUOTE_PRECISION, // $10,000,000 + last_aum: (10_000_000 * QUOTE_PRECISION).into(), // $10,000,000 target_oracle_delay_fee_bps_per_10_slots: 2, target_position_delay_fee_bps_per_10_slots: 10, ..LPPool::default() @@ -2534,7 +2540,7 @@ mod update_aum_tests { let mut usdc_spot_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, historical_oracle_data: HistoricalOracleData::default_quote_oracle(), ..SpotMarket::default() @@ -2545,7 +2551,7 @@ mod update_aum_tests { market_index: 1, oracle_source: OracleSource::PythLazer, oracle: sol_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(200 * PRICE_PRECISION_I64), ..SpotMarket::default() @@ -2556,7 +2562,7 @@ mod update_aum_tests { market_index: 2, oracle_source: OracleSource::PythLazer, oracle: btc_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 8, historical_oracle_data: HistoricalOracleData::default_price( 100_000 * PRICE_PRECISION_I64, @@ -2569,7 +2575,7 @@ mod update_aum_tests { market_index: 3, oracle_source: OracleSource::PythLazer, oracle: bonk_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 5, historical_oracle_data: HistoricalOracleData::default_price(22), ..SpotMarket::default() @@ -2671,7 +2677,8 @@ mod update_aum_tests { // Verify LP pool state was updated assert_eq!( - lp_pool.last_aum, aum, + lp_pool.last_aum, + aum.into(), "{}: last_aum should match calculated AUM", test_name ); @@ -2942,7 +2949,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: parent_index, oracle_source: OracleSource::PythLazer, oracle: parent_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(parent_oracle.price), ..SpotMarket::default() @@ -2957,7 +2964,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: derivative1_index, oracle_source: OracleSource::PythLazer, oracle: derivative1_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(derivative1_oracle.price), ..SpotMarket::default() @@ -2972,7 +2979,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: derivative2_index, oracle_source: OracleSource::PythLazer, oracle: derivative2_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(derivative2_oracle.price), ..SpotMarket::default() @@ -2987,7 +2994,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: derivative3_index, oracle_source: OracleSource::PythLazer, oracle: derivative3_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(derivative3_oracle.price), ..SpotMarket::default() @@ -3258,7 +3265,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: parent_index, oracle_source: OracleSource::PythLazer, oracle: parent_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(parent_oracle.price), ..SpotMarket::default() @@ -3273,7 +3280,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: derivative_index, oracle_source: OracleSource::PythLazer, oracle: derivative_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(derivative_oracle.price), ..SpotMarket::default() @@ -3547,7 +3554,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: parent_index, oracle_source: OracleSource::PythLazer, oracle: parent_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(parent_oracle.price), ..SpotMarket::default() @@ -3562,7 +3569,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: derivative_index, oracle_source: OracleSource::PythLazer, oracle: derivative_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(derivative_oracle.price), ..SpotMarket::default() @@ -3761,7 +3768,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: parent_index, oracle_source: OracleSource::PythLazer, oracle: parent_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(parent_oracle.price), ..SpotMarket::default() @@ -3776,7 +3783,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: derivative1_index, oracle_source: OracleSource::PythLazer, oracle: derivative1_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(derivative1_oracle.price), ..SpotMarket::default() @@ -3791,7 +3798,7 @@ mod update_constituent_target_base_for_derivatives_tests { market_index: derivative2_index, oracle_source: OracleSource::PythLazer, oracle: derivative2_oracle_pubkey, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 9, historical_oracle_data: HistoricalOracleData::default_price(derivative2_oracle.price), ..SpotMarket::default() diff --git a/programs/drift/src/state/oracle.rs b/programs/drift/src/state/oracle.rs index 0275a5549a..43e6d55e51 100644 --- a/programs/drift/src/state/oracle.rs +++ b/programs/drift/src/state/oracle.rs @@ -562,13 +562,13 @@ pub fn get_sb_on_demand_price( let pull_feed_account_info: Ref = load_ref(price_oracle).or(Err(ErrorCode::UnableToLoadOracle))?; - let latest_oracle_submssions: Vec = + let latest_oracle_submissions: Vec = pull_feed_account_info.latest_submissions(); - let average_price = latest_oracle_submssions + let average_price = latest_oracle_submissions .iter() - .map(|submission| submission.value) + .map(|submission| submission.value()) .sum::() - / latest_oracle_submssions.len() as i128; + / latest_oracle_submissions.len() as i128; let price = convert_sb_i128(&average_price)?.cast::()?; @@ -582,7 +582,7 @@ pub fn get_sb_on_demand_price( let delay = clock_slot .cast::()? - .safe_sub(latest_oracle_submssions[0].landed_at.cast()?)?; + .safe_sub(latest_oracle_submissions[0].landed_at.cast()?)?; let has_sufficient_number_of_data_points = true; diff --git a/programs/drift/src/state/oracle/tests.rs b/programs/drift/src/state/oracle/tests.rs index 8d64f725b4..e29fbd4adb 100644 --- a/programs/drift/src/state/oracle/tests.rs +++ b/programs/drift/src/state/oracle/tests.rs @@ -173,11 +173,11 @@ fn use_mm_oracle() { let mut market = PerpMarket { market_index: 0, amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 22_100_000_000, - base_asset_amount_with_amm: (12295081967_i128), + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 22_100_000_000.into(), + base_asset_amount_with_amm: (12295081967_i128).into(), max_spread: 1000, mm_oracle_price: 130 * PRICE_PRECISION_I64 + 973, mm_oracle_slot: slot, @@ -267,11 +267,11 @@ fn mm_oracle_confidence() { let market = PerpMarket { market_index: 0, amm: AMM { - base_asset_reserve: 512295081967, - quote_asset_reserve: 488 * AMM_RESERVE_PRECISION, - sqrt_k: 500 * AMM_RESERVE_PRECISION, - peg_multiplier: 22_100_000_000, - base_asset_amount_with_amm: (12295081967_i128), + base_asset_reserve: 512295081967.into(), + quote_asset_reserve: (488 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (500 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 22_100_000_000.into(), + base_asset_amount_with_amm: (12295081967_i128).into(), max_spread: 1000, mm_oracle_price: 130 * PRICE_PRECISION_I64 + 999, mm_oracle_slot: slot, diff --git a/programs/drift/src/state/oracle_map.rs b/programs/drift/src/state/oracle_map.rs index 48605e0403..af9644fd46 100644 --- a/programs/drift/src/state/oracle_map.rs +++ b/programs/drift/src/state/oracle_map.rs @@ -12,7 +12,6 @@ use crate::state::user::MarketType; use anchor_lang::prelude::{AccountInfo, Pubkey}; use anchor_lang::Discriminator; use anchor_lang::Key; -use arrayref::array_ref; use std::collections::BTreeMap; use std::iter::Peekable; use std::slice::Iter; diff --git a/programs/drift/src/state/order_params.rs b/programs/drift/src/state/order_params.rs index a5b81b8bb6..5cb58a08bc 100644 --- a/programs/drift/src/state/order_params.rs +++ b/programs/drift/src/state/order_params.rs @@ -10,8 +10,10 @@ use crate::math::safe_unwrap::SafeUnwrap; use crate::state::events::OrderActionExplanation; use crate::state::perp_market::{ContractTier, PerpMarket}; use crate::state::user::{MarketType, OrderTriggerCondition, OrderType}; -use anchor_lang::prelude::*; -use borsh::{BorshDeserialize, BorshSerialize}; +use anchor_lang::prelude::{ + borsh::{BorshDeserialize, BorshSerialize}, + *, +}; use std::ops::Div; #[cfg(test)] diff --git a/programs/drift/src/state/order_params/tests.rs b/programs/drift/src/state/order_params/tests.rs index d2d54af789..0b3a8a775a 100644 --- a/programs/drift/src/state/order_params/tests.rs +++ b/programs/drift/src/state/order_params/tests.rs @@ -53,12 +53,12 @@ mod update_perp_auction_params { fn test_extreme_sanitize_oracle_order() { let oracle_price = 145 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -149,12 +149,12 @@ mod update_perp_auction_params { fn test_signed_msg_orders_oracle() { let oracle_price = 100 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -272,12 +272,12 @@ mod update_perp_auction_params { fn test_signed_msg_orders_limit() { let oracle_price = 100 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -398,12 +398,12 @@ mod update_perp_auction_params { fn test_extreme_sanitize_oracle_order_huge_market_prem() { let oracle_price = 145 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -446,12 +446,12 @@ mod update_perp_auction_params { fn test_sanitize_limit() { let oracle_price = 100 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -624,12 +624,12 @@ mod update_perp_auction_params { fn test_sanitize_oracle_limit() { let oracle_price = 100 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 1000) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 1000) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -779,12 +779,12 @@ mod update_perp_auction_params { fn test_market_sanitize() { let oracle_price = 99 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 99 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (99 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -889,12 +889,12 @@ mod update_perp_auction_params { fn test_oracle_market_sanitize() { let oracle_price = 99 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -982,12 +982,12 @@ mod update_perp_auction_params { fn test_market_sanatize_no_auction_params() { let oracle_price = 99 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() @@ -1132,12 +1132,12 @@ mod update_perp_auction_params { fn test_oracle_market_sanitize_no_auction_params() { let oracle_price = 99 * PRICE_PRECISION_I64; let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 100) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), volume_24h: 1_000_000 * QUOTE_PRECISION_U64, ..AMM::default() }; diff --git a/programs/drift/src/state/perp_market.rs b/programs/drift/src/state/perp_market.rs index 5a6b441c1c..9189157d74 100644 --- a/programs/drift/src/state/perp_market.rs +++ b/programs/drift/src/state/perp_market.rs @@ -2,7 +2,10 @@ use crate::msg; use crate::state::fill_mode::FillMode; use crate::state::pyth_lazer_oracle::PythLazerOracle; use crate::state::user::{MarketType, Order}; -use anchor_lang::prelude::*; +use anchor_lang::prelude::{ + borsh::{BorshDeserialize, BorshSerialize}, + *, +}; use crate::state::state::{State, ValidityGuardRails}; use std::cmp::max; @@ -36,10 +39,9 @@ use crate::state::oracle::{ }; use crate::state::spot_market::{AssetTier, SpotBalance, SpotBalanceType}; use crate::state::traits::{MarketIndexOffset, Size}; -use borsh::{BorshDeserialize, BorshSerialize}; use crate::state::paused_operations::PerpOperation; -use drift_macros::assert_no_slop; +use drift_macros::{assert_no_slop, legacy_layout}; use static_assertions::const_assert_eq; use super::oracle_map::OracleIdentifier; @@ -154,6 +156,7 @@ impl ContractTier { } } +#[legacy_layout] #[account(zero_copy(unsafe))] #[derive(Eq, PartialEq, Debug)] #[repr(C)] @@ -373,7 +376,7 @@ impl PerpMarket { .net_revenue_since_last_funding .cast::()? .safe_mul(PERCENTAGE_PRECISION_I128)? - .safe_div(self.amm.total_fee_minus_distributions.max(1))?; + .safe_div(self.amm.total_fee_minus_distributions.as_i128().max(1))?; let percent_drawdown_limit_breached = match self.contract_tier { ContractTier::A => percent_drawdown <= -PERCENTAGE_PRECISION_I128 / 50, @@ -697,6 +700,7 @@ impl PerpMarket { let peg_sqrt = (self .amm .peg_multiplier + .as_u128() .safe_mul(PEG_PRECISION)? .saturating_add(1)) .nth_root(2) @@ -706,8 +710,9 @@ impl PerpMarket { let mut quote_asset_reserve_upper_bound = self .amm .sqrt_k + .as_u128() .safe_mul(peg_sqrt)? - .safe_div(self.amm.peg_multiplier)?; + .safe_div(self.amm.peg_multiplier.into())?; // for price [0,1] maintain following invariants: if direction == PositionDirection::Long { @@ -715,19 +720,21 @@ impl PerpMarket { quote_asset_reserve_lower_bound = self .amm .sqrt_k + .as_u128() .safe_mul(22361)? .safe_mul(peg_sqrt)? .safe_div(100000)? - .safe_div(self.amm.peg_multiplier)? + .safe_div(self.amm.peg_multiplier.into())? } else { // highest bid price is $0.95 quote_asset_reserve_upper_bound = self .amm .sqrt_k + .as_u128() .safe_mul(97467)? .safe_mul(peg_sqrt)? .safe_div(100000)? - .safe_div(self.amm.peg_multiplier)? + .safe_div(self.amm.peg_multiplier.into())? } Ok(( @@ -1024,6 +1031,7 @@ pub struct InsuranceClaim { pub last_revenue_withdraw_ts: i64, } +#[legacy_layout] #[zero_copy(unsafe)] #[derive(Default, Eq, PartialEq, Debug)] #[repr(C)] @@ -1047,16 +1055,16 @@ impl SpotBalance for PoolBalance { } fn balance(&self) -> u128 { - self.scaled_balance + self.scaled_balance.as_u128() } fn increase_balance(&mut self, delta: u128) -> DriftResult { - self.scaled_balance = self.scaled_balance.safe_add(delta)?; + self.scaled_balance = self.scaled_balance().safe_add(delta)?.into(); Ok(()) } fn decrease_balance(&mut self, delta: u128) -> DriftResult { - self.scaled_balance = self.scaled_balance.safe_sub(delta)?; + self.scaled_balance = self.scaled_balance().safe_sub(delta)?.into(); Ok(()) } @@ -1066,7 +1074,8 @@ impl SpotBalance for PoolBalance { } #[assert_no_slop] -#[zero_copy(unsafe)] +#[legacy_layout] +#[account(zero_copy(unsafe))] #[derive(Debug, PartialEq, Eq)] #[repr(C)] pub struct AMM { @@ -1214,7 +1223,7 @@ pub struct AMM { pub net_revenue_since_last_funding: i64, /// the last funding rate update unix_timestamp pub last_funding_rate_ts: i64, - /// the peridocity of the funding rate updates + /// the periodicity of the funding rate updates pub funding_period: i64, /// the base step size (increment) of orders /// precision: BASE_PRECISION @@ -1295,45 +1304,45 @@ impl Default for AMM { AMM { oracle: Pubkey::default(), historical_oracle_data: HistoricalOracleData::default(), - base_asset_amount_per_lp: 0, - quote_asset_amount_per_lp: 0, + base_asset_amount_per_lp: 0.into(), + quote_asset_amount_per_lp: 0.into(), fee_pool: PoolBalance::default(), - base_asset_reserve: 0, - quote_asset_reserve: 0, - concentration_coef: 0, - min_base_asset_reserve: 0, - max_base_asset_reserve: 0, - sqrt_k: 0, - peg_multiplier: 0, - terminal_quote_asset_reserve: 0, - base_asset_amount_long: 0, - base_asset_amount_short: 0, - base_asset_amount_with_amm: 0, - base_asset_amount_with_unsettled_lp: 0, - max_open_interest: 0, - quote_asset_amount: 0, - quote_entry_amount_long: 0, - quote_entry_amount_short: 0, - quote_break_even_amount_long: 0, - quote_break_even_amount_short: 0, - user_lp_shares: 0, - last_funding_rate: 0, - last_funding_rate_long: 0, - last_funding_rate_short: 0, - last_24h_avg_funding_rate: 0, - total_fee: 0, - total_mm_fee: 0, - total_exchange_fee: 0, - total_fee_minus_distributions: 0, - total_fee_withdrawn: 0, - total_liquidation_fee: 0, - cumulative_funding_rate_long: 0, - cumulative_funding_rate_short: 0, - total_social_loss: 0, - ask_base_asset_reserve: 0, - ask_quote_asset_reserve: 0, - bid_base_asset_reserve: 0, - bid_quote_asset_reserve: 0, + base_asset_reserve: 0.into(), + quote_asset_reserve: 0.into(), + concentration_coef: 0.into(), + min_base_asset_reserve: 0.into(), + max_base_asset_reserve: 0.into(), + sqrt_k: 0.into(), + peg_multiplier: 0.into(), + terminal_quote_asset_reserve: 0.into(), + base_asset_amount_long: 0.into(), + base_asset_amount_short: 0.into(), + base_asset_amount_with_amm: 0.into(), + base_asset_amount_with_unsettled_lp: 0.into(), + max_open_interest: 0.into(), + quote_asset_amount: 0.into(), + quote_entry_amount_long: 0.into(), + quote_entry_amount_short: 0.into(), + quote_break_even_amount_long: 0.into(), + quote_break_even_amount_short: 0.into(), + user_lp_shares: 0.into(), + last_funding_rate: 0.into(), + last_funding_rate_long: 0.into(), + last_funding_rate_short: 0.into(), + last_24h_avg_funding_rate: 0.into(), + total_fee: 0.into(), + total_mm_fee: 0.into(), + total_exchange_fee: 0.into(), + total_fee_minus_distributions: 0.into(), + total_fee_withdrawn: 0.into(), + total_liquidation_fee: 0.into(), + cumulative_funding_rate_long: 0.into(), + cumulative_funding_rate_short: 0.into(), + total_social_loss: 0.into(), + ask_base_asset_reserve: 0.into(), + ask_quote_asset_reserve: 0.into(), + bid_base_asset_reserve: 0.into(), + bid_quote_asset_reserve: 0.into(), last_oracle_normalised_price: 0, last_oracle_reserve_price_spread_pct: 0, last_bid_price_twap: 0, @@ -1442,10 +1451,10 @@ impl AMM { } pub fn get_lower_bound_sqrt_k(self) -> DriftResult { - Ok(self.sqrt_k.min( - (self.min_order_size.cast::()?) - .max(self.base_asset_amount_with_amm.unsigned_abs()), - )) + Ok(self + .sqrt_k + .as_u128() + .min((self.min_order_size as u128).max(self.base_asset_amount_with_amm.unsigned_abs()))) } pub fn get_protocol_owned_position(self) -> DriftResult { @@ -1471,10 +1480,10 @@ impl AMM { pub fn amm_wants_to_jit_make(&self, taker_direction: PositionDirection) -> DriftResult { let amm_wants_to_jit_make = match taker_direction { PositionDirection::Long => { - self.base_asset_amount_with_amm < -(self.order_step_size.cast()?) + self.base_asset_amount_with_amm.as_i128() < -(self.order_step_size as i128) } PositionDirection::Short => { - self.base_asset_amount_with_amm > (self.order_step_size.cast()?) + self.base_asset_amount_with_amm.as_i128() > self.order_step_size as i128 } }; Ok(amm_wants_to_jit_make && self.amm_jit_is_active()) @@ -1486,9 +1495,9 @@ impl AMM { if amm_wants_to_jit_make { // inventory scale let (max_bids, max_asks) = amm::_calculate_market_open_bids_asks( - self.base_asset_reserve, - self.min_base_asset_reserve, - self.max_base_asset_reserve, + self.base_asset_reserve.into(), + self.min_base_asset_reserve.into(), + self.max_base_asset_reserve.into(), )?; let protocol_owned_min_side_liquidity = max_bids.min(max_asks.abs()); @@ -1506,9 +1515,9 @@ impl AMM { pub fn reserve_price(&self) -> DriftResult { amm::calculate_price( - self.quote_asset_reserve, - self.base_asset_reserve, - self.peg_multiplier, + self.quote_asset_reserve.into(), + self.base_asset_reserve.into(), + self.peg_multiplier.into(), ) } @@ -1569,7 +1578,7 @@ impl AMM { .base_asset_amount_with_amm .unsigned_abs() .max(min_order_size_u128) - < self.sqrt_k) + < self.sqrt_k.into()) && (min_order_size_u128 < max_bids.unsigned_abs().max(max_asks.unsigned_abs())); Ok(can_lower) @@ -1755,16 +1764,16 @@ impl AMM { let default_reserves = 100 * AMM_RESERVE_PRECISION; // make sure tests dont have the default sqrt_k = 0 AMM { - base_asset_reserve: default_reserves, - quote_asset_reserve: default_reserves, - sqrt_k: default_reserves, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, + base_asset_reserve: default_reserves.into(), + quote_asset_reserve: default_reserves.into(), + sqrt_k: default_reserves.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), order_step_size: 1, order_tick_size: 1, - max_base_asset_reserve: u64::MAX as u128, - min_base_asset_reserve: 0, - terminal_quote_asset_reserve: default_reserves, - peg_multiplier: crate::math::constants::PEG_PRECISION, + max_base_asset_reserve: (u64::MAX as u128).into(), + min_base_asset_reserve: 0.into(), + terminal_quote_asset_reserve: default_reserves.into(), + peg_multiplier: crate::math::constants::PEG_PRECISION.into(), max_fill_reserve_fraction: 1, max_spread: 1000, historical_oracle_data: HistoricalOracleData { @@ -1780,21 +1789,21 @@ impl AMM { use crate::math::constants::PRICE_PRECISION_I64; AMM { - base_asset_reserve: 65 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 63015384615, - terminal_quote_asset_reserve: 64 * AMM_RESERVE_PRECISION, - sqrt_k: 64 * AMM_RESERVE_PRECISION, + base_asset_reserve: (65 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: 63015384615.into(), + terminal_quote_asset_reserve: (64 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (64 * AMM_RESERVE_PRECISION).into(), - peg_multiplier: 19_400_000_000, + peg_multiplier: 19_400_000_000.into(), - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - max_base_asset_reserve: 90 * AMM_RESERVE_PRECISION, - min_base_asset_reserve: 45 * AMM_RESERVE_PRECISION, + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + max_base_asset_reserve: (90 * AMM_RESERVE_PRECISION).into(), + min_base_asset_reserve: (45 * AMM_RESERVE_PRECISION).into(), - base_asset_amount_with_amm: -(AMM_RESERVE_PRECISION as i128), + base_asset_amount_with_amm: (AMM_RESERVE_PRECISION as i128 * -1).into(), mark_std: PRICE_PRECISION as u64, - quote_asset_amount: 19_000_000_000, // short 1 BTC @ $19000 + quote_asset_amount: 19_000_000_000.into(), // short 1 BTC @ $19000 historical_oracle_data: HistoricalOracleData { last_oracle_price: 19_400 * PRICE_PRECISION_I64, last_oracle_price_twap: 19_400 * PRICE_PRECISION_I64, diff --git a/programs/drift/src/state/perp_market/tests.rs b/programs/drift/src/state/perp_market/tests.rs index 3f09e5c58c..6a489f491d 100644 --- a/programs/drift/src/state/perp_market/tests.rs +++ b/programs/drift/src/state/perp_market/tests.rs @@ -7,12 +7,12 @@ mod amm { #[test] fn last_ask_premium() { let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 10) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 10) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), ..AMM::default() }; amm.historical_oracle_data.last_oracle_price = 100 * PRICE_PRECISION_I64; @@ -25,12 +25,12 @@ mod amm { #[test] fn last_bid_discount() { let mut amm = AMM { - base_asset_reserve: 100 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 100 * AMM_RESERVE_PRECISION, + base_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (100 * AMM_RESERVE_PRECISION).into(), short_spread: (BID_ASK_SPREAD_PRECISION / 10) as u32, long_spread: (BID_ASK_SPREAD_PRECISION / 10) as u32, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 100 * PEG_PRECISION, + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: (100 * PEG_PRECISION).into(), ..AMM::default() }; amm.historical_oracle_data.last_oracle_price = 100 * PRICE_PRECISION_I64; @@ -590,13 +590,13 @@ mod amm_can_fill_order_tests { assert!(!can1); // valid oracle for immediate and user can skip, market can skip due to low inventory => can fill - market.amm.base_asset_amount_with_amm = -2; // taker long improves balance + market.amm.set_base_asset_amount_with_amm(-2); // taker long improves balance market.amm.order_step_size = 1; - market.amm.base_asset_reserve = 1_000_000; - market.amm.quote_asset_reserve = 1_000_000; - market.amm.sqrt_k = 1_000_000; - market.amm.max_base_asset_reserve = 2_000_000; - market.amm.min_base_asset_reserve = 0; + market.amm.set_base_asset_reserve(1_000_000); + market.amm.set_quote_asset_reserve(1_000_000); + market.amm.set_sqrt_k(1_000_000); + market.amm.set_max_base_asset_reserve(2_000_000); + market.amm.set_min_base_asset_reserve(0); let can2 = market .amm_can_fill_order( diff --git a/programs/drift/src/state/perp_market_map.rs b/programs/drift/src/state/perp_market_map.rs index 28367fb7ae..b9770cb3f2 100644 --- a/programs/drift/src/state/perp_market_map.rs +++ b/programs/drift/src/state/perp_market_map.rs @@ -25,7 +25,7 @@ pub struct PerpMarketMap<'a>(pub BTreeMap>); impl<'a> PerpMarketMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref(&self, market_index: &u16) -> DriftResult> { + pub fn get_ref(&self, market_index: &u16) -> DriftResult> { let loader = match self.0.get(market_index) { Some(loader) => loader, None => { @@ -58,7 +58,7 @@ impl<'a> PerpMarketMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref_mut(&self, market_index: &u16) -> DriftResult> { + pub fn get_ref_mut(&self, market_index: &u16) -> DriftResult> { let loader = match self.0.get(market_index) { Some(loader) => loader, None => { diff --git a/programs/drift/src/state/revenue_share.rs b/programs/drift/src/state/revenue_share.rs index 7997b2fb4e..f63efbf8be 100644 --- a/programs/drift/src/state/revenue_share.rs +++ b/programs/drift/src/state/revenue_share.rs @@ -1,9 +1,10 @@ use std::cell::{Ref, RefMut}; use anchor_lang::prelude::{ - account, zero_copy, AccountInfo, AnchorDeserialize, AnchorSerialize, Discriminator, Pubkey, + account, + borsh::{BorshDeserialize, BorshSerialize}, + zero_copy, AccountInfo, AnchorDeserialize, AnchorSerialize, Discriminator, Pubkey, }; -use borsh::{BorshDeserialize, BorshSerialize}; use crate::error::{DriftResult, ErrorCode}; use crate::math::casting::Cast; @@ -512,12 +513,12 @@ impl<'a> RevenueShareEscrowZeroCopyMut<'a> { } pub trait RevenueShareEscrowLoader<'a> { - fn load_zc(&self) -> DriftResult; - fn load_zc_mut(&self) -> DriftResult; + fn load_zc(&self) -> DriftResult>; + fn load_zc_mut(&self) -> DriftResult>; } impl<'a> RevenueShareEscrowLoader<'a> for AccountInfo<'a> { - fn load_zc(&self) -> DriftResult { + fn load_zc(&self) -> DriftResult> { let owner = self.owner; validate!( @@ -543,7 +544,7 @@ impl<'a> RevenueShareEscrowLoader<'a> for AccountInfo<'a> { }) } - fn load_zc_mut(&self) -> DriftResult { + fn load_zc_mut(&self) -> DriftResult> { let owner = self.owner; validate!( diff --git a/programs/drift/src/state/revenue_share_map.rs b/programs/drift/src/state/revenue_share_map.rs index 912e8a43ea..39347bb048 100644 --- a/programs/drift/src/state/revenue_share_map.rs +++ b/programs/drift/src/state/revenue_share_map.rs @@ -71,7 +71,7 @@ impl<'a> RevenueShareMap<'a> { #[track_caller] #[inline(always)] - pub fn get_user_ref_mut(&self, authority: &Pubkey) -> DriftResult> { + pub fn get_user_ref_mut(&self, authority: &Pubkey) -> DriftResult> { let loader = match self.0.get(authority).and_then(|e| e.user.as_ref()) { Some(loader) => loader, None => { @@ -107,7 +107,7 @@ impl<'a> RevenueShareMap<'a> { pub fn get_revenue_share_account_mut( &self, authority: &Pubkey, - ) -> DriftResult> { + ) -> DriftResult> { let loader = match self.0.get(authority).and_then(|e| e.revenue_share.as_ref()) { Some(loader) => loader, None => { diff --git a/programs/drift/src/state/settle_pnl_mode.rs b/programs/drift/src/state/settle_pnl_mode.rs index f13002d7db..eafa1837b9 100644 --- a/programs/drift/src/state/settle_pnl_mode.rs +++ b/programs/drift/src/state/settle_pnl_mode.rs @@ -1,6 +1,6 @@ use crate::error::{DriftResult, ErrorCode}; use crate::msg; -use borsh::{BorshDeserialize, BorshSerialize}; +use anchor_lang::prelude::{borsh::BorshDeserialize, borsh::BorshSerialize}; use std::panic::Location; #[cfg(test)] diff --git a/programs/drift/src/state/signed_msg_user.rs b/programs/drift/src/state/signed_msg_user.rs index 2ab4bef97b..f8c922faff 100644 --- a/programs/drift/src/state/signed_msg_user.rs +++ b/programs/drift/src/state/signed_msg_user.rs @@ -169,12 +169,12 @@ impl<'a> SignedMsgUserOrdersZeroCopyMut<'a> { } pub trait SignedMsgUserOrdersLoader<'a> { - fn load(&self) -> DriftResult; - fn load_mut(&self) -> DriftResult; + fn load(&self) -> DriftResult>; + fn load_mut(&self) -> DriftResult>; } impl<'a> SignedMsgUserOrdersLoader<'a> for AccountInfo<'a> { - fn load(&self) -> DriftResult { + fn load(&self) -> DriftResult> { let owner = self.owner; validate!( @@ -199,7 +199,7 @@ impl<'a> SignedMsgUserOrdersLoader<'a> for AccountInfo<'a> { }) } - fn load_mut(&self) -> DriftResult { + fn load_mut(&self) -> DriftResult> { let owner = self.owner; validate!( diff --git a/programs/drift/src/state/spot_market.rs b/programs/drift/src/state/spot_market.rs index c42000a7b1..e3d503d29c 100644 --- a/programs/drift/src/state/spot_market.rs +++ b/programs/drift/src/state/spot_market.rs @@ -1,11 +1,6 @@ use std::fmt; use std::fmt::{Display, Formatter}; -use anchor_lang::prelude::*; -use anchor_spl::token::spl_token; -use anchor_spl::token_2022::spl_token_2022; -use borsh::{BorshDeserialize, BorshSerialize}; - use crate::error::{DriftResult, ErrorCode}; use crate::math::casting::Cast; use crate::math::constants::{ @@ -20,6 +15,13 @@ use crate::math::margin::{ }; use crate::math::safe_math::SafeMath; use crate::math::spot_balance::{calculate_utilization, get_token_amount, get_token_value}; +use anchor_lang::prelude::{ + borsh::{BorshDeserialize, BorshSerialize}, + *, +}; +use anchor_spl::token::spl_token; +use anchor_spl::token_2022::spl_token_2022; +use drift_macros::legacy_layout; use crate::math::stats::calculate_new_twap; use crate::state::oracle::{HistoricalIndexData, HistoricalOracleData, OracleSource}; @@ -30,6 +32,7 @@ use crate::validate; use super::oracle_map::OracleIdentifier; +#[legacy_layout] #[account(zero_copy(unsafe))] #[derive(PartialEq, Eq, Debug)] #[repr(C)] @@ -223,13 +226,13 @@ impl Default for SpotMarket { revenue_pool: PoolBalance::default(), spot_fee_pool: PoolBalance::default(), insurance_fund: InsuranceFund::default(), - total_spot_fee: 0, - deposit_balance: 0, - borrow_balance: 0, - cumulative_deposit_interest: 0, - cumulative_borrow_interest: 0, - total_social_loss: 0, - total_quote_social_loss: 0, + total_spot_fee: 0.into(), + deposit_balance: 0.into(), + borrow_balance: 0.into(), + cumulative_deposit_interest: 0.into(), + cumulative_borrow_interest: 0.into(), + total_social_loss: 0.into(), + total_quote_social_loss: 0.into(), withdraw_guard_threshold: 0, max_token_deposits: 0, deposit_token_twap: 0, @@ -449,11 +452,11 @@ impl SpotMarket { } pub fn get_deposits(&self) -> DriftResult { - get_token_amount(self.deposit_balance, self, &SpotBalanceType::Deposit) + get_token_amount(self.deposit_balance.into(), self, &SpotBalanceType::Deposit) } pub fn get_borrows(&self) -> DriftResult { - get_token_amount(self.borrow_balance, self, &SpotBalanceType::Borrow) + get_token_amount(self.borrow_balance.into(), self, &SpotBalanceType::Borrow) } pub fn get_tvl(&self) -> DriftResult { @@ -500,10 +503,10 @@ impl SpotMarket { pub fn get_available_deposits(&self) -> DriftResult { let deposit_token_amount = - get_token_amount(self.deposit_balance, self, &SpotBalanceType::Deposit)?; + get_token_amount(self.deposit_balance.into(), self, &SpotBalanceType::Deposit)?; let borrow_token_amount = - get_token_amount(self.borrow_balance, self, &SpotBalanceType::Borrow)?; + get_token_amount(self.borrow_balance.into(), self, &SpotBalanceType::Borrow)?; deposit_token_amount.safe_sub(borrow_token_amount) } @@ -513,11 +516,14 @@ impl SpotMarket { } pub fn get_utilization(self) -> DriftResult { - let deposit_token_amount = - get_token_amount(self.deposit_balance, &self, &SpotBalanceType::Deposit)?; + let deposit_token_amount = get_token_amount( + self.deposit_balance.into(), + &self, + &SpotBalanceType::Deposit, + )?; let borrow_token_amount = - get_token_amount(self.borrow_balance, &self, &SpotBalanceType::Borrow)?; + get_token_amount(self.borrow_balance.into(), &self, &SpotBalanceType::Borrow)?; calculate_utilization(deposit_token_amount, borrow_token_amount) } @@ -597,8 +603,8 @@ impl SpotMarket { pub fn default_base_market() -> Self { SpotMarket { market_index: 1, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), initial_liability_weight: 12000, maintenance_liability_weight: 11000, initial_asset_weight: 8000, @@ -613,8 +619,8 @@ impl SpotMarket { pub fn default_quote_market() -> Self { SpotMarket { - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, - cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), + cumulative_borrow_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_liability_weight: 10000, maintenance_liability_weight: 10000, @@ -686,6 +692,7 @@ pub enum AssetTier { Unlisted, } +#[legacy_layout] #[zero_copy(unsafe)] #[derive(Default, Eq, PartialEq, Debug)] #[repr(C)] @@ -703,7 +710,9 @@ pub struct InsuranceFund { impl InsuranceFund { pub fn get_protocol_shares(&self) -> DriftResult { - self.total_shares.safe_sub(self.user_shares) + self.total_shares + .as_u128() + .safe_sub(self.user_shares.as_u128()) } } diff --git a/programs/drift/src/state/spot_market_map.rs b/programs/drift/src/state/spot_market_map.rs index c555a939cc..cb34ed06f6 100644 --- a/programs/drift/src/state/spot_market_map.rs +++ b/programs/drift/src/state/spot_market_map.rs @@ -24,7 +24,7 @@ pub struct SpotMarketMap<'a>( impl<'a> SpotMarketMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref(&self, market_index: &u16) -> DriftResult> { + pub fn get_ref(&self, market_index: &u16) -> DriftResult> { let loader = match self.0.get(market_index) { Some(loader) => loader, None => { @@ -57,7 +57,7 @@ impl<'a> SpotMarketMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref_mut(&self, market_index: &u16) -> DriftResult> { + pub fn get_ref_mut(&self, market_index: &u16) -> DriftResult> { if !self.1.contains(market_index) { let caller = Location::caller(); msg!( @@ -101,7 +101,7 @@ impl<'a> SpotMarketMap<'a> { #[track_caller] #[inline(always)] - pub fn get_quote_spot_market(&self) -> DriftResult> { + pub fn get_quote_spot_market(&self) -> DriftResult> { let loader = match self.0.get("E_SPOT_MARKET_INDEX) { Some(loader) => loader, None => { @@ -134,7 +134,7 @@ impl<'a> SpotMarketMap<'a> { #[track_caller] #[inline(always)] - pub fn get_quote_spot_market_mut(&self) -> DriftResult> { + pub fn get_quote_spot_market_mut(&self) -> DriftResult> { if !self.1.contains("E_SPOT_MARKET_INDEX) { let caller = Location::caller(); msg!( diff --git a/programs/drift/src/state/state.rs b/programs/drift/src/state/state.rs index 07e9213396..14afc90bd9 100644 --- a/programs/drift/src/state/state.rs +++ b/programs/drift/src/state/state.rs @@ -1,4 +1,5 @@ use anchor_lang::prelude::*; +use drift_macros::legacy_layout; use enumflags2::BitFlags; use crate::error::DriftResult; @@ -13,6 +14,7 @@ use crate::state::traits::Size; #[cfg(test)] mod tests; +#[legacy_layout] #[account] #[derive(Default)] #[repr(C)] @@ -254,6 +256,7 @@ impl Default for FeeTier { } } +#[legacy_layout] #[derive(AnchorSerialize, AnchorDeserialize, Default, Clone, Debug)] pub struct OrderFillerRewardStructure { pub reward_numerator: u32, @@ -329,7 +332,7 @@ impl FeeStructure { filler_reward_structure: OrderFillerRewardStructure { reward_numerator: 10, reward_denominator: FEE_PERCENTAGE_DENOMINATOR, - time_based_reward_lower_bound: 10_000, // 1 cent + time_based_reward_lower_bound: 10_000.into(), // 1 cent }, flat_filler_fee: 10_000, referrer_reward_epoch_upper_bound: MAX_REFERRER_REWARD_EPOCH_UPPER_BOUND, @@ -353,7 +356,7 @@ impl FeeStructure { filler_reward_structure: OrderFillerRewardStructure { reward_numerator: 10, reward_denominator: FEE_PERCENTAGE_DENOMINATOR, - time_based_reward_lower_bound: 10_000, // 1 cent + time_based_reward_lower_bound: 10_000.into(), // 1 cent }, flat_filler_fee: 10_000, referrer_reward_epoch_upper_bound: MAX_REFERRER_REWARD_EPOCH_UPPER_BOUND, @@ -380,7 +383,7 @@ impl FeeStructure { filler_reward_structure: OrderFillerRewardStructure { reward_numerator: 10, reward_denominator: FEE_PERCENTAGE_DENOMINATOR, - time_based_reward_lower_bound: 10_000, // 1 cent + time_based_reward_lower_bound: 10_000.into(), // 1 cent }, ..FeeStructure::perps_default() } diff --git a/programs/drift/src/state/user.rs b/programs/drift/src/state/user.rs index a89467cce3..24aeaf0455 100644 --- a/programs/drift/src/state/user.rs +++ b/programs/drift/src/state/user.rs @@ -28,9 +28,13 @@ use crate::state::spot_market::{SpotBalance, SpotBalanceType, SpotMarket}; use crate::state::traits::Size; use crate::validate; use crate::{get_then_update_id, ID}; -use anchor_lang::prelude::*; -use borsh::{BorshDeserialize, BorshSerialize}; +use anchor_lang::prelude::{ + borsh::{BorshDeserialize, BorshSerialize}, + *, +}; use bytemuck::{Pod, Zeroable}; +use drift_macros::legacy_layout; +use num_traits::Zero; use std::cmp::max; use std::fmt; use std::ops::Neg; @@ -2085,6 +2089,8 @@ impl FuelOverflowStatus { status & FuelOverflowStatus::Exists as u8 != 0 } } + +#[legacy_layout] #[account(zero_copy(unsafe))] #[derive(Default, Debug)] #[repr(C)] @@ -2111,39 +2117,56 @@ impl FuelOverflow { pub fn update_from_user_stats(&mut self, user_stats: &UserStats, now: u32) -> DriftResult<()> { self.fuel_insurance = self .fuel_insurance - .safe_add(user_stats.fuel_insurance.cast()?)?; + .as_u128() + .safe_add(user_stats.fuel_insurance as u128)? + .into(); self.fuel_deposits = self .fuel_deposits - .safe_add(user_stats.fuel_deposits.cast()?)?; + .as_u128() + .safe_add(user_stats.fuel_deposits as u128)? + .into(); self.fuel_borrows = self .fuel_borrows - .safe_add(user_stats.fuel_borrows.cast()?)?; + .as_u128() + .safe_add(user_stats.fuel_borrows as u128)? + .into(); self.fuel_positions = self .fuel_positions - .safe_add(user_stats.fuel_positions.cast()?)?; - self.fuel_taker = self.fuel_taker.safe_add(user_stats.fuel_taker.cast()?)?; - self.fuel_maker = self.fuel_maker.safe_add(user_stats.fuel_maker.cast()?)?; + .as_u128() + .safe_add(user_stats.fuel_positions as u128)? + .into(); + self.fuel_taker = self + .fuel_taker + .as_u128() + .safe_add(user_stats.fuel_taker as u128)? + .into(); + self.fuel_maker = self + .fuel_maker + .as_u128() + .safe_add(user_stats.fuel_maker as u128)? + .into(); self.last_fuel_sweep_ts = now; Ok(()) } pub fn reset_fuel(&mut self, now: u32) { - self.fuel_insurance = 0; - self.fuel_deposits = 0; - self.fuel_borrows = 0; - self.fuel_positions = 0; - self.fuel_taker = 0; - self.fuel_maker = 0; + self.fuel_insurance = Zero::zero(); + self.fuel_deposits = Zero::zero(); + self.fuel_borrows = Zero::zero(); + self.fuel_positions = Zero::zero(); + self.fuel_taker = Zero::zero(); + self.fuel_maker = Zero::zero(); self.last_reset_ts = now; } pub fn total_fuel(&self) -> DriftResult { self.fuel_insurance - .safe_add(self.fuel_deposits)? - .safe_add(self.fuel_borrows)? - .safe_add(self.fuel_positions)? - .safe_add(self.fuel_taker)? - .safe_add(self.fuel_maker) + .as_u128() + .safe_add(self.fuel_deposits.as_u128())? + .safe_add(self.fuel_borrows.as_u128())? + .safe_add(self.fuel_positions.as_u128())? + .safe_add(self.fuel_taker.as_u128())? + .safe_add(self.fuel_maker.as_u128()) } } diff --git a/programs/drift/src/state/user/tests.rs b/programs/drift/src/state/user/tests.rs index 4b2392d1ba..335bbfd24a 100644 --- a/programs/drift/src/state/user/tests.rs +++ b/programs/drift/src/state/user/tests.rs @@ -214,30 +214,30 @@ mod get_claimable_pnl { let usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 1000 * SPOT_BALANCE_PRECISION, + deposit_balance: (1000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; let perp_market = PerpMarket { amm: AMM { - base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 150_000, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION_I128, + base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 150_000.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION_I128).into(), curve_update_intensity: 100, - base_asset_amount_with_amm: AMM_RESERVE_PRECISION as i128, - quote_asset_amount: -100 * QUOTE_PRECISION_I128, + base_asset_amount_with_amm: (AMM_RESERVE_PRECISION as i128).into(), + quote_asset_amount: (-100 * QUOTE_PRECISION_I128).into(), ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: (10 * SPOT_BALANCE_PRECISION), + scaled_balance: (10 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -280,7 +280,7 @@ mod get_claimable_pnl { let oracle_price = 150 * PRICE_PRECISION_I64; let pnl_pool_token_amount = get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), &usdc_market, perp_market.pnl_pool.balance_type(), ) @@ -320,30 +320,30 @@ mod get_claimable_pnl { let usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 1000 * SPOT_BALANCE_PRECISION, + deposit_balance: (1000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; let mut perp_market = PerpMarket { amm: AMM { - base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 150_000, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION_I128, + base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 150_000.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION_I128).into(), curve_update_intensity: 100, - base_asset_amount_with_amm: AMM_RESERVE_PRECISION as i128, - quote_asset_amount: -99 * QUOTE_PRECISION_I128, + base_asset_amount_with_amm: (AMM_RESERVE_PRECISION as i128).into(), + quote_asset_amount: (-99 * QUOTE_PRECISION_I128).into(), ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: (60 * SPOT_BALANCE_PRECISION), + scaled_balance: (60 * SPOT_BALANCE_PRECISION).into(), market_index: QUOTE_SPOT_MARKET_INDEX, ..PoolBalance::default() }, @@ -386,7 +386,7 @@ mod get_claimable_pnl { let oracle_price = 150 * PRICE_PRECISION_I64; let pnl_pool_token_amount = get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), &usdc_market, perp_market.pnl_pool.balance_type(), ) @@ -440,7 +440,9 @@ mod get_claimable_pnl { ); assert_eq!(unsettled_pnl3, 9_000_000); - perp_market.amm.quote_asset_amount = -100 * QUOTE_PRECISION_I128; + perp_market + .amm + .set_quote_asset_amount(-100 * QUOTE_PRECISION_I128); let net_user_pnl = calculate_net_user_pnl(&perp_market.amm, oracle_price).unwrap(); assert_eq!(net_user_pnl, 50000000); let max_pnl_pool_excess = if net_user_pnl < pnl_pool_token_amount { @@ -471,30 +473,30 @@ mod get_claimable_pnl { let usdc_market = SpotMarket { market_index: 0, oracle_source: OracleSource::QuoteAsset, - cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION, + cumulative_deposit_interest: SPOT_CUMULATIVE_INTEREST_PRECISION.into(), decimals: 6, initial_asset_weight: SPOT_WEIGHT_PRECISION, maintenance_asset_weight: SPOT_WEIGHT_PRECISION, - deposit_balance: 1000 * SPOT_BALANCE_PRECISION, + deposit_balance: (1000 * SPOT_BALANCE_PRECISION).into(), liquidator_fee: 0, ..SpotMarket::default() }; let perp_market = PerpMarket { amm: AMM { - base_asset_reserve: 99 * AMM_RESERVE_PRECISION, - quote_asset_reserve: 101 * AMM_RESERVE_PRECISION, - sqrt_k: 100 * AMM_RESERVE_PRECISION, - peg_multiplier: 150_000, - concentration_coef: MAX_CONCENTRATION_COEFFICIENT, - total_fee_minus_distributions: 1000 * QUOTE_PRECISION_I128, + base_asset_reserve: (99 * AMM_RESERVE_PRECISION).into(), + quote_asset_reserve: (101 * AMM_RESERVE_PRECISION).into(), + sqrt_k: (100 * AMM_RESERVE_PRECISION).into(), + peg_multiplier: 150_000.into(), + concentration_coef: MAX_CONCENTRATION_COEFFICIENT.into(), + total_fee_minus_distributions: (1000 * QUOTE_PRECISION_I128).into(), curve_update_intensity: 100, - base_asset_amount_with_amm: AMM_RESERVE_PRECISION as i128, - quote_asset_amount: -100 * QUOTE_PRECISION_I128, + base_asset_amount_with_amm: (AMM_RESERVE_PRECISION as i128).into(), + quote_asset_amount: (-100 * QUOTE_PRECISION_I128).into(), ..AMM::default() }, pnl_pool: PoolBalance { - scaled_balance: (1000 * SPOT_BALANCE_PRECISION), + scaled_balance: (1000 * SPOT_BALANCE_PRECISION).into(), market_index: 0, ..PoolBalance::default() }, @@ -537,7 +539,7 @@ mod get_claimable_pnl { let oracle_price = 160 * PRICE_PRECISION_I64; let pnl_pool_token_amount = get_token_amount( - perp_market.pnl_pool.scaled_balance, + perp_market.pnl_pool.scaled_balance(), &usdc_market, perp_market.pnl_pool.balance_type(), ) diff --git a/programs/drift/src/state/user_map.rs b/programs/drift/src/state/user_map.rs index 8f71c992dc..b5a850955e 100644 --- a/programs/drift/src/state/user_map.rs +++ b/programs/drift/src/state/user_map.rs @@ -21,7 +21,7 @@ pub struct UserMap<'a>(pub BTreeMap>); impl<'a> UserMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref(&self, user: &Pubkey) -> DriftResult> { + pub fn get_ref(&self, user: &Pubkey) -> DriftResult> { let loader = match self.0.get(user) { Some(loader) => loader, None => { @@ -54,7 +54,7 @@ impl<'a> UserMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref_mut(&self, user: &Pubkey) -> DriftResult> { + pub fn get_ref_mut(&self, user: &Pubkey) -> DriftResult> { let loader = match self.0.get(user) { Some(loader) => loader, None => { @@ -143,7 +143,7 @@ pub struct UserStatsMap<'a>(pub BTreeMap>); impl<'a> UserStatsMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref(&self, authority: &Pubkey) -> DriftResult> { + pub fn get_ref(&self, authority: &Pubkey) -> DriftResult> { let loader = match self.0.get(authority) { Some(loader) => loader, None => { @@ -176,7 +176,7 @@ impl<'a> UserStatsMap<'a> { #[track_caller] #[inline(always)] - pub fn get_ref_mut(&self, authority: &Pubkey) -> DriftResult> { + pub fn get_ref_mut(&self, authority: &Pubkey) -> DriftResult> { let loader = match self.0.get(authority) { Some(loader) => loader, None => { diff --git a/programs/drift/src/validation/perp_market.rs b/programs/drift/src/validation/perp_market.rs index 30bce4dedd..7945136ce4 100644 --- a/programs/drift/src/validation/perp_market.rs +++ b/programs/drift/src/validation/perp_market.rs @@ -12,13 +12,13 @@ use crate::validate; pub fn validate_perp_market(market: &PerpMarket) -> DriftResult { let (_, remainder_base_asset_amount_long) = crate::math::orders::standardize_base_asset_amount_with_remainder_i128( - market.amm.base_asset_amount_long, + market.amm.base_asset_amount_long(), market.amm.order_step_size.cast()?, )?; let (_, remainder_base_asset_amount_short) = crate::math::orders::standardize_base_asset_amount_with_remainder_i128( - market.amm.base_asset_amount_short, + market.amm.base_asset_amount_short(), market.amm.order_step_size.cast()?, )?; @@ -31,29 +31,29 @@ pub fn validate_perp_market(market: &PerpMarket) -> DriftResult { market.amm.order_step_size )?; validate!( - (market.amm.base_asset_amount_long + market.amm.base_asset_amount_short) - == market.amm.base_asset_amount_with_amm, + (market.amm.base_asset_amount_long() + market.amm.base_asset_amount_short()) + == market.amm.base_asset_amount_with_amm(), ErrorCode::InvalidAmmDetected, "Market NET_BAA Error: market.amm.base_asset_amount_long={}, + market.amm.base_asset_amount_short={} != market.amm.base_asset_amount_with_amm={}", - market.amm.base_asset_amount_long, - market.amm.base_asset_amount_short, - market.amm.base_asset_amount_with_amm, + market.amm.base_asset_amount_long(), + market.amm.base_asset_amount_short(), + market.amm.base_asset_amount_with_amm(), )?; validate!( - market.amm.base_asset_amount_with_amm <= (MAX_BASE_ASSET_AMOUNT_WITH_AMM as i128), + market.amm.base_asset_amount_with_amm() <= (MAX_BASE_ASSET_AMOUNT_WITH_AMM as i128), ErrorCode::InvalidAmmDetected, "market {} market.amm.base_asset_amount_with_amm={} is too large", market.market_index, - market.amm.base_asset_amount_with_amm + market.amm.base_asset_amount_with_amm() )?; validate!( - market.amm.peg_multiplier > 0, + market.amm.peg_multiplier() > 0, ErrorCode::InvalidAmmDetected, "market {} peg_multiplier out of wack", market.market_index, @@ -61,35 +61,35 @@ pub fn validate_perp_market(market: &PerpMarket) -> DriftResult { if market.status != MarketStatus::ReduceOnly { validate!( - market.amm.sqrt_k > market.amm.base_asset_amount_with_amm.unsigned_abs(), + market.amm.sqrt_k() > market.amm.base_asset_amount_with_amm().unsigned_abs(), ErrorCode::InvalidAmmDetected, "market {} k out of wack: k={}, net_baa={}", market.market_index, - market.amm.sqrt_k, - market.amm.base_asset_amount_with_amm + market.amm.sqrt_k(), + market.amm.base_asset_amount_with_amm() )?; } validate!( - market.amm.sqrt_k >= market.amm.base_asset_reserve - || market.amm.sqrt_k >= market.amm.quote_asset_reserve, + market.amm.sqrt_k() >= market.amm.base_asset_reserve() + || market.amm.sqrt_k() >= market.amm.quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "market {} k out of wack: k={}, bar={}, qar={}", market.market_index, - market.amm.sqrt_k, - market.amm.base_asset_reserve, - market.amm.quote_asset_reserve + market.amm.sqrt_k(), + market.amm.base_asset_reserve(), + market.amm.quote_asset_reserve() )?; - let invariant_sqrt_u192 = crate::math::bn::U192::from(market.amm.sqrt_k); + let invariant_sqrt_u192 = crate::math::bn::U192::from(market.amm.sqrt_k()); let invariant = invariant_sqrt_u192.safe_mul(invariant_sqrt_u192)?; let quote_asset_reserve = invariant - .safe_div(crate::math::bn::U192::from(market.amm.base_asset_reserve))? + .safe_div(crate::math::bn::U192::from(market.amm.base_asset_reserve()))? .try_to_u128()?; let rounding_diff = quote_asset_reserve .cast::()? - .safe_sub(market.amm.quote_asset_reserve.cast()?)? + .safe_sub(market.amm.quote_asset_reserve().cast()?)? .abs(); validate!( @@ -98,8 +98,8 @@ pub fn validate_perp_market(market: &PerpMarket) -> DriftResult { "market {} amm qar/bar/k invalid: k={}, bar={}, qar={}, qar'={} (rounding: {})", market.market_index, invariant, - market.amm.base_asset_reserve, - market.amm.quote_asset_reserve, + market.amm.base_asset_reserve(), + market.amm.quote_asset_reserve(), quote_asset_reserve, rounding_diff )?; @@ -109,30 +109,30 @@ pub fn validate_perp_market(market: &PerpMarket) -> DriftResult { // bid quote/base < reserve q/b if market.amm.reference_price_offset <= 0 { validate!( - market.amm.bid_base_asset_reserve >= market.amm.base_asset_reserve - && market.amm.bid_quote_asset_reserve <= market.amm.quote_asset_reserve, + market.amm.bid_base_asset_reserve() >= market.amm.base_asset_reserve() + && market.amm.bid_quote_asset_reserve() <= market.amm.quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "market {} amm bid reserves invalid: {} -> {}, quote: {} -> {}", market.market_index, - market.amm.bid_base_asset_reserve, - market.amm.base_asset_reserve, - market.amm.bid_quote_asset_reserve, - market.amm.quote_asset_reserve + market.amm.bid_base_asset_reserve(), + market.amm.base_asset_reserve(), + market.amm.bid_quote_asset_reserve(), + market.amm.quote_asset_reserve() )?; } if market.amm.reference_price_offset >= 0 { // ask quote/base > reserve q/b validate!( - market.amm.ask_base_asset_reserve <= market.amm.base_asset_reserve - && market.amm.ask_quote_asset_reserve >= market.amm.quote_asset_reserve, + market.amm.ask_base_asset_reserve() <= market.amm.base_asset_reserve() + && market.amm.ask_quote_asset_reserve() >= market.amm.quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "market {} amm ask reserves invalid: {} -> {}, quote: {} -> {}", market.market_index, - market.amm.ask_base_asset_reserve, - market.amm.base_asset_reserve, - market.amm.ask_quote_asset_reserve, - market.amm.quote_asset_reserve + market.amm.ask_base_asset_reserve(), + market.amm.base_asset_reserve(), + market.amm.ask_quote_asset_reserve(), + market.amm.quote_asset_reserve() )?; } } @@ -164,32 +164,32 @@ pub fn validate_perp_market(market: &PerpMarket) -> DriftResult { market.amm.max_spread, )?; - if market.amm.base_asset_amount_with_amm > 0 { + if market.amm.base_asset_amount_with_amm() > 0 { // users are long = removed base and added quote = qar increased // bid quote/base < reserve q/b validate!( - market.amm.terminal_quote_asset_reserve <= market.amm.quote_asset_reserve, + market.amm.terminal_quote_asset_reserve() <= market.amm.quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "market {} terminal_quote_asset_reserve out of wack", market.market_index, )?; - } else if market.amm.base_asset_amount_with_amm < 0 { + } else if market.amm.base_asset_amount_with_amm() < 0 { validate!( - market.amm.terminal_quote_asset_reserve >= market.amm.quote_asset_reserve, + market.amm.terminal_quote_asset_reserve() >= market.amm.quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "market {} terminal_quote_asset_reserve out of wack (terminal <) {} > {}", market.market_index, - market.amm.terminal_quote_asset_reserve, - market.amm.quote_asset_reserve + market.amm.terminal_quote_asset_reserve(), + market.amm.quote_asset_reserve() )?; } else { validate!( - market.amm.terminal_quote_asset_reserve == market.amm.quote_asset_reserve, + market.amm.terminal_quote_asset_reserve() == market.amm.quote_asset_reserve(), ErrorCode::InvalidAmmDetected, "market {} terminal_quote_asset_reserve out of wack {}!={}", market.market_index, - market.amm.terminal_quote_asset_reserve, - market.amm.quote_asset_reserve + market.amm.terminal_quote_asset_reserve(), + market.amm.quote_asset_reserve() )?; } @@ -224,17 +224,17 @@ pub fn validate_perp_market(market: &PerpMarket) -> DriftResult { pub fn validate_amm_account_for_fill(amm: &AMM, direction: PositionDirection) -> DriftResult { if direction == PositionDirection::Long { validate!( - amm.base_asset_reserve >= amm.min_base_asset_reserve, + amm.base_asset_reserve() >= amm.min_base_asset_reserve(), ErrorCode::InvalidAmmForFillDetected, "Market baa below min_base_asset_reserve: {} < {}", - amm.base_asset_reserve, - amm.min_base_asset_reserve, + amm.base_asset_reserve(), + amm.min_base_asset_reserve(), )?; } if direction == PositionDirection::Short { validate!( - amm.base_asset_reserve <= amm.max_base_asset_reserve, + amm.base_asset_reserve() <= amm.max_base_asset_reserve(), ErrorCode::InvalidAmmForFillDetected, "Market baa above max_base_asset_reserve" )?; diff --git a/programs/drift/src/validation/sig_verification.rs b/programs/drift/src/validation/sig_verification.rs index c2b6d79be9..6ce2d6d4ca 100644 --- a/programs/drift/src/validation/sig_verification.rs +++ b/programs/drift/src/validation/sig_verification.rs @@ -3,7 +3,7 @@ use crate::state::order_params::{ OrderParams, SignedMsgOrderParamsDelegateMessage, SignedMsgOrderParamsMessage, SignedMsgTriggerOrderParams, }; -use anchor_lang::prelude::*; +use anchor_lang::prelude::{borsh::BorshDeserialize, *}; use bytemuck::try_cast_slice; use bytemuck::{Pod, Zeroable}; use byteorder::ByteOrder; diff --git a/programs/openbook_v2/src/lib.rs b/programs/openbook_v2/src/lib.rs index d6ea487c61..f16103f8f5 100644 --- a/programs/openbook_v2/src/lib.rs +++ b/programs/openbook_v2/src/lib.rs @@ -1,4 +1,5 @@ #![allow(clippy::too_many_arguments)] +#![allow(unexpected_cfgs)] use anchor_lang::prelude::{ borsh::{BorshDeserialize, BorshSerialize}, diff --git a/programs/pyth/src/lib.rs b/programs/pyth/src/lib.rs index 199249ce04..bf76a45ae4 100644 --- a/programs/pyth/src/lib.rs +++ b/programs/pyth/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(unexpected_cfgs)] use anchor_lang::prelude::*; pub mod pc; use pc::Price; diff --git a/programs/switchboard-on-demand/src/lib.rs b/programs/switchboard-on-demand/src/lib.rs index a251ad5e27..f651bf670b 100644 --- a/programs/switchboard-on-demand/src/lib.rs +++ b/programs/switchboard-on-demand/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] + use anchor_lang::declare_id; use anchor_lang::prelude::*; use anchor_lang::program; @@ -25,28 +27,28 @@ pub struct CompactResult { #[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable)] pub struct CurrentResult { /// The median value of the submissions needed for quorum size - pub value: i128, + value: [u8; 16], /// The standard deviation of the submissions needed for quorum size - pub std_dev: i128, + std_dev: [u8; 16], /// The mean of the submissions needed for quorum size - pub mean: i128, + mean: [u8; 16], /// The range of the submissions needed for quorum size - pub range: i128, + range: [u8; 16], /// The minimum value of the submissions needed for quorum size - pub min_value: i128, + min_value: [u8; 16], /// The maximum value of the submissions needed for quorum size - pub max_value: i128, + max_value: [u8; 16], /// The number of samples used to calculate this result - pub num_samples: u8, + num_samples: u8, /// The index of the submission that was used to calculate this result - pub submission_idx: u8, - pub padding1: [u8; 6], + submission_idx: u8, + padding1: [u8; 6], /// The slot at which this value was signed. - pub slot: u64, + slot: u64, /// The slot at which the first considered submission was made - pub min_slot: u64, + min_slot: u64, /// The slot at which the last considered submission was made - pub max_slot: u64, + max_slot: u64, } impl CurrentResult { /// The median value of the submissions needed for quorum size @@ -54,7 +56,7 @@ impl CurrentResult { if self.slot == 0 { return None; } - Some(self.value) + Some(i128::from_le_bytes(self.value)) } /// The standard deviation of the submissions needed for quorum size @@ -62,7 +64,7 @@ impl CurrentResult { if self.slot == 0 { return None; } - Some(self.std_dev) + Some(i128::from_le_bytes(self.std_dev)) } /// The mean of the submissions needed for quorum size @@ -70,7 +72,7 @@ impl CurrentResult { if self.slot == 0 { return None; } - Some(self.mean) + Some(i128::from_le_bytes(self.mean)) } /// The range of the submissions needed for quorum size @@ -78,7 +80,7 @@ impl CurrentResult { if self.slot == 0 { return None; } - Some(self.range) + Some(i128::from_le_bytes(self.range)) } /// The minimum value of the submissions needed for quorum size @@ -86,7 +88,7 @@ impl CurrentResult { if self.slot == 0 { return None; } - Some(self.min_value) + Some(i128::from_le_bytes(self.min_value)) } /// The maximum value of the submissions needed for quorum size @@ -94,7 +96,7 @@ impl CurrentResult { if self.slot == 0 { return None; } - Some(self.max_value) + Some(i128::from_le_bytes(self.max_value)) } pub fn result_slot(&self) -> Option { @@ -129,7 +131,7 @@ pub struct OracleSubmission { /// The slot at which this value was landed on chain. pub landed_at: u64, /// The value that was submitted. - pub value: i128, + value: [u8; 16], } impl OracleSubmission { @@ -138,7 +140,7 @@ impl OracleSubmission { } pub fn value(&self) -> i128 { - self.value + i128::from_le_bytes(self.value) } } diff --git a/programs/switchboard/src/lib.rs b/programs/switchboard/src/lib.rs index f95c5969fe..7fc8682659 100644 --- a/programs/switchboard/src/lib.rs +++ b/programs/switchboard/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] + use anchor_lang::prelude::*; declare_id!("SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f"); diff --git a/programs/token_faucet/src/lib.rs b/programs/token_faucet/src/lib.rs index bd873ae03a..e3ade3135f 100644 --- a/programs/token_faucet/src/lib.rs +++ b/programs/token_faucet/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(unexpected_cfgs)] + use anchor_lang::prelude::*; use anchor_spl::token::{self, Mint, Token, TokenAccount}; From cb6d1d1e85ddd6b43aeb68f7d723dfc2bafd974f Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Wed, 26 Nov 2025 11:28:01 +0800 Subject: [PATCH 11/25] wip --- Anchor.toml | 6 +- Cargo.lock | 110 +++++++++++++++++++++++++++++-- programs/drift/Cargo.toml | 6 +- programs/token_faucet/Cargo.toml | 8 +-- 4 files changed, 118 insertions(+), 12 deletions(-) diff --git a/Anchor.toml b/Anchor.toml index dbaa023761..1cc60b748d 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -2,6 +2,10 @@ cluster = "localnet" wallet = "~/.config/solana/id.json" +[toolchain] +solana_version = "2.3.0" +anchor_version = "0.32.1" + [workspace] exclude = ["programs/openbook_v2"] @@ -25,4 +29,4 @@ filename = "./deps/configs/usdc.json" [[test.validator.account]] address = "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL" -filename = "./deps/configs/pyth_lazer_storage.json" \ No newline at end of file +filename = "./deps/configs/pyth_lazer_storage.json" diff --git a/Cargo.lock b/Cargo.lock index 7ead8cd2c2..0c17276071 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,6 +49,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + [[package]] name = "alloc-traits" version = "0.1.1" @@ -181,6 +190,7 @@ dependencies = [ "anchor-derive-accounts", "anchor-derive-serde", "anchor-derive-space", + "anchor-lang-idl", "base64 0.21.7", "bincode", "borsh 0.10.4", @@ -217,6 +227,7 @@ dependencies = [ "anchor-lang-idl-spec", "anyhow", "heck", + "regex", "serde", "serde_json", "sha2 0.10.9", @@ -255,6 +266,7 @@ checksum = "b93b69aa7d099b59378433f6d7e20e1008fc10c69e48b220270e5b3f2ec4c8be" dependencies = [ "anyhow", "bs58 0.5.1", + "cargo_toml", "heck", "proc-macro2", "quote", @@ -525,6 +537,16 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +[[package]] +name = "cargo_toml" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a98356df42a2eb1bd8f1793ae4ee4de48e384dd974ce5eac8eee802edb7492be" +dependencies = [ + "serde", + "toml 0.8.23", +] + [[package]] name = "cc" version = "1.2.44" @@ -711,6 +733,7 @@ dependencies = [ "num-traits", "openbook-v2-light", "phoenix-v1", + "proc-macro2", "pyth", "pyth-client", "pyth-lazer-solana-contract", @@ -728,7 +751,7 @@ dependencies = [ [[package]] name = "drift-macros" version = "0.1.0" -source = "git+https://github.com/drift-labs/drift-macros?rev=92192a1#92192a1efdfa0ddef3ae06e20e24462ea3bbdc0f" +source = "git+https://github.com/drift-labs/drift-macros?rev=f48c4c77#f48c4c77c8bc60d204458a414d3f1e9478444c39" dependencies = [ "quote", "static_assertions", @@ -1342,7 +1365,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" dependencies = [ - "toml", + "toml 0.5.11", ] [[package]] @@ -1351,7 +1374,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" dependencies = [ - "toml_edit", + "toml_edit 0.23.7", ] [[package]] @@ -1559,6 +1582,35 @@ dependencies = [ "bitflags", ] +[[package]] +name = "regex" +version = "1.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" + [[package]] name = "rend" version = "0.4.2" @@ -1711,6 +1763,15 @@ dependencies = [ "serde_core", ] +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + [[package]] name = "serum_dex" version = "0.5.6" @@ -3253,6 +3314,27 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime 0.6.11", + "toml_edit 0.22.27", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + [[package]] name = "toml_datetime" version = "0.7.3" @@ -3262,6 +3344,20 @@ dependencies = [ "serde_core", ] +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime 0.6.11", + "toml_write", + "winnow", +] + [[package]] name = "toml_edit" version = "0.23.7" @@ -3269,7 +3365,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ "indexmap", - "toml_datetime", + "toml_datetime 0.7.3", "toml_parser", "winnow", ] @@ -3283,6 +3379,12 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + [[package]] name = "typenum" version = "1.19.0" diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index 71df9dd4e5..863a71798d 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -18,9 +18,8 @@ default=["mainnet-beta", "no-entrypoint"] drift-rs=[] [dependencies] -anchor-lang = "0.32.1" +anchor-lang = { version = "0.32.1", features = ["idl-build"] } anchor-spl = { version = "0.32.1", features = [] } -# pin to highest version anchor crate allows solana-program = "=2.2.1" pyth-client = "0.2.2" pyth-lazer-solana-contract = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master", features = ["no-entrypoint"]} @@ -39,11 +38,12 @@ enumflags2 = "0.6.4" phoenix-v1 = { git = "https://github.com/jordy25519/phoenix-v1", branch = "master", features = ["no-entrypoint"] } solana-security-txt = "1.1.0" static_assertions = "1.1.0" -drift-macros = { git = "https://github.com/drift-labs/drift-macros", rev = "92192a1" } +drift-macros = { git = "https://github.com/drift-labs/drift-macros", rev = "f48c4c77" } switchboard = { path = "../switchboard", features = ["no-entrypoint"] } openbook-v2-light = { path = "../openbook_v2", features = ["no-entrypoint"] } switchboard-on-demand = { path = "../switchboard-on-demand", features = ["no-entrypoint"] } byteorder = "1.4.3" +proc-macro2 = { version = "1.0.103", features = ["span-locations"] } [dev-dependencies] bytes = "1.2.0" diff --git a/programs/token_faucet/Cargo.toml b/programs/token_faucet/Cargo.toml index 8696f9482e..73289d9af9 100644 --- a/programs/token_faucet/Cargo.toml +++ b/programs/token_faucet/Cargo.toml @@ -2,7 +2,7 @@ name = "token-faucet" version = "0.1.0" description = "Created with Anchor" -edition = "2018" +edition = "2021" [lib] crate-type = ["cdylib", "lib"] @@ -13,8 +13,8 @@ no-entrypoint = [] cpi = ["no-entrypoint"] mainnet-beta=[] anchor-test= [] - [dependencies] -anchor-lang = "0.32.1" -anchor-spl = "0.32.1" + +anchor-lang = { version = "0.32.1", features = ["idl-build"] } +anchor-spl = { version = "0.32.1", features = [] } bytemuck = { version = "1.4.0" } \ No newline at end of file From 43d025d2fd4db97dc05dcbb2f2dce8600c4b1010 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Tue, 2 Dec 2025 14:40:17 +0800 Subject: [PATCH 12/25] anchor build idl finally --- Cargo.lock | 5 --- programs/drift/Cargo.toml | 30 +++++++++------ programs/drift/src/controller/position.rs | 7 +--- programs/drift/src/instructions/admin.rs | 21 +++++----- programs/drift/src/instructions/if_staker.rs | 1 - programs/drift/src/instructions/keeper.rs | 4 +- programs/drift/src/instructions/lp_admin.rs | 38 +++++++++---------- programs/drift/src/instructions/lp_pool.rs | 22 +++++------ .../src/instructions/pyth_pull_oracle.rs | 4 +- programs/drift/src/instructions/user.rs | 33 +++++++--------- programs/drift/src/lib.rs | 2 +- programs/drift/src/math/bn.rs | 9 +++-- programs/drift/src/math/oracle.rs | 9 +++-- programs/drift/src/state/amm_cache.rs | 7 +++- programs/drift/src/state/events.rs | 21 +++++----- programs/drift/src/state/order_params.rs | 9 ++--- programs/drift/src/state/perp_market.rs | 13 +++---- programs/drift/src/state/revenue_share.rs | 4 +- programs/drift/src/state/settle_pnl_mode.rs | 7 +++- programs/drift/src/state/signed_msg_user.rs | 13 ++++--- .../drift/src/state/signed_msg_user/tests.rs | 9 +++-- programs/drift/src/state/spot_market.rs | 13 +++---- programs/drift/src/state/user.rs | 24 ++++++------ .../drift/src/validation/sig_verification.rs | 2 +- programs/openbook_v2/Cargo.toml | 8 ++-- programs/openbook_v2/src/account.rs | 15 ++++---- programs/openbook_v2/src/lib.rs | 5 +-- programs/pyth/Cargo.toml | 5 ++- programs/switchboard-on-demand/Cargo.toml | 3 ++ programs/switchboard-on-demand/src/lib.rs | 6 +-- programs/token_faucet/Cargo.toml | 16 +++++--- 31 files changed, 183 insertions(+), 182 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c17276071..48e06222a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -722,7 +722,6 @@ dependencies = [ "anchor-spl", "arrayref", "base64 0.13.1", - "borsh 0.10.4", "bytemuck", "byteorder", "bytes", @@ -1423,7 +1422,6 @@ checksum = "44de48029c54ec1ca570786b5baeb906b0fc2409c8e0145585e287ee7a526c72" [[package]] name = "pyth-lazer-protocol" version = "0.1.2" -source = "git+https://github.com/jordy25519/pyth-crosschain?branch=master#688cc38cdcd6976d72db7a63bd75da73d8248804" dependencies = [ "anyhow", "byteorder", @@ -1436,7 +1434,6 @@ dependencies = [ [[package]] name = "pyth-lazer-solana-contract" version = "0.2.0" -source = "git+https://github.com/jordy25519/pyth-crosschain?branch=master#688cc38cdcd6976d72db7a63bd75da73d8248804" dependencies = [ "anchor-lang", "bytemuck", @@ -1449,7 +1446,6 @@ dependencies = [ [[package]] name = "pyth-solana-receiver-sdk" version = "0.3.0" -source = "git+https://github.com/jordy25519/pyth-crosschain?branch=master#688cc38cdcd6976d72db7a63bd75da73d8248804" dependencies = [ "anchor-lang", "hex", @@ -1460,7 +1456,6 @@ dependencies = [ [[package]] name = "pythnet-sdk" version = "2.1.0" -source = "git+https://github.com/jordy25519/pyth-crosschain?branch=master#688cc38cdcd6976d72db7a63bd75da73d8248804" dependencies = [ "anchor-lang", "bincode", diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index 863a71798d..57862c3779 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -12,21 +12,29 @@ path = "src/lib.rs" [features] no-entrypoint = [] cpi = ["no-entrypoint"] -mainnet-beta=[] -anchor-test= [] -default=["mainnet-beta", "no-entrypoint"] -drift-rs=[] +mainnet-beta =[] +anchor-test = [] +default = ["mainnet-beta", "no-entrypoint"] +drift-rs = [] +idl-build = [ + "anchor-lang/idl-build", + "anchor-spl/idl-build", + "pyth-lazer-solana-contract/idl-build", + "pythnet-sdk/idl-build", + "pythnet-sdk/idl-build", + "switchboard-on-demand/idl-build", + "openbook-v2-light/idl-build" +] [dependencies] -anchor-lang = { version = "0.32.1", features = ["idl-build"] } -anchor-spl = { version = "0.32.1", features = [] } +anchor-lang = "0.32.1" +anchor-spl = { version = "0.32.1", features = ["idl-build"] } solana-program = "=2.2.1" pyth-client = "0.2.2" -pyth-lazer-solana-contract = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master", features = ["no-entrypoint"]} -pythnet-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master"} -pyth-solana-receiver-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master"} -bytemuck = { version = "1.4.0" } -borsh = "0.10.4" +pyth-lazer-solana-contract = { path = "../../../pyth-crosschain/lazer/contracts/solana/programs/pyth-lazer-solana-contract", features = ["no-entrypoint"]} +pyth-solana-receiver-sdk = { path = "../../../pyth-crosschain/target_chains/solana/pyth_solana_receiver_sdk" } +pythnet-sdk = { path = "../../../pyth-crosschain/pythnet/pythnet_sdk" } +bytemuck = "1.4.0" hex = "0.4.3" uint = { version = "0.9.1", default-features = false } num-integer = "0.1.44" diff --git a/programs/drift/src/controller/position.rs b/programs/drift/src/controller/position.rs index b6debc088e..47ec779d64 100644 --- a/programs/drift/src/controller/position.rs +++ b/programs/drift/src/controller/position.rs @@ -1,8 +1,5 @@ use crate::msg; -use anchor_lang::prelude::{ - borsh::{BorshDeserialize, BorshSerialize}, - *, -}; +use anchor_lang::prelude::*; use crate::controller; use crate::controller::amm::SwapDirection; @@ -26,7 +23,7 @@ use crate::validate; #[cfg(test)] mod tests; -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum PositionDirection { #[default] Long, diff --git a/programs/drift/src/instructions/admin.rs b/programs/drift/src/instructions/admin.rs index 61d0e99e89..53d5e7f772 100644 --- a/programs/drift/src/instructions/admin.rs +++ b/programs/drift/src/instructions/admin.rs @@ -1,5 +1,10 @@ use crate::{msg, FeatureBitFlags}; -use anchor_lang::prelude::{borsh::BorshDeserialize, *}; +use anchor_lang::prelude::*; +use anchor_spl::token_2022::spl_token_2022::extension::transfer_hook::TransferHook; +use anchor_spl::token_2022::spl_token_2022::extension::{ + BaseStateWithExtensions, StateWithExtensions, +}; +use anchor_spl::token_2022::spl_token_2022::state::Mint as MintInner; use anchor_spl::token_2022::Token2022; use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; use phoenix::quantities::WrapperU64; @@ -85,12 +90,6 @@ use crate::validation::spot_market::validate_borrow_rate; use crate::{load_mut, PTYH_PRICE_FEED_SEED_PREFIX}; use crate::{math, safe_decrement, safe_increment}; -use anchor_spl::token_2022::spl_token_2022::extension::transfer_hook::TransferHook; -use anchor_spl::token_2022::spl_token_2022::extension::{ - BaseStateWithExtensions, StateWithExtensions, -}; -use anchor_spl::token_2022::spl_token_2022::state::Mint as MintInner; - pub fn handle_initialize(ctx: Context) -> Result<()> { let (drift_signer, drift_signer_nonce) = Pubkey::find_program_address(&[b"drift_signer".as_ref()], ctx.program_id); @@ -5491,7 +5490,7 @@ pub struct InitializeAmmCache<'info> { pub state: Box>, #[account( init, - seeds = [AMM_POSITIONS_CACHE.as_ref()], + seeds = [AMM_POSITIONS_CACHE.as_bytes()], space = AmmCache::init_space(), bump, payer = admin @@ -5511,7 +5510,7 @@ pub struct AddMarketToAmmCache<'info> { pub state: Box>, #[account( mut, - seeds = [AMM_POSITIONS_CACHE.as_ref()], + seeds = [AMM_POSITIONS_CACHE.as_bytes()], bump, realloc = AmmCache::space(amm_cache.cache.len() + 1), realloc::payer = admin, @@ -5533,7 +5532,7 @@ pub struct DeleteAmmCache<'info> { pub state: Box>, #[account( mut, - seeds = [AMM_POSITIONS_CACHE.as_ref()], + seeds = [AMM_POSITIONS_CACHE.as_bytes()], bump, close = admin, )] @@ -5788,7 +5787,7 @@ pub struct AdminUpdatePerpMarketOracle<'info> { pub old_oracle: AccountInfo<'info>, #[account( mut, - seeds = [AMM_POSITIONS_CACHE.as_ref()], + seeds = [AMM_POSITIONS_CACHE.as_bytes()], bump = amm_cache.bump, )] pub amm_cache: Box>, diff --git a/programs/drift/src/instructions/if_staker.rs b/programs/drift/src/instructions/if_staker.rs index 2b706de701..c1dae6da3b 100644 --- a/programs/drift/src/instructions/if_staker.rs +++ b/programs/drift/src/instructions/if_staker.rs @@ -1,5 +1,4 @@ use anchor_lang::prelude::*; -use anchor_lang::Discriminator; use anchor_spl::token_interface::{TokenAccount, TokenInterface}; use crate::error::ErrorCode; diff --git a/programs/drift/src/instructions/keeper.rs b/programs/drift/src/instructions/keeper.rs index 766ec68698..2d67167fbd 100644 --- a/programs/drift/src/instructions/keeper.rs +++ b/programs/drift/src/instructions/keeper.rs @@ -3657,7 +3657,7 @@ pub struct SettleAmmPnlToLp<'info> { #[account( mut, owner = crate::ID, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), QUOTE_SPOT_MARKET_INDEX.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), QUOTE_SPOT_MARKET_INDEX.to_le_bytes().as_ref()], bump = constituent.load()?.bump, constraint = constituent.load()?.mint.eq("e_market.load()?.mint) )] @@ -3826,7 +3826,7 @@ pub struct PlaceSignedMsgTakerOrder<'info> { pub user_stats: AccountLoader<'info, UserStats>, #[account( mut, - seeds = [SIGNED_MSG_PDA_SEED.as_ref(), user.load()?.authority.as_ref()], + seeds = [SIGNED_MSG_PDA_SEED.as_bytes(), user.load()?.authority.as_ref()], bump, )] /// CHECK: checked in SignedMsgUserOrdersZeroCopy checks diff --git a/programs/drift/src/instructions/lp_admin.rs b/programs/drift/src/instructions/lp_admin.rs index 468c9a0b3e..d5b2bbcf00 100644 --- a/programs/drift/src/instructions/lp_admin.rs +++ b/programs/drift/src/instructions/lp_admin.rs @@ -18,7 +18,7 @@ use crate::state::spot_market::SpotMarket; use crate::state::state::State; use crate::validate; use crate::{controller, load_mut}; -use anchor_lang::prelude::{borsh::BorshDeserialize, *}; +use anchor_lang::prelude::*; use anchor_lang::Discriminator; use anchor_spl::associated_token::AssociatedToken; use anchor_spl::token::Token; @@ -1045,7 +1045,7 @@ pub struct InitializeLpPool<'info> { #[account( init, - seeds = [AMM_MAP_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [AMM_MAP_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, space = AmmConstituentMapping::space(0 as usize), payer = admin, @@ -1054,7 +1054,7 @@ pub struct InitializeLpPool<'info> { #[account( init, - seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, space = ConstituentTargetBase::space(0 as usize), payer = admin, @@ -1063,7 +1063,7 @@ pub struct InitializeLpPool<'info> { #[account( init, - seeds = [CONSTITUENT_CORRELATIONS_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [CONSTITUENT_CORRELATIONS_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, space = ConstituentCorrelations::space(0 as usize), payer = admin, @@ -1094,7 +1094,7 @@ pub struct InitializeConstituent<'info> { #[account( mut, - seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump = constituent_target_base.bump, realloc = ConstituentTargetBase::space(constituent_target_base.targets.len() + 1_usize), realloc::payer = admin, @@ -1104,7 +1104,7 @@ pub struct InitializeConstituent<'info> { #[account( mut, - seeds = [CONSTITUENT_CORRELATIONS_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [CONSTITUENT_CORRELATIONS_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump = constituent_correlations.bump, realloc = ConstituentCorrelations::space(constituent_target_base.targets.len() + 1_usize), realloc::payer = admin, @@ -1114,7 +1114,7 @@ pub struct InitializeConstituent<'info> { #[account( init, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), spot_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), spot_market_index.to_le_bytes().as_ref()], bump, space = Constituent::SIZE, payer = admin, @@ -1131,7 +1131,7 @@ pub struct InitializeConstituent<'info> { pub spot_market_mint: Box>, #[account( init, - seeds = [CONSTITUENT_VAULT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), spot_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_VAULT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), spot_market_index.to_le_bytes().as_ref()], bump, payer = admin, token::mint = spot_market_mint, @@ -1148,7 +1148,7 @@ pub struct UpdateConstituentParams<'info> { pub lp_pool: AccountLoader<'info, LPPool>, #[account( mut, - seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump = constituent_target_base.bump, constraint = constituent.load()?.lp_pool == lp_pool.key() )] @@ -1220,7 +1220,7 @@ pub struct AddAmmConstituentMappingData<'info> { #[account( mut, - seeds = [AMM_MAP_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [AMM_MAP_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, realloc = AmmConstituentMapping::space(amm_constituent_mapping.weights.len() + amm_constituent_mapping_data.len()), realloc::payer = admin, @@ -1229,7 +1229,7 @@ pub struct AddAmmConstituentMappingData<'info> { pub amm_constituent_mapping: Box>, #[account( mut, - seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [CONSTITUENT_TARGET_BASE_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, realloc = ConstituentTargetBase::space(constituent_target_base.targets.len() + 1_usize), realloc::payer = admin, @@ -1254,7 +1254,7 @@ pub struct UpdateAmmConstituentMappingData<'info> { #[account( mut, - seeds = [AMM_MAP_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [AMM_MAP_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, )] pub amm_constituent_mapping: Box>, @@ -1273,7 +1273,7 @@ pub struct RemoveAmmConstituentMappingData<'info> { #[account( mut, - seeds = [AMM_MAP_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [AMM_MAP_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, realloc = AmmConstituentMapping::space(amm_constituent_mapping.weights.len() - 1), realloc::payer = admin, @@ -1295,7 +1295,7 @@ pub struct UpdateConstituentCorrelation<'info> { #[account( mut, - seeds = [CONSTITUENT_CORRELATIONS_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [CONSTITUENT_CORRELATIONS_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump = constituent_correlations.bump, )] pub constituent_correlations: Box>, @@ -1354,13 +1354,13 @@ pub struct LPTakerSwap<'info> { /// Constituents #[account( mut, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), out_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), out_market_index.to_le_bytes().as_ref()], bump = out_constituent.load()?.bump, )] pub out_constituent: AccountLoader<'info, Constituent>, #[account( mut, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], bump = in_constituent.load()?.bump, )] pub in_constituent: AccountLoader<'info, Constituent>, @@ -1382,7 +1382,7 @@ pub struct UpdatePerpMarketLpPoolStatus<'info> { pub state: Box>, #[account(mut)] pub perp_market: AccountLoader<'info, PerpMarket>, - #[account(mut, seeds = [AMM_POSITIONS_CACHE.as_ref()], + #[account(mut, seeds = [AMM_POSITIONS_CACHE.as_bytes()], bump = amm_cache.bump,)] pub amm_cache: Box>, } @@ -1397,7 +1397,7 @@ pub struct UpdateInitialAmmCacheInfo<'info> { pub admin: Signer<'info>, #[account( mut, - seeds = [AMM_POSITIONS_CACHE.as_ref()], + seeds = [AMM_POSITIONS_CACHE.as_bytes()], bump = amm_cache.bump, )] pub amm_cache: Box>, @@ -1413,7 +1413,7 @@ pub struct ResetAmmCache<'info> { pub state: Box>, #[account( mut, - seeds = [AMM_POSITIONS_CACHE.as_ref()], + seeds = [AMM_POSITIONS_CACHE.as_bytes()], bump = amm_cache.bump, realloc = AmmCache::space(state.number_of_markets as usize), realloc::payer = admin, diff --git a/programs/drift/src/instructions/lp_pool.rs b/programs/drift/src/instructions/lp_pool.rs index 287946ee0e..7f0d8151b6 100644 --- a/programs/drift/src/instructions/lp_pool.rs +++ b/programs/drift/src/instructions/lp_pool.rs @@ -1887,14 +1887,14 @@ pub struct LPPoolSwap<'info> { #[account( mut, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], bump=in_constituent.load()?.bump, constraint = in_constituent.load()?.mint.eq(&constituent_in_token_account.mint) )] pub in_constituent: AccountLoader<'info, Constituent>, #[account( mut, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), out_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), out_market_index.to_le_bytes().as_ref()], bump=out_constituent.load()?.bump, constraint = out_constituent.load()?.mint.eq(&constituent_out_token_account.mint) )] @@ -1944,14 +1944,14 @@ pub struct ViewLPPoolSwapFees<'info> { #[account( mut, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], bump=in_constituent.load()?.bump, constraint = in_constituent.load()?.mint.eq(&constituent_in_token_account.mint) )] pub in_constituent: AccountLoader<'info, Constituent>, #[account( mut, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), out_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), out_market_index.to_le_bytes().as_ref()], bump=out_constituent.load()?.bump, constraint = out_constituent.load()?.mint.eq(&constituent_out_token_account.mint) )] @@ -1975,7 +1975,7 @@ pub struct LPPoolAddLiquidity<'info> { pub in_market_mint: Box>, #[account( mut, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], bump, constraint = in_constituent.load()?.mint.eq(&constituent_in_token_account.mint) @@ -2011,7 +2011,7 @@ pub struct LPPoolAddLiquidity<'info> { #[account( mut, - seeds = [LP_POOL_TOKEN_VAULT_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [LP_POOL_TOKEN_VAULT_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, )] pub lp_pool_token_vault: Box>, @@ -2029,7 +2029,7 @@ pub struct ViewLPPoolAddLiquidityFees<'info> { pub authority: Signer<'info>, pub in_market_mint: Box>, #[account( - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], bump, )] pub in_constituent: AccountLoader<'info, Constituent>, @@ -2059,7 +2059,7 @@ pub struct LPPoolRemoveLiquidity<'info> { pub out_market_mint: Box>, #[account( mut, - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), out_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), out_market_index.to_le_bytes().as_ref()], bump, constraint = out_constituent.load()?.mint.eq(&constituent_out_token_account.mint) @@ -2099,7 +2099,7 @@ pub struct LPPoolRemoveLiquidity<'info> { #[account( mut, - seeds = [LP_POOL_TOKEN_VAULT_PDA_SEED.as_ref(), lp_pool.key().as_ref()], + seeds = [LP_POOL_TOKEN_VAULT_PDA_SEED.as_bytes(), lp_pool.key().as_ref()], bump, )] pub lp_pool_token_vault: Box>, @@ -2107,7 +2107,7 @@ pub struct LPPoolRemoveLiquidity<'info> { pub token_program: Interface<'info, TokenInterface>, #[account( - seeds = [AMM_POSITIONS_CACHE.as_ref()], + seeds = [AMM_POSITIONS_CACHE.as_bytes()], bump, )] /// CHECK: checked in AmmCacheZeroCopy checks @@ -2124,7 +2124,7 @@ pub struct ViewLPPoolRemoveLiquidityFees<'info> { pub authority: Signer<'info>, pub out_market_mint: Box>, #[account( - seeds = [CONSTITUENT_PDA_SEED.as_ref(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], + seeds = [CONSTITUENT_PDA_SEED.as_bytes(), lp_pool.key().as_ref(), in_market_index.to_le_bytes().as_ref()], bump, )] pub out_constituent: AccountLoader<'info, Constituent>, diff --git a/programs/drift/src/instructions/pyth_pull_oracle.rs b/programs/drift/src/instructions/pyth_pull_oracle.rs index bc1f3a09ed..c3de044e2d 100644 --- a/programs/drift/src/instructions/pyth_pull_oracle.rs +++ b/programs/drift/src/instructions/pyth_pull_oracle.rs @@ -209,9 +209,7 @@ pub fn get_timestamp_from_price_feed_account(price_feed_account: &AccountInfo) - } } -pub fn get_timestamp_from_price_update_message( - update_message: &PrefixedVec, -) -> Result { +pub fn get_timestamp_from_price_update_message(update_message: &PrefixedVec) -> Result { let message = from_slice::(update_message.as_ref()) .map_err(|_| ErrorCode::OracleDeserializeMessageFailed)?; let next_timestamp = match message { diff --git a/programs/drift/src/instructions/user.rs b/programs/drift/src/instructions/user.rs index 195e168340..d69fe4c183 100644 --- a/programs/drift/src/instructions/user.rs +++ b/programs/drift/src/instructions/user.rs @@ -1,14 +1,7 @@ use std::convert::TryFrom; use std::ops::DerefMut; -use anchor_lang::{ - prelude::{ - borsh::{BorshDeserialize, BorshSerialize}, - *, - }, - solana_program::sysvar::instructions, - Discriminator, -}; +use anchor_lang::{prelude::*, solana_program::sysvar::instructions, Discriminator}; use anchor_spl::{ associated_token::AssociatedToken, token::Token, @@ -3720,7 +3713,7 @@ pub fn handle_begin_swap<'c: 'info, 'info>( Ok(()) } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] pub enum SwapReduceOnly { In, Out, @@ -4172,7 +4165,7 @@ pub struct InitializeUserStats<'info> { pub struct InitializeSignedMsgUserOrders<'info> { #[account( init, - seeds = [SIGNED_MSG_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [SIGNED_MSG_PDA_SEED.as_bytes(), authority.key().as_ref()], space = SignedMsgUserOrders::space(num_orders as usize), bump, payer = payer @@ -4191,7 +4184,7 @@ pub struct InitializeSignedMsgUserOrders<'info> { pub struct ResizeSignedMsgUserOrders<'info> { #[account( mut, - seeds = [SIGNED_MSG_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [SIGNED_MSG_PDA_SEED.as_bytes(), authority.key().as_ref()], bump, realloc = SignedMsgUserOrders::space(num_orders as usize), realloc::payer = payer, @@ -4213,7 +4206,7 @@ pub struct ResizeSignedMsgUserOrders<'info> { #[instruction(delegates: Vec)] pub struct InitializeSignedMsgWsDelegates<'info> { #[account( - seeds = [SIGNED_MSG_WS_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [SIGNED_MSG_WS_PDA_SEED.as_bytes(), authority.key().as_ref()], bump, init, space = 8 + 4 + delegates.len() * 32, @@ -4231,7 +4224,7 @@ pub struct InitializeSignedMsgWsDelegates<'info> { pub struct ChangeSignedMsgWsDelegateStatus<'info> { #[account( mut, - seeds = [SIGNED_MSG_WS_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [SIGNED_MSG_WS_PDA_SEED.as_bytes(), authority.key().as_ref()], bump, realloc = SignedMsgWsDelegates::space(&signed_msg_ws_delegates, add), realloc::payer = authority, @@ -4598,7 +4591,7 @@ pub struct PlaceAndMakeSignedMsg<'info> { )] pub taker_stats: AccountLoader<'info, UserStats>, #[account( - seeds = [SIGNED_MSG_PDA_SEED.as_ref(), taker.load()?.authority.as_ref()], + seeds = [SIGNED_MSG_PDA_SEED.as_bytes(), taker.load()?.authority.as_ref()], bump, )] /// CHECK: checked in SignedMsgUserOrdersZeroCopy checks @@ -4673,7 +4666,7 @@ pub struct DeleteSignedMsgUserOrders<'info> { #[account( mut, close = authority, - seeds = [SIGNED_MSG_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [SIGNED_MSG_PDA_SEED.as_bytes(), authority.key().as_ref()], bump, )] pub signed_msg_user_orders: Box>, @@ -4784,7 +4777,7 @@ pub struct UpdateUserProtectedMakerMode<'info> { pub struct InitializeRevenueShare<'info> { #[account( init, - seeds = [REVENUE_SHARE_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [REVENUE_SHARE_PDA_SEED.as_bytes(), authority.key().as_ref()], space = RevenueShare::space(), bump, payer = payer @@ -4803,7 +4796,7 @@ pub struct InitializeRevenueShare<'info> { pub struct InitializeRevenueShareEscrow<'info> { #[account( init, - seeds = [REVENUE_SHARE_ESCROW_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [REVENUE_SHARE_ESCROW_PDA_SEED.as_bytes(), authority.key().as_ref()], space = RevenueShareEscrow::space(num_orders as usize, 1), bump, payer = payer @@ -4827,7 +4820,7 @@ pub struct InitializeRevenueShareEscrow<'info> { pub struct MigrateReferrer<'info> { #[account( mut, - seeds = [REVENUE_SHARE_ESCROW_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [REVENUE_SHARE_ESCROW_PDA_SEED.as_bytes(), authority.key().as_ref()], bump, )] pub escrow: Box>, @@ -4847,7 +4840,7 @@ pub struct MigrateReferrer<'info> { pub struct ResizeRevenueShareEscrowOrders<'info> { #[account( mut, - seeds = [REVENUE_SHARE_ESCROW_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [REVENUE_SHARE_ESCROW_PDA_SEED.as_bytes(), authority.key().as_ref()], bump, realloc = RevenueShareEscrow::space(num_orders as usize, escrow.approved_builders.len()), realloc::payer = payer, @@ -4867,7 +4860,7 @@ pub struct ResizeRevenueShareEscrowOrders<'info> { pub struct ChangeApprovedBuilder<'info> { #[account( mut, - seeds = [REVENUE_SHARE_ESCROW_PDA_SEED.as_ref(), authority.key().as_ref()], + seeds = [REVENUE_SHARE_ESCROW_PDA_SEED.as_bytes(), authority.key().as_ref()], bump, // revoking a builder does not remove the slot to avoid unintended reuse realloc = RevenueShareEscrow::space(escrow.orders.len(), if add { escrow.approved_builders.len() + 1 } else { escrow.approved_builders.len() }), diff --git a/programs/drift/src/lib.rs b/programs/drift/src/lib.rs index d134c3b330..1344e5b67c 100644 --- a/programs/drift/src/lib.rs +++ b/programs/drift/src/lib.rs @@ -3,7 +3,7 @@ #![allow(clippy::bool_assert_comparison)] #![allow(clippy::comparison_chain)] -use anchor_lang::prelude::{borsh::BorshDeserialize, *}; +use anchor_lang::prelude::*; use instructions::*; #[cfg(test)] diff --git a/programs/drift/src/math/bn.rs b/programs/drift/src/math/bn.rs index 09ab7b117f..3fcbbe11be 100644 --- a/programs/drift/src/math/bn.rs +++ b/programs/drift/src/math/bn.rs @@ -14,7 +14,10 @@ use crate::error::DriftResult; pub mod compat { #![allow(non_camel_case_types)] - use anchor_lang::prelude::borsh::{BorshDeserialize, BorshSerialize}; + use anchor_lang::prelude::{ + borsh::{self}, + AnchorDeserialize, AnchorSerialize, + }; use bytemuck::{Pod, Zeroable}; use std::{ cmp::Ordering, @@ -25,7 +28,7 @@ pub mod compat { use crate::{error::DriftResult, math::casting::Cast}; /// `u128` with legacy bit layout - #[derive(Copy, Clone, PartialEq, Eq, Debug, Default, BorshSerialize, BorshDeserialize)] + #[derive(Copy, Clone, PartialEq, Eq, Debug, Default, AnchorSerialize, AnchorDeserialize)] pub struct u128([u8; 16]); impl std::fmt::Display for self::u128 { @@ -152,7 +155,7 @@ pub mod compat { } /// `i128` with legacy bit layout - #[derive(Copy, Clone, PartialEq, Eq, Debug, Default, BorshSerialize, BorshDeserialize)] + #[derive(Copy, Clone, PartialEq, Eq, Debug, Default, AnchorSerialize, AnchorDeserialize)] pub struct i128([u8; 16]); impl std::fmt::Display for self::i128 { diff --git a/programs/drift/src/math/oracle.rs b/programs/drift/src/math/oracle.rs index 8ec3555a02..fc97606f96 100644 --- a/programs/drift/src/math/oracle.rs +++ b/programs/drift/src/math/oracle.rs @@ -1,4 +1,7 @@ -use anchor_lang::prelude::borsh::{BorshDeserialize, BorshSerialize}; +use anchor_lang::prelude::{ + borsh::{self}, + AnchorDeserialize, AnchorSerialize, +}; use crate::error::{DriftResult, ErrorCode}; use crate::math::amm; @@ -18,7 +21,7 @@ use std::fmt; mod tests; // ordered by "severity" -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum OracleValidity { NonPositive, TooVolatile, @@ -125,7 +128,7 @@ impl From for u8 { } } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] pub enum DriftAction { UpdateFunding, SettlePnl, diff --git a/programs/drift/src/state/amm_cache.rs b/programs/drift/src/state/amm_cache.rs index 06003edff1..6b98b63b48 100644 --- a/programs/drift/src/state/amm_cache.rs +++ b/programs/drift/src/state/amm_cache.rs @@ -16,7 +16,10 @@ use crate::state::zero_copy::{AccountZeroCopy, AccountZeroCopyMut}; use crate::OracleSource; use crate::{impl_zero_copy_loader, OracleGuardRails}; -use anchor_lang::prelude::*; +use anchor_lang::prelude::{ + borsh::{self, BorshDeserialize, BorshSerialize}, + *, +}; use super::user::MarketType; @@ -32,7 +35,7 @@ pub struct AmmCache { } #[zero_copy] -#[derive(AnchorSerialize, AnchorDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Debug)] #[repr(C)] pub struct CacheInfo { pub oracle: Pubkey, diff --git a/programs/drift/src/state/events.rs b/programs/drift/src/state/events.rs index 1c5438362c..57be0eea50 100644 --- a/programs/drift/src/state/events.rs +++ b/programs/drift/src/state/events.rs @@ -1,7 +1,4 @@ -use anchor_lang::prelude::{ - borsh::{BorshDeserialize, BorshSerialize}, - *, -}; +use anchor_lang::prelude::*; use crate::controller::position::PositionDirection; use crate::error::{DriftResult, ErrorCode::InvalidOrder}; @@ -55,7 +52,7 @@ pub struct DepositRecord { pub transfer_user: Option, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Default)] pub enum DepositExplanation { #[default] None, @@ -85,7 +82,7 @@ pub struct SpotInterestRecord { pub max_borrow_rate: u32, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Default)] pub enum DepositDirection { #[default] Deposit, @@ -355,7 +352,7 @@ pub fn get_order_action_record( }) } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Default)] pub enum OrderAction { #[default] Place, @@ -365,7 +362,7 @@ pub enum OrderAction { Expire, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq)] pub enum OrderActionExplanation { None, InsufficientFreeCollateral, @@ -408,7 +405,7 @@ pub struct LPRecord { pub pnl: i64, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Default)] pub enum LPAction { #[default] AddLiquidity, @@ -442,7 +439,7 @@ pub struct LiquidationRecord { pub spot_bankruptcy: SpotBankruptcyRecord, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Default)] pub enum LiquidationType { #[default] LiquidatePerp, @@ -535,7 +532,7 @@ pub struct SettlePnlRecord { pub explanation: SettlePnlExplanation, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Default)] pub enum SettlePnlExplanation { #[default] None, @@ -582,7 +579,7 @@ pub struct InsuranceFundStakeRecord { pub total_if_shares_after: u128, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Default)] pub enum StakeAction { #[default] Stake, diff --git a/programs/drift/src/state/order_params.rs b/programs/drift/src/state/order_params.rs index 5cb58a08bc..f94140cf0c 100644 --- a/programs/drift/src/state/order_params.rs +++ b/programs/drift/src/state/order_params.rs @@ -10,10 +10,7 @@ use crate::math::safe_unwrap::SafeUnwrap; use crate::state::events::OrderActionExplanation; use crate::state::perp_market::{ContractTier, PerpMarket}; use crate::state::user::{MarketType, OrderTriggerCondition, OrderType}; -use anchor_lang::prelude::{ - borsh::{BorshDeserialize, BorshSerialize}, - *, -}; +use anchor_lang::prelude::*; use std::ops::Div; #[cfg(test)] @@ -40,7 +37,7 @@ pub struct OrderParams { pub auction_end_price: Option, // specified in price or oracle_price_offset } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] pub enum OrderParamsBitFlag { ImmediateOrCancel = 0b00000001, UpdateHighLeverageMode = 0b00000010, @@ -919,7 +916,7 @@ fn get_auction_duration( .clamp(1, 180) as u8) // 180 slots max } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum PostOnlyParam { #[default] None, diff --git a/programs/drift/src/state/perp_market.rs b/programs/drift/src/state/perp_market.rs index 9189157d74..6c5ec5b0cf 100644 --- a/programs/drift/src/state/perp_market.rs +++ b/programs/drift/src/state/perp_market.rs @@ -2,10 +2,7 @@ use crate::msg; use crate::state::fill_mode::FillMode; use crate::state::pyth_lazer_oracle::PythLazerOracle; use crate::state::user::{MarketType, Order}; -use anchor_lang::prelude::{ - borsh::{BorshDeserialize, BorshSerialize}, - *, -}; +use anchor_lang::prelude::*; use crate::state::state::{State, ValidityGuardRails}; use std::cmp::max; @@ -53,7 +50,7 @@ use crate::math::oracle::{ #[cfg(test)] mod tests; -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum MarketStatus { /// warm up period for initialization, fills are paused #[default] @@ -93,7 +90,7 @@ impl MarketStatus { } } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum LpStatus { /// Not considered #[default] @@ -110,7 +107,7 @@ impl LpStatus { } } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum ContractType { #[default] Perpetual, @@ -119,7 +116,7 @@ pub enum ContractType { } #[derive( - Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, PartialOrd, Ord, Default, + Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, PartialOrd, Ord, Default, )] pub enum ContractTier { /// max insurance capped at A level diff --git a/programs/drift/src/state/revenue_share.rs b/programs/drift/src/state/revenue_share.rs index f63efbf8be..56598f7cbc 100644 --- a/programs/drift/src/state/revenue_share.rs +++ b/programs/drift/src/state/revenue_share.rs @@ -2,7 +2,7 @@ use std::cell::{Ref, RefMut}; use anchor_lang::prelude::{ account, - borsh::{BorshDeserialize, BorshSerialize}, + borsh::{self, BorshDeserialize, BorshSerialize}, zero_copy, AccountInfo, AnchorDeserialize, AnchorSerialize, Discriminator, Pubkey, }; @@ -16,7 +16,7 @@ use crate::{msg, ID}; pub const REVENUE_SHARE_PDA_SEED: &str = "REV_SHARE"; pub const REVENUE_SHARE_ESCROW_PDA_SEED: &str = "REV_ESCROW"; -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum RevenueShareOrderBitFlag { #[default] Init = 0b00000000, diff --git a/programs/drift/src/state/settle_pnl_mode.rs b/programs/drift/src/state/settle_pnl_mode.rs index eafa1837b9..e5d4375034 100644 --- a/programs/drift/src/state/settle_pnl_mode.rs +++ b/programs/drift/src/state/settle_pnl_mode.rs @@ -1,12 +1,15 @@ use crate::error::{DriftResult, ErrorCode}; use crate::msg; -use anchor_lang::prelude::{borsh::BorshDeserialize, borsh::BorshSerialize}; +use anchor_lang::prelude::{ + borsh::{self}, + AnchorDeserialize, AnchorSerialize, +}; use std::panic::Location; #[cfg(test)] mod tests; -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] pub enum SettlePnlMode { MustSettle, TrySettle, diff --git a/programs/drift/src/state/signed_msg_user.rs b/programs/drift/src/state/signed_msg_user.rs index f8c922faff..5abdc5c327 100644 --- a/programs/drift/src/state/signed_msg_user.rs +++ b/programs/drift/src/state/signed_msg_user.rs @@ -4,11 +4,14 @@ use crate::error::{DriftResult, ErrorCode}; use crate::math::safe_unwrap::SafeUnwrap; use crate::msg; use crate::{validate, ID}; -use anchor_lang::prelude::Pubkey; -use anchor_lang::*; -use anchor_lang::{account, zero_copy}; -use borsh::{BorshDeserialize, BorshSerialize}; -use prelude::AccountInfo; +use anchor_lang::{ + account, + prelude::{ + borsh::{self, BorshDeserialize, BorshSerialize}, + AccountInfo, AnchorDeserialize, AnchorSerialize, Discriminator, Pubkey, + }, + zero_copy, +}; use crate::state::traits::Size; diff --git a/programs/drift/src/state/signed_msg_user/tests.rs b/programs/drift/src/state/signed_msg_user/tests.rs index 96af65b096..985a6dec41 100644 --- a/programs/drift/src/state/signed_msg_user/tests.rs +++ b/programs/drift/src/state/signed_msg_user/tests.rs @@ -2,8 +2,7 @@ mod signed_msg_order_id_eviction { use std::cell::RefCell; - use anchor_lang::prelude::Pubkey; - use borsh::BorshSerialize; + use anchor_lang::prelude::{AnchorSerialize, Pubkey}; use crate::{ error::ErrorCode, @@ -142,8 +141,10 @@ mod zero_copy { use crate::test_utils::create_account_info; use crate::ID; - use anchor_lang::{prelude::Pubkey, Discriminator}; - use borsh::BorshSerialize; + use anchor_lang::{ + prelude::{AnchorSerialize, Pubkey}, + Discriminator, + }; use crate::{ error::ErrorCode, diff --git a/programs/drift/src/state/spot_market.rs b/programs/drift/src/state/spot_market.rs index e3d503d29c..e5ea34de34 100644 --- a/programs/drift/src/state/spot_market.rs +++ b/programs/drift/src/state/spot_market.rs @@ -15,10 +15,7 @@ use crate::math::margin::{ }; use crate::math::safe_math::SafeMath; use crate::math::spot_balance::{calculate_utilization, get_token_amount, get_token_value}; -use anchor_lang::prelude::{ - borsh::{BorshDeserialize, BorshSerialize}, - *, -}; +use anchor_lang::prelude::*; use anchor_spl::token::spl_token; use anchor_spl::token_2022::spl_token_2022; use drift_macros::legacy_layout; @@ -638,7 +635,7 @@ impl SpotMarket { } } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Debug, Default)] pub enum SpotBalanceType { #[default] Deposit, @@ -668,7 +665,7 @@ pub trait SpotBalance { fn update_balance_type(&mut self, balance_type: SpotBalanceType) -> DriftResult; } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum SpotFulfillmentConfigStatus { #[default] Enabled, @@ -676,7 +673,7 @@ pub enum SpotFulfillmentConfigStatus { } #[derive( - Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, PartialOrd, Ord, Default, + Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, PartialOrd, Ord, Default, )] pub enum AssetTier { /// full priviledge @@ -716,7 +713,7 @@ impl InsuranceFund { } } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] pub enum TokenProgramFlag { Token2022 = 0b00000001, TransferHook = 0b00000010, diff --git a/programs/drift/src/state/user.rs b/programs/drift/src/state/user.rs index 24aeaf0455..81d0399e16 100644 --- a/programs/drift/src/state/user.rs +++ b/programs/drift/src/state/user.rs @@ -29,7 +29,7 @@ use crate::state::traits::Size; use crate::validate; use crate::{get_then_update_id, ID}; use anchor_lang::prelude::{ - borsh::{BorshDeserialize, BorshSerialize}, + borsh::{self, BorshDeserialize, BorshSerialize}, *, }; use bytemuck::{Pod, Zeroable}; @@ -52,7 +52,7 @@ use crate::state::spot_market_map::SpotMarketMap; #[cfg(test)] mod tests; -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] pub enum UserStatus { // Active = 0 BeingLiquidated = 0b00000001, @@ -1193,7 +1193,7 @@ impl PerpPosition { #[zero_copy(unsafe)] #[repr(C)] -#[derive(AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] +#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] pub struct Order { /// The slot the order was placed pub slot: u64, @@ -1260,7 +1260,7 @@ pub struct Order { pub padding: [u8; 1], } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Debug)] pub enum AssetType { Base, Quote, @@ -1584,7 +1584,7 @@ impl Default for Order { } } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Eq, Debug)] pub enum OrderStatus { /// The order is not in use Init, @@ -1596,7 +1596,7 @@ pub enum OrderStatus { Canceled, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum OrderType { Market, #[default] @@ -1607,7 +1607,7 @@ pub enum OrderType { Oracle, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum OrderTriggerCondition { #[default] Above, @@ -1616,7 +1616,7 @@ pub enum OrderTriggerCondition { TriggeredBelow, // below condition has been triggered } -#[derive(Default, Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Default, Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] pub enum MarketType { #[default] Spot, @@ -1635,7 +1635,7 @@ impl fmt::Display for MarketType { unsafe impl Zeroable for MarketType {} unsafe impl Pod for MarketType {} -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] pub enum OrderBitFlag { SignedMessage = 0b00000001, OracleTriggerMarket = 0b00000010, @@ -1713,7 +1713,7 @@ pub struct UserStats { pub padding: [u8; 12], } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] #[repr(u8)] pub enum ReferrerStatus { IsReferrer = 0b00000001, @@ -2070,7 +2070,7 @@ impl Size for ReferrerName { const SIZE: usize = 136; } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq, Default)] pub enum MarginMode { #[default] Default, @@ -2078,7 +2078,7 @@ pub enum MarginMode { HighLeverageMaintenance, } -#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] +#[derive(Clone, Copy, AnchorSerialize, AnchorDeserialize, PartialEq, Debug, Eq)] #[repr(u8)] pub enum FuelOverflowStatus { Exists = 0b00000001, diff --git a/programs/drift/src/validation/sig_verification.rs b/programs/drift/src/validation/sig_verification.rs index 6ce2d6d4ca..c2b6d79be9 100644 --- a/programs/drift/src/validation/sig_verification.rs +++ b/programs/drift/src/validation/sig_verification.rs @@ -3,7 +3,7 @@ use crate::state::order_params::{ OrderParams, SignedMsgOrderParamsDelegateMessage, SignedMsgOrderParamsMessage, SignedMsgTriggerOrderParams, }; -use anchor_lang::prelude::{borsh::BorshDeserialize, *}; +use anchor_lang::prelude::*; use bytemuck::try_cast_slice; use bytemuck::{Pod, Zeroable}; use byteorder::ByteOrder; diff --git a/programs/openbook_v2/Cargo.toml b/programs/openbook_v2/Cargo.toml index 1191dfa6be..549662e2e2 100644 --- a/programs/openbook_v2/Cargo.toml +++ b/programs/openbook_v2/Cargo.toml @@ -15,9 +15,11 @@ no-entrypoint = [] no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] - +idl-build = [ + "anchor-lang/idl-build" +] [dependencies] -anchor-lang = { version = "0.32.1", features = ["derive"] } +anchor-lang = "0.32.1" borsh = {version = "0.10.3", features = ["const-generics", "default"]} -bytemuck = { version = "1.4.0" , features = ["derive", "min_const_generics"]} \ No newline at end of file +bytemuck = { version = "1.4.0", features = ["derive", "min_const_generics"]} \ No newline at end of file diff --git a/programs/openbook_v2/src/account.rs b/programs/openbook_v2/src/account.rs index edf6550f9b..01edb0e543 100644 --- a/programs/openbook_v2/src/account.rs +++ b/programs/openbook_v2/src/account.rs @@ -4,7 +4,7 @@ use crate::*; use bytemuck::Zeroable; #[zero_copy] -#[derive(AnchorDeserialize, AnchorSerialize, Debug)] +#[derive(AnchorDeserialize, Debug)] pub struct OracleConfig { pub conf_filter: f64, pub max_staleness_slots: i64, @@ -207,7 +207,6 @@ impl BookSide { } #[zero_copy] -#[derive(AnchorSerialize)] pub struct AnyNode { pub tag: u8, pub data: [u8; 79], @@ -221,7 +220,7 @@ pub struct OrderTreeNodes { pub padding: [u8; 3], pub bump_index: u32, pub free_list_len: u32, - pub free_list_head: NodeHandle, + pub free_list_head: u32, pub reserved: [u8; 512], pub nodes: [AnyNode; MAX_ORDERTREE_NODES], } @@ -231,7 +230,7 @@ pub type NodeHandle = u32; #[zero_copy] #[derive(Debug)] pub struct OrderTreeRoot { - pub maybe_node: NodeHandle, + pub maybe_node: u32, pub leaf_count: u32, } @@ -335,7 +334,7 @@ impl LeafNode { } #[zero_copy] -#[derive(AnchorSerialize, AnchorDeserialize, Debug, Default, PartialEq)] +#[derive(AnchorDeserialize, Debug, Default, PartialEq)] pub struct NonZeroPubkeyOption { key: Pubkey, } @@ -394,20 +393,20 @@ impl NonZeroPubkeyOption { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(AnchorDeserialize, Debug, AnchorSerialize)] pub enum Side { Bid, Ask, } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(AnchorDeserialize, Debug, AnchorSerialize)] pub enum SelfTradeBehavior { DecrementTake, CancelProvide, AbortTransaction, } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(AnchorDeserialize, Debug, AnchorSerialize)] pub enum PlaceOrderType { Limit, ImmediateOrCancel, diff --git a/programs/openbook_v2/src/lib.rs b/programs/openbook_v2/src/lib.rs index f16103f8f5..6d07ceb68b 100644 --- a/programs/openbook_v2/src/lib.rs +++ b/programs/openbook_v2/src/lib.rs @@ -1,10 +1,7 @@ #![allow(clippy::too_many_arguments)] #![allow(unexpected_cfgs)] -use anchor_lang::prelude::{ - borsh::{BorshDeserialize, BorshSerialize}, - *, -}; +use anchor_lang::prelude::*; declare_id!("opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb"); diff --git a/programs/pyth/Cargo.toml b/programs/pyth/Cargo.toml index e3ccf01864..4e0c0ab36c 100644 --- a/programs/pyth/Cargo.toml +++ b/programs/pyth/Cargo.toml @@ -15,7 +15,10 @@ cpi = ["no-entrypoint"] default = ["mainnet-beta"] mainnet-beta=[] anchor-test= [] +idl-build = [ + "anchor-lang/idl-build" +] [dependencies] anchor-lang = "0.32.1" -bytemuck = { version = "1.4.0" } +bytemuck = "1.4.0" diff --git a/programs/switchboard-on-demand/Cargo.toml b/programs/switchboard-on-demand/Cargo.toml index 02df150f4d..4e36cd251e 100644 --- a/programs/switchboard-on-demand/Cargo.toml +++ b/programs/switchboard-on-demand/Cargo.toml @@ -14,6 +14,9 @@ cpi = ["no-entrypoint"] default = ["mainnet-beta"] mainnet-beta=[] anchor-test= [] +idl-build = [ + "anchor-lang/idl-build" +] [dependencies] anchor-lang = "0.32.1" diff --git a/programs/switchboard-on-demand/src/lib.rs b/programs/switchboard-on-demand/src/lib.rs index f651bf670b..93d4712b3d 100644 --- a/programs/switchboard-on-demand/src/lib.rs +++ b/programs/switchboard-on-demand/src/lib.rs @@ -16,7 +16,7 @@ pub mod switchboard_on_demand {} pub const SB_ON_DEMAND_PRECISION: u32 = 18; #[repr(C)] -#[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable)] +#[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable, AnchorSerialize)] pub struct CompactResult { pub std_dev: f32, pub mean: f32, @@ -24,7 +24,7 @@ pub struct CompactResult { } #[repr(C)] -#[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable)] +#[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable, AnchorSerialize)] pub struct CurrentResult { /// The median value of the submissions needed for quorum size value: [u8; 16], @@ -122,7 +122,7 @@ impl CurrentResult { } #[repr(C)] -#[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable)] +#[derive(Clone, Copy, Debug, bytemuck::Pod, bytemuck::Zeroable, AnchorSerialize)] pub struct OracleSubmission { /// The public key of the oracle that submitted this value. pub oracle: Pubkey, diff --git a/programs/token_faucet/Cargo.toml b/programs/token_faucet/Cargo.toml index 73289d9af9..bf49663d0d 100644 --- a/programs/token_faucet/Cargo.toml +++ b/programs/token_faucet/Cargo.toml @@ -11,10 +11,14 @@ name = "token_faucet" [features] no-entrypoint = [] cpi = ["no-entrypoint"] -mainnet-beta=[] -anchor-test= [] -[dependencies] +mainnet-beta = [] +anchor-test = [] +idl-build = [ + "anchor-lang/idl-build", + "anchor-spl/idl-build", +] -anchor-lang = { version = "0.32.1", features = ["idl-build"] } -anchor-spl = { version = "0.32.1", features = [] } -bytemuck = { version = "1.4.0" } \ No newline at end of file +[dependencies] +anchor-lang = "0.32.1" +anchor-spl = "0.32.1" +bytemuck = "1.4.0" \ No newline at end of file From d5a8d2ef5911c02f0b2534718836df86b46090a6 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Wed, 3 Dec 2025 13:13:33 +0800 Subject: [PATCH 13/25] fix idl build --- Cargo.lock | 4 ++++ programs/drift/Cargo.toml | 12 +++++------- programs/drift/src/instructions/pyth_pull_oracle.rs | 4 +++- programs/switchboard/Cargo.toml | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index adcc60b059..4ea65af448 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1422,6 +1422,7 @@ checksum = "44de48029c54ec1ca570786b5baeb906b0fc2409c8e0145585e287ee7a526c72" [[package]] name = "pyth-lazer-protocol" version = "0.1.2" +source = "git+https://github.com/jordy25519/pyth-crosschain#e43b2765edf680a52f1649ae57024d63ef645443" dependencies = [ "anyhow", "byteorder", @@ -1434,6 +1435,7 @@ dependencies = [ [[package]] name = "pyth-lazer-solana-contract" version = "0.2.0" +source = "git+https://github.com/jordy25519/pyth-crosschain#e43b2765edf680a52f1649ae57024d63ef645443" dependencies = [ "anchor-lang", "bytemuck", @@ -1446,6 +1448,7 @@ dependencies = [ [[package]] name = "pyth-solana-receiver-sdk" version = "0.3.0" +source = "git+https://github.com/jordy25519/pyth-crosschain#e43b2765edf680a52f1649ae57024d63ef645443" dependencies = [ "anchor-lang", "hex", @@ -1456,6 +1459,7 @@ dependencies = [ [[package]] name = "pythnet-sdk" version = "2.1.0" +source = "git+https://github.com/jordy25519/pyth-crosschain#e43b2765edf680a52f1649ae57024d63ef645443" dependencies = [ "anchor-lang", "bincode", diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index 6112aee822..6b2acd066e 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -19,11 +19,9 @@ drift-rs = [] idl-build = [ "anchor-lang/idl-build", "anchor-spl/idl-build", - "pyth-lazer-solana-contract/idl-build", - "pythnet-sdk/idl-build", - "pythnet-sdk/idl-build", + "openbook-v2-light/idl-build", "switchboard-on-demand/idl-build", - "openbook-v2-light/idl-build" + "pythnet-sdk/idl-build" ] [dependencies] @@ -31,9 +29,9 @@ anchor-lang = "0.32.1" anchor-spl = { version = "0.32.1", features = ["idl-build"] } solana-program = "=2.2.1" pyth-client = "0.2.2" -pyth-lazer-solana-contract = { path = "../../../pyth-crosschain/lazer/contracts/solana/programs/pyth-lazer-solana-contract", features = ["no-entrypoint"]} -pyth-solana-receiver-sdk = { path = "../../../pyth-crosschain/target_chains/solana/pyth_solana_receiver_sdk" } -pythnet-sdk = { path = "../../../pyth-crosschain/pythnet/pythnet_sdk" } +pyth-lazer-solana-contract = { git = "https://github.com/jordy25519/pyth-crosschain", features = ["no-entrypoint"]} +pyth-solana-receiver-sdk = { git = "https://github.com/jordy25519/pyth-crosschain" } +pythnet-sdk = { git = "https://github.com/jordy25519/pyth-crosschain" } bytemuck = "1.4.0" hex = "0.4.3" uint = { version = "0.9.1", default-features = false } diff --git a/programs/drift/src/instructions/pyth_pull_oracle.rs b/programs/drift/src/instructions/pyth_pull_oracle.rs index c3de044e2d..bc1f3a09ed 100644 --- a/programs/drift/src/instructions/pyth_pull_oracle.rs +++ b/programs/drift/src/instructions/pyth_pull_oracle.rs @@ -209,7 +209,9 @@ pub fn get_timestamp_from_price_feed_account(price_feed_account: &AccountInfo) - } } -pub fn get_timestamp_from_price_update_message(update_message: &PrefixedVec) -> Result { +pub fn get_timestamp_from_price_update_message( + update_message: &PrefixedVec, +) -> Result { let message = from_slice::(update_message.as_ref()) .map_err(|_| ErrorCode::OracleDeserializeMessageFailed)?; let next_timestamp = match message { diff --git a/programs/switchboard/Cargo.toml b/programs/switchboard/Cargo.toml index e659b127b0..f49600dc00 100644 --- a/programs/switchboard/Cargo.toml +++ b/programs/switchboard/Cargo.toml @@ -14,6 +14,7 @@ cpi = ["no-entrypoint"] default = ["mainnet-beta"] mainnet-beta=[] anchor-test= [] +idl-build = ["anchor-lang/idl-build"] [dependencies] anchor-lang = "0.32.1" From 2665d59924bba7e9235903c47455cbd0ef9c544a Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Wed, 3 Dec 2025 13:16:34 +0800 Subject: [PATCH 14/25] CI: update solana version & rust version --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 105ddcd80e..1c5d08b466 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,8 +13,8 @@ defaults: env: CARGO_TERM_COLOR: always - RUST_TOOLCHAIN: 1.87.0 - SOLANA_VERSION: "1.16.27" + RUST_TOOLCHAIN: 1.91.1 + SOLANA_VERSION: 2.3.0 jobs: fmt-clippy: From 314fcb0f942a475521937b00996cbc2d568fbb0d Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Wed, 3 Dec 2025 13:48:57 +0800 Subject: [PATCH 15/25] id-build always on --- programs/drift/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index 6b2acd066e..b8bfd245ce 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -31,7 +31,7 @@ solana-program = "=2.2.1" pyth-client = "0.2.2" pyth-lazer-solana-contract = { git = "https://github.com/jordy25519/pyth-crosschain", features = ["no-entrypoint"]} pyth-solana-receiver-sdk = { git = "https://github.com/jordy25519/pyth-crosschain" } -pythnet-sdk = { git = "https://github.com/jordy25519/pyth-crosschain" } +pythnet-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", features = ["idl-build"] } bytemuck = "1.4.0" hex = "0.4.3" uint = { version = "0.9.1", default-features = false } From a09e2a0e8ea70fac3886a45153c9dd193b9a4093 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Wed, 3 Dec 2025 14:57:09 +0800 Subject: [PATCH 16/25] CI: solana install from agave repo, update actions/checkout@v4 --- .../scripts/solana-install-init.sh | 20 ++++---- .github/workflows/main.yml | 47 +++++++++---------- programs/drift/Cargo.toml | 4 +- 3 files changed, 34 insertions(+), 37 deletions(-) diff --git a/.github/actions/setup-solana/scripts/solana-install-init.sh b/.github/actions/setup-solana/scripts/solana-install-init.sh index db36dc61e2..cf2d1babf3 100755 --- a/.github/actions/setup-solana/scripts/solana-install-init.sh +++ b/.github/actions/setup-solana/scripts/solana-install-init.sh @@ -10,25 +10,25 @@ # except according to those terms. # This is just a little script that can be downloaded from the internet to -# install solana-install. It just does platform detection, downloads the installer +# install agave-install. It just does platform detection, downloads the installer # and runs it. { # this ensures the entire script is downloaded # if [ -z "$SOLANA_DOWNLOAD_ROOT" ]; then - SOLANA_DOWNLOAD_ROOT="https://github.com/solana-labs/solana/releases/download/" + SOLANA_DOWNLOAD_ROOT="https://github.com/anza-xyz/agave/releases/download/" fi -GH_LATEST_RELEASE="https://api.github.com/repos/solana-labs/solana/releases/latest" +GH_LATEST_RELEASE="https://api.github.com/repos/anza-xyz/agave/releases/latest" set -e usage() { cat 1>&2 < --pubkey + agave-install-init [FLAGS] [OPTIONS] --data_dir --pubkey FLAGS: -h, --help Prints help information @@ -81,7 +81,7 @@ main() { esac TARGET="${_cputype}-${_ostype}" - temp_dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t solana-install-init)" + temp_dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t agave-install-init)" ensure mkdir -p "$temp_dir" # Check for SOLANA_RELEASE environment variable override. Otherwise fetch @@ -101,8 +101,8 @@ main() { fi fi - download_url="$SOLANA_DOWNLOAD_ROOT/$release/solana-install-init-$TARGET" - solana_install_init="$temp_dir/solana-install-init" + download_url="$SOLANA_DOWNLOAD_ROOT/$release/agave-install-init-$TARGET" + solana_install_init="$temp_dir/agave-install-init" printf 'downloading %s installer\n' "$release" 1>&2 @@ -111,7 +111,7 @@ main() { ensure chmod u+x "$solana_install_init" if [ ! -x "$solana_install_init" ]; then printf '%s\n' "Cannot execute $solana_install_init (likely because of mounting /tmp as noexec)." 1>&2 - printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./solana-install-init." 1>&2 + printf '%s\n' "Please copy the file to a location where you can execute binaries and run ./agave-install-init." 1>&2 exit 1 fi @@ -130,7 +130,7 @@ main() { } err() { - printf 'solana-install-init: %s\n' "$1" >&2 + printf 'agave-install-init: %s\n' "$1" >&2 exit 1 } diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c5d08b466..4aa400d6bc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,13 +15,15 @@ env: CARGO_TERM_COLOR: always RUST_TOOLCHAIN: 1.91.1 SOLANA_VERSION: 2.3.0 + ANCHOR_VERSION: 0.32.1 + NODE_VERSION: "22.14.x" jobs: fmt-clippy: name: fmt & clippy runs-on: ubicloud steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Rust nightly uses: actions-rs/toolchain@v1 with: @@ -39,7 +41,7 @@ jobs: name: Unit tests runs-on: ubicloud steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: @@ -57,7 +59,7 @@ jobs: # name: Cargo audit # runs-on: ubicloud # steps: -# - uses: actions/checkout@v2 +# - uses: actions/checkout@v4 # - name: Cache cargo-audit version # uses: Swatinem/rust-cache@v1 # - name: Download cargo-audit @@ -70,11 +72,11 @@ jobs: yarn-prettier: runs-on: ubicloud steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup node uses: actions/setup-node@v2 with: - node-version: "22.14.x" + node-version: ${{ env.NODE_VERSION }} registry-url: "https://registry.npmjs.org" - name: Install yarn run: yarn @@ -85,11 +87,11 @@ jobs: yarn-lint: runs-on: ubicloud steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup node uses: actions/setup-node@v2 with: - node-version: "22.14.x" + node-version: ${{ env.NODE_VERSION }} registry-url: "https://registry.npmjs.org" - name: Install yarn run: yarn @@ -99,7 +101,7 @@ jobs: runs-on: ubicloud timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 @@ -119,18 +121,18 @@ jobs: uses: actions/cache@v4 with: path: ~/.cargo/bin/anchor - key: ${{ runner.os }}-anchor-cli-0.32.1 + key: ${{ runner.os }}-anchor-cli-${{ env.ANCHOR_VERSION }} - name: Install Anchor CLI if: steps.cache-anchor.outputs.cache-hit != 'true' run: | sudo apt install libudev-dev - cargo install --git https://github.com/coral-xyz/anchor --tag v0.32.1 anchor-cli --locked + cargo install --git https://github.com/coral-xyz/anchor --tag v${{ env.ANCHOR_VERSION }} anchor-cli --locked - name: Setup node uses: actions/setup-node@v2 with: - node-version: "22.14.x" + node-version: ${{ env.NODE_VERSION }} registry-url: "https://registry.npmjs.org" - name: Setup yarn @@ -158,12 +160,12 @@ jobs: name: Verify SDK Configs runs-on: ubicloud steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v2 with: - node-version: "22.14.x" + node-version: ${{ env.NODE_VERSION }} registry-url: 'https://registry.npmjs.org' - name: Install dependencies @@ -197,7 +199,7 @@ jobs: sdk: ${{ steps.filter.outputs.sdk }} steps: # For pull requests it's not necessary to checkout the code - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: dorny/paths-filter@v2 id: filter with: @@ -222,11 +224,11 @@ jobs: outputs: version: ${{ steps.git-commit.outputs.version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup node uses: actions/setup-node@v2 with: - node-version: "22.14.x" + node-version: ${{ env.NODE_VERSION }} registry-url: "https://registry.npmjs.org" - name: Build sdk run: yarn @@ -290,7 +292,7 @@ jobs: ] steps: - name: Checkout code with new updated version - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Emit dispatch event run: | curl -X POST \ @@ -312,7 +314,7 @@ jobs: program: ${{ steps.filter.outputs.program }} steps: # For pull requests it's not necessary to checkout the code - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: dorny/paths-filter@v2 id: filter with: @@ -329,16 +331,11 @@ jobs: if: ${{ needs.check-for-program-version-changes.outputs.program == 'true' }} steps: - name: Checkout - uses: actions/checkout@v3 - - - name: Install Solana Verify - run: | - cargo install --version 0.2.13 solana-verify - solana-verify --version + uses: actions/checkout@v4 - name: Verifiable Build run: | - solana-verify build --library-name drift --base-image ellipsislabs/solana:1.16.6 + anchor build --verifiable -s ${{ env.SOLANA_VERSION }} -d solanafoundation/anchor:v${{ env.ANCHOR_VERSION }} - name: Upload Artifact uses: actions/upload-artifact@v4 diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index b8bfd245ce..26f8e9f602 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -20,8 +20,8 @@ idl-build = [ "anchor-lang/idl-build", "anchor-spl/idl-build", "openbook-v2-light/idl-build", - "switchboard-on-demand/idl-build", - "pythnet-sdk/idl-build" + "pythnet-sdk/idl-build", + "switchboard-on-demand/idl-build" ] [dependencies] From 13929997fdfbfa0916608120eb8d1191b665c0c2 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 8 Dec 2025 12:54:17 +0800 Subject: [PATCH 17/25] ts build --- bun.lock | 239 +- package.json | 10 +- sdk/bun.lock | 107 +- sdk/package.json | 12 +- sdk/src/accounts/fetch.ts | 11 +- sdk/src/accounts/grpcAccountSubscriber.ts | 5 +- .../grpcDriftClientAccountSubscriber.ts | 3 +- .../grpcDriftClientAccountSubscriberV2.ts | 5 +- ...grpcInsuranceFundStakeAccountSubscriber.ts | 3 +- .../accounts/grpcMultiAccountSubscriber.ts | 7 +- .../grpcMultiUserAccountSubscriber.ts | 5 +- .../accounts/grpcProgramAccountSubscriber.ts | 5 +- sdk/src/accounts/grpcUserAccountSubscriber.ts | 3 +- .../grpcUserStatsAccountSubscriber.ts | 3 +- .../accounts/laserProgramAccountSubscriber.ts | 5 +- .../accounts/oneShotUserAccountSubscriber.ts | 5 +- .../oneShotUserStatsAccountSubscriber.ts | 9 +- .../pollingDriftClientAccountSubscriber.ts | 5 +- ...HighLeverageModeConfigAccountSubscriber.ts | 11 +- ...lingInsuranceFundStakeAccountSubscriber.ts | 5 +- .../pollingUserStatsAccountSubscriber.ts | 9 +- .../accounts/webSocketAccountSubscriber.ts | 5 +- .../accounts/webSocketAccountSubscriberV2.ts | 5 +- .../webSocketDriftClientAccountSubscriber.ts | 13 +- ...webSocketDriftClientAccountSubscriberV2.ts | 5 +- ...HighLeverageModeConfigAccountSubscriber.ts | 5 +- ...cketInsuranceFundStakeAccountSubscriber.ts | 5 +- .../webSocketProgramAccountSubscriber.ts | 5 +- .../webSocketProgramAccountsSubscriberV2.ts | 5 +- .../webSocketUserAccountSubscriber.ts | 5 +- .../webSocketUserStatsAccountSubsriber.ts | 5 +- .../websocketProgramUserAccountSubscriber.ts | 5 +- sdk/src/adminClient.ts | 526 - sdk/src/config.ts | 35 +- .../pollingConstituentAccountSubscriber.ts | 5 +- .../webSocketConstituentAccountSubscriber.ts | 5 +- sdk/src/decode/customCoder.ts | 8 +- sdk/src/decode/user.ts | 1 - sdk/src/driftClient.ts | 520 +- sdk/src/driftClientConfig.ts | 7 +- sdk/src/events/fetchLogs.ts | 2 +- sdk/src/events/parse.ts | 2 +- sdk/src/factory/oracleClient.ts | 3 +- sdk/src/idl/drift.json | 29910 +++++++++------- sdk/src/idl/drift.ts | 21433 +++++++++++ sdk/src/marinade/index.ts | 2 +- sdk/src/memcmp.ts | 2 +- sdk/src/openbook/openbookV2Subscriber.ts | 2 +- sdk/src/oracles/oracleClientCache.ts | 3 +- sdk/src/oracles/prelaunchOracleClient.ts | 5 +- sdk/src/oracles/pythLazerClient.ts | 10 +- sdk/src/oracles/pythPullClient.ts | 2 +- sdk/src/oracles/switchboardClient.ts | 2 +- sdk/src/oracles/switchboardOnDemandClient.ts | 4 +- sdk/src/tokenFaucet.ts | 2 +- sdk/src/types.ts | 78 +- sdk/src/user.ts | 1 - sdk/tests/dlob/helpers.ts | 1 - tests/delistMarket.ts | 7 - yarn.lock | 282 +- 60 files changed, 39377 insertions(+), 14013 deletions(-) create mode 100644 sdk/src/idl/drift.ts diff --git a/bun.lock b/bun.lock index 865ade9e6e..a2652fec3a 100644 --- a/bun.lock +++ b/bun.lock @@ -5,8 +5,8 @@ "dependencies": { "@ellipsis-labs/phoenix-sdk": "1.4.2", "@pythnetwork/pyth-solana-receiver": "0.8.0", - "@switchboard-xyz/common": "3.0.14", - "@switchboard-xyz/on-demand": "2.4.1", + "@switchboard-xyz/common": "5.5.0", + "@switchboard-xyz/on-demand": "3.7.3", "anchor-bankrun": "0.3.0", "chai-bn": "0.2.2", "csvtojson": "2.0.10", @@ -19,8 +19,8 @@ "zstddec": "0.1.0", }, "devDependencies": { - "@coral-xyz/anchor": "0.29.0", - "@coral-xyz/anchor-30": "npm:@coral-xyz/anchor@0.30.1", + "@coral-xyz/anchor": "npm:@coral-xyz/anchor@0.31.1", + "@coral-xyz/anchor-29": "npm:@coral-xyz/anchor@0.29.0", "@project-serum/common": "0.0.1-beta.3", "@project-serum/serum": "0.13.65", "@pythnetwork/client": "2.21.0", @@ -44,49 +44,42 @@ }, }, "overrides": { + "debug": "<4.4.2", + "supports-color": "7.2.0", "ansi-regex": "5.0.1", + "color-convert": "<3.1.1", "ansi-styles": "4.3.0", - "backslash": "<0.2.1", + "wrap-ansi": "7.0.0", "chalk": "4.1.2", - "chalk-template": "<1.1.1", - "color-convert": "<3.1.1", - "color-name": "<2.0.1", - "color-string": "<2.1.1", - "debug": "<4.4.2", - "error-ex": "<1.3.3", - "has-ansi": "<6.0.1", - "is-arrayish": "<0.3.3", - "simple-swizzle": "<0.2.3", - "slice-ansi": "3.0.0", "strip-ansi": "6.0.1", - "supports-color": "7.2.0", - "supports-hyperlinks": "<4.1.1", - "wrap-ansi": "7.0.0", + "color-name": "<2.0.1", }, "packages": { - "@babel/runtime": ["@babel/runtime@7.28.3", "", {}, "sha512-9uIQ10o0WGdpP6GDhXcdOJPJuDgFtIDtN/9+ArJQ2NAfAmiuhTQdzkaTGR33v43GYS2UrSA0eX2pPPHoFVvpxA=="], + "@babel/runtime": ["@babel/runtime@7.28.4", "", {}, "sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ=="], + + "@coral-xyz/anchor": ["@coral-xyz/anchor@0.31.1", "", { "dependencies": { "@coral-xyz/anchor-errors": "^0.31.1", "@coral-xyz/borsh": "^0.31.1", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.69.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA=="], - "@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], + "@coral-xyz/anchor-29": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], - "@coral-xyz/anchor-30": ["@coral-xyz/anchor@0.30.1", "", { "dependencies": { "@coral-xyz/anchor-errors": "^0.30.1", "@coral-xyz/borsh": "^0.30.1", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ=="], + "@coral-xyz/anchor-31": ["@coral-xyz/anchor@0.31.1", "", { "dependencies": { "@coral-xyz/anchor-errors": "^0.31.1", "@coral-xyz/borsh": "^0.31.1", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.69.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA=="], - "@coral-xyz/anchor-errors": ["@coral-xyz/anchor-errors@0.30.1", "", {}, "sha512-9Mkradf5yS5xiLWrl9WrpjqOrAV+/W2RQHDlbnAZBivoGpOs1ECjoDCkVk4aRG8ZdiFiB8zQEVlxf+8fKkmSfQ=="], + "@coral-xyz/anchor-errors": ["@coral-xyz/anchor-errors@0.31.1", "", {}, "sha512-NhNEku4F3zzUSBtrYz84FzYWm48+9OvmT1Hhnwr6GnPQry2dsEqH/ti/7ASjjpoFTWRnPXrjAIT1qM6Isop+LQ=="], - "@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + "@coral-xyz/borsh": ["@coral-xyz/borsh@0.31.1", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.69.0" } }, "sha512-9N8AU9F0ubriKfNE3g1WF0/4dtlGXoBN/hd1PvbNBamBNwRgHxH4P+o3Zt7rSEloW1HUs6LfZEchlx9fW7POYw=="], "@ellipsis-labs/phoenix-sdk": ["@ellipsis-labs/phoenix-sdk@1.4.2", "", { "dependencies": { "@metaplex-foundation/beet": "^0.7.1", "@metaplex-foundation/rustbin": "^0.3.1", "@metaplex-foundation/solita": "^0.12.2", "@solana/spl-token": "^0.3.7", "@types/node": "^18.11.13", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^5.0.0" } }, "sha512-7Rf2aWHZwuLX8jcrNSRUDf2aHuBnBzsDBN4GzClTdJYVGo4uQzf9ixju5J3apZ+xkQ6qvrEVYOXtogdgOhJFvw=="], - "@eslint-community/eslint-utils": ["@eslint-community/eslint-utils@4.7.0", "", { "dependencies": { "eslint-visitor-keys": "^3.4.3" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw=="], + "@eslint-community/eslint-utils": ["@eslint-community/eslint-utils@4.9.0", "", { "dependencies": { "eslint-visitor-keys": "^3.4.3" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g=="], - "@eslint-community/regexpp": ["@eslint-community/regexpp@4.12.1", "", {}, "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ=="], + "@eslint-community/regexpp": ["@eslint-community/regexpp@4.12.2", "", {}, "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew=="], "@eslint/eslintrc": ["@eslint/eslintrc@2.1.4", "", { "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" } }, "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ=="], "@eslint/js": ["@eslint/js@8.57.0", "", {}, "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g=="], - "@grpc/grpc-js": ["@grpc/grpc-js@1.13.4", "", { "dependencies": { "@grpc/proto-loader": "^0.7.13", "@js-sdsl/ordered-map": "^4.4.2" } }, "sha512-GsFaMXCkMqkKIvwCQjCrwH+GHbPKBjhwo/8ZuUkWHqbI73Kky9I+pQltrlT0+MWpedCoosda53lgjYfyEPgxBg=="], + "@grpc/grpc-js": ["@grpc/grpc-js@1.14.2", "", { "dependencies": { "@grpc/proto-loader": "^0.8.0", "@js-sdsl/ordered-map": "^4.4.2" } }, "sha512-QzVUtEFyu05UNx2xr0fCQmStUO17uVQhGNowtxs00IgTZT6/W2PBLfUkj30s0FKJ29VtTa3ArVNIhNP6akQhqA=="], - "@grpc/proto-loader": ["@grpc/proto-loader@0.7.15", "", { "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", "protobufjs": "^7.2.5", "yargs": "^17.7.2" }, "bin": { "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" } }, "sha512-tMXdRCfYVixjuFK+Hk0Q1s38gV9zDiDJfWL3h1rv4Qc39oILCu1TRTDt7+fGUI8K4G1Fj125Hx/ru3azECWTyQ=="], + "@grpc/proto-loader": ["@grpc/proto-loader@0.8.0", "", { "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", "protobufjs": "^7.5.3", "yargs": "^17.7.2" }, "bin": { "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" } }, "sha512-rc1hOQtjIWGxcxpb9aHAfLpIctjEnsDehj0DAiVfBlmT84uvR0uUtN2hEi/ecvWVjXUGf5qPF4qEgiLOx1YIMQ=="], "@humanwhocodes/config-array": ["@humanwhocodes/config-array@0.11.14", "", { "dependencies": { "@humanwhocodes/object-schema": "^2.0.2", "debug": "^4.3.1", "minimatch": "^3.0.5" } }, "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg=="], @@ -152,11 +145,11 @@ "@pythnetwork/price-service-client": ["@pythnetwork/price-service-client@1.9.0", "", { "dependencies": { "@pythnetwork/price-service-sdk": "*", "@types/ws": "^8.5.3", "axios": "^1.5.1", "axios-retry": "^3.8.0", "isomorphic-ws": "^4.0.1", "ts-log": "^2.2.4", "ws": "^8.6.0" } }, "sha512-SLm3IFcfmy9iMqHeT4Ih6qMNZhJEefY14T9yTlpsH2D/FE5+BaGGnfcexUifVlfH6M7mwRC4hEFdNvZ6ebZjJg=="], - "@pythnetwork/price-service-sdk": ["@pythnetwork/price-service-sdk@1.8.0", "", { "dependencies": { "bn.js": "^5.2.1" } }, "sha512-tFZ1thj3Zja06DzPIX2dEWSi7kIfIyqreoywvw5NQ3Z1pl5OJHQGMEhxt6Li3UCGSp2ooYZS9wl8/8XfrfrNSA=="], + "@pythnetwork/price-service-sdk": ["@pythnetwork/price-service-sdk@1.9.0", "", { "dependencies": { "bn.js": "^5.2.1" } }, "sha512-DX8N4VUqllyervqnCx/Z6Tjz130EcoczYYa96F1YjlbZf0rFyU8VCzX1yAf60q+b8EVcVFVeSkdzJTZD3n6+jQ=="], "@pythnetwork/pyth-solana-receiver": ["@pythnetwork/pyth-solana-receiver@0.8.0", "", { "dependencies": { "@coral-xyz/anchor": "^0.29.0", "@noble/hashes": "^1.4.0", "@pythnetwork/price-service-sdk": ">=1.6.0", "@pythnetwork/solana-utils": "*", "@solana/web3.js": "^1.90.0" } }, "sha512-5lhLtggAqsiHtffTPM8vcKJmhBdxzidBmiNNUlqPyg9XmhZ4Z+roY0dfzluEoX5xer9rEA1ThsBpX0bG1DRIGA=="], - "@pythnetwork/solana-utils": ["@pythnetwork/solana-utils@0.5.0", "", { "dependencies": { "@coral-xyz/anchor": "^0.29.0", "@solana/web3.js": "^1.90.0", "bs58": "^5.0.0", "jito-ts": "^3.0.1", "ts-log": "^2.2.7" } }, "sha512-6F99H/FiLNcleLlagBbM5YKPEp7QGo+bk5IUf+PPfEdk64sflRVq74M4rRghm+LpK4TuTbCA2Gh4aKJUZLG08Q=="], + "@pythnetwork/solana-utils": ["@pythnetwork/solana-utils@0.6.0", "", { "dependencies": { "@coral-xyz/anchor": "^0.29.0", "@solana/web3.js": "^1.90.0", "bs58": "^5.0.0", "jito-ts": "^3.0.1", "ts-log": "^2.2.7" } }, "sha512-dkjenNL7fiLHnJoBBxZh+NC5CKeAUKJKhnuKQpR8dW3oX44cF1MyMaY3j1x+8I9GvaXa4jhoudriiJKBfYOZfQ=="], "@solana/buffer-layout": ["@solana/buffer-layout@4.0.1", "", { "dependencies": { "buffer": "~6.0.3" } }, "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA=="], @@ -164,7 +157,7 @@ "@solana/codecs": ["@solana/codecs@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-data-structures": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/codecs-strings": "2.0.0-rc.1", "@solana/options": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-qxoR7VybNJixV51L0G1RD2boZTcxmwUWnKCaJJExQ5qNKwbpSyDdWfFJfM5JhGyKe9DnPVOZB+JHWXnpbZBqrQ=="], - "@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="], + "@solana/codecs-core": ["@solana/codecs-core@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw=="], "@solana/codecs-data-structures": ["@solana/codecs-data-structures@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-rinCv0RrAVJ9rE/rmaibWJQxMwC5lSaORSZuwjopSUE6T0nb/MVg6Z1siNCXhh/HFTOg0l8bNvZHgBcN/yvXog=="], @@ -186,9 +179,9 @@ "@swc/helpers": ["@swc/helpers@0.5.17", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A=="], - "@switchboard-xyz/common": ["@switchboard-xyz/common@3.0.14", "", { "dependencies": { "@solana/web3.js": "^1.98.0", "axios": "^1.8.3", "big.js": "^6.2.2", "bn.js": "^5.2.1", "bs58": "^6.0.0", "buffer": "^6.0.3", "decimal.js": "^10.4.3", "js-sha256": "^0.11.0", "protobufjs": "^7.4.0", "yaml": "^2.6.1" } }, "sha512-LpxzEywO0DjPYIgPzQYkf32C7agwW4YRsPN6BcIvYrw0iJdDMtPZ3SQfIGHLSlD1fwvn2KLUYuGaKegeq4aBTw=="], + "@switchboard-xyz/common": ["@switchboard-xyz/common@5.5.0", "", { "dependencies": { "@solana/web3.js": "^1.98.2", "axios": "^1.9.0", "big.js": "^6.2.2", "bn.js": "^5.2.1", "bs58": "^6.0.0", "buffer": "^6.0.3", "decimal.js": "^10.4.3", "js-sha256": "^0.11.0", "protobufjs": "^7.4.0" } }, "sha512-Wvs9KJw+YSe8O2IOsMUvPE8aQHb0t2vi/9hEQC7Pc6279s7tTTI8eVgT/0Jb2z897OHgIZTD3oGQ8IEBqIgV0w=="], - "@switchboard-xyz/on-demand": ["@switchboard-xyz/on-demand@2.4.1", "", { "dependencies": { "@coral-xyz/anchor-30": "npm:@coral-xyz/anchor@0.30.1", "@isaacs/ttlcache": "^1.4.1", "@switchboard-xyz/common": ">=3.0.0", "axios": "^1.8.3", "bs58": "^6.0.0", "buffer": "^6.0.3", "js-yaml": "^4.1.0" } }, "sha512-eSlBp+c8lxpcSgh0/2xK8OaLHPziTSZlcs8V96gZGdiCJz1KgWJRNE1qnIJDOwaGdFecZdwcmajfQRtLRLED3w=="], + "@switchboard-xyz/on-demand": ["@switchboard-xyz/on-demand@3.7.3", "", { "dependencies": { "@coral-xyz/anchor-31": "npm:@coral-xyz/anchor@0.31.1", "@isaacs/ttlcache": "^1.4.1", "@solana/spl-token": "^0.4.14", "@solana/web3.js": "^1.98.4", "@switchboard-xyz/common": "^5.2.9", "axios": "^1.9", "bs58": "^6.0.0", "buffer": "^6.0.3", "events": "^3.3.0", "isomorphic-ws": "^5.0.0", "js-yaml": "^4.1.0", "tweetnacl": "^1.0.3", "ws": "^8.18.1" } }, "sha512-sG9errSwjYlQbIlQl0iptUQcbKrPe7QVxX20+qXuucG3qIWlA/w6sXGnITeYbt+BERyBYdfue0viBjmjOsCZrg=="], "@types/bn.js": ["@types/bn.js@5.1.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-Xh8vSwUeMKeYYrj3cX4lGQgFSF/N03r+tv4AiLl1SucqV+uTQpxRcnM8AkXKHwYP9ZPXOYXRr2KPXpVlIvqh9w=="], @@ -200,9 +193,9 @@ "@types/mocha": ["@types/mocha@8.2.3", "", {}, "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw=="], - "@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], - "@types/semver": ["@types/semver@7.7.0", "", {}, "sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA=="], + "@types/semver": ["@types/semver@7.7.1", "", {}, "sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA=="], "@types/uuid": ["@types/uuid@8.3.4", "", {}, "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw=="], @@ -256,7 +249,7 @@ "available-typed-arrays": ["available-typed-arrays@1.0.7", "", { "dependencies": { "possible-typed-array-names": "^1.0.0" } }, "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ=="], - "axios": ["axios@1.11.0", "", { "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, "sha512-1Lx3WLFQWm3ooKDYZD1eXmoGO9fxYQjrycfHFC8P0sCfQVXyROp0p9PFWBehewBOdCwHc+f/b8I0fMto5eSfwA=="], + "axios": ["axios@1.13.2", "", { "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA=="], "axios-retry": ["axios-retry@3.9.1", "", { "dependencies": { "@babel/runtime": "^7.15.4", "is-retry-allowed": "^2.2.0" } }, "sha512-8PJDLJv7qTTMMwdnbMvrLYuvB47M81wRtxQmEdV5w4rgbTXTt+vtPkXwajOfOdSyv/wZICJOC+/UhXH4aQ/R+w=="], @@ -312,9 +305,9 @@ "cliui": ["cliui@8.0.1", "", { "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" } }, "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ=="], - "color-convert": ["color-convert@2.0.1", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="], + "color-convert": ["color-convert@3.1.0", "", { "dependencies": { "color-name": "^2.0.0" } }, "sha512-TVoqAq8ZDIpK5lsQY874DDnu65CSsc9vzq0wLpNQ6UMBq81GSZocVazPiBbYGzngzBOIRahpkTzCLVe2at4MfA=="], - "color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="], + "color-name": ["color-name@2.0.0", "", {}, "sha512-SbtvAMWvASO5TE2QP07jHBMXKafgdZz8Vrsrn96fiL+O92/FN/PLARzUW5sKt013fjAprK2d2iCn2hk2Xb5oow=="], "combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="], @@ -396,6 +389,8 @@ "eventemitter3": ["eventemitter3@4.0.7", "", {}, "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="], + "events": ["events@3.3.0", "", {}, "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q=="], + "eyes": ["eyes@0.1.8", "", {}, "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ=="], "fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="], @@ -434,12 +429,14 @@ "for-each": ["for-each@0.3.5", "", { "dependencies": { "is-callable": "^1.2.7" } }, "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg=="], - "form-data": ["form-data@4.0.4", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow=="], + "form-data": ["form-data@4.0.5", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w=="], "fs.realpath": ["fs.realpath@1.0.0", "", {}, "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="], "function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="], + "generator-function": ["generator-function@2.0.1", "", {}, "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g=="], + "get-caller-file": ["get-caller-file@2.0.5", "", {}, "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg=="], "get-func-name": ["get-func-name@2.0.2", "", {}, "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ=="], @@ -494,7 +491,7 @@ "is-fullwidth-code-point": ["is-fullwidth-code-point@3.0.0", "", {}, "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="], - "is-generator-function": ["is-generator-function@1.1.0", "", { "dependencies": { "call-bound": "^1.0.3", "get-proto": "^1.0.0", "has-tostringtag": "^1.0.2", "safe-regex-test": "^1.1.0" } }, "sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ=="], + "is-generator-function": ["is-generator-function@1.1.2", "", { "dependencies": { "call-bound": "^1.0.4", "generator-function": "^2.0.0", "get-proto": "^1.0.1", "has-tostringtag": "^1.0.2", "safe-regex-test": "^1.1.0" } }, "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA=="], "is-glob": ["is-glob@4.0.3", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="], @@ -522,7 +519,7 @@ "js-sha256": ["js-sha256@0.11.1", "", {}, "sha512-o6WSo/LUvY2uC4j7mO50a2ms7E/EAdbP0swigLV+nzHKTTaYnaLIWJ02VdXrsJX0vGedDESQnLsOekr94ryfjg=="], - "js-yaml": ["js-yaml@4.1.0", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA=="], + "js-yaml": ["js-yaml@4.1.1", "", { "dependencies": { "argparse": "^2.0.1" }, "bin": { "js-yaml": "bin/js-yaml.js" } }, "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA=="], "json-buffer": ["json-buffer@3.0.1", "", {}, "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="], @@ -652,7 +649,7 @@ "safe-regex-test": ["safe-regex-test@1.1.0", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "is-regex": "^1.2.1" } }, "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw=="], - "semver": ["semver@7.7.2", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA=="], + "semver": ["semver@7.7.3", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="], "set-function-length": ["set-function-length@1.2.2", "", { "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2" } }, "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg=="], @@ -718,6 +715,8 @@ "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="], + "tweetnacl": ["tweetnacl@1.0.3", "", {}, "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw=="], + "type-check": ["type-check@0.4.0", "", { "dependencies": { "prelude-ls": "^1.2.1" } }, "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew=="], "type-detect": ["type-detect@4.1.0", "", {}, "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw=="], @@ -728,7 +727,7 @@ "typescript": ["typescript@5.4.5", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ=="], - "undici-types": ["undici-types@7.10.0", "", {}, "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="], + "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], "uri-js": ["uri-js@4.4.1", "", { "dependencies": { "punycode": "^2.1.0" } }, "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg=="], @@ -760,8 +759,6 @@ "y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="], - "yaml": ["yaml@2.8.1", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw=="], - "yargs": ["yargs@17.7.2", "", { "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", "yargs-parser": "^21.1.1" } }, "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w=="], "yargs-parser": ["yargs-parser@21.1.1", "", {}, "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw=="], @@ -772,11 +769,15 @@ "zstddec": ["zstddec@0.1.0", "", {}, "sha512-w2NTI8+3l3eeltKAdK8QpiLo/flRAr2p8AGeakfMZOXBxOg9HIu4LVDxBi81sYgVhFhdJjv1OrB5ssI8uFPoLg=="], - "@coral-xyz/anchor-30/@coral-xyz/borsh": ["@coral-xyz/borsh@0.30.1", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-aaxswpPrCFKl8vZTbxLssA2RvwX2zmKLlRCIktJOwW+VpVwYtXRtlWiIP+c2pPRKneiTiWCN2GEMSH9j1zTlWQ=="], + "@coral-xyz/anchor/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], + + "@coral-xyz/anchor-29/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + + "@coral-xyz/anchor-31/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], "@ellipsis-labs/phoenix-sdk/@solana/spl-token": ["@solana/spl-token@0.3.11", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", "@solana/spl-token-metadata": "^0.1.2", "buffer": "^6.0.3" }, "peerDependencies": { "@solana/web3.js": "^1.88.0" } }, "sha512-bvohO3rIMSVL24Pb+I4EYTJ6cL82eFpInEXD/I8K8upOGjpqHsKUoAempR/RnUlI1qSFNyFlWJfu6MNUgfbCQQ=="], - "@ellipsis-labs/phoenix-sdk/@types/node": ["@types/node@18.19.123", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-K7DIaHnh0mzVxreCR9qwgNxp3MH9dltPNIEddW9MYUlcKAzm+3grKNSTe2vCJHI1FaLpvpL5JGJrz1UZDKYvDg=="], + "@ellipsis-labs/phoenix-sdk/@types/node": ["@types/node@18.19.130", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg=="], "@ellipsis-labs/phoenix-sdk/bs58": ["bs58@5.0.0", "", { "dependencies": { "base-x": "^4.0.0" } }, "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ=="], @@ -802,31 +803,41 @@ "@project-serum/serum/@solana/spl-token": ["@solana/spl-token@0.1.8", "", { "dependencies": { "@babel/runtime": "^7.10.5", "@solana/web3.js": "^1.21.0", "bn.js": "^5.1.0", "buffer": "6.0.3", "buffer-layout": "^1.2.0", "dotenv": "10.0.0" } }, "sha512-LZmYCKcPQDtJgecvWOgT/cnoIQPWjdH+QVyzPcFvyDUiT0DiRjZaam4aqNUyvchLFhzgunv3d9xOoyE34ofdoQ=="], + "@pythnetwork/client/@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], + "@pythnetwork/client/@coral-xyz/borsh": ["@coral-xyz/borsh@0.28.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-/u1VTzw7XooK7rqeD7JLUSwOyRSesPUk0U37BV9zK0axJc1q0nRbKFGFLYCQ16OtdOJTTwGfGp11Lx9B45bRCQ=="], + "@pythnetwork/pyth-solana-receiver/@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], + "@pythnetwork/pyth-solana-receiver/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], + "@pythnetwork/solana-utils/@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], + "@pythnetwork/solana-utils/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], "@pythnetwork/solana-utils/bs58": ["bs58@5.0.0", "", { "dependencies": { "base-x": "^4.0.0" } }, "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ=="], "@solana/buffer-layout-utils/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], + "@solana/codecs/@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="], + "@solana/codecs/@solana/codecs-numbers": ["@solana/codecs-numbers@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ=="], - "@solana/codecs-core/@solana/errors": ["@solana/errors@2.0.0-rc.1", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ=="], + "@solana/codecs-data-structures/@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="], "@solana/codecs-data-structures/@solana/codecs-numbers": ["@solana/codecs-numbers@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ=="], "@solana/codecs-data-structures/@solana/errors": ["@solana/errors@2.0.0-rc.1", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ=="], - "@solana/codecs-numbers/@solana/codecs-core": ["@solana/codecs-core@2.3.0", "", { "dependencies": { "@solana/errors": "2.3.0" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw=="], + "@solana/codecs-strings/@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="], "@solana/codecs-strings/@solana/codecs-numbers": ["@solana/codecs-numbers@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ=="], "@solana/codecs-strings/@solana/errors": ["@solana/errors@2.0.0-rc.1", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ=="], - "@solana/errors/commander": ["commander@14.0.0", "", {}, "sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA=="], + "@solana/errors/commander": ["commander@14.0.2", "", {}, "sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ=="], + + "@solana/options/@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="], "@solana/options/@solana/codecs-numbers": ["@solana/codecs-numbers@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ=="], @@ -840,8 +851,14 @@ "@switchboard-xyz/common/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="], + "@switchboard-xyz/on-demand/@solana/spl-token": ["@solana/spl-token@0.4.14", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", "@solana/spl-token-group": "^0.0.7", "@solana/spl-token-metadata": "^0.1.6", "buffer": "^6.0.3" }, "peerDependencies": { "@solana/web3.js": "^1.95.5" } }, "sha512-u09zr96UBpX4U685MnvQsNzlvw9TiY005hk1vJmJr7gMJldoPG1eYU5/wNEyOA5lkMLiR/gOi9SFD4MefOYEsA=="], + + "@switchboard-xyz/on-demand/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], + "@switchboard-xyz/on-demand/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="], + "@switchboard-xyz/on-demand/isomorphic-ws": ["isomorphic-ws@5.0.0", "", { "peerDependencies": { "ws": "*" } }, "sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw=="], + "@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.3", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg=="], "fast-glob/glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="], @@ -866,6 +883,18 @@ "typedoc/minimatch": ["minimatch@5.1.6", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g=="], + "@coral-xyz/anchor-31/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], + + "@coral-xyz/anchor-31/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], + + "@coral-xyz/anchor-31/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + + "@coral-xyz/anchor/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], + + "@coral-xyz/anchor/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], + + "@coral-xyz/anchor/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + "@ellipsis-labs/phoenix-sdk/@types/node/undici-types": ["undici-types@5.26.5", "", {}, "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="], "@ellipsis-labs/phoenix-sdk/bs58/base-x": ["base-x@4.0.1", "", {}, "sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw=="], @@ -874,7 +903,7 @@ "@metaplex-foundation/beet-solana/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "@metaplex-foundation/beet-solana/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "@metaplex-foundation/beet-solana/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "@metaplex-foundation/beet-solana/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], @@ -882,13 +911,13 @@ "@metaplex-foundation/solita/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "@metaplex-foundation/solita/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "@metaplex-foundation/solita/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "@metaplex-foundation/solita/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], "@project-serum/anchor/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "@project-serum/anchor/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "@project-serum/anchor/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "@project-serum/anchor/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], @@ -896,17 +925,29 @@ "@project-serum/serum/@solana/spl-token/dotenv": ["dotenv@10.0.0", "", {}, "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="], + "@pythnetwork/client/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + + "@pythnetwork/pyth-solana-receiver/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + + "@pythnetwork/pyth-solana-receiver/@coral-xyz/anchor/@solana/web3.js": ["@solana/web3.js@1.73.2", "", { "dependencies": { "@babel/runtime": "^7.12.5", "@noble/ed25519": "^1.7.0", "@noble/hashes": "^1.1.2", "@noble/secp256k1": "^1.6.3", "@solana/buffer-layout": "^4.0.0", "agentkeepalive": "^4.2.1", "bigint-buffer": "^1.1.5", "bn.js": "^5.0.0", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.1", "fast-stable-stringify": "^1.0.0", "jayson": "^3.4.4", "node-fetch": "2", "rpc-websockets": "^7.5.0", "superstruct": "^0.14.2" } }, "sha512-9WACF8W4Nstj7xiDw3Oom22QmrhBh0VyZyZ7JvvG3gOxLWLlX3hvm5nPVJOGcCE/9fFavBbCUb5A6CIuvMGdoA=="], + "@pythnetwork/pyth-solana-receiver/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "@pythnetwork/pyth-solana-receiver/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "@pythnetwork/pyth-solana-receiver/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "@pythnetwork/pyth-solana-receiver/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + "@pythnetwork/solana-utils/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + + "@pythnetwork/solana-utils/@coral-xyz/anchor/@solana/web3.js": ["@solana/web3.js@1.73.2", "", { "dependencies": { "@babel/runtime": "^7.12.5", "@noble/ed25519": "^1.7.0", "@noble/hashes": "^1.1.2", "@noble/secp256k1": "^1.6.3", "@solana/buffer-layout": "^4.0.0", "agentkeepalive": "^4.2.1", "bigint-buffer": "^1.1.5", "bn.js": "^5.0.0", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.1", "fast-stable-stringify": "^1.0.0", "jayson": "^3.4.4", "node-fetch": "2", "rpc-websockets": "^7.5.0", "superstruct": "^0.14.2" } }, "sha512-9WACF8W4Nstj7xiDw3Oom22QmrhBh0VyZyZ7JvvG3gOxLWLlX3hvm5nPVJOGcCE/9fFavBbCUb5A6CIuvMGdoA=="], + + "@pythnetwork/solana-utils/@coral-xyz/anchor/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], + "@pythnetwork/solana-utils/@solana/web3.js/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], "@pythnetwork/solana-utils/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "@pythnetwork/solana-utils/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "@pythnetwork/solana-utils/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "@pythnetwork/solana-utils/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], @@ -914,16 +955,16 @@ "@solana/buffer-layout-utils/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "@solana/buffer-layout-utils/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "@solana/buffer-layout-utils/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "@solana/buffer-layout-utils/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], - "@solana/codecs-core/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], - "@solana/codecs-data-structures/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], "@solana/codecs-strings/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], + "@solana/codecs/@solana/codecs-core/@solana/errors": ["@solana/errors@2.0.0-rc.1", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ=="], + "@solana/codecs/@solana/codecs-numbers/@solana/errors": ["@solana/errors@2.0.0-rc.1", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ=="], "@solana/options/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], @@ -932,17 +973,25 @@ "@switchboard-xyz/common/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "@switchboard-xyz/common/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "@switchboard-xyz/common/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "@switchboard-xyz/common/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], "@switchboard-xyz/common/bs58/base-x": ["base-x@5.0.1", "", {}, "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg=="], + "@switchboard-xyz/on-demand/@solana/web3.js/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + "@switchboard-xyz/on-demand/bs58/base-x": ["base-x@5.0.1", "", {}, "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg=="], "@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.2", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ=="], - "jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], "jito-ts/@solana/web3.js/superstruct": ["superstruct@0.14.2", "", {}, "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ=="], @@ -956,12 +1005,32 @@ "solana-bankrun/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "solana-bankrun/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "solana-bankrun/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "solana-bankrun/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], "typedoc/minimatch/brace-expansion": ["brace-expansion@2.0.2", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ=="], + "@coral-xyz/anchor-31/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], + + "@coral-xyz/anchor-31/@solana/web3.js/jayson/@types/ws": ["@types/ws@7.4.7", "", { "dependencies": { "@types/node": "*" } }, "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww=="], + + "@coral-xyz/anchor-31/@solana/web3.js/jayson/commander": ["commander@2.20.3", "", {}, "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="], + + "@coral-xyz/anchor-31/@solana/web3.js/jayson/ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="], + + "@coral-xyz/anchor-31/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + + "@coral-xyz/anchor/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], + + "@coral-xyz/anchor/@solana/web3.js/jayson/@types/ws": ["@types/ws@7.4.7", "", { "dependencies": { "@types/node": "*" } }, "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww=="], + + "@coral-xyz/anchor/@solana/web3.js/jayson/commander": ["commander@2.20.3", "", {}, "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="], + + "@coral-xyz/anchor/@solana/web3.js/jayson/ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="], + + "@coral-xyz/anchor/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + "@metaplex-foundation/beet-solana/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], "@metaplex-foundation/beet-solana/@solana/web3.js/jayson/@types/ws": ["@types/ws@7.4.7", "", { "dependencies": { "@types/node": "*" } }, "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww=="], @@ -994,10 +1063,14 @@ "@project-serum/serum/@solana/spl-token/@solana/web3.js/jayson": ["jayson@4.2.0", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "stream-json": "^1.9.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-VfJ9t1YLwacIubLhONk0KFeosUBwstRWQ0IRT1KDjEjnVnSOVHC3uwugyV7L0c7R9lpVyrUGT2XWiBA1UTtpyg=="], - "@project-serum/serum/@solana/spl-token/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.3", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-I+kNjW0udB4Fetr3vvtRuYZJS0PcSPyyvBcH5sDdoV8DFs5E4W2pTr7aiMlKfPxANTClP9RlqCPolj9dd5MsEA=="], + "@project-serum/serum/@solana/spl-token/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.3.2", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA=="], "@project-serum/serum/@solana/spl-token/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + "@pythnetwork/pyth-solana-receiver/@coral-xyz/anchor/@solana/web3.js/buffer": ["buffer@6.0.1", "", { "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" } }, "sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ=="], + + "@pythnetwork/pyth-solana-receiver/@coral-xyz/anchor/@solana/web3.js/superstruct": ["superstruct@0.14.2", "", {}, "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ=="], + "@pythnetwork/pyth-solana-receiver/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], "@pythnetwork/pyth-solana-receiver/@solana/web3.js/jayson/@types/ws": ["@types/ws@7.4.7", "", { "dependencies": { "@types/node": "*" } }, "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww=="], @@ -1008,6 +1081,10 @@ "@pythnetwork/pyth-solana-receiver/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + "@pythnetwork/solana-utils/@coral-xyz/anchor/@solana/web3.js/buffer": ["buffer@6.0.1", "", { "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" } }, "sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ=="], + + "@pythnetwork/solana-utils/@coral-xyz/anchor/@solana/web3.js/superstruct": ["superstruct@0.14.2", "", {}, "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ=="], + "@pythnetwork/solana-utils/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], "@pythnetwork/solana-utils/@solana/web3.js/jayson/@types/ws": ["@types/ws@7.4.7", "", { "dependencies": { "@types/node": "*" } }, "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww=="], @@ -1028,6 +1105,8 @@ "@solana/buffer-layout-utils/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + "@solana/codecs/@solana/codecs-core/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], + "@solana/codecs/@solana/codecs-numbers/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], "@switchboard-xyz/common/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], @@ -1040,7 +1119,19 @@ "@switchboard-xyz/common/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], - "jito-ts/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@switchboard-xyz/on-demand/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/jayson/@types/ws": ["@types/ws@7.4.7", "", { "dependencies": { "@types/node": "*" } }, "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/jayson/commander": ["commander@2.20.3", "", {}, "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/jayson/isomorphic-ws": ["isomorphic-ws@4.0.1", "", { "peerDependencies": { "ws": "*" } }, "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/jayson/ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + + "jito-ts/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], "solana-bankrun/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], @@ -1052,11 +1143,15 @@ "solana-bankrun/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], - "@metaplex-foundation/beet-solana/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@coral-xyz/anchor-31/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], + + "@coral-xyz/anchor/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], - "@metaplex-foundation/solita/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@metaplex-foundation/beet-solana/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], - "@project-serum/anchor/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@metaplex-foundation/solita/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], + + "@project-serum/anchor/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], "@project-serum/serum/@solana/spl-token/@solana/web3.js/jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], @@ -1068,16 +1163,18 @@ "@project-serum/serum/@solana/spl-token/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], - "@pythnetwork/pyth-solana-receiver/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@pythnetwork/pyth-solana-receiver/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], + + "@pythnetwork/solana-utils/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], - "@pythnetwork/solana-utils/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@solana/buffer-layout-utils/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], - "@solana/buffer-layout-utils/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@switchboard-xyz/common/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], - "@switchboard-xyz/common/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@switchboard-xyz/on-demand/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], - "solana-bankrun/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "solana-bankrun/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], - "@project-serum/serum/@solana/spl-token/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.3.0", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow=="], + "@project-serum/serum/@solana/spl-token/@solana/web3.js/jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], } } diff --git a/package.json b/package.json index 4b30b26fde..096b64278b 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "author": "", "license": "ISC", "devDependencies": { - "@coral-xyz/anchor": "0.29.0", - "@coral-xyz/anchor-30": "npm:@coral-xyz/anchor@0.30.1", + "@coral-xyz/anchor": "npm:@coral-xyz/anchor@0.31.1", + "@coral-xyz/anchor-29": "npm:@coral-xyz/anchor@0.29.0", "@project-serum/common": "0.0.1-beta.3", "@project-serum/serum": "0.13.65", "@pythnetwork/client": "2.21.0", @@ -30,8 +30,8 @@ "dependencies": { "@ellipsis-labs/phoenix-sdk": "1.4.2", "@pythnetwork/pyth-solana-receiver": "0.8.0", - "@switchboard-xyz/common": "3.0.14", - "@switchboard-xyz/on-demand": "2.4.1", + "@switchboard-xyz/common": "5.5.0", + "@switchboard-xyz/on-demand": "3.7.3", "anchor-bankrun": "0.3.0", "chai-bn": "0.2.2", "csvtojson": "2.0.10", @@ -95,4 +95,4 @@ "supports-hyperlinks": "<4.1.1", "has-ansi": "<6.0.1" } -} +} \ No newline at end of file diff --git a/sdk/bun.lock b/sdk/bun.lock index d3d328c729..1c160496ec 100644 --- a/sdk/bun.lock +++ b/sdk/bun.lock @@ -4,8 +4,8 @@ "": { "name": "@drift-labs/sdk", "dependencies": { - "@coral-xyz/anchor": "0.29.0", - "@coral-xyz/anchor-30": "npm:@coral-xyz/anchor@0.30.1", + "@coral-xyz/anchor": "npm:@coral-xyz/anchor@0.31.1", + "@coral-xyz/anchor-29": "npm:@coral-xyz/anchor@0.29.0", "@ellipsis-labs/phoenix-sdk": "1.4.5", "@grpc/grpc-js": "1.14.0", "@msgpack/msgpack": "^3.1.2", @@ -16,11 +16,11 @@ "@pythnetwork/pyth-solana-receiver": "0.7.0", "@solana/spl-token": "0.4.13", "@solana/web3.js": "1.98.0", - "@switchboard-xyz/common": "3.0.14", - "@switchboard-xyz/on-demand": "2.4.1", + "@switchboard-xyz/common": "5.5.0", + "@switchboard-xyz/on-demand": "3.7.3", "@triton-one/yellowstone-grpc": "1.4.1", "anchor-bankrun": "0.3.0", - "gill": "^0.10.2", + "gill": "^0.10.3", "helius-laserstream": "0.1.8", "nanoid": "3.3.4", "node-cache": "5.1.2", @@ -60,24 +60,15 @@ }, }, "overrides": { + "debug": "<4.4.2", + "supports-color": "7.2.0", "ansi-regex": "5.0.1", + "color-convert": "<3.1.1", "ansi-styles": "4.3.0", - "backslash": "<0.2.1", + "wrap-ansi": "7.0.0", "chalk": "4.1.2", - "chalk-template": "<1.1.1", - "color-convert": "<3.1.1", - "color-name": "<2.0.1", - "color-string": "<2.1.1", - "debug": "<4.4.2", - "error-ex": "<1.3.3", - "has-ansi": "<6.0.1", - "is-arrayish": "<0.3.3", - "simple-swizzle": "<0.2.3", - "slice-ansi": "3.0.0", "strip-ansi": "6.0.1", - "supports-color": "7.2.0", - "supports-hyperlinks": "<4.1.1", - "wrap-ansi": "7.0.0", + "color-name": "<2.0.1", }, "packages": { "@babel/code-frame": ["@babel/code-frame@7.26.2", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.25.9", "js-tokens": "^4.0.0", "picocolors": "^1.0.0" } }, "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ=="], @@ -92,13 +83,15 @@ "@babel/types": ["@babel/types@7.28.2", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.27.1" } }, "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ=="], - "@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], + "@coral-xyz/anchor": ["@coral-xyz/anchor@0.31.1", "", { "dependencies": { "@coral-xyz/anchor-errors": "^0.31.1", "@coral-xyz/borsh": "^0.31.1", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.69.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA=="], - "@coral-xyz/anchor-30": ["@coral-xyz/anchor@0.30.1", "", { "dependencies": { "@coral-xyz/anchor-errors": "^0.30.1", "@coral-xyz/borsh": "^0.30.1", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ=="], + "@coral-xyz/anchor-29": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], - "@coral-xyz/anchor-errors": ["@coral-xyz/anchor-errors@0.30.1", "", {}, "sha512-9Mkradf5yS5xiLWrl9WrpjqOrAV+/W2RQHDlbnAZBivoGpOs1ECjoDCkVk4aRG8ZdiFiB8zQEVlxf+8fKkmSfQ=="], + "@coral-xyz/anchor-31": ["@coral-xyz/anchor@0.31.1", "", { "dependencies": { "@coral-xyz/anchor-errors": "^0.31.1", "@coral-xyz/borsh": "^0.31.1", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.69.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA=="], - "@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + "@coral-xyz/anchor-errors": ["@coral-xyz/anchor-errors@0.31.1", "", {}, "sha512-NhNEku4F3zzUSBtrYz84FzYWm48+9OvmT1Hhnwr6GnPQry2dsEqH/ti/7ASjjpoFTWRnPXrjAIT1qM6Isop+LQ=="], + + "@coral-xyz/borsh": ["@coral-xyz/borsh@0.31.1", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.69.0" } }, "sha512-9N8AU9F0ubriKfNE3g1WF0/4dtlGXoBN/hd1PvbNBamBNwRgHxH4P+o3Zt7rSEloW1HUs6LfZEchlx9fW7POYw=="], "@cspotcode/source-map-support": ["@cspotcode/source-map-support@0.8.1", "", { "dependencies": { "@jridgewell/trace-mapping": "0.3.9" } }, "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw=="], @@ -302,9 +295,9 @@ "@swc/helpers": ["@swc/helpers@0.5.15", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g=="], - "@switchboard-xyz/common": ["@switchboard-xyz/common@3.0.14", "", { "dependencies": { "@solana/web3.js": "^1.98.0", "axios": "^1.8.3", "big.js": "^6.2.2", "bn.js": "^5.2.1", "bs58": "^6.0.0", "buffer": "^6.0.3", "decimal.js": "^10.4.3", "js-sha256": "^0.11.0", "protobufjs": "^7.4.0", "yaml": "^2.6.1" } }, "sha512-LpxzEywO0DjPYIgPzQYkf32C7agwW4YRsPN6BcIvYrw0iJdDMtPZ3SQfIGHLSlD1fwvn2KLUYuGaKegeq4aBTw=="], + "@switchboard-xyz/common": ["@switchboard-xyz/common@5.5.0", "", { "dependencies": { "@solana/web3.js": "^1.98.2", "axios": "^1.9.0", "big.js": "^6.2.2", "bn.js": "^5.2.1", "bs58": "^6.0.0", "buffer": "^6.0.3", "decimal.js": "^10.4.3", "js-sha256": "^0.11.0", "protobufjs": "^7.4.0" } }, "sha512-Wvs9KJw+YSe8O2IOsMUvPE8aQHb0t2vi/9hEQC7Pc6279s7tTTI8eVgT/0Jb2z897OHgIZTD3oGQ8IEBqIgV0w=="], - "@switchboard-xyz/on-demand": ["@switchboard-xyz/on-demand@2.4.1", "", { "dependencies": { "@coral-xyz/anchor-30": "npm:@coral-xyz/anchor@0.30.1", "@isaacs/ttlcache": "^1.4.1", "@switchboard-xyz/common": ">=3.0.0", "axios": "^1.8.3", "bs58": "^6.0.0", "buffer": "^6.0.3", "js-yaml": "^4.1.0" } }, "sha512-eSlBp+c8lxpcSgh0/2xK8OaLHPziTSZlcs8V96gZGdiCJz1KgWJRNE1qnIJDOwaGdFecZdwcmajfQRtLRLED3w=="], + "@switchboard-xyz/on-demand": ["@switchboard-xyz/on-demand@3.7.3", "", { "dependencies": { "@coral-xyz/anchor-31": "npm:@coral-xyz/anchor@0.31.1", "@isaacs/ttlcache": "^1.4.1", "@solana/spl-token": "^0.4.14", "@solana/web3.js": "^1.98.4", "@switchboard-xyz/common": "^5.2.9", "axios": "^1.9", "bs58": "^6.0.0", "buffer": "^6.0.3", "events": "^3.3.0", "isomorphic-ws": "^5.0.0", "js-yaml": "^4.1.0", "tweetnacl": "^1.0.3", "ws": "^8.18.1" } }, "sha512-sG9errSwjYlQbIlQl0iptUQcbKrPe7QVxX20+qXuucG3qIWlA/w6sXGnITeYbt+BERyBYdfue0viBjmjOsCZrg=="], "@triton-one/yellowstone-grpc": ["@triton-one/yellowstone-grpc@1.4.1", "", { "dependencies": { "@grpc/grpc-js": "^1.8.0" } }, "sha512-ZN49vooxFbOqWttll8u7AOsIVnX+srqX9ddhZ9ttE+OcehUo8c2p2suK8Gr2puab49cgsV0VGjiTn9Gua/ntIw=="], @@ -632,6 +625,8 @@ "eventemitter3": ["eventemitter3@4.0.7", "", {}, "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="], + "events": ["events@3.3.0", "", {}, "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q=="], + "expect": ["expect@28.1.3", "", { "dependencies": { "@jest/expect-utils": "^28.1.3", "jest-get-type": "^28.0.2", "jest-matcher-utils": "^28.1.3", "jest-message-util": "^28.1.3", "jest-util": "^28.1.3" } }, "sha512-eEh0xn8HlsuOBxFgIss+2mX85VAS4Qy3OSkjV7rlBWljtA4oWH37glVGyOZSZvErDT/yBywZdPGwCXuTvSG85g=="], "eyes": ["eyes@0.1.8", "", {}, "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ=="], @@ -696,7 +691,7 @@ "get-proto": ["get-proto@1.0.1", "", { "dependencies": { "dunder-proto": "^1.0.1", "es-object-atoms": "^1.0.0" } }, "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g=="], - "gill": ["gill@0.10.2", "", { "dependencies": { "@solana-program/address-lookup-table": "^0.7.0", "@solana-program/compute-budget": "^0.8.0", "@solana-program/system": "^0.7.0", "@solana-program/token-2022": "^0.4.1", "@solana/assertions": "^2.1.1", "@solana/codecs": "^2.1.1", "@solana/kit": "^2.1.1", "@solana/transaction-confirmation": "^2.1.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-upWoY2dfOzKHOcX3UnD+B3h9WUunPv0oxeKzsIgKSaLyURpWK9oI+K2NHWbwrUFsXEK6ozu/sgkhuqyAcVTZCg=="], + "gill": ["gill@0.10.3", "", { "dependencies": { "@solana-program/address-lookup-table": "^0.7.0", "@solana-program/compute-budget": "^0.8.0", "@solana-program/system": "^0.7.0", "@solana-program/token-2022": "^0.4.2", "@solana/assertions": "^2.1.1", "@solana/codecs": "^2.1.1", "@solana/kit": "^2.3.0", "@solana/transaction-confirmation": "^2.1.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-4LIVA32lKcWoqU/dbwu+YpJbR59QQT6mvCtqkElBWF2aT9upmewjKN3/anhfTGy+o/RJykAV21i3RzCj9FR0Xg=="], "glob": ["glob@8.1.0", "", { "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^5.0.1", "once": "^1.3.0" } }, "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ=="], @@ -800,7 +795,7 @@ "isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="], - "isomorphic-ws": ["isomorphic-ws@4.0.1", "", { "peerDependencies": { "ws": "*" } }, "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w=="], + "isomorphic-ws": ["isomorphic-ws@5.0.0", "", { "peerDependencies": { "ws": "*" } }, "sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw=="], "jayson": ["jayson@4.1.3", "", { "dependencies": { "@types/connect": "^3.4.33", "@types/node": "^12.12.54", "@types/ws": "^7.4.4", "JSONStream": "^1.3.5", "commander": "^2.20.3", "delay": "^5.0.0", "es6-promisify": "^5.0.0", "eyes": "^0.1.8", "isomorphic-ws": "^4.0.1", "json-stringify-safe": "^5.0.1", "uuid": "^8.3.2", "ws": "^7.5.10" }, "bin": { "jayson": "bin/jayson.js" } }, "sha512-LtXh5aYZodBZ9Fc3j6f2w+MTNcnxteMOrb+QgIouguGOulWi0lieEkOUg+HkjjFs0DGoWDds6bi4E9hpNFLulQ=="], @@ -972,7 +967,7 @@ "pretty-ms": ["pretty-ms@7.0.1", "", { "dependencies": { "parse-ms": "^2.1.0" } }, "sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q=="], - "protobufjs": ["protobufjs@7.4.0", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw=="], + "protobufjs": ["protobufjs@7.5.4", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg=="], "proxy-from-env": ["proxy-from-env@1.1.0", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="], @@ -1162,8 +1157,6 @@ "y18n": ["y18n@5.0.8", "", {}, "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA=="], - "yaml": ["yaml@2.7.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA=="], - "yargs": ["yargs@17.7.2", "", { "dependencies": { "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.3", "y18n": "^5.0.5", "yargs-parser": "^21.1.1" } }, "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w=="], "yargs-parser": ["yargs-parser@20.2.9", "", {}, "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w=="], @@ -1180,7 +1173,7 @@ "@babel/types/@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.27.1", "", {}, "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow=="], - "@coral-xyz/anchor-30/@coral-xyz/borsh": ["@coral-xyz/borsh@0.30.1", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-aaxswpPrCFKl8vZTbxLssA2RvwX2zmKLlRCIktJOwW+VpVwYtXRtlWiIP+c2pPRKneiTiWCN2GEMSH9j1zTlWQ=="], + "@coral-xyz/anchor-29/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], "@ellipsis-labs/phoenix-sdk/@solana/spl-token": ["@solana/spl-token@0.3.7", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", "buffer": "^6.0.3" }, "peerDependencies": { "@solana/web3.js": "^1.47.4" } }, "sha512-bKGxWTtIw6VDdCBngjtsGlKGLSmiu/8ghSt/IOYJV24BsymRbgq7r12GToeetpxmPaZYLddKwAz7+EwprLfkfg=="], @@ -1188,8 +1181,6 @@ "@ellipsis-labs/phoenix-sdk/bs58": ["bs58@5.0.0", "", { "dependencies": { "base-x": "^4.0.0" } }, "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ=="], - "@grpc/proto-loader/protobufjs": ["protobufjs@7.5.4", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg=="], - "@metaplex-foundation/beet-solana/bs58": ["bs58@5.0.0", "", { "dependencies": { "base-x": "^4.0.0" } }, "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ=="], "@metaplex-foundation/solita/@metaplex-foundation/beet": ["@metaplex-foundation/beet@0.4.0", "", { "dependencies": { "ansicolors": "^0.3.2", "bn.js": "^5.2.0", "debug": "^4.3.3" } }, "sha512-2OAKJnLatCc3mBXNL0QmWVQKAWK2C7XDfepgL0p/9+8oSx4bmRAFHFqptl1A/C0U5O3dxGwKfmKluW161OVGcA=="], @@ -1198,6 +1189,8 @@ "@metaplex-foundation/solita/prettier": ["prettier@2.8.8", "", { "bin": { "prettier": "bin-prettier.js" } }, "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q=="], + "@openbook-dex/openbook-v2/@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], + "@openbook-dex/openbook-v2/@solana/spl-token": ["@solana/spl-token@0.4.12", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", "@solana/spl-token-group": "^0.0.7", "@solana/spl-token-metadata": "^0.1.6", "buffer": "^6.0.3" }, "peerDependencies": { "@solana/web3.js": "^1.95.5" } }, "sha512-K6CxzSoO1vC+WBys25zlSDaW0w4UFZO/IvEZquEI35A/PjqXNQHeVigmDCZYEJfESvYarKwsr8tYr/29lPtvaw=="], "@project-serum/anchor/camelcase": ["camelcase@5.3.1", "", {}, "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg=="], @@ -1206,6 +1199,10 @@ "@project-serum/serum/@solana/spl-token": ["@solana/spl-token@0.1.8", "", { "dependencies": { "@babel/runtime": "^7.10.5", "@solana/web3.js": "^1.21.0", "bn.js": "^5.1.0", "buffer": "6.0.3", "buffer-layout": "^1.2.0", "dotenv": "10.0.0" } }, "sha512-LZmYCKcPQDtJgecvWOgT/cnoIQPWjdH+QVyzPcFvyDUiT0DiRjZaam4aqNUyvchLFhzgunv3d9xOoyE34ofdoQ=="], + "@pythnetwork/pyth-solana-receiver/@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], + + "@pythnetwork/solana-utils/@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], + "@pythnetwork/solana-utils/bs58": ["bs58@5.0.0", "", { "dependencies": { "base-x": "^4.0.0" } }, "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ=="], "@sinonjs/commons/type-detect": ["type-detect@4.0.8", "", {}, "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g=="], @@ -1222,11 +1219,15 @@ "@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + "@switchboard-xyz/common/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], + "@switchboard-xyz/common/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="], - "@switchboard-xyz/on-demand/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="], + "@switchboard-xyz/on-demand/@solana/spl-token": ["@solana/spl-token@0.4.14", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", "@solana/spl-token-group": "^0.0.7", "@solana/spl-token-metadata": "^0.1.6", "buffer": "^6.0.3" }, "peerDependencies": { "@solana/web3.js": "^1.95.5" } }, "sha512-u09zr96UBpX4U685MnvQsNzlvw9TiY005hk1vJmJr7gMJldoPG1eYU5/wNEyOA5lkMLiR/gOi9SFD4MefOYEsA=="], - "@types/protobufjs/protobufjs": ["protobufjs@7.5.4", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg=="], + "@switchboard-xyz/on-demand/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], + + "@switchboard-xyz/on-demand/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="], "@typescript-eslint/project-service/@typescript-eslint/types": ["@typescript-eslint/types@8.38.0", "", {}, "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw=="], @@ -1254,12 +1255,12 @@ "glob/minimatch": ["minimatch@5.1.6", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g=="], - "helius-laserstream/protobufjs": ["protobufjs@7.5.4", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg=="], - "jayson/@types/node": ["@types/node@12.20.55", "", {}, "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ=="], "jayson/commander": ["commander@2.20.3", "", {}, "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="], + "jayson/isomorphic-ws": ["isomorphic-ws@4.0.1", "", { "peerDependencies": { "ws": "*" } }, "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w=="], + "jayson/ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="], "jito-ts/@grpc/grpc-js": ["@grpc/grpc-js@1.12.6", "", { "dependencies": { "@grpc/proto-loader": "^0.7.13", "@js-sdsl/ordered-map": "^4.4.2" } }, "sha512-JXUj6PI0oqqzTGvKtzOkxtpsyPRNsrmhh41TtIz/zEB6J+AUiZZ0dxWzcMwO9Ns5rmSPuMdghlTbUuqIM48d3Q=="], @@ -1306,6 +1307,14 @@ "@metaplex-foundation/beet-solana/bs58/base-x": ["base-x@4.0.0", "", {}, "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw=="], + "@openbook-dex/openbook-v2/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + + "@pythnetwork/pyth-solana-receiver/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + + "@pythnetwork/solana-utils/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], + + "@pythnetwork/solana-utils/@coral-xyz/anchor/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], + "@pythnetwork/solana-utils/bs58/base-x": ["base-x@4.0.0", "", {}, "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw=="], "@solana/spl-token-group/@solana/codecs/@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="], @@ -1332,8 +1341,20 @@ "@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + "@switchboard-xyz/common/@solana/web3.js/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], + + "@switchboard-xyz/common/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.1", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-1IXGM/TfPT6nfYMIXkJdzn+L4JEsmb0FL1O2OBjaH03V3yuUDdKFulGLMFG6ErV+8pZ5HVC0limve01RyO+saA=="], + + "@switchboard-xyz/common/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + "@switchboard-xyz/common/bs58/base-x": ["base-x@5.0.0", "", {}, "sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ=="], + "@switchboard-xyz/on-demand/@solana/web3.js/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.1", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-1IXGM/TfPT6nfYMIXkJdzn+L4JEsmb0FL1O2OBjaH03V3yuUDdKFulGLMFG6ErV+8pZ5HVC0limve01RyO+saA=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + "@switchboard-xyz/on-demand/bs58/base-x": ["base-x@5.0.0", "", {}, "sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ=="], "@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="], @@ -1376,10 +1397,20 @@ "@solana/spl-token-metadata/@solana/codecs/@solana/options/@solana/errors": ["@solana/errors@2.0.0-rc.1", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ=="], + "@switchboard-xyz/common/@solana/web3.js/rpc-websockets/@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="], + + "@switchboard-xyz/common/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/rpc-websockets/@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="], + + "@switchboard-xyz/on-demand/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + "detective-typescript/@typescript-eslint/typescript-estree/@typescript-eslint/visitor-keys/eslint-visitor-keys": ["eslint-visitor-keys@4.2.1", "", {}, "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ=="], "detective-typescript/@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="], + "jito-ts/@grpc/grpc-js/@grpc/proto-loader/protobufjs": ["protobufjs@7.4.0", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw=="], + "@solana/spl-token-group/@solana/codecs/@solana/codecs-core/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], "@solana/spl-token-group/@solana/codecs/@solana/codecs-data-structures/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], @@ -1400,4 +1431,4 @@ "@solana/spl-token-metadata/@solana/codecs/@solana/options/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], } -} \ No newline at end of file +} diff --git a/sdk/package.json b/sdk/package.json index 68c281784d..a162a64a01 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -41,8 +41,8 @@ "access": "public" }, "dependencies": { - "@coral-xyz/anchor": "0.29.0", - "@coral-xyz/anchor-30": "npm:@coral-xyz/anchor@0.30.1", + "@coral-xyz/anchor": "npm:@coral-xyz/anchor@0.31.1", + "@coral-xyz/anchor-29": "npm:@coral-xyz/anchor@0.29.0", "@ellipsis-labs/phoenix-sdk": "1.4.5", "@grpc/grpc-js": "1.14.0", "@msgpack/msgpack": "^3.1.2", @@ -53,11 +53,11 @@ "@pythnetwork/pyth-solana-receiver": "0.7.0", "@solana/spl-token": "0.4.13", "@solana/web3.js": "1.98.0", - "@switchboard-xyz/common": "3.0.14", - "@switchboard-xyz/on-demand": "2.4.1", + "@switchboard-xyz/common": "5.5.0", + "@switchboard-xyz/on-demand": "3.7.3", "@triton-one/yellowstone-grpc": "1.4.1", "anchor-bankrun": "0.3.0", - "gill": "^0.10.2", + "gill": "^0.10.3", "helius-laserstream": "0.1.8", "nanoid": "3.3.4", "node-cache": "5.1.2", @@ -147,4 +147,4 @@ "@grpc/grpc-js": false, "zstddec": false } -} +} \ No newline at end of file diff --git a/sdk/src/accounts/fetch.ts b/sdk/src/accounts/fetch.ts index 63c7bfd7f0..53d5f9ff5e 100644 --- a/sdk/src/accounts/fetch.ts +++ b/sdk/src/accounts/fetch.ts @@ -12,10 +12,11 @@ import { getUserStatsAccountPublicKey, } from '../addresses/pda'; import { Program } from '@coral-xyz/anchor'; +import { Drift } from '../idl/drift'; export async function fetchUserAccounts( connection: Connection, - program: Program, + program: Program, authority: PublicKey, limit = 8 ): Promise<(UserAccount | undefined)[]> { @@ -31,7 +32,7 @@ export async function fetchUserAccounts( export async function fetchUserAccountsUsingKeys( connection: Connection, - program: Program, + program: Program, userAccountPublicKeys: PublicKey[] ): Promise<(UserAccount | undefined)[]> { const accountInfos = await connection.getMultipleAccountsInfo( @@ -52,7 +53,7 @@ export async function fetchUserAccountsUsingKeys( export async function fetchUserStatsAccount( connection: Connection, - program: Program, + program: Program, authority: PublicKey ): Promise { const userStatsPublicKey = getUserStatsAccountPublicKey( @@ -74,7 +75,7 @@ export async function fetchUserStatsAccount( export async function fetchRevenueShareAccount( connection: Connection, - program: Program, + program: Program, authority: PublicKey ): Promise { const revenueShareAccountPublicKey = getRevenueShareAccountPublicKey( @@ -93,7 +94,7 @@ export async function fetchRevenueShareAccount( export async function fetchRevenueShareEscrowAccount( connection: Connection, - program: Program, + program: Program, authority: PublicKey ): Promise { const revenueShareEscrowPubKey = getRevenueShareEscrowAccountPublicKey( diff --git a/sdk/src/accounts/grpcAccountSubscriber.ts b/sdk/src/accounts/grpcAccountSubscriber.ts index 50adb2f318..dd698fbf04 100644 --- a/sdk/src/accounts/grpcAccountSubscriber.ts +++ b/sdk/src/accounts/grpcAccountSubscriber.ts @@ -12,6 +12,7 @@ import { SubscribeRequest, SubscribeUpdate, } from '../isomorphic/grpc'; +import { Drift } from '../idl/drift'; export class grpcAccountSubscriber extends WebSocketAccountSubscriber { private client: Client; @@ -23,7 +24,7 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { client: Client, commitmentLevel: CommitmentLevel, accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts @@ -36,7 +37,7 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { public static async create( grpcConfigs: GrpcConfigs, accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => U, resubOpts?: ResubOpts, diff --git a/sdk/src/accounts/grpcDriftClientAccountSubscriber.ts b/sdk/src/accounts/grpcDriftClientAccountSubscriber.ts index 31d34e32ca..c12ec8efb8 100644 --- a/sdk/src/accounts/grpcDriftClientAccountSubscriber.ts +++ b/sdk/src/accounts/grpcDriftClientAccountSubscriber.ts @@ -11,13 +11,14 @@ import { DelistedMarketSetting, GrpcConfigs, ResubOpts } from './types'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types'; import { getOracleId } from '../oracles/oracleId'; +import { Drift } from '../idl/drift'; export class grpcDriftClientAccountSubscriber extends WebSocketDriftClientAccountSubscriber { private grpcConfigs: GrpcConfigs; constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], diff --git a/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts b/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts index d2770dc3c7..5ff0a15dd1 100644 --- a/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts +++ b/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts @@ -30,6 +30,7 @@ import { } from '../oracles/oracleId'; import { OracleClientCache } from '../oracles/oracleClientCache'; import { findDelistedPerpMarketsAndOracles } from './utils'; +import { Drift } from '../idl/drift'; export class grpcDriftClientAccountSubscriberV2 implements DriftClientAccountSubscriber @@ -51,7 +52,7 @@ export class grpcDriftClientAccountSubscriberV2 >; public isSubscribed: boolean; public isSubscribing: boolean; - public program: Program; + public program: Program; public perpMarketIndexes: number[]; public spotMarketIndexes: number[]; public shouldFindAllMarketsAndOracles: boolean; @@ -76,7 +77,7 @@ export class grpcDriftClientAccountSubscriberV2 constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], diff --git a/sdk/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts b/sdk/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts index 56aa167b7e..89387ec46f 100644 --- a/sdk/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +++ b/sdk/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts @@ -4,13 +4,14 @@ import { PublicKey } from '@solana/web3.js'; import { InsuranceFundStake } from '../types'; import { WebSocketInsuranceFundStakeAccountSubscriber } from './webSocketInsuranceFundStakeAccountSubscriber'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; +import { Drift } from '../idl/drift'; export class grpcInsuranceFundStakeAccountSubscriber extends WebSocketInsuranceFundStakeAccountSubscriber { private grpcConfigs: GrpcConfigs; public constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: Program, insuranceFundStakeAccountPublicKey: PublicKey, resubTimeoutMs?: number ) { diff --git a/sdk/src/accounts/grpcMultiAccountSubscriber.ts b/sdk/src/accounts/grpcMultiAccountSubscriber.ts index 7a442ac5cd..3bf465c8fb 100644 --- a/sdk/src/accounts/grpcMultiAccountSubscriber.ts +++ b/sdk/src/accounts/grpcMultiAccountSubscriber.ts @@ -12,6 +12,7 @@ import { createClient, } from '../isomorphic/grpc'; import { BufferAndSlot, DataAndSlot, GrpcConfigs, ResubOpts } from './types'; +import { Drift } from '../idl/drift'; interface AccountInfoLike { owner: PublicKey; @@ -40,7 +41,7 @@ export class grpcMultiAccountSubscriber { private client: Client; private stream: ClientDuplexStream; private commitmentLevel: CommitmentLevel; - private program: Program; + private program: Program; private accountName: string; private decodeBufferFn?: ( buffer: Buffer, @@ -69,7 +70,7 @@ export class grpcMultiAccountSubscriber { client: Client, commitmentLevel: CommitmentLevel, accountName: string, - program: Program, + program: Program, decodeBuffer?: (buffer: Buffer, pubkey?: string) => T, resubOpts?: ResubOpts, onUnsubscribe?: () => Promise, @@ -88,7 +89,7 @@ export class grpcMultiAccountSubscriber { public static async create( grpcConfigs: GrpcConfigs, accountName: string, - program: Program, + program: Program, decodeBuffer?: (buffer: Buffer, pubkey?: string, accountProps?: U) => T, resubOpts?: ResubOpts, clientProp?: Client, diff --git a/sdk/src/accounts/grpcMultiUserAccountSubscriber.ts b/sdk/src/accounts/grpcMultiUserAccountSubscriber.ts index 38ea46c78c..14d8c5435f 100644 --- a/sdk/src/accounts/grpcMultiUserAccountSubscriber.ts +++ b/sdk/src/accounts/grpcMultiUserAccountSubscriber.ts @@ -12,9 +12,10 @@ import { Context, PublicKey } from '@solana/web3.js'; import { Program } from '@coral-xyz/anchor'; import { UserAccount } from '../types'; import { grpcMultiAccountSubscriber } from './grpcMultiAccountSubscriber'; +import { Drift } from '../idl/drift'; export class grpcMultiUserAccountSubscriber { - private program: Program; + private program: Program; private multiSubscriber: grpcMultiAccountSubscriber; private userData = new Map>(); @@ -50,7 +51,7 @@ export class grpcMultiUserAccountSubscriber { }; public constructor( - program: Program, + program: Program, grpcConfigs: GrpcConfigs, resubOpts?: ResubOpts, multiSubscriber?: grpcMultiAccountSubscriber diff --git a/sdk/src/accounts/grpcProgramAccountSubscriber.ts b/sdk/src/accounts/grpcProgramAccountSubscriber.ts index f575c64229..4440597f96 100644 --- a/sdk/src/accounts/grpcProgramAccountSubscriber.ts +++ b/sdk/src/accounts/grpcProgramAccountSubscriber.ts @@ -12,6 +12,7 @@ import { SubscribeRequest, SubscribeUpdate, } from '../isomorphic/grpc'; +import { Drift } from '../idl/drift'; export class grpcProgramAccountSubscriber< T, @@ -26,7 +27,7 @@ export class grpcProgramAccountSubscriber< commitmentLevel: CommitmentLevel, subscriptionName: string, accountDiscriminator: string, - program: Program, + program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => T, options: { filters: MemcmpFilter[] } = { filters: [], @@ -49,7 +50,7 @@ export class grpcProgramAccountSubscriber< grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, - program: Program, + program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options: { filters: MemcmpFilter[] } = { filters: [], diff --git a/sdk/src/accounts/grpcUserAccountSubscriber.ts b/sdk/src/accounts/grpcUserAccountSubscriber.ts index db3ad1225a..72dbbe8aac 100644 --- a/sdk/src/accounts/grpcUserAccountSubscriber.ts +++ b/sdk/src/accounts/grpcUserAccountSubscriber.ts @@ -4,13 +4,14 @@ import { PublicKey } from '@solana/web3.js'; import { UserAccount } from '../types'; import { WebSocketUserAccountSubscriber } from './webSocketUserAccountSubscriber'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; +import { Drift } from '../idl/drift'; export class grpcUserAccountSubscriber extends WebSocketUserAccountSubscriber { private grpcConfigs: GrpcConfigs; public constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: Program, userAccountPublicKey: PublicKey, resubOpts?: ResubOpts ) { diff --git a/sdk/src/accounts/grpcUserStatsAccountSubscriber.ts b/sdk/src/accounts/grpcUserStatsAccountSubscriber.ts index 2998e5884f..59bd837ffd 100644 --- a/sdk/src/accounts/grpcUserStatsAccountSubscriber.ts +++ b/sdk/src/accounts/grpcUserStatsAccountSubscriber.ts @@ -4,13 +4,14 @@ import { PublicKey } from '@solana/web3.js'; import { UserStatsAccount } from '../types'; import { WebSocketUserStatsAccountSubscriber } from './webSocketUserStatsAccountSubsriber'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; +import { Drift } from '../idl/drift'; export class grpcUserStatsAccountSubscriber extends WebSocketUserStatsAccountSubscriber { private grpcConfigs: GrpcConfigs; public constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: Program, userStatsAccountPublicKey: PublicKey, resubOpts?: ResubOpts ) { diff --git a/sdk/src/accounts/laserProgramAccountSubscriber.ts b/sdk/src/accounts/laserProgramAccountSubscriber.ts index a2315ad92f..059cb40f67 100644 --- a/sdk/src/accounts/laserProgramAccountSubscriber.ts +++ b/sdk/src/accounts/laserProgramAccountSubscriber.ts @@ -13,6 +13,7 @@ import { CompressionAlgorithms, CommitmentLevel, } from '../isomorphic/grpc'; +import { Drift } from '../idl/drift'; type LaserCommitment = (typeof LaserCommitmentLevel)[keyof typeof LaserCommitmentLevel]; @@ -38,7 +39,7 @@ export class LaserstreamProgramAccountSubscriber< commitmentLevel: CommitmentLevel, subscriptionName: string, accountDiscriminator: string, - program: Program, + program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => T, options: { filters: MemcmpFilter[] } = { filters: [] }, resubOpts?: ResubOpts @@ -59,7 +60,7 @@ export class LaserstreamProgramAccountSubscriber< grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, - program: Program, + program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options: { filters: MemcmpFilter[] } = { filters: [], diff --git a/sdk/src/accounts/oneShotUserAccountSubscriber.ts b/sdk/src/accounts/oneShotUserAccountSubscriber.ts index 263bfa03d6..73bdd136ab 100644 --- a/sdk/src/accounts/oneShotUserAccountSubscriber.ts +++ b/sdk/src/accounts/oneShotUserAccountSubscriber.ts @@ -3,6 +3,7 @@ import { UserAccount } from '../types'; import { BasicUserAccountSubscriber } from './basicUserAccountSubscriber'; import { Program } from '@coral-xyz/anchor'; import { UserAccountSubscriber } from './types'; +import { Drift } from '../idl/drift'; /** * Simple implementation of UserAccountSubscriber. It will fetch the UserAccount @@ -13,11 +14,11 @@ export class OneShotUserAccountSubscriber extends BasicUserAccountSubscriber implements UserAccountSubscriber { - program: Program; + program: Program; commitment: Commitment; public constructor( - program: Program, + program: Program, userAccountPublicKey: PublicKey, data?: UserAccount, slot?: number, diff --git a/sdk/src/accounts/oneShotUserStatsAccountSubscriber.ts b/sdk/src/accounts/oneShotUserStatsAccountSubscriber.ts index a464063f6c..e4e9c0c2aa 100644 --- a/sdk/src/accounts/oneShotUserStatsAccountSubscriber.ts +++ b/sdk/src/accounts/oneShotUserStatsAccountSubscriber.ts @@ -1,8 +1,9 @@ import { Commitment, PublicKey } from '@solana/web3.js'; -import { UserStatsAccount } from '../types'; +import { parseUserStatsAccount, UserStatsAccount } from '../types'; import { BasicUserStatsAccountSubscriber } from './basicUserStatsAccountSubscriber'; import { Program } from '@coral-xyz/anchor'; import { UserStatsAccountSubscriber } from './types'; +import { Drift } from '../idl/drift'; /** * Simple implementation of UserStatsAccountSubscriber. It will fetch the UserStatsAccount @@ -13,11 +14,11 @@ export class OneShotUserStatsAccountSubscriber extends BasicUserStatsAccountSubscriber implements UserStatsAccountSubscriber { - program: Program; + program: Program; commitment: Commitment; public constructor( - program: Program, + program: Program, userStatsAccountPublicKey: PublicKey, data?: UserStatsAccount, slot?: number, @@ -56,7 +57,7 @@ export class OneShotUserStatsAccountSubscriber ); if (dataAndContext.context.slot > (this.userStats?.slot ?? 0)) { this.userStats = { - data: dataAndContext.data as UserStatsAccount, + data: parseUserStatsAccount(dataAndContext.data), slot: dataAndContext.context.slot, }; } diff --git a/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts b/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts index 18da8df653..d386ded475 100644 --- a/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts +++ b/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts @@ -30,6 +30,7 @@ import { OracleClientCache } from '../oracles/oracleClientCache'; import { QUOTE_ORACLE_PRICE_DATA } from '../oracles/quoteAssetOracleClient'; import { findAllMarketAndOracles } from '../config'; import { getOracleId } from '../oracles/oracleId'; +import { Drift } from '../idl/drift'; const ORACLE_DEFAULT_ID = getOracleId( PublicKey.default, @@ -40,7 +41,7 @@ export class PollingDriftClientAccountSubscriber implements DriftClientAccountSubscriber { isSubscribed: boolean; - program: Program; + program: Program; perpMarketIndexes: number[]; spotMarketIndexes: number[]; oracleInfos: OracleInfo[]; @@ -71,7 +72,7 @@ export class PollingDriftClientAccountSubscriber private subscriptionPromiseResolver: (val: boolean) => void; public constructor( - program: Program, + program: Program, accountLoader: BulkAccountLoader, perpMarketIndexes: number[], spotMarketIndexes: number[], diff --git a/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts b/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts index 6b7f2a0f65..c06955dced 100644 --- a/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +++ b/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts @@ -10,12 +10,13 @@ import { EventEmitter } from 'events'; import { PublicKey } from '@solana/web3.js'; import { BulkAccountLoader } from './bulkAccountLoader'; import { HighLeverageModeConfig } from '../types'; +import { Drift } from '../idl/drift'; export class PollingHighLeverageModeConfigAccountSubscriber implements HighLeverageModeConfigAccountSubscriber { isSubscribed: boolean; - program: Program; + program: Program; eventEmitter: StrictEventEmitter< EventEmitter, HighLeverageModeConfigAccountEvents @@ -29,7 +30,7 @@ export class PollingHighLeverageModeConfigAccountSubscriber highLeverageModeConfigAccountAndSlot?: DataAndSlot; public constructor( - program: Program, + program: Program, publicKey: PublicKey, accountLoader: BulkAccountLoader ) { @@ -118,7 +119,11 @@ export class PollingHighLeverageModeConfigAccountSubscriber (this.highLeverageModeConfigAccountAndSlot?.slot ?? 0) ) { this.highLeverageModeConfigAccountAndSlot = { - data: dataAndContext.data as HighLeverageModeConfig, + data: { + maxUsers: dataAndContext.data.maxUsers, + currentUsers: dataAndContext.data.currentUsers, + reduceOnly: dataAndContext.data.reduceOnly > 0, + }, slot: dataAndContext.context.slot, }; } diff --git a/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts b/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts index bca1c04ac7..0134b1cfc1 100644 --- a/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +++ b/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts @@ -10,12 +10,13 @@ import { EventEmitter } from 'events'; import { PublicKey } from '@solana/web3.js'; import { BulkAccountLoader } from './bulkAccountLoader'; import { InsuranceFundStake } from '../types'; +import { Drift } from '../idl/drift'; export class PollingInsuranceFundStakeAccountSubscriber implements InsuranceFundStakeAccountSubscriber { isSubscribed: boolean; - program: Program; + program: Program; eventEmitter: StrictEventEmitter< EventEmitter, InsuranceFundStakeAccountEvents @@ -29,7 +30,7 @@ export class PollingInsuranceFundStakeAccountSubscriber insuranceFundStakeAccountAndSlot?: DataAndSlot; public constructor( - program: Program, + program: Program, publicKey: PublicKey, accountLoader: BulkAccountLoader ) { diff --git a/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts b/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts index d146c31dc8..faa2971fa1 100644 --- a/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts +++ b/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts @@ -8,14 +8,15 @@ import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { PublicKey } from '@solana/web3.js'; -import { UserStatsAccount } from '../types'; +import { parseUserStatsAccount, UserStatsAccount } from '../types'; import { BulkAccountLoader } from './bulkAccountLoader'; +import { Drift } from '../idl/drift'; export class PollingUserStatsAccountSubscriber implements UserStatsAccountSubscriber { isSubscribed: boolean; - program: Program; + program: Program; eventEmitter: StrictEventEmitter; userStatsAccountPublicKey: PublicKey; @@ -26,7 +27,7 @@ export class PollingUserStatsAccountSubscriber userStats?: DataAndSlot; public constructor( - program: Program, + program: Program, userStatsAccountPublicKey: PublicKey, accountLoader: BulkAccountLoader ) { @@ -105,7 +106,7 @@ export class PollingUserStatsAccountSubscriber ); if (dataAndContext.context.slot > (this.userStats?.slot ?? 0)) { this.userStats = { - data: dataAndContext.data as UserStatsAccount, + data: parseUserStatsAccount(dataAndContext.data), slot: dataAndContext.context.slot, }; } diff --git a/sdk/src/accounts/webSocketAccountSubscriber.ts b/sdk/src/accounts/webSocketAccountSubscriber.ts index deee456166..a994c37d7c 100644 --- a/sdk/src/accounts/webSocketAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketAccountSubscriber.ts @@ -8,13 +8,14 @@ import { AnchorProvider, Program } from '@coral-xyz/anchor'; import { AccountInfo, Commitment, Context, PublicKey } from '@solana/web3.js'; import { capitalize } from './utils'; import * as Buffer from 'buffer'; +import { Drift } from '../idl/drift'; export class WebSocketAccountSubscriber implements AccountSubscriber { dataAndSlot?: DataAndSlot; bufferAndSlot?: BufferAndSlot; accountName: string; logAccountName: string; - program: Program; + program: Program; accountPublicKey: PublicKey; decodeBufferFn: (buffer: Buffer) => T; onChange: (data: T) => void; @@ -31,7 +32,7 @@ export class WebSocketAccountSubscriber implements AccountSubscriber { public constructor( accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts, diff --git a/sdk/src/accounts/webSocketAccountSubscriberV2.ts b/sdk/src/accounts/webSocketAccountSubscriberV2.ts index c86f7bda06..d12c3064e5 100644 --- a/sdk/src/accounts/webSocketAccountSubscriberV2.ts +++ b/sdk/src/accounts/webSocketAccountSubscriberV2.ts @@ -20,6 +20,7 @@ import { } from 'gill'; import { PublicKey } from '@solana/web3.js'; import bs58 from 'bs58'; +import { Drift } from '../idl/drift'; /** * WebSocketAccountSubscriberV2 @@ -74,7 +75,7 @@ export class WebSocketAccountSubscriberV2 implements AccountSubscriber { bufferAndSlot?: BufferAndSlot; accountName: string; logAccountName: string; - program: Program; + program: Program; accountPublicKey: PublicKey; decodeBufferFn: (buffer: Buffer) => T; onChange: (data: T) => void; @@ -112,7 +113,7 @@ export class WebSocketAccountSubscriberV2 implements AccountSubscriber { */ public constructor( accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts, diff --git a/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts b/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts index 973e5ac007..fd91da4484 100644 --- a/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts @@ -29,6 +29,7 @@ import { findDelistedPerpMarketsAndOracles } from './utils'; import { getOracleId } from '../oracles/oracleId'; import { OracleSource } from '../types'; import { WebSocketAccountSubscriberV2 } from './webSocketAccountSubscriberV2'; +import { Drift } from '../idl/drift'; const ORACLE_DEFAULT_ID = getOracleId( PublicKey.default, @@ -39,7 +40,7 @@ export class WebSocketDriftClientAccountSubscriber implements DriftClientAccountSubscriber { isSubscribed: boolean; - program: Program; + program: Program; commitment?: Commitment; perpMarketIndexes: number[]; spotMarketIndexes: number[]; @@ -71,7 +72,7 @@ export class WebSocketDriftClientAccountSubscriber initialOraclePriceData: Map; customPerpMarketAccountSubscriber?: new ( accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -79,7 +80,7 @@ export class WebSocketDriftClientAccountSubscriber ) => AccountSubscriber; customOracleAccountSubscriber?: new ( accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -91,7 +92,7 @@ export class WebSocketDriftClientAccountSubscriber protected subscriptionPromiseResolver: (val: boolean) => void; public constructor( - program: Program, + program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], @@ -101,7 +102,7 @@ export class WebSocketDriftClientAccountSubscriber commitment?: Commitment, customPerpMarketAccountSubscriber?: new ( accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -109,7 +110,7 @@ export class WebSocketDriftClientAccountSubscriber ) => WebSocketAccountSubscriberV2 | WebSocketAccountSubscriber, customOracleAccountSubscriber?: new ( accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, diff --git a/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts b/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts index 0a37b53d81..502dd0ce6c 100644 --- a/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts +++ b/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts @@ -45,6 +45,7 @@ import { } from '../memcmp'; import { WebSocketProgramAccountsSubscriberV2 } from './webSocketProgramAccountsSubscriberV2'; import { WebSocketAccountSubscriberV2 } from './webSocketAccountSubscriberV2'; +import { Drift } from '../idl/drift'; const ORACLE_DEFAULT_ID = getOracleId( PublicKey.default, OracleSource.QUOTE_ASSET @@ -54,7 +55,7 @@ export class WebSocketDriftClientAccountSubscriberV2 implements DriftClientAccountSubscriber { isSubscribed: boolean; - program: Program; + program: Program; commitment?: Commitment; perpMarketIndexes: number[]; spotMarketIndexes: number[]; @@ -97,7 +98,7 @@ export class WebSocketDriftClientAccountSubscriberV2 string; public constructor( - program: Program, + program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], diff --git a/sdk/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts b/sdk/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts index 0742f6b1fa..17f19913ce 100644 --- a/sdk/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts @@ -11,6 +11,7 @@ import { EventEmitter } from 'events'; import { Commitment, PublicKey } from '@solana/web3.js'; import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { HighLeverageModeConfig } from '../types'; +import { Drift } from '../idl/drift'; export class WebSocketHighLeverageModeConfigAccountSubscriber implements HighLeverageModeConfigAccountSubscriber @@ -18,7 +19,7 @@ export class WebSocketHighLeverageModeConfigAccountSubscriber isSubscribed: boolean; resubTimeoutMs?: number; commitment?: Commitment; - program: Program; + program: Program; eventEmitter: StrictEventEmitter< EventEmitter, HighLeverageModeConfigAccountEvents @@ -28,7 +29,7 @@ export class WebSocketHighLeverageModeConfigAccountSubscriber highLeverageModeConfigDataAccountSubscriber: AccountSubscriber; public constructor( - program: Program, + program: Program, highLeverageModeConfigAccountPublicKey: PublicKey, resubTimeoutMs?: number, commitment?: Commitment diff --git a/sdk/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts b/sdk/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts index bc8042a7ae..f2a731ed39 100644 --- a/sdk/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts @@ -11,6 +11,7 @@ import { EventEmitter } from 'events'; import { Commitment, PublicKey } from '@solana/web3.js'; import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { InsuranceFundStake } from '../types'; +import { Drift } from '../idl/drift'; export class WebSocketInsuranceFundStakeAccountSubscriber implements InsuranceFundStakeAccountSubscriber @@ -18,7 +19,7 @@ export class WebSocketInsuranceFundStakeAccountSubscriber isSubscribed: boolean; resubTimeoutMs?: number; commitment?: Commitment; - program: Program; + program: Program; eventEmitter: StrictEventEmitter< EventEmitter, InsuranceFundStakeAccountEvents @@ -28,7 +29,7 @@ export class WebSocketInsuranceFundStakeAccountSubscriber insuranceFundStakeDataAccountSubscriber: AccountSubscriber; public constructor( - program: Program, + program: Program, insuranceFundStakeAccountPublicKey: PublicKey, resubTimeoutMs?: number, commitment?: Commitment diff --git a/sdk/src/accounts/webSocketProgramAccountSubscriber.ts b/sdk/src/accounts/webSocketProgramAccountSubscriber.ts index d860477583..85a0e8fe95 100644 --- a/sdk/src/accounts/webSocketProgramAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketProgramAccountSubscriber.ts @@ -8,6 +8,7 @@ import { PublicKey, } from '@solana/web3.js'; import * as Buffer from 'buffer'; +import { Drift } from '../idl/drift'; export class WebSocketProgramAccountSubscriber implements ProgramAccountSubscriber @@ -16,7 +17,7 @@ export class WebSocketProgramAccountSubscriber accountDiscriminator: string; bufferAndSlot?: BufferAndSlot; bufferAndSlotMap: Map = new Map(); - program: Program; + program: Program; decodeBuffer: (accountName: string, ix: Buffer) => T; onChange: ( accountId: PublicKey, @@ -35,7 +36,7 @@ export class WebSocketProgramAccountSubscriber public constructor( subscriptionName: string, accountDiscriminator: string, - program: Program, + program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => T, options: { filters: MemcmpFilter[]; commitment?: Commitment } = { filters: [], diff --git a/sdk/src/accounts/webSocketProgramAccountsSubscriberV2.ts b/sdk/src/accounts/webSocketProgramAccountsSubscriberV2.ts index 31a68ce02e..02508638a4 100644 --- a/sdk/src/accounts/webSocketProgramAccountsSubscriberV2.ts +++ b/sdk/src/accounts/webSocketProgramAccountsSubscriberV2.ts @@ -13,6 +13,7 @@ import { Commitment as GillCommitment, } from 'gill'; import bs58 from 'bs58'; +import { Drift } from '../idl/drift'; type ProgramAccountSubscriptionAsyncIterable = AsyncIterable< Readonly<{ @@ -98,7 +99,7 @@ export class WebSocketProgramAccountsSubscriberV2 subscriptionName: string; accountDiscriminator: string; bufferAndSlotMap: Map = new Map(); - program: Program; + program: Program; decodeBuffer: (accountName: string, ix: Buffer) => T; onChange: ( accountId: PublicKey, @@ -142,7 +143,7 @@ export class WebSocketProgramAccountsSubscriberV2 public constructor( subscriptionName: string, accountDiscriminator: string, - program: Program, + program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => T, options: { filters: MemcmpFilter[]; commitment?: Commitment } = { filters: [], diff --git a/sdk/src/accounts/webSocketUserAccountSubscriber.ts b/sdk/src/accounts/webSocketUserAccountSubscriber.ts index 79d6f9401f..766f3c2db7 100644 --- a/sdk/src/accounts/webSocketUserAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketUserAccountSubscriber.ts @@ -12,19 +12,20 @@ import { EventEmitter } from 'events'; import { Commitment, PublicKey } from '@solana/web3.js'; import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { UserAccount } from '../types'; +import { Drift } from '../idl/drift'; export class WebSocketUserAccountSubscriber implements UserAccountSubscriber { isSubscribed: boolean; resubOpts?: ResubOpts; commitment?: Commitment; - program: Program; + program: Program; eventEmitter: StrictEventEmitter; userAccountPublicKey: PublicKey; userDataAccountSubscriber: AccountSubscriber; public constructor( - program: Program, + program: Program, userAccountPublicKey: PublicKey, resubOpts?: ResubOpts, commitment?: Commitment diff --git a/sdk/src/accounts/webSocketUserStatsAccountSubsriber.ts b/sdk/src/accounts/webSocketUserStatsAccountSubsriber.ts index fdc0be5507..b15d91bc31 100644 --- a/sdk/src/accounts/webSocketUserStatsAccountSubsriber.ts +++ b/sdk/src/accounts/webSocketUserStatsAccountSubsriber.ts @@ -12,6 +12,7 @@ import { EventEmitter } from 'events'; import { Commitment, PublicKey } from '@solana/web3.js'; import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { UserStatsAccount } from '../types'; +import { Drift } from '../idl/drift'; export class WebSocketUserStatsAccountSubscriber implements UserStatsAccountSubscriber @@ -19,14 +20,14 @@ export class WebSocketUserStatsAccountSubscriber isSubscribed: boolean; resubOpts?: ResubOpts; commitment?: Commitment; - program: Program; + program: Program; eventEmitter: StrictEventEmitter; userStatsAccountPublicKey: PublicKey; userStatsAccountSubscriber: AccountSubscriber; public constructor( - program: Program, + program: Program, userStatsAccountPublicKey: PublicKey, resubOpts?: ResubOpts, commitment?: Commitment diff --git a/sdk/src/accounts/websocketProgramUserAccountSubscriber.ts b/sdk/src/accounts/websocketProgramUserAccountSubscriber.ts index 6c95afe2d0..74e6e7fd1b 100644 --- a/sdk/src/accounts/websocketProgramUserAccountSubscriber.ts +++ b/sdk/src/accounts/websocketProgramUserAccountSubscriber.ts @@ -10,6 +10,7 @@ import { EventEmitter } from 'events'; import { Context, PublicKey } from '@solana/web3.js'; import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber'; import { UserAccount } from '../types'; +import { Drift } from '../idl/drift'; export class WebSocketProgramUserAccountSubscriber implements UserAccountSubscriber @@ -18,12 +19,12 @@ export class WebSocketProgramUserAccountSubscriber eventEmitter: StrictEventEmitter; private userAccountPublicKey: PublicKey; - private program: Program; + private program: Program; private programSubscriber: WebSocketProgramAccountSubscriber; private userAccountAndSlot?: DataAndSlot; public constructor( - program: Program, + program: Program, userAccountPublicKey: PublicKey, programSubscriber: WebSocketProgramAccountSubscriber ) { diff --git a/sdk/src/adminClient.ts b/sdk/src/adminClient.ts index dd8acc158b..ae9f722072 100644 --- a/sdk/src/adminClient.ts +++ b/sdk/src/adminClient.ts @@ -37,7 +37,6 @@ import { getSerumOpenOrdersPublicKey, getSerumFulfillmentConfigPublicKey, getPhoenixFulfillmentConfigPublicKey, - getProtocolIfSharesTransferConfigPublicKey, getPrelaunchOraclePublicKey, getOpenbookV2FulfillmentConfigPublicKey, getPythPullOraclePublicKey, @@ -48,7 +47,6 @@ import { getFuelOverflowAccountPublicKey, getTokenProgramForSpotMarket, getIfRebalanceConfigPublicKey, - getInsuranceFundStakeAccountPublicKey, getLpPoolPublicKey, getAmmConstituentMappingPublicKey, getConstituentTargetBasePublicKey, @@ -76,14 +74,12 @@ import { ONE, BASE_PRECISION, PRICE_PRECISION, - GOV_SPOT_MARKET_INDEX, } from './constants/numericConstants'; import { calculateTargetPriceTrade } from './math/trade'; import { calculateAmmReservesAfterSwap, getSwapDirection } from './math/amm'; import { PROGRAM_ID as PHOENIX_PROGRAM_ID } from '@ellipsis-labs/phoenix-sdk'; import { DRIFT_ORACLE_RECEIVER_ID } from './config'; import { getFeedIdUint8Array } from './util/pythOracleUtils'; -import { FUEL_RESET_LOG_ACCOUNT } from './constants/txConstants'; import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient'; import { SwapMode } from './swap/UnifiedSwapClient'; @@ -812,30 +808,6 @@ export class AdminClient extends DriftClient { ); } - public async resetAmmCache( - txParams?: TxParams - ): Promise { - const initializeAmmCacheIx = await this.getResetAmmCacheIx(); - const tx = await this.buildTransaction(initializeAmmCacheIx, txParams); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getResetAmmCacheIx(): Promise { - return this.program.instruction.resetAmmCache({ - accounts: { - state: await this.getStatePublicKey(), - admin: this.useHotWalletAdmin - ? this.wallet.publicKey - : this.getStateAccount().admin, - ammCache: getAmmCachePublicKey(this.program.programId), - systemProgram: anchor.web3.SystemProgram.programId, - }, - }); - } - public async initializePredictionMarket( perpMarketIndex: number ): Promise { @@ -1584,26 +1556,6 @@ export class AdminClient extends DriftClient { } ); } - - public async updatePerpMarketTargetBaseAssetAmountPerLp( - perpMarketIndex: number, - targetBaseAssetAmountPerLP: number - ): Promise { - const updatePerpMarketTargetBaseAssetAmountPerLpIx = - await this.getUpdatePerpMarketTargetBaseAssetAmountPerLpIx( - perpMarketIndex, - targetBaseAssetAmountPerLP - ); - - const tx = await this.buildTransaction( - updatePerpMarketTargetBaseAssetAmountPerLpIx - ); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - public async updatePerpMarketAmmSummaryStats( perpMarketIndex: number, updateAmmSummaryStats?: boolean, @@ -1662,27 +1614,6 @@ export class AdminClient extends DriftClient { ); } - public async getUpdatePerpMarketTargetBaseAssetAmountPerLpIx( - perpMarketIndex: number, - targetBaseAssetAmountPerLP: number - ): Promise { - return await this.program.instruction.updatePerpMarketTargetBaseAssetAmountPerLp( - targetBaseAssetAmountPerLP, - { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - perpMarket: await getPerpMarketPublicKey( - this.program.programId, - perpMarketIndex - ), - }, - } - ); - } - public async updatePerpMarketMarginRatio( perpMarketIndex: number, marginRatioInitial: number, @@ -1987,40 +1918,6 @@ export class AdminClient extends DriftClient { }); } - public async updatePerpMarketPerLpBase( - perpMarketIndex: number, - perLpBase: number - ): Promise { - const updatePerpMarketPerLpBaseIx = - await this.getUpdatePerpMarketPerLpBaseIx(perpMarketIndex, perLpBase); - - const tx = await this.buildTransaction(updatePerpMarketPerLpBaseIx); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdatePerpMarketPerLpBaseIx( - perpMarketIndex: number, - perLpBase: number - ): Promise { - const perpMarketPublicKey = await getPerpMarketPublicKey( - this.program.programId, - perpMarketIndex - ); - - return await this.program.instruction.updatePerpMarketPerLpBase(perLpBase, { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - perpMarket: perpMarketPublicKey, - }, - }); - } - public async updatePerpMarketMaxSpread( perpMarketIndex: number, maxSpread: number @@ -2593,33 +2490,6 @@ export class AdminClient extends DriftClient { ); } - public async updateLpCooldownTime( - cooldownTime: BN - ): Promise { - const updateLpCooldownTimeIx = await this.getUpdateLpCooldownTimeIx( - cooldownTime - ); - - const tx = await this.buildTransaction(updateLpCooldownTimeIx); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdateLpCooldownTimeIx( - cooldownTime: BN - ): Promise { - return await this.program.instruction.updateLpCooldownTime(cooldownTime, { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - }, - }); - } - public async updatePerpMarketOracle( perpMarketIndex: number, oracle: PublicKey, @@ -3106,33 +2976,6 @@ export class AdminClient extends DriftClient { }); } - public async updateWhitelistMint( - whitelistMint?: PublicKey - ): Promise { - const updateWhitelistMintIx = await this.getUpdateWhitelistMintIx( - whitelistMint - ); - - const tx = await this.buildTransaction(updateWhitelistMintIx); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdateWhitelistMintIx( - whitelistMint?: PublicKey - ): Promise { - return await this.program.instruction.updateWhitelistMint(whitelistMint, { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - }, - }); - } - public async updateDiscountMint( discountMint: PublicKey ): Promise { @@ -3473,7 +3316,6 @@ export class AdminClient extends DriftClient { this.program.programId, perpMarketIndex ), - ammCache: getAmmCachePublicKey(this.program.programId), }, } ); @@ -3604,40 +3446,6 @@ export class AdminClient extends DriftClient { ); } - public async updateMaxSlippageRatio( - perpMarketIndex: number, - maxSlippageRatio: number - ): Promise { - const updateMaxSlippageRatioIx = await this.getUpdateMaxSlippageRatioIx( - perpMarketIndex, - maxSlippageRatio - ); - - const tx = await this.buildTransaction(updateMaxSlippageRatioIx); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdateMaxSlippageRatioIx( - perpMarketIndex: number, - maxSlippageRatio: number - ): Promise { - return await this.program.instruction.updateMaxSlippageRatio( - maxSlippageRatio, - { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey, - }, - } - ); - } - public async updatePerpMarketUnrealizedAssetWeight( perpMarketIndex: number, unrealizedInitialAssetWeight: number, @@ -3884,32 +3692,6 @@ export class AdminClient extends DriftClient { ); } - public async updateSerumVault( - srmVault: PublicKey - ): Promise { - const updateSerumVaultIx = await this.getUpdateSerumVaultIx(srmVault); - - const tx = await this.buildTransaction(updateSerumVaultIx); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdateSerumVaultIx( - srmVault: PublicKey - ): Promise { - return await this.program.instruction.updateSerumVault(srmVault, { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - srmVault: srmVault, - }, - }); - } - public async updatePerpMarketLiquidationFee( perpMarketIndex: number, liquidatorFee: number, @@ -3994,75 +3776,6 @@ export class AdminClient extends DriftClient { ); } - public async initializeProtocolIfSharesTransferConfig(): Promise { - const initializeProtocolIfSharesTransferConfigIx = - await this.getInitializeProtocolIfSharesTransferConfigIx(); - - const tx = await this.buildTransaction( - initializeProtocolIfSharesTransferConfigIx - ); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getInitializeProtocolIfSharesTransferConfigIx(): Promise { - return await this.program.instruction.initializeProtocolIfSharesTransferConfig( - { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - rent: SYSVAR_RENT_PUBKEY, - systemProgram: anchor.web3.SystemProgram.programId, - protocolIfSharesTransferConfig: - getProtocolIfSharesTransferConfigPublicKey(this.program.programId), - }, - } - ); - } - - public async updateProtocolIfSharesTransferConfig( - whitelistedSigners?: PublicKey[], - maxTransferPerEpoch?: BN - ): Promise { - const updateProtocolIfSharesTransferConfigIx = - await this.getUpdateProtocolIfSharesTransferConfigIx( - whitelistedSigners, - maxTransferPerEpoch - ); - - const tx = await this.buildTransaction( - updateProtocolIfSharesTransferConfigIx - ); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdateProtocolIfSharesTransferConfigIx( - whitelistedSigners?: PublicKey[], - maxTransferPerEpoch?: BN - ): Promise { - return await this.program.instruction.updateProtocolIfSharesTransferConfig( - whitelistedSigners || null, - maxTransferPerEpoch, - { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - protocolIfSharesTransferConfig: - getProtocolIfSharesTransferConfigPublicKey(this.program.programId), - }, - } - ); - } - public async transferProtocolIfSharesToRevenuePool( outMarketIndex: number, inMarketIndex: number, @@ -4263,106 +3976,6 @@ export class AdminClient extends DriftClient { }); } - public async updateSpotMarketFuel( - spotMarketIndex: number, - fuelBoostDeposits?: number, - fuelBoostBorrows?: number, - fuelBoostTaker?: number, - fuelBoostMaker?: number, - fuelBoostInsurance?: number - ): Promise { - const updateSpotMarketFuelIx = await this.getUpdateSpotMarketFuelIx( - spotMarketIndex, - fuelBoostDeposits ?? null, - fuelBoostBorrows ?? null, - fuelBoostTaker ?? null, - fuelBoostMaker ?? null, - fuelBoostInsurance ?? null - ); - - const tx = await this.buildTransaction(updateSpotMarketFuelIx); - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdateSpotMarketFuelIx( - spotMarketIndex: number, - fuelBoostDeposits?: number, - fuelBoostBorrows?: number, - fuelBoostTaker?: number, - fuelBoostMaker?: number, - fuelBoostInsurance?: number - ): Promise { - const spotMarketPublicKey = await getSpotMarketPublicKey( - this.program.programId, - spotMarketIndex - ); - - return await this.program.instruction.updateSpotMarketFuel( - fuelBoostDeposits ?? null, - fuelBoostBorrows ?? null, - fuelBoostTaker ?? null, - fuelBoostMaker ?? null, - fuelBoostInsurance ?? null, - { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - spotMarket: spotMarketPublicKey, - }, - } - ); - } - - public async updatePerpMarketFuel( - perpMarketIndex: number, - fuelBoostTaker?: number, - fuelBoostMaker?: number, - fuelBoostPosition?: number - ): Promise { - const updatePerpMarketFuelIx = await this.getUpdatePerpMarketFuelIx( - perpMarketIndex, - fuelBoostTaker ?? null, - fuelBoostMaker ?? null, - fuelBoostPosition ?? null - ); - - const tx = await this.buildTransaction(updatePerpMarketFuelIx); - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdatePerpMarketFuelIx( - perpMarketIndex: number, - fuelBoostTaker?: number, - fuelBoostMaker?: number, - fuelBoostPosition?: number - ): Promise { - const perpMarketPublicKey = await getPerpMarketPublicKey( - this.program.programId, - perpMarketIndex - ); - - return await this.program.instruction.updatePerpMarketFuel( - fuelBoostTaker ?? null, - fuelBoostMaker ?? null, - fuelBoostPosition ?? null, - { - accounts: { - admin: this.isSubscribed - ? this.getStateAccount().admin - : this.wallet.publicKey, - state: await this.getStatePublicKey(), - perpMarket: perpMarketPublicKey, - }, - } - ); - } - public async updatePerpMarketOracleLowRiskSlotDelayOverride( perpMarketIndex: number, oracleLowRiskSlotDelayOverride: number @@ -4568,64 +4181,6 @@ export class AdminClient extends DriftClient { }); } - public async initUserFuel( - user: PublicKey, - authority: PublicKey, - fuelBonusDeposits?: number, - fuelBonusBorrows?: number, - fuelBonusTaker?: number, - fuelBonusMaker?: number, - fuelBonusInsurance?: number - ): Promise { - const updatePerpMarketFuelIx = await this.getInitUserFuelIx( - user, - authority, - fuelBonusDeposits, - fuelBonusBorrows, - fuelBonusTaker, - fuelBonusMaker, - fuelBonusInsurance - ); - - const tx = await this.buildTransaction(updatePerpMarketFuelIx); - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getInitUserFuelIx( - user: PublicKey, - authority: PublicKey, - fuelBonusDeposits?: number, - fuelBonusBorrows?: number, - fuelBonusTaker?: number, - fuelBonusMaker?: number, - fuelBonusInsurance?: number - ): Promise { - const userStats = await getUserStatsAccountPublicKey( - this.program.programId, - authority - ); - - return await this.program.instruction.initUserFuel( - fuelBonusDeposits || null, - fuelBonusBorrows || null, - fuelBonusTaker || null, - fuelBonusMaker || null, - fuelBonusInsurance || null, - { - accounts: { - admin: this.useHotWalletAdmin - ? this.wallet.publicKey - : this.getStateAccount().admin, - state: await this.getStatePublicKey(), - user, - userStats, - }, - } - ); - } - /** * @param fuelSweepExists - whether the fuel sweep account exists, must provide this if the user has a FuelSweep account in order to properly reset the fuel season * @param authority - the authority to reset fuel for @@ -4670,7 +4225,6 @@ export class AdminClient extends DriftClient { admin: this.useHotWalletAdmin ? this.wallet.publicKey : this.getStateAccount().admin, - logAccount: FUEL_RESET_LOG_ACCOUNT, }, remainingAccounts, }); @@ -5033,36 +4587,6 @@ export class AdminClient extends DriftClient { }); } - public async updateFeatureBitFlagsBuilderReferral( - enable: boolean - ): Promise { - const updateFeatureBitFlagsBuilderReferralIx = - await this.getUpdateFeatureBitFlagsBuilderReferralIx(enable); - - const tx = await this.buildTransaction( - updateFeatureBitFlagsBuilderReferralIx - ); - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdateFeatureBitFlagsBuilderReferralIx( - enable: boolean - ): Promise { - return this.program.instruction.updateFeatureBitFlagsBuilderReferral( - enable, - { - accounts: { - admin: this.useHotWalletAdmin - ? this.wallet.publicKey - : this.getStateAccount().admin, - state: await this.getStatePublicKey(), - }, - } - ); - } - public async updateFeatureBitFlagsMedianTriggerPrice( enable: boolean ): Promise { @@ -5092,55 +4616,6 @@ export class AdminClient extends DriftClient { ); } - public async updateDelegateUserGovTokenInsuranceStake( - authority: PublicKey, - delegate: PublicKey - ): Promise { - const updateDelegateUserGovTokenInsuranceStakeIx = - await this.getUpdateDelegateUserGovTokenInsuranceStakeIx( - authority, - delegate - ); - - const tx = await this.buildTransaction( - updateDelegateUserGovTokenInsuranceStakeIx - ); - const { txSig } = await this.sendTransaction(tx, [], this.opts); - - return txSig; - } - - public async getUpdateDelegateUserGovTokenInsuranceStakeIx( - authority: PublicKey, - delegate: PublicKey - ): Promise { - const marketIndex = GOV_SPOT_MARKET_INDEX; - const spotMarket = this.getSpotMarketAccount(marketIndex); - const ifStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey( - this.program.programId, - delegate, - marketIndex - ); - const userStatsPublicKey = getUserStatsAccountPublicKey( - this.program.programId, - authority - ); - - const ix = - this.program.instruction.getUpdateDelegateUserGovTokenInsuranceStakeIx({ - accounts: { - state: await this.getStatePublicKey(), - spotMarket: spotMarket.pubkey, - insuranceFundStake: ifStakeAccountPublicKey, - userStats: userStatsPublicKey, - signer: this.wallet.publicKey, - insuranceFundVault: spotMarket.insuranceFund.vault, - }, - }); - - return ix; - } - public async depositIntoInsuranceFundStake( marketIndex: number, amount: BN, @@ -5736,7 +5211,6 @@ export class AdminClient extends DriftClient { lpPool, ammConstituentMapping, constituentTargetBase, - rent: SYSVAR_RENT_PUBKEY, systemProgram: SystemProgram.programId, state: await this.getStatePublicKey(), }, diff --git a/sdk/src/config.ts b/sdk/src/config.ts index 0ff967b7ad..4c257d15e2 100644 --- a/sdk/src/config.ts +++ b/sdk/src/config.ts @@ -1,5 +1,10 @@ import { ConfirmOptions, PublicKey } from '@solana/web3.js'; -import { PerpMarketAccount, SpotMarketAccount } from './types'; +import { + PerpMarketAccount, + SpotMarketAccount, + parsePerpMarketAccount, + parseSpotMarketAccount, +} from './types'; import { DevnetPerpMarkets, MainnetPerpMarkets, @@ -19,6 +24,7 @@ import { ON_DEMAND_MAINNET_PID, } from '@switchboard-xyz/on-demand'; import { getOracleId } from './oracles/oracleId'; +import { Drift } from './idl/drift'; type DriftConfig = { ENV: DriftEnv; @@ -167,7 +173,9 @@ export function getMarketsAndOraclesForSubscription( }; } -export async function findAllMarketAndOracles(program: Program): Promise<{ +export async function findAllMarketAndOracles( + program: Program +): Promise<{ perpMarketIndexes: number[]; perpMarketAccounts: PerpMarketAccount[]; spotMarketIndexes: number[]; @@ -178,13 +186,24 @@ export async function findAllMarketAndOracles(program: Program): Promise<{ const spotMarketIndexes = []; const oracleInfos = new Map(); - const perpMarketProgramAccounts = - (await program.account.perpMarket.all()) as ProgramAccount[]; - const spotMarketProgramAccounts = - (await program.account.spotMarket.all()) as ProgramAccount[]; + //@ts-ignore TS2589 + const perpMarketProgramAccountsRaw = await program.account.perpMarket.all(); + //@ts-ignore TS2589 + const spotMarketProgramAccountsRaw = await program.account.spotMarket.all(); + + const perpMarketProgramAccounts: ProgramAccount[] = + perpMarketProgramAccountsRaw.map((account) => ({ + ...account, + account: parsePerpMarketAccount(account.account), + })); + const spotMarketProgramAccounts: ProgramAccount[] = + spotMarketProgramAccountsRaw.map((account) => ({ + ...account, + account: parseSpotMarketAccount(account.account), + })); for (const perpMarketProgramAccount of perpMarketProgramAccounts) { - const perpMarket = perpMarketProgramAccount.account as PerpMarketAccount; + const perpMarket = perpMarketProgramAccount.account; perpMarketIndexes.push(perpMarket.marketIndex); oracleInfos.set( getOracleId(perpMarket.amm.oracle, perpMarket.amm.oracleSource), @@ -196,7 +215,7 @@ export async function findAllMarketAndOracles(program: Program): Promise<{ } for (const spotMarketProgramAccount of spotMarketProgramAccounts) { - const spotMarket = spotMarketProgramAccount.account as SpotMarketAccount; + const spotMarket = spotMarketProgramAccount.account; spotMarketIndexes.push(spotMarket.marketIndex); oracleInfos.set(getOracleId(spotMarket.oracle, spotMarket.oracleSource), { publicKey: spotMarket.oracle, diff --git a/sdk/src/constituentMap/pollingConstituentAccountSubscriber.ts b/sdk/src/constituentMap/pollingConstituentAccountSubscriber.ts index e50b34df4b..8da5e168d0 100644 --- a/sdk/src/constituentMap/pollingConstituentAccountSubscriber.ts +++ b/sdk/src/constituentMap/pollingConstituentAccountSubscriber.ts @@ -8,12 +8,13 @@ import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Commitment, MemcmpFilter } from '@solana/web3.js'; import { ConstituentMap } from './constituentMap'; +import { Drift } from '../idl/drift'; export class PollingConstituentAccountSubscriber implements ConstituentAccountSubscriber { isSubscribed: boolean; - program: Program; + program: Program; frequency: number; commitment?: Commitment; additionalFilters?: MemcmpFilter[]; @@ -24,7 +25,7 @@ export class PollingConstituentAccountSubscriber public constructor( constituentMap: ConstituentMap, - program: Program, + program: Program, frequency: number, commitment?: Commitment, additionalFilters?: MemcmpFilter[] diff --git a/sdk/src/constituentMap/webSocketConstituentAccountSubscriber.ts b/sdk/src/constituentMap/webSocketConstituentAccountSubscriber.ts index 816acd6211..4502867621 100644 --- a/sdk/src/constituentMap/webSocketConstituentAccountSubscriber.ts +++ b/sdk/src/constituentMap/webSocketConstituentAccountSubscriber.ts @@ -11,6 +11,7 @@ import { ConstituentAccount } from '../types'; import { WebSocketProgramAccountSubscriber } from '../accounts/webSocketProgramAccountSubscriber'; import { getConstituentFilter } from '../memcmp'; import { ConstituentMap } from './constituentMap'; +import { Drift } from '../idl/drift'; export class WebSocketConstituentAccountSubscriber implements ConstituentAccountSubscriber @@ -18,7 +19,7 @@ export class WebSocketConstituentAccountSubscriber isSubscribed: boolean; resubTimeoutMs?: number; commitment?: Commitment; - program: Program; + program: Program; eventEmitter: StrictEventEmitter; constituentDataAccountSubscriber: WebSocketProgramAccountSubscriber; @@ -27,7 +28,7 @@ export class WebSocketConstituentAccountSubscriber public constructor( constituentMap: ConstituentMap, - program: Program, + program: Program, resubTimeoutMs?: number, commitment?: Commitment, additionalFilters?: MemcmpFilter[] diff --git a/sdk/src/decode/customCoder.ts b/sdk/src/decode/customCoder.ts index bf24f990a0..f39c7e5081 100644 --- a/sdk/src/decode/customCoder.ts +++ b/sdk/src/decode/customCoder.ts @@ -1,15 +1,15 @@ import { Buffer } from 'buffer'; import camelcase from 'camelcase'; -import { Idl, IdlTypeDef } from '@coral-xyz/anchor/dist/cjs/idl'; +import { Idl, IdlTypeDef } from '@coral-xyz/anchor-29/dist/cjs/idl'; import { AccountsCoder, BorshAccountsCoder, BorshEventCoder, BorshInstructionCoder, Coder, -} from '@coral-xyz/anchor/dist/cjs/coder'; -import { BorshTypesCoder } from '@coral-xyz/anchor/dist/cjs/coder/borsh/types'; -import { discriminator } from '@coral-xyz/anchor/dist/cjs/coder/borsh/discriminator'; +} from '@coral-xyz/anchor-29/dist/cjs/coder'; +import { BorshTypesCoder } from '@coral-xyz/anchor-29/dist/cjs/coder/borsh/types'; +import { discriminator } from '@coral-xyz/anchor-29/dist/cjs/coder/borsh/discriminator'; export class CustomBorshCoder< A extends string = string, diff --git a/sdk/src/decode/user.ts b/sdk/src/decode/user.ts index 62af46d79e..8ebca783de 100644 --- a/sdk/src/decode/user.ts +++ b/sdk/src/decode/user.ts @@ -133,7 +133,6 @@ export function decodeUser(buffer: Buffer): UserAccount { openAsks, settledPnl, lpShares, - remainderBaseAssetAmount: 0, lastBaseAssetAmountPerLp, lastQuoteAssetAmountPerLp, marketIndex, diff --git a/sdk/src/driftClient.ts b/sdk/src/driftClient.ts index eabb861885..9223cb77b2 100644 --- a/sdk/src/driftClient.ts +++ b/sdk/src/driftClient.ts @@ -6,7 +6,7 @@ import { Program, ProgramAccount, } from '@coral-xyz/anchor'; -import { Idl as Idl30, Program as Program30 } from '@coral-xyz/anchor-30'; +import { Program as Program20 } from '@coral-xyz/anchor-29'; import bs58 from 'bs58'; import { ASSOCIATED_TOKEN_PROGRAM_ID, @@ -61,6 +61,7 @@ import { TxParams, UserAccount, UserStatsAccount, + parseUserStatsAccount, ProtectedMakerModeConfig, SignedMsgOrderParamsDelegateMessage, TokenProgramFlag, @@ -161,7 +162,6 @@ import { configs, DRIFT_ORACLE_RECEIVER_ID, DEFAULT_CONFIRMATION_OPTS, - DRIFT_PROGRAM_ID, DriftEnv, PYTH_LAZER_STORAGE_ACCOUNT_KEY, } from './config'; @@ -204,7 +204,7 @@ import { MAX_TX_BYTE_SIZE, } from './tx/utils'; import pythSolanaReceiverIdl from './idl/pyth_solana_receiver.json'; -import { asV0Tx, PullFeed, AnchorUtils } from '@switchboard-xyz/on-demand'; +import { PullFeed } from '@switchboard-xyz/on-demand'; import { grpcDriftClientAccountSubscriber } from './accounts/grpcDriftClientAccountSubscriber'; import nacl from 'tweetnacl'; import { Slothash } from './slot/SlothashSubscriber'; @@ -221,6 +221,7 @@ import { } from './math/builder'; import { TitanClient, SwapMode as TitanSwapMode } from './titan/titanClient'; import { UnifiedSwapClient } from './swap/UnifiedSwapClient'; +import { Drift } from './idl/drift'; /** * Union type for swap clients (Titan and Jupiter) - Legacy type @@ -244,7 +245,7 @@ type RemainingAccountParams = { export class DriftClient { connection: Connection; wallet: IWallet; - public program: Program; + public program: Program; provider: AnchorProvider; env: DriftEnv; opts?: ConfirmOptions; @@ -285,10 +286,10 @@ export class DriftClient { txHandler: TxHandler; - receiverProgram?: Program; - wormholeProgram?: Program; + receiverProgram?: Program20; + wormholeProgram?: Program20; sbOnDemandProgramdId: PublicKey; - sbOnDemandProgram?: Program30; + sbOnDemandProgram?: Program; sbProgramFeedConfigs?: Map; public get isSubscribed() { @@ -318,12 +319,7 @@ export class DriftClient { config.wallet, this.opts ); - this.program = new Program( - driftIDL as Idl, - config.programID ?? new PublicKey(DRIFT_PROGRAM_ID), - this.provider, - config.coder - ); + this.program = new Program(driftIDL, this.provider, config.coder); this.authority = config.authority ?? this.wallet.publicKey; this.activeSubAccountId = config.activeSubAccountId ?? 0; @@ -823,11 +819,7 @@ export class DriftClient { newWallet, this.opts ); - const newProgram = new Program( - driftIDL as Idl, - this.program.programId, - newProvider - ); + const newProgram = new Program(driftIDL, newProvider); this.skipLoadUsers = false; // Update provider for txSender with new wallet details @@ -1339,37 +1331,6 @@ export class DriftClient { }); } - public async migrateReferrer( - authority: PublicKey, - txParams?: TxParams - ): Promise { - const ix = await this.getMigrateReferrerIx(authority); - const tx = await this.buildTransaction([ix], txParams); - const { txSig } = await this.sendTransaction(tx, [], this.opts); - return txSig; - } - - public async getMigrateReferrerIx( - authority: PublicKey - ): Promise { - const escrow = getRevenueShareEscrowAccountPublicKey( - this.program.programId, - authority - ); - return this.program.instruction.migrateReferrer({ - accounts: { - escrow, - authority, - userStats: getUserStatsAccountPublicKey( - this.program.programId, - authority - ), - state: await this.getStatePublicKey(), - payer: this.wallet.publicKey, - }, - }); - } - public async resizeRevenueShareEscrowOrders( authority: PublicKey, numOrders: number, @@ -1932,43 +1893,6 @@ export class DriftClient { return txSig; } - public async updateUserAdvancedLp( - updates: { advancedLp: boolean; subAccountId: number }[] - ): Promise { - const ixs = await Promise.all( - updates.map(async ({ advancedLp, subAccountId }) => { - return await this.getUpdateAdvancedDlpIx(advancedLp, subAccountId); - }) - ); - - const tx = await this.buildTransaction(ixs, this.txParams); - - const { txSig } = await this.sendTransaction(tx, [], this.opts); - return txSig; - } - - public async getUpdateAdvancedDlpIx( - advancedLp: boolean, - subAccountId: number - ) { - const ix = await this.program.instruction.updateUserAdvancedLp( - subAccountId, - advancedLp, - { - accounts: { - user: getUserAccountPublicKeySync( - this.program.programId, - this.wallet.publicKey, - subAccountId - ), - authority: this.wallet.publicKey, - }, - } - ); - - return ix; - } - public async updateUserReduceOnly( updates: { reduceOnly: boolean; subAccountId: number }[] ): Promise { @@ -2119,8 +2043,8 @@ export class DriftClient { }, ]); - return programAccounts.map( - (programAccount) => programAccount.account as UserStatsAccount + return programAccounts.map((programAccount) => + parseUserStatsAccount(programAccount.account) ); } @@ -2298,7 +2222,6 @@ export class DriftClient { public async getSignedMsgUserOrdersDeletionIx(authority: PublicKey) { const ix = await this.program.instruction.deleteSignedMsgUserOrders({ accounts: { - user: authority, signedMsgUserOrders: getSignedMsgUserAccountPublicKey( this.program.programId, authority @@ -3120,7 +3043,6 @@ export class DriftClient { { accounts: { state: await this.getStatePublicKey(), - spotMarket: spotMarketAccount.pubkey, spotMarketVault: spotMarketAccount.vault, user: userAccountPublicKey, userStats: this.getUserStatsAccountPublicKey(), @@ -3773,7 +3695,6 @@ export class DriftClient { { accounts: { state: await this.getStatePublicKey(), - spotMarket: spotMarketAccount.pubkey, spotMarketVault: spotMarketAccount.vault, driftSigner: this.getSignerPublicKey(), user, @@ -4111,197 +4032,6 @@ export class DriftClient { }); } - public async settleLP( - settleeUserAccountPublicKey: PublicKey, - marketIndex: number, - txParams?: TxParams - ): Promise { - const { txSig } = await this.sendTransaction( - await this.buildTransaction( - await this.settleLPIx(settleeUserAccountPublicKey, marketIndex), - txParams - ), - [], - this.opts - ); - return txSig; - } - - public async settleLPIx( - settleeUserAccountPublicKey: PublicKey, - marketIndex: number - ): Promise { - const settleeUserAccount = (await this.program.account.user.fetch( - settleeUserAccountPublicKey - )) as UserAccount; - - const remainingAccounts = this.getRemainingAccounts({ - userAccounts: [settleeUserAccount], - writablePerpMarketIndexes: [marketIndex], - }); - - return this.program.instruction.settleLp(marketIndex, { - accounts: { - state: await this.getStatePublicKey(), - user: settleeUserAccountPublicKey, - }, - remainingAccounts: remainingAccounts, - }); - } - - public async removePerpLpShares( - marketIndex: number, - sharesToBurn?: BN, - txParams?: TxParams, - subAccountId?: number - ): Promise { - const { txSig } = await this.sendTransaction( - await this.buildTransaction( - await this.getRemovePerpLpSharesIx( - marketIndex, - sharesToBurn, - subAccountId - ), - txParams - ), - [], - this.opts - ); - return txSig; - } - - public async removePerpLpSharesInExpiringMarket( - marketIndex: number, - userAccountPublicKey: PublicKey, - sharesToBurn?: BN, - txParams?: TxParams - ): Promise { - const { txSig } = await this.sendTransaction( - await this.buildTransaction( - await this.getRemovePerpLpSharesInExpiringMarket( - marketIndex, - userAccountPublicKey, - sharesToBurn - ), - txParams - ), - [], - this.opts - ); - return txSig; - } - - public async getRemovePerpLpSharesInExpiringMarket( - marketIndex: number, - userAccountPublicKey: PublicKey, - sharesToBurn?: BN - ): Promise { - const userAccount = (await this.program.account.user.fetch( - userAccountPublicKey - )) as UserAccount; - - const remainingAccounts = this.getRemainingAccounts({ - userAccounts: [userAccount], - writablePerpMarketIndexes: [marketIndex], - }); - - if (sharesToBurn == undefined) { - const perpPosition = userAccount.perpPositions.filter( - (position) => position.marketIndex === marketIndex - )[0]; - sharesToBurn = perpPosition.lpShares; - console.log('burning lp shares:', sharesToBurn.toString()); - } - - return this.program.instruction.removePerpLpSharesInExpiringMarket( - sharesToBurn, - marketIndex, - { - accounts: { - state: await this.getStatePublicKey(), - user: userAccountPublicKey, - }, - remainingAccounts: remainingAccounts, - } - ); - } - - public async getRemovePerpLpSharesIx( - marketIndex: number, - sharesToBurn?: BN, - subAccountId?: number - ): Promise { - const user = await this.getUserAccountPublicKey(subAccountId); - - const remainingAccounts = this.getRemainingAccounts({ - userAccounts: [this.getUserAccount(subAccountId)], - useMarketLastSlotCache: true, - writablePerpMarketIndexes: [marketIndex], - }); - - if (sharesToBurn == undefined) { - const userAccount = this.getUserAccount(subAccountId); - const perpPosition = userAccount.perpPositions.filter( - (position) => position.marketIndex === marketIndex - )[0]; - sharesToBurn = perpPosition.lpShares; - console.log('burning lp shares:', sharesToBurn.toString()); - } - - return this.program.instruction.removePerpLpShares( - sharesToBurn, - marketIndex, - { - accounts: { - state: await this.getStatePublicKey(), - user, - authority: this.wallet.publicKey, - }, - remainingAccounts: remainingAccounts, - } - ); - } - - public async addPerpLpShares( - amount: BN, - marketIndex: number, - txParams?: TxParams, - subAccountId?: number - ): Promise { - const { txSig, slot } = await this.sendTransaction( - await this.buildTransaction( - await this.getAddPerpLpSharesIx(amount, marketIndex, subAccountId), - txParams - ), - [], - this.opts - ); - this.perpMarketLastSlotCache.set(marketIndex, slot); - return txSig; - } - - public async getAddPerpLpSharesIx( - amount: BN, - marketIndex: number, - subAccountId?: number - ): Promise { - const user = await this.getUserAccountPublicKey(subAccountId); - const remainingAccounts = this.getRemainingAccounts({ - userAccounts: [this.getUserAccount(subAccountId)], - useMarketLastSlotCache: true, - writablePerpMarketIndexes: [marketIndex], - }); - - return this.program.instruction.addPerpLpShares(amount, marketIndex, { - accounts: { - state: await this.getStatePublicKey(), - user, - authority: this.wallet.publicKey, - }, - remainingAccounts: remainingAccounts, - }); - } - public getQuoteValuePerLpShare(marketIndex: number): BN { const perpMarketAccount = this.getPerpMarketAccount(marketIndex); @@ -4596,7 +4326,6 @@ export class DriftClient { accounts: { state: await this.getStatePublicKey(), user, - userStats: this.getUserStatsAccountPublicKey(), authority: this.wallet.publicKey, }, remainingAccounts, @@ -4787,10 +4516,6 @@ export class DriftClient { subAccountId?: number ): Promise { const user = await this.getUserAccountPublicKey(subAccountId); - - const order = this.getOrderByUserId(userOrderId); - const oracle = this.getPerpMarketAccount(order.marketIndex).amm.oracle; - const remainingAccounts = this.getRemainingAccounts({ userAccounts: [this.getUserAccount(subAccountId)], useMarketLastSlotCache: true, @@ -4801,7 +4526,6 @@ export class DriftClient { state: await this.getStatePublicKey(), user, authority: this.wallet.publicKey, - oracle, }, remainingAccounts, }); @@ -5059,7 +4783,6 @@ export class DriftClient { accounts: { state: await this.getStatePublicKey(), user, - userStats: this.getUserStatsAccountPublicKey(), authority, }, remainingAccounts, @@ -5111,7 +4834,6 @@ export class DriftClient { accounts: { state: await this.getStatePublicKey(), user, - userStats: this.getUserStatsAccountPublicKey(), authority: this.wallet.publicKey, }, remainingAccounts, @@ -5370,7 +5092,6 @@ export class DriftClient { accounts: { state: await this.getStatePublicKey(), user: userAccountPublicKey, - userStats: this.getUserStatsAccountPublicKey(), authority: this.wallet.publicKey, }, remainingAccounts, @@ -6690,54 +6411,6 @@ export class DriftClient { }); } - /* Deprecated */ - public async updateUserFuelBonus( - userAccountPublicKey: PublicKey, - user: UserAccount, - userAuthority: PublicKey, - txParams?: TxParams - ): Promise { - const { txSig } = await this.sendTransaction( - await this.buildTransaction( - await this.getUpdateUserFuelBonusIx( - userAccountPublicKey, - user, - userAuthority - ), - txParams - ), - [], - this.opts - ); - return txSig; - } - - /* Deprecated */ - public async getUpdateUserFuelBonusIx( - userAccountPublicKey: PublicKey, - userAccount: UserAccount, - userAuthority: PublicKey - ): Promise { - const userStatsAccountPublicKey = getUserStatsAccountPublicKey( - this.program.programId, - userAuthority - ); - - const remainingAccounts = this.getRemainingAccounts({ - userAccounts: [userAccount], - }); - - return await this.program.instruction.updateUserFuelBonus({ - accounts: { - state: await this.getStatePublicKey(), - user: userAccountPublicKey, - userStats: userStatsAccountPublicKey, - authority: this.wallet.publicKey, - }, - remainingAccounts, - }); - } - public async updateUserStatsReferrerStatus( userAuthority: PublicKey, txParams?: TxParams @@ -6770,49 +6443,6 @@ export class DriftClient { }); } - public async updateUserOpenOrdersCount( - userAccountPublicKey: PublicKey, - user: UserAccount, - txParams?: TxParams, - fillerPublicKey?: PublicKey - ): Promise { - const { txSig } = await this.sendTransaction( - await this.buildTransaction( - await this.getUpdateUserOpenOrdersCountIx( - userAccountPublicKey, - user, - fillerPublicKey - ), - txParams - ), - [], - this.opts - ); - return txSig; - } - - public async getUpdateUserOpenOrdersCountIx( - userAccountPublicKey: PublicKey, - userAccount: UserAccount, - fillerPublicKey?: PublicKey - ): Promise { - const filler = fillerPublicKey ?? (await this.getUserAccountPublicKey()); - - const remainingAccounts = this.getRemainingAccounts({ - userAccounts: [userAccount], - }); - - return await this.program.instruction.updateUserOpenOrdersCount({ - accounts: { - state: await this.getStatePublicKey(), - filler, - user: userAccountPublicKey, - authority: this.wallet.publicKey, - }, - remainingAccounts, - }); - } - public async placeAndTakePerpOrder( orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], @@ -8076,7 +7706,6 @@ export class DriftClient { accounts: { state: await this.getStatePublicKey(), user: userPubKey, - userStats: this.getUserStatsAccountPublicKey(), authority, }, remainingAccounts, @@ -8201,7 +7830,6 @@ export class DriftClient { accounts: { state: await this.getStatePublicKey(), user, - userStats: this.getUserStatsAccountPublicKey(), authority: this.wallet.publicKey, }, remainingAccounts, @@ -10076,7 +9704,6 @@ export class DriftClient { amount, { accounts: { - state: await this.getStatePublicKey(), spotMarket: spotMarketAccount.pubkey, insuranceFundStake: ifStakeAccountPublicKey, userStats: getUserStatsAccountPublicKey( @@ -10111,7 +9738,6 @@ export class DriftClient { marketIndex, { accounts: { - state: await this.getStatePublicKey(), spotMarket: spotMarketAccount.pubkey, insuranceFundStake: ifStakeAccountPublicKey, userStats: getUserStatsAccountPublicKey( @@ -10562,9 +10188,9 @@ export class DriftClient { return undefined; } - public getReceiverProgram(): Program { + public getReceiverProgram(): Program20 { if (this.receiverProgram === undefined) { - this.receiverProgram = new Program( + this.receiverProgram = new Program20( pythSolanaReceiverIdl as PythSolanaReceiver, DEFAULT_RECEIVER_PROGRAM_ID, this.provider @@ -10573,10 +10199,11 @@ export class DriftClient { return this.receiverProgram; } - public async getSwitchboardOnDemandProgram(): Promise> { + public async getSwitchboardOnDemandProgram(): Promise> { if (this.sbOnDemandProgram === undefined) { - this.sbOnDemandProgram = await AnchorUtils.loadProgramFromConnection( - this.connection + this.sbOnDemandProgram = await Program.at( + this.sbOnDemandProgramdId, + this.provider ); } return this.sbOnDemandProgram; @@ -10853,9 +10480,12 @@ export class DriftClient { numSignatures = 3 ): Promise { const program = await this.getSwitchboardOnDemandProgram(); + const pullFeeds = feeds.map((f) => { + return new PullFeed(program, f); + }); const [pullIxs, _luts, _rawResponse] = await PullFeed.fetchUpdateManyLightIx(program, { - feeds, + feeds: pullFeeds, numSignatures, recentSlothashes: recentSlothash ? [[new BN(recentSlothash.slot), recentSlothash.hash]] @@ -10869,65 +10499,6 @@ export class DriftClient { return pullIxs; } - // @deprecated use getPostManySwitchboardOnDemandUpdatesAtomicIxs instead. This function no longer returns the required ixs due to upstream sdk changes. - public async getPostSwitchboardOnDemandUpdateAtomicIx( - feed: PublicKey, - recentSlothash?: Slothash, - numSignatures = 3 - ): Promise { - const program = await this.getSwitchboardOnDemandProgram(); - const feedAccount = new PullFeed(program, feed); - if (!this.sbProgramFeedConfigs) { - this.sbProgramFeedConfigs = new Map(); - } - if (!this.sbProgramFeedConfigs.has(feedAccount.pubkey.toString())) { - const feedConfig = await feedAccount.loadConfigs(); - this.sbProgramFeedConfigs.set(feed.toString(), feedConfig); - } - const [pullIx, _responses, success] = await PullFeed.fetchUpdateManyIx( - program, - { - feeds: [feed], - numSignatures, - recentSlothashes: recentSlothash - ? [[new BN(recentSlothash.slot), recentSlothash.hash]] - : undefined, - } - ); - if (!success) { - return undefined; - } - return pullIx[0]; - } - - public async postSwitchboardOnDemandUpdate( - feed: PublicKey, - recentSlothash?: Slothash, - numSignatures = 3 - ): Promise { - const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx( - feed, - recentSlothash, - numSignatures - ); - if (!pullIx) { - return undefined; - } - const tx = await asV0Tx({ - connection: this.connection, - ixs: [pullIx], - payer: this.wallet.publicKey, - computeUnitLimitMultiple: 1.3, - lookupTables: await this.fetchAllLookupTableAccounts(), - }); - const { txSig } = await this.sendTransaction(tx, [], { - commitment: 'processed', - skipPreflight: true, - maxRetries: 0, - }); - return txSig; - } - private async getBuildEncodedVaaIxs( vaa: Buffer, guardianSet: PublicKey @@ -10935,7 +10506,7 @@ export class DriftClient { const postIxs: TransactionInstruction[] = []; if (this.wormholeProgram === undefined) { - this.wormholeProgram = new Program( + this.wormholeProgram = new Program20( wormholeCoreBridgeIdl, DEFAULT_WORMHOLE_PROGRAM_ID, this.provider @@ -11115,14 +10686,22 @@ export class DriftClient { const config = await this.program.account.highLeverageModeConfig.fetch( getHighLeverageModeConfigPublicKey(this.program.programId) ); - return config as HighLeverageModeConfig; + return { + maxUsers: config.maxUsers, + currentUsers: config.currentUsers, + reduceOnly: config.reduceOnly > 0, + }; } public async fetchProtectedMakerModeConfig(): Promise { const config = await this.program.account.protectedMakerModeConfig.fetch( getProtectedMakerModeConfigPublicKey(this.program.programId) ); - return config as ProtectedMakerModeConfig; + return { + maxUsers: config.maxUsers, + currentUsers: config.currentUsers, + reduceOnly: config.reduceOnly > 0, + }; } public async updateUserProtectedMakerOrders( @@ -11309,9 +10888,38 @@ export class DriftClient { } public async getLpPoolAccount(lpPoolId: number): Promise { - return (await this.program.account.lpPool.fetch( + const lpPool = await this.program.account.lpPool.fetch( getLpPoolPublicKey(this.program.programId, lpPoolId) - )) as LPPoolAccount; + ); + + return { + lpPoolId: lpPool.lpPoolId, + pubkey: lpPool.pubkey, + mint: lpPool.mint, + whitelistMint: lpPool.whitelistMint, + constituentTargetBase: lpPool.constituentTargetBase, + constituentCorrelations: lpPool.constituentCorrelations, + maxAum: new BN(lpPool.maxAum[0]), + lastAum: new BN(lpPool.lastAum[0]), + cumulativeQuoteSentToPerpMarkets: new BN( + lpPool.cumulativeQuoteSentToPerpMarkets[0] + ), + cumulativeQuoteReceivedFromPerpMarkets: new BN( + lpPool.cumulativeQuoteReceivedFromPerpMarkets[0] + ), + totalMintRedeemFeesPaid: new BN(lpPool.totalMintRedeemFeesPaid[0]), + lastAumSlot: new BN(lpPool.lastAumSlot), + maxSettleQuoteAmount: new BN(lpPool.maxSettleQuoteAmount), + mintRedeemId: new BN(lpPool.mintRedeemId), + settleId: new BN(lpPool.settleId), + minMintFee: new BN(lpPool.minMintFee), + tokenSupply: new BN(lpPool.tokenSupply), + volatility: new BN(lpPool.volatility), + constituents: lpPool.constituents, + bump: lpPool.bump, + gammaExecution: lpPool.gammaExecution, + xi: lpPool.xi, + }; } public async getConstituentTargetBaseAccount( diff --git a/sdk/src/driftClientConfig.ts b/sdk/src/driftClientConfig.ts index 4ca3a8a9eb..17869defe6 100644 --- a/sdk/src/driftClientConfig.ts +++ b/sdk/src/driftClientConfig.ts @@ -25,6 +25,7 @@ import { grpcMultiUserAccountSubscriber } from './accounts/grpcMultiUserAccountS import { WebSocketProgramAccountSubscriber } from './accounts/webSocketProgramAccountSubscriber'; import { WebSocketDriftClientAccountSubscriber } from './accounts/webSocketDriftClientAccountSubscriber'; import { WebSocketDriftClientAccountSubscriberV2 } from './accounts/webSocketDriftClientAccountSubscriberV2'; +import { Drift } from './idl/drift'; export type DriftClientConfig = { connection: Connection; @@ -65,7 +66,7 @@ export type DriftClientSubscriptionConfig = logResubMessages?: boolean; driftClientAccountSubscriber?: new ( grpcConfigs: GrpcConfigs, - program: Program, + program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], @@ -84,7 +85,7 @@ export type DriftClientSubscriptionConfig = programUserAccountSubscriber?: WebSocketProgramAccountSubscriber; perpMarketAccountSubscriber?: new ( accountName: string, - program: Program, + program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -92,7 +93,7 @@ export type DriftClientSubscriptionConfig = ) => WebSocketAccountSubscriberV2 | WebSocketAccountSubscriber; /** If you use V2 here, whatever you pass for perpMarketAccountSubscriber will be ignored and it will use v2 under the hood regardless */ driftClientAccountSubscriber?: new ( - program: Program, + program: Program, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], diff --git a/sdk/src/events/fetchLogs.ts b/sdk/src/events/fetchLogs.ts index fa01d645ce..d8d7980fce 100644 --- a/sdk/src/events/fetchLogs.ts +++ b/sdk/src/events/fetchLogs.ts @@ -1,4 +1,4 @@ -import { Program } from '@coral-xyz/anchor'; +import { Program } from '@coral-xyz/anchor-29'; import { Connection, Finality, diff --git a/sdk/src/events/parse.ts b/sdk/src/events/parse.ts index 96223134e3..9bc4849e6b 100644 --- a/sdk/src/events/parse.ts +++ b/sdk/src/events/parse.ts @@ -1,4 +1,4 @@ -import { Program, Event } from '@coral-xyz/anchor'; +import { Program, Event } from '@coral-xyz/anchor-29'; import { CuUsageEvent } from './types'; const driftProgramId = 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; diff --git a/sdk/src/factory/oracleClient.ts b/sdk/src/factory/oracleClient.ts index c1e777c6bb..492edcfcfc 100644 --- a/sdk/src/factory/oracleClient.ts +++ b/sdk/src/factory/oracleClient.ts @@ -10,11 +10,12 @@ import { SwitchboardClient } from '../oracles/switchboardClient'; import { PythPullClient } from '../oracles/pythPullClient'; import { SwitchboardOnDemandClient } from '../oracles/switchboardOnDemandClient'; import { PythLazerClient } from '../oracles/pythLazerClient'; +import { Drift } from '../idl/drift'; export function getOracleClient( oracleSource: OracleSource, connection: Connection, - program: Program + program: Program ): OracleClient { if (isVariant(oracleSource, 'pyth')) { return new PythClient(connection); diff --git a/sdk/src/idl/drift.json b/sdk/src/idl/drift.json index b55a69fc48..aede7f9a7d 100644 --- a/sdk/src/idl/drift.json +++ b/sdk/src/idl/drift.json @@ -1,1801 +1,2693 @@ { - "version": "2.150.0", - "name": "drift", + "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH", + "metadata": { + "name": "drift", + "version": "2.150.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, "instructions": [ { - "name": "initializeUser", + "name": "add_amm_constituent_mapping_data", + "discriminator": [ + 164, + 236, + 130, + 40, + 118, + 179, + 46, + 235 + ], "accounts": [ { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "lp_pool" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "amm_constituent_mapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "constituent_target_base", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "name", + "name": "amm_constituent_mapping_data", "type": { - "array": [ - "u8", - 32 - ] + "vec": { + "defined": { + "name": "AddAmmConstituentMappingDatum" + } + } } } ] }, { - "name": "initializeUserStats", + "name": "add_insurance_fund_stake", + "discriminator": [ + 251, + 144, + 115, + 11, + 222, + 47, + 62, + 236 + ], "accounts": [ { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "insurance_fund_stake", + "writable": true }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "user_stats", + "writable": true }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true, + "relations": [ + "insurance_fund_stake", + "user_stats" + ] }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "initializeSignedMsgUserOrders", - "accounts": [ - { - "name": "signedMsgUserOrders", - "isMut": true, - "isSigner": false + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": false + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "drift_signer" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "user_token_account", + "writable": true }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "numOrders", + "name": "market_index", "type": "u16" + }, + { + "name": "amount", + "type": "u64" } ] }, { - "name": "resizeSignedMsgUserOrders", + "name": "add_market_to_amm_cache", + "discriminator": [ + 112, + 149, + 195, + 222, + 124, + 7, + 87, + 237 + ], "accounts": [ { - "name": "signedMsgUserOrders", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "user", - "isMut": false, - "isSigner": false + "name": "amm_cache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "perp_market" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, { - "name": "numOrders", - "type": "u16" + "name": "system_program", + "address": "11111111111111111111111111111111" } - ] + ], + "args": [] }, { - "name": "initializeSignedMsgWsDelegates", + "name": "admin_deposit", + "discriminator": [ + 210, + 66, + 65, + 182, + 102, + 214, + 176, + 30 + ], "accounts": [ { - "name": "signedMsgWsDelegates", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "authority", - "isMut": true, - "isSigner": true + "name": "user", + "writable": true }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, + { + "name": "admin_token_account", + "writable": true }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "delegates", - "type": { - "vec": "publicKey" - } + "name": "market_index", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" } ] }, { - "name": "changeSignedMsgWsDelegateStatus", + "name": "admin_disable_update_perp_bid_ask_twap", + "discriminator": [ + 17, + 164, + 82, + 45, + 183, + 86, + 191, + 199 + ], "accounts": [ { - "name": "signedMsgWsDelegates", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true }, { - "name": "authority", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true } ], "args": [ { - "name": "delegate", - "type": "publicKey" - }, - { - "name": "add", + "name": "disable", "type": "bool" } ] }, { - "name": "initializeFuelOverflow", + "name": "begin_insurance_fund_swap", + "discriminator": [ + 176, + 69, + 143, + 205, + 32, + 132, + 163, + 0 + ], "accounts": [ { - "name": "fuelOverflow", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "authority", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": false + "name": "out_insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "in_insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "out_token_account", + "writable": true }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "sweepFuel", - "accounts": [ + "name": "in_token_account", + "writable": true + }, { - "name": "fuelOverflow", - "isMut": true, - "isSigner": false + "name": "if_rebalance_config", + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "token_program" }, { - "name": "authority", - "isMut": false, - "isSigner": false + "name": "drift_signer" }, { - "name": "signer", - "isMut": false, - "isSigner": true + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" } ], - "args": [] - }, - { - "name": "resetFuelSeason", - "accounts": [ - { - "name": "userStats", - "isMut": true, - "isSigner": false - }, + "args": [ { - "name": "authority", - "isMut": false, - "isSigner": false + "name": "in_market_index", + "type": "u16" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "out_market_index", + "type": "u16" }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "amount_in", + "type": "u64" } - ], - "args": [] + ] }, { - "name": "initializeReferrerName", + "name": "begin_lp_swap", + "discriminator": [ + 64, + 44, + 24, + 199, + 48, + 125, + 67, + 91 + ], "accounts": [ { - "name": "referrerName", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "signer_out_token_account", + "docs": [ + "Signer token accounts" + ], + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "signer_in_token_account", + "writable": true }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "constituent_out_token_account", + "docs": [ + "Constituent token accounts" + ], + "writable": true }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "constituent_in_token_account", + "writable": true }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ - { - "name": "name", - "type": { - "array": [ - "u8", - 32 + "name": "out_constituent", + "docs": [ + "Constituents" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "out_market_index" + } ] } - } - ] - }, - { - "name": "deposit", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false }, { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "in_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "lp_pool" }, { - "name": "userTokenAccount", - "isMut": true, - "isSigner": false + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "marketIndex", + "name": "in_market_index", "type": "u16" }, { - "name": "amount", - "type": "u64" + "name": "out_market_index", + "type": "u16" }, { - "name": "reduceOnly", - "type": "bool" + "name": "amount_in", + "type": "u64" } ] }, { - "name": "withdraw", + "name": "begin_swap", + "discriminator": [ + 174, + 109, + 228, + 1, + 242, + 105, + 232, + 105 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { "name": "user", - "isMut": true, - "isSigner": false + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true + "signer": true + }, + { + "name": "out_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } + }, + { + "name": "in_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } + }, + { + "name": "out_token_account", + "writable": true }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "in_token_account", + "writable": true }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "token_program" }, { - "name": "userTokenAccount", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" } ], "args": [ { - "name": "marketIndex", + "name": "in_market_index", "type": "u16" }, { - "name": "amount", - "type": "u64" + "name": "out_market_index", + "type": "u16" }, { - "name": "reduceOnly", - "type": "bool" + "name": "amount_in", + "type": "u64" } ] }, { - "name": "transferDeposit", + "name": "cancel_order", + "discriminator": [ + 95, + 129, + 237, + 240, + 8, + 49, + 223, + 132 + ], "accounts": [ { - "name": "fromUser", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "toUser", - "isMut": true, - "isSigner": false - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "spotMarketVault", - "isMut": false, - "isSigner": false + "signer": true } ], "args": [ { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" + "name": "order_id", + "type": { + "option": "u32" + } } ] }, { - "name": "transferPools", + "name": "cancel_order_by_user_id", + "discriminator": [ + 107, + 211, + 250, + 133, + 18, + 37, + 57, + 100 + ], "accounts": [ { - "name": "fromUser", - "isMut": true, - "isSigner": false - }, - { - "name": "toUser", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "depositFromSpotMarketVault", - "isMut": true, - "isSigner": false - }, - { - "name": "depositToSpotMarketVault", - "isMut": true, - "isSigner": false - }, - { - "name": "borrowFromSpotMarketVault", - "isMut": true, - "isSigner": false - }, - { - "name": "borrowToSpotMarketVault", - "isMut": true, - "isSigner": false - }, - { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "signer": true } ], "args": [ { - "name": "depositFromMarketIndex", - "type": "u16" - }, - { - "name": "depositToMarketIndex", - "type": "u16" - }, - { - "name": "borrowFromMarketIndex", - "type": "u16" - }, - { - "name": "borrowToMarketIndex", - "type": "u16" - }, - { - "name": "depositAmount", - "type": { - "option": "u64" - } - }, - { - "name": "borrowAmount", - "type": { - "option": "u64" - } + "name": "user_order_id", + "type": "u8" } ] }, { - "name": "transferPerpPosition", + "name": "cancel_orders", + "discriminator": [ + 238, + 225, + 95, + 158, + 227, + 103, + 8, + 194 + ], "accounts": [ { - "name": "fromUser", - "isMut": true, - "isSigner": false - }, - { - "name": "toUser", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "signer": true } ], "args": [ { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", + "name": "market_type", "type": { - "option": "i64" + "option": { + "defined": { + "name": "MarketType" + } + } } - } - ] - }, - { - "name": "placePerpOrder", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "market_index", + "type": { + "option": "u16" + } }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "params", + "name": "direction", "type": { - "defined": "OrderParams" + "option": { + "defined": { + "name": "PositionDirection" + } + } } } ] }, { - "name": "cancelOrder", + "name": "cancel_orders_by_ids", + "discriminator": [ + 134, + 19, + 144, + 165, + 94, + 240, + 210, + 94 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { "name": "user", - "isMut": true, - "isSigner": false + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true + "signer": true } ], "args": [ { - "name": "orderId", + "name": "order_ids", "type": { - "option": "u32" + "vec": "u32" } } ] }, { - "name": "cancelOrderByUserId", + "name": "cancel_request_remove_insurance_fund_stake", + "discriminator": [ + 97, + 235, + 78, + 62, + 212, + 42, + 241, + 127 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "insurance_fund_stake", + "writable": true + }, + { + "name": "user_stats", + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "insurance_fund_stake", + "user_stats" + ] + }, + { + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } } ], "args": [ { - "name": "userOrderId", - "type": "u8" + "name": "market_index", + "type": "u16" } ] }, { - "name": "cancelOrders", + "name": "change_approved_builder", + "discriminator": [ + 179, + 134, + 211, + 45, + 195, + 5, + 189, + 173 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true, + "relations": [ + "escrow" + ] }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketType", - "type": { - "option": { - "defined": "MarketType" - } - } + "name": "builder", + "type": "pubkey" }, { - "name": "marketIndex", - "type": { - "option": "u16" - } + "name": "max_fee_bps", + "type": "u16" }, { - "name": "direction", - "type": { - "option": { - "defined": "PositionDirection" - } - } + "name": "add", + "type": "bool" } ] }, { - "name": "cancelOrdersByIds", + "name": "change_signed_msg_ws_delegate_status", + "discriminator": [ + 252, + 202, + 252, + 219, + 179, + 27, + 84, + 138 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "signed_msg_ws_delegates", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71, + 95, + 87, + 83 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "authority", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "orderIds", - "type": { - "vec": "u32" - } + "name": "delegate", + "type": "pubkey" + }, + { + "name": "add", + "type": "bool" } ] }, { - "name": "modifyOrder", + "name": "delete_amm_cache", + "discriminator": [ + 216, + 130, + 215, + 206, + 233, + 232, + 191, + 88 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } + "name": "state" }, { - "name": "modifyOrderParams", - "type": { - "defined": "ModifyOrderParams" + "name": "amm_cache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] } } - ] + ], + "args": [] }, { - "name": "modifyOrderByUserId", + "name": "delete_initialized_perp_market", + "discriminator": [ + 91, + 154, + 24, + 87, + 106, + 59, + 190, + 66 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "state", + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "userOrderId", - "type": "u8" - }, - { - "name": "modifyOrderParams", - "type": { - "defined": "ModifyOrderParams" - } + "name": "market_index", + "type": "u16" } ] }, { - "name": "placeAndTakePerpOrder", + "name": "delete_initialized_spot_market", + "discriminator": [ + 31, + 140, + 67, + 191, + 189, + 20, + 101, + 221 + ], "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, { "name": "state", - "isMut": false, - "isSigner": false + "writable": true }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true + }, + { + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, + { + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "token_program" } ], "args": [ { - "name": "params", - "type": { - "defined": "OrderParams" - } - }, - { - "name": "successCondition", - "type": { - "option": "u32" - } + "name": "market_index", + "type": "u16" } ] }, { - "name": "placeAndMakePerpOrder", + "name": "delete_prelaunch_oracle", + "discriminator": [ + 59, + 169, + 100, + 49, + 69, + 17, + 173, + 253 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "taker", - "isMut": true, - "isSigner": false + "name": "prelaunch_oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "perp_market_index" + } + ] + } }, { - "name": "takerStats", - "isMut": true, - "isSigner": false + "name": "perp_market" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "state" } ], "args": [ { - "name": "params", - "type": { - "defined": "OrderParams" - } - }, - { - "name": "takerOrderId", - "type": "u32" + "name": "perp_market_index", + "type": "u16" } ] }, { - "name": "placeAndMakeSignedMsgPerpOrder", + "name": "delete_signed_msg_user_orders", + "discriminator": [ + 221, + 247, + 128, + 253, + 212, + 254, + 46, + 153 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "signed_msg_user_orders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "state", + "writable": true }, { - "name": "taker", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true + } + ], + "args": [] + }, + { + "name": "delete_user", + "discriminator": [ + 186, + 85, + 17, + 249, + 219, + 231, + 98, + 251 + ], + "accounts": [ + { + "name": "user", + "writable": true }, { - "name": "takerStats", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "takerSignedMsgUserOrders", - "isMut": false, - "isSigner": false + "name": "state", + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true + "writable": true, + "signer": true, + "relations": [ + "user", + "user_stats" + ] } ], - "args": [ - { - "name": "params", - "type": { - "defined": "OrderParams" - } - }, - { - "name": "signedMsgOrderUuid", - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] + "args": [] }, { - "name": "placeSignedMsgTakerOrder", + "name": "deposit", + "discriminator": [ + 242, + 35, + 198, + 137, + 82, + 225, + 242, + 182 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { "name": "user", - "isMut": true, - "isSigner": false + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "signedMsgUserOrders", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "ixSysvar", - "isMut": false, - "isSigner": false, - "docs": [ - "the supplied Sysvar could be anything else.", - "The Instruction Sysvar has not been implemented", - "in the Anchor framework yet, so this is the safe approach." - ] + "name": "user_token_account", + "writable": true + }, + { + "name": "token_program" } ], "args": [ { - "name": "signedMsgOrderParamsMessageBytes", - "type": "bytes" + "name": "market_index", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" }, { - "name": "isDelegateSigner", + "name": "reduce_only", "type": "bool" } ] }, { - "name": "placeSpotOrder", + "name": "deposit_into_insurance_fund_stake", + "discriminator": [ + 4, + 22, + 226, + 201, + 124, + 44, + 82, + 230 + ], "accounts": [ + { + "name": "signer", + "signer": true + }, { "name": "state", - "isMut": false, - "isSigner": false + "writable": true }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ + "name": "insurance_fund_stake", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101 + ] + }, + { + "kind": "account", + "path": "user_stats" + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, { - "name": "params", - "type": { - "defined": "OrderParams" + "name": "user_stats", + "writable": true + }, + { + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] } - } - ] - }, - { - "name": "placeAndTakeSpotOrder", - "accounts": [ + }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "user_token_account", + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "token_program" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "drift_signer" } ], "args": [ { - "name": "params", - "type": { - "defined": "OrderParams" - } - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": "SpotFulfillmentType" - } - } + "name": "market_index", + "type": "u16" }, { - "name": "makerOrderId", - "type": { - "option": "u32" - } + "name": "amount", + "type": "u64" } ] }, { - "name": "placeAndMakeSpotOrder", + "name": "deposit_into_perp_market_fee_pool", + "discriminator": [ + 34, + 58, + 57, + 68, + 97, + 80, + 244, + 6 + ], "accounts": [ { "name": "state", - "isMut": false, - "isSigner": false + "writable": true }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "taker", - "isMut": true, - "isSigner": false + "name": "source_vault", + "writable": true }, { - "name": "takerStats", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": "OrderParams" + "name": "quote_spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] } }, { - "name": "takerOrderId", - "type": "u32" - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": "SpotFulfillmentType" - } + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] } - } - ] - }, - { - "name": "placeOrders", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false }, { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "token_program" } ], "args": [ { - "name": "params", - "type": { - "vec": { - "defined": "OrderParams" - } - } + "name": "amount", + "type": "u64" } ] }, { - "name": "beginSwap", + "name": "deposit_into_spot_market_revenue_pool", + "discriminator": [ + 92, + 40, + 151, + 42, + 122, + 254, + 139, + 246 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "authority", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spot_market" + } + ] + } }, { - "name": "outSpotMarketVault", - "isMut": true, - "isSigner": false + "name": "user_token_account", + "writable": true }, { - "name": "inSpotMarketVault", - "isMut": true, - "isSigner": false + "name": "token_program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "deposit_into_spot_market_vault", + "discriminator": [ + 48, + 252, + 119, + 73, + 255, + 205, + 174, + 247 + ], + "accounts": [ + { + "name": "state" }, { - "name": "outTokenAccount", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true }, { - "name": "inTokenAccount", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "source_vault", + "writable": true }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "spot_market_vault", + "writable": true }, { - "name": "instructions", - "isMut": false, - "isSigner": false, - "docs": [ - "Instructions Sysvar for instruction introspection" - ] + "name": "token_program" } ], "args": [ { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "amountIn", + "name": "amount", "type": "u64" } ] }, { - "name": "endSwap", + "name": "deposit_to_program_vault", + "discriminator": [ + 235, + 171, + 121, + 80, + 57, + 239, + 147, + 220 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "userStats", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "admin", + "writable": true, + "signer": true }, { - "name": "outSpotMarketVault", - "isMut": true, - "isSigner": false + "name": "constituent", + "writable": true }, { - "name": "inSpotMarketVault", - "isMut": true, - "isSigner": false + "name": "constituent_token_account", + "writable": true }, { - "name": "outTokenAccount", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true }, { - "name": "inTokenAccount", - "isMut": true, - "isSigner": false + "name": "spot_market_vault", + "writable": true }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "token_program" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "mint" }, { - "name": "instructions", - "isMut": false, - "isSigner": false, - "docs": [ - "Instructions Sysvar for instruction introspection" - ] + "name": "oracle" } ], "args": [ { - "name": "inMarketIndex", - "type": "u16" + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "disable_user_high_leverage_mode", + "discriminator": [ + 183, + 155, + 45, + 0, + 226, + 85, + 213, + 69 + ], + "accounts": [ + { + "name": "state" }, { - "name": "outMarketIndex", - "type": "u16" + "name": "authority", + "signer": true }, { - "name": "limitPrice", - "type": { - "option": "u64" - } + "name": "user", + "writable": true }, { - "name": "reduceOnly", - "type": { - "option": { - "defined": "SwapReduceOnly" - } - } + "name": "high_leverage_mode_config", + "writable": true + } + ], + "args": [ + { + "name": "disable_maintenance", + "type": "bool" } ] }, { - "name": "updateUserName", + "name": "enable_user_high_leverage_mode", + "discriminator": [ + 231, + 24, + 230, + 112, + 201, + 173, + 73, + 184 + ], "accounts": [ + { + "name": "state" + }, { "name": "user", - "isMut": true, - "isSigner": false + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true + "signer": true + }, + { + "name": "high_leverage_mode_config", + "writable": true } ], "args": [ { - "name": "subAccountId", + "name": "sub_account_id", "type": "u16" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } } ] }, { - "name": "updateUserCustomMarginRatio", + "name": "end_insurance_fund_swap", + "discriminator": [ + 206, + 230, + 98, + 8, + 249, + 158, + 169, + 167 + ], "accounts": [ { - "name": "user", - "isMut": true, - "isSigner": false + "name": "state" }, { "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "writable": true, + "signer": true }, { - "name": "marginRatio", - "type": "u32" - } - ] - }, - { - "name": "updateUserPerpPositionCustomMarginRatio", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "out_insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "in_insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "perpMarketIndex", - "type": "u16" + "name": "out_token_account", + "writable": true }, { - "name": "marginRatio", - "type": "u16" - } - ] - }, - { - "name": "updateUserMarginTradingEnabled", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "in_token_account", + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "if_rebalance_config", + "writable": true }, { - "name": "marginTradingEnabled", - "type": "bool" - } - ] - }, - { - "name": "updateUserPoolId", - "accounts": [ + "name": "token_program" + }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" } ], "args": [ { - "name": "subAccountId", + "name": "in_market_index", "type": "u16" }, { - "name": "poolId", - "type": "u8" + "name": "out_market_index", + "type": "u16" } ] }, { - "name": "updateUserDelegate", + "name": "end_lp_swap", + "discriminator": [ + 99, + 125, + 214, + 165, + 129, + 175, + 253, + 135 + ], "accounts": [ { - "name": "user", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "admin", + "writable": true, + "signer": true }, { - "name": "delegate", - "type": "publicKey" - } - ] - }, - { - "name": "updateUserReduceOnly", - "accounts": [ + "name": "signer_out_token_account", + "docs": [ + "Signer token accounts" + ], + "writable": true + }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "signer_in_token_account", + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ + "name": "constituent_out_token_account", + "docs": [ + "Constituent token accounts" + ], + "writable": true + }, { - "name": "subAccountId", - "type": "u16" + "name": "constituent_in_token_account", + "writable": true }, { - "name": "reduceOnly", - "type": "bool" - } - ] - }, - { - "name": "updateUserProtectedMakerOrders", - "accounts": [ + "name": "out_constituent", + "docs": [ + "Constituents" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } + }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "in_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "lp_pool" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" }, { - "name": "protectedMakerModeConfig", - "isMut": true, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "subAccountId", + "name": "_in_market_index", "type": "u16" }, { - "name": "protectedMakerOrders", - "type": "bool" + "name": "_out_market_index", + "type": "u16" } ] }, { - "name": "deleteUser", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false - }, - { - "name": "state", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": true, - "isSigner": true - } + "name": "end_swap", + "discriminator": [ + 177, + 184, + 27, + 193, + 34, + 13, + 210, + 145 ], - "args": [] - }, - { - "name": "forceDeleteUser", "accounts": [ { - "name": "user", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { "name": "authority", - "isMut": true, - "isSigner": false + "signer": true }, { - "name": "keeper", - "isMut": true, - "isSigner": true - }, - { - "name": "driftSigner", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "deleteSignedMsgUserOrders", - "accounts": [ - { - "name": "signedMsgUserOrders", - "isMut": true, - "isSigner": false + "name": "out_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "in_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [] - }, - { - "name": "reclaimRent", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "out_token_account", + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "in_token_account", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "token_program" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "drift_signer" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" } ], - "args": [] - }, - { - "name": "enableUserHighLeverageMode", - "accounts": [ + "args": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "in_market_index", + "type": "u16" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "out_market_index", + "type": "u16" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "limit_price", + "type": { + "option": "u64" + } }, { - "name": "highLeverageModeConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "reduce_only", + "type": { + "option": { + "defined": { + "name": "SwapReduceOnly" + } + } + } } ] }, { - "name": "fillPerpOrder", + "name": "fill_perp_order", + "discriminator": [ + 13, + 188, + 248, + 103, + 134, + 217, + 106, + 240 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { "name": "authority", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "filler", - "isMut": true, - "isSigner": false + "writable": true }, { - "name": "fillerStats", - "isMut": true, - "isSigner": false + "name": "filler_stats", + "writable": true }, { "name": "user", - "isMut": true, - "isSigner": false + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true } ], "args": [ { - "name": "orderId", + "name": "order_id", "type": { "option": "u32" } }, { - "name": "makerOrderId", + "name": "_maker_order_id", "type": { "option": "u32" } @@ -1803,82 +2695,61 @@ ] }, { - "name": "revertFill", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "filler", - "isMut": true, - "isSigner": false - }, - { - "name": "fillerStats", - "isMut": true, - "isSigner": false - } + "name": "fill_spot_order", + "discriminator": [ + 212, + 206, + 130, + 173, + 21, + 34, + 199, + 40 ], - "args": [] - }, - { - "name": "fillSpotOrder", "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { "name": "authority", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "filler", - "isMut": true, - "isSigner": false + "writable": true }, { - "name": "fillerStats", - "isMut": true, - "isSigner": false + "name": "filler_stats", + "writable": true }, { "name": "user", - "isMut": true, - "isSigner": false + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true } ], "args": [ { - "name": "orderId", + "name": "order_id", "type": { "option": "u32" } }, { - "name": "fulfillmentType", + "name": "fulfillment_type", "type": { "option": { - "defined": "SpotFulfillmentType" + "defined": { + "name": "SpotFulfillmentType" + } } } }, { - "name": "makerOrderId", + "name": "maker_order_id", "type": { "option": "u32" } @@ -1886,7219 +2757,12317 @@ ] }, { - "name": "triggerOrder", + "name": "force_cancel_orders", + "discriminator": [ + 64, + 181, + 196, + 63, + 222, + 72, + 64, + 232 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { "name": "authority", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "filler", - "isMut": true, - "isSigner": false + "writable": true }, { "name": "user", - "isMut": true, - "isSigner": false + "writable": true } ], - "args": [ - { - "name": "orderId", - "type": "u32" - } - ] + "args": [] }, { - "name": "forceCancelOrders", + "name": "force_delete_user", + "discriminator": [ + 2, + 241, + 195, + 172, + 227, + 24, + 254, + 158 + ], "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "user_stats", + "writable": true + }, { "name": "state", - "isMut": false, - "isSigner": false + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true + "writable": true, + "relations": [ + "user", + "user_stats" + ] }, { - "name": "filler", - "isMut": true, - "isSigner": false + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "drift_signer" } ], "args": [] }, { - "name": "updateUserIdle", + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, { "name": "state", - "isMut": false, - "isSigner": false + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 114, + 105, + 102, + 116, + 95, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "quote_asset_mint" }, { - "name": "filler", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "user", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "logUserBalances", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "token_program" } ], "args": [] }, { - "name": "disableUserHighLeverageMode", + "name": "initialize_amm_cache", + "discriminator": [ + 38, + 60, + 171, + 158, + 203, + 58, + 137, + 8 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "amm_cache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } }, { - "name": "highLeverageModeConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, { - "name": "disableMaintenance", - "type": "bool" + "name": "system_program", + "address": "11111111111111111111111111111111" } - ] + ], + "args": [] }, { - "name": "updateUserStatsReferrerStatus", + "name": "initialize_constituent", + "discriminator": [ + 12, + 196, + 45, + 218, + 93, + 89, + 0, + 33 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "admin", + "writable": true, + "signer": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "adminDisableUpdatePerpBidAskTwap", - "accounts": [ + "name": "lp_pool", + "writable": true + }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "constituent_target_base", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "constituent_correlations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "userStats", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } + }, { - "name": "disable", - "type": "bool" - } - ] - }, - { - "name": "settlePnl", - "accounts": [ + "name": "spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } + }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market_mint" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "constituent_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "spotMarketVault", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "marketIndex", + "name": "spot_market_index", "type": "u16" - } - ] - }, - { - "name": "settleMultiplePnls", - "accounts": [ + }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "decimals", + "type": "u8" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "max_weight_deviation", + "type": "i64" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "swap_fee_min", + "type": "i64" }, { - "name": "spotMarketVault", - "isMut": false, - "isSigner": false - } - ], - "args": [ + "name": "swap_fee_max", + "type": "i64" + }, { - "name": "marketIndexes", - "type": { - "vec": "u16" - } + "name": "max_borrow_token_amount", + "type": "u64" }, { - "name": "mode", + "name": "oracle_staleness_threshold", + "type": "u64" + }, + { + "name": "cost_to_trade", + "type": "i32" + }, + { + "name": "constituent_derivative_index", "type": { - "defined": "SettlePnlMode" + "option": "i16" } - } - ] - }, - { - "name": "settleFundingPayment", - "accounts": [ + }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "constituent_derivative_depeg_threshold", + "type": "u64" }, { - "name": "user", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "settleExpiredMarket", - "accounts": [ + "name": "derivative_weight", + "type": "u64" + }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "volatility", + "type": "u64" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "gamma_execution", + "type": "u8" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "gamma_inventory", + "type": "u8" + }, { - "name": "marketIndex", - "type": "u16" + "name": "xi", + "type": "u8" + }, + { + "name": "new_constituent_correlations", + "type": { + "vec": "i64" + } } ] }, { - "name": "liquidatePerp", + "name": "initialize_fuel_overflow", + "discriminator": [ + 88, + 223, + 132, + 161, + 208, + 88, + 142, + 42 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "fuel_overflow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 117, + 101, + 108, + 95, + 111, + 118, + 101, + 114, + 102, + 108, + 111, + 119 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "user_stats", + "writable": true }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "authority", + "relations": [ + "user_stats" + ] }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "payer", + "writable": true, + "signer": true }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxBaseAssetAmount", - "type": "u64" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] + "args": [] }, { - "name": "liquidatePerpWithFill", + "name": "initialize_high_leverage_mode_config", + "discriminator": [ + 213, + 167, + 93, + 246, + 208, + 130, + 90, + 248 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "high_leverage_mode_config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndex", - "type": "u16" + "name": "max_users", + "type": "u32" } ] }, { - "name": "liquidateSpot", + "name": "initialize_if_rebalance_config", + "discriminator": [ + 8, + 85, + 184, + 167, + 176, + 61, + 173, + 226 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "if_rebalance_config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 102, + 95, + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "arg", + "path": "params.in_market_index" + }, + { + "kind": "arg", + "path": "params.out_market_index" + } + ] + } }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxLiabilityTransfer", - "type": "u128" - }, - { - "name": "limitPrice", + "name": "params", "type": { - "option": "u64" + "defined": { + "name": "IfRebalanceConfigParams" + } } } ] }, { - "name": "liquidateSpotWithSwapBegin", + "name": "initialize_insurance_fund_stake", + "discriminator": [ + 187, + 179, + 243, + 70, + 248, + 90, + 92, + 147 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "insurance_fund_stake", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true, + "relations": [ + "user_stats" + ] }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "payer", + "writable": true, + "signer": true }, { - "name": "liabilitySpotMarketVault", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "assetSpotMarketVault", - "isMut": true, - "isSigner": false - }, - { - "name": "liabilityTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "assetTokenAccount", - "isMut": true, - "isSigner": false - }, - { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - }, - { - "name": "driftSigner", - "isMut": false, - "isSigner": false - }, - { - "name": "instructions", - "isMut": false, - "isSigner": false, - "docs": [ - "Instructions Sysvar for instruction introspection" - ] + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "liabilityMarketIndex", + "name": "market_index", "type": "u16" - }, - { - "name": "swapAmount", - "type": "u64" } ] }, { - "name": "liquidateSpotWithSwapEnd", + "name": "initialize_lp_pool", + "discriminator": [ + 242, + 64, + 1, + 222, + 142, + 46, + 204, + 227 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "lp_pool", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 112, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "arg", + "path": "id" + } + ] + } }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "mint" }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "lp_pool_token_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "amm_constituent_mapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "constituent_target_base", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "liabilitySpotMarketVault", - "isMut": true, - "isSigner": false + "name": "constituent_correlations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "assetSpotMarketVault", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "liabilityTokenAccount", - "isMut": true, - "isSigner": false + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { - "name": "assetTokenAccount", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "lp_pool_id", + "type": "u8" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "min_mint_fee", + "type": "i64" }, { - "name": "instructions", - "isMut": false, - "isSigner": false, - "docs": [ - "Instructions Sysvar for instruction introspection" - ] - } - ], - "args": [ + "name": "max_aum", + "type": "u128" + }, { - "name": "assetMarketIndex", - "type": "u16" + "name": "max_settle_quote_amount_per_market", + "type": "u64" }, { - "name": "liabilityMarketIndex", - "type": "u16" + "name": "whitelist_mint", + "type": "pubkey" } ] }, { - "name": "liquidateBorrowForPerpPnl", + "name": "initialize_openbook_v2_fulfillment_config", + "discriminator": [ + 7, + 221, + 103, + 153, + 107, + 57, + 27, + 197 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "base_spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "quote_spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "state", + "writable": true }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "openbook_v2_program" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "openbook_v2_market" }, { - "name": "userStats", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "drift_signer" + }, { - "name": "perpMarketIndex", - "type": "u16" + "name": "openbook_v2_fulfillment_config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 112, + 101, + 110, + 98, + 111, + 111, + 107, + 95, + 118, + 50, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "openbook_v2_market" + } + ] + } }, { - "name": "spotMarketIndex", - "type": "u16" + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "liquidatorMaxLiabilityTransfer", - "type": "u128" + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "limitPrice", - "type": { - "option": "u64" - } + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "market_index", + "type": "u16" } ] }, { - "name": "liquidatePerpPnlForDeposit", + "name": "initialize_perp_market", + "discriminator": [ + 132, + 9, + 229, + 118, + 117, + 118, + 117, + 62 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "state", + "writable": true }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 101, + 114, + 112, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_markets", + "account": "State" + } + ] + } }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "oracle" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "perpMarketIndex", + "name": "market_index", "type": "u16" }, { - "name": "spotMarketIndex", - "type": "u16" + "name": "amm_base_asset_reserve", + "type": "u128" }, { - "name": "liquidatorMaxPnlTransfer", + "name": "amm_quote_asset_reserve", "type": "u128" }, { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "setUserStatusToBeingLiquidated", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "amm_periodicity", + "type": "i64" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "amm_peg_multiplier", + "type": "u128" }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [] - }, - { - "name": "resolvePerpPnlDeficit", - "accounts": [ + "name": "oracle_source", + "type": { + "defined": { + "name": "OracleSource" + } + } + }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "contract_tier", + "type": { + "defined": { + "name": "ContractTier" + } + } }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "margin_ratio_initial", + "type": "u32" }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "margin_ratio_maintenance", + "type": "u32" }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "liquidator_fee", + "type": "u32" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "if_liquidation_fee", + "type": "u32" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ + "name": "imf_factor", + "type": "u32" + }, { - "name": "spotMarketIndex", - "type": "u16" + "name": "active_status", + "type": "bool" }, { - "name": "perpMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "resolvePerpBankruptcy", - "accounts": [ + "name": "base_spread", + "type": "u32" + }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "max_spread", + "type": "u32" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "max_open_interest", + "type": "u128" }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "max_revenue_withdraw_per_period", + "type": "u64" }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "quote_max_insurance", + "type": "u64" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "order_step_size", + "type": "u64" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "order_tick_size", + "type": "u64" }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "min_order_size", + "type": "u64" }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "concentration_coef_scale", + "type": "u128" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "curve_update_intensity", + "type": "u8" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ + "name": "amm_jit_intensity", + "type": "u8" + }, { - "name": "quoteSpotMarketIndex", - "type": "u16" + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } }, { - "name": "marketIndex", - "type": "u16" + "name": "lp_pool_id", + "type": "u8" } ] }, { - "name": "resolveSpotBankruptcy", + "name": "initialize_phoenix_fulfillment_config", + "discriminator": [ + 135, + 132, + 110, + 107, + 185, + 160, + 169, + 154 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "base_spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "quote_spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "liquidator", - "isMut": true, - "isSigner": false + "name": "state", + "writable": true }, { - "name": "liquidatorStats", - "isMut": true, - "isSigner": false + "name": "phoenix_program" }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "phoenix_market" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "phoenix_fulfillment_config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 104, + 111, + 101, + 110, + 105, + 120, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "phoenix_market" + } + ] + } }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndex", + "name": "market_index", "type": "u16" } ] }, { - "name": "settleRevenueToInsuranceFund", + "name": "initialize_prediction_market", + "discriminator": [ + 248, + 70, + 198, + 224, + 224, + 105, + 125, + 195 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "spotMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false - }, - { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - } - ] + "args": [] }, { - "name": "updateFundingRate", + "name": "initialize_prelaunch_oracle", + "discriminator": [ + 169, + 178, + 84, + 25, + 175, + 62, + 29, + 247 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "prelaunch_oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "params.perp_market_index" + } + ] + } }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndex", - "type": "u16" + "name": "params", + "type": { + "defined": { + "name": "PrelaunchOracleParams" + } + } } ] }, { - "name": "updatePrelaunchOracle", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "perpMarket", - "isMut": false, - "isSigner": false - }, - { - "name": "oracle", - "isMut": true, - "isSigner": false - } + "name": "initialize_protected_maker_mode_config", + "discriminator": [ + 67, + 103, + 220, + 67, + 88, + 32, + 252, + 8 ], - "args": [] - }, - { - "name": "updatePerpBidAskTwap", "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "protected_maker_mode_config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "keeperStats", - "isMut": false, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "system_program", + "address": "11111111111111111111111111111111" } ], - "args": [] + "args": [ + { + "name": "max_users", + "type": "u32" + } + ] }, { - "name": "updateSpotMarketCumulativeInterest", + "name": "initialize_pyth_lazer_oracle", + "discriminator": [ + 140, + 107, + 33, + 214, + 235, + 219, + 103, + 20 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "lazer_oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 108, + 97, + 122, + 101, + 114 + ] + }, + { + "kind": "arg", + "path": "feed_id" + } + ] + } }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "spotMarketVault", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateAmms", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndexes", - "type": { - "vec": "u16" - } + "name": "feed_id", + "type": "u32" } ] }, { - "name": "updateSpotMarketExpiry", + "name": "initialize_pyth_pull_oracle", + "discriminator": [ + 249, + 140, + 253, + 243, + 248, + 74, + 240, + 238 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "pyth_solana_receiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "price_feed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feed_id" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "expiryTs", - "type": "i64" + "name": "feed_id", + "type": { + "array": [ + "u8", + 32 + ] + } } ] }, { - "name": "updateUserQuoteAssetInsuranceStake", + "name": "initialize_referrer_name", + "discriminator": [ + 235, + 126, + 231, + 10, + 42, + 164, + 26, + 61 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "spotMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "insuranceFundStake", - "isMut": true, - "isSigner": false - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false - }, - { - "name": "signer", - "isMut": false, - "isSigner": true + "name": "referrer_name", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 102, + 101, + 114, + 114, + 101, + 114, + 95, + 110, + 97, + 109, + 101 + ] + }, + { + "kind": "arg", + "path": "name" + } + ] + } }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateUserGovTokenInsuranceStake", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "insuranceFundStake", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "payer", + "writable": true, + "signer": true }, { - "name": "signer", - "isMut": false, - "isSigner": true + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], - "args": [] + "args": [ + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] }, { - "name": "updateDelegateUserGovTokenInsuranceStake", + "name": "initialize_revenue_share", + "discriminator": [ + 57, + 9, + 123, + 131, + 82, + 52, + 50, + 13 + ], "accounts": [ { - "name": "spotMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "insuranceFundStake", - "isMut": false, - "isSigner": false + "name": "revenue_share", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 83, + 72, + 65, + 82, + 69 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "authority" }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "payer", + "writable": true, + "signer": true }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [] }, { - "name": "initializeInsuranceFundStake", + "name": "initialize_revenue_share_escrow", + "discriminator": [ + 187, + 18, + 123, + 88, + 238, + 104, + 84, + 154 + ], "accounts": [ { - "name": "spotMarket", - "isMut": false, - "isSigner": false - }, - { - "name": "insuranceFundStake", - "isMut": true, - "isSigner": false + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "authority", + "relations": [ + "user_stats" + ] }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "state" }, { "name": "payer", - "isMut": true, - "isSigner": true + "writable": true, + "signer": true }, { "name": "rent", - "isMut": false, - "isSigner": false + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndex", + "name": "num_orders", "type": "u16" } ] }, { - "name": "addInsuranceFundStake", + "name": "initialize_serum_fulfillment_config", + "discriminator": [ + 193, + 211, + 132, + 172, + 70, + 171, + 7, + 94 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "base_spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, + { + "name": "quote_spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "state", + "writable": true }, { - "name": "insuranceFundStake", - "isMut": true, - "isSigner": false + "name": "serum_program" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "serum_market" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "serum_open_orders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 114, + 117, + 109, + 95, + 111, + 112, + 101, + 110, + 95, + 111, + 114, + 100, + 101, + 114, + 115 + ] + }, + { + "kind": "account", + "path": "serum_market" + } + ] + } }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "serum_fulfillment_config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 114, + 117, + 109, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "serum_market" + } + ] + } }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "userTokenAccount", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndex", + "name": "market_index", "type": "u16" - }, - { - "name": "amount", - "type": "u64" } ] }, { - "name": "requestRemoveInsuranceFundStake", + "name": "initialize_signed_msg_user_orders", + "discriminator": [ + 164, + 99, + 156, + 126, + 156, + 57, + 99, + 180 + ], "accounts": [ { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "signed_msg_user_orders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "insuranceFundStake", - "isMut": true, - "isSigner": false + "name": "authority" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "payer", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndex", + "name": "num_orders", "type": "u16" - }, - { - "name": "amount", - "type": "u64" } ] }, { - "name": "cancelRequestRemoveInsuranceFundStake", + "name": "initialize_signed_msg_ws_delegates", + "discriminator": [ + 40, + 132, + 96, + 219, + 184, + 193, + 80, + 8 + ], "accounts": [ { - "name": "spotMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "insuranceFundStake", - "isMut": true, - "isSigner": false + "name": "signed_msg_ws_delegates", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71, + 95, + 87, + 83 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "authority", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndex", - "type": "u16" + "name": "delegates", + "type": { + "vec": "pubkey" + } } ] }, { - "name": "removeInsuranceFundStake", + "name": "initialize_spot_market", + "discriminator": [ + 234, + 196, + 128, + 44, + 94, + 15, + 48, + 201 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "State" + } + ] + } + }, + { + "name": "spot_market_mint" + }, + { + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "State" + } + ] + } }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "State" + } + ] + } }, { - "name": "insuranceFundStake", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "state", + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "oracle" }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "userTokenAccount", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "beginInsuranceFundSwap", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": true, - "isSigner": true - }, - { - "name": "outInsuranceFundVault", - "isMut": true, - "isSigner": false - }, - { - "name": "inInsuranceFundVault", - "isMut": true, - "isSigner": false + "name": "optimal_utilization", + "type": "u32" }, { - "name": "outTokenAccount", - "isMut": true, - "isSigner": false + "name": "optimal_borrow_rate", + "type": "u32" }, { - "name": "inTokenAccount", - "isMut": true, - "isSigner": false + "name": "max_borrow_rate", + "type": "u32" }, { - "name": "ifRebalanceConfig", - "isMut": true, - "isSigner": false + "name": "oracle_source", + "type": { + "defined": { + "name": "OracleSource" + } + } }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "initial_asset_weight", + "type": "u32" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "maintenance_asset_weight", + "type": "u32" }, { - "name": "instructions", - "isMut": false, - "isSigner": false, - "docs": [ - "Instructions Sysvar for instruction introspection" - ] - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" + "name": "initial_liability_weight", + "type": "u32" }, { - "name": "outMarketIndex", - "type": "u16" + "name": "maintenance_liability_weight", + "type": "u32" }, { - "name": "amountIn", - "type": "u64" - } - ] - }, - { - "name": "endInsuranceFundSwap", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "imf_factor", + "type": "u32" }, { - "name": "authority", - "isMut": true, - "isSigner": true + "name": "liquidator_fee", + "type": "u32" }, { - "name": "outInsuranceFundVault", - "isMut": true, - "isSigner": false + "name": "if_liquidation_fee", + "type": "u32" }, { - "name": "inInsuranceFundVault", - "isMut": true, - "isSigner": false + "name": "active_status", + "type": "bool" }, { - "name": "outTokenAccount", - "isMut": true, - "isSigner": false + "name": "asset_tier", + "type": { + "defined": { + "name": "AssetTier" + } + } }, { - "name": "inTokenAccount", - "isMut": true, - "isSigner": false + "name": "scale_initial_asset_weight_start", + "type": "u64" }, { - "name": "ifRebalanceConfig", - "isMut": true, - "isSigner": false + "name": "withdraw_guard_threshold", + "type": "u64" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "order_tick_size", + "type": "u64" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "order_step_size", + "type": "u64" }, { - "name": "instructions", - "isMut": false, - "isSigner": false, - "docs": [ - "Instructions Sysvar for instruction introspection" - ] - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" + "name": "if_total_factor", + "type": "u32" }, { - "name": "outMarketIndex", - "type": "u16" + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } } ] }, { - "name": "transferProtocolIfSharesToRevenuePool", + "name": "initialize_user", + "discriminator": [ + 111, + 17, + 185, + 250, + 60, + 122, + 38, + 254 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "sub_account_id" + } + ] + } }, { - "name": "authority", - "isMut": true, - "isSigner": true + "name": "user_stats", + "writable": true }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "state", + "writable": true }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true, + "relations": [ + "user_stats" + ] }, { - "name": "ifRebalanceConfig", - "isMut": true, - "isSigner": false + "name": "payer", + "writable": true, + "signer": true }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marketIndex", + "name": "sub_account_id", "type": "u16" }, { - "name": "amount", - "type": "u64" + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } } ] }, { - "name": "depositIntoInsuranceFundStake", + "name": "initialize_user_stats", + "discriminator": [ + 254, + 243, + 72, + 98, + 251, + 130, + 168, + 213 + ], "accounts": [ { - "name": "signer", - "isMut": false, - "isSigner": true + "name": "user_stats", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114, + 95, + 115, + 116, + 97, + 116, + 115 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true + }, + { + "name": "authority", + "signer": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "payer", + "writable": true, + "signer": true }, { - "name": "insuranceFundStake", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "liquidate_borrow_for_perp_pnl", + "discriminator": [ + 169, + 17, + 32, + 90, + 207, + 148, + 209, + 27 + ], + "accounts": [ + { + "name": "state" }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "liquidator", + "writable": true }, { - "name": "userTokenAccount", - "isMut": true, - "isSigner": false + "name": "liquidator_stats", + "writable": true }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true } ], "args": [ { - "name": "marketIndex", + "name": "perp_market_index", "type": "u16" }, { - "name": "amount", - "type": "u64" + "name": "spot_market_index", + "type": "u16" + }, + { + "name": "liquidator_max_liability_transfer", + "type": "u128" + }, + { + "name": "limit_price", + "type": { + "option": "u64" + } } ] }, { - "name": "updatePythPullOracle", + "name": "liquidate_perp", + "discriminator": [ + 75, + 35, + 119, + 247, + 191, + 18, + 139, + 2 + ], "accounts": [ { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true }, { - "name": "pythSolanaReceiver", - "isMut": false, - "isSigner": false + "name": "liquidator_stats", + "writable": true }, { - "name": "encodedVaa", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "priceFeed", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true } ], "args": [ { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } + "name": "market_index", + "type": "u16" }, { - "name": "params", - "type": "bytes" + "name": "liquidator_max_base_asset_amount", + "type": "u64" + }, + { + "name": "limit_price", + "type": { + "option": "u64" + } } ] }, { - "name": "postPythPullOracleUpdateAtomic", + "name": "liquidate_perp_pnl_for_deposit", + "discriminator": [ + 237, + 75, + 198, + 235, + 233, + 186, + 75, + 35 + ], "accounts": [ { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true }, { - "name": "pythSolanaReceiver", - "isMut": false, - "isSigner": false + "name": "liquidator_stats", + "writable": true }, { - "name": "guardianSet", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "priceFeed", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true } ], "args": [ { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } + "name": "perp_market_index", + "type": "u16" }, { - "name": "params", - "type": "bytes" + "name": "spot_market_index", + "type": "u16" + }, + { + "name": "liquidator_max_pnl_transfer", + "type": "u128" + }, + { + "name": "limit_price", + "type": { + "option": "u64" + } } ] }, { - "name": "postMultiPythPullOracleUpdatesAtomic", + "name": "liquidate_perp_with_fill", + "discriminator": [ + 95, + 111, + 124, + 105, + 86, + 169, + 187, + 34 + ], "accounts": [ { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidator_stats", + "writable": true }, { - "name": "pythSolanaReceiver", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "guardianSet", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true } ], "args": [ { - "name": "params", - "type": "bytes" + "name": "market_index", + "type": "u16" } ] }, { - "name": "pauseSpotMarketDepositWithdraw", + "name": "liquidate_spot", + "discriminator": [ + 107, + 0, + 128, + 41, + 35, + 229, + 251, + 18 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "keeper", - "isMut": false, - "isSigner": true + "name": "authority", + "signer": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "liquidator", + "writable": true }, { - "name": "spotMarketVault", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "initialize", - "accounts": [ - { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "liquidator_stats", + "writable": true }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "quoteAssetMint", - "isMut": false, - "isSigner": false - }, + "name": "user_stats", + "writable": true + } + ], + "args": [ { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "asset_market_index", + "type": "u16" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "liability_market_index", + "type": "u16" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "liquidator_max_liability_transfer", + "type": "u128" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "limit_price", + "type": { + "option": "u64" + } } - ], - "args": [] + ] }, { - "name": "initializeSpotMarket", + "name": "liquidate_spot_with_swap_begin", + "discriminator": [ + 12, + 43, + 176, + 83, + 156, + 251, + 117, + 13 + ], "accounts": [ { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "spotMarketMint", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "liquidator", + "writable": true }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false + "name": "liquidator_stats", + "writable": true }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "liability_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "liability_market_index" + } + ] + } }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "asset_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "asset_market_index" + } + ] + } }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "liability_token_account", + "writable": true + }, + { + "name": "asset_token_account", + "writable": true + }, + { + "name": "token_program" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "drift_signer" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" } ], "args": [ { - "name": "optimalUtilization", - "type": "u32" + "name": "asset_market_index", + "type": "u16" }, { - "name": "optimalBorrowRate", - "type": "u32" + "name": "liability_market_index", + "type": "u16" }, { - "name": "maxBorrowRate", - "type": "u32" - }, - { - "name": "oracleSource", - "type": { - "defined": "OracleSource" - } - }, - { - "name": "initialAssetWeight", - "type": "u32" - }, + "name": "swap_amount", + "type": "u64" + } + ] + }, + { + "name": "liquidate_spot_with_swap_end", + "discriminator": [ + 142, + 88, + 163, + 160, + 223, + 75, + 55, + 225 + ], + "accounts": [ { - "name": "maintenanceAssetWeight", - "type": "u32" + "name": "state" }, { - "name": "initialLiabilityWeight", - "type": "u32" + "name": "authority", + "signer": true }, { - "name": "maintenanceLiabilityWeight", - "type": "u32" + "name": "liquidator", + "writable": true }, { - "name": "imfFactor", - "type": "u32" + "name": "liquidator_stats", + "writable": true }, { - "name": "liquidatorFee", - "type": "u32" + "name": "user", + "writable": true }, { - "name": "ifLiquidationFee", - "type": "u32" + "name": "user_stats", + "writable": true }, { - "name": "activeStatus", - "type": "bool" + "name": "liability_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "liability_market_index" + } + ] + } }, { - "name": "assetTier", - "type": { - "defined": "AssetTier" + "name": "asset_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "asset_market_index" + } + ] } }, { - "name": "scaleInitialAssetWeightStart", - "type": "u64" + "name": "liability_token_account", + "writable": true }, { - "name": "withdrawGuardThreshold", - "type": "u64" + "name": "asset_token_account", + "writable": true }, { - "name": "orderTickSize", - "type": "u64" + "name": "token_program" }, { - "name": "orderStepSize", - "type": "u64" + "name": "drift_signer" }, { - "name": "ifTotalFactor", - "type": "u32" + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "asset_market_index", + "type": "u16" }, { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } + "name": "liability_market_index", + "type": "u16" } ] }, { - "name": "deleteInitializedSpotMarket", + "name": "log_user_balances", + "discriminator": [ + 162, + 21, + 35, + 251, + 32, + 57, + 161, + 210 + ], "accounts": [ { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "state", - "isMut": true, - "isSigner": false - }, - { - "name": "spotMarket", - "isMut": true, - "isSigner": false - }, - { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "insuranceFundVault", - "isMut": true, - "isSigner": false - }, - { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true } ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] + "args": [] }, { - "name": "initializeSerumFulfillmentConfig", + "name": "lp_pool_add_liquidity", + "discriminator": [ + 49, + 135, + 246, + 103, + 93, + 146, + 220, + 141 + ], "accounts": [ { - "name": "baseSpotMarket", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "quoteSpotMarket", - "isMut": false, - "isSigner": false + "name": "lp_pool", + "writable": true }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true + }, + { + "name": "in_market_mint" }, { - "name": "serumProgram", - "isMut": false, - "isSigner": false + "name": "in_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "serumMarket", - "isMut": false, - "isSigner": false + "name": "user_in_token_account", + "writable": true }, { - "name": "serumOpenOrders", - "isMut": true, - "isSigner": false + "name": "constituent_in_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "user_lp_token_account", + "writable": true }, { - "name": "serumFulfillmentConfig", - "isMut": true, - "isSigner": false + "name": "lp_mint", + "writable": true }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "constituent_target_base" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "lp_pool_token_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "marketIndex", + "name": "in_market_index", "type": "u16" + }, + { + "name": "in_amount", + "type": "u128" + }, + { + "name": "min_mint_amount", + "type": "u64" } ] }, { - "name": "updateSerumFulfillmentConfigStatus", + "name": "lp_pool_remove_liquidity", + "discriminator": [ + 164, + 36, + 193, + 252, + 196, + 157, + 138, + 43 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "serumFulfillmentConfig", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "admin", - "isMut": true, - "isSigner": true - } - ], - "args": [ + "name": "lp_pool", + "writable": true + }, { - "name": "status", - "type": { - "defined": "SpotFulfillmentConfigStatus" - } - } - ] - }, - { - "name": "initializeOpenbookV2FulfillmentConfig", - "accounts": [ + "name": "authority", + "signer": true + }, { - "name": "baseSpotMarket", - "isMut": false, - "isSigner": false + "name": "out_market_mint" }, { - "name": "quoteSpotMarket", - "isMut": false, - "isSigner": false + "name": "out_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "user_out_token_account", + "writable": true }, { - "name": "openbookV2Program", - "isMut": false, - "isSigner": false + "name": "constituent_out_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "openbookV2Market", - "isMut": false, - "isSigner": false + "name": "user_lp_token_account", + "writable": true }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "spot_market_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "openbookV2FulfillmentConfig", - "isMut": true, - "isSigner": false + "name": "lp_mint", + "writable": true }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "constituent_target_base" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "lp_pool_token_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } + }, + { + "name": "token_program" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "amm_cache", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } } ], "args": [ { - "name": "marketIndex", + "name": "in_market_index", "type": "u16" + }, + { + "name": "in_amount", + "type": "u64" + }, + { + "name": "min_out_amount", + "type": "u128" } ] }, { - "name": "openbookV2FulfillmentConfigStatus", + "name": "lp_pool_swap", + "discriminator": [ + 36, + 161, + 39, + 49, + 227, + 1, + 35, + 226 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "openbookV2FulfillmentConfig", - "isMut": true, - "isSigner": false + "name": "lp_pool" }, { - "name": "admin", - "isMut": true, - "isSigner": true - } - ], - "args": [ + "name": "constituent_target_base" + }, { - "name": "status", - "type": { - "defined": "SpotFulfillmentConfigStatus" - } - } - ] - }, - { - "name": "initializePhoenixFulfillmentConfig", - "accounts": [ + "name": "constituent_correlations" + }, { - "name": "baseSpotMarket", - "isMut": false, - "isSigner": false + "name": "constituent_in_token_account", + "writable": true }, { - "name": "quoteSpotMarket", - "isMut": false, - "isSigner": false + "name": "constituent_out_token_account", + "writable": true }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "user_in_token_account", + "writable": true }, { - "name": "phoenixProgram", - "isMut": false, - "isSigner": false + "name": "user_out_token_account", + "writable": true }, { - "name": "phoenixMarket", - "isMut": false, - "isSigner": false + "name": "in_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "out_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "phoenixFulfillmentConfig", - "isMut": true, - "isSigner": false + "name": "in_market_mint" }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "out_market_mint" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "marketIndex", + "name": "in_market_index", + "type": "u16" + }, + { + "name": "out_market_index", "type": "u16" + }, + { + "name": "in_amount", + "type": "u64" + }, + { + "name": "min_out_amount", + "type": "u64" } ] }, { - "name": "phoenixFulfillmentConfigStatus", + "name": "modify_order", + "discriminator": [ + 47, + 124, + 117, + 255, + 201, + 197, + 130, + 94 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "phoenixFulfillmentConfig", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "authority", + "signer": true } ], "args": [ { - "name": "status", + "name": "order_id", "type": { - "defined": "SpotFulfillmentConfigStatus" + "option": "u32" + } + }, + { + "name": "modify_order_params", + "type": { + "defined": { + "name": "ModifyOrderParams" + } } } ] }, { - "name": "initializePerpMarket", + "name": "modify_order_by_user_id", + "discriminator": [ + 158, + 77, + 4, + 253, + 252, + 194, + 161, + 179 + ], "accounts": [ { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "user_order_id", + "type": "u8" }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "modify_order_params", + "type": { + "defined": { + "name": "ModifyOrderParams" + } + } + } + ] + }, + { + "name": "move_amm_price", + "discriminator": [ + 235, + 109, + 2, + 82, + 219, + 118, + 6, + 159 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "marketIndex", - "type": "u16" + "name": "base_asset_reserve", + "type": "u128" }, { - "name": "ammBaseAssetReserve", + "name": "quote_asset_reserve", "type": "u128" }, { - "name": "ammQuoteAssetReserve", + "name": "sqrt_k", "type": "u128" - }, + } + ] + }, + { + "name": "openbook_v2_fulfillment_config_status", + "discriminator": [ + 25, + 173, + 19, + 189, + 4, + 211, + 64, + 238 + ], + "accounts": [ { - "name": "ammPeriodicity", - "type": "i64" + "name": "state" }, { - "name": "ammPegMultiplier", - "type": "u128" + "name": "openbook_v2_fulfillment_config", + "writable": true }, { - "name": "oracleSource", - "type": { - "defined": "OracleSource" - } - }, + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ { - "name": "contractTier", + "name": "status", "type": { - "defined": "ContractTier" + "defined": { + "name": "SpotFulfillmentConfigStatus" + } } - }, + } + ] + }, + { + "name": "override_amm_cache_info", + "discriminator": [ + 189, + 198, + 128, + 9, + 49, + 145, + 201, + 115 + ], + "accounts": [ { - "name": "marginRatioInitial", - "type": "u32" + "name": "state", + "writable": true }, { - "name": "marginRatioMaintenance", - "type": "u32" + "name": "admin", + "signer": true }, { - "name": "liquidatorFee", - "type": "u32" - }, + "name": "amm_cache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ { - "name": "ifLiquidationFee", - "type": "u32" + "name": "market_index", + "type": "u16" }, { - "name": "imfFactor", - "type": "u32" - }, + "name": "override_params", + "type": { + "defined": { + "name": "OverrideAmmCacheParams" + } + } + } + ] + }, + { + "name": "pause_spot_market_deposit_withdraw", + "discriminator": [ + 183, + 119, + 59, + 170, + 137, + 35, + 242, + 86 + ], + "accounts": [ { - "name": "activeStatus", - "type": "bool" + "name": "state" }, { - "name": "baseSpread", - "type": "u32" + "name": "keeper", + "signer": true }, { - "name": "maxSpread", - "type": "u32" + "name": "spot_market", + "writable": true }, { - "name": "maxOpenInterest", - "type": "u128" - }, + "name": "spot_market_vault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spot_market" + } + ] + } + } + ], + "args": [] + }, + { + "name": "phoenix_fulfillment_config_status", + "discriminator": [ + 96, + 31, + 113, + 32, + 12, + 203, + 7, + 154 + ], + "accounts": [ { - "name": "maxRevenueWithdrawPerPeriod", - "type": "u64" + "name": "state" }, { - "name": "quoteMaxInsurance", - "type": "u64" + "name": "phoenix_fulfillment_config", + "writable": true }, { - "name": "orderStepSize", - "type": "u64" - }, + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ { - "name": "orderTickSize", - "type": "u64" + "name": "status", + "type": { + "defined": { + "name": "SpotFulfillmentConfigStatus" + } + } + } + ] + }, + { + "name": "place_and_make_perp_order", + "discriminator": [ + 149, + 117, + 11, + 237, + 47, + 95, + 89, + 237 + ], + "accounts": [ + { + "name": "state" }, { - "name": "minOrderSize", - "type": "u64" + "name": "user", + "writable": true }, { - "name": "concentrationCoefScale", - "type": "u128" + "name": "user_stats", + "writable": true }, { - "name": "curveUpdateIntensity", - "type": "u8" + "name": "taker", + "writable": true }, { - "name": "ammJitIntensity", - "type": "u8" + "name": "taker_stats", + "writable": true }, { - "name": "name", + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", "type": { - "array": [ - "u8", - 32 - ] + "defined": { + "name": "OrderParams" + } } }, { - "name": "lpPoolId", - "type": "u8" + "name": "taker_order_id", + "type": "u32" } ] }, { - "name": "initializeAmmCache", + "name": "place_and_make_signed_msg_perp_order", + "discriminator": [ + 16, + 26, + 123, + 131, + 94, + 29, + 175, + 98 + ], "accounts": [ { - "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "addMarketToAmmCache", - "accounts": [ - { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "taker", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "taker_stats", + "writable": true }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "taker_signed_msg_user_orders", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "taker" + } + ] + } }, { - "name": "perpMarket", - "isMut": false, - "isSigner": false - }, + "name": "authority", + "signer": true + } + ], + "args": [ { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "params", + "type": { + "defined": { + "name": "OrderParams" + } + } }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "signed_msg_order_uuid", + "type": { + "array": [ + "u8", + 8 + ] + } } - ], - "args": [] + ] }, { - "name": "deleteAmmCache", + "name": "place_and_make_spot_order", + "discriminator": [ + 149, + 158, + 85, + 66, + 239, + 9, + 243, + 98 + ], "accounts": [ { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "ammCache", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateInitialAmmCacheInfo", - "accounts": [ + "name": "user_stats", + "writable": true + }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "taker", + "writable": true }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "taker_stats", + "writable": true }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true } ], - "args": [] - }, - { - "name": "initializePredictionMarket", - "accounts": [ + "args": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "params", + "type": { + "defined": { + "name": "OrderParams" + } + } }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "taker_order_id", + "type": "u32" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "fulfillment_type", + "type": { + "option": { + "defined": { + "name": "SpotFulfillmentType" + } + } + } } - ], - "args": [] + ] }, { - "name": "deleteInitializedPerpMarket", + "name": "place_and_take_perp_order", + "discriminator": [ + 213, + 51, + 1, + 187, + 108, + 220, + 230, + 224 + ], "accounts": [ { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true + }, + { + "name": "user_stats", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "marketIndex", - "type": "u16" + "name": "params", + "type": { + "defined": { + "name": "OrderParams" + } + } + }, + { + "name": "success_condition", + "type": { + "option": "u32" + } } ] }, { - "name": "moveAmmPrice", + "name": "place_and_take_spot_order", + "discriminator": [ + 191, + 3, + 138, + 71, + 114, + 198, + 202, + 100 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true + }, + { + "name": "user_stats", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "baseAssetReserve", - "type": "u128" + "name": "params", + "type": { + "defined": { + "name": "OrderParams" + } + } }, { - "name": "quoteAssetReserve", - "type": "u128" + "name": "fulfillment_type", + "type": { + "option": { + "defined": { + "name": "SpotFulfillmentType" + } + } + } }, { - "name": "sqrtK", - "type": "u128" + "name": "maker_order_id", + "type": { + "option": "u32" + } } ] }, { - "name": "recenterPerpMarketAmm", + "name": "place_orders", + "discriminator": [ + 60, + 63, + 50, + 123, + 12, + 197, + 60, + 190 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "pegMultiplier", - "type": "u128" - }, - { - "name": "sqrtK", - "type": "u128" + "name": "params", + "type": { + "vec": { + "defined": { + "name": "OrderParams" + } + } + } } ] }, { - "name": "recenterPerpMarketAmmCrank", + "name": "place_perp_order", + "discriminator": [ + 69, + 161, + 93, + 202, + 120, + 126, + 76, + 185 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "spotMarket", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "depth", + "name": "params", "type": { - "option": "u128" + "defined": { + "name": "OrderParams" + } } } ] }, { - "name": "updatePerpMarketAmmSummaryStats", + "name": "place_signed_msg_taker_order", + "discriminator": [ + 32, + 79, + 101, + 139, + 25, + 6, + 98, + 15 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true + }, + { + "name": "user_stats", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "signed_msg_user_orders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "user" + } + ] + } }, { - "name": "spotMarket", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "ix_sysvar", + "docs": [ + "the supplied Sysvar could be anything else.", + "The Instruction Sysvar has not been implemented", + "in the Anchor framework yet, so this is the safe approach." + ], + "address": "Sysvar1nstructions1111111111111111111111111" } ], "args": [ { - "name": "params", - "type": { - "defined": "UpdatePerpMarketSummaryStatsParams" - } + "name": "signed_msg_order_params_message_bytes", + "type": "bytes" + }, + { + "name": "is_delegate_signer", + "type": "bool" } ] }, { - "name": "updatePerpMarketExpiry", + "name": "place_spot_order", + "discriminator": [ + 45, + 79, + 81, + 160, + 248, + 90, + 91, + 220 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "expiryTs", - "type": "i64" + "name": "params", + "type": { + "defined": { + "name": "OrderParams" + } + } } ] }, { - "name": "updatePerpMarketLpPoolPausedOperations", + "name": "post_multi_pyth_pull_oracle_updates_atomic", + "discriminator": [ + 243, + 79, + 204, + 228, + 227, + 208, + 100, + 244 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "pyth_solana_receiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "guardian_set" } ], "args": [ { - "name": "lpPausedOperations", - "type": "u8" + "name": "params", + "type": "bytes" } ] }, { - "name": "updatePerpMarketLpPoolStatus", + "name": "post_pyth_lazer_oracle_update", + "discriminator": [ + 218, + 237, + 170, + 245, + 39, + 143, + 166, + 33 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "pyth_lazer_storage", + "address": "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL" }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "ix_sysvar", + "address": "Sysvar1nstructions1111111111111111111111111" } ], "args": [ { - "name": "lpStatus", - "type": "u8" + "name": "pyth_message", + "type": "bytes" } ] }, { - "name": "updatePerpMarketLpPoolFeeTransferScalar", + "name": "post_pyth_pull_oracle_update_atomic", + "discriminator": [ + 116, + 122, + 137, + 158, + 224, + 195, + 173, + 119 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "pyth_solana_receiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "guardian_set" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "price_feed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feed_id" + } + ] + } } ], "args": [ { - "name": "optionalLpFeeTransferScalar", + "name": "feed_id", "type": { - "option": "u8" + "array": [ + "u8", + 32 + ] } }, { - "name": "optionalLpNetPnlTransferScalar", - "type": { - "option": "u8" - } + "name": "params", + "type": "bytes" } ] }, { - "name": "settleExpiredMarketPoolsToRevenuePool", + "name": "recenter_perp_market_amm", + "discriminator": [ + 24, + 87, + 10, + 115, + 165, + 190, + 80, + 139 + ], "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true } ], - "args": [] - }, - { - "name": "depositIntoPerpMarketFeePool", - "accounts": [ + "args": [ { - "name": "state", - "isMut": true, - "isSigner": false + "name": "peg_multiplier", + "type": "u128" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - }, + "name": "sqrt_k", + "type": "u128" + } + ] + }, + { + "name": "recenter_perp_market_amm_crank", + "discriminator": [ + 166, + 19, + 64, + 10, + 14, + 51, + 101, + 122 + ], + "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "sourceVault", - "isMut": true, - "isSigner": false + "signer": true }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "quoteSpotMarket", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "perp_market" + } + ] + } }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "oracle" } ], "args": [ { - "name": "amount", - "type": "u64" + "name": "depth", + "type": { + "option": "u128" + } } ] }, { - "name": "updatePerpMarketPnlPool", + "name": "reclaim_rent", + "discriminator": [ + 218, + 200, + 19, + 197, + 227, + 89, + 192, + 22 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "user_stats", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true, + "relations": [ + "user", + "user_stats" + ] }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" } ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] + "args": [] }, { - "name": "depositIntoSpotMarketVault", + "name": "remove_amm_constituent_mapping_data", + "discriminator": [ + 20, + 183, + 211, + 162, + 16, + 52, + 229, + 115 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "lp_pool" }, { - "name": "sourceVault", - "isMut": true, - "isSigner": false + "name": "amm_constituent_mapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "amount", - "type": "u64" + "name": "perp_market_index", + "type": "u16" + }, + { + "name": "constituent_index", + "type": "u16" } ] }, { - "name": "depositIntoSpotMarketRevenuePool", + "name": "remove_insurance_fund_stake", + "discriminator": [ + 128, + 166, + 142, + 9, + 254, + 187, + 143, + 174 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" + }, + { + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, + { + "name": "insurance_fund_stake", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { "name": "authority", - "isMut": true, - "isSigner": true + "signer": true, + "relations": [ + "insurance_fund_stake", + "user_stats" + ] + }, + { + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "userTokenAccount", - "isMut": true, - "isSigner": false + "name": "user_token_account", + "writable": true }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "amount", - "type": "u64" + "name": "market_index", + "type": "u16" } ] }, { - "name": "repegAmmCurve", + "name": "repeg_amm_curve", + "discriminator": [ + 3, + 36, + 102, + 89, + 180, + 128, + 120, + 213 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "oracle" }, { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] } ], "args": [ { - "name": "newPegCandidate", + "name": "new_peg_candidate", "type": "u128" } ] }, { - "name": "updatePerpMarketAmmOracleTwap", + "name": "request_remove_insurance_fund_stake", + "discriminator": [ + 142, + 70, + 204, + 92, + 73, + 106, + 180, + 52 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "insurance_fund_stake", + "writable": true }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "authority", + "signer": true, + "relations": [ + "insurance_fund_stake", + "user_stats" + ] + }, + { + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } } ], - "args": [] + "args": [ + { + "name": "market_index", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] }, { - "name": "resetPerpMarketAmmOracleTwap", + "name": "reset_fuel_season", + "discriminator": [ + 199, + 122, + 192, + 255, + 32, + 99, + 63, + 200 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "authority", + "relations": [ + "user_stats" + ] }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "state" }, { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true } ], "args": [] }, { - "name": "updateK", + "name": "reset_perp_market_amm_oracle_twap", + "discriminator": [ + 127, + 10, + 55, + 164, + 123, + 226, + 47, + 24 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "oracle" }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] } ], - "args": [ - { - "name": "sqrtK", - "type": "u128" - } - ] + "args": [] }, { - "name": "updatePerpMarketMarginRatio", + "name": "resize_revenue_share_escrow_orders", + "discriminator": [ + 32, + 124, + 247, + 225, + 151, + 213, + 225, + 38 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "authority", + "relations": [ + "escrow" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marginRatioInitial", - "type": "u32" - }, - { - "name": "marginRatioMaintenance", - "type": "u32" + "name": "num_orders", + "type": "u16" } ] }, { - "name": "updatePerpMarketHighLeverageMarginRatio", + "name": "resize_signed_msg_user_orders", + "discriminator": [ + 137, + 10, + 87, + 150, + 18, + 115, + 79, + 168 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "signed_msg_user_orders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "authority", + "relations": [ + "user" + ] + }, + { + "name": "user" + }, + { + "name": "payer", + "writable": true, + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "marginRatioInitial", - "type": "u16" - }, - { - "name": "marginRatioMaintenance", + "name": "num_orders", "type": "u16" } ] }, { - "name": "updatePerpMarketFundingPeriod", + "name": "resolve_perp_bankruptcy", + "discriminator": [ + 224, + 16, + 176, + 214, + 162, + 213, + 183, + 222 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "fundingPeriod", - "type": "i64" - } - ] - }, - { - "name": "updatePerpMarketMaxImbalances", - "accounts": [ - { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "liquidator", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "liquidator_stats", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "unrealizedMaxImbalance", - "type": "u64" + "name": "user", + "writable": true }, { - "name": "maxRevenueWithdrawPerPeriod", - "type": "u64" + "name": "user_stats", + "writable": true }, { - "name": "quoteMaxInsurance", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketLiquidationFee", - "accounts": [ + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } + }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "drift_signer" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "liquidatorFee", - "type": "u32" + "name": "quote_spot_market_index", + "type": "u16" }, { - "name": "ifLiquidationFee", - "type": "u32" + "name": "market_index", + "type": "u16" } ] }, { - "name": "updatePerpMarketLpPoolId", + "name": "resolve_perp_pnl_deficit", + "discriminator": [ + 168, + 204, + 68, + 150, + 159, + 126, + 95, + 148 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "lpPoolId", - "type": "u8" - } - ] - }, - { - "name": "updateInsuranceFundUnstakingPeriod", - "accounts": [ + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } + }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "drift_signer" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "insuranceFundUnstakingPeriod", - "type": "i64" + "name": "spot_market_index", + "type": "u16" + }, + { + "name": "perp_market_index", + "type": "u16" } ] }, { - "name": "updateSpotMarketPoolId", + "name": "resolve_spot_bankruptcy", + "discriminator": [ + 124, + 194, + 240, + 254, + 198, + 213, + 52, + 122 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "poolId", - "type": "u8" - } - ] - }, - { - "name": "updateSpotMarketLiquidationFee", - "accounts": [ - { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "liquidator", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "liquidator_stats", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "user", + "writable": true + }, { - "name": "liquidatorFee", - "type": "u32" + "name": "user_stats", + "writable": true }, { - "name": "ifLiquidationFee", - "type": "u32" - } - ] - }, - { - "name": "updateWithdrawGuardThreshold", - "accounts": [ + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } + }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spot_market_index" + } + ] + } }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "drift_signer" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "withdrawGuardThreshold", - "type": "u64" + "name": "market_index", + "type": "u16" } ] }, { - "name": "updateSpotMarketIfFactor", + "name": "revert_fill", + "discriminator": [ + 236, + 238, + 176, + 69, + 239, + 10, + 181, + 193 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "filler", + "writable": true + }, + { + "name": "filler_stats", + "writable": true } ], - "args": [ + "args": [] + }, + { + "name": "set_user_status_to_being_liquidated", + "discriminator": [ + 106, + 133, + 160, + 206, + 193, + 171, + 192, + 194 + ], + "accounts": [ { - "name": "spotMarketIndex", - "type": "u16" + "name": "state" }, { - "name": "userIfFactor", - "type": "u32" + "name": "user", + "writable": true }, { - "name": "totalIfFactor", - "type": "u32" + "name": "authority", + "signer": true } - ] + ], + "args": [] }, { - "name": "updateSpotMarketRevenueSettlePeriod", + "name": "settle_expired_market", + "discriminator": [ + 120, + 89, + 11, + 25, + 122, + 77, + 72, + 193 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "revenueSettlePeriod", - "type": "i64" + "name": "market_index", + "type": "u16" } ] }, { - "name": "updateSpotMarketStatus", + "name": "settle_expired_market_pools_to_revenue_pool", + "discriminator": [ + 55, + 19, + 238, + 169, + 227, + 90, + 200, + 184 + ], "accounts": [ + { + "name": "state" + }, { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true } ], - "args": [ - { - "name": "status", - "type": { - "defined": "MarketStatus" - } - } - ] + "args": [] }, { - "name": "updateSpotMarketPausedOperations", + "name": "settle_funding_payment", + "discriminator": [ + 222, + 90, + 202, + 94, + 28, + 45, + 115, + 183 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true } ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] + "args": [] }, { - "name": "updateSpotMarketAssetTier", + "name": "settle_multiple_pnls", + "discriminator": [ + 127, + 66, + 117, + 57, + 40, + 50, + 152, + 127 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "spot_market_vault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } } ], "args": [ { - "name": "assetTier", + "name": "market_indexes", + "type": { + "vec": "u16" + } + }, + { + "name": "mode", "type": { - "defined": "AssetTier" + "defined": { + "name": "SettlePnlMode" + } } } ] }, { - "name": "updateSpotMarketMarginWeights", + "name": "settle_perp_to_lp_pool", + "discriminator": [ + 5, + 98, + 46, + 188, + 10, + 59, + 2, + 249 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "lp_pool", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "initialAssetWeight", - "type": "u32" + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "maintenanceAssetWeight", - "type": "u32" + "name": "amm_cache", + "writable": true }, { - "name": "initialLiabilityWeight", - "type": "u32" + "name": "quote_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "maintenanceLiabilityWeight", - "type": "u32" + "name": "constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "imfFactor", - "type": "u32" - } - ] - }, - { - "name": "updateSpotMarketBorrowRate", - "accounts": [ + "name": "constituent_quote_token_account", + "writable": true + }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "quote_token_vault", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "token_program" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "drift_signer" } ], - "args": [ + "args": [] + }, + { + "name": "settle_pnl", + "discriminator": [ + 43, + 61, + 234, + 45, + 15, + 95, + 152, + 153 + ], + "accounts": [ { - "name": "optimalUtilization", - "type": "u32" + "name": "state" }, { - "name": "optimalBorrowRate", - "type": "u32" + "name": "user", + "writable": true }, { - "name": "maxBorrowRate", - "type": "u32" + "name": "authority", + "signer": true }, { - "name": "minBorrowRate", - "type": { - "option": "u8" - } - } + "name": "spot_market_vault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [ + { + "name": "market_index", + "type": "u16" + } ] }, { - "name": "updateSpotMarketMaxTokenDeposits", + "name": "settle_revenue_to_insurance_fund", + "discriminator": [ + 200, + 120, + 93, + 136, + 69, + 38, + 199, + 159 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, + { + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, + { + "name": "drift_signer" + }, + { + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "maxTokenDeposits", - "type": "u64" + "name": "spot_market_index", + "type": "u16" } ] }, { - "name": "updateSpotMarketMaxTokenBorrows", + "name": "sweep_fuel", + "discriminator": [ + 175, + 107, + 19, + 56, + 165, + 241, + 43, + 69 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "fuel_overflow", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "authority", + "relations": [ + "fuel_overflow", + "user_stats" + ] + }, { - "name": "maxTokenBorrowsFraction", - "type": "u16" + "name": "signer", + "signer": true } - ] + ], + "args": [] }, { - "name": "updateSpotMarketScaleInitialAssetWeightStart", + "name": "transfer_deposit", + "discriminator": [ + 20, + 20, + 147, + 223, + 41, + 63, + 204, + 111 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "from_user", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "to_user", + "writable": true + }, + { + "name": "user_stats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "from_user", + "to_user", + "user_stats" + ] }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "spot_market_vault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } } ], "args": [ { - "name": "scaleInitialAssetWeightStart", + "name": "market_index", + "type": "u16" + }, + { + "name": "amount", "type": "u64" } ] }, { - "name": "updateSpotMarketOracle", + "name": "transfer_perp_position", + "discriminator": [ + 23, + 172, + 188, + 168, + 134, + 210, + 3, + 108 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "from_user", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "to_user", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "oldOracle", - "isMut": false, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "oracle", - "type": "publicKey" + "name": "market_index", + "type": "u16" }, { - "name": "oracleSource", + "name": "amount", "type": { - "defined": "OracleSource" + "option": "i64" } - }, - { - "name": "skipInvariantCheck", - "type": "bool" } ] }, { - "name": "updateSpotMarketStepSizeAndTickSize", + "name": "transfer_pools", + "discriminator": [ + 197, + 103, + 154, + 25, + 107, + 90, + 60, + 94 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "from_user", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "to_user", + "writable": true + }, + { + "name": "user_stats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "from_user", + "to_user", + "user_stats" + ] + }, + { + "name": "state" + }, + { + "name": "deposit_from_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "deposit_from_market_index" + } + ] + } + }, + { + "name": "deposit_to_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "deposit_to_market_index" + } + ] + } + }, + { + "name": "borrow_from_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "borrow_from_market_index" + } + ] + } + }, + { + "name": "borrow_to_spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "borrow_to_market_index" + } + ] + } }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "drift_signer" } ], "args": [ { - "name": "stepSize", - "type": "u64" + "name": "deposit_from_market_index", + "type": "u16" }, { - "name": "tickSize", - "type": "u64" + "name": "deposit_to_market_index", + "type": "u16" + }, + { + "name": "borrow_from_market_index", + "type": "u16" + }, + { + "name": "borrow_to_market_index", + "type": "u16" + }, + { + "name": "deposit_amount", + "type": { + "option": "u64" + } + }, + { + "name": "borrow_amount", + "type": { + "option": "u64" + } } ] }, { - "name": "updateSpotMarketMinOrderSize", + "name": "transfer_protocol_if_shares_to_revenue_pool", + "discriminator": [ + 236, + 136, + 147, + 153, + 146, + 205, + 104, + 29 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, + { + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, + { + "name": "if_rebalance_config", + "writable": true + }, + { + "name": "token_program" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "drift_signer" } ], "args": [ { - "name": "orderSize", + "name": "market_index", + "type": "u16" + }, + { + "name": "amount", "type": "u64" } ] }, { - "name": "updateSpotMarketOrdersEnabled", + "name": "trigger_order", + "discriminator": [ + 63, + 112, + 51, + 233, + 232, + 47, + 240, + 199 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true } ], "args": [ { - "name": "ordersEnabled", - "type": "bool" + "name": "order_id", + "type": "u32" } ] }, { - "name": "updateSpotMarketIfPausedOperations", + "name": "update_admin", + "discriminator": [ + 161, + 176, + 40, + 213, + 60, + 184, + 179, + 228 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "pausedOperations", - "type": "u8" + "name": "admin", + "type": "pubkey" } ] }, { - "name": "updateSpotMarketName", + "name": "update_amm_cache", + "discriminator": [ + 88, + 4, + 63, + 94, + 83, + 224, + 255, + 130 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "amm_cache", + "writable": true + }, { - "name": "name", - "type": { - "array": [ - "u8", - 32 + "name": "quote_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } ] } } - ] + ], + "args": [] }, { - "name": "updatePerpMarketStatus", + "name": "update_amm_constituent_mapping_data", + "discriminator": [ + 84, + 70, + 33, + 167, + 133, + 107, + 59, + 24 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "lp_pool" + }, + { + "name": "amm_constituent_mapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "status", + "name": "amm_constituent_mapping_data", "type": { - "defined": "MarketStatus" + "vec": { + "defined": { + "name": "AddAmmConstituentMappingDatum" + } + } } } ] }, { - "name": "updatePerpMarketPausedOperations", + "name": "update_amm_jit_intensity", + "discriminator": [ + 181, + 191, + 53, + 109, + 166, + 249, + 55, + 142 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "pausedOperations", + "name": "amm_jit_intensity", "type": "u8" } ] }, { - "name": "updatePerpMarketContractTier", + "name": "update_amms", + "discriminator": [ + 201, + 106, + 217, + 253, + 4, + 175, + 228, + 97 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "contractTier", + "name": "market_indexes", "type": { - "defined": "ContractTier" + "vec": "u16" } } ] }, { - "name": "updatePerpMarketImfFactor", + "name": "update_constituent_correlation_data", + "discriminator": [ + 79, + 14, + 19, + 73, + 221, + 106, + 62, + 109 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "lp_pool" + }, + { + "name": "constituent_correlations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "imfFactor", - "type": "u32" + "name": "index1", + "type": "u16" }, { - "name": "unrealizedPnlImfFactor", - "type": "u32" - } - ] + "name": "index2", + "type": "u16" + }, + { + "name": "correlation", + "type": "i64" + } + ] }, { - "name": "updatePerpMarketUnrealizedAssetWeight", + "name": "update_constituent_oracle_info", + "discriminator": [ + 198, + 117, + 231, + 250, + 147, + 33, + 127, + 161 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "constituent", + "writable": true + }, { - "name": "unrealizedInitialAssetWeight", - "type": "u32" + "name": "spot_market" }, { - "name": "unrealizedMaintenanceAssetWeight", - "type": "u32" + "name": "oracle" } - ] + ], + "args": [] }, { - "name": "updatePerpMarketConcentrationCoef", + "name": "update_constituent_params", + "discriminator": [ + 238, + 130, + 122, + 31, + 12, + 104, + 192, + 122 + ], "accounts": [ + { + "name": "lp_pool" + }, + { + "name": "constituent_target_base", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lp_pool" + } + ] + } + }, { "name": "admin", - "isMut": false, - "isSigner": true + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "constituent", + "writable": true } ], "args": [ { - "name": "concentrationScale", - "type": "u128" + "name": "constituent_params", + "type": { + "defined": { + "name": "ConstituentParams" + } + } } ] }, { - "name": "updatePerpMarketCurveUpdateIntensity", + "name": "update_constituent_paused_operations", + "discriminator": [ + 185, + 122, + 153, + 191, + 131, + 177, + 132, + 208 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "constituent", + "writable": true } ], "args": [ { - "name": "curveUpdateIntensity", + "name": "paused_operations", "type": "u8" } ] }, { - "name": "updatePerpMarketReferencePriceOffsetDeadbandPct", + "name": "update_constituent_status", + "discriminator": [ + 76, + 159, + 211, + 239, + 182, + 214, + 6, + 15 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "writable": true, + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "constituent", + "writable": true } ], "args": [ { - "name": "referencePriceOffsetDeadbandPct", + "name": "new_status", "type": "u8" } ] }, { - "name": "updatePerpFeeStructure", + "name": "update_delegate_user_gov_token_insurance_stake", + "discriminator": [ + 241, + 29, + 215, + 228, + 142, + 116, + 22, + 160 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } }, { - "name": "state", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "insurance_fund_stake" + }, { - "name": "feeStructure", - "type": { - "defined": "FeeStructure" + "name": "user_stats", + "writable": true + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] } + }, + { + "name": "state" } - ] + ], + "args": [] }, { - "name": "updateSpotFeeStructure", + "name": "update_discount_mint", + "discriminator": [ + 32, + 252, + 122, + 211, + 66, + 31, + 47, + 241 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "feeStructure", - "type": { - "defined": "FeeStructure" - } + "name": "discount_mint", + "type": "pubkey" } ] }, { - "name": "updateInitialPctToLiquidate", + "name": "update_exchange_status", + "discriminator": [ + 83, + 160, + 252, + 250, + 129, + 116, + 49, + 223 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "initialPctToLiquidate", - "type": "u16" + "name": "exchange_status", + "type": "u8" } ] }, { - "name": "updateLiquidationDuration", + "name": "update_feature_bit_flags_builder_codes", + "discriminator": [ + 1, + 128, + 177, + 51, + 173, + 45, + 11, + 102 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "liquidationDuration", - "type": "u8" + "name": "enable", + "type": "bool" } ] }, { - "name": "updateLiquidationMarginBufferRatio", + "name": "update_feature_bit_flags_median_trigger_price", + "discriminator": [ + 64, + 185, + 221, + 45, + 87, + 147, + 12, + 19 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "liquidationMarginBufferRatio", - "type": "u32" + "name": "enable", + "type": "bool" } ] }, { - "name": "updateOracleGuardRails", + "name": "update_feature_bit_flags_mint_redeem_lp_pool", + "discriminator": [ + 26, + 11, + 142, + 122, + 206, + 159, + 9, + 45 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "oracleGuardRails", - "type": { - "defined": "OracleGuardRails" - } + "name": "enable", + "type": "bool" } ] }, { - "name": "updateStateSettlementDuration", + "name": "update_feature_bit_flags_mm_oracle", + "discriminator": [ + 218, + 134, + 33, + 186, + 231, + 59, + 130, + 149 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "settlementDuration", - "type": "u16" + "name": "enable", + "type": "bool" } ] }, { - "name": "updateStateMaxNumberOfSubAccounts", + "name": "update_feature_bit_flags_settle_lp_pool", + "discriminator": [ + 186, + 28, + 78, + 230, + 155, + 83, + 242, + 26 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "maxNumberOfSubAccounts", - "type": "u16" + "name": "enable", + "type": "bool" } ] }, { - "name": "updateStateMaxInitializeUserFee", + "name": "update_feature_bit_flags_swap_lp_pool", + "discriminator": [ + 83, + 16, + 150, + 12, + 102, + 3, + 22, + 58 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { "name": "state", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "maxInitializeUserFee", - "type": "u16" + "name": "enable", + "type": "bool" } ] }, { - "name": "updatePerpMarketOracle", + "name": "update_funding_rate", + "discriminator": [ + 201, + 178, + 116, + 212, + 166, + 144, + 72, + 238 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - }, + "name": "oracle" + } + ], + "args": [ { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "market_index", + "type": "u16" + } + ] + }, + { + "name": "update_high_leverage_mode_config", + "discriminator": [ + 64, + 122, + 212, + 93, + 141, + 217, + 202, + 55 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "oldOracle", - "isMut": false, - "isSigner": false + "name": "high_leverage_mode_config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "oracle", - "type": "publicKey" + "name": "max_users", + "type": "u32" }, { - "name": "oracleSource", - "type": { - "defined": "OracleSource" - } + "name": "reduce_only", + "type": "bool" }, { - "name": "skipInvariantCheck", - "type": "bool" + "name": "current_users", + "type": { + "option": "u32" + } } ] }, { - "name": "updatePerpMarketBaseSpread", + "name": "update_if_rebalance_config", + "discriminator": [ + 142, + 245, + 249, + 66, + 249, + 181, + 22, + 83 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "if_rebalance_config", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "baseSpread", - "type": "u32" + "name": "params", + "type": { + "defined": { + "name": "IfRebalanceConfigParams" + } + } } ] }, { - "name": "updateAmmJitIntensity", + "name": "update_initial_amm_cache_info", + "discriminator": [ + 157, + 210, + 109, + 67, + 212, + 170, + 12, + 107 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "amm_cache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } } ], - "args": [ - { - "name": "ammJitIntensity", - "type": "u8" - } - ] + "args": [] }, { - "name": "updatePerpMarketMaxSpread", + "name": "update_initial_pct_to_liquidate", + "discriminator": [ + 210, + 133, + 225, + 128, + 194, + 50, + 13, + 109 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "maxSpread", - "type": "u32" + "name": "initial_pct_to_liquidate", + "type": "u16" } ] }, { - "name": "updatePerpMarketStepSizeAndTickSize", + "name": "update_insurance_fund_unstaking_period", + "discriminator": [ + 44, + 69, + 43, + 226, + 204, + 223, + 202, + 52 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true } ], "args": [ { - "name": "stepSize", - "type": "u64" - }, - { - "name": "tickSize", - "type": "u64" + "name": "insurance_fund_unstaking_period", + "type": "i64" } ] }, { - "name": "updatePerpMarketName", + "name": "update_k", + "discriminator": [ + 72, + 98, + 9, + 139, + 129, + 229, + 172, + 56 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "oracle" } ], "args": [ { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } + "name": "sqrt_k", + "type": "u128" } ] }, { - "name": "updatePerpMarketMinOrderSize", + "name": "update_liquidation_duration", + "discriminator": [ + 28, + 154, + 20, + 249, + 102, + 192, + 73, + 71 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "orderSize", - "type": "u64" + "name": "liquidation_duration", + "type": "u8" } ] }, { - "name": "updatePerpMarketMaxSlippageRatio", + "name": "update_liquidation_margin_buffer_ratio", + "discriminator": [ + 132, + 224, + 243, + 160, + 154, + 82, + 97, + 215 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "maxSlippageRatio", - "type": "u16" + "name": "liquidation_margin_buffer_ratio", + "type": "u32" } ] }, { - "name": "updatePerpMarketMaxFillReserveFraction", + "name": "update_lp_constituent_target_base", + "discriminator": [ + 157, + 65, + 50, + 207, + 59, + 236, + 161, + 110 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "amm_constituent_mapping" + }, { - "name": "maxFillReserveFraction", - "type": "u16" + "name": "constituent_target_base", + "writable": true + }, + { + "name": "amm_cache" + }, + { + "name": "lp_pool" } - ] + ], + "args": [] }, { - "name": "updatePerpMarketMaxOpenInterest", + "name": "update_lp_pool_aum", + "discriminator": [ + 88, + 113, + 137, + 206, + 246, + 247, + 171, + 142 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "lp_pool", + "writable": true + }, { - "name": "maxOpenInterest", - "type": "u128" + "name": "constituent_target_base", + "writable": true + }, + { + "name": "amm_cache", + "writable": true } - ] + ], + "args": [] }, { - "name": "updatePerpMarketNumberOfUsers", + "name": "update_lp_pool_params", + "discriminator": [ + 217, + 92, + 2, + 255, + 27, + 167, + 178, + 81 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "lp_pool", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "numberOfUsers", - "type": { - "option": "u32" - } - }, - { - "name": "numberOfUsersWithBase", + "name": "lp_pool_params", "type": { - "option": "u32" + "defined": { + "name": "LpPoolParams" + } } } ] }, { - "name": "updatePerpMarketFeeAdjustment", + "name": "update_oracle_guard_rails", + "discriminator": [ + 131, + 112, + 10, + 59, + 32, + 54, + 40, + 164 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "feeAdjustment", - "type": "i16" + "name": "oracle_guard_rails", + "type": { + "defined": { + "name": "OracleGuardRails" + } + } } ] }, { - "name": "updateSpotMarketFeeAdjustment", + "name": "update_perp_auction_duration", + "discriminator": [ + 126, + 110, + 52, + 174, + 30, + 206, + 215, + 90 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "feeAdjustment", - "type": "i16" + "name": "min_perp_auction_duration", + "type": "u8" } ] }, { - "name": "updatePerpMarketProtectedMakerParams", + "name": "update_perp_bid_ask_twap", + "discriminator": [ + 247, + 23, + 255, + 65, + 212, + 90, + 221, + 194 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "keeper_stats" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true } ], - "args": [ + "args": [] + }, + { + "name": "update_perp_fee_structure", + "discriminator": [ + 23, + 178, + 111, + 203, + 73, + 22, + 140, + 75 + ], + "accounts": [ { - "name": "protectedMakerLimitPriceDivisor", - "type": { - "option": "u8" - } + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "protectedMakerDynamicDivisor", + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "fee_structure", "type": { - "option": "u8" + "defined": { + "name": "FeeStructure" + } } } ] }, { - "name": "updatePerpMarketOracleLowRiskSlotDelayOverride", + "name": "update_perp_market_amm_oracle_twap", + "discriminator": [ + 241, + 74, + 114, + 123, + 206, + 153, + 24, + 202 + ], "accounts": [ { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "oracle" + }, { - "name": "oracleLowRiskSlotDelayOverride", - "type": "i8" + "name": "admin", + "signer": true, + "relations": [ + "state" + ] } - ] + ], + "args": [] }, { - "name": "updatePerpMarketAmmSpreadAdjustment", + "name": "update_perp_market_amm_spread_adjustment", + "discriminator": [ + 155, + 195, + 149, + 43, + 220, + 82, + 173, + 205 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "ammSpreadAdjustment", + "name": "amm_spread_adjustment", "type": "i8" }, { - "name": "ammInventorySpreadAdjustment", + "name": "amm_inventory_spread_adjustment", "type": "i8" }, { - "name": "referencePriceOffset", + "name": "reference_price_offset", "type": "i32" } ] }, { - "name": "updatePerpMarketOracleSlotDelayOverride", + "name": "update_perp_market_amm_summary_stats", + "discriminator": [ + 122, + 101, + 249, + 238, + 209, + 9, + 241, + 245 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true + }, + { + "name": "spot_market", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "perp_market" + } + ] + } }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "oracle" } ], "args": [ { - "name": "oracleSlotDelayOverride", - "type": "i8" + "name": "params", + "type": { + "defined": { + "name": "UpdatePerpMarketSummaryStatsParams" + } + } } ] }, { - "name": "updateAdmin", + "name": "update_perp_market_base_spread", + "discriminator": [ + 71, + 95, + 84, + 168, + 9, + 157, + 198, + 65 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "admin", - "type": "publicKey" + "name": "base_spread", + "type": "u32" } ] }, { - "name": "updateDiscountMint", + "name": "update_perp_market_concentration_coef", + "discriminator": [ + 24, + 78, + 232, + 126, + 169, + 176, + 230, + 16 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "discountMint", - "type": "publicKey" + "name": "concentration_scale", + "type": "u128" } ] }, { - "name": "updateExchangeStatus", + "name": "update_perp_market_contract_tier", + "discriminator": [ + 236, + 128, + 15, + 95, + 203, + 214, + 68, + 117 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "exchangeStatus", - "type": "u8" + "name": "contract_tier", + "type": { + "defined": { + "name": "ContractTier" + } + } } ] }, { - "name": "updatePerpAuctionDuration", + "name": "update_perp_market_curve_update_intensity", + "discriminator": [ + 50, + 131, + 6, + 156, + 226, + 231, + 189, + 72 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "minPerpAuctionDuration", + "name": "curve_update_intensity", "type": "u8" } ] }, { - "name": "updateSpotAuctionDuration", + "name": "update_perp_market_expiry", + "discriminator": [ + 44, + 221, + 227, + 151, + 131, + 140, + 22, + 110 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "defaultSpotAuctionDuration", - "type": "u8" + "name": "expiry_ts", + "type": "i64" } ] }, { - "name": "initializePrelaunchOracle", + "name": "update_perp_market_fee_adjustment", + "discriminator": [ + 194, + 174, + 87, + 102, + 43, + 148, + 32, + 112 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "prelaunchOracle", - "isMut": true, - "isSigner": false - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "params", - "type": { - "defined": "PrelaunchOracleParams" - } + "name": "fee_adjustment", + "type": "i16" } ] }, { - "name": "updatePrelaunchOracleParams", + "name": "update_perp_market_funding_period", + "discriminator": [ + 171, + 161, + 69, + 91, + 129, + 139, + 161, + 28 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "prelaunchOracle", - "isMut": true, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "params", - "type": { - "defined": "PrelaunchOracleParams" - } + "name": "funding_period", + "type": "i64" } ] }, { - "name": "deletePrelaunchOracle", + "name": "update_perp_market_high_leverage_margin_ratio", + "discriminator": [ + 88, + 112, + 86, + 49, + 24, + 116, + 74, + 157 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "prelaunchOracle", - "isMut": true, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "perpMarket", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "perpMarketIndex", + "name": "margin_ratio_initial", + "type": "u16" + }, + { + "name": "margin_ratio_maintenance", "type": "u16" } ] }, { - "name": "initializePythPullOracle", + "name": "update_perp_market_imf_factor", + "discriminator": [ + 207, + 194, + 56, + 132, + 35, + 67, + 71, + 244 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "pythSolanaReceiver", - "isMut": false, - "isSigner": false - }, - { - "name": "priceFeed", - "isMut": true, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } + "name": "imf_factor", + "type": "u32" + }, + { + "name": "unrealized_pnl_imf_factor", + "type": "u32" } ] }, { - "name": "initializePythLazerOracle", + "name": "update_perp_market_liquidation_fee", + "discriminator": [ + 90, + 137, + 9, + 145, + 41, + 8, + 148, + 117 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "lazerOracle", - "isMut": true, - "isSigner": false - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "feedId", + "name": "liquidator_fee", + "type": "u32" + }, + { + "name": "if_liquidation_fee", "type": "u32" } ] }, { - "name": "postPythLazerOracleUpdate", + "name": "update_perp_market_lp_pool_fee_transfer_scalar", + "discriminator": [ + 94, + 228, + 237, + 109, + 100, + 185, + 4, + 81 + ], "accounts": [ { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "admin", + "signer": true }, { - "name": "pythLazerStorage", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "ixSysvar", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "pythMessage", - "type": "bytes" + "name": "optional_lp_fee_transfer_scalar", + "type": { + "option": "u8" + } + }, + { + "name": "optional_lp_net_pnl_transfer_scalar", + "type": { + "option": "u8" + } } ] }, { - "name": "initializeHighLeverageModeConfig", + "name": "update_perp_market_lp_pool_id", + "discriminator": [ + 119, + 208, + 154, + 88, + 165, + 92, + 21, + 188 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "highLeverageModeConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "maxUsers", - "type": "u32" + "name": "lp_pool_id", + "type": "u8" } ] }, { - "name": "updateHighLeverageModeConfig", + "name": "update_perp_market_lp_pool_paused_operations", + "discriminator": [ + 181, + 94, + 93, + 146, + 51, + 89, + 32, + 135 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "highLeverageModeConfig", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "bool" - }, - { - "name": "currentUsers", - "type": { - "option": "u32" - } + "name": "lp_paused_operations", + "type": "u8" } ] }, { - "name": "initializeProtectedMakerModeConfig", + "name": "update_perp_market_lp_pool_status", + "discriminator": [ + 67, + 6, + 252, + 61, + 54, + 88, + 89, + 233 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "protectedMakerModeConfig", - "isMut": true, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "amm_cache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } } ], "args": [ { - "name": "maxUsers", - "type": "u32" + "name": "lp_status", + "type": "u8" } ] }, { - "name": "updateProtectedMakerModeConfig", + "name": "update_perp_market_margin_ratio", + "discriminator": [ + 130, + 173, + 107, + 45, + 119, + 105, + 26, + 113 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "protectedMakerModeConfig", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "maxUsers", + "name": "margin_ratio_initial", "type": "u32" }, { - "name": "reduceOnly", - "type": "bool" - }, - { - "name": "currentUsers", - "type": { - "option": "u32" - } + "name": "margin_ratio_maintenance", + "type": "u32" } ] }, { - "name": "adminDeposit", + "name": "update_perp_market_max_fill_reserve_fraction", + "discriminator": [ + 19, + 172, + 114, + 154, + 42, + 135, + 161, + 133 + ], "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false - }, { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "adminTokenAccount", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "marketIndex", + "name": "max_fill_reserve_fraction", "type": "u16" - }, - { - "name": "amount", - "type": "u64" } ] }, { - "name": "initializeIfRebalanceConfig", + "name": "update_perp_market_max_imbalances", + "discriminator": [ + 15, + 206, + 73, + 133, + 60, + 8, + 86, + 89 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "ifRebalanceConfig", - "isMut": true, - "isSigner": false - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "params", - "type": { - "defined": "IfRebalanceConfigParams" - } + "name": "unrealized_max_imbalance", + "type": "u64" + }, + { + "name": "max_revenue_withdraw_per_period", + "type": "u64" + }, + { + "name": "quote_max_insurance", + "type": "u64" } ] }, { - "name": "updateIfRebalanceConfig", + "name": "update_perp_market_max_open_interest", + "discriminator": [ + 194, + 79, + 149, + 224, + 246, + 102, + 186, + 140 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "ifRebalanceConfig", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "params", - "type": { - "defined": "IfRebalanceConfigParams" - } + "name": "max_open_interest", + "type": "u128" } ] }, { - "name": "updateFeatureBitFlagsMmOracle", + "name": "update_perp_market_max_slippage_ratio", + "discriminator": [ + 235, + 37, + 40, + 196, + 70, + 146, + 54, + 201 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "enable", - "type": "bool" + "name": "max_slippage_ratio", + "type": "u16" } ] }, { - "name": "zeroMmOracleFields", + "name": "update_perp_market_max_spread", + "discriminator": [ + 80, + 252, + 122, + 62, + 40, + 218, + 91, + 100 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "perpMarket", - "isMut": true, - "isSigner": false + "name": "perp_market", + "writable": true } ], - "args": [] - }, + "args": [ + { + "name": "max_spread", + "type": "u32" + } + ] + }, { - "name": "updateFeatureBitFlagsMedianTriggerPrice", + "name": "update_perp_market_min_order_size", + "discriminator": [ + 226, + 74, + 5, + 89, + 108, + 223, + 46, + 141 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "enable", - "type": "bool" + "name": "order_size", + "type": "u64" } ] }, { - "name": "updateFeatureBitFlagsBuilderCodes", + "name": "update_perp_market_name", + "discriminator": [ + 211, + 31, + 21, + 210, + 64, + 108, + 66, + 201 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "enable", - "type": "bool" + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } } ] }, { - "name": "initializeRevenueShare", + "name": "update_perp_market_number_of_users", + "discriminator": [ + 35, + 62, + 144, + 177, + 180, + 62, + 215, + 196 + ], "accounts": [ { - "name": "revenueShare", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "authority", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "payer", - "isMut": true, - "isSigner": true - }, + "name": "perp_market", + "writable": true + } + ], + "args": [ { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "number_of_users", + "type": { + "option": "u32" + } }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "number_of_users_with_base", + "type": { + "option": "u32" + } } - ], - "args": [] + ] }, { - "name": "initializeRevenueShareEscrow", + "name": "update_perp_market_oracle", + "discriminator": [ + 182, + 113, + 111, + 160, + 67, + 174, + 89, + 191 + ], "accounts": [ { - "name": "escrow", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "oracle" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "old_oracle" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "amm_cache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } } ], "args": [ { - "name": "numOrders", - "type": "u16" + "name": "oracle", + "type": "pubkey" + }, + { + "name": "oracle_source", + "type": { + "defined": { + "name": "OracleSource" + } + } + }, + { + "name": "skip_invariant_check", + "type": "bool" } ] }, { - "name": "resizeRevenueShareEscrowOrders", + "name": "update_perp_market_oracle_low_risk_slot_delay_override", + "discriminator": [ + 124, + 108, + 147, + 229, + 109, + 117, + 123, + 3 + ], "accounts": [ { - "name": "escrow", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "numOrders", - "type": "u16" + "name": "oracle_low_risk_slot_delay_override", + "type": "i8" } ] }, { - "name": "changeApprovedBuilder", + "name": "update_perp_market_oracle_slot_delay_override", + "discriminator": [ + 165, + 91, + 239, + 227, + 63, + 172, + 227, + 8 + ], "accounts": [ { - "name": "escrow", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "admin", + "signer": true }, { - "name": "payer", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "builder", - "type": "publicKey" - }, - { - "name": "maxFeeBps", - "type": "u16" - }, - { - "name": "add", - "type": "bool" + "name": "oracle_slot_delay_override", + "type": "i8" } ] }, { - "name": "initializeLpPool", + "name": "update_perp_market_paused_operations", + "discriminator": [ + 53, + 16, + 136, + 132, + 30, + 220, + 121, + 85 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "lpPool", - "isMut": true, - "isSigner": false - }, - { - "name": "mint", - "isMut": false, - "isSigner": false + "signer": true }, { - "name": "lpPoolTokenVault", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "ammConstituentMapping", - "isMut": true, - "isSigner": false - }, + "name": "perp_market", + "writable": true + } + ], + "args": [ { - "name": "constituentTargetBase", - "isMut": true, - "isSigner": false - }, + "name": "paused_operations", + "type": "u8" + } + ] + }, + { + "name": "update_perp_market_pnl_pool", + "discriminator": [ + 50, + 202, + 249, + 224, + 166, + 184, + 13, + 143 + ], + "accounts": [ { - "name": "constituentCorrelations", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "lpPoolId", - "type": "u8" - }, + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "update_perp_market_protected_maker_params", + "discriminator": [ + 249, + 213, + 115, + 34, + 253, + 239, + 75, + 173 + ], + "accounts": [ { - "name": "minMintFee", - "type": "i64" + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "maxAum", - "type": "u128" + "name": "state" }, { - "name": "maxSettleQuoteAmountPerMarket", - "type": "u64" + "name": "perp_market", + "writable": true + } + ], + "args": [ + { + "name": "protected_maker_limit_price_divisor", + "type": { + "option": "u8" + } }, { - "name": "whitelistMint", - "type": "publicKey" + "name": "protected_maker_dynamic_divisor", + "type": { + "option": "u8" + } } ] }, { - "name": "updateFeatureBitFlagsSettleLpPool", + "name": "update_perp_market_reference_price_offset_deadband_pct", + "discriminator": [ + 214, + 73, + 166, + 11, + 218, + 76, + 110, + 163 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "enable", - "type": "bool" + "name": "reference_price_offset_deadband_pct", + "type": "u8" } ] }, { - "name": "updateFeatureBitFlagsSwapLpPool", + "name": "update_perp_market_status", + "discriminator": [ + 71, + 201, + 175, + 122, + 255, + 207, + 196, + 207 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "enable", - "type": "bool" + "name": "status", + "type": { + "defined": { + "name": "MarketStatus" + } + } } ] }, { - "name": "updateFeatureBitFlagsMintRedeemLpPool", + "name": "update_perp_market_step_size_and_tick_size", + "discriminator": [ + 231, + 255, + 97, + 25, + 146, + 139, + 174, + 4 + ], "accounts": [ { "name": "admin", - "isMut": false, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "state" + }, + { + "name": "perp_market", + "writable": true } ], "args": [ { - "name": "enable", - "type": "bool" + "name": "step_size", + "type": "u64" + }, + { + "name": "tick_size", + "type": "u64" } ] }, { - "name": "initializeConstituent", + "name": "update_perp_market_unrealized_asset_weight", + "discriminator": [ + 135, + 132, + 205, + 165, + 109, + 150, + 166, + 106 + ], "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, { "name": "admin", - "isMut": true, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "lpPool", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "constituentTargetBase", - "isMut": true, - "isSigner": false - }, + "name": "perp_market", + "writable": true + } + ], + "args": [ { - "name": "constituentCorrelations", - "isMut": true, - "isSigner": false + "name": "unrealized_initial_asset_weight", + "type": "u32" }, { - "name": "constituent", - "isMut": true, - "isSigner": false - }, + "name": "unrealized_maintenance_asset_weight", + "type": "u32" + } + ] + }, + { + "name": "update_prelaunch_oracle", + "discriminator": [ + 220, + 132, + 27, + 27, + 233, + 220, + 61, + 219 + ], + "accounts": [ { - "name": "spotMarket", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "spotMarketMint", - "isMut": false, - "isSigner": false + "name": "perp_market" }, { - "name": "constituentVault", - "isMut": true, - "isSigner": false + "name": "oracle", + "writable": true + } + ], + "args": [] + }, + { + "name": "update_prelaunch_oracle_params", + "discriminator": [ + 98, + 205, + 147, + 243, + 18, + 75, + 83, + 207 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "prelaunch_oracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "params.perp_market_index" + } + ] + } }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "perp_market", + "writable": true }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "state" } ], "args": [ { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "decimals", - "type": "u8" - }, - { - "name": "maxWeightDeviation", - "type": "i64" - }, + "name": "params", + "type": { + "defined": { + "name": "PrelaunchOracleParams" + } + } + } + ] + }, + { + "name": "update_protected_maker_mode_config", + "discriminator": [ + 86, + 166, + 235, + 253, + 67, + 202, + 223, + 17 + ], + "accounts": [ { - "name": "swapFeeMin", - "type": "i64" + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "swapFeeMax", - "type": "i64" + "name": "protected_maker_mode_config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } }, { - "name": "maxBorrowTokenAmount", - "type": "u64" - }, + "name": "state" + } + ], + "args": [ { - "name": "oracleStalenessThreshold", - "type": "u64" + "name": "max_users", + "type": "u32" }, { - "name": "costToTrade", - "type": "i32" + "name": "reduce_only", + "type": "bool" }, { - "name": "constituentDerivativeIndex", + "name": "current_users", "type": { - "option": "i16" + "option": "u32" } - }, - { - "name": "constituentDerivativeDepegThreshold", - "type": "u64" - }, - { - "name": "derivativeWeight", - "type": "u64" - }, + } + ] + }, + { + "name": "update_pyth_pull_oracle", + "discriminator": [ + 230, + 191, + 189, + 94, + 108, + 59, + 74, + 197 + ], + "accounts": [ { - "name": "volatility", - "type": "u64" + "name": "keeper", + "writable": true, + "signer": true }, { - "name": "gammaExecution", - "type": "u8" + "name": "pyth_solana_receiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" }, { - "name": "gammaInventory", - "type": "u8" + "name": "encoded_vaa" }, { - "name": "xi", - "type": "u8" - }, + "name": "price_feed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feed_id" + } + ] + } + } + ], + "args": [ { - "name": "newConstituentCorrelations", + "name": "feed_id", "type": { - "vec": "i64" + "array": [ + "u8", + 32 + ] } + }, + { + "name": "params", + "type": "bytes" } ] }, { - "name": "updateConstituentStatus", + "name": "update_serum_fulfillment_config_status", + "discriminator": [ + 171, + 109, + 240, + 251, + 95, + 1, + 149, + 89 + ], "accounts": [ { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "serum_fulfillment_config", + "writable": true }, { - "name": "constituent", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] } ], "args": [ { - "name": "newStatus", - "type": "u8" + "name": "status", + "type": { + "defined": { + "name": "SpotFulfillmentConfigStatus" + } + } } ] }, { - "name": "updateConstituentPausedOperations", + "name": "update_spot_auction_duration", + "discriminator": [ + 182, + 178, + 203, + 72, + 187, + 143, + 157, + 107 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "constituent", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "pausedOperations", + "name": "default_spot_auction_duration", "type": "u8" } ] }, { - "name": "updateConstituentParams", + "name": "update_spot_fee_structure", + "discriminator": [ + 97, + 216, + 105, + 131, + 113, + 246, + 142, + 141 + ], "accounts": [ - { - "name": "lpPool", - "isMut": false, - "isSigner": false - }, - { - "name": "constituentTargetBase", - "isMut": true, - "isSigner": false - }, { "name": "admin", - "isMut": true, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "constituent", - "isMut": true, - "isSigner": false + "writable": true } ], "args": [ { - "name": "constituentParams", + "name": "fee_structure", "type": { - "defined": "ConstituentParams" + "defined": { + "name": "FeeStructure" + } } } ] }, { - "name": "updateLpPoolParams", + "name": "update_spot_market_asset_tier", + "discriminator": [ + 253, + 209, + 231, + 14, + 242, + 208, + 243, + 130 + ], "accounts": [ { - "name": "lpPool", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], "args": [ { - "name": "lpPoolParams", + "name": "asset_tier", "type": { - "defined": "LpPoolParams" + "defined": { + "name": "AssetTier" + } } } ] }, { - "name": "addAmmConstituentMappingData", + "name": "update_spot_market_borrow_rate", + "discriminator": [ + 71, + 239, + 236, + 153, + 210, + 62, + 254, + 76 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true + "signer": true, + "relations": [ + "state" + ] }, { - "name": "lpPool", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "ammConstituentMapping", - "isMut": true, - "isSigner": false - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ { - "name": "constituentTargetBase", - "isMut": true, - "isSigner": false + "name": "optimal_utilization", + "type": "u32" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "optimal_borrow_rate", + "type": "u32" }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false - } - ], - "args": [ + "name": "max_borrow_rate", + "type": "u32" + }, { - "name": "ammConstituentMappingData", + "name": "min_borrow_rate", "type": { - "vec": { - "defined": "AddAmmConstituentMappingDatum" - } + "option": "u8" } } ] }, { - "name": "updateAmmConstituentMappingData", + "name": "update_spot_market_cumulative_interest", + "discriminator": [ + 39, + 166, + 139, + 243, + 158, + 165, + 155, + 225 + ], "accounts": [ { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "state" + }, + { + "name": "spot_market", + "writable": true }, { - "name": "lpPool", - "isMut": false, - "isSigner": false + "name": "oracle" }, { - "name": "ammConstituentMapping", - "isMut": true, - "isSigner": false + "name": "spot_market_vault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spot_market" + } + ] + } + } + ], + "args": [] + }, + { + "name": "update_spot_market_expiry", + "discriminator": [ + 208, + 11, + 211, + 159, + 226, + 24, + 11, + 247 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], "args": [ { - "name": "ammConstituentMappingData", - "type": { - "vec": { - "defined": "AddAmmConstituentMappingDatum" - } - } + "name": "expiry_ts", + "type": "i64" } ] }, { - "name": "removeAmmConstituentMappingData", + "name": "update_spot_market_fee_adjustment", + "discriminator": [ + 148, + 182, + 3, + 126, + 157, + 114, + 220, + 99 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "lpPool", - "isMut": false, - "isSigner": false - }, - { - "name": "ammConstituentMapping", - "isMut": true, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "systemProgram", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], "args": [ { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" + "name": "fee_adjustment", + "type": "i16" } ] }, { - "name": "updateConstituentCorrelationData", + "name": "update_spot_market_if_factor", + "discriminator": [ + 147, + 30, + 224, + 34, + 18, + 230, + 105, + 4 + ], "accounts": [ { "name": "admin", - "isMut": true, - "isSigner": true - }, - { - "name": "lpPool", - "isMut": false, - "isSigner": false + "signer": true, + "relations": [ + "state" + ] }, { - "name": "constituentCorrelations", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], "args": [ { - "name": "index1", + "name": "spot_market_index", "type": "u16" }, { - "name": "index2", - "type": "u16" + "name": "user_if_factor", + "type": "u32" }, { - "name": "correlation", - "type": "i64" + "name": "total_if_factor", + "type": "u32" } ] }, { - "name": "updateLpConstituentTargetBase", + "name": "update_spot_market_if_paused_operations", + "discriminator": [ + 101, + 215, + 79, + 74, + 59, + 41, + 79, + 12 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "ammConstituentMapping", - "isMut": false, - "isSigner": false - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ + { + "name": "paused_operations", + "type": "u8" + } + ] + }, + { + "name": "update_spot_market_liquidation_fee", + "discriminator": [ + 11, + 13, + 255, + 53, + 56, + 136, + 104, + 177 + ], + "accounts": [ { - "name": "constituentTargetBase", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "ammCache", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "lpPool", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], - "args": [] + "args": [ + { + "name": "liquidator_fee", + "type": "u32" + }, + { + "name": "if_liquidation_fee", + "type": "u32" + } + ] }, { - "name": "updateLpPoolAum", + "name": "update_spot_market_margin_weights", + "discriminator": [ + 109, + 33, + 87, + 195, + 255, + 36, + 6, + 81 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "state" + }, + { + "name": "spot_market", + "writable": true + } + ], + "args": [ + { + "name": "initial_asset_weight", + "type": "u32" + }, + { + "name": "maintenance_asset_weight", + "type": "u32" }, { - "name": "lpPool", - "isMut": true, - "isSigner": false + "name": "initial_liability_weight", + "type": "u32" }, { - "name": "constituentTargetBase", - "isMut": true, - "isSigner": false + "name": "maintenance_liability_weight", + "type": "u32" }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "imf_factor", + "type": "u32" } - ], - "args": [] + ] }, { - "name": "updateAmmCache", + "name": "update_spot_market_max_token_borrows", + "discriminator": [ + 57, + 102, + 204, + 212, + 253, + 95, + 13, + 199 + ], "accounts": [ { - "name": "keeper", - "isMut": true, - "isSigner": true - }, - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "quoteMarket", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], - "args": [] + "args": [ + { + "name": "max_token_borrows_fraction", + "type": "u16" + } + ] }, { - "name": "overrideAmmCacheInfo", + "name": "update_spot_market_max_token_deposits", + "discriminator": [ + 56, + 191, + 79, + 18, + 26, + 121, + 80, + 208 + ], "accounts": [ { - "name": "state", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "admin", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true } ], "args": [ { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "overrideParams", - "type": { - "defined": "OverrideAmmCacheParams" - } + "name": "max_token_deposits", + "type": "u64" } ] }, { - "name": "lpPoolSwap", + "name": "update_spot_market_min_order_size", + "discriminator": [ + 93, + 128, + 11, + 119, + 26, + 20, + 181, + 50 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "lpPool", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "constituentTargetBase", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "constituentCorrelations", - "isMut": false, - "isSigner": false - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ { - "name": "constituentInTokenAccount", - "isMut": true, - "isSigner": false - }, + "name": "order_size", + "type": "u64" + } + ] + }, + { + "name": "update_spot_market_name", + "discriminator": [ + 17, + 208, + 1, + 1, + 162, + 211, + 188, + 224 + ], + "accounts": [ { - "name": "constituentOutTokenAccount", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "userInTokenAccount", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "userOutTokenAccount", - "isMut": true, - "isSigner": false - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ { - "name": "inConstituent", - "isMut": true, - "isSigner": false - }, + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "update_spot_market_oracle", + "discriminator": [ + 114, + 184, + 102, + 37, + 246, + 186, + 180, + 99 + ], + "accounts": [ { - "name": "outConstituent", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "inMarketMint", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "outMarketMint", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "oracle" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "old_oracle" } ], "args": [ { - "name": "inMarketIndex", - "type": "u16" + "name": "oracle", + "type": "pubkey" }, { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" + "name": "oracle_source", + "type": { + "defined": { + "name": "OracleSource" + } + } }, { - "name": "minOutAmount", - "type": "u64" + "name": "skip_invariant_check", + "type": "bool" } ] }, { - "name": "viewLpPoolSwapFees", + "name": "update_spot_market_orders_enabled", + "discriminator": [ + 190, + 79, + 206, + 15, + 26, + 229, + 229, + 43 + ], "accounts": [ { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "lpPool", - "isMut": false, - "isSigner": false - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ { - "name": "constituentTargetBase", - "isMut": false, - "isSigner": false - }, + "name": "orders_enabled", + "type": "bool" + } + ] + }, + { + "name": "update_spot_market_paused_operations", + "discriminator": [ + 100, + 61, + 153, + 81, + 180, + 12, + 6, + 248 + ], + "accounts": [ { - "name": "constituentCorrelations", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "constituentInTokenAccount", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "constituentOutTokenAccount", - "isMut": true, - "isSigner": false - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ { - "name": "inConstituent", - "isMut": true, - "isSigner": false - }, + "name": "paused_operations", + "type": "u8" + } + ] + }, + { + "name": "update_spot_market_pool_id", + "discriminator": [ + 22, + 213, + 197, + 160, + 139, + 193, + 81, + 149 + ], + "accounts": [ { - "name": "outConstituent", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], "args": [ { - "name": "inMarketIndex", - "type": "u16" - }, + "name": "pool_id", + "type": "u8" + } + ] + }, + { + "name": "update_spot_market_revenue_settle_period", + "discriminator": [ + 81, + 92, + 126, + 41, + 250, + 225, + 156, + 219 + ], + "accounts": [ { - "name": "outMarketIndex", - "type": "u16" + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "inAmount", - "type": "u64" + "name": "state" }, { - "name": "inTargetWeight", - "type": "i64" - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ { - "name": "outTargetWeight", + "name": "revenue_settle_period", "type": "i64" } ] }, { - "name": "lpPoolAddLiquidity", + "name": "update_spot_market_scale_initial_asset_weight_start", + "discriminator": [ + 217, + 204, + 204, + 118, + 204, + 130, + 225, + 147 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "lpPool", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "inMarketMint", - "isMut": false, - "isSigner": false - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ { - "name": "inConstituent", - "isMut": true, - "isSigner": false - }, + "name": "scale_initial_asset_weight_start", + "type": "u64" + } + ] + }, + { + "name": "update_spot_market_status", + "discriminator": [ + 78, + 94, + 16, + 188, + 193, + 110, + 231, + 31 + ], + "accounts": [ { - "name": "userInTokenAccount", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "constituentInTokenAccount", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "userLpTokenAccount", - "isMut": true, - "isSigner": false - }, + "name": "spot_market", + "writable": true + } + ], + "args": [ { - "name": "lpMint", - "isMut": true, - "isSigner": false - }, + "name": "status", + "type": { + "defined": { + "name": "MarketStatus" + } + } + } + ] + }, + { + "name": "update_spot_market_step_size_and_tick_size", + "discriminator": [ + 238, + 153, + 137, + 80, + 206, + 59, + 250, + 61 + ], + "accounts": [ { - "name": "constituentTargetBase", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "lpPoolTokenVault", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], "args": [ { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u128" + "name": "step_size", + "type": "u64" }, { - "name": "minMintAmount", + "name": "tick_size", "type": "u64" } ] }, { - "name": "lpPoolRemoveLiquidity", + "name": "update_state_max_initialize_user_fee", + "discriminator": [ + 237, + 225, + 25, + 237, + 193, + 45, + 77, + 97 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false - }, + "name": "state", + "writable": true + } + ], + "args": [ { - "name": "lpPool", - "isMut": true, - "isSigner": false - }, + "name": "max_initialize_user_fee", + "type": "u16" + } + ] + }, + { + "name": "update_state_max_number_of_sub_accounts", + "discriminator": [ + 155, + 123, + 214, + 2, + 221, + 166, + 204, + 85 + ], + "accounts": [ { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "outMarketMint", - "isMut": false, - "isSigner": false - }, + "name": "state", + "writable": true + } + ], + "args": [ { - "name": "outConstituent", - "isMut": true, - "isSigner": false - }, + "name": "max_number_of_sub_accounts", + "type": "u16" + } + ] + }, + { + "name": "update_state_settlement_duration", + "discriminator": [ + 97, + 68, + 199, + 235, + 131, + 80, + 61, + 173 + ], + "accounts": [ { - "name": "userOutTokenAccount", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "constituentOutTokenAccount", - "isMut": true, - "isSigner": false - }, + "name": "state", + "writable": true + } + ], + "args": [ { - "name": "userLpTokenAccount", - "isMut": true, - "isSigner": false - }, + "name": "settlement_duration", + "type": "u16" + } + ] + }, + { + "name": "update_user_custom_margin_ratio", + "discriminator": [ + 21, + 221, + 140, + 187, + 32, + 129, + 11, + 123 + ], + "accounts": [ { - "name": "spotMarketTokenAccount", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "sub_account_id" + } + ] + } }, { - "name": "lpMint", - "isMut": true, - "isSigner": false - }, + "name": "authority", + "signer": true + } + ], + "args": [ { - "name": "constituentTargetBase", - "isMut": false, - "isSigner": false + "name": "_sub_account_id", + "type": "u16" }, { - "name": "lpPoolTokenVault", - "isMut": true, - "isSigner": false - }, + "name": "margin_ratio", + "type": "u32" + } + ] + }, + { + "name": "update_user_delegate", + "discriminator": [ + 139, + 205, + 141, + 141, + 113, + 36, + 94, + 187 + ], + "accounts": [ { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "sub_account_id" + } + ] + } }, { - "name": "ammCache", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "inMarketIndex", + "name": "_sub_account_id", "type": "u16" }, { - "name": "inAmount", - "type": "u64" - }, - { - "name": "minOutAmount", - "type": "u128" + "name": "delegate", + "type": "pubkey" } ] }, { - "name": "viewLpPoolAddLiquidityFees", + "name": "update_user_gov_token_insurance_stake", + "discriminator": [ + 143, + 99, + 235, + 187, + 20, + 159, + 184, + 84 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "lpPool", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } }, { - "name": "inMarketMint", - "isMut": false, - "isSigner": false + "name": "insurance_fund_stake", + "writable": true }, { - "name": "inConstituent", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "lpMint", - "isMut": false, - "isSigner": false + "name": "signer", + "signer": true }, { - "name": "constituentTargetBase", - "isMut": false, - "isSigner": false + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } } ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u128" - } - ] + "args": [] }, { - "name": "viewLpPoolRemoveLiquidityFees", + "name": "update_user_idle", + "discriminator": [ + 253, + 133, + 67, + 22, + 103, + 161, + 20, + 100 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "lpPool", - "isMut": false, - "isSigner": false + "name": "state" }, { "name": "authority", - "isMut": false, - "isSigner": true + "signer": true }, { - "name": "outMarketMint", - "isMut": false, - "isSigner": false + "name": "filler", + "writable": true }, { - "name": "outConstituent", - "isMut": false, - "isSigner": false - }, + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "update_user_margin_trading_enabled", + "discriminator": [ + 194, + 92, + 204, + 223, + 246, + 188, + 31, + 203 + ], + "accounts": [ { - "name": "lpMint", - "isMut": false, - "isSigner": false + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "sub_account_id" + } + ] + } }, { - "name": "constituentTargetBase", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "inMarketIndex", + "name": "_sub_account_id", "type": "u16" }, { - "name": "inAmount", - "type": "u64" + "name": "margin_trading_enabled", + "type": "bool" } ] }, { - "name": "beginLpSwap", + "name": "update_user_name", + "discriminator": [ + 135, + 25, + 185, + 56, + 165, + 53, + 34, + 136 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "sub_account_id" + } + ] + } }, { - "name": "signerOutTokenAccount", - "isMut": true, - "isSigner": false, - "docs": [ - "Signer token accounts" - ] - }, + "name": "authority", + "signer": true + } + ], + "args": [ { - "name": "signerInTokenAccount", - "isMut": true, - "isSigner": false + "name": "_sub_account_id", + "type": "u16" }, { - "name": "constituentOutTokenAccount", - "isMut": true, - "isSigner": false, - "docs": [ - "Constituent token accounts" - ] - }, + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "update_user_perp_position_custom_margin_ratio", + "discriminator": [ + 121, + 137, + 157, + 155, + 89, + 186, + 145, + 113 + ], + "accounts": [ { - "name": "constituentInTokenAccount", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "outConstituent", - "isMut": true, - "isSigner": false, - "docs": [ - "Constituents" - ] - }, + "name": "authority", + "signer": true + } + ], + "args": [ { - "name": "inConstituent", - "isMut": true, - "isSigner": false + "name": "_sub_account_id", + "type": "u16" }, { - "name": "lpPool", - "isMut": false, - "isSigner": false + "name": "perp_market_index", + "type": "u16" }, { - "name": "instructions", - "isMut": false, - "isSigner": false, - "docs": [ - "Instructions Sysvar for instruction introspection" - ] + "name": "margin_ratio", + "type": "u16" + } + ] + }, + { + "name": "update_user_pool_id", + "discriminator": [ + 219, + 86, + 73, + 106, + 56, + 218, + 128, + 109 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "sub_account_id" + } + ] + } }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", + "name": "_sub_account_id", "type": "u16" }, { - "name": "amountIn", - "type": "u64" + "name": "pool_id", + "type": "u8" } ] }, { - "name": "endLpSwap", + "name": "update_user_protected_maker_orders", + "discriminator": [ + 114, + 39, + 123, + 198, + 187, + 25, + 90, + 219 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "user", + "writable": true }, { - "name": "signerOutTokenAccount", - "isMut": true, - "isSigner": false, - "docs": [ - "Signer token accounts" - ] + "name": "authority", + "signer": true }, { - "name": "signerInTokenAccount", - "isMut": true, - "isSigner": false + "name": "protected_maker_mode_config", + "writable": true + } + ], + "args": [ + { + "name": "_sub_account_id", + "type": "u16" }, { - "name": "constituentOutTokenAccount", - "isMut": true, - "isSigner": false, - "docs": [ - "Constituent token accounts" - ] + "name": "protected_maker_orders", + "type": "bool" + } + ] + }, + { + "name": "update_user_quote_asset_insurance_stake", + "discriminator": [ + 251, + 101, + 156, + 7, + 2, + 63, + 30, + 23 + ], + "accounts": [ + { + "name": "state" }, { - "name": "constituentInTokenAccount", - "isMut": true, - "isSigner": false + "name": "spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { - "name": "outConstituent", - "isMut": true, - "isSigner": false, - "docs": [ - "Constituents" - ] + "name": "insurance_fund_stake", + "writable": true }, { - "name": "inConstituent", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true }, { - "name": "lpPool", - "isMut": false, - "isSigner": false + "name": "signer", + "signer": true }, { - "name": "instructions", - "isMut": false, - "isSigner": false, - "docs": [ - "Instructions Sysvar for instruction introspection" - ] + "name": "insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "update_user_reduce_only", + "discriminator": [ + 199, + 71, + 42, + 67, + 144, + 19, + 86, + 109 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "sub_account_id" + } + ] + } }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true } ], "args": [ { - "name": "inMarketIndex", + "name": "_sub_account_id", "type": "u16" }, { - "name": "outMarketIndex", - "type": "u16" + "name": "reduce_only", + "type": "bool" } ] }, { - "name": "updateConstituentOracleInfo", + "name": "update_user_stats_referrer_status", + "discriminator": [ + 174, + 154, + 72, + 42, + 191, + 148, + 145, + 205 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "authority", + "signer": true }, { - "name": "constituent", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true + } + ], + "args": [] + }, + { + "name": "update_withdraw_guard_threshold", + "discriminator": [ + 56, + 18, + 39, + 61, + 155, + 211, + 44, + 133 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] }, { - "name": "spotMarket", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "spot_market", + "writable": true } ], - "args": [] + "args": [ + { + "name": "withdraw_guard_threshold", + "type": "u64" + } + ] }, { - "name": "depositToProgramVault", + "name": "view_lp_pool_add_liquidity_fees", + "discriminator": [ + 80, + 66, + 226, + 161, + 70, + 142, + 119, + 84 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "lp_pool" }, { - "name": "constituent", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true + }, + { + "name": "in_market_mint" + }, + { + "name": "in_constituent", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } + }, + { + "name": "lp_mint" }, { - "name": "constituentTokenAccount", - "isMut": true, - "isSigner": false + "name": "constituent_target_base" + } + ], + "args": [ + { + "name": "in_market_index", + "type": "u16" }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "in_amount", + "type": "u128" + } + ] + }, + { + "name": "view_lp_pool_remove_liquidity_fees", + "discriminator": [ + 47, + 12, + 9, + 102, + 12, + 226, + 197, + 89 + ], + "accounts": [ + { + "name": "state" }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "lp_pool" }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "mint", - "isMut": false, - "isSigner": false + "name": "out_market_mint" }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "out_constituent", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } + }, + { + "name": "lp_mint" + }, + { + "name": "constituent_target_base" } ], "args": [ { - "name": "amount", + "name": "in_market_index", + "type": "u16" + }, + { + "name": "in_amount", "type": "u64" } ] }, { - "name": "withdrawFromProgramVault", + "name": "view_lp_pool_swap_fees", + "discriminator": [ + 126, + 189, + 109, + 189, + 170, + 156, + 3, + 46 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "drift_signer" }, { - "name": "admin", - "isMut": true, - "isSigner": true + "name": "state" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false + "name": "lp_pool" }, { - "name": "constituent", - "isMut": true, - "isSigner": false + "name": "constituent_target_base" + }, + { + "name": "constituent_correlations" }, { - "name": "constituentTokenAccount", - "isMut": true, - "isSigner": false + "name": "constituent_in_token_account", + "writable": true }, { - "name": "spotMarket", - "isMut": true, - "isSigner": false + "name": "constituent_out_token_account", + "writable": true }, { - "name": "spotMarketVault", - "isMut": true, - "isSigner": false + "name": "in_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "out_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "mint", - "isMut": false, - "isSigner": false + "name": "authority", + "signer": true }, { - "name": "oracle", - "isMut": false, - "isSigner": false + "name": "token_program" } ], "args": [ { - "name": "amount", + "name": "in_market_index", + "type": "u16" + }, + { + "name": "out_market_index", + "type": "u16" + }, + { + "name": "in_amount", "type": "u64" + }, + { + "name": "in_target_weight", + "type": "i64" + }, + { + "name": "out_target_weight", + "type": "i64" } ] }, { - "name": "settlePerpToLpPool", + "name": "withdraw", + "discriminator": [ + 183, + 18, + 70, + 156, + 148, + 109, + 161, + 34 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "lpPool", - "isMut": true, - "isSigner": false + "name": "user", + "writable": true }, { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "user_stats", + "writable": true }, { - "name": "ammCache", - "isMut": true, - "isSigner": false + "name": "authority", + "signer": true, + "relations": [ + "user", + "user_stats" + ] }, { - "name": "quoteMarket", - "isMut": true, - "isSigner": false + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } }, { - "name": "constituent", - "isMut": true, - "isSigner": false + "name": "drift_signer" }, { - "name": "constituentQuoteTokenAccount", - "isMut": true, - "isSigner": false + "name": "user_token_account", + "writable": true }, { - "name": "quoteTokenVault", - "isMut": true, - "isSigner": false - }, + "name": "token_program" + } + ], + "args": [ { - "name": "tokenProgram", - "isMut": false, - "isSigner": false + "name": "market_index", + "type": "u16" }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false - } + "name": "amount", + "type": "u64" + }, + { + "name": "reduce_only", + "type": "bool" + } + ] + }, + { + "name": "withdraw_from_program_vault", + "discriminator": [ + 120, + 40, + 183, + 149, + 232, + 18, + 224, + 151 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "drift_signer" + }, + { + "name": "constituent", + "writable": true + }, + { + "name": "constituent_token_account", + "writable": true + }, + { + "name": "spot_market", + "writable": true + }, + { + "name": "spot_market_vault", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "mint" + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "zero_mm_oracle_fields", + "discriminator": [ + 192, + 226, + 39, + 204, + 207, + 120, + 148, + 250 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perp_market", + "writable": true + } ], "args": [] } @@ -9106,835 +15075,1582 @@ "accounts": [ { "name": "AmmCache", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "cache", - "type": { - "vec": { - "defined": "CacheInfo" - } - } - } - ] - } + "discriminator": [ + 213, + 114, + 161, + 56, + 20, + 22, + 2, + 59 + ] + }, + { + "name": "AmmConstituentMapping", + "discriminator": [ + 254, + 89, + 5, + 173, + 66, + 54, + 214, + 247 + ] + }, + { + "name": "Constituent", + "discriminator": [ + 0, + 61, + 36, + 35, + 177, + 76, + 216, + 205 + ] + }, + { + "name": "ConstituentCorrelations", + "discriminator": [ + 124, + 203, + 115, + 33, + 18, + 162, + 67, + 216 + ] + }, + { + "name": "ConstituentTargetBase", + "discriminator": [ + 255, + 142, + 134, + 71, + 125, + 66, + 198, + 99 + ] + }, + { + "name": "FuelOverflow", + "discriminator": [ + 182, + 64, + 231, + 177, + 226, + 142, + 69, + 58 + ] + }, + { + "name": "HighLeverageModeConfig", + "discriminator": [ + 3, + 196, + 90, + 189, + 193, + 64, + 228, + 234 + ] + }, + { + "name": "IfRebalanceConfig", + "discriminator": [ + 214, + 84, + 40, + 251, + 107, + 144, + 173, + 239 + ] + }, + { + "name": "InsuranceFundStake", + "discriminator": [ + 110, + 202, + 14, + 42, + 95, + 73, + 90, + 95 + ] + }, + { + "name": "LPPool", + "discriminator": [ + 228, + 152, + 141, + 224, + 161, + 170, + 11, + 89 + ] }, { "name": "OpenbookV2FulfillmentConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "publicKey" - }, - { - "name": "openbookV2ProgramId", - "type": "publicKey" - }, - { - "name": "openbookV2Market", - "type": "publicKey" - }, - { - "name": "openbookV2MarketAuthority", - "type": "publicKey" - }, - { - "name": "openbookV2EventHeap", - "type": "publicKey" - }, - { - "name": "openbookV2Bids", - "type": "publicKey" - }, - { - "name": "openbookV2Asks", - "type": "publicKey" - }, - { - "name": "openbookV2BaseVault", - "type": "publicKey" - }, - { - "name": "openbookV2QuoteVault", - "type": "publicKey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": "SpotFulfillmentType" - } - }, - { - "name": "status", - "type": { - "defined": "SpotFulfillmentConfigStatus" - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } + "discriminator": [ + 3, + 43, + 58, + 106, + 131, + 132, + 199, + 171 + ] + }, + { + "name": "PerpMarket", + "discriminator": [ + 10, + 223, + 12, + 44, + 107, + 245, + 55, + 247 + ] }, { "name": "PhoenixV1FulfillmentConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "publicKey" - }, - { - "name": "phoenixProgramId", - "type": "publicKey" - }, - { - "name": "phoenixLogAuthority", - "type": "publicKey" - }, - { - "name": "phoenixMarket", - "type": "publicKey" - }, - { - "name": "phoenixBaseVault", - "type": "publicKey" - }, - { - "name": "phoenixQuoteVault", - "type": "publicKey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": "SpotFulfillmentType" - } - }, - { - "name": "status", - "type": { - "defined": "SpotFulfillmentConfigStatus" - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } + "discriminator": [ + 233, + 45, + 62, + 40, + 35, + 129, + 48, + 72 + ] }, { - "name": "SerumV3FulfillmentConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "publicKey" - }, - { - "name": "serumProgramId", - "type": "publicKey" - }, - { - "name": "serumMarket", - "type": "publicKey" - }, - { - "name": "serumRequestQueue", - "type": "publicKey" - }, - { - "name": "serumEventQueue", - "type": "publicKey" - }, - { - "name": "serumBids", - "type": "publicKey" - }, - { - "name": "serumAsks", - "type": "publicKey" - }, - { - "name": "serumBaseVault", - "type": "publicKey" - }, - { - "name": "serumQuoteVault", - "type": "publicKey" - }, - { - "name": "serumOpenOrders", - "type": "publicKey" - }, - { - "name": "serumSignerNonce", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": "SpotFulfillmentType" - } - }, - { - "name": "status", - "type": { - "defined": "SpotFulfillmentConfigStatus" - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } + "name": "PrelaunchOracle", + "discriminator": [ + 92, + 14, + 139, + 234, + 72, + 244, + 68, + 26 + ] }, { - "name": "HighLeverageModeConfig", + "name": "ProtectedMakerModeConfig", + "discriminator": [ + 47, + 86, + 90, + 9, + 224, + 255, + 10, + 69 + ] + }, + { + "name": "PythLazerOracle", + "discriminator": [ + 159, + 7, + 161, + 249, + 34, + 81, + 121, + 133 + ] + }, + { + "name": "ReferrerName", + "discriminator": [ + 105, + 133, + 170, + 110, + 52, + 42, + 28, + 182 + ] + }, + { + "name": "RevenueShare", + "discriminator": [ + 55, + 40, + 228, + 7, + 139, + 52, + 180, + 110 + ] + }, + { + "name": "RevenueShareEscrow", + "discriminator": [ + 98, + 167, + 3, + 46, + 74, + 177, + 173, + 252 + ] + }, + { + "name": "SerumV3FulfillmentConfig", + "discriminator": [ + 65, + 160, + 197, + 112, + 239, + 168, + 103, + 185 + ] + }, + { + "name": "SignedMsgUserOrders", + "discriminator": [ + 70, + 6, + 50, + 248, + 222, + 1, + 143, + 49 + ] + }, + { + "name": "SignedMsgWsDelegates", + "discriminator": [ + 190, + 115, + 111, + 44, + 216, + 252, + 108, + 85 + ] + }, + { + "name": "SpotMarket", + "discriminator": [ + 100, + 177, + 8, + 107, + 168, + 65, + 65, + 39 + ] + }, + { + "name": "State", + "discriminator": [ + 216, + 146, + 107, + 94, + 104, + 75, + 182, + 177 + ] + }, + { + "name": "User", + "discriminator": [ + 159, + 117, + 95, + 227, + 239, + 151, + 58, + 236 + ] + }, + { + "name": "UserStats", + "discriminator": [ + 176, + 223, + 136, + 27, + 122, + 79, + 32, + 227 + ] + } + ], + "events": [ + { + "name": "CurveRecord", + "discriminator": [ + 101, + 238, + 40, + 228, + 70, + 46, + 61, + 117 + ] + }, + { + "name": "DeleteUserRecord", + "discriminator": [ + 71, + 111, + 190, + 118, + 7, + 3, + 132, + 222 + ] + }, + { + "name": "DepositRecord", + "discriminator": [ + 180, + 241, + 218, + 207, + 102, + 135, + 44, + 134 + ] + }, + { + "name": "FuelSeasonRecord", + "discriminator": [ + 19, + 137, + 119, + 33, + 224, + 249, + 6, + 87 + ] + }, + { + "name": "FuelSweepRecord", + "discriminator": [ + 41, + 84, + 37, + 246, + 132, + 240, + 131, + 8 + ] + }, + { + "name": "FundingPaymentRecord", + "discriminator": [ + 8, + 59, + 96, + 20, + 137, + 201, + 56, + 95 + ] + }, + { + "name": "FundingRateRecord", + "discriminator": [ + 68, + 3, + 255, + 26, + 133, + 91, + 147, + 254 + ] + }, + { + "name": "InsuranceFundRecord", + "discriminator": [ + 56, + 222, + 215, + 235, + 78, + 197, + 99, + 146 + ] + }, + { + "name": "InsuranceFundStakeRecord", + "discriminator": [ + 68, + 66, + 156, + 7, + 216, + 148, + 250, + 114 + ] + }, + { + "name": "InsuranceFundSwapRecord", + "discriminator": [ + 85, + 190, + 99, + 203, + 237, + 33, + 227, + 100 + ] + }, + { + "name": "LPBorrowLendDepositRecord", + "discriminator": [ + 242, + 181, + 11, + 56, + 243, + 61, + 79, + 210 + ] + }, + { + "name": "LPMintRedeemRecord", + "discriminator": [ + 53, + 178, + 142, + 73, + 78, + 91, + 91, + 8 + ] + }, + { + "name": "LPRecord", + "discriminator": [ + 101, + 22, + 54, + 38, + 178, + 13, + 142, + 111 + ] + }, + { + "name": "LPSettleRecord", + "discriminator": [ + 208, + 191, + 131, + 110, + 173, + 48, + 7, + 2 + ] + }, + { + "name": "LPSwapRecord", + "discriminator": [ + 159, + 62, + 130, + 196, + 96, + 79, + 176, + 254 + ] + }, + { + "name": "LiquidationRecord", + "discriminator": [ + 127, + 17, + 0, + 108, + 182, + 13, + 231, + 53 + ] + }, + { + "name": "NewUserRecord", + "discriminator": [ + 236, + 186, + 113, + 219, + 42, + 51, + 149, + 249 + ] + }, + { + "name": "OrderActionRecord", + "discriminator": [ + 224, + 52, + 67, + 71, + 194, + 237, + 109, + 1 + ] + }, + { + "name": "OrderRecord", + "discriminator": [ + 104, + 19, + 64, + 56, + 89, + 21, + 2, + 90 + ] + }, + { + "name": "RevenueShareSettleRecord", + "discriminator": [ + 61, + 162, + 89, + 10, + 24, + 20, + 59, + 45 + ] + }, + { + "name": "SettlePnlRecord", + "discriminator": [ + 57, + 68, + 105, + 26, + 119, + 198, + 213, + 89 + ] + }, + { + "name": "SignedMsgOrderRecord", + "discriminator": [ + 211, + 197, + 25, + 18, + 142, + 86, + 113, + 27 + ] + }, + { + "name": "SpotInterestRecord", + "discriminator": [ + 183, + 186, + 203, + 186, + 225, + 187, + 95, + 130 + ] + }, + { + "name": "SpotMarketVaultDepositRecord", + "discriminator": [ + 178, + 217, + 23, + 188, + 127, + 190, + 32, + 73 + ] + }, + { + "name": "SwapRecord", + "discriminator": [ + 162, + 187, + 123, + 194, + 138, + 56, + 250, + 241 + ] + }, + { + "name": "TransferProtocolIfSharesToRevenuePoolRecord", + "discriminator": [ + 209, + 118, + 142, + 167, + 130, + 46, + 164, + 151 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidEd25519InstructionProgramId", + "msg": "invalid ed25519 instruction program" + }, + { + "code": 6001, + "name": "InvalidEd25519InstructionDataLength", + "msg": "invalid ed25519 instruction data length" + }, + { + "code": 6002, + "name": "InvalidSignatureIndex", + "msg": "invalid signature index" + }, + { + "code": 6003, + "name": "InvalidSignatureOffset", + "msg": "invalid signature offset" + }, + { + "code": 6004, + "name": "InvalidPublicKeyOffset", + "msg": "invalid public key offset" + }, + { + "code": 6005, + "name": "InvalidMessageOffset", + "msg": "invalid message offset" + }, + { + "code": 6006, + "name": "InvalidMessageDataSize", + "msg": "invalid message data size" + }, + { + "code": 6007, + "name": "InvalidInstructionIndex", + "msg": "invalid instruction index" + }, + { + "code": 6008, + "name": "MessageOffsetOverflow", + "msg": "message offset overflow" + }, + { + "code": 6009, + "name": "InvalidMessageHex", + "msg": "invalid message hex" + }, + { + "code": 6010, + "name": "InvalidMessageData", + "msg": "invalid message data" + }, + { + "code": 6011, + "name": "LoadInstructionAtFailed", + "msg": "loading custom ix at index failed" + } + ], + "types": [ + { + "name": "AMM", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "currentUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "u8" + "name": "oracle", + "docs": [ + "oracle price data public key" + ], + "type": "pubkey" }, { - "name": "padding1", + "name": "historical_oracle_data", + "docs": [ + "stores historically witnessed oracle data" + ], "type": { - "array": [ - "u8", - 3 - ] + "defined": { + "name": "HistoricalOracleData" + } } }, { - "name": "currentMaintenanceUsers", - "type": "u32" - }, - { - "name": "padding2", + "name": "base_asset_amount_per_lp", + "docs": [ + "accumulated base asset amount since inception per lp share", + "precision: QUOTE_PRECISION" + ], "type": { - "array": [ - "u8", - 24 - ] + "defined": { + "name": "i128" + } } - } - ] - } - }, - { - "name": "IfRebalanceConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "publicKey" }, { - "name": "totalInAmount", + "name": "quote_asset_amount_per_lp", "docs": [ - "total amount to be sold" + "accumulated quote asset amount since inception per lp share", + "precision: QUOTE_PRECISION" ], - "type": "u64" + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "currentInAmount", + "name": "fee_pool", "docs": [ - "amount already sold" + "partition of fees from perp market trading moved from pnl settlements" ], - "type": "u64" + "type": { + "defined": { + "name": "PoolBalance" + } + } }, { - "name": "currentOutAmount", + "name": "base_asset_reserve", "docs": [ - "amount already bought" + "`x` reserves for constant product mm formula (x * y = k)", + "precision: AMM_RESERVE_PRECISION" ], - "type": "u64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "currentOutAmountTransferred", + "name": "quote_asset_reserve", "docs": [ - "amount already transferred to revenue pool" + "`y` reserves for constant product mm formula (x * y = k)", + "precision: AMM_RESERVE_PRECISION" ], - "type": "u64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "currentInAmountSinceLastTransfer", + "name": "concentration_coef", "docs": [ - "amount already bought in epoch" + "determines how close the min/max base asset reserve sit vs base reserves", + "allow for decreasing slippage without increasing liquidity and v.v.", + "precision: PERCENTAGE_PRECISION" ], - "type": "u64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "epochStartTs", + "name": "min_base_asset_reserve", "docs": [ - "start time of epoch" + "minimum base_asset_reserve allowed before AMM is unavailable", + "precision: AMM_RESERVE_PRECISION" ], - "type": "i64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "epochInAmount", + "name": "max_base_asset_reserve", "docs": [ - "amount already bought in epoch" + "maximum base_asset_reserve allowed before AMM is unavailable", + "precision: AMM_RESERVE_PRECISION" ], - "type": "u64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "epochMaxInAmount", + "name": "sqrt_k", "docs": [ - "max amount to swap in epoch" + "`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues", + "precision: AMM_RESERVE_PRECISION" ], - "type": "u64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "epochDuration", + "name": "peg_multiplier", "docs": [ - "duration of epoch" + "normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced", + "precision: PEG_PRECISION" ], - "type": "i64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "outMarketIndex", + "name": "terminal_quote_asset_reserve", "docs": [ - "market index to sell" + "y when market is balanced. stored to save computation", + "precision: AMM_RESERVE_PRECISION" ], - "type": "u16" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "inMarketIndex", + "name": "base_asset_amount_long", "docs": [ - "market index to buy" + "always non-negative. tracks number of total longs in market (regardless of counterparty)", + "precision: BASE_PRECISION" ], - "type": "u16" - }, - { - "name": "maxSlippageBps", - "type": "u16" - }, - { - "name": "swapMode", - "type": "u8" - }, - { - "name": "status", - "type": "u8" - }, - { - "name": "padding2", "type": { - "array": [ - "u8", - 32 - ] + "defined": { + "name": "i128" + } } - } - ] - } - }, - { - "name": "InsuranceFundStake", - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "publicKey" - }, - { - "name": "ifShares", - "type": "u128" - }, - { - "name": "lastWithdrawRequestShares", - "type": "u128" - }, - { - "name": "ifBase", - "type": "u128" }, { - "name": "lastValidTs", - "type": "i64" - }, - { - "name": "lastWithdrawRequestValue", - "type": "u64" - }, - { - "name": "lastWithdrawRequestTs", - "type": "i64" - }, - { - "name": "costBasis", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "padding", + "name": "base_asset_amount_short", + "docs": [ + "always non-positive. tracks number of total shorts in market (regardless of counterparty)", + "precision: BASE_PRECISION" + ], "type": { - "array": [ - "u8", - 14 - ] + "defined": { + "name": "i128" + } } - } - ] - } - }, - { - "name": "ProtocolIfSharesTransferConfig", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "whitelistedSigners", + "name": "base_asset_amount_with_amm", + "docs": [ + "tracks net position (longs-shorts) in market with AMM as counterparty", + "precision: BASE_PRECISION" + ], "type": { - "array": [ - "publicKey", - 4 - ] + "defined": { + "name": "i128" + } } }, { - "name": "maxTransferPerEpoch", - "type": "u128" - }, - { - "name": "currentEpochTransfer", - "type": "u128" - }, - { - "name": "nextEpochTs", - "type": "i64" - }, - { - "name": "padding", + "name": "base_asset_amount_with_unsettled_lp", + "docs": [ + "tracks net position (longs-shorts) in market with LPs as counterparty", + "precision: BASE_PRECISION" + ], "type": { - "array": [ - "u128", - 8 - ] + "defined": { + "name": "i128" + } } - } - ] - } - }, - { - "name": "LPPool", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "pubkey", + "name": "max_open_interest", "docs": [ - "address of the vault." + "max allowed open interest, blocks trades that breach this value", + "precision: BASE_PRECISION" ], - "type": "publicKey" - }, - { - "name": "mint", - "type": "publicKey" - }, - { - "name": "whitelistMint", - "type": "publicKey" - }, - { - "name": "constituentTargetBase", - "type": "publicKey" - }, - { - "name": "constituentCorrelations", - "type": "publicKey" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "maxAum", + "name": "quote_asset_amount", "docs": [ - "The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)", - "which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)", - "pub quote_constituent_index: u16,", - "QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this" + "sum of all user's perp quote_asset_amount in market", + "precision: QUOTE_PRECISION" ], - "type": "u128" + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "lastAum", + "name": "quote_entry_amount_long", "docs": [ - "QUOTE_PRECISION: AUM of the vault in USD, updated lazily" + "sum of all long user's quote_entry_amount in market", + "precision: QUOTE_PRECISION" ], - "type": "u128" + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "cumulativeQuoteSentToPerpMarkets", + "name": "quote_entry_amount_short", "docs": [ - "QUOTE PRECISION: Cumulative quotes from settles" + "sum of all short user's quote_entry_amount in market", + "precision: QUOTE_PRECISION" ], - "type": "u128" - }, - { - "name": "cumulativeQuoteReceivedFromPerpMarkets", - "type": "u128" + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "totalMintRedeemFeesPaid", + "name": "quote_break_even_amount_long", "docs": [ - "QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens" + "sum of all long user's quote_break_even_amount in market", + "precision: QUOTE_PRECISION" ], - "type": "i128" + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "lastAumSlot", + "name": "quote_break_even_amount_short", "docs": [ - "timestamp of last AUM slot" + "sum of all short user's quote_break_even_amount in market", + "precision: QUOTE_PRECISION" ], - "type": "u64" - }, - { - "name": "maxSettleQuoteAmount", - "type": "u64" + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "padding", + "name": "user_lp_shares", "docs": [ - "timestamp of last vAMM revenue rebalance" + "total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)", + "precision: AMM_RESERVE_PRECISION" ], - "type": "u64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "mintRedeemId", + "name": "last_funding_rate", "docs": [ - "Every mint/redeem has a monotonically increasing id. This is the next id to use" + "last funding rate in this perp market (unit is quote per base)", + "precision: FUNDING_RATE_PRECISION" ], - "type": "u64" + "type": "i64" }, { - "name": "settleId", - "type": "u64" + "name": "last_funding_rate_long", + "docs": [ + "last funding rate for longs in this perp market (unit is quote per base)", + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" }, { - "name": "minMintFee", + "name": "last_funding_rate_short", "docs": [ - "PERCENTAGE_PRECISION" + "last funding rate for shorts in this perp market (unit is quote per base)", + "precision: QUOTE_PRECISION" ], "type": "i64" }, { - "name": "tokenSupply", - "type": "u64" + "name": "last_24h_avg_funding_rate", + "docs": [ + "estimate of last 24h of funding rate perp market (unit is quote per base)", + "precision: QUOTE_PRECISION" + ], + "type": "i64" }, { - "name": "volatility", - "type": "u64" + "name": "total_fee", + "docs": [ + "total fees collected by this perp market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "constituents", - "type": "u16" + "name": "total_mm_fee", + "docs": [ + "total fees collected by the vAMM's bid/ask spread", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "quoteConsituentIndex", - "type": "u16" + "name": "total_exchange_fee", + "docs": [ + "total fees collected by exchange fee schedule", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "bump", - "type": "u8" + "name": "total_fee_minus_distributions", + "docs": [ + "total fees minus any recognized upnl and pool withdraws", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "gammaExecution", - "type": "u8" + "name": "total_fee_withdrawn", + "docs": [ + "sum of all fees from fee pool withdrawn to revenue pool", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "xi", - "type": "u8" + "name": "total_liquidation_fee", + "docs": [ + "all fees collected by market for liquidations", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "targetOracleDelayFeeBpsPer10Slots", - "type": "u8" + "name": "cumulative_funding_rate_long", + "docs": [ + "accumulated funding rate for longs since inception in market" + ], + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "targetPositionDelayFeeBpsPer10Slots", - "type": "u8" + "name": "cumulative_funding_rate_short", + "docs": [ + "accumulated funding rate for shorts since inception in market" + ], + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "lpPoolId", - "type": "u8" + "name": "total_social_loss", + "docs": [ + "accumulated social loss paid by users since inception in market" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "padding", + "name": "ask_base_asset_reserve", + "docs": [ + "transformed base_asset_reserve for users going long", + "precision: AMM_RESERVE_PRECISION" + ], "type": { - "array": [ - "u8", - 174 - ] + "defined": { + "name": "u128" + } } - } - ] - } - }, - { - "name": "Constituent", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "pubkey", + "name": "ask_quote_asset_reserve", "docs": [ - "address of the constituent" + "transformed quote_asset_reserve for users going long", + "precision: AMM_RESERVE_PRECISION" ], - "type": "publicKey" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "mint", - "type": "publicKey" + "name": "bid_base_asset_reserve", + "docs": [ + "transformed base_asset_reserve for users going short", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "lpPool", - "type": "publicKey" + "name": "bid_quote_asset_reserve", + "docs": [ + "transformed quote_asset_reserve for users going short", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "vault", - "type": "publicKey" + "name": "last_oracle_normalised_price", + "docs": [ + "the last seen oracle price partially shrunk toward the amm reserve price", + "precision: PRICE_PRECISION" + ], + "type": "i64" }, { - "name": "totalSwapFees", + "name": "last_oracle_reserve_price_spread_pct", "docs": [ - "total fees received by the constituent. Positive = fees received, Negative = fees paid" + "the gap between the oracle price and the reserve price = y * peg_multiplier / x" ], - "type": "i128" + "type": "i64" }, { - "name": "spotBalance", + "name": "last_bid_price_twap", "docs": [ - "spot borrow-lend balance for constituent" + "average estimate of bid price over funding_period", + "precision: PRICE_PRECISION" ], - "type": { - "defined": "ConstituentSpotBalance" - } + "type": "u64" }, { - "name": "lastSpotBalanceTokenAmount", - "type": "i64" + "name": "last_ask_price_twap", + "docs": [ + "average estimate of ask price over funding_period", + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "cumulativeSpotInterestAccruedTokenAmount", - "type": "i64" + "name": "last_mark_price_twap", + "docs": [ + "average estimate of (bid+ask)/2 price over funding_period", + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "maxWeightDeviation", + "name": "last_mark_price_twap_5min", "docs": [ - "max deviation from target_weight allowed for the constituent", - "precision: PERCENTAGE_PRECISION" + "average estimate of (bid+ask)/2 price over FIVE_MINUTES" ], - "type": "i64" + "type": "u64" }, { - "name": "swapFeeMin", + "name": "last_update_slot", "docs": [ - "min fee charged on swaps to/from this constituent", - "precision: PERCENTAGE_PRECISION" + "the last blockchain slot the amm was updated" ], - "type": "i64" + "type": "u64" }, { - "name": "swapFeeMax", + "name": "last_oracle_conf_pct", "docs": [ - "max fee charged on swaps to/from this constituent", + "the pct size of the oracle confidence interval", "precision: PERCENTAGE_PRECISION" ], - "type": "i64" + "type": "u64" }, { - "name": "maxBorrowTokenAmount", + "name": "net_revenue_since_last_funding", "docs": [ - "Max Borrow amount:", - "precision: token precision" + "the total_fee_minus_distribution change since the last funding update", + "precision: QUOTE_PRECISION" ], - "type": "u64" + "type": "i64" }, { - "name": "vaultTokenBalance", + "name": "last_funding_rate_ts", "docs": [ - "ata token balance in token precision" + "the last funding rate update unix_timestamp" ], - "type": "u64" + "type": "i64" }, { - "name": "lastOraclePrice", + "name": "funding_period", + "docs": [ + "the periodicity of the funding rate updates" + ], "type": "i64" }, { - "name": "lastOracleSlot", + "name": "order_step_size", + "docs": [ + "the base step size (increment) of orders", + "precision: BASE_PRECISION" + ], "type": "u64" }, { - "name": "oracleStalenessThreshold", + "name": "order_tick_size", "docs": [ - "Delay allowed for valid AUM calculation" + "the price tick size of orders", + "precision: PRICE_PRECISION" ], "type": "u64" }, { - "name": "flashLoanInitialTokenAmount", + "name": "min_order_size", + "docs": [ + "the minimum base size of an order", + "precision: BASE_PRECISION" + ], "type": "u64" }, { - "name": "nextSwapId", + "name": "mm_oracle_slot", "docs": [ - "Every swap to/from this constituent has a monotonically increasing id. This is the next id to use" + "the max base size a single user can have", + "precision: BASE_PRECISION" ], "type": "u64" }, { - "name": "derivativeWeight", + "name": "volume_24h", "docs": [ - "percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight" + "estimated total of volume in market", + "QUOTE_PRECISION" ], "type": "u64" }, { - "name": "volatility", + "name": "long_intensity_volume", + "docs": [ + "the volume intensity of long fills against AMM" + ], "type": "u64" }, { - "name": "constituentDerivativeDepegThreshold", + "name": "short_intensity_volume", + "docs": [ + "the volume intensity of short fills against AMM" + ], "type": "u64" }, { - "name": "constituentDerivativeIndex", + "name": "last_trade_ts", "docs": [ - "The `constituent_index` of the parent constituent. -1 if it is a parent index", - "Example: if in a pool with SOL (parent) and dSOL (derivative),", - "SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,", - "dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1" + "the blockchain unix timestamp at the time of the last trade" ], - "type": "i16" + "type": "i64" }, { - "name": "spotMarketIndex", - "type": "u16" + "name": "mark_std", + "docs": [ + "estimate of standard deviation of the fill (mark) prices", + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "constituentIndex", - "type": "u16" + "name": "oracle_std", + "docs": [ + "estimate of standard deviation of the oracle price at each update", + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "decimals", - "type": "u8" + "name": "last_mark_price_twap_ts", + "docs": [ + "the last unix_timestamp the mark twap was updated" + ], + "type": "i64" }, { - "name": "bump", - "type": "u8" + "name": "base_spread", + "docs": [ + "the minimum spread the AMM can quote. also used as step size for some spread logic increases." + ], + "type": "u32" }, { - "name": "vaultBump", - "type": "u8" + "name": "max_spread", + "docs": [ + "the maximum spread the AMM can quote" + ], + "type": "u32" }, { - "name": "gammaInventory", - "type": "u8" + "name": "long_spread", + "docs": [ + "the spread for asks vs the reserve price" + ], + "type": "u32" }, { - "name": "gammaExecution", - "type": "u8" + "name": "short_spread", + "docs": [ + "the spread for bids vs the reserve price" + ], + "type": "u32" }, { - "name": "xi", - "type": "u8" + "name": "mm_oracle_price", + "docs": [ + "MM oracle price" + ], + "type": "i64" }, { - "name": "status", - "type": "u8" + "name": "max_fill_reserve_fraction", + "docs": [ + "the fraction of total available liquidity a single fill on the AMM can consume" + ], + "type": "u16" }, { - "name": "pausedOperations", - "type": "u8" + "name": "max_slippage_ratio", + "docs": [ + "the maximum slippage a single fill on the AMM can push" + ], + "type": "u16" }, { - "name": "padding", + "name": "curve_update_intensity", + "docs": [ + "the update intensity of AMM formulaic updates (adjusting k). 0-100" + ], + "type": "u8" + }, + { + "name": "amm_jit_intensity", + "docs": [ + "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.", + "(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM." + ], + "type": "u8" + }, + { + "name": "oracle_source", + "docs": [ + "the oracle provider information. used to decode/scale the oracle public key" + ], + "type": { + "defined": { + "name": "OracleSource" + } + } + }, + { + "name": "last_oracle_valid", + "docs": [ + "tracks whether the oracle was considered valid at the last AMM update" + ], + "type": "bool" + }, + { + "name": "target_base_asset_amount_per_lp", + "docs": [ + "the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split", + "precision: BASE_PRECISION" + ], + "type": "i32" + }, + { + "name": "per_lp_base", + "docs": [ + "expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)" + ], + "type": "i8" + }, + { + "name": "oracle_low_risk_slot_delay_override", + "docs": [ + "the override for the state.min_perp_auction_duration", + "0 is no override, -1 is disable speed bump, 1-100 is literal speed bump" + ], + "type": "i8" + }, + { + "name": "amm_spread_adjustment", + "docs": [ + "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" + ], + "type": "i8" + }, + { + "name": "oracle_slot_delay_override", + "type": "i8" + }, + { + "name": "mm_oracle_sequence_id", + "type": "u64" + }, + { + "name": "net_unsettled_funding_pnl", + "type": "i64" + }, + { + "name": "quote_asset_amount_with_unsettled_lp", + "type": "i64" + }, + { + "name": "reference_price_offset", + "type": "i32" + }, + { + "name": "amm_inventory_spread_adjustment", + "docs": [ + "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" + ], + "type": "i8" + }, + { + "name": "reference_price_offset_deadband_pct", + "type": "u8" + }, + { + "name": "padding", "type": { "array": [ "u8", - 162 + 2 ] } + }, + { + "name": "last_funding_oracle_twap", + "type": "i64" } ] } }, { - "name": "AmmConstituentMapping", + "name": "AddAmmConstituentMappingDatum", "type": { "kind": "struct", "fields": [ { - "name": "lpPool", - "type": "publicKey" + "name": "constituent_index", + "type": "u16" + }, + { + "name": "perp_market_index", + "type": "u16" }, + { + "name": "weight", + "type": "i64" + } + ] + } + }, + { + "name": "AmmCache", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { "name": "bump", "type": "u8" }, { - "name": "padding", + "name": "_padding", "type": { "array": [ "u8", @@ -9943,10 +16659,12 @@ } }, { - "name": "weights", + "name": "cache", "type": { "vec": { - "defined": "AmmConstituentDatum" + "defined": { + "name": "CacheInfo" + } } } } @@ -9954,53 +16672,63 @@ } }, { - "name": "ConstituentTargetBase", + "name": "AmmConstituentDatum", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "lpPool", - "type": "publicKey" + "name": "perp_market_index", + "type": "u16" }, { - "name": "bump", - "type": "u8" + "name": "constituent_index", + "type": "u16" }, { - "name": "padding", + "name": "_padding", "type": { "array": [ "u8", - 3 + 4 ] } }, { - "name": "targets", - "type": { - "vec": { - "defined": "TargetsDatum" - } - } + "name": "last_slot", + "type": "u64" + }, + { + "name": "weight", + "docs": [ + "PERCENTAGE_PRECISION. The weight this constituent has on the perp market" + ], + "type": "i64" } ] } }, { - "name": "ConstituentCorrelations", + "name": "AmmConstituentMapping", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "lpPool", - "type": "publicKey" + "name": "lp_pool", + "type": "pubkey" }, { "name": "bump", "type": "u8" }, { - "name": "padding", + "name": "_padding", "type": { "array": [ "u8", @@ -10009,41 +16737,56 @@ } }, { - "name": "correlations", + "name": "weights", "type": { - "vec": "i64" + "vec": { + "defined": { + "name": "AmmConstituentDatum" + } + } } } ] } }, { - "name": "PrelaunchOracle", + "name": "AssetTier", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "price", - "type": "i64" + "name": "Collateral" }, { - "name": "maxPrice", - "type": "i64" + "name": "Protected" }, { - "name": "confidence", - "type": "u64" + "name": "Cross" }, { - "name": "lastUpdateSlot", - "type": "u64" + "name": "Isolated" }, { - "name": "ammLastUpdateSlot", - "type": "u64" + "name": "Unlisted" + } + ] + } + }, + { + "name": "BuilderInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" }, { - "name": "perpMarketIndex", + "name": "max_fee_tenth_bps", "type": "u16" }, { @@ -10051,7 +16794,7 @@ "type": { "array": [ "u8", - 70 + 6 ] } } @@ -10059,311 +16802,303 @@ } }, { - "name": "PerpMarket", + "name": "CacheInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "pubkey", - "docs": [ - "The perp market's address. It is a pda of the market index" - ], - "type": "publicKey" + "name": "oracle", + "type": "pubkey" }, { - "name": "amm", - "docs": [ - "The automated market maker" - ], - "type": { - "defined": "AMM" - } + "name": "last_fee_pool_token_amount", + "type": "u128" }, { - "name": "pnlPool", - "docs": [ - "The market's pnl pool. When users settle negative pnl, the balance increases.", - "When users settle positive pnl, the balance decreases. Can not go negative." - ], - "type": { - "defined": "PoolBalance" - } + "name": "last_net_pnl_pool_token_amount", + "type": "i128" }, { - "name": "name", - "docs": [ - "Encoded display name for the perp market e.g. SOL-PERP" - ], - "type": { - "array": [ - "u8", - 32 - ] - } + "name": "last_exchange_fees", + "type": "u128" }, { - "name": "insuranceClaim", - "docs": [ - "The perp market's claim on the insurance fund" - ], - "type": { - "defined": "InsuranceClaim" - } + "name": "last_settle_amm_ex_fees", + "type": "u128" }, { - "name": "unrealizedPnlMaxImbalance", - "docs": [ - "The max pnl imbalance before positive pnl asset weight is discounted", - "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", - "the amm has negative pnl and the initial asset weight for positive pnl is discounted", - "precision = QUOTE_PRECISION" - ], - "type": "u64" + "name": "last_settle_amm_pnl", + "type": "i128" }, { - "name": "expiryTs", + "name": "position", "docs": [ - "The ts when the market will be expired. Only set if market is in reduce only mode" + "BASE PRECISION" ], "type": "i64" }, { - "name": "expiryPrice", - "docs": [ - "The price at which positions will be settled. Only set if market is expired", - "precision = PRICE_PRECISION" - ], - "type": "i64" + "name": "slot", + "type": "u64" }, { - "name": "nextFillRecordId", - "docs": [ - "Every trade has a fill record id. This is the next id to be used" - ], + "name": "last_settle_amount", "type": "u64" }, { - "name": "nextFundingRateRecordId", - "docs": [ - "Every funding rate update has a record id. This is the next id to be used" - ], + "name": "last_settle_slot", "type": "u64" }, { - "name": "nextCurveRecordId", - "docs": [ - "Every amm k updated has a record id. This is the next id to be used" - ], - "type": "u64" + "name": "last_settle_ts", + "type": "i64" }, { - "name": "imfFactor", - "docs": [ - "The initial margin fraction factor. Used to increase margin ratio for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" + "name": "quote_owed_from_lp_pool", + "type": "i64" }, { - "name": "unrealizedPnlImfFactor", - "docs": [ - "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", - "precision: MARGIN_PRECISION" - ], - "type": "u32" + "name": "amm_inventory_limit", + "type": "i64" }, { - "name": "liquidatorFee", - "docs": [ - "The fee the liquidator is paid for taking over perp position", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" + "name": "oracle_price", + "type": "i64" }, { - "name": "ifLiquidationFee", - "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" + "name": "oracle_slot", + "type": "u64" }, { - "name": "marginRatioInitial", - "docs": [ - "The margin ratio which determines how much collateral is required to open a position", - "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", - "precision: MARGIN_PRECISION" - ], - "type": "u32" + "name": "market_index", + "type": "u16" }, { - "name": "marginRatioMaintenance", - "docs": [ - "The margin ratio which determines when a user will be liquidated", - "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", - "else they will be liquidated", - "precision: MARGIN_PRECISION" - ], - "type": "u32" + "name": "oracle_source", + "type": "u8" }, { - "name": "unrealizedPnlInitialAssetWeight", - "docs": [ - "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "oracle_validity", + "type": "u8" }, { - "name": "unrealizedPnlMaintenanceAssetWeight", - "docs": [ - "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "lp_status_for_perp_market", + "type": "u8" }, { - "name": "numberOfUsersWithBase", - "docs": [ - "number of users in a position (base)" - ], - "type": "u32" + "name": "amm_position_scalar", + "type": "u8" }, { - "name": "numberOfUsers", + "name": "_padding", + "type": { + "array": [ + "u8", + 34 + ] + } + } + ] + } + }, + { + "name": "Constituent", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", "docs": [ - "number of users in a position (pnl) or pnl (quote)" + "address of the constituent" ], - "type": "u32" + "type": "pubkey" }, { - "name": "marketIndex", - "type": "u16" + "name": "mint", + "type": "pubkey" }, { - "name": "status", + "name": "lp_pool", + "type": "pubkey" + }, + { + "name": "vault", + "type": "pubkey" + }, + { + "name": "total_swap_fees", "docs": [ - "Whether a market is active, reduce only, expired, etc", - "Affects whether users can open/close positions" + "total fees received by the constituent. Positive = fees received, Negative = fees paid" ], "type": { - "defined": "MarketStatus" + "defined": { + "name": "i128" + } } }, { - "name": "contractType", + "name": "spot_balance", "docs": [ - "Currently only Perpetual markets are supported" + "spot borrow-lend balance for constituent" ], "type": { - "defined": "ContractType" + "defined": { + "name": "ConstituentSpotBalance" + } } }, { - "name": "contractTier", + "name": "last_spot_balance_token_amount", + "type": "i64" + }, + { + "name": "cumulative_spot_interest_accrued_token_amount", + "type": "i64" + }, + { + "name": "max_weight_deviation", "docs": [ - "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", - "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" + "max deviation from target_weight allowed for the constituent", + "precision: PERCENTAGE_PRECISION" ], - "type": { - "defined": "ContractTier" - } + "type": "i64" }, { - "name": "pausedOperations", - "type": "u8" + "name": "swap_fee_min", + "docs": [ + "min fee charged on swaps to/from this constituent", + "precision: PERCENTAGE_PRECISION" + ], + "type": "i64" }, { - "name": "quoteSpotMarketIndex", + "name": "swap_fee_max", "docs": [ - "The spot market that pnl is settled in" + "max fee charged on swaps to/from this constituent", + "precision: PERCENTAGE_PRECISION" ], - "type": "u16" + "type": "i64" }, { - "name": "feeAdjustment", + "name": "max_borrow_token_amount", "docs": [ - "Between -100 and 100, represents what % to increase/decrease the fee by", - "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", - "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" + "Max Borrow amount:", + "precision: token precision" ], - "type": "i16" + "type": "u64" }, { - "name": "fuelBoostPosition", + "name": "vault_token_balance", "docs": [ - "fuel multiplier for perp funding", - "precision: 10" + "ata token balance in token precision" ], - "type": "u8" + "type": "u64" + }, + { + "name": "last_oracle_price", + "type": "i64" }, { - "name": "fuelBoostTaker", + "name": "last_oracle_slot", + "type": "u64" + }, + { + "name": "oracle_staleness_threshold", "docs": [ - "fuel multiplier for perp taker", - "precision: 10" + "Delay allowed for valid AUM calculation" ], - "type": "u8" + "type": "u64" }, { - "name": "fuelBoostMaker", + "name": "flash_loan_initial_token_amount", + "type": "u64" + }, + { + "name": "next_swap_id", "docs": [ - "fuel multiplier for perp maker", - "precision: 10" + "Every swap to/from this constituent has a monotonically increasing id. This is the next id to use" ], - "type": "u8" + "type": "u64" }, { - "name": "poolId", - "type": "u8" + "name": "derivative_weight", + "docs": [ + "percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight" + ], + "type": "u64" + }, + { + "name": "volatility", + "type": "u64" + }, + { + "name": "constituent_derivative_depeg_threshold", + "type": "u64" + }, + { + "name": "constituent_derivative_index", + "docs": [ + "The `constituent_index` of the parent constituent. -1 if it is a parent index", + "Example: if in a pool with SOL (parent) and dSOL (derivative),", + "SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,", + "dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1" + ], + "type": "i16" }, { - "name": "highLeverageMarginRatioInitial", + "name": "spot_market_index", "type": "u16" }, { - "name": "highLeverageMarginRatioMaintenance", + "name": "constituent_index", "type": "u16" }, { - "name": "protectedMakerLimitPriceDivisor", + "name": "decimals", "type": "u8" }, { - "name": "protectedMakerDynamicDivisor", + "name": "bump", "type": "u8" }, { - "name": "lpFeeTransferScalar", + "name": "vault_bump", "type": "u8" }, { - "name": "lpStatus", + "name": "gamma_inventory", "type": "u8" }, { - "name": "lpPausedOperations", + "name": "gamma_execution", "type": "u8" }, { - "name": "lpExchangeFeeExcluscionScalar", + "name": "xi", "type": "u8" }, { - "name": "lastFillPrice", - "type": "u64" + "name": "status", + "type": "u8" }, { - "name": "lpPoolId", + "name": "paused_operations", "type": "u8" }, { - "name": "padding", + "name": "_padding", "type": { "array": [ "u8", - 23 + 162 ] } } @@ -10371,165 +17106,211 @@ } }, { - "name": "ProtectedMakerModeConfig", + "name": "ConstituentCorrelations", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "currentUsers", - "type": "u32" + "name": "lp_pool", + "type": "pubkey" }, { - "name": "reduceOnly", + "name": "bump", "type": "u8" }, { - "name": "padding", + "name": "_padding", "type": { "array": [ "u8", - 31 + 3 ] } + }, + { + "name": "correlations", + "type": { + "vec": "i64" + } } ] } }, { - "name": "PythLazerOracle", + "name": "ConstituentParams", "type": { "kind": "struct", "fields": [ { - "name": "price", - "type": "i64" + "name": "max_weight_deviation", + "type": { + "option": "i64" + } }, { - "name": "publishTime", - "type": "u64" + "name": "swap_fee_min", + "type": { + "option": "i64" + } }, { - "name": "postedSlot", - "type": "u64" + "name": "swap_fee_max", + "type": { + "option": "i64" + } }, { - "name": "exponent", - "type": "i32" + "name": "max_borrow_token_amount", + "type": { + "option": "u64" + } }, { - "name": "padding", + "name": "oracle_staleness_threshold", "type": { - "array": [ - "u8", - 4 - ] + "option": "u64" } }, { - "name": "conf", - "type": "u64" - } - ] - } - }, - { - "name": "RevenueShare", - "type": { - "kind": "struct", - "fields": [ + "name": "cost_to_trade_bps", + "type": { + "option": "i32" + } + }, { - "name": "authority", - "docs": [ - "the owner of this account, a builder or referrer" - ], - "type": "publicKey" + "name": "constituent_derivative_index", + "type": { + "option": "i16" + } }, { - "name": "totalReferrerRewards", - "type": "u64" + "name": "derivative_weight", + "type": { + "option": "u64" + } }, { - "name": "totalBuilderRewards", - "type": "u64" + "name": "volatility", + "type": { + "option": "u64" + } }, { - "name": "padding", + "name": "gamma_execution", "type": { - "array": [ - "u8", - 18 - ] + "option": "u8" + } + }, + { + "name": "gamma_inventory", + "type": { + "option": "u8" + } + }, + { + "name": "xi", + "type": { + "option": "u8" } } ] } }, { - "name": "RevenueShareEscrow", + "name": "ConstituentSpotBalance", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "authority", + "name": "scaled_balance", "docs": [ - "the owner of this account, a user" + "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", + "interest of corresponding market.", + "precision: token precision" ], - "type": "publicKey" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "referrer", - "type": "publicKey" - }, - { - "name": "referrerBoostExpireTs", - "type": "u32" - }, - { - "name": "referrerRewardOffset", - "type": "i8" + "name": "cumulative_deposits", + "docs": [ + "The cumulative deposits/borrows a user has made into a market", + "precision: token mint precision" + ], + "type": "i64" }, { - "name": "refereeFeeNumeratorOffset", - "type": "i8" + "name": "market_index", + "docs": [ + "The market index of the corresponding spot market" + ], + "type": "u16" }, { - "name": "referrerBoostNumerator", - "type": "i8" + "name": "balance_type", + "docs": [ + "Whether the position is deposit or borrow" + ], + "type": { + "defined": { + "name": "SpotBalanceType" + } + } }, { - "name": "reservedFixed", + "name": "padding", "type": { "array": [ "u8", - 17 + 5 ] } + } + ] + } + }, + { + "name": "ConstituentTargetBase", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lp_pool", + "type": "pubkey" }, { - "name": "padding0", - "type": "u32" + "name": "bump", + "type": "u8" }, { - "name": "orders", + "name": "_padding", "type": { - "vec": { - "defined": "RevenueShareOrder" - } + "array": [ + "u8", + 3 + ] } }, { - "name": "padding1", - "type": "u32" - }, - { - "name": "approvedBuilders", + "name": "targets", "type": { "vec": { - "defined": "BuilderInfo" + "defined": { + "name": "TargetsDatum" + } } } } @@ -10537,912 +17318,792 @@ } }, { - "name": "SignedMsgUserOrders", - "docs": [ - "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" - ], + "name": "ContractTier", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "authorityPubkey", - "type": "publicKey" + "name": "A" }, { - "name": "padding", - "type": "u32" + "name": "B" }, { - "name": "signedMsgOrderData", - "type": { - "vec": { - "defined": "SignedMsgOrderId" - } - } + "name": "C" + }, + { + "name": "Speculative" + }, + { + "name": "HighlySpeculative" + }, + { + "name": "Isolated" } ] } }, { - "name": "SignedMsgWsDelegates", - "docs": [ - "* Used to store authenticated delegates for swift-like ws connections" - ], + "name": "ContractType", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "delegates", - "type": { - "vec": "publicKey" - } + "name": "Perpetual" + }, + { + "name": "Future" + }, + { + "name": "Prediction" } ] } }, { - "name": "SpotMarket", + "name": "CurveRecord", "type": { "kind": "struct", "fields": [ { - "name": "pubkey", - "docs": [ - "The address of the spot market. It is a pda of the market index" - ], - "type": "publicKey" - }, - { - "name": "oracle", - "docs": [ - "The oracle used to price the markets deposits/borrows" - ], - "type": "publicKey" - }, - { - "name": "mint", - "docs": [ - "The token mint of the market" - ], - "type": "publicKey" - }, - { - "name": "vault", - "docs": [ - "The vault used to store the market's deposits", - "The amount in the vault should be equal to or greater than deposits - borrows" - ], - "type": "publicKey" - }, - { - "name": "name", - "docs": [ - "The encoded display name for the market e.g. SOL" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "historicalOracleData", - "type": { - "defined": "HistoricalOracleData" - } + "name": "ts", + "type": "i64" }, { - "name": "historicalIndexData", - "type": { - "defined": "HistoricalIndexData" - } + "name": "record_id", + "type": "u64" }, { - "name": "revenuePool", - "docs": [ - "Revenue the protocol has collected in this markets token", - "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" - ], - "type": { - "defined": "PoolBalance" - } + "name": "peg_multiplier_before", + "type": "u128" }, { - "name": "spotFeePool", - "docs": [ - "The fees collected from swaps between this market and the quote market", - "Is settled to the quote markets revenue pool" - ], - "type": { - "defined": "PoolBalance" - } + "name": "base_asset_reserve_before", + "type": "u128" }, { - "name": "insuranceFund", - "docs": [ - "Details on the insurance fund covering bankruptcies in this markets token", - "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" - ], - "type": { - "defined": "InsuranceFund" - } + "name": "quote_asset_reserve_before", + "type": "u128" }, { - "name": "totalSpotFee", - "docs": [ - "The total spot fees collected for this market", - "precision: QUOTE_PRECISION" - ], + "name": "sqrt_k_before", "type": "u128" }, { - "name": "depositBalance", - "docs": [ - "The sum of the scaled balances for deposits across users and pool balances", - "To convert to the deposit token amount, multiply by the cumulative deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], + "name": "peg_multiplier_after", "type": "u128" }, { - "name": "borrowBalance", - "docs": [ - "The sum of the scaled balances for borrows across users and pool balances", - "To convert to the borrow token amount, multiply by the cumulative borrow interest", - "precision: SPOT_BALANCE_PRECISION" - ], + "name": "base_asset_reserve_after", "type": "u128" }, { - "name": "cumulativeDepositInterest", - "docs": [ - "The cumulative interest earned by depositors", - "Used to calculate the deposit token amount from the deposit balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], + "name": "quote_asset_reserve_after", "type": "u128" }, { - "name": "cumulativeBorrowInterest", - "docs": [ - "The cumulative interest earned by borrowers", - "Used to calculate the borrow token amount from the borrow balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], + "name": "sqrt_k_after", "type": "u128" }, { - "name": "totalSocialLoss", + "name": "base_asset_amount_long", "docs": [ - "The total socialized loss from borrows, in the mint's token", - "precision: token mint precision" + "precision: BASE_PRECISION" ], "type": "u128" }, { - "name": "totalQuoteSocialLoss", + "name": "base_asset_amount_short", "docs": [ - "The total socialized loss from borrows, in the quote market's token", - "preicision: QUOTE_PRECISION" + "precision: BASE_PRECISION" ], "type": "u128" }, { - "name": "withdrawGuardThreshold", + "name": "base_asset_amount_with_amm", "docs": [ - "no withdraw limits/guards when deposits below this threshold", - "precision: token mint precision" + "precision: BASE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "maxTokenDeposits", + "name": "total_fee", "docs": [ - "The max amount of token deposits in this market", - "0 if there is no limit", - "precision: token mint precision" + "precision: QUOTE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "depositTokenTwap", + "name": "total_fee_minus_distributions", "docs": [ - "24hr average of deposit token amount", - "precision: token mint precision" + "precision: QUOTE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "borrowTokenTwap", + "name": "adjustment_cost", "docs": [ - "24hr average of borrow token amount", - "precision: token mint precision" + "precision: QUOTE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "utilizationTwap", + "name": "oracle_price", "docs": [ - "24hr average of utilization", - "which is borrow amount over token amount", - "precision: SPOT_UTILIZATION_PRECISION" + "precision: PRICE_PRECISION" ], - "type": "u64" + "type": "i64" }, { - "name": "lastInterestTs", - "docs": [ - "Last time the cumulative deposit and borrow interest was updated" - ], - "type": "u64" + "name": "fill_record", + "type": "u128" }, { - "name": "lastTwapTs", - "docs": [ - "Last time the deposit/borrow/utilization averages were updated" - ], - "type": "u64" + "name": "number_of_users", + "type": "u32" }, { - "name": "expiryTs", + "name": "market_index", + "type": "u16" + } + ] + } + }, + { + "name": "DeleteUserRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", "docs": [ - "The time the market is set to expire. Only set if market is in reduce only mode" + "unix_timestamp of action" ], "type": "i64" }, { - "name": "orderStepSize", - "docs": [ - "Spot orders must be a multiple of the step size", - "precision: token mint precision" - ], - "type": "u64" + "name": "user_authority", + "type": "pubkey" }, { - "name": "orderTickSize", - "docs": [ - "Spot orders must be a multiple of the tick size", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "user", + "type": "pubkey" }, { - "name": "minOrderSize", - "docs": [ - "The minimum order size", - "precision: token mint precision" - ], - "type": "u64" + "name": "sub_account_id", + "type": "u16" }, { - "name": "maxPositionSize", - "docs": [ - "The maximum spot position size", - "if the limit is 0, there is no limit", - "precision: token mint precision" - ], - "type": "u64" - }, + "name": "keeper", + "type": { + "option": "pubkey" + } + } + ] + } + }, + { + "name": "DepositDirection", + "type": { + "kind": "enum", + "variants": [ { - "name": "nextFillRecordId", - "docs": [ - "Every spot trade has a fill record id. This is the next id to use" - ], - "type": "u64" + "name": "Deposit" }, { - "name": "nextDepositRecordId", - "docs": [ - "Every deposit has a deposit record id. This is the next id to use" - ], - "type": "u64" - }, + "name": "Withdraw" + } + ] + } + }, + { + "name": "DepositExplanation", + "type": { + "kind": "enum", + "variants": [ { - "name": "initialAssetWeight", - "docs": [ - "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", - "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "None" }, { - "name": "maintenanceAssetWeight", - "docs": [ - "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", - "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "Transfer" }, { - "name": "initialLiabilityWeight", - "docs": [ - "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", - "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "Borrow" }, { - "name": "maintenanceLiabilityWeight", - "docs": [ - "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", - "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "RepayBorrow" }, { - "name": "imfFactor", + "name": "Reward" + } + ] + } + }, + { + "name": "DepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", "docs": [ - "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", - "precision: MARGIN_PRECISION" + "unix_timestamp of action" ], - "type": "u32" + "type": "i64" }, { - "name": "liquidatorFee", - "docs": [ - "The fee the liquidator is paid for taking over borrow/deposit", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" + "name": "user_authority", + "type": "pubkey" }, { - "name": "ifLiquidationFee", + "name": "user", "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" + "user account public key" ], - "type": "u32" + "type": "pubkey" }, { - "name": "optimalUtilization", - "docs": [ - "The optimal utilization rate for this market.", - "Used to determine the markets borrow rate", - "precision: SPOT_UTILIZATION_PRECISION" - ], - "type": "u32" + "name": "direction", + "type": { + "defined": { + "name": "DepositDirection" + } + } }, { - "name": "optimalBorrowRate", - "docs": [ - "The borrow rate for this market when the market has optimal utilization", - "precision: SPOT_RATE_PRECISION" - ], - "type": "u32" + "name": "deposit_record_id", + "type": "u64" }, { - "name": "maxBorrowRate", + "name": "amount", "docs": [ - "The borrow rate for this market when the market has 1000 utilization", - "precision: SPOT_RATE_PRECISION" + "precision: token mint precision" ], - "type": "u32" + "type": "u64" }, { - "name": "decimals", + "name": "market_index", "docs": [ - "The market's token mint's decimals. To from decimals to a precision, 10^decimals" + "spot market index" ], - "type": "u32" - }, - { - "name": "marketIndex", "type": "u16" }, { - "name": "ordersEnabled", + "name": "oracle_price", "docs": [ - "Whether or not spot trading is enabled" + "precision: PRICE_PRECISION" ], - "type": "bool" - }, - { - "name": "oracleSource", - "type": { - "defined": "OracleSource" - } - }, - { - "name": "status", - "type": { - "defined": "MarketStatus" - } + "type": "i64" }, { - "name": "assetTier", + "name": "market_deposit_balance", "docs": [ - "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" + "precision: SPOT_BALANCE_PRECISION" ], - "type": { - "defined": "AssetTier" - } - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "ifPausedOperations", - "type": "u8" - }, - { - "name": "feeAdjustment", - "type": "i16" + "type": "u128" }, { - "name": "maxTokenBorrowsFraction", + "name": "market_withdraw_balance", "docs": [ - "What fraction of max_token_deposits", - "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", - "precision: X/10000" + "precision: SPOT_BALANCE_PRECISION" ], - "type": "u16" + "type": "u128" }, { - "name": "flashLoanAmount", + "name": "market_cumulative_deposit_interest", "docs": [ - "For swaps, the amount of token loaned out in the begin_swap ix", - "precision: token mint precision" + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" ], - "type": "u64" + "type": "u128" }, { - "name": "flashLoanInitialTokenAmount", + "name": "market_cumulative_borrow_interest", "docs": [ - "For swaps, the amount in the users token account in the begin_swap ix", - "Used to calculate how much of the token left the system in end_swap ix", - "precision: token mint precision" + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" ], - "type": "u64" + "type": "u128" }, { - "name": "totalSwapFee", + "name": "total_deposits_after", "docs": [ - "The total fees received from swaps", - "precision: token mint precision" + "precision: QUOTE_PRECISION" ], "type": "u64" }, { - "name": "scaleInitialAssetWeightStart", + "name": "total_withdraws_after", "docs": [ - "When to begin scaling down the initial asset weight", - "disabled when 0", "precision: QUOTE_PRECISION" ], "type": "u64" }, { - "name": "minBorrowRate", - "docs": [ - "The min borrow rate for this market when the market regardless of utilization", - "1 => 1/200 => .5%", - "precision: X/200" - ], - "type": "u8" - }, - { - "name": "fuelBoostDeposits", - "docs": [ - "fuel multiplier for spot deposits", - "precision: 10" - ], - "type": "u8" + "name": "explanation", + "type": { + "defined": { + "name": "DepositExplanation" + } + } }, { - "name": "fuelBoostBorrows", - "docs": [ - "fuel multiplier for spot borrows", - "precision: 10" - ], - "type": "u8" + "name": "transfer_user", + "type": { + "option": "pubkey" + } }, { - "name": "fuelBoostTaker", - "docs": [ - "fuel multiplier for spot taker", - "precision: 10" - ], - "type": "u8" + "name": "signer", + "type": { + "option": "pubkey" + } }, { - "name": "fuelBoostMaker", + "name": "user_token_amount_after", "docs": [ - "fuel multiplier for spot maker", - "precision: 10" + "precision: token mint precision" ], - "type": "u8" - }, + "type": "i128" + } + ] + } + }, + { + "name": "FeeStructure", + "type": { + "kind": "struct", + "fields": [ { - "name": "fuelBoostInsurance", - "docs": [ - "fuel multiplier for spot insurance stake", - "precision: 10" - ], - "type": "u8" + "name": "fee_tiers", + "type": { + "array": [ + { + "defined": { + "name": "FeeTier" + } + }, + 10 + ] + } }, { - "name": "tokenProgramFlag", - "type": "u8" + "name": "filler_reward_structure", + "type": { + "defined": { + "name": "OrderFillerRewardStructure" + } + } }, { - "name": "poolId", - "type": "u8" + "name": "referrer_reward_epoch_upper_bound", + "type": "u64" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 40 - ] - } + "name": "flat_filler_fee", + "type": "u64" } ] } }, { - "name": "State", + "name": "FeeTier", "type": { "kind": "struct", "fields": [ { - "name": "admin", - "type": "publicKey" + "name": "fee_numerator", + "type": "u32" }, { - "name": "whitelistMint", - "type": "publicKey" + "name": "fee_denominator", + "type": "u32" }, { - "name": "discountMint", - "type": "publicKey" + "name": "maker_rebate_numerator", + "type": "u32" }, { - "name": "signer", - "type": "publicKey" + "name": "maker_rebate_denominator", + "type": "u32" }, { - "name": "srmVault", - "type": "publicKey" + "name": "referrer_reward_numerator", + "type": "u32" }, { - "name": "perpFeeStructure", - "type": { - "defined": "FeeStructure" - } + "name": "referrer_reward_denominator", + "type": "u32" }, { - "name": "spotFeeStructure", - "type": { - "defined": "FeeStructure" - } + "name": "referee_fee_numerator", + "type": "u32" + }, + { + "name": "referee_fee_denominator", + "type": "u32" + } + ] + } + }, + { + "name": "FuelOverflow", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The authority of this overflow account" + ], + "type": "pubkey" }, { - "name": "oracleGuardRails", + "name": "fuel_insurance", "type": { - "defined": "OracleGuardRails" + "defined": { + "name": "u128" + } } }, { - "name": "numberOfAuthorities", - "type": "u64" + "name": "fuel_deposits", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "numberOfSubAccounts", - "type": "u64" + "name": "fuel_borrows", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "lpCooldownTime", - "type": "u64" + "name": "fuel_positions", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuel_taker", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuel_maker", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "liquidationMarginBufferRatio", + "name": "last_fuel_sweep_ts", "type": "u32" }, { - "name": "settlementDuration", - "type": "u16" + "name": "last_reset_ts", + "type": "u32" }, { - "name": "numberOfMarkets", - "type": "u16" + "name": "padding", + "type": { + "array": [ + "u128", + 6 + ] + } + } + ] + } + }, + { + "name": "FuelSeasonRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "numberOfSpotMarkets", - "type": "u16" + "name": "authority", + "type": "pubkey" }, { - "name": "signerNonce", - "type": "u8" + "name": "fuel_insurance", + "type": "u128" }, { - "name": "minPerpAuctionDuration", - "type": "u8" + "name": "fuel_deposits", + "type": "u128" }, { - "name": "defaultMarketOrderTimeInForce", - "type": "u8" + "name": "fuel_borrows", + "type": "u128" }, { - "name": "defaultSpotAuctionDuration", - "type": "u8" + "name": "fuel_positions", + "type": "u128" }, { - "name": "exchangeStatus", - "type": "u8" + "name": "fuel_taker", + "type": "u128" }, { - "name": "liquidationDuration", - "type": "u8" + "name": "fuel_maker", + "type": "u128" }, { - "name": "initialPctToLiquidate", - "type": "u16" + "name": "fuel_total", + "type": "u128" + } + ] + } + }, + { + "name": "FuelSweepRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "maxNumberOfSubAccounts", - "type": "u16" + "name": "authority", + "type": "pubkey" }, { - "name": "maxInitializeUserFee", - "type": "u16" + "name": "user_stats_fuel_insurance", + "type": "u32" }, { - "name": "featureBitFlags", - "type": "u8" + "name": "user_stats_fuel_deposits", + "type": "u32" }, { - "name": "lpPoolFeatureBitFlags", - "type": "u8" + "name": "user_stats_fuel_borrows", + "type": "u32" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 8 - ] - } + "name": "user_stats_fuel_positions", + "type": "u32" + }, + { + "name": "user_stats_fuel_taker", + "type": "u32" + }, + { + "name": "user_stats_fuel_maker", + "type": "u32" + }, + { + "name": "fuel_overflow_fuel_insurance", + "type": "u128" + }, + { + "name": "fuel_overflow_fuel_deposits", + "type": "u128" + }, + { + "name": "fuel_overflow_fuel_borrows", + "type": "u128" + }, + { + "name": "fuel_overflow_fuel_positions", + "type": "u128" + }, + { + "name": "fuel_overflow_fuel_taker", + "type": "u128" + }, + { + "name": "fuel_overflow_fuel_maker", + "type": "u128" } ] } }, { - "name": "User", + "name": "FundingPaymentRecord", "type": { "kind": "struct", "fields": [ { - "name": "authority", - "docs": [ - "The owner/authority of the account" - ], - "type": "publicKey" + "name": "ts", + "type": "i64" }, { - "name": "delegate", - "docs": [ - "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw" - ], - "type": "publicKey" + "name": "user_authority", + "type": "pubkey" }, { - "name": "name", - "docs": [ - "Encoded display name e.g. \"toly\"" - ], - "type": { - "array": [ - "u8", - 32 - ] - } + "name": "user", + "type": "pubkey" }, { - "name": "spotPositions", - "docs": [ - "The user's spot positions" - ], - "type": { - "array": [ - { - "defined": "SpotPosition" - }, - 8 - ] - } + "name": "market_index", + "type": "u16" }, { - "name": "perpPositions", + "name": "funding_payment", "docs": [ - "The user's perp positions" + "precision: QUOTE_PRECISION" ], - "type": { - "array": [ - { - "defined": "PerpPosition" - }, - 8 - ] - } + "type": "i64" }, { - "name": "orders", + "name": "base_asset_amount", "docs": [ - "The user's orders" + "precision: BASE_PRECISION" ], - "type": { - "array": [ - { - "defined": "Order" - }, - 32 - ] - } + "type": "i64" }, { - "name": "lastAddPerpLpSharesTs", + "name": "user_last_cumulative_funding", "docs": [ - "The last time the user added perp lp positions" + "precision: FUNDING_RATE_PRECISION" ], "type": "i64" }, { - "name": "totalDeposits", + "name": "amm_cumulative_funding_long", "docs": [ - "The total values of deposits the user has made", - "precision: QUOTE_PRECISION" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "totalWithdraws", + "name": "amm_cumulative_funding_short", "docs": [ - "The total values of withdrawals the user has made", - "precision: QUOTE_PRECISION" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u64" + "type": "i128" + } + ] + } + }, + { + "name": "FundingRateRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "totalSocialLoss", - "docs": [ - "The total socialized loss the users has incurred upon the protocol", - "precision: QUOTE_PRECISION" - ], + "name": "record_id", "type": "u64" }, { - "name": "settledPerpPnl", - "docs": [ - "Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps", - "precision: QUOTE_PRECISION" - ], - "type": "i64" + "name": "market_index", + "type": "u16" }, { - "name": "cumulativeSpotFees", + "name": "funding_rate", "docs": [ - "Fees (taker fees, maker rebate, filler reward) for spot", - "precision: QUOTE_PRECISION" + "precision: FUNDING_RATE_PRECISION" ], "type": "i64" }, { - "name": "cumulativePerpFunding", + "name": "funding_rate_long", "docs": [ - "Cumulative funding paid/received for perps", - "precision: QUOTE_PRECISION" + "precision: FUNDING_RATE_PRECISION" ], - "type": "i64" + "type": "i128" }, { - "name": "liquidationMarginFreed", + "name": "funding_rate_short", "docs": [ - "The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time", - "Defaults to zero when not being liquidated", - "precision: QUOTE_PRECISION" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "lastActiveSlot", + "name": "cumulative_funding_rate_long", "docs": [ - "The last slot a user was active. Used to determine if a user is idle" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "nextOrderId", + "name": "cumulative_funding_rate_short", "docs": [ - "Every user order has an order id. This is the next order id to be used" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u32" + "type": "i128" }, { - "name": "maxMarginRatio", + "name": "oracle_price_twap", "docs": [ - "Custom max initial margin ratio for the user" + "precision: PRICE_PRECISION" ], - "type": "u32" + "type": "i64" }, { - "name": "nextLiquidationId", + "name": "mark_price_twap", "docs": [ - "The next liquidation id to be used for user" + "precision: PRICE_PRECISION" ], - "type": "u16" + "type": "u64" }, { - "name": "subAccountId", + "name": "period_revenue", "docs": [ - "The sub account id for this user" + "precision: QUOTE_PRECISION" ], - "type": "u16" + "type": "i64" }, { - "name": "status", + "name": "base_asset_amount_with_amm", "docs": [ - "Whether the user is active, being liquidated or bankrupt" + "precision: BASE_PRECISION" ], - "type": "u8" + "type": "i128" }, { - "name": "isMarginTradingEnabled", + "name": "base_asset_amount_with_unsettled_lp", "docs": [ - "Whether the user has enabled margin trading" - ], - "type": "bool" - }, - { - "name": "idle", - "docs": [ - "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", - "Off-chain keeper bots can ignore users that are idle" - ], - "type": "bool" - }, - { - "name": "openOrders", - "docs": [ - "number of open orders" - ], - "type": "u8" - }, - { - "name": "hasOpenOrder", - "docs": [ - "Whether or not user has open order" - ], - "type": "bool" - }, - { - "name": "openAuctions", - "docs": [ - "number of open orders with auction" + "precision: BASE_PRECISION" ], - "type": "u8" - }, + "type": "i128" + } + ] + } + }, + { + "name": "HighLeverageModeConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "hasOpenAuction", - "docs": [ - "Whether or not user has open order with auction" - ], - "type": "bool" + "name": "max_users", + "type": "u32" }, { - "name": "marginMode", - "type": { - "defined": "MarginMode" - } + "name": "current_users", + "type": "u32" }, { - "name": "poolId", + "name": "reduce_only", "type": "u8" }, { @@ -11455,15 +18116,15 @@ } }, { - "name": "lastFuelBonusUpdateTs", + "name": "current_maintenance_users", "type": "u32" }, { - "name": "padding", + "name": "padding2", "type": { "array": [ "u8", - 12 + 24 ] } } @@ -11471,224 +18132,202 @@ } }, { - "name": "UserStats", + "name": "HistoricalIndexData", "type": { "kind": "struct", "fields": [ { - "name": "authority", + "name": "last_index_bid_price", "docs": [ - "The authority for all of a users sub accounts" + "precision: PRICE_PRECISION" ], - "type": "publicKey" + "type": "u64" }, { - "name": "referrer", + "name": "last_index_ask_price", "docs": [ - "The address that referred this user" + "precision: PRICE_PRECISION" ], - "type": "publicKey" + "type": "u64" }, { - "name": "fees", + "name": "last_index_price_twap", "docs": [ - "Stats on the fees paid by the user" + "precision: PRICE_PRECISION" ], - "type": { - "defined": "UserFees" - } + "type": "u64" }, { - "name": "nextEpochTs", + "name": "last_index_price_twap_5min", "docs": [ - "The timestamp of the next epoch", - "Epoch is used to limit referrer rewards earned in single epoch" + "precision: PRICE_PRECISION" ], - "type": "i64" + "type": "u64" }, { - "name": "makerVolume30d", + "name": "last_index_price_twap_ts", "docs": [ - "Rolling 30day maker volume for user", - "precision: QUOTE_PRECISION" + "unix_timestamp of last snapshot" ], - "type": "u64" - }, + "type": "i64" + } + ] + } + }, + { + "name": "HistoricalOracleData", + "type": { + "kind": "struct", + "fields": [ { - "name": "takerVolume30d", + "name": "last_oracle_price", "docs": [ - "Rolling 30day taker volume for user", - "precision: QUOTE_PRECISION" + "precision: PRICE_PRECISION" ], - "type": "u64" + "type": "i64" }, { - "name": "fillerVolume30d", + "name": "last_oracle_conf", "docs": [ - "Rolling 30day filler volume for user", - "precision: QUOTE_PRECISION" + "precision: PRICE_PRECISION" ], "type": "u64" }, { - "name": "lastMakerVolume30dTs", + "name": "last_oracle_delay", "docs": [ - "last time the maker volume was updated" + "number of slots since last update" ], "type": "i64" }, { - "name": "lastTakerVolume30dTs", + "name": "last_oracle_price_twap", "docs": [ - "last time the taker volume was updated" + "precision: PRICE_PRECISION" ], "type": "i64" }, { - "name": "lastFillerVolume30dTs", + "name": "last_oracle_price_twap_5min", "docs": [ - "last time the filler volume was updated" + "precision: PRICE_PRECISION" ], "type": "i64" }, { - "name": "ifStakedQuoteAssetAmount", + "name": "last_oracle_price_twap_ts", "docs": [ - "The amount of tokens staked in the quote spot markets if" + "unix_timestamp of last snapshot" ], - "type": "u64" - }, + "type": "i64" + } + ] + } + }, + { + "name": "IfRebalanceConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "numberOfSubAccounts", - "docs": [ - "The current number of sub accounts" - ], - "type": "u16" + "name": "pubkey", + "type": "pubkey" }, { - "name": "numberOfSubAccountsCreated", + "name": "total_in_amount", "docs": [ - "The number of sub accounts created. Can be greater than the number of sub accounts if user", - "has deleted sub accounts" + "total amount to be sold" ], - "type": "u16" + "type": "u64" }, { - "name": "referrerStatus", + "name": "current_in_amount", "docs": [ - "Flags for referrer status:", - "First bit (LSB): 1 if user is a referrer, 0 otherwise", - "Second bit: 1 if user was referred, 0 otherwise" + "amount already sold" ], - "type": "u8" - }, - { - "name": "disableUpdatePerpBidAskTwap", - "type": "bool" - }, - { - "name": "padding1", - "type": { - "array": [ - "u8", - 1 - ] - } + "type": "u64" }, { - "name": "fuelOverflowStatus", + "name": "current_out_amount", "docs": [ - "whether the user has a FuelOverflow account" + "amount already bought" ], - "type": "u8" + "type": "u64" }, { - "name": "fuelInsurance", + "name": "current_out_amount_transferred", "docs": [ - "accumulated fuel for token amounts of insurance" + "amount already transferred to revenue pool" ], - "type": "u32" + "type": "u64" }, { - "name": "fuelDeposits", + "name": "current_in_amount_since_last_transfer", "docs": [ - "accumulated fuel for notional of deposits" + "amount already bought in epoch" ], - "type": "u32" + "type": "u64" }, { - "name": "fuelBorrows", + "name": "epoch_start_ts", "docs": [ - "accumulate fuel bonus for notional of borrows" + "start time of epoch" ], - "type": "u32" + "type": "i64" }, { - "name": "fuelPositions", + "name": "epoch_in_amount", "docs": [ - "accumulated fuel for perp open interest" + "amount already bought in epoch" ], - "type": "u32" + "type": "u64" }, { - "name": "fuelTaker", + "name": "epoch_max_in_amount", "docs": [ - "accumulate fuel bonus for taker volume" + "max amount to swap in epoch" ], - "type": "u32" + "type": "u64" }, { - "name": "fuelMaker", + "name": "epoch_duration", "docs": [ - "accumulate fuel bonus for maker volume" + "duration of epoch" ], - "type": "u32" + "type": "i64" }, { - "name": "ifStakedGovTokenAmount", + "name": "out_market_index", "docs": [ - "The amount of tokens staked in the governance spot markets if" + "market index to sell" ], - "type": "u64" + "type": "u16" }, { - "name": "lastFuelIfBonusUpdateTs", + "name": "in_market_index", "docs": [ - "last unix ts user stats data was used to update if fuel (u32 to save space)" + "market index to buy" ], - "type": "u32" + "type": "u16" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 12 - ] - } - } - ] - } - }, - { - "name": "ReferrerName", - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "publicKey" + "name": "max_slippage_bps", + "type": "u16" }, { - "name": "user", - "type": "publicKey" + "name": "swap_mode", + "type": "u8" }, { - "name": "userStats", - "type": "publicKey" + "name": "status", + "type": "u8" }, { - "name": "name", + "name": "padding2", "type": { "array": [ "u8", @@ -11700,715 +18339,796 @@ } }, { - "name": "FuelOverflow", + "name": "IfRebalanceConfigParams", "type": { "kind": "struct", "fields": [ { - "name": "authority", - "docs": [ - "The authority of this overflow account" - ], - "type": "publicKey" - }, - { - "name": "fuelInsurance", - "type": "u128" - }, - { - "name": "fuelDeposits", - "type": "u128" + "name": "total_in_amount", + "type": "u64" }, { - "name": "fuelBorrows", - "type": "u128" + "name": "epoch_max_in_amount", + "type": "u64" }, { - "name": "fuelPositions", - "type": "u128" + "name": "epoch_duration", + "type": "i64" }, { - "name": "fuelTaker", - "type": "u128" + "name": "out_market_index", + "type": "u16" }, { - "name": "fuelMaker", - "type": "u128" + "name": "in_market_index", + "type": "u16" }, { - "name": "lastFuelSweepTs", - "type": "u32" + "name": "max_slippage_bps", + "type": "u16" }, { - "name": "lastResetTs", - "type": "u32" + "name": "swap_mode", + "type": "u8" }, { - "name": "padding", - "type": { - "array": [ - "u128", - 6 - ] - } + "name": "status", + "type": "u8" } ] } - } - ], - "types": [ + }, { - "name": "UpdatePerpMarketSummaryStatsParams", + "name": "InsuranceClaim", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "quoteAssetAmountWithUnsettledLp", - "type": { - "option": "i64" - } + "name": "revenue_withdraw_since_last_settle", + "docs": [ + "The amount of revenue last settled", + "Positive if funds left the perp market,", + "negative if funds were pulled into the perp market", + "precision: QUOTE_PRECISION" + ], + "type": "i64" }, { - "name": "netUnsettledFundingPnl", - "type": { - "option": "i64" - } + "name": "max_revenue_withdraw_per_period", + "docs": [ + "The max amount of revenue that can be withdrawn per period", + "precision: QUOTE_PRECISION" + ], + "type": "u64" }, { - "name": "updateAmmSummaryStats", - "type": { - "option": "bool" - } + "name": "quote_max_insurance", + "docs": [ + "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits", + "precision: QUOTE_PRECISION" + ], + "type": "u64" }, { - "name": "excludeTotalLiqFee", - "type": { - "option": "bool" - } + "name": "quote_settled_insurance", + "docs": [ + "The amount of insurance that has been used to resolve bankruptcy and pnl deficits", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "last_revenue_withdraw_ts", + "docs": [ + "The last time revenue was settled in/out of market" + ], + "type": "i64" } ] } }, { - "name": "ConstituentParams", + "name": "InsuranceFund", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "maxWeightDeviation", - "type": { - "option": "i64" - } - }, - { - "name": "swapFeeMin", - "type": { - "option": "i64" - } - }, - { - "name": "swapFeeMax", - "type": { - "option": "i64" - } - }, - { - "name": "maxBorrowTokenAmount", - "type": { - "option": "u64" - } + "name": "vault", + "type": "pubkey" }, { - "name": "oracleStalenessThreshold", + "name": "total_shares", "type": { - "option": "u64" + "defined": { + "name": "u128" + } } }, { - "name": "costToTradeBps", + "name": "user_shares", "type": { - "option": "i32" + "defined": { + "name": "u128" + } } }, { - "name": "constituentDerivativeIndex", + "name": "shares_base", "type": { - "option": "i16" + "defined": { + "name": "u128" + } } }, { - "name": "derivativeWeight", - "type": { - "option": "u64" - } + "name": "unstaking_period", + "type": "i64" }, { - "name": "volatility", - "type": { - "option": "u64" - } + "name": "last_revenue_settle_ts", + "type": "i64" }, { - "name": "gammaExecution", - "type": { - "option": "u8" - } + "name": "revenue_settle_period", + "type": "i64" }, { - "name": "gammaInventory", - "type": { - "option": "u8" - } + "name": "total_factor", + "type": "u32" }, { - "name": "xi", - "type": { - "option": "u8" - } + "name": "user_factor", + "type": "u32" } ] } }, { - "name": "LpPoolParams", + "name": "InsuranceFundRecord", "type": { "kind": "struct", "fields": [ { - "name": "maxSettleQuoteAmount", - "type": { - "option": "u64" - } + "name": "ts", + "type": "i64" }, { - "name": "volatility", - "type": { - "option": "u64" - } + "name": "spot_market_index", + "type": "u16" }, { - "name": "gammaExecution", - "type": { - "option": "u8" - } + "name": "perp_market_index", + "type": "u16" }, { - "name": "xi", - "type": { - "option": "u8" - } + "name": "user_if_factor", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" }, { - "name": "maxAum", - "type": { - "option": "u128" - } + "name": "total_if_factor", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" }, { - "name": "whitelistMint", - "type": { - "option": "publicKey" - } + "name": "vault_amount_before", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "insurance_vault_amount_before", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "total_if_shares_before", + "type": "u128" + }, + { + "name": "total_if_shares_after", + "type": "u128" + }, + { + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "i64" } ] } }, { - "name": "OverrideAmmCacheParams", + "name": "InsuranceFundStake", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "quoteOwedFromLpPool", - "type": { - "option": "i64" - } + "name": "authority", + "type": "pubkey" }, { - "name": "lastSettleSlot", + "name": "if_shares", "type": { - "option": "u64" + "defined": { + "name": "u128" + } } }, { - "name": "lastFeePoolTokenAmount", + "name": "last_withdraw_request_shares", "type": { - "option": "u128" + "defined": { + "name": "u128" + } } }, { - "name": "lastNetPnlPoolTokenAmount", + "name": "if_base", "type": { - "option": "i128" + "defined": { + "name": "u128" + } } }, { - "name": "ammPositionScalar", - "type": { - "option": "u8" - } + "name": "last_valid_ts", + "type": "i64" + }, + { + "name": "last_withdraw_request_value", + "type": "u64" + }, + { + "name": "last_withdraw_request_ts", + "type": "i64" + }, + { + "name": "cost_basis", + "type": "i64" }, { - "name": "ammInventoryLimit", + "name": "market_index", + "type": "u16" + }, + { + "name": "padding", "type": { - "option": "i64" + "array": [ + "u8", + 14 + ] } } ] } }, { - "name": "AddAmmConstituentMappingDatum", + "name": "InsuranceFundStakeRecord", "type": { "kind": "struct", "fields": [ { - "name": "constituentIndex", - "type": "u16" + "name": "ts", + "type": "i64" + }, + { + "name": "user_authority", + "type": "pubkey" + }, + { + "name": "action", + "type": { + "defined": { + "name": "StakeAction" + } + } }, { - "name": "perpMarketIndex", + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "market_index", "type": "u16" }, { - "name": "weight", - "type": "i64" + "name": "insurance_vault_amount_before", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "if_shares_before", + "type": "u128" + }, + { + "name": "user_if_shares_before", + "type": "u128" + }, + { + "name": "total_if_shares_before", + "type": "u128" + }, + { + "name": "if_shares_after", + "type": "u128" + }, + { + "name": "user_if_shares_after", + "type": "u128" + }, + { + "name": "total_if_shares_after", + "type": "u128" } ] } }, { - "name": "CacheInfo", + "name": "InsuranceFundSwapRecord", "type": { "kind": "struct", "fields": [ { - "name": "oracle", - "type": "publicKey" + "name": "rebalance_config", + "type": "pubkey" }, { - "name": "lastFeePoolTokenAmount", + "name": "in_if_total_shares_before", "type": "u128" }, { - "name": "lastNetPnlPoolTokenAmount", - "type": "i128" + "name": "out_if_total_shares_before", + "type": "u128" }, { - "name": "lastExchangeFees", + "name": "in_if_user_shares_before", "type": "u128" }, { - "name": "lastSettleAmmExFees", + "name": "out_if_user_shares_before", "type": "u128" }, { - "name": "lastSettleAmmPnl", - "type": "i128" + "name": "in_if_total_shares_after", + "type": "u128" }, { - "name": "position", - "docs": [ - "BASE PRECISION" - ], - "type": "i64" + "name": "out_if_total_shares_after", + "type": "u128" }, { - "name": "slot", - "type": "u64" + "name": "in_if_user_shares_after", + "type": "u128" }, { - "name": "lastSettleAmount", - "type": "u64" + "name": "out_if_user_shares_after", + "type": "u128" }, { - "name": "lastSettleSlot", - "type": "u64" + "name": "ts", + "type": "i64" }, { - "name": "lastSettleTs", - "type": "i64" + "name": "in_amount", + "type": "u64" }, { - "name": "quoteOwedFromLpPool", - "type": "i64" + "name": "out_amount", + "type": "u64" }, { - "name": "ammInventoryLimit", - "type": "i64" + "name": "out_oracle_price", + "type": "u64" }, { - "name": "oraclePrice", + "name": "out_oracle_price_twap", "type": "i64" }, { - "name": "oracleSlot", + "name": "in_vault_amount_before", "type": "u64" }, { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "oracleSource", - "type": "u8" + "name": "out_vault_amount_before", + "type": "u64" }, { - "name": "oracleValidity", - "type": "u8" + "name": "in_fund_vault_amount_after", + "type": "u64" }, { - "name": "lpStatusForPerpMarket", - "type": "u8" + "name": "out_fund_vault_amount_after", + "type": "u64" }, { - "name": "ammPositionScalar", - "type": "u8" + "name": "in_market_index", + "type": "u16" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 34 - ] - } + "name": "out_market_index", + "type": "u16" } ] } }, { - "name": "AmmCacheFixed", + "name": "LPAction", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "bump", - "type": "u8" + "name": "AddLiquidity" }, { - "name": "pad", - "type": { - "array": [ - "u8", - 3 - ] - } + "name": "RemoveLiquidity" }, { - "name": "len", - "type": "u32" + "name": "SettleLiquidity" + }, + { + "name": "RemoveLiquidityDerisk" } ] } }, { - "name": "LiquidatePerpRecord", + "name": "LPBorrowLendDepositRecord", "type": { "kind": "struct", "fields": [ { - "name": "marketIndex", - "type": "u16" + "name": "ts", + "type": "i64" }, { - "name": "oraclePrice", - "type": "i64" + "name": "slot", + "type": "u64" }, { - "name": "baseAssetAmount", - "type": "i64" + "name": "spot_market_index", + "type": "u16" }, { - "name": "quoteAssetAmount", - "type": "i64" + "name": "constituent_index", + "type": "u16" }, { - "name": "lpShares", - "docs": [ - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u64" + "name": "direction", + "type": { + "defined": { + "name": "DepositDirection" + } + } }, { - "name": "fillRecordId", - "type": "u64" + "name": "token_balance", + "type": "i64" }, { - "name": "userOrderId", - "type": "u32" + "name": "last_token_balance", + "type": "i64" }, { - "name": "liquidatorOrderId", - "type": "u32" + "name": "interest_accrued_token_amount", + "type": "i64" }, { - "name": "liquidatorFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], + "name": "amount_deposit_withdraw", "type": "u64" }, { - "name": "ifFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "lp_pool", + "type": "pubkey" } ] } }, { - "name": "LiquidateSpotRecord", + "name": "LPMintRedeemRecord", "type": { "kind": "struct", "fields": [ { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "assetPrice", + "name": "ts", "type": "i64" }, { - "name": "assetTransfer", - "type": "u128" + "name": "slot", + "type": "u64" }, { - "name": "liabilityMarketIndex", - "type": "u16" + "name": "authority", + "type": "pubkey" }, { - "name": "liabilityPrice", - "type": "i64" + "name": "description", + "type": "u8" }, { - "name": "liabilityTransfer", + "name": "amount", "docs": [ - "precision: token mint precision" + "precision: continutent mint precision, gross fees" ], "type": "u128" }, { - "name": "ifFee", + "name": "fee", "docs": [ - "precision: token mint precision" + "precision: fee on amount, constituent market mint precision" ], - "type": "u64" - } - ] - } - }, - { - "name": "LiquidateBorrowForPerpPnlRecord", - "type": { - "kind": "struct", - "fields": [ + "type": "i128" + }, + { + "name": "spot_market_index", + "type": "u16" + }, { - "name": "perpMarketIndex", + "name": "constituent_index", "type": "u16" }, { - "name": "marketOraclePrice", + "name": "oracle_price", + "docs": [ + "precision: PRICE_PRECISION" + ], "type": "i64" }, { - "name": "pnlTransfer", - "type": "u128" + "name": "mint", + "docs": [ + "token mint" + ], + "type": "pubkey" }, { - "name": "liabilityMarketIndex", - "type": "u16" + "name": "lp_amount", + "docs": [ + "lp amount, lp mint precision" + ], + "type": "u64" }, { - "name": "liabilityPrice", + "name": "lp_fee", + "docs": [ + "lp fee, lp mint precision" + ], "type": "i64" }, { - "name": "liabilityTransfer", + "name": "lp_price", + "docs": [ + "the fair price of the lp token, PRICE_PRECISION" + ], "type": "u128" - } - ] - } - }, - { - "name": "LiquidatePerpPnlForDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" }, { - "name": "marketOraclePrice", - "type": "i64" + "name": "mint_redeem_id", + "type": "u64" }, { - "name": "pnlTransfer", + "name": "last_aum", + "docs": [ + "LPPool last_aum" + ], "type": "u128" }, { - "name": "assetMarketIndex", - "type": "u16" + "name": "last_aum_slot", + "type": "u64" }, { - "name": "assetPrice", + "name": "in_market_current_weight", + "docs": [ + "PERCENTAGE_PRECISION" + ], "type": "i64" }, { - "name": "assetTransfer", - "type": "u128" + "name": "in_market_target_weight", + "type": "i64" + }, + { + "name": "lp_pool", + "type": "pubkey" } ] } }, { - "name": "PerpBankruptcyRecord", + "name": "LPPool", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "marketIndex", - "type": "u16" + "name": "pubkey", + "docs": [ + "address of the vault." + ], + "type": "pubkey" }, { - "name": "pnl", - "type": "i128" + "name": "mint", + "type": "pubkey" }, { - "name": "ifPayment", - "type": "u128" + "name": "whitelist_mint", + "type": "pubkey" + }, + { + "name": "constituent_target_base", + "type": "pubkey" }, { - "name": "clawbackUser", + "name": "constituent_correlations", + "type": "pubkey" + }, + { + "name": "max_aum", + "docs": [ + "The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)", + "which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)", + "pub quote_constituent_index: u16,", + "QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this" + ], "type": { - "option": "publicKey" + "defined": { + "name": "u128" + } } }, { - "name": "clawbackUserPayment", + "name": "last_aum", + "docs": [ + "QUOTE_PRECISION: AUM of the vault in USD, updated lazily" + ], "type": { - "option": "u128" + "defined": { + "name": "u128" + } } }, { - "name": "cumulativeFundingRateDelta", - "type": "i128" - } - ] - } - }, - { - "name": "SpotBankruptcyRecord", - "type": { - "kind": "struct", - "fields": [ + "name": "cumulative_quote_sent_to_perp_markets", + "docs": [ + "QUOTE PRECISION: Cumulative quotes from settles" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, { - "name": "marketIndex", - "type": "u16" + "name": "cumulative_quote_received_from_perp_markets", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "borrowAmount", - "type": "u128" + "name": "total_mint_redeem_fees_paid", + "docs": [ + "QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens" + ], + "type": { + "defined": { + "name": "i128" + } + } }, { - "name": "ifPayment", - "type": "u128" + "name": "last_aum_slot", + "docs": [ + "timestamp of last AUM slot" + ], + "type": "u64" }, { - "name": "cumulativeDepositInterestDelta", - "type": "u128" - } - ] - } - }, - { - "name": "IfRebalanceConfigParams", - "type": { - "kind": "struct", - "fields": [ + "name": "max_settle_quote_amount", + "type": "u64" + }, + { + "name": "_padding", + "docs": [ + "timestamp of last vAMM revenue rebalance" + ], + "type": "u64" + }, { - "name": "totalInAmount", + "name": "mint_redeem_id", + "docs": [ + "Every mint/redeem has a monotonically increasing id. This is the next id to use" + ], "type": "u64" }, { - "name": "epochMaxInAmount", + "name": "settle_id", "type": "u64" }, { - "name": "epochDuration", + "name": "min_mint_fee", + "docs": [ + "PERCENTAGE_PRECISION" + ], "type": "i64" }, { - "name": "outMarketIndex", - "type": "u16" + "name": "token_supply", + "type": "u64" + }, + { + "name": "volatility", + "type": "u64" }, { - "name": "inMarketIndex", + "name": "constituents", "type": "u16" }, { - "name": "maxSlippageBps", + "name": "quote_consituent_index", "type": "u16" }, { - "name": "swapMode", + "name": "bump", "type": "u8" }, { - "name": "status", + "name": "gamma_execution", "type": "u8" - } - ] - } - }, - { - "name": "ConstituentSpotBalance", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "scaledBalance", - "docs": [ - "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", - "interest of corresponding market.", - "precision: token precision" - ], - "type": "u128" + "name": "xi", + "type": "u8" }, { - "name": "cumulativeDeposits", - "docs": [ - "The cumulative deposits/borrows a user has made into a market", - "precision: token mint precision" - ], - "type": "i64" + "name": "target_oracle_delay_fee_bps_per_10_slots", + "type": "u8" }, { - "name": "marketIndex", - "docs": [ - "The market index of the corresponding spot market" - ], - "type": "u16" + "name": "target_position_delay_fee_bps_per_10_slots", + "type": "u8" }, { - "name": "balanceType", - "docs": [ - "Whether the position is deposit or borrow" - ], - "type": { - "defined": "SpotBalanceType" - } + "name": "lp_pool_id", + "type": "u8" }, { "name": "padding", "type": { "array": [ "u8", - 5 + 174 ] } } @@ -12416,35 +19136,56 @@ } }, { - "name": "AmmConstituentDatum", + "name": "LPRecord", "type": { "kind": "struct", "fields": [ { - "name": "perpMarketIndex", - "type": "u16" + "name": "ts", + "type": "i64" }, { - "name": "constituentIndex", - "type": "u16" + "name": "user", + "type": "pubkey" }, { - "name": "padding", + "name": "action", "type": { - "array": [ - "u8", - 4 - ] + "defined": { + "name": "LPAction" + } } }, { - "name": "lastSlot", + "name": "n_shares", + "docs": [ + "precision: AMM_RESERVE_PRECISION" + ], "type": "u64" }, { - "name": "weight", + "name": "market_index", + "type": "u16" + }, + { + "name": "delta_base_asset_amount", "docs": [ - "PERCENTAGE_PRECISION. The weight this constituent has on the perp market" + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "delta_quote_asset_amount", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "pnl", + "docs": [ + "realized pnl of the position settlement", + "precision: QUOTE_PRECISION" ], "type": "i64" } @@ -12452,518 +19193,587 @@ } }, { - "name": "AmmConstituentMappingFixed", + "name": "LPSettleRecord", "type": { "kind": "struct", "fields": [ { - "name": "lpPool", - "type": "publicKey" + "name": "record_id", + "type": "u64" }, { - "name": "bump", - "type": "u8" + "name": "last_ts", + "type": "i64" }, { - "name": "pad", - "type": { - "array": [ - "u8", - 3 - ] - } + "name": "last_slot", + "type": "u64" }, { - "name": "len", - "type": "u32" - } - ] - } - }, - { - "name": "TargetsDatum", - "type": { - "kind": "struct", - "fields": [ + "name": "ts", + "type": "i64" + }, { - "name": "costToTradeBps", - "type": "i32" + "name": "slot", + "type": "u64" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } + "name": "perp_market_index", + "type": "u16" }, { - "name": "targetBase", + "name": "settle_to_lp_amount", "type": "i64" }, { - "name": "lastOracleSlot", - "type": "u64" + "name": "perp_amm_pnl_delta", + "type": "i64" }, { - "name": "lastPositionSlot", - "type": "u64" + "name": "perp_amm_ex_fee_delta", + "type": "i64" + }, + { + "name": "lp_aum", + "type": "u128" + }, + { + "name": "lp_price", + "type": "u128" + }, + { + "name": "lp_pool", + "type": "pubkey" } ] } }, { - "name": "ConstituentTargetBaseFixed", + "name": "LPSwapRecord", "type": { "kind": "struct", "fields": [ { - "name": "lpPool", - "type": "publicKey" + "name": "ts", + "type": "i64" }, { - "name": "bump", - "type": "u8" + "name": "slot", + "type": "u64" }, { - "name": "pad", - "type": { - "array": [ - "u8", - 3 - ] - } + "name": "authority", + "type": "pubkey" }, { - "name": "len", + "name": "out_amount", "docs": [ - "total elements in the flattened `data` vec" + "precision: out market mint precision, gross fees" ], - "type": "u32" - } - ] - } - }, - { - "name": "ConstituentCorrelationsFixed", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lpPool", - "type": "publicKey" + "type": "u128" }, { - "name": "bump", - "type": "u8" + "name": "in_amount", + "docs": [ + "precision: in market mint precision, gross fees" + ], + "type": "u128" }, { - "name": "pad", - "type": { - "array": [ - "u8", - 3 - ] - } + "name": "out_fee", + "docs": [ + "precision: fee on amount_out, in market mint precision" + ], + "type": "i128" }, { - "name": "len", + "name": "in_fee", "docs": [ - "total elements in the flattened `data` vec" + "precision: fee on amount_in, out market mint precision" ], - "type": "u32" - } - ] - } - }, - { - "name": "MarketIdentifier", - "type": { - "kind": "struct", - "fields": [ + "type": "i128" + }, { - "name": "marketType", - "type": { - "defined": "MarketType" - } + "name": "out_spot_market_index", + "type": "u16" }, { - "name": "marketIndex", + "name": "in_spot_market_index", "type": "u16" - } - ] - } - }, - { - "name": "HistoricalOracleData", - "type": { - "kind": "struct", - "fields": [ + }, + { + "name": "out_constituent_index", + "type": "u16" + }, + { + "name": "in_constituent_index", + "type": "u16" + }, { - "name": "lastOraclePrice", + "name": "out_oracle_price", "docs": [ "precision: PRICE_PRECISION" ], "type": "i64" }, { - "name": "lastOracleConf", + "name": "in_oracle_price", "docs": [ "precision: PRICE_PRECISION" ], + "type": "i64" + }, + { + "name": "last_aum", + "docs": [ + "LPPool last_aum, QUOTE_PRECISION" + ], + "type": "u128" + }, + { + "name": "last_aum_slot", "type": "u64" }, { - "name": "lastOracleDelay", + "name": "in_market_current_weight", "docs": [ - "number of slots since last update" + "PERCENTAGE_PRECISION" ], "type": "i64" }, { - "name": "lastOraclePriceTwap", + "name": "out_market_current_weight", "docs": [ - "precision: PRICE_PRECISION" + "PERCENTAGE_PRECISION" ], "type": "i64" }, { - "name": "lastOraclePriceTwap5min", + "name": "in_market_target_weight", "docs": [ - "precision: PRICE_PRECISION" + "PERCENTAGE_PRECISION" ], "type": "i64" }, { - "name": "lastOraclePriceTwapTs", + "name": "out_market_target_weight", "docs": [ - "unix_timestamp of last snapshot" + "PERCENTAGE_PRECISION" ], "type": "i64" + }, + { + "name": "in_swap_id", + "type": "u64" + }, + { + "name": "out_swap_id", + "type": "u64" + }, + { + "name": "lp_pool", + "type": "pubkey" } ] } }, { - "name": "HistoricalIndexData", + "name": "LiquidateBorrowForPerpPnlRecord", "type": { "kind": "struct", "fields": [ { - "name": "lastIndexBidPrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "perp_market_index", + "type": "u16" }, { - "name": "lastIndexAskPrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "market_oracle_price", + "type": "i64" }, { - "name": "lastIndexPriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "pnl_transfer", + "type": "u128" }, { - "name": "lastIndexPriceTwap5min", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "liability_market_index", + "type": "u16" }, { - "name": "lastIndexPriceTwapTs", - "docs": [ - "unix_timestamp of last snapshot" - ], + "name": "liability_price", "type": "i64" + }, + { + "name": "liability_transfer", + "type": "u128" } ] } }, { - "name": "PrelaunchOracleParams", + "name": "LiquidatePerpPnlForDepositRecord", "type": { "kind": "struct", "fields": [ { - "name": "perpMarketIndex", + "name": "perp_market_index", "type": "u16" }, { - "name": "price", - "type": { - "option": "i64" - } + "name": "market_oracle_price", + "type": "i64" }, { - "name": "maxPrice", - "type": { - "option": "i64" - } + "name": "pnl_transfer", + "type": "u128" + }, + { + "name": "asset_market_index", + "type": "u16" + }, + { + "name": "asset_price", + "type": "i64" + }, + { + "name": "asset_transfer", + "type": "u128" } ] } }, { - "name": "OrderParams", + "name": "LiquidatePerpRecord", "type": { "kind": "struct", "fields": [ { - "name": "orderType", - "type": { - "defined": "OrderType" - } + "name": "market_index", + "type": "u16" }, { - "name": "marketType", - "type": { - "defined": "MarketType" - } + "name": "oracle_price", + "type": "i64" }, { - "name": "direction", - "type": { - "defined": "PositionDirection" - } + "name": "base_asset_amount", + "type": "i64" }, { - "name": "userOrderId", - "type": "u8" + "name": "quote_asset_amount", + "type": "i64" }, { - "name": "baseAssetAmount", + "name": "lp_shares", + "docs": [ + "precision: AMM_RESERVE_PRECISION" + ], "type": "u64" }, { - "name": "price", + "name": "fill_record_id", "type": "u64" }, { - "name": "marketIndex", - "type": "u16" + "name": "user_order_id", + "type": "u32" }, { - "name": "reduceOnly", - "type": "bool" + "name": "liquidator_order_id", + "type": "u32" }, { - "name": "postOnly", - "type": { - "defined": "PostOnlyParam" - } + "name": "liquidator_fee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" }, { - "name": "bitFlags", - "type": "u8" + "name": "if_fee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + } + ] + } + }, + { + "name": "LiquidateSpotRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "asset_market_index", + "type": "u16" }, { - "name": "maxTs", - "type": { - "option": "i64" - } - }, - { - "name": "triggerPrice", - "type": { - "option": "u64" - } + "name": "asset_price", + "type": "i64" }, { - "name": "triggerCondition", - "type": { - "defined": "OrderTriggerCondition" - } + "name": "asset_transfer", + "type": "u128" }, { - "name": "oraclePriceOffset", - "type": { - "option": "i32" - } + "name": "liability_market_index", + "type": "u16" }, { - "name": "auctionDuration", - "type": { - "option": "u8" - } + "name": "liability_price", + "type": "i64" }, { - "name": "auctionStartPrice", - "type": { - "option": "i64" - } + "name": "liability_transfer", + "docs": [ + "precision: token mint precision" + ], + "type": "u128" }, { - "name": "auctionEndPrice", - "type": { - "option": "i64" - } + "name": "if_fee", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" } ] } }, { - "name": "SignedMsgOrderParamsMessage", + "name": "LiquidationRecord", "type": { "kind": "struct", "fields": [ { - "name": "signedMsgOrderParams", + "name": "ts", + "type": "i64" + }, + { + "name": "liquidation_type", "type": { - "defined": "OrderParams" + "defined": { + "name": "LiquidationType" + } } }, { - "name": "subAccountId", - "type": "u16" + "name": "user", + "type": "pubkey" }, { - "name": "slot", + "name": "liquidator", + "type": "pubkey" + }, + { + "name": "margin_requirement", + "type": "u128" + }, + { + "name": "total_collateral", + "type": "i128" + }, + { + "name": "margin_freed", "type": "u64" }, { - "name": "uuid", + "name": "liquidation_id", + "type": "u16" + }, + { + "name": "bankrupt", + "type": "bool" + }, + { + "name": "canceled_order_ids", "type": { - "array": [ - "u8", - 8 - ] + "vec": "u32" } }, { - "name": "takeProfitOrderParams", + "name": "liquidate_perp", "type": { - "option": { - "defined": "SignedMsgTriggerOrderParams" + "defined": { + "name": "LiquidatePerpRecord" } } }, { - "name": "stopLossOrderParams", + "name": "liquidate_spot", "type": { - "option": { - "defined": "SignedMsgTriggerOrderParams" + "defined": { + "name": "LiquidateSpotRecord" } } }, { - "name": "maxMarginRatio", + "name": "liquidate_borrow_for_perp_pnl", "type": { - "option": "u16" + "defined": { + "name": "LiquidateBorrowForPerpPnlRecord" + } } }, { - "name": "builderIdx", + "name": "liquidate_perp_pnl_for_deposit", "type": { - "option": "u8" + "defined": { + "name": "LiquidatePerpPnlForDepositRecord" + } } }, { - "name": "builderFeeTenthBps", + "name": "perp_bankruptcy", "type": { - "option": "u16" + "defined": { + "name": "PerpBankruptcyRecord" + } } }, { - "name": "isolatedPositionDeposit", + "name": "spot_bankruptcy", "type": { - "option": "u64" + "defined": { + "name": "SpotBankruptcyRecord" + } } } ] } }, { - "name": "SignedMsgOrderParamsDelegateMessage", + "name": "LiquidationType", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "signedMsgOrderParams", - "type": { - "defined": "OrderParams" - } + "name": "LiquidatePerp" }, { - "name": "takerPubkey", - "type": "publicKey" + "name": "LiquidateSpot" }, { - "name": "slot", - "type": "u64" + "name": "LiquidateBorrowForPerpPnl" }, { - "name": "uuid", - "type": { - "array": [ - "u8", - 8 - ] - } + "name": "LiquidatePerpPnlForDeposit" + }, + { + "name": "PerpBankruptcy" }, { - "name": "takeProfitOrderParams", + "name": "SpotBankruptcy" + } + ] + } + }, + { + "name": "LpPoolParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "max_settle_quote_amount", "type": { - "option": { - "defined": "SignedMsgTriggerOrderParams" - } + "option": "u64" } }, { - "name": "stopLossOrderParams", + "name": "volatility", "type": { - "option": { - "defined": "SignedMsgTriggerOrderParams" - } + "option": "u64" } }, { - "name": "maxMarginRatio", + "name": "gamma_execution", "type": { - "option": "u16" + "option": "u8" } }, { - "name": "builderIdx", + "name": "xi", "type": { "option": "u8" } }, { - "name": "builderFeeTenthBps", + "name": "max_aum", "type": { - "option": "u16" + "option": "u128" } }, { - "name": "isolatedPositionDeposit", + "name": "whitelist_mint", "type": { - "option": "u64" + "option": "pubkey" } } ] } }, { - "name": "SignedMsgTriggerOrderParams", + "name": "MarginMode", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "triggerPrice", - "type": "u64" + "name": "Default" }, { - "name": "baseAssetAmount", - "type": "u64" + "name": "HighLeverage" + }, + { + "name": "HighLeverageMaintenance" + } + ] + } + }, + { + "name": "MarketStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Initialized" + }, + { + "name": "Active" + }, + { + "name": "FundingPaused" + }, + { + "name": "AmmPaused" + }, + { + "name": "FillPaused" + }, + { + "name": "WithdrawPaused" + }, + { + "name": "ReduceOnly" + }, + { + "name": "Settlement" + }, + { + "name": "Delisted" + } + ] + } + }, + { + "name": "MarketType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Spot" + }, + { + "name": "Perp" } ] } @@ -12977,12 +19787,14 @@ "name": "direction", "type": { "option": { - "defined": "PositionDirection" + "defined": { + "name": "PositionDirection" + } } } }, { - "name": "baseAssetAmount", + "name": "base_asset_amount", "type": { "option": "u64" } @@ -12994,65 +19806,69 @@ } }, { - "name": "reduceOnly", + "name": "reduce_only", "type": { "option": "bool" } }, { - "name": "postOnly", + "name": "post_only", "type": { "option": { - "defined": "PostOnlyParam" + "defined": { + "name": "PostOnlyParam" + } } } }, { - "name": "bitFlags", + "name": "bit_flags", "type": { "option": "u8" } }, { - "name": "maxTs", + "name": "max_ts", "type": { "option": "i64" } }, { - "name": "triggerPrice", + "name": "trigger_price", "type": { "option": "u64" } }, { - "name": "triggerCondition", + "name": "trigger_condition", "type": { "option": { - "defined": "OrderTriggerCondition" + "defined": { + "name": "OrderTriggerCondition" + } } } }, { - "name": "oraclePriceOffset", + "name": "oracle_price_offset", "type": { "option": "i32" } }, { - "name": "auctionDuration", + "name": "auction_duration", "type": { "option": "u8" } }, { - "name": "auctionStartPrice", + "name": "auction_start_price", "type": { "option": "i64" } }, { - "name": "auctionEndPrice", + "name": "auction_end_price", "type": { "option": "i64" } @@ -13067,81 +19883,116 @@ } }, { - "name": "InsuranceClaim", + "name": "NewUserRecord", "type": { "kind": "struct", "fields": [ { - "name": "revenueWithdrawSinceLastSettle", + "name": "ts", "docs": [ - "The amount of revenue last settled", - "Positive if funds left the perp market,", - "negative if funds were pulled into the perp market", - "precision: QUOTE_PRECISION" + "unix_timestamp of action" ], "type": "i64" }, { - "name": "maxRevenueWithdrawPerPeriod", - "docs": [ - "The max amount of revenue that can be withdrawn per period", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "user_authority", + "type": "pubkey" }, { - "name": "quoteMaxInsurance", - "docs": [ - "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "user", + "type": "pubkey" }, { - "name": "quoteSettledInsurance", - "docs": [ - "The amount of insurance that has been used to resolve bankruptcy and pnl deficits", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "sub_account_id", + "type": "u16" }, { - "name": "lastRevenueWithdrawTs", - "docs": [ - "The last time revenue was settled in/out of market" - ], - "type": "i64" + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "referrer", + "type": "pubkey" } ] } }, { - "name": "PoolBalance", + "name": "OpenbookV2FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "scaledBalance", - "docs": [ - "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", - "deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" + "name": "pubkey", + "type": "pubkey" }, { - "name": "marketIndex", - "docs": [ - "The spot market the pool is for" - ], + "name": "openbook_v2_program_id", + "type": "pubkey" + }, + { + "name": "openbook_v2_market", + "type": "pubkey" + }, + { + "name": "openbook_v2_market_authority", + "type": "pubkey" + }, + { + "name": "openbook_v2_event_heap", + "type": "pubkey" + }, + { + "name": "openbook_v2_bids", + "type": "pubkey" + }, + { + "name": "openbook_v2_asks", + "type": "pubkey" + }, + { + "name": "openbook_v2_base_vault", + "type": "pubkey" + }, + { + "name": "openbook_v2_quote_vault", + "type": "pubkey" + }, + { + "name": "market_index", "type": "u16" }, + { + "name": "fulfillment_type", + "type": { + "defined": { + "name": "SpotFulfillmentType" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "SpotFulfillmentConfigStatus" + } + } + }, { "name": "padding", "type": { "array": [ "u8", - 6 + 4 ] } } @@ -13149,1991 +20000,2147 @@ } }, { - "name": "AMM", + "name": "OracleGuardRails", "type": { "kind": "struct", "fields": [ { - "name": "oracle", - "docs": [ - "oracle price data public key" - ], - "type": "publicKey" + "name": "price_divergence", + "type": { + "defined": { + "name": "PriceDivergenceGuardRails" + } + } }, { - "name": "historicalOracleData", - "docs": [ - "stores historically witnessed oracle data" - ], + "name": "validity", "type": { - "defined": "HistoricalOracleData" + "defined": { + "name": "ValidityGuardRails" + } } - }, + } + ] + } + }, + { + "name": "OracleSource", + "type": { + "kind": "enum", + "variants": [ { - "name": "baseAssetAmountPerLp", - "docs": [ - "accumulated base asset amount since inception per lp share", - "precision: QUOTE_PRECISION" - ], - "type": "i128" + "name": "Pyth" }, { - "name": "quoteAssetAmountPerLp", - "docs": [ - "accumulated quote asset amount since inception per lp share", - "precision: QUOTE_PRECISION" - ], - "type": "i128" + "name": "Switchboard" }, { - "name": "feePool", - "docs": [ - "partition of fees from perp market trading moved from pnl settlements" - ], - "type": { - "defined": "PoolBalance" - } + "name": "QuoteAsset" }, { - "name": "baseAssetReserve", - "docs": [ - "`x` reserves for constant product mm formula (x * y = k)", - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u128" + "name": "Pyth1K" }, { - "name": "quoteAssetReserve", - "docs": [ - "`y` reserves for constant product mm formula (x * y = k)", - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u128" + "name": "Pyth1M" }, { - "name": "concentrationCoef", - "docs": [ - "determines how close the min/max base asset reserve sit vs base reserves", - "allow for decreasing slippage without increasing liquidity and v.v.", - "precision: PERCENTAGE_PRECISION" - ], - "type": "u128" + "name": "PythStableCoin" }, { - "name": "minBaseAssetReserve", - "docs": [ - "minimum base_asset_reserve allowed before AMM is unavailable", - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u128" + "name": "Prelaunch" }, { - "name": "maxBaseAssetReserve", - "docs": [ - "maximum base_asset_reserve allowed before AMM is unavailable", - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u128" + "name": "PythPull" }, { - "name": "sqrtK", - "docs": [ - "`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues", - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u128" + "name": "Pyth1KPull" }, { - "name": "pegMultiplier", - "docs": [ - "normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced", - "precision: PEG_PRECISION" - ], - "type": "u128" + "name": "Pyth1MPull" }, { - "name": "terminalQuoteAssetReserve", - "docs": [ - "y when market is balanced. stored to save computation", - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u128" + "name": "PythStableCoinPull" }, { - "name": "baseAssetAmountLong", - "docs": [ - "always non-negative. tracks number of total longs in market (regardless of counterparty)", - "precision: BASE_PRECISION" - ], - "type": "i128" + "name": "SwitchboardOnDemand" }, { - "name": "baseAssetAmountShort", - "docs": [ - "always non-positive. tracks number of total shorts in market (regardless of counterparty)", - "precision: BASE_PRECISION" - ], - "type": "i128" + "name": "PythLazer" }, { - "name": "baseAssetAmountWithAmm", - "docs": [ - "tracks net position (longs-shorts) in market with AMM as counterparty", - "precision: BASE_PRECISION" - ], - "type": "i128" + "name": "PythLazer1K" }, { - "name": "baseAssetAmountWithUnsettledLp", - "docs": [ - "tracks net position (longs-shorts) in market with LPs as counterparty", - "precision: BASE_PRECISION" - ], - "type": "i128" + "name": "PythLazer1M" }, { - "name": "maxOpenInterest", - "docs": [ - "max allowed open interest, blocks trades that breach this value", - "precision: BASE_PRECISION" - ], - "type": "u128" - }, + "name": "PythLazerStableCoin" + } + ] + } + }, + { + "name": "Order", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "quoteAssetAmount", + "name": "slot", "docs": [ - "sum of all user's perp quote_asset_amount in market", - "precision: QUOTE_PRECISION" + "The slot the order was placed" ], - "type": "i128" + "type": "u64" }, { - "name": "quoteEntryAmountLong", + "name": "price", "docs": [ - "sum of all long user's quote_entry_amount in market", - "precision: QUOTE_PRECISION" + "The limit price for the order (can be 0 for market orders)", + "For orders with an auction, this price isn't used until the auction is complete", + "precision: PRICE_PRECISION" ], - "type": "i128" + "type": "u64" }, { - "name": "quoteEntryAmountShort", + "name": "base_asset_amount", "docs": [ - "sum of all short user's quote_entry_amount in market", - "precision: QUOTE_PRECISION" + "The size of the order", + "precision for perps: BASE_PRECISION", + "precision for spot: token mint precision" ], - "type": "i128" + "type": "u64" }, { - "name": "quoteBreakEvenAmountLong", + "name": "base_asset_amount_filled", "docs": [ - "sum of all long user's quote_break_even_amount in market", - "precision: QUOTE_PRECISION" + "The amount of the order filled", + "precision for perps: BASE_PRECISION", + "precision for spot: token mint precision" ], - "type": "i128" + "type": "u64" }, { - "name": "quoteBreakEvenAmountShort", + "name": "quote_asset_amount_filled", "docs": [ - "sum of all short user's quote_break_even_amount in market", + "The amount of quote filled for the order", "precision: QUOTE_PRECISION" ], - "type": "i128" + "type": "u64" }, { - "name": "userLpShares", + "name": "trigger_price", "docs": [ - "total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)", - "precision: AMM_RESERVE_PRECISION" + "At what price the order will be triggered. Only relevant for trigger orders", + "precision: PRICE_PRECISION" ], - "type": "u128" + "type": "u64" }, { - "name": "lastFundingRate", + "name": "auction_start_price", "docs": [ - "last funding rate in this perp market (unit is quote per base)", - "precision: FUNDING_RATE_PRECISION" + "The start price for the auction. Only relevant for market/oracle orders", + "precision: PRICE_PRECISION" ], "type": "i64" }, { - "name": "lastFundingRateLong", + "name": "auction_end_price", "docs": [ - "last funding rate for longs in this perp market (unit is quote per base)", - "precision: FUNDING_RATE_PRECISION" + "The end price for the auction. Only relevant for market/oracle orders", + "precision: PRICE_PRECISION" ], "type": "i64" }, { - "name": "lastFundingRateShort", + "name": "max_ts", "docs": [ - "last funding rate for shorts in this perp market (unit is quote per base)", - "precision: QUOTE_PRECISION" + "The time when the order will expire" ], "type": "i64" }, { - "name": "last24hAvgFundingRate", + "name": "oracle_price_offset", "docs": [ - "estimate of last 24h of funding rate perp market (unit is quote per base)", - "precision: QUOTE_PRECISION" + "If set, the order limit price is the oracle price + this offset", + "precision: PRICE_PRECISION" ], - "type": "i64" + "type": "i32" }, { - "name": "totalFee", + "name": "order_id", "docs": [ - "total fees collected by this perp market", - "precision: QUOTE_PRECISION" + "The id for the order. Each users has their own order id space" ], - "type": "i128" + "type": "u32" }, { - "name": "totalMmFee", + "name": "market_index", "docs": [ - "total fees collected by the vAMM's bid/ask spread", - "precision: QUOTE_PRECISION" + "The perp/spot market index" ], - "type": "i128" + "type": "u16" }, { - "name": "totalExchangeFee", + "name": "status", "docs": [ - "total fees collected by exchange fee schedule", - "precision: QUOTE_PRECISION" + "Whether the order is open or unused" ], - "type": "u128" + "type": { + "defined": { + "name": "OrderStatus" + } + } }, { - "name": "totalFeeMinusDistributions", + "name": "order_type", "docs": [ - "total fees minus any recognized upnl and pool withdraws", - "precision: QUOTE_PRECISION" + "The type of order" ], - "type": "i128" + "type": { + "defined": { + "name": "OrderType" + } + } }, { - "name": "totalFeeWithdrawn", + "name": "market_type", "docs": [ - "sum of all fees from fee pool withdrawn to revenue pool", - "precision: QUOTE_PRECISION" + "Whether market is spot or perp" ], - "type": "u128" + "type": { + "defined": { + "name": "MarketType" + } + } }, { - "name": "totalLiquidationFee", + "name": "user_order_id", "docs": [ - "all fees collected by market for liquidations", - "precision: QUOTE_PRECISION" + "User generated order id. Can make it easier to place/cancel orders" ], - "type": "u128" + "type": "u8" }, { - "name": "cumulativeFundingRateLong", + "name": "existing_position_direction", "docs": [ - "accumulated funding rate for longs since inception in market" + "What the users position was when the order was placed" ], - "type": "i128" + "type": { + "defined": { + "name": "PositionDirection" + } + } }, { - "name": "cumulativeFundingRateShort", + "name": "direction", "docs": [ - "accumulated funding rate for shorts since inception in market" + "Whether the user is going long or short. LONG = bid, SHORT = ask" ], - "type": "i128" + "type": { + "defined": { + "name": "PositionDirection" + } + } }, { - "name": "totalSocialLoss", + "name": "reduce_only", "docs": [ - "accumulated social loss paid by users since inception in market" + "Whether the order is allowed to only reduce position size" ], - "type": "u128" + "type": "bool" }, { - "name": "askBaseAssetReserve", + "name": "post_only", "docs": [ - "transformed base_asset_reserve for users going long", - "precision: AMM_RESERVE_PRECISION" + "Whether the order must be a maker" ], - "type": "u128" + "type": "bool" }, { - "name": "askQuoteAssetReserve", + "name": "immediate_or_cancel", "docs": [ - "transformed quote_asset_reserve for users going long", - "precision: AMM_RESERVE_PRECISION" + "Whether the order must be canceled the same slot it is placed" ], - "type": "u128" + "type": "bool" }, { - "name": "bidBaseAssetReserve", + "name": "trigger_condition", "docs": [ - "transformed base_asset_reserve for users going short", - "precision: AMM_RESERVE_PRECISION" + "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders" ], - "type": "u128" + "type": { + "defined": { + "name": "OrderTriggerCondition" + } + } }, { - "name": "bidQuoteAssetReserve", + "name": "auction_duration", "docs": [ - "transformed quote_asset_reserve for users going short", - "precision: AMM_RESERVE_PRECISION" + "How many slots the auction lasts" ], - "type": "u128" + "type": "u8" }, { - "name": "lastOracleNormalisedPrice", + "name": "posted_slot_tail", "docs": [ - "the last seen oracle price partially shrunk toward the amm reserve price", - "precision: PRICE_PRECISION" + "Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)" ], - "type": "i64" + "type": "u8" }, { - "name": "lastOracleReservePriceSpreadPct", + "name": "bit_flags", "docs": [ - "the gap between the oracle price and the reserve price = y * peg_multiplier / x" + "Bitflags for further classification", + "0: is_signed_message" ], - "type": "i64" + "type": "u8" }, { - "name": "lastBidPriceTwap", - "docs": [ - "average estimate of bid price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "padding", + "type": { + "array": [ + "u8", + 1 + ] + } + } + ] + } + }, + { + "name": "OrderAction", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Place" }, { - "name": "lastAskPriceTwap", - "docs": [ - "average estimate of ask price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "Cancel" }, { - "name": "lastMarkPriceTwap", - "docs": [ - "average estimate of (bid+ask)/2 price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "Fill" }, { - "name": "lastMarkPriceTwap5min", - "docs": [ - "average estimate of (bid+ask)/2 price over FIVE_MINUTES" - ], - "type": "u64" + "name": "Trigger" }, { - "name": "lastUpdateSlot", - "docs": [ - "the last blockchain slot the amm was updated" - ], - "type": "u64" + "name": "Expire" + } + ] + } + }, + { + "name": "OrderActionExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "None" }, { - "name": "lastOracleConfPct", - "docs": [ - "the pct size of the oracle confidence interval", - "precision: PERCENTAGE_PRECISION" - ], - "type": "u64" + "name": "InsufficientFreeCollateral" }, { - "name": "netRevenueSinceLastFunding", - "docs": [ - "the total_fee_minus_distribution change since the last funding update", - "precision: QUOTE_PRECISION" - ], - "type": "i64" + "name": "OraclePriceBreachedLimitPrice" }, { - "name": "lastFundingRateTs", - "docs": [ - "the last funding rate update unix_timestamp" - ], - "type": "i64" + "name": "MarketOrderFilledToLimitPrice" }, { - "name": "fundingPeriod", - "docs": [ - "the peridocity of the funding rate updates" - ], - "type": "i64" + "name": "OrderExpired" }, { - "name": "orderStepSize", - "docs": [ - "the base step size (increment) of orders", - "precision: BASE_PRECISION" - ], - "type": "u64" + "name": "Liquidation" }, { - "name": "orderTickSize", - "docs": [ - "the price tick size of orders", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "OrderFilledWithAMM" }, { - "name": "minOrderSize", - "docs": [ - "the minimum base size of an order", - "precision: BASE_PRECISION" - ], - "type": "u64" + "name": "OrderFilledWithAMMJit" }, { - "name": "mmOracleSlot", - "docs": [ - "the max base size a single user can have", - "precision: BASE_PRECISION" - ], - "type": "u64" + "name": "OrderFilledWithMatch" }, { - "name": "volume24h", - "docs": [ - "estimated total of volume in market", - "QUOTE_PRECISION" - ], - "type": "u64" + "name": "OrderFilledWithMatchJit" }, { - "name": "longIntensityVolume", - "docs": [ - "the volume intensity of long fills against AMM" - ], - "type": "u64" + "name": "MarketExpired" }, { - "name": "shortIntensityVolume", - "docs": [ - "the volume intensity of short fills against AMM" - ], - "type": "u64" + "name": "RiskingIncreasingOrder" }, { - "name": "lastTradeTs", - "docs": [ - "the blockchain unix timestamp at the time of the last trade" - ], - "type": "i64" + "name": "ReduceOnlyOrderIncreasedPosition" }, { - "name": "markStd", - "docs": [ - "estimate of standard deviation of the fill (mark) prices", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "OrderFillWithSerum" }, { - "name": "oracleStd", - "docs": [ - "estimate of standard deviation of the oracle price at each update", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "NoBorrowLiquidity" }, { - "name": "lastMarkPriceTwapTs", - "docs": [ - "the last unix_timestamp the mark twap was updated" - ], - "type": "i64" + "name": "OrderFillWithPhoenix" }, { - "name": "baseSpread", - "docs": [ - "the minimum spread the AMM can quote. also used as step size for some spread logic increases." - ], - "type": "u32" + "name": "OrderFilledWithAMMJitLPSplit" }, { - "name": "maxSpread", - "docs": [ - "the maximum spread the AMM can quote" - ], - "type": "u32" + "name": "OrderFilledWithLPJit" }, { - "name": "longSpread", - "docs": [ - "the spread for asks vs the reserve price" - ], - "type": "u32" + "name": "DeriskLp" }, { - "name": "shortSpread", - "docs": [ - "the spread for bids vs the reserve price" - ], - "type": "u32" + "name": "OrderFilledWithOpenbookV2" }, { - "name": "mmOraclePrice", - "docs": [ - "MM oracle price" - ], + "name": "TransferPerpPosition" + } + ] + } + }, + { + "name": "OrderActionRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", "type": "i64" }, { - "name": "maxFillReserveFraction", - "docs": [ - "the fraction of total available liquidity a single fill on the AMM can consume" - ], - "type": "u16" + "name": "action", + "type": { + "defined": { + "name": "OrderAction" + } + } }, { - "name": "maxSlippageRatio", - "docs": [ - "the maximum slippage a single fill on the AMM can push" - ], + "name": "action_explanation", + "type": { + "defined": { + "name": "OrderActionExplanation" + } + } + }, + { + "name": "market_index", "type": "u16" }, { - "name": "curveUpdateIntensity", + "name": "market_type", + "type": { + "defined": { + "name": "MarketType" + } + } + }, + { + "name": "filler", + "type": { + "option": "pubkey" + } + }, + { + "name": "filler_reward", "docs": [ - "the update intensity of AMM formulaic updates (adjusting k). 0-100" + "precision: QUOTE_PRECISION" ], - "type": "u8" + "type": { + "option": "u64" + } + }, + { + "name": "fill_record_id", + "type": { + "option": "u64" + } }, { - "name": "ammJitIntensity", + "name": "base_asset_amount_filled", "docs": [ - "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.", - "(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM." + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" ], - "type": "u8" + "type": { + "option": "u64" + } }, { - "name": "oracleSource", + "name": "quote_asset_amount_filled", "docs": [ - "the oracle provider information. used to decode/scale the oracle public key" + "precision: QUOTE_PRECISION" ], "type": { - "defined": "OracleSource" + "option": "u64" } }, { - "name": "lastOracleValid", + "name": "taker_fee", "docs": [ - "tracks whether the oracle was considered valid at the last AMM update" + "precision: QUOTE_PRECISION" ], - "type": "bool" + "type": { + "option": "u64" + } }, { - "name": "targetBaseAssetAmountPerLp", + "name": "maker_fee", "docs": [ - "the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split", - "precision: BASE_PRECISION" + "precision: QUOTE_PRECISION" ], - "type": "i32" + "type": { + "option": "i64" + } }, { - "name": "perLpBase", + "name": "referrer_reward", "docs": [ - "expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)" + "precision: QUOTE_PRECISION" ], - "type": "i8" + "type": { + "option": "u32" + } }, { - "name": "oracleLowRiskSlotDelayOverride", + "name": "quote_asset_amount_surplus", "docs": [ - "the override for the state.min_perp_auction_duration", - "0 is no override, -1 is disable speed bump, 1-100 is literal speed bump" + "precision: QUOTE_PRECISION" ], - "type": "i8" + "type": { + "option": "i64" + } }, { - "name": "ammSpreadAdjustment", + "name": "spot_fulfillment_method_fee", "docs": [ - "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" + "precision: QUOTE_PRECISION" ], - "type": "i8" + "type": { + "option": "u64" + } }, { - "name": "oracleSlotDelayOverride", - "type": "i8" + "name": "taker", + "type": { + "option": "pubkey" + } }, { - "name": "mmOracleSequenceId", - "type": "u64" + "name": "taker_order_id", + "type": { + "option": "u32" + } }, { - "name": "netUnsettledFundingPnl", - "type": "i64" + "name": "taker_order_direction", + "type": { + "option": { + "defined": { + "name": "PositionDirection" + } + } + } }, { - "name": "quoteAssetAmountWithUnsettledLp", - "type": "i64" + "name": "taker_order_base_asset_amount", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } }, { - "name": "referencePriceOffset", - "type": "i32" + "name": "taker_order_cumulative_base_asset_amount_filled", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } }, { - "name": "ammInventorySpreadAdjustment", + "name": "taker_order_cumulative_quote_asset_amount_filled", "docs": [ - "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" + "precision: QUOTE_PRECISION" ], - "type": "i8" + "type": { + "option": "u64" + } }, { - "name": "referencePriceOffsetDeadbandPct", - "type": "u8" + "name": "maker", + "type": { + "option": "pubkey" + } }, { - "name": "padding", + "name": "maker_order_id", "type": { - "array": [ - "u8", - 2 - ] + "option": "u32" } }, { - "name": "lastFundingOracleTwap", - "type": "i64" - } - ] - } - }, - { - "name": "RevenueShareOrder", - "type": { - "kind": "struct", - "fields": [ + "name": "maker_order_direction", + "type": { + "option": { + "defined": { + "name": "PositionDirection" + } + } + } + }, { - "name": "feesAccrued", + "name": "maker_order_base_asset_amount", "docs": [ - "fees accrued so far for this order slot. This is not exclusively fees from this order_id", - "and may include fees from other orders in the same market. This may be swept to the", - "builder's SpotPosition during settle_pnl." + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" ], - "type": "u64" + "type": { + "option": "u64" + } }, { - "name": "orderId", + "name": "maker_order_cumulative_base_asset_amount_filled", "docs": [ - "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open" + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" ], - "type": "u32" + "type": { + "option": "u64" + } }, { - "name": "feeTenthBps", + "name": "maker_order_cumulative_quote_asset_amount_filled", "docs": [ - "the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%" + "precision: QUOTE_PRECISION" ], - "type": "u16" - }, - { - "name": "marketIndex", - "type": "u16" + "type": { + "option": "u64" + } }, { - "name": "subAccountId", + "name": "oracle_price", "docs": [ - "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open" + "precision: PRICE_PRECISION" ], - "type": "u16" + "type": "i64" }, { - "name": "builderIdx", + "name": "bit_flags", "docs": [ - "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", - "if bit_flag = Referral." + "Bit flags:", + "0: is_signed_message" ], "type": "u8" }, { - "name": "bitFlags", + "name": "taker_existing_quote_entry_amount", "docs": [ - "bitflags that describe the state of the order.", - "[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.", - "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", - "[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.", - "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", - "[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.", - "If it is set, no other bitflag should be set." + "precision: QUOTE_PRECISION", + "Only Some if the taker reduced position" ], - "type": "u8" + "type": { + "option": "u64" + } }, { - "name": "userOrderIndex", + "name": "taker_existing_base_asset_amount", "docs": [ - "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches." + "precision: BASE_PRECISION", + "Only Some if the taker flipped position direction" ], - "type": "u8" + "type": { + "option": "u64" + } }, { - "name": "marketType", + "name": "maker_existing_quote_entry_amount", + "docs": [ + "precision: QUOTE_PRECISION", + "Only Some if the maker reduced position" + ], "type": { - "defined": "MarketType" + "option": "u64" } }, { - "name": "padding", + "name": "maker_existing_base_asset_amount", + "docs": [ + "precision: BASE_PRECISION", + "Only Some if the maker flipped position direction" + ], "type": { - "array": [ - "u8", - 10 - ] + "option": "u64" } - } - ] - } - }, - { - "name": "BuilderInfo", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "authority", - "type": "publicKey" + "name": "trigger_price", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": { + "option": "u64" + } }, { - "name": "maxFeeTenthBps", - "type": "u16" + "name": "builder_idx", + "docs": [ + "the idx of the builder in the taker's [`RevenueShareEscrow`] account" + ], + "type": { + "option": "u8" + } }, { - "name": "padding", + "name": "builder_fee", + "docs": [ + "precision: QUOTE_PRECISION builder fee paid by the taker" + ], "type": { - "array": [ - "u8", - 6 - ] + "option": "u64" } } ] } }, { - "name": "RevenueShareEscrowFixed", + "name": "OrderFillerRewardStructure", "type": { "kind": "struct", "fields": [ { - "name": "authority", - "type": "publicKey" - }, - { - "name": "referrer", - "type": "publicKey" - }, - { - "name": "referrerBoostExpireTs", + "name": "reward_numerator", "type": "u32" }, { - "name": "referrerRewardOffset", - "type": "i8" - }, - { - "name": "refereeFeeNumeratorOffset", - "type": "i8" - }, - { - "name": "referrerBoostNumerator", - "type": "i8" + "name": "reward_denominator", + "type": "u32" }, { - "name": "reservedFixed", + "name": "time_based_reward_lower_bound", "type": { - "array": [ - "u8", - 17 - ] + "defined": { + "name": "u128" + } } } ] } }, { - "name": "SignedMsgOrderId", + "name": "OrderParams", "type": { "kind": "struct", "fields": [ { - "name": "uuid", + "name": "order_type", "type": { - "array": [ - "u8", - 8 - ] + "defined": { + "name": "OrderType" + } } }, { - "name": "maxSlot", - "type": "u64" + "name": "market_type", + "type": { + "defined": { + "name": "MarketType" + } + } }, { - "name": "orderId", - "type": "u32" + "name": "direction", + "type": { + "defined": { + "name": "PositionDirection" + } + } }, { - "name": "padding", - "type": "u32" - } - ] - } - }, - { - "name": "SignedMsgUserOrdersFixed", - "type": { - "kind": "struct", - "fields": [ - { - "name": "userPubkey", - "type": "publicKey" + "name": "user_order_id", + "type": "u8" }, { - "name": "padding", - "type": "u32" + "name": "base_asset_amount", + "type": "u64" }, { - "name": "len", - "type": "u32" - } - ] - } - }, - { - "name": "InsuranceFund", - "type": { - "kind": "struct", - "fields": [ + "name": "price", + "type": "u64" + }, { - "name": "vault", - "type": "publicKey" + "name": "market_index", + "type": "u16" }, { - "name": "totalShares", - "type": "u128" + "name": "reduce_only", + "type": "bool" }, { - "name": "userShares", - "type": "u128" + "name": "post_only", + "type": { + "defined": { + "name": "PostOnlyParam" + } + } }, { - "name": "sharesBase", - "type": "u128" + "name": "bit_flags", + "type": "u8" }, { - "name": "unstakingPeriod", - "type": "i64" + "name": "max_ts", + "type": { + "option": "i64" + } }, { - "name": "lastRevenueSettleTs", - "type": "i64" + "name": "trigger_price", + "type": { + "option": "u64" + } }, { - "name": "revenueSettlePeriod", - "type": "i64" + "name": "trigger_condition", + "type": { + "defined": { + "name": "OrderTriggerCondition" + } + } }, { - "name": "totalFactor", - "type": "u32" + "name": "oracle_price_offset", + "type": { + "option": "i32" + } }, { - "name": "userFactor", - "type": "u32" - } - ] - } - }, - { - "name": "OracleGuardRails", - "type": { - "kind": "struct", - "fields": [ + "name": "auction_duration", + "type": { + "option": "u8" + } + }, { - "name": "priceDivergence", + "name": "auction_start_price", "type": { - "defined": "PriceDivergenceGuardRails" + "option": "i64" } }, { - "name": "validity", + "name": "auction_end_price", "type": { - "defined": "ValidityGuardRails" + "option": "i64" } } ] } }, { - "name": "PriceDivergenceGuardRails", + "name": "OrderRecord", "type": { "kind": "struct", "fields": [ { - "name": "markOraclePercentDivergence", - "type": "u64" + "name": "ts", + "type": "i64" }, { - "name": "oracleTwap5minPercentDivergence", - "type": "u64" + "name": "user", + "type": "pubkey" + }, + { + "name": "order", + "type": { + "defined": { + "name": "Order" + } + } } ] } }, { - "name": "ValidityGuardRails", + "name": "OrderStatus", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "slotsBeforeStaleForAmm", - "type": "i64" + "name": "Init" }, { - "name": "slotsBeforeStaleForMargin", - "type": "i64" + "name": "Open" }, { - "name": "confidenceIntervalMaxSize", - "type": "u64" + "name": "Filled" }, { - "name": "tooVolatileRatio", - "type": "i64" + "name": "Canceled" } ] } }, { - "name": "FeeStructure", + "name": "OrderTriggerCondition", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "feeTiers", - "type": { - "array": [ - { - "defined": "FeeTier" - }, - 10 - ] - } + "name": "Above" }, { - "name": "fillerRewardStructure", - "type": { - "defined": "OrderFillerRewardStructure" - } + "name": "Below" }, { - "name": "referrerRewardEpochUpperBound", - "type": "u64" + "name": "TriggeredAbove" }, { - "name": "flatFillerFee", - "type": "u64" + "name": "TriggeredBelow" } ] } }, { - "name": "FeeTier", + "name": "OrderType", "type": { - "kind": "struct", - "fields": [ - { - "name": "feeNumerator", - "type": "u32" - }, - { - "name": "feeDenominator", - "type": "u32" - }, - { - "name": "makerRebateNumerator", - "type": "u32" - }, + "kind": "enum", + "variants": [ { - "name": "makerRebateDenominator", - "type": "u32" + "name": "Market" }, { - "name": "referrerRewardNumerator", - "type": "u32" + "name": "Limit" }, { - "name": "referrerRewardDenominator", - "type": "u32" + "name": "TriggerMarket" }, { - "name": "refereeFeeNumerator", - "type": "u32" + "name": "TriggerLimit" }, { - "name": "refereeFeeDenominator", - "type": "u32" + "name": "Oracle" } ] } }, { - "name": "OrderFillerRewardStructure", + "name": "OverrideAmmCacheParams", "type": { "kind": "struct", "fields": [ { - "name": "rewardNumerator", - "type": "u32" + "name": "quote_owed_from_lp_pool", + "type": { + "option": "i64" + } }, { - "name": "rewardDenominator", - "type": "u32" + "name": "last_settle_slot", + "type": { + "option": "u64" + } }, { - "name": "timeBasedRewardLowerBound", - "type": "u128" + "name": "last_fee_pool_token_amount", + "type": { + "option": "u128" + } + }, + { + "name": "last_net_pnl_pool_token_amount", + "type": { + "option": "i128" + } + }, + { + "name": "amm_position_scalar", + "type": { + "option": "u8" + } + }, + { + "name": "amm_inventory_limit", + "type": { + "option": "i64" + } } ] } }, { - "name": "UserFees", + "name": "PerpBankruptcyRecord", "type": { "kind": "struct", "fields": [ { - "name": "totalFeePaid", - "docs": [ - "Total taker fee paid", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "market_index", + "type": "u16" }, { - "name": "totalFeeRebate", - "docs": [ - "Total maker fee rebate", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "pnl", + "type": "i128" }, { - "name": "totalTokenDiscount", - "docs": [ - "Total discount from holding token", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "if_payment", + "type": "u128" }, { - "name": "totalRefereeDiscount", - "docs": [ - "Total discount from being referred", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "clawback_user", + "type": { + "option": "pubkey" + } }, { - "name": "totalReferrerReward", - "docs": [ - "Total reward to referrer", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "clawback_user_payment", + "type": { + "option": "u128" + } }, { - "name": "currentEpochReferrerReward", - "docs": [ - "Total reward to referrer this epoch", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "cumulative_funding_rate_delta", + "type": "i128" } ] } }, { - "name": "SpotPosition", + "name": "PerpMarket", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "scaledBalance", - "docs": [ - "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", - "interest of corresponding market.", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u64" - }, - { - "name": "openBids", + "name": "pubkey", "docs": [ - "How many spot non reduce only trigger orders the user has open", - "precision: token mint precision" + "The perp market's address. It is a pda of the market index" ], - "type": "i64" + "type": "pubkey" }, { - "name": "openAsks", + "name": "amm", "docs": [ - "How many spot non reduce only trigger orders the user has open", - "precision: token mint precision" + "The automated market maker" ], - "type": "i64" + "type": { + "defined": { + "name": "AMM" + } + } }, { - "name": "cumulativeDeposits", + "name": "pnl_pool", "docs": [ - "The cumulative deposits/borrows a user has made into a market", - "precision: token mint precision" + "The market's pnl pool. When users settle negative pnl, the balance increases.", + "When users settle positive pnl, the balance decreases. Can not go negative." ], - "type": "i64" + "type": { + "defined": { + "name": "PoolBalance" + } + } }, { - "name": "marketIndex", + "name": "name", "docs": [ - "The market index of the corresponding spot market" + "Encoded display name for the perp market e.g. SOL-PERP" ], - "type": "u16" + "type": { + "array": [ + "u8", + 32 + ] + } }, { - "name": "balanceType", + "name": "insurance_claim", "docs": [ - "Whether the position is deposit or borrow" + "The perp market's claim on the insurance fund" ], "type": { - "defined": "SpotBalanceType" + "defined": { + "name": "InsuranceClaim" + } } }, { - "name": "openOrders", + "name": "unrealized_pnl_max_imbalance", "docs": [ - "Number of open orders" + "The max pnl imbalance before positive pnl asset weight is discounted", + "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", + "the amm has negative pnl and the initial asset weight for positive pnl is discounted", + "precision = QUOTE_PRECISION" ], - "type": "u8" + "type": "u64" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "PerpPosition", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastCumulativeFundingRate", + "name": "expiry_ts", "docs": [ - "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", - "precision: FUNDING_RATE_PRECISION" + "The ts when the market will be expired. Only set if market is in reduce only mode" ], "type": "i64" }, { - "name": "baseAssetAmount", + "name": "expiry_price", "docs": [ - "the size of the users perp position", - "precision: BASE_PRECISION" + "The price at which positions will be settled. Only set if market is expired", + "precision = PRICE_PRECISION" ], "type": "i64" }, { - "name": "quoteAssetAmount", + "name": "next_fill_record_id", "docs": [ - "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees", - "Updated when the user open/closes position or settles pnl. Includes fees/funding", - "precision: QUOTE_PRECISION" + "Every trade has a fill record id. This is the next id to be used" ], - "type": "i64" + "type": "u64" }, { - "name": "quoteBreakEvenAmount", + "name": "next_funding_rate_record_id", "docs": [ - "The amount of quote the user would need to exit their position at to break even", - "Updated when the user open/closes position or settles pnl. Includes fees/funding", - "precision: QUOTE_PRECISION" + "Every funding rate update has a record id. This is the next id to be used" ], - "type": "i64" + "type": "u64" }, { - "name": "quoteEntryAmount", + "name": "next_curve_record_id", "docs": [ - "The amount quote the user entered the position with. Equal to base asset amount * avg entry price", - "Updated when the user open/closes position. Excludes fees/funding", - "precision: QUOTE_PRECISION" + "Every amm k updated has a record id. This is the next id to be used" ], - "type": "i64" + "type": "u64" }, { - "name": "openBids", + "name": "imf_factor", "docs": [ - "The amount of non reduce only trigger orders the user has open", - "precision: BASE_PRECISION" + "The initial margin fraction factor. Used to increase margin ratio for large positions", + "precision: MARGIN_PRECISION" ], - "type": "i64" + "type": "u32" }, { - "name": "openAsks", + "name": "unrealized_pnl_imf_factor", "docs": [ - "The amount of non reduce only trigger orders the user has open", - "precision: BASE_PRECISION" + "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", + "precision: MARGIN_PRECISION" ], - "type": "i64" + "type": "u32" }, { - "name": "settledPnl", + "name": "liquidator_fee", "docs": [ - "The amount of pnl settled in this market since opening the position", - "precision: QUOTE_PRECISION" + "The fee the liquidator is paid for taking over perp position", + "precision: LIQUIDATOR_FEE_PRECISION" ], - "type": "i64" + "type": "u32" }, { - "name": "lpShares", + "name": "if_liquidation_fee", "docs": [ - "The number of lp (liquidity provider) shares the user has in this perp market", - "LP shares allow users to provide liquidity via the AMM", - "precision: BASE_PRECISION" + "The fee the insurance fund receives from liquidation", + "precision: LIQUIDATOR_FEE_PRECISION" ], - "type": "u64" + "type": "u32" }, { - "name": "lastBaseAssetAmountPerLp", + "name": "margin_ratio_initial", "docs": [ - "The last base asset amount per lp the amm had", - "Used to settle the users lp position", - "precision: BASE_PRECISION" + "The margin ratio which determines how much collateral is required to open a position", + "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", + "precision: MARGIN_PRECISION" ], - "type": "i64" + "type": "u32" }, { - "name": "lastQuoteAssetAmountPerLp", + "name": "margin_ratio_maintenance", "docs": [ - "The last quote asset amount per lp the amm had", - "Used to settle the users lp position", - "precision: QUOTE_PRECISION" + "The margin ratio which determines when a user will be liquidated", + "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", + "else they will be liquidated", + "precision: MARGIN_PRECISION" ], - "type": "i64" + "type": "u32" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 2 - ] - } + "name": "unrealized_pnl_initial_asset_weight", + "docs": [ + "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" }, { - "name": "maxMarginRatio", - "type": "u16" + "name": "unrealized_pnl_maintenance_asset_weight", + "docs": [ + "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" }, { - "name": "marketIndex", + "name": "number_of_users_with_base", "docs": [ - "The market index for the perp market" + "number of users in a position (base)" ], - "type": "u16" + "type": "u32" }, { - "name": "openOrders", + "name": "number_of_users", "docs": [ - "The number of open orders" + "number of users in a position (pnl) or pnl (quote)" ], - "type": "u8" + "type": "u32" }, { - "name": "perLpBase", - "type": "i8" - } - ] - } - }, - { - "name": "Order", - "type": { - "kind": "struct", - "fields": [ + "name": "market_index", + "type": "u16" + }, { - "name": "slot", + "name": "status", "docs": [ - "The slot the order was placed" + "Whether a market is active, reduce only, expired, etc", + "Affects whether users can open/close positions" ], - "type": "u64" + "type": { + "defined": { + "name": "MarketStatus" + } + } }, { - "name": "price", + "name": "contract_type", "docs": [ - "The limit price for the order (can be 0 for market orders)", - "For orders with an auction, this price isn't used until the auction is complete", - "precision: PRICE_PRECISION" + "Currently only Perpetual markets are supported" ], - "type": "u64" + "type": { + "defined": { + "name": "ContractType" + } + } }, { - "name": "baseAssetAmount", + "name": "contract_tier", "docs": [ - "The size of the order", - "precision for perps: BASE_PRECISION", - "precision for spot: token mint precision" + "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", + "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" ], - "type": "u64" + "type": { + "defined": { + "name": "ContractTier" + } + } }, { - "name": "baseAssetAmountFilled", - "docs": [ - "The amount of the order filled", - "precision for perps: BASE_PRECISION", - "precision for spot: token mint precision" - ], - "type": "u64" + "name": "paused_operations", + "type": "u8" }, { - "name": "quoteAssetAmountFilled", + "name": "quote_spot_market_index", "docs": [ - "The amount of quote filled for the order", - "precision: QUOTE_PRECISION" + "The spot market that pnl is settled in" ], - "type": "u64" + "type": "u16" }, { - "name": "triggerPrice", + "name": "fee_adjustment", "docs": [ - "At what price the order will be triggered. Only relevant for trigger orders", - "precision: PRICE_PRECISION" + "Between -100 and 100, represents what % to increase/decrease the fee by", + "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", + "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" ], - "type": "u64" + "type": "i16" }, { - "name": "auctionStartPrice", + "name": "fuel_boost_position", "docs": [ - "The start price for the auction. Only relevant for market/oracle orders", - "precision: PRICE_PRECISION" + "fuel multiplier for perp funding", + "precision: 10" ], - "type": "i64" + "type": "u8" }, { - "name": "auctionEndPrice", + "name": "fuel_boost_taker", "docs": [ - "The end price for the auction. Only relevant for market/oracle orders", - "precision: PRICE_PRECISION" + "fuel multiplier for perp taker", + "precision: 10" ], - "type": "i64" + "type": "u8" }, { - "name": "maxTs", + "name": "fuel_boost_maker", "docs": [ - "The time when the order will expire" + "fuel multiplier for perp maker", + "precision: 10" ], - "type": "i64" + "type": "u8" }, { - "name": "oraclePriceOffset", - "docs": [ - "If set, the order limit price is the oracle price + this offset", - "precision: PRICE_PRECISION" - ], - "type": "i32" + "name": "pool_id", + "type": "u8" }, { - "name": "orderId", - "docs": [ - "The id for the order. Each users has their own order id space" - ], - "type": "u32" + "name": "high_leverage_margin_ratio_initial", + "type": "u16" }, { - "name": "marketIndex", - "docs": [ - "The perp/spot market index" - ], + "name": "high_leverage_margin_ratio_maintenance", "type": "u16" }, { - "name": "status", - "docs": [ - "Whether the order is open or unused" - ], - "type": { - "defined": "OrderStatus" - } + "name": "protected_maker_limit_price_divisor", + "type": "u8" }, { - "name": "orderType", - "docs": [ - "The type of order" - ], + "name": "protected_maker_dynamic_divisor", + "type": "u8" + }, + { + "name": "lp_fee_transfer_scalar", + "type": "u8" + }, + { + "name": "lp_status", + "type": "u8" + }, + { + "name": "lp_paused_operations", + "type": "u8" + }, + { + "name": "lp_exchange_fee_excluscion_scalar", + "type": "u8" + }, + { + "name": "last_fill_price", + "type": "u64" + }, + { + "name": "lp_pool_id", + "type": "u8" + }, + { + "name": "padding", "type": { - "defined": "OrderType" + "array": [ + "u8", + 23 + ] } - }, + } + ] + } + }, + { + "name": "PerpPosition", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "marketType", + "name": "last_cumulative_funding_rate", "docs": [ - "Whether market is spot or perp" + "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", + "precision: FUNDING_RATE_PRECISION" ], - "type": { - "defined": "MarketType" - } + "type": "i64" }, { - "name": "userOrderId", + "name": "base_asset_amount", "docs": [ - "User generated order id. Can make it easier to place/cancel orders" + "the size of the users perp position", + "precision: BASE_PRECISION" ], - "type": "u8" + "type": "i64" }, { - "name": "existingPositionDirection", + "name": "quote_asset_amount", "docs": [ - "What the users position was when the order was placed" + "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees", + "Updated when the user open/closes position or settles pnl. Includes fees/funding", + "precision: QUOTE_PRECISION" ], - "type": { - "defined": "PositionDirection" - } + "type": "i64" }, { - "name": "direction", + "name": "quote_break_even_amount", "docs": [ - "Whether the user is going long or short. LONG = bid, SHORT = ask" + "The amount of quote the user would need to exit their position at to break even", + "Updated when the user open/closes position or settles pnl. Includes fees/funding", + "precision: QUOTE_PRECISION" ], - "type": { - "defined": "PositionDirection" - } + "type": "i64" }, { - "name": "reduceOnly", + "name": "quote_entry_amount", "docs": [ - "Whether the order is allowed to only reduce position size" + "The amount quote the user entered the position with. Equal to base asset amount * avg entry price", + "Updated when the user open/closes position. Excludes fees/funding", + "precision: QUOTE_PRECISION" ], - "type": "bool" + "type": "i64" }, { - "name": "postOnly", + "name": "open_bids", "docs": [ - "Whether the order must be a maker" + "The amount of non reduce only trigger orders the user has open", + "precision: BASE_PRECISION" ], - "type": "bool" + "type": "i64" }, { - "name": "immediateOrCancel", + "name": "open_asks", "docs": [ - "Whether the order must be canceled the same slot it is placed" + "The amount of non reduce only trigger orders the user has open", + "precision: BASE_PRECISION" ], - "type": "bool" + "type": "i64" }, { - "name": "triggerCondition", + "name": "settled_pnl", "docs": [ - "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders" + "The amount of pnl settled in this market since opening the position", + "precision: QUOTE_PRECISION" ], - "type": { - "defined": "OrderTriggerCondition" - } + "type": "i64" }, { - "name": "auctionDuration", + "name": "lp_shares", "docs": [ - "How many slots the auction lasts" + "The number of lp (liquidity provider) shares the user has in this perp market", + "LP shares allow users to provide liquidity via the AMM", + "precision: BASE_PRECISION" ], - "type": "u8" + "type": "u64" }, { - "name": "postedSlotTail", + "name": "last_base_asset_amount_per_lp", "docs": [ - "Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)" + "The last base asset amount per lp the amm had", + "Used to settle the users lp position", + "precision: BASE_PRECISION" ], - "type": "u8" + "type": "i64" }, { - "name": "bitFlags", + "name": "last_quote_asset_amount_per_lp", "docs": [ - "Bitflags for further classification", - "0: is_signed_message" + "The last quote asset amount per lp the amm had", + "Used to settle the users lp position", + "precision: QUOTE_PRECISION" ], - "type": "u8" + "type": "i64" }, { "name": "padding", "type": { "array": [ "u8", - 1 + 2 ] } - } - ] - } - }, - { - "name": "SwapDirection", - "type": { - "kind": "enum", - "variants": [ + }, { - "name": "Add" + "name": "max_margin_ratio", + "type": "u16" }, { - "name": "Remove" - } - ] - } - }, - { - "name": "ModifyOrderId", - "type": { - "kind": "enum", - "variants": [ + "name": "market_index", + "docs": [ + "The market index for the perp market" + ], + "type": "u16" + }, { - "name": "UserOrderId", - "fields": [ - "u8" - ] + "name": "open_orders", + "docs": [ + "The number of open orders" + ], + "type": "u8" }, { - "name": "OrderId", - "fields": [ - "u32" - ] + "name": "per_lp_base", + "type": "i8" } ] } }, { - "name": "PositionDirection", + "name": "PhoenixV1FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "Long" + "name": "pubkey", + "type": "pubkey" }, { - "name": "Short" - } - ] - } - }, - { - "name": "SpotFulfillmentType", - "type": { - "kind": "enum", - "variants": [ + "name": "phoenix_program_id", + "type": "pubkey" + }, { - "name": "SerumV3" + "name": "phoenix_log_authority", + "type": "pubkey" }, { - "name": "Match" + "name": "phoenix_market", + "type": "pubkey" }, { - "name": "PhoenixV1" + "name": "phoenix_base_vault", + "type": "pubkey" }, { - "name": "OpenbookV2" - } - ] - } - }, - { - "name": "SwapReduceOnly", - "type": { - "kind": "enum", - "variants": [ + "name": "phoenix_quote_vault", + "type": "pubkey" + }, { - "name": "In" + "name": "market_index", + "type": "u16" }, { - "name": "Out" - } - ] - } - }, - { - "name": "TwapPeriod", - "type": { - "kind": "enum", - "variants": [ + "name": "fulfillment_type", + "type": { + "defined": { + "name": "SpotFulfillmentType" + } + } + }, { - "name": "FundingPeriod" + "name": "status", + "type": { + "defined": { + "name": "SpotFulfillmentConfigStatus" + } + } }, { - "name": "FiveMin" + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } } ] } }, { - "name": "LiquidationMultiplierType", + "name": "PoolBalance", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ + { + "name": "scaled_balance", + "docs": [ + "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", + "deposit interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, { - "name": "Discount" + "name": "market_index", + "docs": [ + "The spot market the pool is for" + ], + "type": "u16" }, { - "name": "Premium" + "name": "padding", + "type": { + "array": [ + "u8", + 6 + ] + } } ] } }, { - "name": "SettlementDirection", + "name": "PositionDirection", "type": { "kind": "enum", "variants": [ { - "name": "ToLpPool" - }, - { - "name": "FromLpPool" + "name": "Long" }, { - "name": "None" + "name": "Short" } ] } }, { - "name": "MarginRequirementType", + "name": "PostOnlyParam", "type": { "kind": "enum", "variants": [ { - "name": "Initial" + "name": "None" + }, + { + "name": "MustPostOnly" }, { - "name": "Fill" + "name": "TryPostOnly" }, { - "name": "Maintenance" + "name": "Slide" } ] } }, { - "name": "OracleValidity", + "name": "PrelaunchOracle", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "NonPositive" + "name": "price", + "type": "i64" }, { - "name": "TooVolatile" + "name": "max_price", + "type": "i64" }, { - "name": "TooUncertain" + "name": "confidence", + "type": "u64" }, { - "name": "StaleForMargin" + "name": "last_update_slot", + "type": "u64" }, { - "name": "InsufficientDataPoints" + "name": "amm_last_update_slot", + "type": "u64" }, { - "name": "StaleForAMM", - "fields": [ - { - "name": "immediate", - "type": "bool" - }, - { - "name": "lowRisk", - "type": "bool" - } - ] + "name": "perp_market_index", + "type": "u16" }, { - "name": "Valid" + "name": "padding", + "type": { + "array": [ + "u8", + 70 + ] + } } ] } }, { - "name": "DriftAction", + "name": "PrelaunchOracleParams", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "UpdateFunding" + "name": "perp_market_index", + "type": "u16" }, { - "name": "SettlePnl" + "name": "price", + "type": { + "option": "i64" + } }, { - "name": "TriggerOrder" - }, + "name": "max_price", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "PriceDivergenceGuardRails", + "type": { + "kind": "struct", + "fields": [ { - "name": "FillOrderMatch" + "name": "mark_oracle_percent_divergence", + "type": "u64" }, { - "name": "FillOrderAmmLowRisk" - }, + "name": "oracle_twap_5min_percent_divergence", + "type": "u64" + } + ] + } + }, + { + "name": "ProtectedMakerModeConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "FillOrderAmmImmediate" + "name": "max_users", + "type": "u32" }, { - "name": "Liquidate" + "name": "current_users", + "type": "u32" }, { - "name": "MarginCalc" + "name": "reduce_only", + "type": "u8" }, { - "name": "UpdateTwap" - }, + "name": "padding", + "type": { + "array": [ + "u8", + 31 + ] + } + } + ] + } + }, + { + "name": "PythLazerOracle", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "UpdateAMMCurve" + "name": "price", + "type": "i64" }, { - "name": "OracleOrderPrice" + "name": "publish_time", + "type": "u64" }, { - "name": "UseMMOraclePrice" + "name": "posted_slot", + "type": "u64" }, { - "name": "UpdateAmmCache" + "name": "exponent", + "type": "i32" }, { - "name": "UpdateLpPoolAum" + "name": "_padding", + "type": { + "array": [ + "u8", + 4 + ] + } }, { - "name": "LpPoolSwap" + "name": "conf", + "type": "u64" } ] } }, { - "name": "LogMode", + "name": "ReferrerName", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ - { - "name": "None" - }, + "kind": "struct", + "fields": [ { - "name": "ExchangeOracle" + "name": "authority", + "type": "pubkey" }, { - "name": "MMOracle" + "name": "user", + "type": "pubkey" }, { - "name": "SafeMMOracle" + "name": "user_stats", + "type": "pubkey" }, { - "name": "Margin" + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } } ] } }, { - "name": "PositionUpdateType", + "name": "RevenueShare", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "rust", + "packed": true + }, "type": { - "kind": "enum", - "variants": [ - { - "name": "Open" - }, + "kind": "struct", + "fields": [ { - "name": "Increase" + "name": "authority", + "docs": [ + "the owner of this account, a builder or referrer" + ], + "type": "pubkey" }, { - "name": "Reduce" + "name": "total_referrer_rewards", + "type": "u64" }, { - "name": "Close" + "name": "total_builder_rewards", + "type": "u64" }, { - "name": "Flip" + "name": "padding", + "type": { + "array": [ + "u8", + 18 + ] + } } ] } }, { - "name": "DepositExplanation", + "name": "RevenueShareEscrow", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "None" + "name": "authority", + "docs": [ + "the owner of this account, a user" + ], + "type": "pubkey" }, { - "name": "Transfer" + "name": "referrer", + "type": "pubkey" }, { - "name": "Borrow" + "name": "referrer_boost_expire_ts", + "type": "u32" }, { - "name": "RepayBorrow" + "name": "referrer_reward_offset", + "type": "i8" }, { - "name": "Reward" - } - ] - } - }, - { - "name": "DepositDirection", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Deposit" + "name": "referee_fee_numerator_offset", + "type": "i8" }, { - "name": "Withdraw" - } - ] - } - }, - { - "name": "OrderAction", - "type": { - "kind": "enum", - "variants": [ + "name": "referrer_boost_numerator", + "type": "i8" + }, { - "name": "Place" + "name": "reserved_fixed", + "type": { + "array": [ + "u8", + 17 + ] + } }, { - "name": "Cancel" + "name": "padding0", + "type": "u32" }, { - "name": "Fill" + "name": "orders", + "type": { + "vec": { + "defined": { + "name": "RevenueShareOrder" + } + } + } }, { - "name": "Trigger" + "name": "padding1", + "type": "u32" }, { - "name": "Expire" + "name": "approved_builders", + "type": { + "vec": { + "defined": { + "name": "BuilderInfo" + } + } + } } ] } }, { - "name": "OrderActionExplanation", + "name": "RevenueShareOrder", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ - { - "name": "None" - }, - { - "name": "InsufficientFreeCollateral" - }, + "kind": "struct", + "fields": [ { - "name": "OraclePriceBreachedLimitPrice" + "name": "fees_accrued", + "docs": [ + "fees accrued so far for this order slot. This is not exclusively fees from this order_id", + "and may include fees from other orders in the same market. This may be swept to the", + "builder's SpotPosition during settle_pnl." + ], + "type": "u64" }, { - "name": "MarketOrderFilledToLimitPrice" + "name": "order_id", + "docs": [ + "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open" + ], + "type": "u32" }, { - "name": "OrderExpired" + "name": "fee_tenth_bps", + "docs": [ + "the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%" + ], + "type": "u16" }, { - "name": "Liquidation" + "name": "market_index", + "type": "u16" }, { - "name": "OrderFilledWithAMM" + "name": "sub_account_id", + "docs": [ + "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open" + ], + "type": "u16" }, { - "name": "OrderFilledWithAMMJit" + "name": "builder_idx", + "docs": [ + "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", + "if bit_flag = Referral." + ], + "type": "u8" }, { - "name": "OrderFilledWithMatch" + "name": "bit_flags", + "docs": [ + "bitflags that describe the state of the order.", + "[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.", + "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", + "[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.", + "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", + "[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.", + "If it is set, no other bitflag should be set." + ], + "type": "u8" }, { - "name": "OrderFilledWithMatchJit" + "name": "user_order_index", + "docs": [ + "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches." + ], + "type": "u8" }, { - "name": "MarketExpired" + "name": "market_type", + "type": { + "defined": { + "name": "MarketType" + } + } }, { - "name": "RiskingIncreasingOrder" - }, + "name": "padding", + "type": { + "array": [ + "u8", + 10 + ] + } + } + ] + } + }, + { + "name": "RevenueShareSettleRecord", + "type": { + "kind": "struct", + "fields": [ { - "name": "ReduceOnlyOrderIncreasedPosition" + "name": "ts", + "type": "i64" }, { - "name": "OrderFillWithSerum" + "name": "builder", + "type": { + "option": "pubkey" + } }, { - "name": "NoBorrowLiquidity" + "name": "referrer", + "type": { + "option": "pubkey" + } }, { - "name": "OrderFillWithPhoenix" + "name": "fee_settled", + "type": "u64" }, { - "name": "OrderFilledWithAMMJitLPSplit" + "name": "market_index", + "type": "u16" }, { - "name": "OrderFilledWithLPJit" + "name": "market_type", + "type": { + "defined": { + "name": "MarketType" + } + } }, { - "name": "DeriskLp" + "name": "builder_sub_account_id", + "type": "u16" }, { - "name": "OrderFilledWithOpenbookV2" + "name": "builder_total_referrer_rewards", + "type": "u64" }, { - "name": "TransferPerpPosition" + "name": "builder_total_builder_rewards", + "type": "u64" } ] } }, { - "name": "LPAction", + "name": "SerumV3FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "AddLiquidity" + "name": "pubkey", + "type": "pubkey" }, { - "name": "RemoveLiquidity" + "name": "serum_program_id", + "type": "pubkey" }, { - "name": "SettleLiquidity" + "name": "serum_market", + "type": "pubkey" }, { - "name": "RemoveLiquidityDerisk" - } - ] - } - }, - { - "name": "LiquidationType", - "type": { - "kind": "enum", - "variants": [ + "name": "serum_request_queue", + "type": "pubkey" + }, { - "name": "LiquidatePerp" + "name": "serum_event_queue", + "type": "pubkey" }, { - "name": "LiquidateSpot" + "name": "serum_bids", + "type": "pubkey" }, { - "name": "LiquidateBorrowForPerpPnl" + "name": "serum_asks", + "type": "pubkey" }, { - "name": "LiquidatePerpPnlForDeposit" + "name": "serum_base_vault", + "type": "pubkey" }, { - "name": "PerpBankruptcy" + "name": "serum_quote_vault", + "type": "pubkey" }, { - "name": "SpotBankruptcy" + "name": "serum_open_orders", + "type": "pubkey" + }, + { + "name": "serum_signer_nonce", + "type": "u64" + }, + { + "name": "market_index", + "type": "u16" + }, + { + "name": "fulfillment_type", + "type": { + "defined": { + "name": "SpotFulfillmentType" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "SpotFulfillmentConfigStatus" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } } ] } @@ -15153,4432 +22160,1941 @@ } }, { - "name": "StakeAction", + "name": "SettlePnlMode", "type": { "kind": "enum", "variants": [ { - "name": "Stake" - }, - { - "name": "UnstakeRequest" - }, - { - "name": "UnstakeCancelRequest" - }, - { - "name": "Unstake" - }, - { - "name": "UnstakeTransfer" - }, - { - "name": "StakeTransfer" + "name": "MustSettle" }, { - "name": "AdminDeposit" + "name": "TrySettle" } ] } }, { - "name": "FillMode", + "name": "SettlePnlRecord", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "Fill" + "name": "ts", + "type": "i64" }, { - "name": "PlaceAndMake" + "name": "user", + "type": "pubkey" }, { - "name": "PlaceAndTake", - "fields": [ - "bool", - "u8" - ] + "name": "market_index", + "type": "u16" }, { - "name": "Liquidation" - } - ] - } - }, - { - "name": "PerpFulfillmentMethod", - "type": { - "kind": "enum", - "variants": [ + "name": "pnl", + "type": "i128" + }, { - "name": "AMM", - "fields": [ - { - "option": "u64" - } - ] + "name": "base_asset_amount", + "type": "i64" }, { - "name": "Match", - "fields": [ - "publicKey", - "u16", - "u64" - ] - } - ] - } - }, - { - "name": "SpotFulfillmentMethod", - "type": { - "kind": "enum", - "variants": [ + "name": "quote_asset_amount_after", + "type": "i64" + }, { - "name": "ExternalMarket" + "name": "quote_entry_amount", + "type": "i64" }, { - "name": "Match", - "fields": [ - "publicKey", - "u16" - ] + "name": "settle_price", + "type": "i64" + }, + { + "name": "explanation", + "type": { + "defined": { + "name": "SettlePnlExplanation" + } + } } ] } }, { - "name": "ConstituentStatus", + "name": "SignedMsgOrderId", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "ReduceOnly" + "name": "uuid", + "type": { + "array": [ + "u8", + 8 + ] + } }, { - "name": "Decommissioned" - } - ] - } - }, - { - "name": "MarginCalculationMode", - "type": { - "kind": "enum", - "variants": [ + "name": "max_slot", + "type": "u64" + }, { - "name": "Standard", - "fields": [ - { - "name": "trackOpenOrdersFraction", - "type": "bool" - } - ] + "name": "order_id", + "type": "u32" }, { - "name": "Liquidation", - "fields": [ - { - "name": "marketToTrackMarginRequirement", - "type": { - "option": { - "defined": "MarketIdentifier" - } - } - } - ] + "name": "padding", + "type": "u32" } ] } }, { - "name": "OracleSource", + "name": "SignedMsgOrderRecord", "type": { - "kind": "enum", - "variants": [ - { - "name": "Pyth" - }, - { - "name": "Switchboard" - }, - { - "name": "QuoteAsset" - }, - { - "name": "Pyth1K" - }, - { - "name": "Pyth1M" - }, - { - "name": "PythStableCoin" - }, + "kind": "struct", + "fields": [ { - "name": "Prelaunch" + "name": "user", + "type": "pubkey" }, { - "name": "PythPull" + "name": "hash", + "type": "string" }, { - "name": "Pyth1KPull" + "name": "matching_order_params", + "type": { + "defined": { + "name": "OrderParams" + } + } }, { - "name": "Pyth1MPull" + "name": "user_order_id", + "type": "u32" }, { - "name": "PythStableCoinPull" + "name": "signed_msg_order_max_slot", + "type": "u64" }, { - "name": "SwitchboardOnDemand" + "name": "signed_msg_order_uuid", + "type": { + "array": [ + "u8", + 8 + ] + } }, { - "name": "PythLazer" - }, + "name": "ts", + "type": "i64" + } + ] + } + }, + { + "name": "SignedMsgUserOrders", + "docs": [ + "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "PythLazer1K" + "name": "authority_pubkey", + "type": "pubkey" }, { - "name": "PythLazer1M" + "name": "padding", + "type": "u32" }, { - "name": "PythLazerStableCoin" + "name": "signed_msg_order_data", + "type": { + "vec": { + "defined": { + "name": "SignedMsgOrderId" + } + } + } } ] } }, { - "name": "OrderParamsBitFlag", + "name": "SignedMsgWsDelegates", + "docs": [ + "* Used to store authenticated delegates for swift-like ws connections" + ], "type": { - "kind": "enum", - "variants": [ - { - "name": "ImmediateOrCancel" - }, + "kind": "struct", + "fields": [ { - "name": "UpdateHighLeverageMode" + "name": "delegates", + "type": { + "vec": "pubkey" + } } ] } }, { - "name": "PostOnlyParam", + "name": "SpotBalanceType", "type": { "kind": "enum", "variants": [ { - "name": "None" - }, - { - "name": "MustPostOnly" - }, - { - "name": "TryPostOnly" + "name": "Deposit" }, { - "name": "Slide" + "name": "Borrow" } ] } }, { - "name": "ModifyOrderPolicy", + "name": "SpotBankruptcyRecord", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ + { + "name": "market_index", + "type": "u16" + }, + { + "name": "borrow_amount", + "type": "u128" + }, { - "name": "MustModify" + "name": "if_payment", + "type": "u128" }, { - "name": "ExcludePreviousFill" + "name": "cumulative_deposit_interest_delta", + "type": "u128" } ] } }, { - "name": "PlaceAndTakeOrderSuccessCondition", + "name": "SpotFulfillmentConfigStatus", "type": { "kind": "enum", "variants": [ { - "name": "PartialFill" + "name": "Enabled" }, { - "name": "FullFill" + "name": "Disabled" } ] } }, { - "name": "PerpOperation", + "name": "SpotFulfillmentType", "type": { "kind": "enum", "variants": [ { - "name": "UpdateFunding" - }, - { - "name": "AmmFill" - }, - { - "name": "Fill" - }, - { - "name": "SettlePnl" - }, - { - "name": "SettlePnlWithPosition" + "name": "SerumV3" }, { - "name": "Liquidation" + "name": "Match" }, { - "name": "AmmImmediateFill" + "name": "PhoenixV1" }, { - "name": "SettleRevPool" + "name": "OpenbookV2" } ] } }, { - "name": "SpotOperation", + "name": "SpotInterestRecord", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "UpdateCumulativeInterest" + "name": "ts", + "type": "i64" }, { - "name": "Fill" + "name": "market_index", + "type": "u16" }, { - "name": "Deposit" + "name": "deposit_balance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" }, { - "name": "Withdraw" + "name": "cumulative_deposit_interest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" }, { - "name": "Liquidation" - } - ] - } - }, - { - "name": "InsuranceFundOperation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Init" + "name": "borrow_balance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" }, { - "name": "Add" + "name": "cumulative_borrow_interest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" }, { - "name": "RequestRemove" + "name": "optimal_utilization", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" }, { - "name": "Remove" - } - ] - } - }, - { - "name": "PerpLpOperation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "TrackAmmRevenue" + "name": "optimal_borrow_rate", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" }, { - "name": "SettleQuoteOwed" + "name": "max_borrow_rate", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" } ] } }, { - "name": "ConstituentLpOperation", + "name": "SpotMarket", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "Swap" + "name": "pubkey", + "docs": [ + "The address of the spot market. It is a pda of the market index" + ], + "type": "pubkey" }, { - "name": "Deposit" + "name": "oracle", + "docs": [ + "The oracle used to price the markets deposits/borrows" + ], + "type": "pubkey" }, { - "name": "Withdraw" - } - ] - } - }, - { - "name": "MarketStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Initialized" + "name": "mint", + "docs": [ + "The token mint of the market" + ], + "type": "pubkey" }, { - "name": "Active" + "name": "vault", + "docs": [ + "The vault used to store the market's deposits", + "The amount in the vault should be equal to or greater than deposits - borrows" + ], + "type": "pubkey" }, { - "name": "FundingPaused" + "name": "name", + "docs": [ + "The encoded display name for the market e.g. SOL" + ], + "type": { + "array": [ + "u8", + 32 + ] + } }, { - "name": "AmmPaused" + "name": "historical_oracle_data", + "type": { + "defined": { + "name": "HistoricalOracleData" + } + } }, { - "name": "FillPaused" + "name": "historical_index_data", + "type": { + "defined": { + "name": "HistoricalIndexData" + } + } }, { - "name": "WithdrawPaused" + "name": "revenue_pool", + "docs": [ + "Revenue the protocol has collected in this markets token", + "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" + ], + "type": { + "defined": { + "name": "PoolBalance" + } + } }, { - "name": "ReduceOnly" + "name": "spot_fee_pool", + "docs": [ + "The fees collected from swaps between this market and the quote market", + "Is settled to the quote markets revenue pool" + ], + "type": { + "defined": { + "name": "PoolBalance" + } + } }, { - "name": "Settlement" + "name": "insurance_fund", + "docs": [ + "Details on the insurance fund covering bankruptcies in this markets token", + "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" + ], + "type": { + "defined": { + "name": "InsuranceFund" + } + } }, { - "name": "Delisted" - } - ] - } - }, - { - "name": "LpStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Uncollateralized" + "name": "total_spot_fee", + "docs": [ + "The total spot fees collected for this market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "Active" + "name": "deposit_balance", + "docs": [ + "The sum of the scaled balances for deposits across users and pool balances", + "To convert to the deposit token amount, multiply by the cumulative deposit interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "Decommissioning" - } - ] - } - }, - { - "name": "ContractType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Perpetual" + "name": "borrow_balance", + "docs": [ + "The sum of the scaled balances for borrows across users and pool balances", + "To convert to the borrow token amount, multiply by the cumulative borrow interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "Future" + "name": "cumulative_deposit_interest", + "docs": [ + "The cumulative interest earned by depositors", + "Used to calculate the deposit token amount from the deposit balance", + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "Prediction" - } - ] - } - }, - { - "name": "ContractTier", - "type": { - "kind": "enum", - "variants": [ + "name": "cumulative_borrow_interest", + "docs": [ + "The cumulative interest earned by borrowers", + "Used to calculate the borrow token amount from the borrow balance", + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, { - "name": "A" + "name": "total_social_loss", + "docs": [ + "The total socialized loss from borrows, in the mint's token", + "precision: token mint precision" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "B" + "name": "total_quote_social_loss", + "docs": [ + "The total socialized loss from borrows, in the quote market's token", + "preicision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "C" + "name": "withdraw_guard_threshold", + "docs": [ + "no withdraw limits/guards when deposits below this threshold", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "Speculative" + "name": "max_token_deposits", + "docs": [ + "The max amount of token deposits in this market", + "0 if there is no limit", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "HighlySpeculative" + "name": "deposit_token_twap", + "docs": [ + "24hr average of deposit token amount", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "Isolated" - } - ] - } - }, - { - "name": "RevenueShareOrderBitFlag", - "type": { - "kind": "enum", - "variants": [ + "name": "borrow_token_twap", + "docs": [ + "24hr average of borrow token amount", + "precision: token mint precision" + ], + "type": "u64" + }, { - "name": "Init" + "name": "utilization_twap", + "docs": [ + "24hr average of utilization", + "which is borrow amount over token amount", + "precision: SPOT_UTILIZATION_PRECISION" + ], + "type": "u64" }, { - "name": "Open" + "name": "last_interest_ts", + "docs": [ + "Last time the cumulative deposit and borrow interest was updated" + ], + "type": "u64" }, { - "name": "Completed" + "name": "last_twap_ts", + "docs": [ + "Last time the deposit/borrow/utilization averages were updated" + ], + "type": "u64" }, { - "name": "Referral" - } - ] - } - }, - { - "name": "SettlePnlMode", - "type": { - "kind": "enum", - "variants": [ + "name": "expiry_ts", + "docs": [ + "The time the market is set to expire. Only set if market is in reduce only mode" + ], + "type": "i64" + }, { - "name": "MustSettle" + "name": "order_step_size", + "docs": [ + "Spot orders must be a multiple of the step size", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "TrySettle" - } - ] - } - }, - { - "name": "SpotBalanceType", - "type": { - "kind": "enum", - "variants": [ + "name": "order_tick_size", + "docs": [ + "Spot orders must be a multiple of the tick size", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, { - "name": "Deposit" + "name": "min_order_size", + "docs": [ + "The minimum order size", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "Borrow" - } - ] - } - }, - { - "name": "SpotFulfillmentConfigStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Enabled" + "name": "max_position_size", + "docs": [ + "The maximum spot position size", + "if the limit is 0, there is no limit", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "Disabled" - } - ] - } - }, - { - "name": "AssetTier", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Collateral" + "name": "next_fill_record_id", + "docs": [ + "Every spot trade has a fill record id. This is the next id to use" + ], + "type": "u64" }, { - "name": "Protected" + "name": "next_deposit_record_id", + "docs": [ + "Every deposit has a deposit record id. This is the next id to use" + ], + "type": "u64" }, { - "name": "Cross" + "name": "initial_asset_weight", + "docs": [ + "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", + "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" }, { - "name": "Isolated" + "name": "maintenance_asset_weight", + "docs": [ + "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", + "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" }, { - "name": "Unlisted" - } - ] - } - }, - { - "name": "TokenProgramFlag", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Token2022" + "name": "initial_liability_weight", + "docs": [ + "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", + "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" }, { - "name": "TransferHook" - } - ] - } - }, - { - "name": "ExchangeStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "DepositPaused" + "name": "maintenance_liability_weight", + "docs": [ + "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", + "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" }, { - "name": "WithdrawPaused" + "name": "imf_factor", + "docs": [ + "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", + "precision: MARGIN_PRECISION" + ], + "type": "u32" }, { - "name": "AmmPaused" + "name": "liquidator_fee", + "docs": [ + "The fee the liquidator is paid for taking over borrow/deposit", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" }, { - "name": "FillPaused" + "name": "if_liquidation_fee", + "docs": [ + "The fee the insurance fund receives from liquidation", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" }, { - "name": "LiqPaused" + "name": "optimal_utilization", + "docs": [ + "The optimal utilization rate for this market.", + "Used to determine the markets borrow rate", + "precision: SPOT_UTILIZATION_PRECISION" + ], + "type": "u32" }, { - "name": "FundingPaused" + "name": "optimal_borrow_rate", + "docs": [ + "The borrow rate for this market when the market has optimal utilization", + "precision: SPOT_RATE_PRECISION" + ], + "type": "u32" }, { - "name": "SettlePnlPaused" + "name": "max_borrow_rate", + "docs": [ + "The borrow rate for this market when the market has 1000 utilization", + "precision: SPOT_RATE_PRECISION" + ], + "type": "u32" }, { - "name": "AmmImmediateFillPaused" - } - ] - } - }, - { - "name": "FeatureBitFlags", - "type": { - "kind": "enum", - "variants": [ - { - "name": "MmOracleUpdate" + "name": "decimals", + "docs": [ + "The market's token mint's decimals. To from decimals to a precision, 10^decimals" + ], + "type": "u32" }, { - "name": "MedianTriggerPrice" + "name": "market_index", + "type": "u16" }, { - "name": "BuilderCodes" + "name": "orders_enabled", + "docs": [ + "Whether or not spot trading is enabled" + ], + "type": "bool" }, { - "name": "BuilderReferral" - } - ] - } - }, - { - "name": "LpPoolFeatureBitFlags", - "type": { - "kind": "enum", - "variants": [ - { - "name": "SettleLpPool" + "name": "oracle_source", + "type": { + "defined": { + "name": "OracleSource" + } + } }, { - "name": "SwapLpPool" + "name": "status", + "type": { + "defined": { + "name": "MarketStatus" + } + } }, { - "name": "MintRedeemLpPool" - } - ] - } - }, - { - "name": "UserStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "BeingLiquidated" + "name": "asset_tier", + "docs": [ + "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" + ], + "type": { + "defined": { + "name": "AssetTier" + } + } }, { - "name": "Bankrupt" + "name": "paused_operations", + "type": "u8" }, { - "name": "ReduceOnly" + "name": "if_paused_operations", + "type": "u8" }, { - "name": "AdvancedLp" + "name": "fee_adjustment", + "type": "i16" }, { - "name": "ProtectedMakerOrders" - } - ] - } - }, - { - "name": "AssetType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Base" + "name": "max_token_borrows_fraction", + "docs": [ + "What fraction of max_token_deposits", + "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", + "precision: X/10000" + ], + "type": "u16" }, { - "name": "Quote" - } - ] - } - }, - { - "name": "OrderStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Init" + "name": "flash_loan_amount", + "docs": [ + "For swaps, the amount of token loaned out in the begin_swap ix", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "Open" + "name": "flash_loan_initial_token_amount", + "docs": [ + "For swaps, the amount in the users token account in the begin_swap ix", + "Used to calculate how much of the token left the system in end_swap ix", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "Filled" + "name": "total_swap_fee", + "docs": [ + "The total fees received from swaps", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "Canceled" - } - ] - } - }, - { - "name": "OrderType", - "type": { - "kind": "enum", - "variants": [ + "name": "scale_initial_asset_weight_start", + "docs": [ + "When to begin scaling down the initial asset weight", + "disabled when 0", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, { - "name": "Market" + "name": "min_borrow_rate", + "docs": [ + "The min borrow rate for this market when the market regardless of utilization", + "1 => 1/200 => .5%", + "precision: X/200" + ], + "type": "u8" }, { - "name": "Limit" + "name": "fuel_boost_deposits", + "docs": [ + "fuel multiplier for spot deposits", + "precision: 10" + ], + "type": "u8" }, { - "name": "TriggerMarket" + "name": "fuel_boost_borrows", + "docs": [ + "fuel multiplier for spot borrows", + "precision: 10" + ], + "type": "u8" }, { - "name": "TriggerLimit" + "name": "fuel_boost_taker", + "docs": [ + "fuel multiplier for spot taker", + "precision: 10" + ], + "type": "u8" }, { - "name": "Oracle" - } - ] - } - }, - { - "name": "OrderTriggerCondition", - "type": { - "kind": "enum", - "variants": [ + "name": "fuel_boost_maker", + "docs": [ + "fuel multiplier for spot maker", + "precision: 10" + ], + "type": "u8" + }, { - "name": "Above" + "name": "fuel_boost_insurance", + "docs": [ + "fuel multiplier for spot insurance stake", + "precision: 10" + ], + "type": "u8" }, { - "name": "Below" + "name": "token_program_flag", + "type": "u8" }, { - "name": "TriggeredAbove" + "name": "pool_id", + "type": "u8" }, { - "name": "TriggeredBelow" + "name": "padding", + "type": { + "array": [ + "u8", + 40 + ] + } } ] } }, { - "name": "MarketType", + "name": "SpotMarketVaultDepositRecord", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "Spot" + "name": "ts", + "type": "i64" }, { - "name": "Perp" - } - ] - } - }, - { - "name": "OrderBitFlag", - "type": { - "kind": "enum", - "variants": [ + "name": "market_index", + "type": "u16" + }, { - "name": "SignedMessage" + "name": "deposit_balance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" }, { - "name": "OracleTriggerMarket" + "name": "cumulative_deposit_interest_before", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" }, { - "name": "SafeTriggerOrder" + "name": "cumulative_deposit_interest_after", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" }, { - "name": "NewTriggerReduceOnly" + "name": "deposit_token_amount_before", + "type": "u64" }, { - "name": "HasBuilder" + "name": "amount", + "type": "u64" } ] } }, { - "name": "ReferrerStatus", + "name": "SpotPosition", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "IsReferrer" + "name": "scaled_balance", + "docs": [ + "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", + "interest of corresponding market.", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u64" }, { - "name": "IsReferred" + "name": "open_bids", + "docs": [ + "How many spot non reduce only trigger orders the user has open", + "precision: token mint precision" + ], + "type": "i64" }, { - "name": "BuilderReferral" - } - ] - } - }, - { - "name": "MarginMode", - "type": { - "kind": "enum", - "variants": [ + "name": "open_asks", + "docs": [ + "How many spot non reduce only trigger orders the user has open", + "precision: token mint precision" + ], + "type": "i64" + }, { - "name": "Default" + "name": "cumulative_deposits", + "docs": [ + "The cumulative deposits/borrows a user has made into a market", + "precision: token mint precision" + ], + "type": "i64" }, { - "name": "HighLeverage" + "name": "market_index", + "docs": [ + "The market index of the corresponding spot market" + ], + "type": "u16" }, { - "name": "HighLeverageMaintenance" + "name": "balance_type", + "docs": [ + "Whether the position is deposit or borrow" + ], + "type": { + "defined": { + "name": "SpotBalanceType" + } + } + }, + { + "name": "open_orders", + "docs": [ + "Number of open orders" + ], + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } } ] } }, { - "name": "FuelOverflowStatus", + "name": "StakeAction", "type": { "kind": "enum", "variants": [ { - "name": "Exists" + "name": "Stake" + }, + { + "name": "UnstakeRequest" + }, + { + "name": "UnstakeCancelRequest" + }, + { + "name": "Unstake" + }, + { + "name": "UnstakeTransfer" + }, + { + "name": "StakeTransfer" + }, + { + "name": "AdminDeposit" } ] } }, { - "name": "SignatureVerificationError", + "name": "State", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "InvalidEd25519InstructionProgramId" + "name": "admin", + "type": "pubkey" }, { - "name": "InvalidEd25519InstructionDataLength" + "name": "whitelist_mint", + "type": "pubkey" }, { - "name": "InvalidSignatureIndex" + "name": "discount_mint", + "type": "pubkey" }, { - "name": "InvalidSignatureOffset" + "name": "signer", + "type": "pubkey" }, { - "name": "InvalidPublicKeyOffset" + "name": "srm_vault", + "type": "pubkey" }, { - "name": "InvalidMessageOffset" + "name": "perp_fee_structure", + "type": { + "defined": { + "name": "FeeStructure" + } + } }, { - "name": "InvalidMessageDataSize" + "name": "spot_fee_structure", + "type": { + "defined": { + "name": "FeeStructure" + } + } }, { - "name": "InvalidInstructionIndex" + "name": "oracle_guard_rails", + "type": { + "defined": { + "name": "OracleGuardRails" + } + } }, { - "name": "MessageOffsetOverflow" + "name": "number_of_authorities", + "type": "u64" }, { - "name": "InvalidMessageHex" + "name": "number_of_sub_accounts", + "type": "u64" }, { - "name": "InvalidMessageData" + "name": "lp_cooldown_time", + "type": "u64" }, { - "name": "LoadInstructionAtFailed" - } - ] - } - } - ], - "events": [ - { - "name": "NewUserRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "userAuthority", - "type": "publicKey", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "subAccountId", - "type": "u16", - "index": false - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] + "name": "liquidation_margin_buffer_ratio", + "type": "u32" }, - "index": false - }, - { - "name": "referrer", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "DepositRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "userAuthority", - "type": "publicKey", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "direction", - "type": { - "defined": "DepositDirection" + { + "name": "settlement_duration", + "type": "u16" }, - "index": false - }, - { - "name": "depositRecordId", - "type": "u64", - "index": false - }, - { - "name": "amount", - "type": "u64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "oraclePrice", - "type": "i64", - "index": false - }, - { - "name": "marketDepositBalance", - "type": "u128", - "index": false - }, - { - "name": "marketWithdrawBalance", - "type": "u128", - "index": false - }, - { - "name": "marketCumulativeDepositInterest", - "type": "u128", - "index": false - }, - { - "name": "marketCumulativeBorrowInterest", - "type": "u128", - "index": false - }, - { - "name": "totalDepositsAfter", - "type": "u64", - "index": false - }, - { - "name": "totalWithdrawsAfter", - "type": "u64", - "index": false - }, - { - "name": "explanation", - "type": { - "defined": "DepositExplanation" + { + "name": "number_of_markets", + "type": "u16" }, - "index": false - }, - { - "name": "transferUser", - "type": { - "option": "publicKey" + { + "name": "number_of_spot_markets", + "type": "u16" }, - "index": false - }, - { - "name": "signer", - "type": { - "option": "publicKey" + { + "name": "signer_nonce", + "type": "u8" }, - "index": false - }, - { - "name": "userTokenAmountAfter", - "type": "i128", - "index": false - } - ] - }, - { - "name": "SpotInterestRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "depositBalance", - "type": "u128", - "index": false - }, - { - "name": "cumulativeDepositInterest", - "type": "u128", - "index": false - }, - { - "name": "borrowBalance", - "type": "u128", - "index": false - }, - { - "name": "cumulativeBorrowInterest", - "type": "u128", - "index": false - }, - { - "name": "optimalUtilization", - "type": "u32", - "index": false - }, - { - "name": "optimalBorrowRate", - "type": "u32", - "index": false - }, - { - "name": "maxBorrowRate", - "type": "u32", - "index": false - } - ] - }, - { - "name": "FundingPaymentRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "userAuthority", - "type": "publicKey", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "fundingPayment", - "type": "i64", - "index": false - }, - { - "name": "baseAssetAmount", - "type": "i64", - "index": false - }, - { - "name": "userLastCumulativeFunding", - "type": "i64", - "index": false - }, - { - "name": "ammCumulativeFundingLong", - "type": "i128", - "index": false - }, - { - "name": "ammCumulativeFundingShort", - "type": "i128", - "index": false - } - ] - }, - { - "name": "FundingRateRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "recordId", - "type": "u64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "fundingRate", - "type": "i64", - "index": false - }, - { - "name": "fundingRateLong", - "type": "i128", - "index": false - }, - { - "name": "fundingRateShort", - "type": "i128", - "index": false - }, - { - "name": "cumulativeFundingRateLong", - "type": "i128", - "index": false - }, - { - "name": "cumulativeFundingRateShort", - "type": "i128", - "index": false - }, - { - "name": "oraclePriceTwap", - "type": "i64", - "index": false - }, - { - "name": "markPriceTwap", - "type": "u64", - "index": false - }, - { - "name": "periodRevenue", - "type": "i64", - "index": false - }, - { - "name": "baseAssetAmountWithAmm", - "type": "i128", - "index": false - }, - { - "name": "baseAssetAmountWithUnsettledLp", - "type": "i128", - "index": false - } - ] - }, - { - "name": "CurveRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "recordId", - "type": "u64", - "index": false - }, - { - "name": "pegMultiplierBefore", - "type": "u128", - "index": false - }, - { - "name": "baseAssetReserveBefore", - "type": "u128", - "index": false - }, - { - "name": "quoteAssetReserveBefore", - "type": "u128", - "index": false - }, - { - "name": "sqrtKBefore", - "type": "u128", - "index": false - }, - { - "name": "pegMultiplierAfter", - "type": "u128", - "index": false - }, - { - "name": "baseAssetReserveAfter", - "type": "u128", - "index": false - }, - { - "name": "quoteAssetReserveAfter", - "type": "u128", - "index": false - }, - { - "name": "sqrtKAfter", - "type": "u128", - "index": false - }, - { - "name": "baseAssetAmountLong", - "type": "u128", - "index": false - }, - { - "name": "baseAssetAmountShort", - "type": "u128", - "index": false - }, - { - "name": "baseAssetAmountWithAmm", - "type": "i128", - "index": false - }, - { - "name": "totalFee", - "type": "i128", - "index": false - }, - { - "name": "totalFeeMinusDistributions", - "type": "i128", - "index": false - }, - { - "name": "adjustmentCost", - "type": "i128", - "index": false - }, - { - "name": "oraclePrice", - "type": "i64", - "index": false - }, - { - "name": "fillRecord", - "type": "u128", - "index": false - }, - { - "name": "numberOfUsers", - "type": "u32", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - } - ] - }, - { - "name": "SignedMsgOrderRecord", - "fields": [ - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "hash", - "type": "string", - "index": false - }, - { - "name": "matchingOrderParams", - "type": { - "defined": "OrderParams" + { + "name": "min_perp_auction_duration", + "type": "u8" }, - "index": false - }, - { - "name": "userOrderId", - "type": "u32", - "index": false - }, - { - "name": "signedMsgOrderMaxSlot", - "type": "u64", - "index": false - }, - { - "name": "signedMsgOrderUuid", - "type": { - "array": [ - "u8", - 8 - ] + { + "name": "default_market_order_time_in_force", + "type": "u8" }, - "index": false - }, - { - "name": "ts", - "type": "i64", - "index": false - } - ] - }, - { - "name": "OrderRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "order", - "type": { - "defined": "Order" + { + "name": "default_spot_auction_duration", + "type": "u8" }, - "index": false - } - ] - }, - { - "name": "OrderActionRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "action", - "type": { - "defined": "OrderAction" + { + "name": "exchange_status", + "type": "u8" }, - "index": false - }, - { - "name": "actionExplanation", - "type": { - "defined": "OrderActionExplanation" + { + "name": "liquidation_duration", + "type": "u8" }, - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "marketType", - "type": { - "defined": "MarketType" + { + "name": "initial_pct_to_liquidate", + "type": "u16" }, - "index": false - }, - { - "name": "filler", - "type": { - "option": "publicKey" + { + "name": "max_number_of_sub_accounts", + "type": "u16" }, - "index": false - }, - { - "name": "fillerReward", - "type": { - "option": "u64" + { + "name": "max_initialize_user_fee", + "type": "u16" }, - "index": false - }, - { - "name": "fillRecordId", - "type": { - "option": "u64" + { + "name": "feature_bit_flags", + "type": "u8" }, - "index": false - }, - { - "name": "baseAssetAmountFilled", - "type": { - "option": "u64" + { + "name": "lp_pool_feature_bit_flags", + "type": "u8" }, - "index": false - }, - { - "name": "quoteAssetAmountFilled", - "type": { - "option": "u64" + { + "name": "padding", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "SwapRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, - "index": false - }, - { - "name": "takerFee", - "type": { - "option": "u64" + { + "name": "user", + "type": "pubkey" }, - "index": false - }, - { - "name": "makerFee", - "type": { - "option": "i64" + { + "name": "amount_out", + "docs": [ + "precision: out market mint precision" + ], + "type": "u64" }, - "index": false - }, - { - "name": "referrerReward", - "type": { - "option": "u32" + { + "name": "amount_in", + "docs": [ + "precision: in market mint precision" + ], + "type": "u64" }, - "index": false - }, - { - "name": "quoteAssetAmountSurplus", - "type": { - "option": "i64" + { + "name": "out_market_index", + "type": "u16" }, - "index": false - }, - { - "name": "spotFulfillmentMethodFee", - "type": { - "option": "u64" - }, - "index": false - }, - { - "name": "taker", - "type": { - "option": "publicKey" - }, - "index": false - }, - { - "name": "takerOrderId", - "type": { - "option": "u32" - }, - "index": false - }, - { - "name": "takerOrderDirection", - "type": { - "option": { - "defined": "PositionDirection" - } - }, - "index": false - }, - { - "name": "takerOrderBaseAssetAmount", - "type": { - "option": "u64" + { + "name": "in_market_index", + "type": "u16" }, - "index": false - }, - { - "name": "takerOrderCumulativeBaseAssetAmountFilled", - "type": { - "option": "u64" + { + "name": "out_oracle_price", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" }, - "index": false - }, - { - "name": "takerOrderCumulativeQuoteAssetAmountFilled", - "type": { - "option": "u64" + { + "name": "in_oracle_price", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" }, - "index": false - }, - { - "name": "maker", - "type": { - "option": "publicKey" + { + "name": "fee", + "type": "u64" + } + ] + } + }, + { + "name": "SwapReduceOnly", + "type": { + "kind": "enum", + "variants": [ + { + "name": "In" }, - "index": false - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" + { + "name": "Out" + } + ] + } + }, + { + "name": "TargetsDatum", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "cost_to_trade_bps", + "type": "i32" }, - "index": false - }, - { - "name": "makerOrderDirection", - "type": { - "option": { - "defined": "PositionDirection" + { + "name": "_padding", + "type": { + "array": [ + "u8", + 4 + ] } }, - "index": false - }, - { - "name": "makerOrderBaseAssetAmount", - "type": { - "option": "u64" - }, - "index": false - }, - { - "name": "makerOrderCumulativeBaseAssetAmountFilled", - "type": { - "option": "u64" - }, - "index": false - }, - { - "name": "makerOrderCumulativeQuoteAssetAmountFilled", - "type": { - "option": "u64" + { + "name": "target_base", + "type": "i64" }, - "index": false - }, - { - "name": "oraclePrice", - "type": "i64", - "index": false - }, - { - "name": "bitFlags", - "type": "u8", - "index": false - }, - { - "name": "takerExistingQuoteEntryAmount", - "type": { - "option": "u64" + { + "name": "last_oracle_slot", + "type": "u64" }, - "index": false - }, - { - "name": "takerExistingBaseAssetAmount", - "type": { - "option": "u64" + { + "name": "last_position_slot", + "type": "u64" + } + ] + } + }, + { + "name": "TransferProtocolIfSharesToRevenuePoolRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, - "index": false - }, - { - "name": "makerExistingQuoteEntryAmount", - "type": { - "option": "u64" + { + "name": "market_index", + "type": "u16" }, - "index": false - }, - { - "name": "makerExistingBaseAssetAmount", - "type": { - "option": "u64" + { + "name": "amount", + "type": "u64" }, - "index": false - }, - { - "name": "triggerPrice", - "type": { - "option": "u64" + { + "name": "shares", + "type": "u128" }, - "index": false - }, - { - "name": "builderIdx", - "type": { - "option": "u8" + { + "name": "if_vault_amount_before", + "type": "u64" }, - "index": false - }, - { - "name": "builderFee", - "type": { - "option": "u64" + { + "name": "protocol_shares_before", + "type": "u128" }, - "index": false - } - ] + { + "name": "transfer_amount", + "type": "u64" + } + ] + } }, { - "name": "LPRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "action", - "type": { - "defined": "LPAction" + "name": "UpdatePerpMarketSummaryStatsParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quote_asset_amount_with_unsettled_lp", + "type": { + "option": "i64" + } }, - "index": false - }, - { - "name": "nShares", - "type": "u64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "deltaBaseAssetAmount", - "type": "i64", - "index": false - }, - { - "name": "deltaQuoteAssetAmount", - "type": "i64", - "index": false - }, - { - "name": "pnl", - "type": "i64", - "index": false - } - ] + { + "name": "net_unsettled_funding_pnl", + "type": { + "option": "i64" + } + }, + { + "name": "update_amm_summary_stats", + "type": { + "option": "bool" + } + }, + { + "name": "exclude_total_liq_fee", + "type": { + "option": "bool" + } + } + ] + } }, { - "name": "LiquidationRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "liquidationType", - "type": { - "defined": "LiquidationType" - }, - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "liquidator", - "type": "publicKey", - "index": false - }, - { - "name": "marginRequirement", - "type": "u128", - "index": false - }, - { - "name": "totalCollateral", - "type": "i128", - "index": false - }, - { - "name": "marginFreed", - "type": "u64", - "index": false - }, - { - "name": "liquidationId", - "type": "u16", - "index": false - }, - { - "name": "bankrupt", - "type": "bool", - "index": false - }, - { - "name": "canceledOrderIds", - "type": { - "vec": "u32" + "name": "User", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The owner/authority of the account" + ], + "type": "pubkey" }, - "index": false - }, - { - "name": "liquidatePerp", - "type": { - "defined": "LiquidatePerpRecord" + { + "name": "delegate", + "docs": [ + "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw" + ], + "type": "pubkey" }, - "index": false - }, - { - "name": "liquidateSpot", - "type": { - "defined": "LiquidateSpotRecord" + { + "name": "name", + "docs": [ + "Encoded display name e.g. \"toly\"" + ], + "type": { + "array": [ + "u8", + 32 + ] + } }, - "index": false - }, - { - "name": "liquidateBorrowForPerpPnl", - "type": { - "defined": "LiquidateBorrowForPerpPnlRecord" + { + "name": "spot_positions", + "docs": [ + "The user's spot positions" + ], + "type": { + "array": [ + { + "defined": { + "name": "SpotPosition" + } + }, + 8 + ] + } }, - "index": false - }, - { - "name": "liquidatePerpPnlForDeposit", - "type": { - "defined": "LiquidatePerpPnlForDepositRecord" + { + "name": "perp_positions", + "docs": [ + "The user's perp positions" + ], + "type": { + "array": [ + { + "defined": { + "name": "PerpPosition" + } + }, + 8 + ] + } }, - "index": false - }, - { - "name": "perpBankruptcy", - "type": { - "defined": "PerpBankruptcyRecord" + { + "name": "orders", + "docs": [ + "The user's orders" + ], + "type": { + "array": [ + { + "defined": { + "name": "Order" + } + }, + 32 + ] + } }, - "index": false - }, - { - "name": "spotBankruptcy", - "type": { - "defined": "SpotBankruptcyRecord" + { + "name": "last_add_perp_lp_shares_ts", + "docs": [ + "The last time the user added perp lp positions" + ], + "type": "i64" }, - "index": false - } - ] - }, - { - "name": "SettlePnlRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "pnl", - "type": "i128", - "index": false - }, - { - "name": "baseAssetAmount", - "type": "i64", - "index": false - }, - { - "name": "quoteAssetAmountAfter", - "type": "i64", - "index": false - }, - { - "name": "quoteEntryAmount", - "type": "i64", - "index": false - }, - { - "name": "settlePrice", - "type": "i64", - "index": false - }, - { - "name": "explanation", - "type": { - "defined": "SettlePnlExplanation" + { + "name": "total_deposits", + "docs": [ + "The total values of deposits the user has made", + "precision: QUOTE_PRECISION" + ], + "type": "u64" }, - "index": false - } - ] + { + "name": "total_withdraws", + "docs": [ + "The total values of withdrawals the user has made", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "total_social_loss", + "docs": [ + "The total socialized loss the users has incurred upon the protocol", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "settled_perp_pnl", + "docs": [ + "Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "cumulative_spot_fees", + "docs": [ + "Fees (taker fees, maker rebate, filler reward) for spot", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "cumulative_perp_funding", + "docs": [ + "Cumulative funding paid/received for perps", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "liquidation_margin_freed", + "docs": [ + "The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time", + "Defaults to zero when not being liquidated", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "last_active_slot", + "docs": [ + "The last slot a user was active. Used to determine if a user is idle" + ], + "type": "u64" + }, + { + "name": "next_order_id", + "docs": [ + "Every user order has an order id. This is the next order id to be used" + ], + "type": "u32" + }, + { + "name": "max_margin_ratio", + "docs": [ + "Custom max initial margin ratio for the user" + ], + "type": "u32" + }, + { + "name": "next_liquidation_id", + "docs": [ + "The next liquidation id to be used for user" + ], + "type": "u16" + }, + { + "name": "sub_account_id", + "docs": [ + "The sub account id for this user" + ], + "type": "u16" + }, + { + "name": "status", + "docs": [ + "Whether the user is active, being liquidated or bankrupt" + ], + "type": "u8" + }, + { + "name": "is_margin_trading_enabled", + "docs": [ + "Whether the user has enabled margin trading" + ], + "type": "bool" + }, + { + "name": "idle", + "docs": [ + "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", + "Off-chain keeper bots can ignore users that are idle" + ], + "type": "bool" + }, + { + "name": "open_orders", + "docs": [ + "number of open orders" + ], + "type": "u8" + }, + { + "name": "has_open_order", + "docs": [ + "Whether or not user has open order" + ], + "type": "bool" + }, + { + "name": "open_auctions", + "docs": [ + "number of open orders with auction" + ], + "type": "u8" + }, + { + "name": "has_open_auction", + "docs": [ + "Whether or not user has open order with auction" + ], + "type": "bool" + }, + { + "name": "margin_mode", + "type": { + "defined": { + "name": "MarginMode" + } + } + }, + { + "name": "pool_id", + "type": "u8" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "last_fuel_bonus_update_ts", + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 12 + ] + } + } + ] + } }, { - "name": "InsuranceFundRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "spotMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "perpMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "userIfFactor", - "type": "u32", - "index": false - }, - { - "name": "totalIfFactor", - "type": "u32", - "index": false - }, - { - "name": "vaultAmountBefore", - "type": "u64", - "index": false - }, - { - "name": "insuranceVaultAmountBefore", - "type": "u64", - "index": false - }, - { - "name": "totalIfSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "totalIfSharesAfter", - "type": "u128", - "index": false - }, - { - "name": "amount", - "type": "i64", - "index": false - } - ] - }, - { - "name": "InsuranceFundStakeRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "userAuthority", - "type": "publicKey", - "index": false - }, - { - "name": "action", - "type": { - "defined": "StakeAction" - }, - "index": false - }, - { - "name": "amount", - "type": "u64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "insuranceVaultAmountBefore", - "type": "u64", - "index": false - }, - { - "name": "ifSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "userIfSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "totalIfSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "ifSharesAfter", - "type": "u128", - "index": false - }, - { - "name": "userIfSharesAfter", - "type": "u128", - "index": false - }, - { - "name": "totalIfSharesAfter", - "type": "u128", - "index": false - } - ] - }, - { - "name": "InsuranceFundSwapRecord", - "fields": [ - { - "name": "rebalanceConfig", - "type": "publicKey", - "index": false - }, - { - "name": "inIfTotalSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "outIfTotalSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "inIfUserSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "outIfUserSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "inIfTotalSharesAfter", - "type": "u128", - "index": false - }, - { - "name": "outIfTotalSharesAfter", - "type": "u128", - "index": false - }, - { - "name": "inIfUserSharesAfter", - "type": "u128", - "index": false - }, - { - "name": "outIfUserSharesAfter", - "type": "u128", - "index": false - }, - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "inAmount", - "type": "u64", - "index": false - }, - { - "name": "outAmount", - "type": "u64", - "index": false - }, - { - "name": "outOraclePrice", - "type": "u64", - "index": false - }, - { - "name": "outOraclePriceTwap", - "type": "i64", - "index": false - }, - { - "name": "inVaultAmountBefore", - "type": "u64", - "index": false - }, - { - "name": "outVaultAmountBefore", - "type": "u64", - "index": false - }, - { - "name": "inFundVaultAmountAfter", - "type": "u64", - "index": false - }, - { - "name": "outFundVaultAmountAfter", - "type": "u64", - "index": false - }, - { - "name": "inMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "outMarketIndex", - "type": "u16", - "index": false - } - ] - }, - { - "name": "TransferProtocolIfSharesToRevenuePoolRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "amount", - "type": "u64", - "index": false - }, - { - "name": "shares", - "type": "u128", - "index": false - }, - { - "name": "ifVaultAmountBefore", - "type": "u64", - "index": false - }, - { - "name": "protocolSharesBefore", - "type": "u128", - "index": false - }, - { - "name": "transferAmount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "SwapRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "amountOut", - "type": "u64", - "index": false - }, - { - "name": "amountIn", - "type": "u64", - "index": false - }, - { - "name": "outMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "inMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "outOraclePrice", - "type": "i64", - "index": false - }, - { - "name": "inOraclePrice", - "type": "i64", - "index": false - }, - { - "name": "fee", - "type": "u64", - "index": false - } - ] - }, - { - "name": "SpotMarketVaultDepositRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "depositBalance", - "type": "u128", - "index": false - }, - { - "name": "cumulativeDepositInterestBefore", - "type": "u128", - "index": false - }, - { - "name": "cumulativeDepositInterestAfter", - "type": "u128", - "index": false - }, - { - "name": "depositTokenAmountBefore", - "type": "u64", - "index": false - }, - { - "name": "amount", - "type": "u64", - "index": false - } - ] - }, - { - "name": "DeleteUserRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "userAuthority", - "type": "publicKey", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "subAccountId", - "type": "u16", - "index": false - }, - { - "name": "keeper", - "type": { - "option": "publicKey" - }, - "index": false - } - ] - }, - { - "name": "FuelSweepRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "authority", - "type": "publicKey", - "index": false - }, - { - "name": "userStatsFuelInsurance", - "type": "u32", - "index": false - }, - { - "name": "userStatsFuelDeposits", - "type": "u32", - "index": false - }, - { - "name": "userStatsFuelBorrows", - "type": "u32", - "index": false - }, - { - "name": "userStatsFuelPositions", - "type": "u32", - "index": false - }, - { - "name": "userStatsFuelTaker", - "type": "u32", - "index": false - }, - { - "name": "userStatsFuelMaker", - "type": "u32", - "index": false - }, - { - "name": "fuelOverflowFuelInsurance", - "type": "u128", - "index": false - }, - { - "name": "fuelOverflowFuelDeposits", - "type": "u128", - "index": false - }, - { - "name": "fuelOverflowFuelBorrows", - "type": "u128", - "index": false - }, - { - "name": "fuelOverflowFuelPositions", - "type": "u128", - "index": false - }, - { - "name": "fuelOverflowFuelTaker", - "type": "u128", - "index": false - }, - { - "name": "fuelOverflowFuelMaker", - "type": "u128", - "index": false - } - ] - }, - { - "name": "FuelSeasonRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "authority", - "type": "publicKey", - "index": false - }, - { - "name": "fuelInsurance", - "type": "u128", - "index": false - }, - { - "name": "fuelDeposits", - "type": "u128", - "index": false - }, - { - "name": "fuelBorrows", - "type": "u128", - "index": false - }, - { - "name": "fuelPositions", - "type": "u128", - "index": false - }, - { - "name": "fuelTaker", - "type": "u128", - "index": false - }, - { - "name": "fuelMaker", - "type": "u128", - "index": false - }, - { - "name": "fuelTotal", - "type": "u128", - "index": false - } - ] - }, - { - "name": "RevenueShareSettleRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "builder", - "type": { - "option": "publicKey" - }, - "index": false - }, - { - "name": "referrer", - "type": { - "option": "publicKey" - }, - "index": false - }, - { - "name": "feeSettled", - "type": "u64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "marketType", - "type": { - "defined": "MarketType" - }, - "index": false - }, - { - "name": "builderSubAccountId", - "type": "u16", - "index": false - }, - { - "name": "builderTotalReferrerRewards", - "type": "u64", - "index": false - }, - { - "name": "builderTotalBuilderRewards", - "type": "u64", - "index": false - } - ] - }, - { - "name": "LPSettleRecord", - "fields": [ - { - "name": "recordId", - "type": "u64", - "index": false - }, - { - "name": "lastTs", - "type": "i64", - "index": false - }, - { - "name": "lastSlot", - "type": "u64", - "index": false - }, - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "slot", - "type": "u64", - "index": false - }, - { - "name": "perpMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "settleToLpAmount", - "type": "i64", - "index": false - }, - { - "name": "perpAmmPnlDelta", - "type": "i64", - "index": false - }, - { - "name": "perpAmmExFeeDelta", - "type": "i64", - "index": false - }, - { - "name": "lpAum", - "type": "u128", - "index": false - }, - { - "name": "lpPrice", - "type": "u128", - "index": false - }, - { - "name": "lpPool", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "LPSwapRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "slot", - "type": "u64", - "index": false - }, - { - "name": "authority", - "type": "publicKey", - "index": false - }, - { - "name": "outAmount", - "type": "u128", - "index": false - }, - { - "name": "inAmount", - "type": "u128", - "index": false - }, - { - "name": "outFee", - "type": "i128", - "index": false - }, - { - "name": "inFee", - "type": "i128", - "index": false - }, - { - "name": "outSpotMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "inSpotMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "outConstituentIndex", - "type": "u16", - "index": false - }, - { - "name": "inConstituentIndex", - "type": "u16", - "index": false - }, - { - "name": "outOraclePrice", - "type": "i64", - "index": false - }, - { - "name": "inOraclePrice", - "type": "i64", - "index": false - }, - { - "name": "lastAum", - "type": "u128", - "index": false - }, - { - "name": "lastAumSlot", - "type": "u64", - "index": false - }, - { - "name": "inMarketCurrentWeight", - "type": "i64", - "index": false - }, - { - "name": "outMarketCurrentWeight", - "type": "i64", - "index": false - }, - { - "name": "inMarketTargetWeight", - "type": "i64", - "index": false - }, - { - "name": "outMarketTargetWeight", - "type": "i64", - "index": false - }, - { - "name": "inSwapId", - "type": "u64", - "index": false - }, - { - "name": "outSwapId", - "type": "u64", - "index": false - }, - { - "name": "lpPool", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "LPMintRedeemRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "slot", - "type": "u64", - "index": false - }, - { - "name": "authority", - "type": "publicKey", - "index": false - }, - { - "name": "description", - "type": "u8", - "index": false - }, - { - "name": "amount", - "type": "u128", - "index": false - }, - { - "name": "fee", - "type": "i128", - "index": false - }, - { - "name": "spotMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "constituentIndex", - "type": "u16", - "index": false - }, - { - "name": "oraclePrice", - "type": "i64", - "index": false - }, - { - "name": "mint", - "type": "publicKey", - "index": false - }, - { - "name": "lpAmount", - "type": "u64", - "index": false - }, - { - "name": "lpFee", - "type": "i64", - "index": false - }, - { - "name": "lpPrice", - "type": "u128", - "index": false - }, - { - "name": "mintRedeemId", - "type": "u64", - "index": false - }, - { - "name": "lastAum", - "type": "u128", - "index": false - }, - { - "name": "lastAumSlot", - "type": "u64", - "index": false - }, - { - "name": "inMarketCurrentWeight", - "type": "i64", - "index": false - }, - { - "name": "inMarketTargetWeight", - "type": "i64", - "index": false - }, - { - "name": "lpPool", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "LPBorrowLendDepositRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "slot", - "type": "u64", - "index": false - }, - { - "name": "spotMarketIndex", - "type": "u16", - "index": false - }, - { - "name": "constituentIndex", - "type": "u16", - "index": false - }, - { - "name": "direction", - "type": { - "defined": "DepositDirection" - }, - "index": false - }, - { - "name": "tokenBalance", - "type": "i64", - "index": false - }, - { - "name": "lastTokenBalance", - "type": "i64", - "index": false - }, - { - "name": "interestAccruedTokenAmount", - "type": "i64", - "index": false - }, - { - "name": "amountDepositWithdraw", - "type": "u64", - "index": false - }, - { - "name": "lpPool", - "type": "publicKey", - "index": false - } - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidSpotMarketAuthority", - "msg": "Invalid Spot Market Authority" - }, - { - "code": 6001, - "name": "InvalidInsuranceFundAuthority", - "msg": "Clearing house not insurance fund authority" - }, - { - "code": 6002, - "name": "InsufficientDeposit", - "msg": "Insufficient deposit" - }, - { - "code": 6003, - "name": "InsufficientCollateral", - "msg": "Insufficient collateral" - }, - { - "code": 6004, - "name": "SufficientCollateral", - "msg": "Sufficient collateral" - }, - { - "code": 6005, - "name": "MaxNumberOfPositions", - "msg": "Max number of positions taken" - }, - { - "code": 6006, - "name": "AdminControlsPricesDisabled", - "msg": "Admin Controls Prices Disabled" - }, - { - "code": 6007, - "name": "MarketDelisted", - "msg": "Market Delisted" - }, - { - "code": 6008, - "name": "MarketIndexAlreadyInitialized", - "msg": "Market Index Already Initialized" - }, - { - "code": 6009, - "name": "UserAccountAndUserPositionsAccountMismatch", - "msg": "User Account And User Positions Account Mismatch" - }, - { - "code": 6010, - "name": "UserHasNoPositionInMarket", - "msg": "User Has No Position In Market" - }, - { - "code": 6011, - "name": "InvalidInitialPeg", - "msg": "Invalid Initial Peg" - }, - { - "code": 6012, - "name": "InvalidRepegRedundant", - "msg": "AMM repeg already configured with amt given" - }, - { - "code": 6013, - "name": "InvalidRepegDirection", - "msg": "AMM repeg incorrect repeg direction" - }, - { - "code": 6014, - "name": "InvalidRepegProfitability", - "msg": "AMM repeg out of bounds pnl" - }, - { - "code": 6015, - "name": "SlippageOutsideLimit", - "msg": "Slippage Outside Limit Price" - }, - { - "code": 6016, - "name": "OrderSizeTooSmall", - "msg": "Order Size Too Small" - }, - { - "code": 6017, - "name": "InvalidUpdateK", - "msg": "Price change too large when updating K" - }, - { - "code": 6018, - "name": "AdminWithdrawTooLarge", - "msg": "Admin tried to withdraw amount larger than fees collected" - }, - { - "code": 6019, - "name": "MathError", - "msg": "Math Error" - }, - { - "code": 6020, - "name": "BnConversionError", - "msg": "Conversion to u128/u64 failed with an overflow or underflow" - }, - { - "code": 6021, - "name": "ClockUnavailable", - "msg": "Clock unavailable" - }, - { - "code": 6022, - "name": "UnableToLoadOracle", - "msg": "Unable To Load Oracles" - }, - { - "code": 6023, - "name": "PriceBandsBreached", - "msg": "Price Bands Breached" - }, - { - "code": 6024, - "name": "ExchangePaused", - "msg": "Exchange is paused" - }, - { - "code": 6025, - "name": "InvalidWhitelistToken", - "msg": "Invalid whitelist token" - }, - { - "code": 6026, - "name": "WhitelistTokenNotFound", - "msg": "Whitelist token not found" - }, - { - "code": 6027, - "name": "InvalidDiscountToken", - "msg": "Invalid discount token" - }, - { - "code": 6028, - "name": "DiscountTokenNotFound", - "msg": "Discount token not found" - }, - { - "code": 6029, - "name": "ReferrerNotFound", - "msg": "Referrer not found" - }, - { - "code": 6030, - "name": "ReferrerStatsNotFound", - "msg": "ReferrerNotFound" - }, - { - "code": 6031, - "name": "ReferrerMustBeWritable", - "msg": "ReferrerMustBeWritable" - }, - { - "code": 6032, - "name": "ReferrerStatsMustBeWritable", - "msg": "ReferrerMustBeWritable" - }, - { - "code": 6033, - "name": "ReferrerAndReferrerStatsAuthorityUnequal", - "msg": "ReferrerAndReferrerStatsAuthorityUnequal" - }, - { - "code": 6034, - "name": "InvalidReferrer", - "msg": "InvalidReferrer" - }, - { - "code": 6035, - "name": "InvalidOracle", - "msg": "InvalidOracle" - }, - { - "code": 6036, - "name": "OracleNotFound", - "msg": "OracleNotFound" - }, - { - "code": 6037, - "name": "LiquidationsBlockedByOracle", - "msg": "Liquidations Blocked By Oracle" - }, - { - "code": 6038, - "name": "MaxDeposit", - "msg": "Can not deposit more than max deposit" - }, - { - "code": 6039, - "name": "CantDeleteUserWithCollateral", - "msg": "Can not delete user that still has collateral" - }, - { - "code": 6040, - "name": "InvalidFundingProfitability", - "msg": "AMM funding out of bounds pnl" - }, - { - "code": 6041, - "name": "CastingFailure", - "msg": "Casting Failure" - }, - { - "code": 6042, - "name": "InvalidOrder", - "msg": "InvalidOrder" - }, - { - "code": 6043, - "name": "InvalidOrderMaxTs", - "msg": "InvalidOrderMaxTs" - }, - { - "code": 6044, - "name": "InvalidOrderMarketType", - "msg": "InvalidOrderMarketType" - }, - { - "code": 6045, - "name": "InvalidOrderForInitialMarginReq", - "msg": "InvalidOrderForInitialMarginReq" - }, - { - "code": 6046, - "name": "InvalidOrderNotRiskReducing", - "msg": "InvalidOrderNotRiskReducing" - }, - { - "code": 6047, - "name": "InvalidOrderSizeTooSmall", - "msg": "InvalidOrderSizeTooSmall" - }, - { - "code": 6048, - "name": "InvalidOrderNotStepSizeMultiple", - "msg": "InvalidOrderNotStepSizeMultiple" - }, - { - "code": 6049, - "name": "InvalidOrderBaseQuoteAsset", - "msg": "InvalidOrderBaseQuoteAsset" - }, - { - "code": 6050, - "name": "InvalidOrderIOC", - "msg": "InvalidOrderIOC" - }, - { - "code": 6051, - "name": "InvalidOrderPostOnly", - "msg": "InvalidOrderPostOnly" - }, - { - "code": 6052, - "name": "InvalidOrderIOCPostOnly", - "msg": "InvalidOrderIOCPostOnly" - }, - { - "code": 6053, - "name": "InvalidOrderTrigger", - "msg": "InvalidOrderTrigger" - }, - { - "code": 6054, - "name": "InvalidOrderAuction", - "msg": "InvalidOrderAuction" - }, - { - "code": 6055, - "name": "InvalidOrderOracleOffset", - "msg": "InvalidOrderOracleOffset" - }, - { - "code": 6056, - "name": "InvalidOrderMinOrderSize", - "msg": "InvalidOrderMinOrderSize" - }, - { - "code": 6057, - "name": "PlacePostOnlyLimitFailure", - "msg": "Failed to Place Post-Only Limit Order" - }, - { - "code": 6058, - "name": "UserHasNoOrder", - "msg": "User has no order" - }, - { - "code": 6059, - "name": "OrderAmountTooSmall", - "msg": "Order Amount Too Small" - }, - { - "code": 6060, - "name": "MaxNumberOfOrders", - "msg": "Max number of orders taken" - }, - { - "code": 6061, - "name": "OrderDoesNotExist", - "msg": "Order does not exist" - }, - { - "code": 6062, - "name": "OrderNotOpen", - "msg": "Order not open" - }, - { - "code": 6063, - "name": "FillOrderDidNotUpdateState", - "msg": "FillOrderDidNotUpdateState" - }, - { - "code": 6064, - "name": "ReduceOnlyOrderIncreasedRisk", - "msg": "Reduce only order increased risk" - }, - { - "code": 6065, - "name": "UnableToLoadAccountLoader", - "msg": "Unable to load AccountLoader" - }, - { - "code": 6066, - "name": "TradeSizeTooLarge", - "msg": "Trade Size Too Large" - }, - { - "code": 6067, - "name": "UserCantReferThemselves", - "msg": "User cant refer themselves" - }, - { - "code": 6068, - "name": "DidNotReceiveExpectedReferrer", - "msg": "Did not receive expected referrer" - }, - { - "code": 6069, - "name": "CouldNotDeserializeReferrer", - "msg": "Could not deserialize referrer" - }, - { - "code": 6070, - "name": "CouldNotDeserializeReferrerStats", - "msg": "Could not deserialize referrer stats" - }, - { - "code": 6071, - "name": "UserOrderIdAlreadyInUse", - "msg": "User Order Id Already In Use" - }, - { - "code": 6072, - "name": "NoPositionsLiquidatable", - "msg": "No positions liquidatable" - }, - { - "code": 6073, - "name": "InvalidMarginRatio", - "msg": "Invalid Margin Ratio" - }, - { - "code": 6074, - "name": "CantCancelPostOnlyOrder", - "msg": "Cant Cancel Post Only Order" - }, - { - "code": 6075, - "name": "InvalidOracleOffset", - "msg": "InvalidOracleOffset" - }, - { - "code": 6076, - "name": "CantExpireOrders", - "msg": "CantExpireOrders" - }, - { - "code": 6077, - "name": "CouldNotLoadMarketData", - "msg": "CouldNotLoadMarketData" - }, - { - "code": 6078, - "name": "PerpMarketNotFound", - "msg": "PerpMarketNotFound" - }, - { - "code": 6079, - "name": "InvalidMarketAccount", - "msg": "InvalidMarketAccount" - }, - { - "code": 6080, - "name": "UnableToLoadPerpMarketAccount", - "msg": "UnableToLoadMarketAccount" - }, - { - "code": 6081, - "name": "MarketWrongMutability", - "msg": "MarketWrongMutability" - }, - { - "code": 6082, - "name": "UnableToCastUnixTime", - "msg": "UnableToCastUnixTime" - }, - { - "code": 6083, - "name": "CouldNotFindSpotPosition", - "msg": "CouldNotFindSpotPosition" - }, - { - "code": 6084, - "name": "NoSpotPositionAvailable", - "msg": "NoSpotPositionAvailable" - }, - { - "code": 6085, - "name": "InvalidSpotMarketInitialization", - "msg": "InvalidSpotMarketInitialization" - }, - { - "code": 6086, - "name": "CouldNotLoadSpotMarketData", - "msg": "CouldNotLoadSpotMarketData" - }, - { - "code": 6087, - "name": "SpotMarketNotFound", - "msg": "SpotMarketNotFound" - }, - { - "code": 6088, - "name": "InvalidSpotMarketAccount", - "msg": "InvalidSpotMarketAccount" - }, - { - "code": 6089, - "name": "UnableToLoadSpotMarketAccount", - "msg": "UnableToLoadSpotMarketAccount" - }, - { - "code": 6090, - "name": "SpotMarketWrongMutability", - "msg": "SpotMarketWrongMutability" - }, - { - "code": 6091, - "name": "SpotMarketInterestNotUpToDate", - "msg": "SpotInterestNotUpToDate" - }, - { - "code": 6092, - "name": "SpotMarketInsufficientDeposits", - "msg": "SpotMarketInsufficientDeposits" - }, - { - "code": 6093, - "name": "UserMustSettleTheirOwnPositiveUnsettledPNL", - "msg": "UserMustSettleTheirOwnPositiveUnsettledPNL" - }, - { - "code": 6094, - "name": "CantUpdatePoolBalanceType", - "msg": "CantUpdatePoolBalanceType" - }, - { - "code": 6095, - "name": "InsufficientCollateralForSettlingPNL", - "msg": "InsufficientCollateralForSettlingPNL" - }, - { - "code": 6096, - "name": "AMMNotUpdatedInSameSlot", - "msg": "AMMNotUpdatedInSameSlot" - }, - { - "code": 6097, - "name": "AuctionNotComplete", - "msg": "AuctionNotComplete" - }, - { - "code": 6098, - "name": "MakerNotFound", - "msg": "MakerNotFound" - }, - { - "code": 6099, - "name": "MakerStatsNotFound", - "msg": "MakerNotFound" - }, - { - "code": 6100, - "name": "MakerMustBeWritable", - "msg": "MakerMustBeWritable" - }, - { - "code": 6101, - "name": "MakerStatsMustBeWritable", - "msg": "MakerMustBeWritable" - }, - { - "code": 6102, - "name": "MakerOrderNotFound", - "msg": "MakerOrderNotFound" - }, - { - "code": 6103, - "name": "CouldNotDeserializeMaker", - "msg": "CouldNotDeserializeMaker" - }, - { - "code": 6104, - "name": "CouldNotDeserializeMakerStats", - "msg": "CouldNotDeserializeMaker" - }, - { - "code": 6105, - "name": "AuctionPriceDoesNotSatisfyMaker", - "msg": "AuctionPriceDoesNotSatisfyMaker" - }, - { - "code": 6106, - "name": "MakerCantFulfillOwnOrder", - "msg": "MakerCantFulfillOwnOrder" - }, - { - "code": 6107, - "name": "MakerOrderMustBePostOnly", - "msg": "MakerOrderMustBePostOnly" - }, - { - "code": 6108, - "name": "CantMatchTwoPostOnlys", - "msg": "CantMatchTwoPostOnlys" - }, - { - "code": 6109, - "name": "OrderBreachesOraclePriceLimits", - "msg": "OrderBreachesOraclePriceLimits" - }, - { - "code": 6110, - "name": "OrderMustBeTriggeredFirst", - "msg": "OrderMustBeTriggeredFirst" - }, - { - "code": 6111, - "name": "OrderNotTriggerable", - "msg": "OrderNotTriggerable" - }, - { - "code": 6112, - "name": "OrderDidNotSatisfyTriggerCondition", - "msg": "OrderDidNotSatisfyTriggerCondition" - }, - { - "code": 6113, - "name": "PositionAlreadyBeingLiquidated", - "msg": "PositionAlreadyBeingLiquidated" - }, - { - "code": 6114, - "name": "PositionDoesntHaveOpenPositionOrOrders", - "msg": "PositionDoesntHaveOpenPositionOrOrders" - }, - { - "code": 6115, - "name": "AllOrdersAreAlreadyLiquidations", - "msg": "AllOrdersAreAlreadyLiquidations" - }, - { - "code": 6116, - "name": "CantCancelLiquidationOrder", - "msg": "CantCancelLiquidationOrder" - }, - { - "code": 6117, - "name": "UserIsBeingLiquidated", - "msg": "UserIsBeingLiquidated" - }, - { - "code": 6118, - "name": "LiquidationsOngoing", - "msg": "LiquidationsOngoing" - }, - { - "code": 6119, - "name": "WrongSpotBalanceType", - "msg": "WrongSpotBalanceType" - }, - { - "code": 6120, - "name": "UserCantLiquidateThemself", - "msg": "UserCantLiquidateThemself" - }, - { - "code": 6121, - "name": "InvalidPerpPositionToLiquidate", - "msg": "InvalidPerpPositionToLiquidate" - }, - { - "code": 6122, - "name": "InvalidBaseAssetAmountForLiquidatePerp", - "msg": "InvalidBaseAssetAmountForLiquidatePerp" - }, - { - "code": 6123, - "name": "InvalidPositionLastFundingRate", - "msg": "InvalidPositionLastFundingRate" - }, - { - "code": 6124, - "name": "InvalidPositionDelta", - "msg": "InvalidPositionDelta" - }, - { - "code": 6125, - "name": "UserBankrupt", - "msg": "UserBankrupt" - }, - { - "code": 6126, - "name": "UserNotBankrupt", - "msg": "UserNotBankrupt" - }, - { - "code": 6127, - "name": "UserHasInvalidBorrow", - "msg": "UserHasInvalidBorrow" - }, - { - "code": 6128, - "name": "DailyWithdrawLimit", - "msg": "DailyWithdrawLimit" - }, - { - "code": 6129, - "name": "DefaultError", - "msg": "DefaultError" - }, - { - "code": 6130, - "name": "InsufficientLPTokens", - "msg": "Insufficient LP tokens" - }, - { - "code": 6131, - "name": "CantLPWithPerpPosition", - "msg": "Cant LP with a market position" - }, - { - "code": 6132, - "name": "UnableToBurnLPTokens", - "msg": "Unable to burn LP tokens" - }, - { - "code": 6133, - "name": "TryingToRemoveLiquidityTooFast", - "msg": "Trying to remove liqudity too fast after adding it" - }, - { - "code": 6134, - "name": "InvalidSpotMarketVault", - "msg": "Invalid Spot Market Vault" - }, - { - "code": 6135, - "name": "InvalidSpotMarketState", - "msg": "Invalid Spot Market State" - }, - { - "code": 6136, - "name": "InvalidSerumProgram", - "msg": "InvalidSerumProgram" - }, - { - "code": 6137, - "name": "InvalidSerumMarket", - "msg": "InvalidSerumMarket" - }, - { - "code": 6138, - "name": "InvalidSerumBids", - "msg": "InvalidSerumBids" - }, - { - "code": 6139, - "name": "InvalidSerumAsks", - "msg": "InvalidSerumAsks" - }, - { - "code": 6140, - "name": "InvalidSerumOpenOrders", - "msg": "InvalidSerumOpenOrders" - }, - { - "code": 6141, - "name": "FailedSerumCPI", - "msg": "FailedSerumCPI" - }, - { - "code": 6142, - "name": "FailedToFillOnExternalMarket", - "msg": "FailedToFillOnExternalMarket" - }, - { - "code": 6143, - "name": "InvalidFulfillmentConfig", - "msg": "InvalidFulfillmentConfig" - }, - { - "code": 6144, - "name": "InvalidFeeStructure", - "msg": "InvalidFeeStructure" - }, - { - "code": 6145, - "name": "InsufficientIFShares", - "msg": "Insufficient IF shares" - }, - { - "code": 6146, - "name": "MarketActionPaused", - "msg": "the Market has paused this action" - }, - { - "code": 6147, - "name": "MarketPlaceOrderPaused", - "msg": "the Market status doesnt allow placing orders" - }, - { - "code": 6148, - "name": "MarketFillOrderPaused", - "msg": "the Market status doesnt allow filling orders" - }, - { - "code": 6149, - "name": "MarketWithdrawPaused", - "msg": "the Market status doesnt allow withdraws" - }, - { - "code": 6150, - "name": "ProtectedAssetTierViolation", - "msg": "Action violates the Protected Asset Tier rules" - }, - { - "code": 6151, - "name": "IsolatedAssetTierViolation", - "msg": "Action violates the Isolated Asset Tier rules" - }, - { - "code": 6152, - "name": "UserCantBeDeleted", - "msg": "User Cant Be Deleted" - }, - { - "code": 6153, - "name": "ReduceOnlyWithdrawIncreasedRisk", - "msg": "Reduce Only Withdraw Increased Risk" - }, - { - "code": 6154, - "name": "MaxOpenInterest", - "msg": "Max Open Interest" - }, - { - "code": 6155, - "name": "CantResolvePerpBankruptcy", - "msg": "Cant Resolve Perp Bankruptcy" - }, - { - "code": 6156, - "name": "LiquidationDoesntSatisfyLimitPrice", - "msg": "Liquidation Doesnt Satisfy Limit Price" - }, - { - "code": 6157, - "name": "MarginTradingDisabled", - "msg": "Margin Trading Disabled" - }, - { - "code": 6158, - "name": "InvalidMarketStatusToSettlePnl", - "msg": "Invalid Market Status to Settle Perp Pnl" - }, - { - "code": 6159, - "name": "PerpMarketNotInSettlement", - "msg": "PerpMarketNotInSettlement" - }, - { - "code": 6160, - "name": "PerpMarketNotInReduceOnly", - "msg": "PerpMarketNotInReduceOnly" - }, - { - "code": 6161, - "name": "PerpMarketSettlementBufferNotReached", - "msg": "PerpMarketSettlementBufferNotReached" - }, - { - "code": 6162, - "name": "PerpMarketSettlementUserHasOpenOrders", - "msg": "PerpMarketSettlementUserHasOpenOrders" - }, - { - "code": 6163, - "name": "PerpMarketSettlementUserHasActiveLP", - "msg": "PerpMarketSettlementUserHasActiveLP" - }, - { - "code": 6164, - "name": "UnableToSettleExpiredUserPosition", - "msg": "UnableToSettleExpiredUserPosition" - }, - { - "code": 6165, - "name": "UnequalMarketIndexForSpotTransfer", - "msg": "UnequalMarketIndexForSpotTransfer" - }, - { - "code": 6166, - "name": "InvalidPerpPositionDetected", - "msg": "InvalidPerpPositionDetected" - }, - { - "code": 6167, - "name": "InvalidSpotPositionDetected", - "msg": "InvalidSpotPositionDetected" - }, - { - "code": 6168, - "name": "InvalidAmmDetected", - "msg": "InvalidAmmDetected" - }, - { - "code": 6169, - "name": "InvalidAmmForFillDetected", - "msg": "InvalidAmmForFillDetected" - }, - { - "code": 6170, - "name": "InvalidAmmLimitPriceOverride", - "msg": "InvalidAmmLimitPriceOverride" - }, - { - "code": 6171, - "name": "InvalidOrderFillPrice", - "msg": "InvalidOrderFillPrice" - }, - { - "code": 6172, - "name": "SpotMarketBalanceInvariantViolated", - "msg": "SpotMarketBalanceInvariantViolated" - }, - { - "code": 6173, - "name": "SpotMarketVaultInvariantViolated", - "msg": "SpotMarketVaultInvariantViolated" - }, - { - "code": 6174, - "name": "InvalidPDA", - "msg": "InvalidPDA" - }, - { - "code": 6175, - "name": "InvalidPDASigner", - "msg": "InvalidPDASigner" - }, - { - "code": 6176, - "name": "RevenueSettingsCannotSettleToIF", - "msg": "RevenueSettingsCannotSettleToIF" - }, - { - "code": 6177, - "name": "NoRevenueToSettleToIF", - "msg": "NoRevenueToSettleToIF" - }, - { - "code": 6178, - "name": "NoAmmPerpPnlDeficit", - "msg": "NoAmmPerpPnlDeficit" - }, - { - "code": 6179, - "name": "SufficientPerpPnlPool", - "msg": "SufficientPerpPnlPool" - }, - { - "code": 6180, - "name": "InsufficientPerpPnlPool", - "msg": "InsufficientPerpPnlPool" - }, - { - "code": 6181, - "name": "PerpPnlDeficitBelowThreshold", - "msg": "PerpPnlDeficitBelowThreshold" - }, - { - "code": 6182, - "name": "MaxRevenueWithdrawPerPeriodReached", - "msg": "MaxRevenueWithdrawPerPeriodReached" - }, - { - "code": 6183, - "name": "MaxIFWithdrawReached", - "msg": "InvalidSpotPositionDetected" - }, - { - "code": 6184, - "name": "NoIFWithdrawAvailable", - "msg": "NoIFWithdrawAvailable" - }, - { - "code": 6185, - "name": "InvalidIFUnstake", - "msg": "InvalidIFUnstake" - }, - { - "code": 6186, - "name": "InvalidIFUnstakeSize", - "msg": "InvalidIFUnstakeSize" - }, - { - "code": 6187, - "name": "InvalidIFUnstakeCancel", - "msg": "InvalidIFUnstakeCancel" - }, - { - "code": 6188, - "name": "InvalidIFForNewStakes", - "msg": "InvalidIFForNewStakes" - }, - { - "code": 6189, - "name": "InvalidIFRebase", - "msg": "InvalidIFRebase" - }, - { - "code": 6190, - "name": "InvalidInsuranceUnstakeSize", - "msg": "InvalidInsuranceUnstakeSize" - }, - { - "code": 6191, - "name": "InvalidOrderLimitPrice", - "msg": "InvalidOrderLimitPrice" - }, - { - "code": 6192, - "name": "InvalidIFDetected", - "msg": "InvalidIFDetected" - }, - { - "code": 6193, - "name": "InvalidAmmMaxSpreadDetected", - "msg": "InvalidAmmMaxSpreadDetected" - }, - { - "code": 6194, - "name": "InvalidConcentrationCoef", - "msg": "InvalidConcentrationCoef" - }, - { - "code": 6195, - "name": "InvalidSrmVault", - "msg": "InvalidSrmVault" - }, - { - "code": 6196, - "name": "InvalidVaultOwner", - "msg": "InvalidVaultOwner" - }, - { - "code": 6197, - "name": "InvalidMarketStatusForFills", - "msg": "InvalidMarketStatusForFills" - }, - { - "code": 6198, - "name": "IFWithdrawRequestInProgress", - "msg": "IFWithdrawRequestInProgress" - }, - { - "code": 6199, - "name": "NoIFWithdrawRequestInProgress", - "msg": "NoIFWithdrawRequestInProgress" - }, - { - "code": 6200, - "name": "IFWithdrawRequestTooSmall", - "msg": "IFWithdrawRequestTooSmall" - }, - { - "code": 6201, - "name": "IncorrectSpotMarketAccountPassed", - "msg": "IncorrectSpotMarketAccountPassed" - }, - { - "code": 6202, - "name": "BlockchainClockInconsistency", - "msg": "BlockchainClockInconsistency" - }, - { - "code": 6203, - "name": "InvalidIFSharesDetected", - "msg": "InvalidIFSharesDetected" - }, - { - "code": 6204, - "name": "NewLPSizeTooSmall", - "msg": "NewLPSizeTooSmall" - }, - { - "code": 6205, - "name": "MarketStatusInvalidForNewLP", - "msg": "MarketStatusInvalidForNewLP" - }, - { - "code": 6206, - "name": "InvalidMarkTwapUpdateDetected", - "msg": "InvalidMarkTwapUpdateDetected" - }, - { - "code": 6207, - "name": "MarketSettlementAttemptOnActiveMarket", - "msg": "MarketSettlementAttemptOnActiveMarket" - }, - { - "code": 6208, - "name": "MarketSettlementRequiresSettledLP", - "msg": "MarketSettlementRequiresSettledLP" - }, - { - "code": 6209, - "name": "MarketSettlementAttemptTooEarly", - "msg": "MarketSettlementAttemptTooEarly" - }, - { - "code": 6210, - "name": "MarketSettlementTargetPriceInvalid", - "msg": "MarketSettlementTargetPriceInvalid" - }, - { - "code": 6211, - "name": "UnsupportedSpotMarket", - "msg": "UnsupportedSpotMarket" - }, - { - "code": 6212, - "name": "SpotOrdersDisabled", - "msg": "SpotOrdersDisabled" - }, - { - "code": 6213, - "name": "MarketBeingInitialized", - "msg": "Market Being Initialized" - }, - { - "code": 6214, - "name": "InvalidUserSubAccountId", - "msg": "Invalid Sub Account Id" - }, - { - "code": 6215, - "name": "InvalidTriggerOrderCondition", - "msg": "Invalid Trigger Order Condition" - }, - { - "code": 6216, - "name": "InvalidSpotPosition", - "msg": "Invalid Spot Position" - }, - { - "code": 6217, - "name": "CantTransferBetweenSameUserAccount", - "msg": "Cant transfer between same user account" - }, - { - "code": 6218, - "name": "InvalidPerpPosition", - "msg": "Invalid Perp Position" - }, - { - "code": 6219, - "name": "UnableToGetLimitPrice", - "msg": "Unable To Get Limit Price" - }, - { - "code": 6220, - "name": "InvalidLiquidation", - "msg": "Invalid Liquidation" - }, - { - "code": 6221, - "name": "SpotFulfillmentConfigDisabled", - "msg": "Spot Fulfillment Config Disabled" - }, - { - "code": 6222, - "name": "InvalidMaker", - "msg": "Invalid Maker" - }, - { - "code": 6223, - "name": "FailedUnwrap", - "msg": "Failed Unwrap" - }, - { - "code": 6224, - "name": "MaxNumberOfUsers", - "msg": "Max Number Of Users" - }, - { - "code": 6225, - "name": "InvalidOracleForSettlePnl", - "msg": "InvalidOracleForSettlePnl" - }, - { - "code": 6226, - "name": "MarginOrdersOpen", - "msg": "MarginOrdersOpen" - }, - { - "code": 6227, - "name": "TierViolationLiquidatingPerpPnl", - "msg": "TierViolationLiquidatingPerpPnl" - }, - { - "code": 6228, - "name": "CouldNotLoadUserData", - "msg": "CouldNotLoadUserData" - }, - { - "code": 6229, - "name": "UserWrongMutability", - "msg": "UserWrongMutability" - }, - { - "code": 6230, - "name": "InvalidUserAccount", - "msg": "InvalidUserAccount" - }, - { - "code": 6231, - "name": "CouldNotLoadUserStatsData", - "msg": "CouldNotLoadUserData" - }, - { - "code": 6232, - "name": "UserStatsWrongMutability", - "msg": "UserWrongMutability" - }, - { - "code": 6233, - "name": "InvalidUserStatsAccount", - "msg": "InvalidUserAccount" - }, - { - "code": 6234, - "name": "UserNotFound", - "msg": "UserNotFound" - }, - { - "code": 6235, - "name": "UnableToLoadUserAccount", - "msg": "UnableToLoadUserAccount" - }, - { - "code": 6236, - "name": "UserStatsNotFound", - "msg": "UserStatsNotFound" - }, - { - "code": 6237, - "name": "UnableToLoadUserStatsAccount", - "msg": "UnableToLoadUserStatsAccount" - }, - { - "code": 6238, - "name": "UserNotInactive", - "msg": "User Not Inactive" - }, - { - "code": 6239, - "name": "RevertFill", - "msg": "RevertFill" - }, - { - "code": 6240, - "name": "InvalidMarketAccountforDeletion", - "msg": "Invalid MarketAccount for Deletion" - }, - { - "code": 6241, - "name": "InvalidSpotFulfillmentParams", - "msg": "Invalid Spot Fulfillment Params" - }, - { - "code": 6242, - "name": "FailedToGetMint", - "msg": "Failed to Get Mint" - }, - { - "code": 6243, - "name": "FailedPhoenixCPI", - "msg": "FailedPhoenixCPI" - }, - { - "code": 6244, - "name": "FailedToDeserializePhoenixMarket", - "msg": "FailedToDeserializePhoenixMarket" - }, - { - "code": 6245, - "name": "InvalidPricePrecision", - "msg": "InvalidPricePrecision" - }, - { - "code": 6246, - "name": "InvalidPhoenixProgram", - "msg": "InvalidPhoenixProgram" - }, - { - "code": 6247, - "name": "InvalidPhoenixMarket", - "msg": "InvalidPhoenixMarket" - }, - { - "code": 6248, - "name": "InvalidSwap", - "msg": "InvalidSwap" - }, - { - "code": 6249, - "name": "SwapLimitPriceBreached", - "msg": "SwapLimitPriceBreached" - }, - { - "code": 6250, - "name": "SpotMarketReduceOnly", - "msg": "SpotMarketReduceOnly" - }, - { - "code": 6251, - "name": "FundingWasNotUpdated", - "msg": "FundingWasNotUpdated" - }, - { - "code": 6252, - "name": "ImpossibleFill", - "msg": "ImpossibleFill" - }, - { - "code": 6253, - "name": "CantUpdatePerpBidAskTwap", - "msg": "CantUpdatePerpBidAskTwap" - }, - { - "code": 6254, - "name": "UserReduceOnly", - "msg": "UserReduceOnly" - }, - { - "code": 6255, - "name": "InvalidMarginCalculation", - "msg": "InvalidMarginCalculation" - }, - { - "code": 6256, - "name": "CantPayUserInitFee", - "msg": "CantPayUserInitFee" - }, - { - "code": 6257, - "name": "CantReclaimRent", - "msg": "CantReclaimRent" - }, - { - "code": 6258, - "name": "InsuranceFundOperationPaused", - "msg": "InsuranceFundOperationPaused" - }, - { - "code": 6259, - "name": "NoUnsettledPnl", - "msg": "NoUnsettledPnl" - }, - { - "code": 6260, - "name": "PnlPoolCantSettleUser", - "msg": "PnlPoolCantSettleUser" - }, - { - "code": 6261, - "name": "OracleNonPositive", - "msg": "OracleInvalid" - }, - { - "code": 6262, - "name": "OracleTooVolatile", - "msg": "OracleTooVolatile" - }, - { - "code": 6263, - "name": "OracleTooUncertain", - "msg": "OracleTooUncertain" - }, - { - "code": 6264, - "name": "OracleStaleForMargin", - "msg": "OracleStaleForMargin" - }, - { - "code": 6265, - "name": "OracleInsufficientDataPoints", - "msg": "OracleInsufficientDataPoints" - }, - { - "code": 6266, - "name": "OracleStaleForAMM", - "msg": "OracleStaleForAMM" - }, - { - "code": 6267, - "name": "UnableToParsePullOracleMessage", - "msg": "Unable to parse pull oracle message" - }, - { - "code": 6268, - "name": "MaxBorrows", - "msg": "Can not borow more than max borrows" - }, - { - "code": 6269, - "name": "OracleUpdatesNotMonotonic", - "msg": "Updates must be monotonically increasing" - }, - { - "code": 6270, - "name": "OraclePriceFeedMessageMismatch", - "msg": "Trying to update price feed with the wrong feed id" - }, - { - "code": 6271, - "name": "OracleUnsupportedMessageType", - "msg": "The message in the update must be a PriceFeedMessage" - }, - { - "code": 6272, - "name": "OracleDeserializeMessageFailed", - "msg": "Could not deserialize the message in the update" - }, - { - "code": 6273, - "name": "OracleWrongGuardianSetOwner", - "msg": "Wrong guardian set owner in update price atomic" - }, - { - "code": 6274, - "name": "OracleWrongWriteAuthority", - "msg": "Oracle post update atomic price feed account must be drift program" - }, - { - "code": 6275, - "name": "OracleWrongVaaOwner", - "msg": "Oracle vaa owner must be wormhole program" - }, - { - "code": 6276, - "name": "OracleTooManyPriceAccountUpdates", - "msg": "Multi updates must have 2 or fewer accounts passed in remaining accounts" - }, - { - "code": 6277, - "name": "OracleMismatchedVaaAndPriceUpdates", - "msg": "Don't have the same remaining accounts number and pyth updates left" - }, - { - "code": 6278, - "name": "OracleBadRemainingAccountPublicKey", - "msg": "Remaining account passed does not match oracle update derived pda" - }, - { - "code": 6279, - "name": "FailedOpenbookV2CPI", - "msg": "FailedOpenbookV2CPI" - }, - { - "code": 6280, - "name": "InvalidOpenbookV2Program", - "msg": "InvalidOpenbookV2Program" - }, - { - "code": 6281, - "name": "InvalidOpenbookV2Market", - "msg": "InvalidOpenbookV2Market" - }, - { - "code": 6282, - "name": "NonZeroTransferFee", - "msg": "Non zero transfer fee" - }, - { - "code": 6283, - "name": "LiquidationOrderFailedToFill", - "msg": "Liquidation order failed to fill" - }, - { - "code": 6284, - "name": "InvalidPredictionMarketOrder", - "msg": "Invalid prediction market order" - }, - { - "code": 6285, - "name": "InvalidVerificationIxIndex", - "msg": "Ed25519 Ix must be before place and make SignedMsg order ix" - }, - { - "code": 6286, - "name": "SigVerificationFailed", - "msg": "SignedMsg message verificaiton failed" - }, - { - "code": 6287, - "name": "MismatchedSignedMsgOrderParamsMarketIndex", - "msg": "Market index mismatched b/w taker and maker SignedMsg order params" - }, - { - "code": 6288, - "name": "InvalidSignedMsgOrderParam", - "msg": "Invalid SignedMsg order param" - }, - { - "code": 6289, - "name": "PlaceAndTakeOrderSuccessConditionFailed", - "msg": "Place and take order success condition failed" - }, - { - "code": 6290, - "name": "InvalidHighLeverageModeConfig", - "msg": "Invalid High Leverage Mode Config" - }, - { - "code": 6291, - "name": "InvalidRFQUserAccount", - "msg": "Invalid RFQ User Account" - }, - { - "code": 6292, - "name": "RFQUserAccountWrongMutability", - "msg": "RFQUserAccount should be mutable" - }, - { - "code": 6293, - "name": "RFQUserAccountFull", - "msg": "RFQUserAccount has too many active RFQs" - }, - { - "code": 6294, - "name": "RFQOrderNotFilled", - "msg": "RFQ order not filled as expected" - }, - { - "code": 6295, - "name": "InvalidRFQOrder", - "msg": "RFQ orders must be jit makers" - }, - { - "code": 6296, - "name": "InvalidRFQMatch", - "msg": "RFQ matches must be valid" - }, - { - "code": 6297, - "name": "InvalidSignedMsgUserAccount", - "msg": "Invalid SignedMsg user account" - }, - { - "code": 6298, - "name": "SignedMsgUserAccountWrongMutability", - "msg": "SignedMsg account wrong mutability" - }, - { - "code": 6299, - "name": "SignedMsgUserOrdersAccountFull", - "msg": "SignedMsgUserAccount has too many active orders" - }, - { - "code": 6300, - "name": "SignedMsgOrderDoesNotExist", - "msg": "Order with SignedMsg uuid does not exist" - }, - { - "code": 6301, - "name": "InvalidSignedMsgOrderId", - "msg": "SignedMsg order id cannot be 0s" - }, - { - "code": 6302, - "name": "InvalidPoolId", - "msg": "Invalid pool id" - }, - { - "code": 6303, - "name": "InvalidProtectedMakerModeConfig", - "msg": "Invalid Protected Maker Mode Config" - }, - { - "code": 6304, - "name": "InvalidPythLazerStorageOwner", - "msg": "Invalid pyth lazer storage owner" - }, - { - "code": 6305, - "name": "UnverifiedPythLazerMessage", - "msg": "Verification of pyth lazer message failed" - }, - { - "code": 6306, - "name": "InvalidPythLazerMessage", - "msg": "Invalid pyth lazer message" - }, - { - "code": 6307, - "name": "PythLazerMessagePriceFeedMismatch", - "msg": "Pyth lazer message does not correspond to correct fed id" - }, - { - "code": 6308, - "name": "InvalidLiquidateSpotWithSwap", - "msg": "InvalidLiquidateSpotWithSwap" - }, - { - "code": 6309, - "name": "SignedMsgUserContextUserMismatch", - "msg": "User in SignedMsg message does not match user in ix context" - }, - { - "code": 6310, - "name": "UserFuelOverflowThresholdNotMet", - "msg": "User fuel overflow threshold not met" - }, - { - "code": 6311, - "name": "FuelOverflowAccountNotFound", - "msg": "FuelOverflow account not found" - }, - { - "code": 6312, - "name": "InvalidTransferPerpPosition", - "msg": "Invalid Transfer Perp Position" - }, - { - "code": 6313, - "name": "InvalidSignedMsgUserOrdersResize", - "msg": "Invalid SignedMsgUserOrders resize" - }, - { - "code": 6314, - "name": "CouldNotDeserializeHighLeverageModeConfig", - "msg": "Could not deserialize high leverage mode config" - }, - { - "code": 6315, - "name": "InvalidIfRebalanceConfig", - "msg": "Invalid If Rebalance Config" - }, - { - "code": 6316, - "name": "InvalidIfRebalanceSwap", - "msg": "Invalid If Rebalance Swap" - }, - { - "code": 6317, - "name": "InvalidRevenueShareResize", - "msg": "Invalid RevenueShare resize" - }, - { - "code": 6318, - "name": "BuilderRevoked", - "msg": "Builder has been revoked" - }, - { - "code": 6319, - "name": "InvalidBuilderFee", - "msg": "Builder fee is greater than max fee bps" - }, - { - "code": 6320, - "name": "RevenueShareEscrowAuthorityMismatch", - "msg": "RevenueShareEscrow authority mismatch" - }, - { - "code": 6321, - "name": "RevenueShareEscrowOrdersAccountFull", - "msg": "RevenueShareEscrow has too many active orders" - }, - { - "code": 6322, - "name": "InvalidRevenueShareAccount", - "msg": "Invalid RevenueShareAccount" - }, - { - "code": 6323, - "name": "CannotRevokeBuilderWithOpenOrders", - "msg": "Cannot revoke builder with open orders" - }, - { - "code": 6324, - "name": "UnableToLoadRevenueShareAccount", - "msg": "Unable to load builder account" - }, - { - "code": 6325, - "name": "InvalidConstituent", - "msg": "Invalid Constituent" - }, - { - "code": 6326, - "name": "InvalidAmmConstituentMappingArgument", - "msg": "Invalid Amm Constituent Mapping argument" - }, - { - "code": 6327, - "name": "ConstituentNotFound", - "msg": "Constituent not found" - }, - { - "code": 6328, - "name": "ConstituentCouldNotLoad", - "msg": "Constituent could not load" - }, - { - "code": 6329, - "name": "ConstituentWrongMutability", - "msg": "Constituent wrong mutability" - }, - { - "code": 6330, - "name": "WrongNumberOfConstituents", - "msg": "Wrong number of constituents passed to instruction" - }, - { - "code": 6331, - "name": "InsufficientConstituentTokenBalance", - "msg": "Insufficient constituent token balance" - }, - { - "code": 6332, - "name": "AMMCacheStale", - "msg": "Amm Cache data too stale" - }, - { - "code": 6333, - "name": "LpPoolAumDelayed", - "msg": "LP Pool AUM not updated recently" - }, - { - "code": 6334, - "name": "ConstituentOracleStale", - "msg": "Constituent oracle is stale" - }, - { - "code": 6335, - "name": "LpInvariantFailed", - "msg": "LP Invariant failed" - }, - { - "code": 6336, - "name": "InvalidConstituentDerivativeWeights", - "msg": "Invalid constituent derivative weights" - }, - { - "code": 6337, - "name": "MaxDlpAumBreached", - "msg": "Max DLP AUM Breached" - }, - { - "code": 6338, - "name": "SettleLpPoolDisabled", - "msg": "Settle Lp Pool Disabled" - }, - { - "code": 6339, - "name": "MintRedeemLpPoolDisabled", - "msg": "Mint/Redeem Lp Pool Disabled" - }, - { - "code": 6340, - "name": "LpPoolSettleInvariantBreached", - "msg": "Settlement amount exceeded" + "name": "UserFees", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "total_fee_paid", + "docs": [ + "Total taker fee paid", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "total_fee_rebate", + "docs": [ + "Total maker fee rebate", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "total_token_discount", + "docs": [ + "Total discount from holding token", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "total_referee_discount", + "docs": [ + "Total discount from being referred", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "total_referrer_reward", + "docs": [ + "Total reward to referrer", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "current_epoch_referrer_reward", + "docs": [ + "Total reward to referrer this epoch", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + } + ] + } }, { - "code": 6341, - "name": "InvalidConstituentOperation", - "msg": "Invalid constituent operation" + "name": "UserStats", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The authority for all of a users sub accounts" + ], + "type": "pubkey" + }, + { + "name": "referrer", + "docs": [ + "The address that referred this user" + ], + "type": "pubkey" + }, + { + "name": "fees", + "docs": [ + "Stats on the fees paid by the user" + ], + "type": { + "defined": { + "name": "UserFees" + } + } + }, + { + "name": "next_epoch_ts", + "docs": [ + "The timestamp of the next epoch", + "Epoch is used to limit referrer rewards earned in single epoch" + ], + "type": "i64" + }, + { + "name": "maker_volume_30d", + "docs": [ + "Rolling 30day maker volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "taker_volume_30d", + "docs": [ + "Rolling 30day taker volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "filler_volume_30d", + "docs": [ + "Rolling 30day filler volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "last_maker_volume_30d_ts", + "docs": [ + "last time the maker volume was updated" + ], + "type": "i64" + }, + { + "name": "last_taker_volume_30d_ts", + "docs": [ + "last time the taker volume was updated" + ], + "type": "i64" + }, + { + "name": "last_filler_volume_30d_ts", + "docs": [ + "last time the filler volume was updated" + ], + "type": "i64" + }, + { + "name": "if_staked_quote_asset_amount", + "docs": [ + "The amount of tokens staked in the quote spot markets if" + ], + "type": "u64" + }, + { + "name": "number_of_sub_accounts", + "docs": [ + "The current number of sub accounts" + ], + "type": "u16" + }, + { + "name": "number_of_sub_accounts_created", + "docs": [ + "The number of sub accounts created. Can be greater than the number of sub accounts if user", + "has deleted sub accounts" + ], + "type": "u16" + }, + { + "name": "referrer_status", + "docs": [ + "Flags for referrer status:", + "First bit (LSB): 1 if user is a referrer, 0 otherwise", + "Second bit: 1 if user was referred, 0 otherwise" + ], + "type": "u8" + }, + { + "name": "disable_update_perp_bid_ask_twap", + "type": "bool" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 1 + ] + } + }, + { + "name": "fuel_overflow_status", + "docs": [ + "whether the user has a FuelOverflow account" + ], + "type": "u8" + }, + { + "name": "fuel_insurance", + "docs": [ + "accumulated fuel for token amounts of insurance" + ], + "type": "u32" + }, + { + "name": "fuel_deposits", + "docs": [ + "accumulated fuel for notional of deposits" + ], + "type": "u32" + }, + { + "name": "fuel_borrows", + "docs": [ + "accumulate fuel bonus for notional of borrows" + ], + "type": "u32" + }, + { + "name": "fuel_positions", + "docs": [ + "accumulated fuel for perp open interest" + ], + "type": "u32" + }, + { + "name": "fuel_taker", + "docs": [ + "accumulate fuel bonus for taker volume" + ], + "type": "u32" + }, + { + "name": "fuel_maker", + "docs": [ + "accumulate fuel bonus for maker volume" + ], + "type": "u32" + }, + { + "name": "if_staked_gov_token_amount", + "docs": [ + "The amount of tokens staked in the governance spot markets if" + ], + "type": "u64" + }, + { + "name": "last_fuel_if_bonus_update_ts", + "docs": [ + "last unix ts user stats data was used to update if fuel (u32 to save space)" + ], + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 12 + ] + } + } + ] + } }, { - "code": 6342, - "name": "Unauthorized", - "msg": "Unauthorized for operation" + "name": "ValidityGuardRails", + "type": { + "kind": "struct", + "fields": [ + { + "name": "slots_before_stale_for_amm", + "type": "i64" + }, + { + "name": "slots_before_stale_for_margin", + "type": "i64" + }, + { + "name": "confidence_interval_max_size", + "type": "u64" + }, + { + "name": "too_volatile_ratio", + "type": "i64" + } + ] + } }, { - "code": 6343, - "name": "InvalidLpPoolId", - "msg": "Invalid Lp Pool Id for Operation" + "name": "i128", + "docs": [ + "`i128` with legacy bit layout" + ], + "type": { + "kind": "struct", + "fields": [ + { + "array": [ + "u8", + 16 + ] + } + ] + } }, { - "code": 6344, - "name": "MarketIndexNotFoundAmmCache", - "msg": "MarketIndexNotFoundAmmCache" + "name": "u128", + "docs": [ + "`u128` with legacy bit layout" + ], + "type": { + "kind": "struct", + "fields": [ + { + "array": [ + "u8", + 16 + ] + } + ] + } } ] } \ No newline at end of file diff --git a/sdk/src/idl/drift.ts b/sdk/src/idl/drift.ts new file mode 100644 index 0000000000..4db21d06fd --- /dev/null +++ b/sdk/src/idl/drift.ts @@ -0,0 +1,21433 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/drift.json`. + */ +export type Drift = { + address: 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; + metadata: { + name: 'drift'; + version: '2.150.0'; + spec: '0.1.0'; + description: 'Created with Anchor'; + }; + instructions: [ + { + name: 'addAmmConstituentMappingData'; + discriminator: [164, 236, 130, 40, 118, 179, 46, 235]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'ammConstituentMappingData'; + type: { + vec: { + defined: { + name: 'addAmmConstituentMappingDatum'; + }; + }; + }; + }, + ]; + }, + { + name: 'addInsuranceFundStake'; + discriminator: [251, 144, 115, 11, 222, 47, 62, 236]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'addMarketToAmmCache'; + discriminator: [112, 149, 195, 222, 124, 7, 87, 237]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'adminDeposit'; + discriminator: [210, 66, 65, 182, 102, 214, 176, 30]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'adminTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'adminDisableUpdatePerpBidAskTwap'; + discriminator: [17, 164, 82, 45, 183, 86, 191, 199]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'disable'; + type: 'bool'; + }, + ]; + }, + { + name: 'beginInsuranceFundSwap'; + discriminator: [176, 69, 143, 205, 32, 132, 163, 0]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'outInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'beginLpSwap'; + discriminator: [64, 44, 24, 199, 48, 125, 67, 91]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'signerOutTokenAccount'; + docs: ['Signer token accounts']; + writable: true; + }, + { + name: 'signerInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + docs: ['Constituent token accounts']; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'outConstituent'; + docs: ['Constituents']; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpPool'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'beginSwap'; + discriminator: [174, 109, 228, 1, 242, 105, 232, 105]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'cancelOrder'; + discriminator: [95, 129, 237, 240, 8, 49, 223, 132]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'cancelOrderByUserId'; + discriminator: [107, 211, 250, 133, 18, 37, 57, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'userOrderId'; + type: 'u8'; + }, + ]; + }, + { + name: 'cancelOrders'; + discriminator: [238, 225, 95, 158, 227, 103, 8, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'marketType'; + type: { + option: { + defined: { + name: 'marketType'; + }; + }; + }; + }, + { + name: 'marketIndex'; + type: { + option: 'u16'; + }; + }, + { + name: 'direction'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + ]; + }, + { + name: 'cancelOrdersByIds'; + discriminator: [134, 19, 144, 165, 94, 240, 210, 94]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderIds'; + type: { + vec: 'u32'; + }; + }, + ]; + }, + { + name: 'cancelRequestRemoveInsuranceFundStake'; + discriminator: [97, 235, 78, 62, 212, 42, 241, 127]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'changeApprovedBuilder'; + discriminator: [179, 134, 211, 45, 195, 5, 189, 173]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + relations: ['escrow']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'builder'; + type: 'pubkey'; + }, + { + name: 'maxFeeBps'; + type: 'u16'; + }, + { + name: 'add'; + type: 'bool'; + }, + ]; + }, + { + name: 'changeSignedMsgWsDelegateStatus'; + discriminator: [252, 202, 252, 219, 179, 27, 84, 138]; + accounts: [ + { + name: 'signedMsgWsDelegates'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'delegate'; + type: 'pubkey'; + }, + { + name: 'add'; + type: 'bool'; + }, + ]; + }, + { + name: 'deleteAmmCache'; + discriminator: [216, 130, 215, 206, 233, 232, 191, 88]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'deleteInitializedPerpMarket'; + discriminator: [91, 154, 24, 87, 106, 59, 190, 66]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deleteInitializedSpotMarket'; + discriminator: [31, 140, 67, 191, 189, 20, 101, 221]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deletePrelaunchOracle'; + discriminator: [59, 169, 100, 49, 69, 17, 173, 253]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'perpMarketIndex'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deleteSignedMsgUserOrders'; + discriminator: [221, 247, 128, 253, 212, 254, 46, 153]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'deleteUser'; + discriminator: [186, 85, 17, 249, 219, 231, 98, 251]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + writable: true; + signer: true; + relations: ['user', 'userStats']; + }, + ]; + args: []; + }, + { + name: 'deposit'; + discriminator: [242, 35, 198, 137, 82, 225, 242, 182]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'depositIntoInsuranceFundStake'; + discriminator: [4, 22, 226, 201, 124, 44, 82, 230]; + accounts: [ + { + name: 'signer'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101, + ]; + }, + { + kind: 'account'; + path: 'userStats'; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoPerpMarketFeePool'; + discriminator: [34, 58, 57, 68, 97, 80, 244, 6]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'sourceVault'; + writable: true; + }, + { + name: 'driftSigner'; + }, + { + name: 'quoteSpotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoSpotMarketRevenuePool'; + discriminator: [92, 40, 151, 42, 122, 254, 139, 246]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoSpotMarketVault'; + discriminator: [48, 252, 119, 73, 255, 205, 174, 247]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'sourceVault'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositToProgramVault'; + discriminator: [235, 171, 121, 80, 57, 239, 147, 220]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'constituentTokenAccount'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'mint'; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'disableUserHighLeverageMode'; + discriminator: [183, 155, 45, 0, 226, 85, 213, 69]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'disableMaintenance'; + type: 'bool'; + }, + ]; + }, + { + name: 'enableUserHighLeverageMode'; + discriminator: [231, 24, 230, 112, 201, 173, 73, 184]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + ]; + }, + { + name: 'endInsuranceFundSwap'; + discriminator: [206, 230, 98, 8, 249, 158, 169, 167]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'outInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'endLpSwap'; + discriminator: [99, 125, 214, 165, 129, 175, 253, 135]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'signerOutTokenAccount'; + docs: ['Signer token accounts']; + writable: true; + }, + { + name: 'signerInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + docs: ['Constituent token accounts']; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'outConstituent'; + docs: ['Constituents']; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpPool'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'endSwap'; + discriminator: [177, 184, 27, 193, 34, 13, 210, 145]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'reduceOnly'; + type: { + option: { + defined: { + name: 'swapReduceOnly'; + }; + }; + }; + }, + ]; + }, + { + name: 'fillPerpOrder'; + discriminator: [13, 188, 248, 103, 134, 217, 106, 240]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'fillSpotOrder'; + discriminator: [212, 206, 130, 173, 21, 34, 199, 40]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'forceCancelOrders'; + discriminator: [64, 181, 196, 63, 222, 72, 64, 232]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'forceDeleteUser'; + discriminator: [2, 241, 195, 172, 227, 24, 254, 158]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + writable: true; + relations: ['user', 'userStats']; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'driftSigner'; + }, + ]; + args: []; + }, + { + name: 'initialize'; + discriminator: [175, 175, 109, 31, 13, 152, 155, 237]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [100, 114, 105, 102, 116, 95, 115, 116, 97, 116, 101]; + }, + ]; + }; + }, + { + name: 'quoteAssetMint'; + }, + { + name: 'driftSigner'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: []; + }, + { + name: 'initializeAmmCache'; + discriminator: [38, 60, 171, 158, 203, 58, 137, 8]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeConstituent'; + discriminator: [12, 196, 45, 218, 93, 89, 0, 33]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketMint'; + }, + { + name: 'constituentVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'decimals'; + type: 'u8'; + }, + { + name: 'maxWeightDeviation'; + type: 'i64'; + }, + { + name: 'swapFeeMin'; + type: 'i64'; + }, + { + name: 'swapFeeMax'; + type: 'i64'; + }, + { + name: 'maxBorrowTokenAmount'; + type: 'u64'; + }, + { + name: 'oracleStalenessThreshold'; + type: 'u64'; + }, + { + name: 'costToTrade'; + type: 'i32'; + }, + { + name: 'constituentDerivativeIndex'; + type: { + option: 'i16'; + }; + }, + { + name: 'constituentDerivativeDepegThreshold'; + type: 'u64'; + }, + { + name: 'derivativeWeight'; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'gammaInventory'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'newConstituentCorrelations'; + type: { + vec: 'i64'; + }; + }, + ]; + }, + { + name: 'initializeFuelOverflow'; + discriminator: [88, 223, 132, 161, 208, 88, 142, 42]; + accounts: [ + { + name: 'fuelOverflow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 102, + 117, + 101, + 108, + 95, + 111, + 118, + 101, + 114, + 102, + 108, + 111, + 119, + ]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeHighLeverageModeConfig'; + discriminator: [213, 167, 93, 246, 208, 130, 90, 248]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializeIfRebalanceConfig'; + discriminator: [8, 85, 184, 167, 176, 61, 173, 226]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 102, + 95, + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'arg'; + path: 'params.in_market_index'; + }, + { + kind: 'arg'; + path: 'params.out_market_index'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'ifRebalanceConfigParams'; + }; + }; + }, + ]; + }, + { + name: 'initializeInsuranceFundStake'; + discriminator: [187, 179, 243, 70, 248, 90, 92, 147]; + accounts: [ + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101, + ]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeLpPool'; + discriminator: [242, 64, 1, 222, 142, 46, 204, 227]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [108, 112, 95, 112, 111, 111, 108]; + }, + { + kind: 'arg'; + path: 'id'; + }, + ]; + }; + }, + { + name: 'mint'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'tokenProgram'; + address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'minMintFee'; + type: 'i64'; + }, + { + name: 'maxAum'; + type: 'u128'; + }, + { + name: 'maxSettleQuoteAmountPerMarket'; + type: 'u64'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'initializeOpenbookV2FulfillmentConfig'; + discriminator: [7, 221, 103, 153, 107, 57, 27, 197]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'openbookV2Program'; + }, + { + name: 'openbookV2Market'; + }, + { + name: 'driftSigner'; + }, + { + name: 'openbookV2FulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 111, + 112, + 101, + 110, + 98, + 111, + 111, + 107, + 95, + 118, + 50, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'openbookV2Market'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializePerpMarket'; + discriminator: [132, 9, 229, 118, 117, 118, 117, 62]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 101, 114, 112, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'state.number_of_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'ammBaseAssetReserve'; + type: 'u128'; + }, + { + name: 'ammQuoteAssetReserve'; + type: 'u128'; + }, + { + name: 'ammPeriodicity'; + type: 'i64'; + }, + { + name: 'ammPegMultiplier'; + type: 'u128'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'contractTier'; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + { + name: 'marginRatioInitial'; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'activeStatus'; + type: 'bool'; + }, + { + name: 'baseSpread'; + type: 'u32'; + }, + { + name: 'maxSpread'; + type: 'u32'; + }, + { + name: 'maxOpenInterest'; + type: 'u128'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + type: 'u64'; + }, + { + name: 'orderStepSize'; + type: 'u64'; + }, + { + name: 'orderTickSize'; + type: 'u64'; + }, + { + name: 'minOrderSize'; + type: 'u64'; + }, + { + name: 'concentrationCoefScale'; + type: 'u128'; + }, + { + name: 'curveUpdateIntensity'; + type: 'u8'; + }, + { + name: 'ammJitIntensity'; + type: 'u8'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'initializePhoenixFulfillmentConfig'; + discriminator: [135, 132, 110, 107, 185, 160, 169, 154]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'phoenixProgram'; + }, + { + name: 'phoenixMarket'; + }, + { + name: 'driftSigner'; + }, + { + name: 'phoenixFulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 104, + 111, + 101, + 110, + 105, + 120, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'phoenixMarket'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializePredictionMarket'; + discriminator: [248, 70, 198, 224, 224, 105, 125, 195]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'initializePrelaunchOracle'; + discriminator: [169, 178, 84, 25, 175, 62, 29, 247]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'params.perp_market_index'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'prelaunchOracleParams'; + }; + }; + }, + ]; + }, + { + name: 'initializeProtectedMakerModeConfig'; + discriminator: [67, 103, 220, 67, 88, 32, 252, 8]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializePythLazerOracle'; + discriminator: [140, 107, 33, 214, 235, 219, 103, 20]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lazerOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 108, 97, 122, 101, 114]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'feedId'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializePythPullOracle'; + discriminator: [249, 140, 253, 243, 248, 74, 240, 238]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeReferrerName'; + discriminator: [235, 126, 231, 10, 42, 164, 26, 61]; + accounts: [ + { + name: 'referrerName'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 114, + 101, + 102, + 101, + 114, + 114, + 101, + 114, + 95, + 110, + 97, + 109, + 101, + ]; + }, + { + kind: 'arg'; + path: 'name'; + }, + ]; + }; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeRevenueShare'; + discriminator: [57, 9, 123, 131, 82, 52, 50, 13]; + accounts: [ + { + name: 'revenueShare'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 83, 72, 65, 82, 69]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeRevenueShareEscrow'; + discriminator: [187, 18, 123, 88, 238, 104, 84, 154]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSerumFulfillmentConfig'; + discriminator: [193, 211, 132, 172, 70, 171, 7, 94]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'serumProgram'; + }, + { + name: 'serumMarket'; + }, + { + name: 'serumOpenOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 101, + 114, + 117, + 109, + 95, + 111, + 112, + 101, + 110, + 95, + 111, + 114, + 100, + 101, + 114, + 115, + ]; + }, + { + kind: 'account'; + path: 'serumMarket'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'serumFulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 101, + 114, + 117, + 109, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'serumMarket'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSignedMsgUserOrders'; + discriminator: [164, 99, 156, 126, 156, 57, 99, 180]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSignedMsgWsDelegates'; + discriminator: [40, 132, 96, 219, 184, 193, 80, 8]; + accounts: [ + { + name: 'signedMsgWsDelegates'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'delegates'; + type: { + vec: 'pubkey'; + }; + }, + ]; + }, + { + name: 'initializeSpotMarket'; + discriminator: [234, 196, 128, 44, 94, 15, 48, 201]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'spotMarketMint'; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'optimalUtilization'; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + type: 'u32'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'initialAssetWeight'; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + { + name: 'activeStatus'; + type: 'bool'; + }, + { + name: 'assetTier'; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + { + name: 'scaleInitialAssetWeightStart'; + type: 'u64'; + }, + { + name: 'withdrawGuardThreshold'; + type: 'u64'; + }, + { + name: 'orderTickSize'; + type: 'u64'; + }, + { + name: 'orderStepSize'; + type: 'u64'; + }, + { + name: 'ifTotalFactor'; + type: 'u32'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeUser'; + discriminator: [111, 17, 185, 250, 60, 122, 38, 254]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeUserStats'; + discriminator: [254, 243, 72, 98, 251, 130, 168, 213]; + accounts: [ + { + name: 'userStats'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114, 95, 115, 116, 97, 116, 115]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'liquidateBorrowForPerpPnl'; + discriminator: [169, 17, 32, 90, 207, 148, 209, 27]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxLiabilityTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerp'; + discriminator: [75, 35, 119, 247, 191, 18, 139, 2]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxBaseAssetAmount'; + type: 'u64'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerpPnlForDeposit'; + discriminator: [237, 75, 198, 235, 233, 186, 75, 35]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxPnlTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerpWithFill'; + discriminator: [95, 111, 124, 105, 86, 169, 187, 34]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'liquidateSpot'; + discriminator: [107, 0, 128, 41, 35, 229, 251, 18]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxLiabilityTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidateSpotWithSwapBegin'; + discriminator: [12, 43, 176, 83, 156, 251, 117, 13]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'liabilitySpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'liabilityMarketIndex'; + }, + ]; + }; + }, + { + name: 'assetSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'assetMarketIndex'; + }, + ]; + }; + }, + { + name: 'liabilityTokenAccount'; + writable: true; + }, + { + name: 'assetTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'swapAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'liquidateSpotWithSwapEnd'; + discriminator: [142, 88, 163, 160, 223, 75, 55, 225]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'liabilitySpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'liabilityMarketIndex'; + }, + ]; + }; + }, + { + name: 'assetSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'assetMarketIndex'; + }, + ]; + }; + }, + { + name: 'liabilityTokenAccount'; + writable: true; + }, + { + name: 'assetTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'logUserBalances'; + discriminator: [162, 21, 35, 251, 32, 57, 161, 210]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'lpPoolAddLiquidity'; + discriminator: [49, 135, 246, 103, 93, 146, 220, 141]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'inMarketMint'; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'userInTokenAccount'; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'userLpTokenAccount'; + writable: true; + }, + { + name: 'lpMint'; + writable: true; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u128'; + }, + { + name: 'minMintAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'lpPoolRemoveLiquidity'; + discriminator: [164, 36, 193, 252, 196, 157, 138, 43]; + accounts: [ + { + name: 'state'; + }, + { + name: 'driftSigner'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outMarketMint'; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'userOutTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'userLpTokenAccount'; + writable: true; + }, + { + name: 'spotMarketTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + writable: true; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + { + name: 'ammCache'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'minOutAmount'; + type: 'u128'; + }, + ]; + }, + { + name: 'lpPoolSwap'; + discriminator: [36, 161, 39, 49, 227, 1, 35, 226]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'constituentCorrelations'; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + }, + { + name: 'userInTokenAccount'; + writable: true; + }, + { + name: 'userOutTokenAccount'; + writable: true; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inMarketMint'; + }, + { + name: 'outMarketMint'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'minOutAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'modifyOrder'; + discriminator: [47, 124, 117, 255, 201, 197, 130, 94]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'modifyOrderParams'; + type: { + defined: { + name: 'modifyOrderParams'; + }; + }; + }, + ]; + }, + { + name: 'modifyOrderByUserId'; + discriminator: [158, 77, 4, 253, 252, 194, 161, 179]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'userOrderId'; + type: 'u8'; + }, + { + name: 'modifyOrderParams'; + type: { + defined: { + name: 'modifyOrderParams'; + }; + }; + }, + ]; + }, + { + name: 'moveAmmPrice'; + discriminator: [235, 109, 2, 82, 219, 118, 6, 159]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'baseAssetReserve'; + type: 'u128'; + }, + { + name: 'quoteAssetReserve'; + type: 'u128'; + }, + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'openbookV2FulfillmentConfigStatus'; + discriminator: [25, 173, 19, 189, 4, 211, 64, 238]; + accounts: [ + { + name: 'state'; + }, + { + name: 'openbookV2FulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'overrideAmmCacheInfo'; + discriminator: [189, 198, 128, 9, 49, 145, 201, 115]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'overrideParams'; + type: { + defined: { + name: 'overrideAmmCacheParams'; + }; + }; + }, + ]; + }, + { + name: 'pauseSpotMarketDepositWithdraw'; + discriminator: [183, 119, 59, 170, 137, 35, 242, 86]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + signer: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'phoenixFulfillmentConfigStatus'; + discriminator: [96, 31, 113, 32, 12, 203, 7, 154]; + accounts: [ + { + name: 'state'; + }, + { + name: 'phoenixFulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'placeAndMakePerpOrder'; + discriminator: [149, 117, 11, 237, 47, 95, 89, 237]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'takerOrderId'; + type: 'u32'; + }, + ]; + }, + { + name: 'placeAndMakeSignedMsgPerpOrder'; + discriminator: [16, 26, 123, 131, 94, 29, 175, 98]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'takerSignedMsgUserOrders'; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'taker'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'signedMsgOrderUuid'; + type: { + array: ['u8', 8]; + }; + }, + ]; + }, + { + name: 'placeAndMakeSpotOrder'; + discriminator: [149, 158, 85, 66, 239, 9, 243, 98]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'takerOrderId'; + type: 'u32'; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + ]; + }, + { + name: 'placeAndTakePerpOrder'; + discriminator: [213, 51, 1, 187, 108, 220, 230, 224]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'successCondition'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'placeAndTakeSpotOrder'; + discriminator: [191, 3, 138, 71, 114, 198, 202, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'placeOrders'; + discriminator: [60, 63, 50, 123, 12, 197, 60, 190]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + vec: { + defined: { + name: 'orderParams'; + }; + }; + }; + }, + ]; + }, + { + name: 'placePerpOrder'; + discriminator: [69, 161, 93, 202, 120, 126, 76, 185]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + ]; + }, + { + name: 'placeSignedMsgTakerOrder'; + discriminator: [32, 79, 101, 139, 25, 6, 98, 15]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'user'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'ixSysvar'; + docs: [ + 'the supplied Sysvar could be anything else.', + 'The Instruction Sysvar has not been implemented', + 'in the Anchor framework yet, so this is the safe approach.', + ]; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'signedMsgOrderParamsMessageBytes'; + type: 'bytes'; + }, + { + name: 'isDelegateSigner'; + type: 'bool'; + }, + ]; + }, + { + name: 'placeSpotOrder'; + discriminator: [45, 79, 81, 160, 248, 90, 91, 220]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + ]; + }, + { + name: 'postMultiPythPullOracleUpdatesAtomic'; + discriminator: [243, 79, 204, 228, 227, 208, 100, 244]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'guardianSet'; + }, + ]; + args: [ + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'postPythLazerOracleUpdate'; + discriminator: [218, 237, 170, 245, 39, 143, 166, 33]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythLazerStorage'; + address: '3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL'; + }, + { + name: 'ixSysvar'; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'pythMessage'; + type: 'bytes'; + }, + ]; + }, + { + name: 'postPythPullOracleUpdateAtomic'; + discriminator: [116, 122, 137, 158, 224, 195, 173, 119]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'guardianSet'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'recenterPerpMarketAmm'; + discriminator: [24, 87, 10, 115, 165, 190, 80, 139]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pegMultiplier'; + type: 'u128'; + }, + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'recenterPerpMarketAmmCrank'; + discriminator: [166, 19, 64, 10, 14, 51, 101, 122]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'perpMarket'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'depth'; + type: { + option: 'u128'; + }; + }, + ]; + }, + { + name: 'reclaimRent'; + discriminator: [218, 200, 19, 197, 227, 89, 192, 22]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + relations: ['user', 'userStats']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'removeAmmConstituentMappingData'; + discriminator: [20, 183, 211, 162, 16, 52, 229, 115]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'removeInsuranceFundStake'; + discriminator: [128, 166, 142, 9, 254, 187, 143, 174]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'repegAmmCurve'; + discriminator: [3, 36, 102, 89, 180, 128, 120, 213]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'newPegCandidate'; + type: 'u128'; + }, + ]; + }, + { + name: 'requestRemoveInsuranceFundStake'; + discriminator: [142, 70, 204, 92, 73, 106, 180, 52]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'resetFuelSeason'; + discriminator: [199, 122, 192, 255, 32, 99, 63, 200]; + accounts: [ + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'resetPerpMarketAmmOracleTwap'; + discriminator: [127, 10, 55, 164, 123, 226, 47, 24]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: []; + }, + { + name: 'resizeRevenueShareEscrowOrders'; + discriminator: [32, 124, 247, 225, 151, 213, 225, 38]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['escrow']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'resizeSignedMsgUserOrders'; + discriminator: [137, 10, 87, 150, 18, 115, 79, 168]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['user']; + }, + { + name: 'user'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolvePerpBankruptcy'; + discriminator: [224, 16, 176, 214, 162, 213, 183, 222]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'quoteSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolvePerpPnlDeficit'; + discriminator: [168, 204, 68, 150, 159, 126, 95, 148]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolveSpotBankruptcy'; + discriminator: [124, 194, 240, 254, 198, 213, 52, 122]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'revertFill'; + discriminator: [236, 238, 176, 69, 239, 10, 181, 193]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'setUserStatusToBeingLiquidated'; + discriminator: [106, 133, 160, 206, 193, 171, 192, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'settleExpiredMarket'; + discriminator: [120, 89, 11, 25, 122, 77, 72, 193]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'settleExpiredMarketPoolsToRevenuePool'; + discriminator: [55, 19, 238, 169, 227, 90, 200, 184]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'settleFundingPayment'; + discriminator: [222, 90, 202, 94, 28, 45, 115, 183]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'settleMultiplePnls'; + discriminator: [127, 66, 117, 57, 40, 50, 152, 127]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndexes'; + type: { + vec: 'u16'; + }; + }, + { + name: 'mode'; + type: { + defined: { + name: 'settlePnlMode'; + }; + }; + }, + ]; + }, + { + name: 'settlePerpToLpPool'; + discriminator: [5, 98, 46, 188, 10, 59, 2, 249]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + }, + { + name: 'quoteMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'constituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'constituentQuoteTokenAccount'; + writable: true; + }, + { + name: 'quoteTokenVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: []; + }, + { + name: 'settlePnl'; + discriminator: [43, 61, 234, 45, 15, 95, 152, 153]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'settleRevenueToInsuranceFund'; + discriminator: [200, 120, 93, 136, 69, 38, 199, 159]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'sweepFuel'; + discriminator: [175, 107, 19, 56, 165, 241, 43, 69]; + accounts: [ + { + name: 'fuelOverflow'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['fuelOverflow', 'userStats']; + }, + { + name: 'signer'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'transferDeposit'; + discriminator: [20, 20, 147, 223, 41, 63, 204, 111]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['fromUser', 'toUser', 'userStats']; + }, + { + name: 'state'; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'transferPerpPosition'; + discriminator: [23, 172, 188, 168, 134, 210, 3, 108]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: { + option: 'i64'; + }; + }, + ]; + }, + { + name: 'transferPools'; + discriminator: [197, 103, 154, 25, 107, 90, 60, 94]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['fromUser', 'toUser', 'userStats']; + }, + { + name: 'state'; + }, + { + name: 'depositFromSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'depositFromMarketIndex'; + }, + ]; + }; + }, + { + name: 'depositToSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'depositToMarketIndex'; + }, + ]; + }; + }, + { + name: 'borrowFromSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'borrowFromMarketIndex'; + }, + ]; + }; + }, + { + name: 'borrowToSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'borrowToMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'depositFromMarketIndex'; + type: 'u16'; + }, + { + name: 'depositToMarketIndex'; + type: 'u16'; + }, + { + name: 'borrowFromMarketIndex'; + type: 'u16'; + }, + { + name: 'borrowToMarketIndex'; + type: 'u16'; + }, + { + name: 'depositAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'borrowAmount'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'transferProtocolIfSharesToRevenuePool'; + discriminator: [236, 136, 147, 153, 146, 205, 104, 29]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'triggerOrder'; + discriminator: [63, 112, 51, 233, 232, 47, 240, 199]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateAdmin'; + discriminator: [161, 176, 40, 213, 60, 184, 179, 228]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'admin'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateAmmCache'; + discriminator: [88, 4, 63, 94, 83, 224, 255, 130]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + }, + { + name: 'quoteMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateAmmConstituentMappingData'; + discriminator: [84, 70, 33, 167, 133, 107, 59, 24]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'ammConstituentMappingData'; + type: { + vec: { + defined: { + name: 'addAmmConstituentMappingDatum'; + }; + }; + }; + }, + ]; + }, + { + name: 'updateAmmJitIntensity'; + discriminator: [181, 191, 53, 109, 166, 249, 55, 142]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ammJitIntensity'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateAmms'; + discriminator: [201, 106, 217, 253, 4, 175, 228, 97]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'marketIndexes'; + type: { + vec: 'u16'; + }; + }, + ]; + }, + { + name: 'updateConstituentCorrelationData'; + discriminator: [79, 14, 19, 73, 221, 106, 62, 109]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'index1'; + type: 'u16'; + }, + { + name: 'index2'; + type: 'u16'; + }, + { + name: 'correlation'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateConstituentOracleInfo'; + discriminator: [198, 117, 231, 250, 147, 33, 127, 161]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'spotMarket'; + }, + { + name: 'oracle'; + }, + ]; + args: []; + }, + { + name: 'updateConstituentParams'; + discriminator: [238, 130, 122, 31, 12, 104, 192, 122]; + accounts: [ + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'constituentParams'; + type: { + defined: { + name: 'constituentParams'; + }; + }; + }, + ]; + }, + { + name: 'updateConstituentPausedOperations'; + discriminator: [185, 122, 153, 191, 131, 177, 132, 208]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateConstituentStatus'; + discriminator: [76, 159, 211, 239, 182, 214, 6, 15]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'newStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateDelegateUserGovTokenInsuranceStake'; + discriminator: [241, 29, 215, 228, 142, 116, 22, 160]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: []; + }, + { + name: 'updateDiscountMint'; + discriminator: [32, 252, 122, 211, 66, 31, 47, 241]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'discountMint'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateExchangeStatus'; + discriminator: [83, 160, 252, 250, 129, 116, 49, 223]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'exchangeStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsBuilderCodes'; + discriminator: [1, 128, 177, 51, 173, 45, 11, 102]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMedianTriggerPrice'; + discriminator: [64, 185, 221, 45, 87, 147, 12, 19]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMintRedeemLpPool'; + discriminator: [26, 11, 142, 122, 206, 159, 9, 45]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMmOracle'; + discriminator: [218, 134, 33, 186, 231, 59, 130, 149]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsSettleLpPool'; + discriminator: [186, 28, 78, 230, 155, 83, 242, 26]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsSwapLpPool'; + discriminator: [83, 16, 150, 12, 102, 3, 22, 58]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFundingRate'; + discriminator: [201, 178, 116, 212, 166, 144, 72, 238]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateHighLeverageModeConfig'; + discriminator: [64, 122, 212, 93, 141, 217, 202, 55]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'currentUsers'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updateIfRebalanceConfig'; + discriminator: [142, 245, 249, 66, 249, 181, 22, 83]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'ifRebalanceConfigParams'; + }; + }; + }, + ]; + }, + { + name: 'updateInitialAmmCacheInfo'; + discriminator: [157, 210, 109, 67, 212, 170, 12, 107]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateInitialPctToLiquidate'; + discriminator: [210, 133, 225, 128, 194, 50, 13, 109]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'initialPctToLiquidate'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateInsuranceFundUnstakingPeriod'; + discriminator: [44, 69, 43, 226, 204, 223, 202, 52]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'insuranceFundUnstakingPeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateK'; + discriminator: [72, 98, 9, 139, 129, 229, 172, 56]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'updateLiquidationDuration'; + discriminator: [28, 154, 20, 249, 102, 192, 73, 71]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidationDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateLiquidationMarginBufferRatio'; + discriminator: [132, 224, 243, 160, 154, 82, 97, 215]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidationMarginBufferRatio'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateLpConstituentTargetBase'; + discriminator: [157, 65, 50, 207, 59, 236, 161, 110]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'ammConstituentMapping'; + }, + { + name: 'constituentTargetBase'; + writable: true; + }, + { + name: 'ammCache'; + }, + { + name: 'lpPool'; + }, + ]; + args: []; + }, + { + name: 'updateLpPoolAum'; + discriminator: [88, 113, 137, 206, 246, 247, 171, 142]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'constituentTargetBase'; + writable: true; + }, + { + name: 'ammCache'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateLpPoolParams'; + discriminator: [217, 92, 2, 255, 27, 167, 178, 81]; + accounts: [ + { + name: 'lpPool'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'lpPoolParams'; + type: { + defined: { + name: 'lpPoolParams'; + }; + }; + }, + ]; + }, + { + name: 'updateOracleGuardRails'; + discriminator: [131, 112, 10, 59, 32, 54, 40, 164]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleGuardRails'; + type: { + defined: { + name: 'oracleGuardRails'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpAuctionDuration'; + discriminator: [126, 110, 52, 174, 30, 206, 215, 90]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'minPerpAuctionDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpBidAskTwap'; + discriminator: [247, 23, 255, 65, 212, 90, 221, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'keeperStats'; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'updatePerpFeeStructure'; + discriminator: [23, 178, 111, 203, 73, 22, 140, 75]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'feeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketAmmOracleTwap'; + discriminator: [241, 74, 114, 123, 206, 153, 24, 202]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: []; + }, + { + name: 'updatePerpMarketAmmSpreadAdjustment'; + discriminator: [155, 195, 149, 43, 220, 82, 173, 205]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ammSpreadAdjustment'; + type: 'i8'; + }, + { + name: 'ammInventorySpreadAdjustment'; + type: 'i8'; + }, + { + name: 'referencePriceOffset'; + type: 'i32'; + }, + ]; + }, + { + name: 'updatePerpMarketAmmSummaryStats'; + discriminator: [122, 101, 249, 238, 209, 9, 241, 245]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'perpMarket'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'updatePerpMarketSummaryStatsParams'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketBaseSpread'; + discriminator: [71, 95, 84, 168, 9, 157, 198, 65]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'baseSpread'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketConcentrationCoef'; + discriminator: [24, 78, 232, 126, 169, 176, 230, 16]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'concentrationScale'; + type: 'u128'; + }, + ]; + }, + { + name: 'updatePerpMarketContractTier'; + discriminator: [236, 128, 15, 95, 203, 214, 68, 117]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'contractTier'; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketCurveUpdateIntensity'; + discriminator: [50, 131, 6, 156, 226, 231, 189, 72]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'curveUpdateIntensity'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketExpiry'; + discriminator: [44, 221, 227, 151, 131, 140, 22, 110]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'expiryTs'; + type: 'i64'; + }, + ]; + }, + { + name: 'updatePerpMarketFeeAdjustment'; + discriminator: [194, 174, 87, 102, 43, 148, 32, 112]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'feeAdjustment'; + type: 'i16'; + }, + ]; + }, + { + name: 'updatePerpMarketFundingPeriod'; + discriminator: [171, 161, 69, 91, 129, 139, 161, 28]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'fundingPeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updatePerpMarketHighLeverageMarginRatio'; + discriminator: [88, 112, 86, 49, 24, 116, 74, 157]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marginRatioInitial'; + type: 'u16'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketImfFactor'; + discriminator: [207, 194, 56, 132, 35, 67, 71, 244]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'unrealizedPnlImfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketLiquidationFee'; + discriminator: [90, 137, 9, 145, 41, 8, 148, 117]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolFeeTransferScalar'; + discriminator: [94, 228, 237, 109, 100, 185, 4, 81]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'optionalLpFeeTransferScalar'; + type: { + option: 'u8'; + }; + }, + { + name: 'optionalLpNetPnlTransferScalar'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolId'; + discriminator: [119, 208, 154, 88, 165, 92, 21, 188]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'lpPoolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolPausedOperations'; + discriminator: [181, 94, 93, 146, 51, 89, 32, 135]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'lpPausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolStatus'; + discriminator: [67, 6, 252, 61, 54, 88, 89, 233]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'lpStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketMarginRatio'; + discriminator: [130, 173, 107, 45, 119, 105, 26, 113]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marginRatioInitial'; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxFillReserveFraction'; + discriminator: [19, 172, 114, 154, 42, 135, 161, 133]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxFillReserveFraction'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxImbalances'; + discriminator: [15, 206, 73, 133, 60, 8, 86, 89]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'unrealizedMaxImbalance'; + type: 'u64'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxOpenInterest'; + discriminator: [194, 79, 149, 224, 246, 102, 186, 140]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxOpenInterest'; + type: 'u128'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxSlippageRatio'; + discriminator: [235, 37, 40, 196, 70, 146, 54, 201]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxSlippageRatio'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxSpread'; + discriminator: [80, 252, 122, 62, 40, 218, 91, 100]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxSpread'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketMinOrderSize'; + discriminator: [226, 74, 5, 89, 108, 223, 46, 141]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'orderSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketName'; + discriminator: [211, 31, 21, 210, 64, 108, 66, 201]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updatePerpMarketNumberOfUsers'; + discriminator: [35, 62, 144, 177, 180, 62, 215, 196]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'numberOfUsers'; + type: { + option: 'u32'; + }; + }, + { + name: 'numberOfUsersWithBase'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketOracle'; + discriminator: [182, 113, 111, 160, 67, 174, 89, 191]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'oldOracle'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'skipInvariantCheck'; + type: 'bool'; + }, + ]; + }, + { + name: 'updatePerpMarketOracleLowRiskSlotDelayOverride'; + discriminator: [124, 108, 147, 229, 109, 117, 123, 3]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleLowRiskSlotDelayOverride'; + type: 'i8'; + }, + ]; + }, + { + name: 'updatePerpMarketOracleSlotDelayOverride'; + discriminator: [165, 91, 239, 227, 63, 172, 227, 8]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleSlotDelayOverride'; + type: 'i8'; + }, + ]; + }, + { + name: 'updatePerpMarketPausedOperations'; + discriminator: [53, 16, 136, 132, 30, 220, 121, 85]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketPnlPool'; + discriminator: [50, 202, 249, 224, 166, 184, 13, 143]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketProtectedMakerParams'; + discriminator: [249, 213, 115, 34, 253, 239, 75, 173]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'protectedMakerLimitPriceDivisor'; + type: { + option: 'u8'; + }; + }, + { + name: 'protectedMakerDynamicDivisor'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketReferencePriceOffsetDeadbandPct'; + discriminator: [214, 73, 166, 11, 218, 76, 110, 163]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'referencePriceOffsetDeadbandPct'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketStatus'; + discriminator: [71, 201, 175, 122, 255, 207, 196, 207]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketStepSizeAndTickSize'; + discriminator: [231, 255, 97, 25, 146, 139, 174, 4]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'stepSize'; + type: 'u64'; + }, + { + name: 'tickSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketUnrealizedAssetWeight'; + discriminator: [135, 132, 205, 165, 109, 150, 166, 106]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'unrealizedInitialAssetWeight'; + type: 'u32'; + }, + { + name: 'unrealizedMaintenanceAssetWeight'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePrelaunchOracle'; + discriminator: [220, 132, 27, 27, 233, 220, 61, 219]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + }, + { + name: 'oracle'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updatePrelaunchOracleParams'; + discriminator: [98, 205, 147, 243, 18, 75, 83, 207]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'params.perp_market_index'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'prelaunchOracleParams'; + }; + }; + }, + ]; + }, + { + name: 'updateProtectedMakerModeConfig'; + discriminator: [86, 166, 235, 253, 67, 202, 223, 17]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'currentUsers'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updatePythPullOracle'; + discriminator: [230, 191, 189, 94, 108, 59, 74, 197]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'encodedVaa'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'updateSerumFulfillmentConfigStatus'; + discriminator: [171, 109, 240, 251, 95, 1, 149, 89]; + accounts: [ + { + name: 'state'; + }, + { + name: 'serumFulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotAuctionDuration'; + discriminator: [182, 178, 203, 72, 187, 143, 157, 107]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'defaultSpotAuctionDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotFeeStructure'; + discriminator: [97, 216, 105, 131, 113, 246, 142, 141]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'feeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketAssetTier'; + discriminator: [253, 209, 231, 14, 242, 208, 243, 130]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'assetTier'; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketBorrowRate'; + discriminator: [71, 239, 236, 153, 210, 62, 254, 76]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'optimalUtilization'; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + type: 'u32'; + }, + { + name: 'minBorrowRate'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updateSpotMarketCumulativeInterest'; + discriminator: [39, 166, 139, 243, 158, 165, 155, 225]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateSpotMarketExpiry'; + discriminator: [208, 11, 211, 159, 226, 24, 11, 247]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'expiryTs'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateSpotMarketFeeAdjustment'; + discriminator: [148, 182, 3, 126, 157, 114, 220, 99]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'feeAdjustment'; + type: 'i16'; + }, + ]; + }, + { + name: 'updateSpotMarketIfFactor'; + discriminator: [147, 30, 224, 34, 18, 230, 105, 4]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'userIfFactor'; + type: 'u32'; + }, + { + name: 'totalIfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketIfPausedOperations'; + discriminator: [101, 215, 79, 74, 59, 41, 79, 12]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketLiquidationFee'; + discriminator: [11, 13, 255, 53, 56, 136, 104, 177]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketMarginWeights'; + discriminator: [109, 33, 87, 195, 255, 36, 6, 81]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'initialAssetWeight'; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketMaxTokenBorrows'; + discriminator: [57, 102, 204, 212, 253, 95, 13, 199]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxTokenBorrowsFraction'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateSpotMarketMaxTokenDeposits'; + discriminator: [56, 191, 79, 18, 26, 121, 80, 208]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxTokenDeposits'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketMinOrderSize'; + discriminator: [93, 128, 11, 119, 26, 20, 181, 50]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'orderSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketName'; + discriminator: [17, 208, 1, 1, 162, 211, 188, 224]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updateSpotMarketOracle'; + discriminator: [114, 184, 102, 37, 246, 186, 180, 99]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'oldOracle'; + }, + ]; + args: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'skipInvariantCheck'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateSpotMarketOrdersEnabled'; + discriminator: [190, 79, 206, 15, 26, 229, 229, 43]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ordersEnabled'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateSpotMarketPausedOperations'; + discriminator: [100, 61, 153, 81, 180, 12, 6, 248]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketPoolId'; + discriminator: [22, 213, 197, 160, 139, 193, 81, 149]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'poolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketRevenueSettlePeriod'; + discriminator: [81, 92, 126, 41, 250, 225, 156, 219]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'revenueSettlePeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateSpotMarketScaleInitialAssetWeightStart'; + discriminator: [217, 204, 204, 118, 204, 130, 225, 147]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'scaleInitialAssetWeightStart'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketStatus'; + discriminator: [78, 94, 16, 188, 193, 110, 231, 31]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketStepSizeAndTickSize'; + discriminator: [238, 153, 137, 80, 206, 59, 250, 61]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'stepSize'; + type: 'u64'; + }, + { + name: 'tickSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateStateMaxInitializeUserFee'; + discriminator: [237, 225, 25, 237, 193, 45, 77, 97]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'maxInitializeUserFee'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateStateMaxNumberOfSubAccounts'; + discriminator: [155, 123, 214, 2, 221, 166, 204, 85]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'maxNumberOfSubAccounts'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateStateSettlementDuration'; + discriminator: [97, 68, 199, 235, 131, 80, 61, 173]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'settlementDuration'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateUserCustomMarginRatio'; + discriminator: [21, 221, 140, 187, 32, 129, 11, 123]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'marginRatio'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateUserDelegate'; + discriminator: [139, 205, 141, 141, 113, 36, 94, 187]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'delegate'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateUserGovTokenInsuranceStake'; + discriminator: [143, 99, 235, 187, 20, 159, 184, 84]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signer'; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateUserIdle'; + discriminator: [253, 133, 67, 22, 103, 161, 20, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateUserMarginTradingEnabled'; + discriminator: [194, 92, 204, 223, 246, 188, 31, 203]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'marginTradingEnabled'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserName'; + discriminator: [135, 25, 185, 56, 165, 53, 34, 136]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updateUserPerpPositionCustomMarginRatio'; + discriminator: [121, 137, 157, 155, 89, 186, 145, 113]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marginRatio'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateUserPoolId'; + discriminator: [219, 86, 73, 106, 56, 218, 128, 109]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateUserProtectedMakerOrders'; + discriminator: [114, 39, 123, 198, 187, 25, 90, 219]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'protectedMakerOrders'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserQuoteAssetInsuranceStake'; + discriminator: [251, 101, 156, 7, 2, 63, 30, 23]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signer'; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateUserReduceOnly'; + discriminator: [199, 71, 42, 67, 144, 19, 86, 109]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserStatsReferrerStatus'; + discriminator: [174, 154, 72, 42, 191, 148, 145, 205]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateWithdrawGuardThreshold'; + discriminator: [56, 18, 39, 61, 155, 211, 44, 133]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'withdrawGuardThreshold'; + type: 'u64'; + }, + ]; + }, + { + name: 'viewLpPoolAddLiquidityFees'; + discriminator: [80, 66, 226, 161, 70, 142, 119, 84]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'inMarketMint'; + }, + { + name: 'inConstituent'; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + }, + { + name: 'constituentTargetBase'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u128'; + }, + ]; + }, + { + name: 'viewLpPoolRemoveLiquidityFees'; + discriminator: [47, 12, 9, 102, 12, 226, 197, 89]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outMarketMint'; + }, + { + name: 'outConstituent'; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + }, + { + name: 'constituentTargetBase'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'viewLpPoolSwapFees'; + discriminator: [126, 189, 109, 189, 170, 156, 3, 46]; + accounts: [ + { + name: 'driftSigner'; + }, + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'constituentCorrelations'; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'inTargetWeight'; + type: 'i64'; + }, + { + name: 'outTargetWeight'; + type: 'i64'; + }, + ]; + }, + { + name: 'withdraw'; + discriminator: [183, 18, 70, 156, 148, 109, 161, 34]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['user', 'userStats']; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'withdrawFromProgramVault'; + discriminator: [120, 40, 183, 149, 232, 18, 224, 151]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'driftSigner'; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'constituentTokenAccount'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'mint'; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'zeroMmOracleFields'; + discriminator: [192, 226, 39, 204, 207, 120, 148, 250]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: 'ammCache'; + discriminator: [213, 114, 161, 56, 20, 22, 2, 59]; + }, + { + name: 'ammConstituentMapping'; + discriminator: [254, 89, 5, 173, 66, 54, 214, 247]; + }, + { + name: 'constituent'; + discriminator: [0, 61, 36, 35, 177, 76, 216, 205]; + }, + { + name: 'constituentCorrelations'; + discriminator: [124, 203, 115, 33, 18, 162, 67, 216]; + }, + { + name: 'constituentTargetBase'; + discriminator: [255, 142, 134, 71, 125, 66, 198, 99]; + }, + { + name: 'fuelOverflow'; + discriminator: [182, 64, 231, 177, 226, 142, 69, 58]; + }, + { + name: 'highLeverageModeConfig'; + discriminator: [3, 196, 90, 189, 193, 64, 228, 234]; + }, + { + name: 'ifRebalanceConfig'; + discriminator: [214, 84, 40, 251, 107, 144, 173, 239]; + }, + { + name: 'insuranceFundStake'; + discriminator: [110, 202, 14, 42, 95, 73, 90, 95]; + }, + { + name: 'lpPool'; + discriminator: [228, 152, 141, 224, 161, 170, 11, 89]; + }, + { + name: 'openbookV2FulfillmentConfig'; + discriminator: [3, 43, 58, 106, 131, 132, 199, 171]; + }, + { + name: 'perpMarket'; + discriminator: [10, 223, 12, 44, 107, 245, 55, 247]; + }, + { + name: 'phoenixV1FulfillmentConfig'; + discriminator: [233, 45, 62, 40, 35, 129, 48, 72]; + }, + { + name: 'prelaunchOracle'; + discriminator: [92, 14, 139, 234, 72, 244, 68, 26]; + }, + { + name: 'protectedMakerModeConfig'; + discriminator: [47, 86, 90, 9, 224, 255, 10, 69]; + }, + { + name: 'pythLazerOracle'; + discriminator: [159, 7, 161, 249, 34, 81, 121, 133]; + }, + { + name: 'referrerName'; + discriminator: [105, 133, 170, 110, 52, 42, 28, 182]; + }, + { + name: 'revenueShare'; + discriminator: [55, 40, 228, 7, 139, 52, 180, 110]; + }, + { + name: 'revenueShareEscrow'; + discriminator: [98, 167, 3, 46, 74, 177, 173, 252]; + }, + { + name: 'serumV3FulfillmentConfig'; + discriminator: [65, 160, 197, 112, 239, 168, 103, 185]; + }, + { + name: 'signedMsgUserOrders'; + discriminator: [70, 6, 50, 248, 222, 1, 143, 49]; + }, + { + name: 'signedMsgWsDelegates'; + discriminator: [190, 115, 111, 44, 216, 252, 108, 85]; + }, + { + name: 'spotMarket'; + discriminator: [100, 177, 8, 107, 168, 65, 65, 39]; + }, + { + name: 'state'; + discriminator: [216, 146, 107, 94, 104, 75, 182, 177]; + }, + { + name: 'user'; + discriminator: [159, 117, 95, 227, 239, 151, 58, 236]; + }, + { + name: 'userStats'; + discriminator: [176, 223, 136, 27, 122, 79, 32, 227]; + }, + ]; + events: [ + { + name: 'curveRecord'; + discriminator: [101, 238, 40, 228, 70, 46, 61, 117]; + }, + { + name: 'deleteUserRecord'; + discriminator: [71, 111, 190, 118, 7, 3, 132, 222]; + }, + { + name: 'depositRecord'; + discriminator: [180, 241, 218, 207, 102, 135, 44, 134]; + }, + { + name: 'fuelSeasonRecord'; + discriminator: [19, 137, 119, 33, 224, 249, 6, 87]; + }, + { + name: 'fuelSweepRecord'; + discriminator: [41, 84, 37, 246, 132, 240, 131, 8]; + }, + { + name: 'fundingPaymentRecord'; + discriminator: [8, 59, 96, 20, 137, 201, 56, 95]; + }, + { + name: 'fundingRateRecord'; + discriminator: [68, 3, 255, 26, 133, 91, 147, 254]; + }, + { + name: 'insuranceFundRecord'; + discriminator: [56, 222, 215, 235, 78, 197, 99, 146]; + }, + { + name: 'insuranceFundStakeRecord'; + discriminator: [68, 66, 156, 7, 216, 148, 250, 114]; + }, + { + name: 'insuranceFundSwapRecord'; + discriminator: [85, 190, 99, 203, 237, 33, 227, 100]; + }, + { + name: 'lpBorrowLendDepositRecord'; + discriminator: [242, 181, 11, 56, 243, 61, 79, 210]; + }, + { + name: 'lpMintRedeemRecord'; + discriminator: [53, 178, 142, 73, 78, 91, 91, 8]; + }, + { + name: 'lpRecord'; + discriminator: [101, 22, 54, 38, 178, 13, 142, 111]; + }, + { + name: 'lpSettleRecord'; + discriminator: [208, 191, 131, 110, 173, 48, 7, 2]; + }, + { + name: 'lpSwapRecord'; + discriminator: [159, 62, 130, 196, 96, 79, 176, 254]; + }, + { + name: 'liquidationRecord'; + discriminator: [127, 17, 0, 108, 182, 13, 231, 53]; + }, + { + name: 'newUserRecord'; + discriminator: [236, 186, 113, 219, 42, 51, 149, 249]; + }, + { + name: 'orderActionRecord'; + discriminator: [224, 52, 67, 71, 194, 237, 109, 1]; + }, + { + name: 'orderRecord'; + discriminator: [104, 19, 64, 56, 89, 21, 2, 90]; + }, + { + name: 'revenueShareSettleRecord'; + discriminator: [61, 162, 89, 10, 24, 20, 59, 45]; + }, + { + name: 'settlePnlRecord'; + discriminator: [57, 68, 105, 26, 119, 198, 213, 89]; + }, + { + name: 'signedMsgOrderRecord'; + discriminator: [211, 197, 25, 18, 142, 86, 113, 27]; + }, + { + name: 'spotInterestRecord'; + discriminator: [183, 186, 203, 186, 225, 187, 95, 130]; + }, + { + name: 'spotMarketVaultDepositRecord'; + discriminator: [178, 217, 23, 188, 127, 190, 32, 73]; + }, + { + name: 'swapRecord'; + discriminator: [162, 187, 123, 194, 138, 56, 250, 241]; + }, + { + name: 'transferProtocolIfSharesToRevenuePoolRecord'; + discriminator: [209, 118, 142, 167, 130, 46, 164, 151]; + }, + ]; + errors: [ + { + code: 6000; + name: 'invalidSpotMarketAuthority'; + msg: 'Invalid Spot Market Authority'; + }, + { + code: 6001; + name: 'invalidInsuranceFundAuthority'; + msg: 'Clearing house not insurance fund authority'; + }, + { + code: 6002; + name: 'insufficientDeposit'; + msg: 'Insufficient deposit'; + }, + { + code: 6003; + name: 'insufficientCollateral'; + msg: 'Insufficient collateral'; + }, + { + code: 6004; + name: 'sufficientCollateral'; + msg: 'Sufficient collateral'; + }, + { + code: 6005; + name: 'maxNumberOfPositions'; + msg: 'Max number of positions taken'; + }, + { + code: 6006; + name: 'adminControlsPricesDisabled'; + msg: 'Admin Controls Prices Disabled'; + }, + { + code: 6007; + name: 'marketDelisted'; + msg: 'Market Delisted'; + }, + { + code: 6008; + name: 'marketIndexAlreadyInitialized'; + msg: 'Market Index Already Initialized'; + }, + { + code: 6009; + name: 'userAccountAndUserPositionsAccountMismatch'; + msg: 'User Account And User Positions Account Mismatch'; + }, + { + code: 6010; + name: 'userHasNoPositionInMarket'; + msg: 'User Has No Position In Market'; + }, + { + code: 6011; + name: 'invalidInitialPeg'; + msg: 'Invalid Initial Peg'; + }, + { + code: 6012; + name: 'invalidRepegRedundant'; + msg: 'AMM repeg already configured with amt given'; + }, + { + code: 6013; + name: 'invalidRepegDirection'; + msg: 'AMM repeg incorrect repeg direction'; + }, + { + code: 6014; + name: 'invalidRepegProfitability'; + msg: 'AMM repeg out of bounds pnl'; + }, + { + code: 6015; + name: 'slippageOutsideLimit'; + msg: 'Slippage Outside Limit Price'; + }, + { + code: 6016; + name: 'orderSizeTooSmall'; + msg: 'Order Size Too Small'; + }, + { + code: 6017; + name: 'invalidUpdateK'; + msg: 'Price change too large when updating K'; + }, + { + code: 6018; + name: 'adminWithdrawTooLarge'; + msg: 'Admin tried to withdraw amount larger than fees collected'; + }, + { + code: 6019; + name: 'mathError'; + msg: 'Math Error'; + }, + { + code: 6020; + name: 'bnConversionError'; + msg: 'Conversion to u128/u64 failed with an overflow or underflow'; + }, + { + code: 6021; + name: 'clockUnavailable'; + msg: 'Clock unavailable'; + }, + { + code: 6022; + name: 'unableToLoadOracle'; + msg: 'Unable To Load Oracles'; + }, + { + code: 6023; + name: 'priceBandsBreached'; + msg: 'Price Bands Breached'; + }, + { + code: 6024; + name: 'exchangePaused'; + msg: 'Exchange is paused'; + }, + { + code: 6025; + name: 'invalidWhitelistToken'; + msg: 'Invalid whitelist token'; + }, + { + code: 6026; + name: 'whitelistTokenNotFound'; + msg: 'Whitelist token not found'; + }, + { + code: 6027; + name: 'invalidDiscountToken'; + msg: 'Invalid discount token'; + }, + { + code: 6028; + name: 'discountTokenNotFound'; + msg: 'Discount token not found'; + }, + { + code: 6029; + name: 'referrerNotFound'; + msg: 'Referrer not found'; + }, + { + code: 6030; + name: 'referrerStatsNotFound'; + msg: 'referrerNotFound'; + }, + { + code: 6031; + name: 'referrerMustBeWritable'; + msg: 'referrerMustBeWritable'; + }, + { + code: 6032; + name: 'referrerStatsMustBeWritable'; + msg: 'referrerMustBeWritable'; + }, + { + code: 6033; + name: 'referrerAndReferrerStatsAuthorityUnequal'; + msg: 'referrerAndReferrerStatsAuthorityUnequal'; + }, + { + code: 6034; + name: 'invalidReferrer'; + msg: 'invalidReferrer'; + }, + { + code: 6035; + name: 'invalidOracle'; + msg: 'invalidOracle'; + }, + { + code: 6036; + name: 'oracleNotFound'; + msg: 'oracleNotFound'; + }, + { + code: 6037; + name: 'liquidationsBlockedByOracle'; + msg: 'Liquidations Blocked By Oracle'; + }, + { + code: 6038; + name: 'maxDeposit'; + msg: 'Can not deposit more than max deposit'; + }, + { + code: 6039; + name: 'cantDeleteUserWithCollateral'; + msg: 'Can not delete user that still has collateral'; + }, + { + code: 6040; + name: 'invalidFundingProfitability'; + msg: 'AMM funding out of bounds pnl'; + }, + { + code: 6041; + name: 'castingFailure'; + msg: 'Casting Failure'; + }, + { + code: 6042; + name: 'invalidOrder'; + msg: 'invalidOrder'; + }, + { + code: 6043; + name: 'invalidOrderMaxTs'; + msg: 'invalidOrderMaxTs'; + }, + { + code: 6044; + name: 'invalidOrderMarketType'; + msg: 'invalidOrderMarketType'; + }, + { + code: 6045; + name: 'invalidOrderForInitialMarginReq'; + msg: 'invalidOrderForInitialMarginReq'; + }, + { + code: 6046; + name: 'invalidOrderNotRiskReducing'; + msg: 'invalidOrderNotRiskReducing'; + }, + { + code: 6047; + name: 'invalidOrderSizeTooSmall'; + msg: 'invalidOrderSizeTooSmall'; + }, + { + code: 6048; + name: 'invalidOrderNotStepSizeMultiple'; + msg: 'invalidOrderNotStepSizeMultiple'; + }, + { + code: 6049; + name: 'invalidOrderBaseQuoteAsset'; + msg: 'invalidOrderBaseQuoteAsset'; + }, + { + code: 6050; + name: 'invalidOrderIoc'; + msg: 'invalidOrderIoc'; + }, + { + code: 6051; + name: 'invalidOrderPostOnly'; + msg: 'invalidOrderPostOnly'; + }, + { + code: 6052; + name: 'invalidOrderIocPostOnly'; + msg: 'invalidOrderIocPostOnly'; + }, + { + code: 6053; + name: 'invalidOrderTrigger'; + msg: 'invalidOrderTrigger'; + }, + { + code: 6054; + name: 'invalidOrderAuction'; + msg: 'invalidOrderAuction'; + }, + { + code: 6055; + name: 'invalidOrderOracleOffset'; + msg: 'invalidOrderOracleOffset'; + }, + { + code: 6056; + name: 'invalidOrderMinOrderSize'; + msg: 'invalidOrderMinOrderSize'; + }, + { + code: 6057; + name: 'placePostOnlyLimitFailure'; + msg: 'Failed to Place Post-Only Limit Order'; + }, + { + code: 6058; + name: 'userHasNoOrder'; + msg: 'User has no order'; + }, + { + code: 6059; + name: 'orderAmountTooSmall'; + msg: 'Order Amount Too Small'; + }, + { + code: 6060; + name: 'maxNumberOfOrders'; + msg: 'Max number of orders taken'; + }, + { + code: 6061; + name: 'orderDoesNotExist'; + msg: 'Order does not exist'; + }, + { + code: 6062; + name: 'orderNotOpen'; + msg: 'Order not open'; + }, + { + code: 6063; + name: 'fillOrderDidNotUpdateState'; + msg: 'fillOrderDidNotUpdateState'; + }, + { + code: 6064; + name: 'reduceOnlyOrderIncreasedRisk'; + msg: 'Reduce only order increased risk'; + }, + { + code: 6065; + name: 'unableToLoadAccountLoader'; + msg: 'Unable to load AccountLoader'; + }, + { + code: 6066; + name: 'tradeSizeTooLarge'; + msg: 'Trade Size Too Large'; + }, + { + code: 6067; + name: 'userCantReferThemselves'; + msg: 'User cant refer themselves'; + }, + { + code: 6068; + name: 'didNotReceiveExpectedReferrer'; + msg: 'Did not receive expected referrer'; + }, + { + code: 6069; + name: 'couldNotDeserializeReferrer'; + msg: 'Could not deserialize referrer'; + }, + { + code: 6070; + name: 'couldNotDeserializeReferrerStats'; + msg: 'Could not deserialize referrer stats'; + }, + { + code: 6071; + name: 'userOrderIdAlreadyInUse'; + msg: 'User Order Id Already In Use'; + }, + { + code: 6072; + name: 'noPositionsLiquidatable'; + msg: 'No positions liquidatable'; + }, + { + code: 6073; + name: 'invalidMarginRatio'; + msg: 'Invalid Margin Ratio'; + }, + { + code: 6074; + name: 'cantCancelPostOnlyOrder'; + msg: 'Cant Cancel Post Only Order'; + }, + { + code: 6075; + name: 'invalidOracleOffset'; + msg: 'invalidOracleOffset'; + }, + { + code: 6076; + name: 'cantExpireOrders'; + msg: 'cantExpireOrders'; + }, + { + code: 6077; + name: 'couldNotLoadMarketData'; + msg: 'couldNotLoadMarketData'; + }, + { + code: 6078; + name: 'perpMarketNotFound'; + msg: 'perpMarketNotFound'; + }, + { + code: 6079; + name: 'invalidMarketAccount'; + msg: 'invalidMarketAccount'; + }, + { + code: 6080; + name: 'unableToLoadPerpMarketAccount'; + msg: 'unableToLoadMarketAccount'; + }, + { + code: 6081; + name: 'marketWrongMutability'; + msg: 'marketWrongMutability'; + }, + { + code: 6082; + name: 'unableToCastUnixTime'; + msg: 'unableToCastUnixTime'; + }, + { + code: 6083; + name: 'couldNotFindSpotPosition'; + msg: 'couldNotFindSpotPosition'; + }, + { + code: 6084; + name: 'noSpotPositionAvailable'; + msg: 'noSpotPositionAvailable'; + }, + { + code: 6085; + name: 'invalidSpotMarketInitialization'; + msg: 'invalidSpotMarketInitialization'; + }, + { + code: 6086; + name: 'couldNotLoadSpotMarketData'; + msg: 'couldNotLoadSpotMarketData'; + }, + { + code: 6087; + name: 'spotMarketNotFound'; + msg: 'spotMarketNotFound'; + }, + { + code: 6088; + name: 'invalidSpotMarketAccount'; + msg: 'invalidSpotMarketAccount'; + }, + { + code: 6089; + name: 'unableToLoadSpotMarketAccount'; + msg: 'unableToLoadSpotMarketAccount'; + }, + { + code: 6090; + name: 'spotMarketWrongMutability'; + msg: 'spotMarketWrongMutability'; + }, + { + code: 6091; + name: 'spotMarketInterestNotUpToDate'; + msg: 'spotInterestNotUpToDate'; + }, + { + code: 6092; + name: 'spotMarketInsufficientDeposits'; + msg: 'spotMarketInsufficientDeposits'; + }, + { + code: 6093; + name: 'userMustSettleTheirOwnPositiveUnsettledPnl'; + msg: 'userMustSettleTheirOwnPositiveUnsettledPnl'; + }, + { + code: 6094; + name: 'cantUpdatePoolBalanceType'; + msg: 'cantUpdatePoolBalanceType'; + }, + { + code: 6095; + name: 'insufficientCollateralForSettlingPnl'; + msg: 'insufficientCollateralForSettlingPnl'; + }, + { + code: 6096; + name: 'ammNotUpdatedInSameSlot'; + msg: 'ammNotUpdatedInSameSlot'; + }, + { + code: 6097; + name: 'auctionNotComplete'; + msg: 'auctionNotComplete'; + }, + { + code: 6098; + name: 'makerNotFound'; + msg: 'makerNotFound'; + }, + { + code: 6099; + name: 'makerStatsNotFound'; + msg: 'makerNotFound'; + }, + { + code: 6100; + name: 'makerMustBeWritable'; + msg: 'makerMustBeWritable'; + }, + { + code: 6101; + name: 'makerStatsMustBeWritable'; + msg: 'makerMustBeWritable'; + }, + { + code: 6102; + name: 'makerOrderNotFound'; + msg: 'makerOrderNotFound'; + }, + { + code: 6103; + name: 'couldNotDeserializeMaker'; + msg: 'couldNotDeserializeMaker'; + }, + { + code: 6104; + name: 'couldNotDeserializeMakerStats'; + msg: 'couldNotDeserializeMaker'; + }, + { + code: 6105; + name: 'auctionPriceDoesNotSatisfyMaker'; + msg: 'auctionPriceDoesNotSatisfyMaker'; + }, + { + code: 6106; + name: 'makerCantFulfillOwnOrder'; + msg: 'makerCantFulfillOwnOrder'; + }, + { + code: 6107; + name: 'makerOrderMustBePostOnly'; + msg: 'makerOrderMustBePostOnly'; + }, + { + code: 6108; + name: 'cantMatchTwoPostOnlys'; + msg: 'cantMatchTwoPostOnlys'; + }, + { + code: 6109; + name: 'orderBreachesOraclePriceLimits'; + msg: 'orderBreachesOraclePriceLimits'; + }, + { + code: 6110; + name: 'orderMustBeTriggeredFirst'; + msg: 'orderMustBeTriggeredFirst'; + }, + { + code: 6111; + name: 'orderNotTriggerable'; + msg: 'orderNotTriggerable'; + }, + { + code: 6112; + name: 'orderDidNotSatisfyTriggerCondition'; + msg: 'orderDidNotSatisfyTriggerCondition'; + }, + { + code: 6113; + name: 'positionAlreadyBeingLiquidated'; + msg: 'positionAlreadyBeingLiquidated'; + }, + { + code: 6114; + name: 'positionDoesntHaveOpenPositionOrOrders'; + msg: 'positionDoesntHaveOpenPositionOrOrders'; + }, + { + code: 6115; + name: 'allOrdersAreAlreadyLiquidations'; + msg: 'allOrdersAreAlreadyLiquidations'; + }, + { + code: 6116; + name: 'cantCancelLiquidationOrder'; + msg: 'cantCancelLiquidationOrder'; + }, + { + code: 6117; + name: 'userIsBeingLiquidated'; + msg: 'userIsBeingLiquidated'; + }, + { + code: 6118; + name: 'liquidationsOngoing'; + msg: 'liquidationsOngoing'; + }, + { + code: 6119; + name: 'wrongSpotBalanceType'; + msg: 'wrongSpotBalanceType'; + }, + { + code: 6120; + name: 'userCantLiquidateThemself'; + msg: 'userCantLiquidateThemself'; + }, + { + code: 6121; + name: 'invalidPerpPositionToLiquidate'; + msg: 'invalidPerpPositionToLiquidate'; + }, + { + code: 6122; + name: 'invalidBaseAssetAmountForLiquidatePerp'; + msg: 'invalidBaseAssetAmountForLiquidatePerp'; + }, + { + code: 6123; + name: 'invalidPositionLastFundingRate'; + msg: 'invalidPositionLastFundingRate'; + }, + { + code: 6124; + name: 'invalidPositionDelta'; + msg: 'invalidPositionDelta'; + }, + { + code: 6125; + name: 'userBankrupt'; + msg: 'userBankrupt'; + }, + { + code: 6126; + name: 'userNotBankrupt'; + msg: 'userNotBankrupt'; + }, + { + code: 6127; + name: 'userHasInvalidBorrow'; + msg: 'userHasInvalidBorrow'; + }, + { + code: 6128; + name: 'dailyWithdrawLimit'; + msg: 'dailyWithdrawLimit'; + }, + { + code: 6129; + name: 'defaultError'; + msg: 'defaultError'; + }, + { + code: 6130; + name: 'insufficientLpTokens'; + msg: 'Insufficient LP tokens'; + }, + { + code: 6131; + name: 'cantLpWithPerpPosition'; + msg: 'Cant LP with a market position'; + }, + { + code: 6132; + name: 'unableToBurnLpTokens'; + msg: 'Unable to burn LP tokens'; + }, + { + code: 6133; + name: 'tryingToRemoveLiquidityTooFast'; + msg: 'Trying to remove liqudity too fast after adding it'; + }, + { + code: 6134; + name: 'invalidSpotMarketVault'; + msg: 'Invalid Spot Market Vault'; + }, + { + code: 6135; + name: 'invalidSpotMarketState'; + msg: 'Invalid Spot Market State'; + }, + { + code: 6136; + name: 'invalidSerumProgram'; + msg: 'invalidSerumProgram'; + }, + { + code: 6137; + name: 'invalidSerumMarket'; + msg: 'invalidSerumMarket'; + }, + { + code: 6138; + name: 'invalidSerumBids'; + msg: 'invalidSerumBids'; + }, + { + code: 6139; + name: 'invalidSerumAsks'; + msg: 'invalidSerumAsks'; + }, + { + code: 6140; + name: 'invalidSerumOpenOrders'; + msg: 'invalidSerumOpenOrders'; + }, + { + code: 6141; + name: 'failedSerumCpi'; + msg: 'failedSerumCpi'; + }, + { + code: 6142; + name: 'failedToFillOnExternalMarket'; + msg: 'failedToFillOnExternalMarket'; + }, + { + code: 6143; + name: 'invalidFulfillmentConfig'; + msg: 'invalidFulfillmentConfig'; + }, + { + code: 6144; + name: 'invalidFeeStructure'; + msg: 'invalidFeeStructure'; + }, + { + code: 6145; + name: 'insufficientIfShares'; + msg: 'Insufficient IF shares'; + }, + { + code: 6146; + name: 'marketActionPaused'; + msg: 'the Market has paused this action'; + }, + { + code: 6147; + name: 'marketPlaceOrderPaused'; + msg: 'the Market status doesnt allow placing orders'; + }, + { + code: 6148; + name: 'marketFillOrderPaused'; + msg: 'the Market status doesnt allow filling orders'; + }, + { + code: 6149; + name: 'marketWithdrawPaused'; + msg: 'the Market status doesnt allow withdraws'; + }, + { + code: 6150; + name: 'protectedAssetTierViolation'; + msg: 'Action violates the Protected Asset Tier rules'; + }, + { + code: 6151; + name: 'isolatedAssetTierViolation'; + msg: 'Action violates the Isolated Asset Tier rules'; + }, + { + code: 6152; + name: 'userCantBeDeleted'; + msg: 'User Cant Be Deleted'; + }, + { + code: 6153; + name: 'reduceOnlyWithdrawIncreasedRisk'; + msg: 'Reduce Only Withdraw Increased Risk'; + }, + { + code: 6154; + name: 'maxOpenInterest'; + msg: 'Max Open Interest'; + }, + { + code: 6155; + name: 'cantResolvePerpBankruptcy'; + msg: 'Cant Resolve Perp Bankruptcy'; + }, + { + code: 6156; + name: 'liquidationDoesntSatisfyLimitPrice'; + msg: 'Liquidation Doesnt Satisfy Limit Price'; + }, + { + code: 6157; + name: 'marginTradingDisabled'; + msg: 'Margin Trading Disabled'; + }, + { + code: 6158; + name: 'invalidMarketStatusToSettlePnl'; + msg: 'Invalid Market Status to Settle Perp Pnl'; + }, + { + code: 6159; + name: 'perpMarketNotInSettlement'; + msg: 'perpMarketNotInSettlement'; + }, + { + code: 6160; + name: 'perpMarketNotInReduceOnly'; + msg: 'perpMarketNotInReduceOnly'; + }, + { + code: 6161; + name: 'perpMarketSettlementBufferNotReached'; + msg: 'perpMarketSettlementBufferNotReached'; + }, + { + code: 6162; + name: 'perpMarketSettlementUserHasOpenOrders'; + msg: 'perpMarketSettlementUserHasOpenOrders'; + }, + { + code: 6163; + name: 'perpMarketSettlementUserHasActiveLp'; + msg: 'perpMarketSettlementUserHasActiveLp'; + }, + { + code: 6164; + name: 'unableToSettleExpiredUserPosition'; + msg: 'unableToSettleExpiredUserPosition'; + }, + { + code: 6165; + name: 'unequalMarketIndexForSpotTransfer'; + msg: 'unequalMarketIndexForSpotTransfer'; + }, + { + code: 6166; + name: 'invalidPerpPositionDetected'; + msg: 'invalidPerpPositionDetected'; + }, + { + code: 6167; + name: 'invalidSpotPositionDetected'; + msg: 'invalidSpotPositionDetected'; + }, + { + code: 6168; + name: 'invalidAmmDetected'; + msg: 'invalidAmmDetected'; + }, + { + code: 6169; + name: 'invalidAmmForFillDetected'; + msg: 'invalidAmmForFillDetected'; + }, + { + code: 6170; + name: 'invalidAmmLimitPriceOverride'; + msg: 'invalidAmmLimitPriceOverride'; + }, + { + code: 6171; + name: 'invalidOrderFillPrice'; + msg: 'invalidOrderFillPrice'; + }, + { + code: 6172; + name: 'spotMarketBalanceInvariantViolated'; + msg: 'spotMarketBalanceInvariantViolated'; + }, + { + code: 6173; + name: 'spotMarketVaultInvariantViolated'; + msg: 'spotMarketVaultInvariantViolated'; + }, + { + code: 6174; + name: 'invalidPda'; + msg: 'invalidPda'; + }, + { + code: 6175; + name: 'invalidPdaSigner'; + msg: 'invalidPdaSigner'; + }, + { + code: 6176; + name: 'revenueSettingsCannotSettleToIf'; + msg: 'revenueSettingsCannotSettleToIf'; + }, + { + code: 6177; + name: 'noRevenueToSettleToIf'; + msg: 'noRevenueToSettleToIf'; + }, + { + code: 6178; + name: 'noAmmPerpPnlDeficit'; + msg: 'noAmmPerpPnlDeficit'; + }, + { + code: 6179; + name: 'sufficientPerpPnlPool'; + msg: 'sufficientPerpPnlPool'; + }, + { + code: 6180; + name: 'insufficientPerpPnlPool'; + msg: 'insufficientPerpPnlPool'; + }, + { + code: 6181; + name: 'perpPnlDeficitBelowThreshold'; + msg: 'perpPnlDeficitBelowThreshold'; + }, + { + code: 6182; + name: 'maxRevenueWithdrawPerPeriodReached'; + msg: 'maxRevenueWithdrawPerPeriodReached'; + }, + { + code: 6183; + name: 'maxIfWithdrawReached'; + msg: 'invalidSpotPositionDetected'; + }, + { + code: 6184; + name: 'noIfWithdrawAvailable'; + msg: 'noIfWithdrawAvailable'; + }, + { + code: 6185; + name: 'invalidIfUnstake'; + msg: 'invalidIfUnstake'; + }, + { + code: 6186; + name: 'invalidIfUnstakeSize'; + msg: 'invalidIfUnstakeSize'; + }, + { + code: 6187; + name: 'invalidIfUnstakeCancel'; + msg: 'invalidIfUnstakeCancel'; + }, + { + code: 6188; + name: 'invalidIfForNewStakes'; + msg: 'invalidIfForNewStakes'; + }, + { + code: 6189; + name: 'invalidIfRebase'; + msg: 'invalidIfRebase'; + }, + { + code: 6190; + name: 'invalidInsuranceUnstakeSize'; + msg: 'invalidInsuranceUnstakeSize'; + }, + { + code: 6191; + name: 'invalidOrderLimitPrice'; + msg: 'invalidOrderLimitPrice'; + }, + { + code: 6192; + name: 'invalidIfDetected'; + msg: 'invalidIfDetected'; + }, + { + code: 6193; + name: 'invalidAmmMaxSpreadDetected'; + msg: 'invalidAmmMaxSpreadDetected'; + }, + { + code: 6194; + name: 'invalidConcentrationCoef'; + msg: 'invalidConcentrationCoef'; + }, + { + code: 6195; + name: 'invalidSrmVault'; + msg: 'invalidSrmVault'; + }, + { + code: 6196; + name: 'invalidVaultOwner'; + msg: 'invalidVaultOwner'; + }, + { + code: 6197; + name: 'invalidMarketStatusForFills'; + msg: 'invalidMarketStatusForFills'; + }, + { + code: 6198; + name: 'ifWithdrawRequestInProgress'; + msg: 'ifWithdrawRequestInProgress'; + }, + { + code: 6199; + name: 'noIfWithdrawRequestInProgress'; + msg: 'noIfWithdrawRequestInProgress'; + }, + { + code: 6200; + name: 'ifWithdrawRequestTooSmall'; + msg: 'ifWithdrawRequestTooSmall'; + }, + { + code: 6201; + name: 'incorrectSpotMarketAccountPassed'; + msg: 'incorrectSpotMarketAccountPassed'; + }, + { + code: 6202; + name: 'blockchainClockInconsistency'; + msg: 'blockchainClockInconsistency'; + }, + { + code: 6203; + name: 'invalidIfSharesDetected'; + msg: 'invalidIfSharesDetected'; + }, + { + code: 6204; + name: 'newLpSizeTooSmall'; + msg: 'newLpSizeTooSmall'; + }, + { + code: 6205; + name: 'marketStatusInvalidForNewLp'; + msg: 'marketStatusInvalidForNewLp'; + }, + { + code: 6206; + name: 'invalidMarkTwapUpdateDetected'; + msg: 'invalidMarkTwapUpdateDetected'; + }, + { + code: 6207; + name: 'marketSettlementAttemptOnActiveMarket'; + msg: 'marketSettlementAttemptOnActiveMarket'; + }, + { + code: 6208; + name: 'marketSettlementRequiresSettledLp'; + msg: 'marketSettlementRequiresSettledLp'; + }, + { + code: 6209; + name: 'marketSettlementAttemptTooEarly'; + msg: 'marketSettlementAttemptTooEarly'; + }, + { + code: 6210; + name: 'marketSettlementTargetPriceInvalid'; + msg: 'marketSettlementTargetPriceInvalid'; + }, + { + code: 6211; + name: 'unsupportedSpotMarket'; + msg: 'unsupportedSpotMarket'; + }, + { + code: 6212; + name: 'spotOrdersDisabled'; + msg: 'spotOrdersDisabled'; + }, + { + code: 6213; + name: 'marketBeingInitialized'; + msg: 'Market Being Initialized'; + }, + { + code: 6214; + name: 'invalidUserSubAccountId'; + msg: 'Invalid Sub Account Id'; + }, + { + code: 6215; + name: 'invalidTriggerOrderCondition'; + msg: 'Invalid Trigger Order Condition'; + }, + { + code: 6216; + name: 'invalidSpotPosition'; + msg: 'Invalid Spot Position'; + }, + { + code: 6217; + name: 'cantTransferBetweenSameUserAccount'; + msg: 'Cant transfer between same user account'; + }, + { + code: 6218; + name: 'invalidPerpPosition'; + msg: 'Invalid Perp Position'; + }, + { + code: 6219; + name: 'unableToGetLimitPrice'; + msg: 'Unable To Get Limit Price'; + }, + { + code: 6220; + name: 'invalidLiquidation'; + msg: 'Invalid Liquidation'; + }, + { + code: 6221; + name: 'spotFulfillmentConfigDisabled'; + msg: 'Spot Fulfillment Config Disabled'; + }, + { + code: 6222; + name: 'invalidMaker'; + msg: 'Invalid Maker'; + }, + { + code: 6223; + name: 'failedUnwrap'; + msg: 'Failed Unwrap'; + }, + { + code: 6224; + name: 'maxNumberOfUsers'; + msg: 'Max Number Of Users'; + }, + { + code: 6225; + name: 'invalidOracleForSettlePnl'; + msg: 'invalidOracleForSettlePnl'; + }, + { + code: 6226; + name: 'marginOrdersOpen'; + msg: 'marginOrdersOpen'; + }, + { + code: 6227; + name: 'tierViolationLiquidatingPerpPnl'; + msg: 'tierViolationLiquidatingPerpPnl'; + }, + { + code: 6228; + name: 'couldNotLoadUserData'; + msg: 'couldNotLoadUserData'; + }, + { + code: 6229; + name: 'userWrongMutability'; + msg: 'userWrongMutability'; + }, + { + code: 6230; + name: 'invalidUserAccount'; + msg: 'invalidUserAccount'; + }, + { + code: 6231; + name: 'couldNotLoadUserStatsData'; + msg: 'couldNotLoadUserData'; + }, + { + code: 6232; + name: 'userStatsWrongMutability'; + msg: 'userWrongMutability'; + }, + { + code: 6233; + name: 'invalidUserStatsAccount'; + msg: 'invalidUserAccount'; + }, + { + code: 6234; + name: 'userNotFound'; + msg: 'userNotFound'; + }, + { + code: 6235; + name: 'unableToLoadUserAccount'; + msg: 'unableToLoadUserAccount'; + }, + { + code: 6236; + name: 'userStatsNotFound'; + msg: 'userStatsNotFound'; + }, + { + code: 6237; + name: 'unableToLoadUserStatsAccount'; + msg: 'unableToLoadUserStatsAccount'; + }, + { + code: 6238; + name: 'userNotInactive'; + msg: 'User Not Inactive'; + }, + { + code: 6239; + name: 'revertFill'; + msg: 'revertFill'; + }, + { + code: 6240; + name: 'invalidMarketAccountforDeletion'; + msg: 'Invalid MarketAccount for Deletion'; + }, + { + code: 6241; + name: 'invalidSpotFulfillmentParams'; + msg: 'Invalid Spot Fulfillment Params'; + }, + { + code: 6242; + name: 'failedToGetMint'; + msg: 'Failed to Get Mint'; + }, + { + code: 6243; + name: 'failedPhoenixCpi'; + msg: 'failedPhoenixCpi'; + }, + { + code: 6244; + name: 'failedToDeserializePhoenixMarket'; + msg: 'failedToDeserializePhoenixMarket'; + }, + { + code: 6245; + name: 'invalidPricePrecision'; + msg: 'invalidPricePrecision'; + }, + { + code: 6246; + name: 'invalidPhoenixProgram'; + msg: 'invalidPhoenixProgram'; + }, + { + code: 6247; + name: 'invalidPhoenixMarket'; + msg: 'invalidPhoenixMarket'; + }, + { + code: 6248; + name: 'invalidSwap'; + msg: 'invalidSwap'; + }, + { + code: 6249; + name: 'swapLimitPriceBreached'; + msg: 'swapLimitPriceBreached'; + }, + { + code: 6250; + name: 'spotMarketReduceOnly'; + msg: 'spotMarketReduceOnly'; + }, + { + code: 6251; + name: 'fundingWasNotUpdated'; + msg: 'fundingWasNotUpdated'; + }, + { + code: 6252; + name: 'impossibleFill'; + msg: 'impossibleFill'; + }, + { + code: 6253; + name: 'cantUpdatePerpBidAskTwap'; + msg: 'cantUpdatePerpBidAskTwap'; + }, + { + code: 6254; + name: 'userReduceOnly'; + msg: 'userReduceOnly'; + }, + { + code: 6255; + name: 'invalidMarginCalculation'; + msg: 'invalidMarginCalculation'; + }, + { + code: 6256; + name: 'cantPayUserInitFee'; + msg: 'cantPayUserInitFee'; + }, + { + code: 6257; + name: 'cantReclaimRent'; + msg: 'cantReclaimRent'; + }, + { + code: 6258; + name: 'insuranceFundOperationPaused'; + msg: 'insuranceFundOperationPaused'; + }, + { + code: 6259; + name: 'noUnsettledPnl'; + msg: 'noUnsettledPnl'; + }, + { + code: 6260; + name: 'pnlPoolCantSettleUser'; + msg: 'pnlPoolCantSettleUser'; + }, + { + code: 6261; + name: 'oracleNonPositive'; + msg: 'oracleInvalid'; + }, + { + code: 6262; + name: 'oracleTooVolatile'; + msg: 'oracleTooVolatile'; + }, + { + code: 6263; + name: 'oracleTooUncertain'; + msg: 'oracleTooUncertain'; + }, + { + code: 6264; + name: 'oracleStaleForMargin'; + msg: 'oracleStaleForMargin'; + }, + { + code: 6265; + name: 'oracleInsufficientDataPoints'; + msg: 'oracleInsufficientDataPoints'; + }, + { + code: 6266; + name: 'oracleStaleForAmm'; + msg: 'oracleStaleForAmm'; + }, + { + code: 6267; + name: 'unableToParsePullOracleMessage'; + msg: 'Unable to parse pull oracle message'; + }, + { + code: 6268; + name: 'maxBorrows'; + msg: 'Can not borow more than max borrows'; + }, + { + code: 6269; + name: 'oracleUpdatesNotMonotonic'; + msg: 'Updates must be monotonically increasing'; + }, + { + code: 6270; + name: 'oraclePriceFeedMessageMismatch'; + msg: 'Trying to update price feed with the wrong feed id'; + }, + { + code: 6271; + name: 'oracleUnsupportedMessageType'; + msg: 'The message in the update must be a PriceFeedMessage'; + }, + { + code: 6272; + name: 'oracleDeserializeMessageFailed'; + msg: 'Could not deserialize the message in the update'; + }, + { + code: 6273; + name: 'oracleWrongGuardianSetOwner'; + msg: 'Wrong guardian set owner in update price atomic'; + }, + { + code: 6274; + name: 'oracleWrongWriteAuthority'; + msg: 'Oracle post update atomic price feed account must be drift program'; + }, + { + code: 6275; + name: 'oracleWrongVaaOwner'; + msg: 'Oracle vaa owner must be wormhole program'; + }, + { + code: 6276; + name: 'oracleTooManyPriceAccountUpdates'; + msg: 'Multi updates must have 2 or fewer accounts passed in remaining accounts'; + }, + { + code: 6277; + name: 'oracleMismatchedVaaAndPriceUpdates'; + msg: "Don't have the same remaining accounts number and pyth updates left"; + }, + { + code: 6278; + name: 'oracleBadRemainingAccountPublicKey'; + msg: 'Remaining account passed does not match oracle update derived pda'; + }, + { + code: 6279; + name: 'failedOpenbookV2cpi'; + msg: 'failedOpenbookV2cpi'; + }, + { + code: 6280; + name: 'invalidOpenbookV2Program'; + msg: 'invalidOpenbookV2Program'; + }, + { + code: 6281; + name: 'invalidOpenbookV2Market'; + msg: 'invalidOpenbookV2Market'; + }, + { + code: 6282; + name: 'nonZeroTransferFee'; + msg: 'Non zero transfer fee'; + }, + { + code: 6283; + name: 'liquidationOrderFailedToFill'; + msg: 'Liquidation order failed to fill'; + }, + { + code: 6284; + name: 'invalidPredictionMarketOrder'; + msg: 'Invalid prediction market order'; + }, + { + code: 6285; + name: 'invalidVerificationIxIndex'; + msg: 'Ed25519 Ix must be before place and make SignedMsg order ix'; + }, + { + code: 6286; + name: 'sigVerificationFailed'; + msg: 'SignedMsg message verificaiton failed'; + }, + { + code: 6287; + name: 'mismatchedSignedMsgOrderParamsMarketIndex'; + msg: 'Market index mismatched b/w taker and maker SignedMsg order params'; + }, + { + code: 6288; + name: 'invalidSignedMsgOrderParam'; + msg: 'Invalid SignedMsg order param'; + }, + { + code: 6289; + name: 'placeAndTakeOrderSuccessConditionFailed'; + msg: 'Place and take order success condition failed'; + }, + { + code: 6290; + name: 'invalidHighLeverageModeConfig'; + msg: 'Invalid High Leverage Mode Config'; + }, + { + code: 6291; + name: 'invalidRfqUserAccount'; + msg: 'Invalid RFQ User Account'; + }, + { + code: 6292; + name: 'rfqUserAccountWrongMutability'; + msg: 'RFQUserAccount should be mutable'; + }, + { + code: 6293; + name: 'rfqUserAccountFull'; + msg: 'RFQUserAccount has too many active RFQs'; + }, + { + code: 6294; + name: 'rfqOrderNotFilled'; + msg: 'RFQ order not filled as expected'; + }, + { + code: 6295; + name: 'invalidRfqOrder'; + msg: 'RFQ orders must be jit makers'; + }, + { + code: 6296; + name: 'invalidRfqMatch'; + msg: 'RFQ matches must be valid'; + }, + { + code: 6297; + name: 'invalidSignedMsgUserAccount'; + msg: 'Invalid SignedMsg user account'; + }, + { + code: 6298; + name: 'signedMsgUserAccountWrongMutability'; + msg: 'SignedMsg account wrong mutability'; + }, + { + code: 6299; + name: 'signedMsgUserOrdersAccountFull'; + msg: 'SignedMsgUserAccount has too many active orders'; + }, + { + code: 6300; + name: 'signedMsgOrderDoesNotExist'; + msg: 'Order with SignedMsg uuid does not exist'; + }, + { + code: 6301; + name: 'invalidSignedMsgOrderId'; + msg: 'SignedMsg order id cannot be 0s'; + }, + { + code: 6302; + name: 'invalidPoolId'; + msg: 'Invalid pool id'; + }, + { + code: 6303; + name: 'invalidProtectedMakerModeConfig'; + msg: 'Invalid Protected Maker Mode Config'; + }, + { + code: 6304; + name: 'invalidPythLazerStorageOwner'; + msg: 'Invalid pyth lazer storage owner'; + }, + { + code: 6305; + name: 'unverifiedPythLazerMessage'; + msg: 'Verification of pyth lazer message failed'; + }, + { + code: 6306; + name: 'invalidPythLazerMessage'; + msg: 'Invalid pyth lazer message'; + }, + { + code: 6307; + name: 'pythLazerMessagePriceFeedMismatch'; + msg: 'Pyth lazer message does not correspond to correct fed id'; + }, + { + code: 6308; + name: 'invalidLiquidateSpotWithSwap'; + msg: 'invalidLiquidateSpotWithSwap'; + }, + { + code: 6309; + name: 'signedMsgUserContextUserMismatch'; + msg: 'User in SignedMsg message does not match user in ix context'; + }, + { + code: 6310; + name: 'userFuelOverflowThresholdNotMet'; + msg: 'User fuel overflow threshold not met'; + }, + { + code: 6311; + name: 'fuelOverflowAccountNotFound'; + msg: 'FuelOverflow account not found'; + }, + { + code: 6312; + name: 'invalidTransferPerpPosition'; + msg: 'Invalid Transfer Perp Position'; + }, + { + code: 6313; + name: 'invalidSignedMsgUserOrdersResize'; + msg: 'Invalid SignedMsgUserOrders resize'; + }, + { + code: 6314; + name: 'couldNotDeserializeHighLeverageModeConfig'; + msg: 'Could not deserialize high leverage mode config'; + }, + { + code: 6315; + name: 'invalidIfRebalanceConfig'; + msg: 'Invalid If Rebalance Config'; + }, + { + code: 6316; + name: 'invalidIfRebalanceSwap'; + msg: 'Invalid If Rebalance Swap'; + }, + { + code: 6317; + name: 'invalidRevenueShareResize'; + msg: 'Invalid RevenueShare resize'; + }, + { + code: 6318; + name: 'builderRevoked'; + msg: 'Builder has been revoked'; + }, + { + code: 6319; + name: 'invalidBuilderFee'; + msg: 'Builder fee is greater than max fee bps'; + }, + { + code: 6320; + name: 'revenueShareEscrowAuthorityMismatch'; + msg: 'RevenueShareEscrow authority mismatch'; + }, + { + code: 6321; + name: 'revenueShareEscrowOrdersAccountFull'; + msg: 'RevenueShareEscrow has too many active orders'; + }, + { + code: 6322; + name: 'invalidRevenueShareAccount'; + msg: 'Invalid RevenueShareAccount'; + }, + { + code: 6323; + name: 'cannotRevokeBuilderWithOpenOrders'; + msg: 'Cannot revoke builder with open orders'; + }, + { + code: 6324; + name: 'unableToLoadRevenueShareAccount'; + msg: 'Unable to load builder account'; + }, + { + code: 6325; + name: 'invalidConstituent'; + msg: 'Invalid Constituent'; + }, + { + code: 6326; + name: 'invalidAmmConstituentMappingArgument'; + msg: 'Invalid Amm Constituent Mapping argument'; + }, + { + code: 6327; + name: 'constituentNotFound'; + msg: 'Constituent not found'; + }, + { + code: 6328; + name: 'constituentCouldNotLoad'; + msg: 'Constituent could not load'; + }, + { + code: 6329; + name: 'constituentWrongMutability'; + msg: 'Constituent wrong mutability'; + }, + { + code: 6330; + name: 'wrongNumberOfConstituents'; + msg: 'Wrong number of constituents passed to instruction'; + }, + { + code: 6331; + name: 'insufficientConstituentTokenBalance'; + msg: 'Insufficient constituent token balance'; + }, + { + code: 6332; + name: 'ammCacheStale'; + msg: 'Amm Cache data too stale'; + }, + { + code: 6333; + name: 'lpPoolAumDelayed'; + msg: 'LP Pool AUM not updated recently'; + }, + { + code: 6334; + name: 'constituentOracleStale'; + msg: 'Constituent oracle is stale'; + }, + { + code: 6335; + name: 'lpInvariantFailed'; + msg: 'LP Invariant failed'; + }, + { + code: 6336; + name: 'invalidConstituentDerivativeWeights'; + msg: 'Invalid constituent derivative weights'; + }, + { + code: 6337; + name: 'maxDlpAumBreached'; + msg: 'Max DLP AUM Breached'; + }, + { + code: 6338; + name: 'settleLpPoolDisabled'; + msg: 'Settle Lp Pool Disabled'; + }, + { + code: 6339; + name: 'mintRedeemLpPoolDisabled'; + msg: 'Mint/Redeem Lp Pool Disabled'; + }, + { + code: 6340; + name: 'lpPoolSettleInvariantBreached'; + msg: 'Settlement amount exceeded'; + }, + { + code: 6341; + name: 'invalidConstituentOperation'; + msg: 'Invalid constituent operation'; + }, + { + code: 6342; + name: 'unauthorized'; + msg: 'Unauthorized for operation'; + }, + { + code: 6343; + name: 'invalidLpPoolId'; + msg: 'Invalid Lp Pool Id for Operation'; + }, + { + code: 6344; + name: 'marketIndexNotFoundAmmCache'; + msg: 'marketIndexNotFoundAmmCache'; + }, + ]; + types: [ + { + name: 'amm'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'oracle'; + docs: ['oracle price data public key']; + type: 'pubkey'; + }, + { + name: 'historicalOracleData'; + docs: ['stores historically witnessed oracle data']; + type: { + defined: { + name: 'historicalOracleData'; + }; + }; + }, + { + name: 'baseAssetAmountPerLp'; + docs: [ + 'accumulated base asset amount since inception per lp share', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteAssetAmountPerLp'; + docs: [ + 'accumulated quote asset amount since inception per lp share', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'feePool'; + docs: [ + 'partition of fees from perp market trading moved from pnl settlements', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'baseAssetReserve'; + docs: [ + '`x` reserves for constant product mm formula (x * y = k)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'quoteAssetReserve'; + docs: [ + '`y` reserves for constant product mm formula (x * y = k)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'concentrationCoef'; + docs: [ + 'determines how close the min/max base asset reserve sit vs base reserves', + 'allow for decreasing slippage without increasing liquidity and v.v.', + 'precision: PERCENTAGE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'minBaseAssetReserve'; + docs: [ + 'minimum base_asset_reserve allowed before AMM is unavailable', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'maxBaseAssetReserve'; + docs: [ + 'maximum base_asset_reserve allowed before AMM is unavailable', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'sqrtK'; + docs: [ + '`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'pegMultiplier'; + docs: [ + 'normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced', + 'precision: PEG_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'terminalQuoteAssetReserve'; + docs: [ + 'y when market is balanced. stored to save computation', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'baseAssetAmountLong'; + docs: [ + 'always non-negative. tracks number of total longs in market (regardless of counterparty)', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountShort'; + docs: [ + 'always non-positive. tracks number of total shorts in market (regardless of counterparty)', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: [ + 'tracks net position (longs-shorts) in market with AMM as counterparty', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountWithUnsettledLp'; + docs: [ + 'tracks net position (longs-shorts) in market with LPs as counterparty', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'maxOpenInterest'; + docs: [ + 'max allowed open interest, blocks trades that breach this value', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'quoteAssetAmount'; + docs: [ + "sum of all user's perp quote_asset_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteEntryAmountLong'; + docs: [ + "sum of all long user's quote_entry_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteEntryAmountShort'; + docs: [ + "sum of all short user's quote_entry_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteBreakEvenAmountLong'; + docs: [ + "sum of all long user's quote_break_even_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteBreakEvenAmountShort'; + docs: [ + "sum of all short user's quote_break_even_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'userLpShares'; + docs: [ + 'total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastFundingRate'; + docs: [ + 'last funding rate in this perp market (unit is quote per base)', + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateLong'; + docs: [ + 'last funding rate for longs in this perp market (unit is quote per base)', + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateShort'; + docs: [ + 'last funding rate for shorts in this perp market (unit is quote per base)', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'last24hAvgFundingRate'; + docs: [ + 'estimate of last 24h of funding rate perp market (unit is quote per base)', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'totalFee'; + docs: [ + 'total fees collected by this perp market', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalMmFee'; + docs: [ + "total fees collected by the vAMM's bid/ask spread", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalExchangeFee'; + docs: [ + 'total fees collected by exchange fee schedule', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalFeeMinusDistributions'; + docs: [ + 'total fees minus any recognized upnl and pool withdraws', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalFeeWithdrawn'; + docs: [ + 'sum of all fees from fee pool withdrawn to revenue pool', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalLiquidationFee'; + docs: [ + 'all fees collected by market for liquidations', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeFundingRateLong'; + docs: [ + 'accumulated funding rate for longs since inception in market', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'cumulativeFundingRateShort'; + docs: [ + 'accumulated funding rate for shorts since inception in market', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalSocialLoss'; + docs: [ + 'accumulated social loss paid by users since inception in market', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'askBaseAssetReserve'; + docs: [ + 'transformed base_asset_reserve for users going long', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'askQuoteAssetReserve'; + docs: [ + 'transformed quote_asset_reserve for users going long', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'bidBaseAssetReserve'; + docs: [ + 'transformed base_asset_reserve for users going short', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'bidQuoteAssetReserve'; + docs: [ + 'transformed quote_asset_reserve for users going short', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastOracleNormalisedPrice'; + docs: [ + 'the last seen oracle price partially shrunk toward the amm reserve price', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastOracleReservePriceSpreadPct'; + docs: [ + 'the gap between the oracle price and the reserve price = y * peg_multiplier / x', + ]; + type: 'i64'; + }, + { + name: 'lastBidPriceTwap'; + docs: [ + 'average estimate of bid price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastAskPriceTwap'; + docs: [ + 'average estimate of ask price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwap'; + docs: [ + 'average estimate of (bid+ask)/2 price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwap5min'; + docs: ['average estimate of (bid+ask)/2 price over FIVE_MINUTES']; + type: 'u64'; + }, + { + name: 'lastUpdateSlot'; + docs: ['the last blockchain slot the amm was updated']; + type: 'u64'; + }, + { + name: 'lastOracleConfPct'; + docs: [ + 'the pct size of the oracle confidence interval', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'netRevenueSinceLastFunding'; + docs: [ + 'the total_fee_minus_distribution change since the last funding update', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateTs'; + docs: ['the last funding rate update unix_timestamp']; + type: 'i64'; + }, + { + name: 'fundingPeriod'; + docs: ['the periodicity of the funding rate updates']; + type: 'i64'; + }, + { + name: 'orderStepSize'; + docs: [ + 'the base step size (increment) of orders', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'orderTickSize'; + docs: [ + 'the price tick size of orders', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minOrderSize'; + docs: [ + 'the minimum base size of an order', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'mmOracleSlot'; + docs: [ + 'the max base size a single user can have', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'volume24h'; + docs: ['estimated total of volume in market', 'QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'longIntensityVolume'; + docs: ['the volume intensity of long fills against AMM']; + type: 'u64'; + }, + { + name: 'shortIntensityVolume'; + docs: ['the volume intensity of short fills against AMM']; + type: 'u64'; + }, + { + name: 'lastTradeTs'; + docs: [ + 'the blockchain unix timestamp at the time of the last trade', + ]; + type: 'i64'; + }, + { + name: 'markStd'; + docs: [ + 'estimate of standard deviation of the fill (mark) prices', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'oracleStd'; + docs: [ + 'estimate of standard deviation of the oracle price at each update', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwapTs'; + docs: ['the last unix_timestamp the mark twap was updated']; + type: 'i64'; + }, + { + name: 'baseSpread'; + docs: [ + 'the minimum spread the AMM can quote. also used as step size for some spread logic increases.', + ]; + type: 'u32'; + }, + { + name: 'maxSpread'; + docs: ['the maximum spread the AMM can quote']; + type: 'u32'; + }, + { + name: 'longSpread'; + docs: ['the spread for asks vs the reserve price']; + type: 'u32'; + }, + { + name: 'shortSpread'; + docs: ['the spread for bids vs the reserve price']; + type: 'u32'; + }, + { + name: 'mmOraclePrice'; + docs: ['MM oracle price']; + type: 'i64'; + }, + { + name: 'maxFillReserveFraction'; + docs: [ + 'the fraction of total available liquidity a single fill on the AMM can consume', + ]; + type: 'u16'; + }, + { + name: 'maxSlippageRatio'; + docs: ['the maximum slippage a single fill on the AMM can push']; + type: 'u16'; + }, + { + name: 'curveUpdateIntensity'; + docs: [ + 'the update intensity of AMM formulaic updates (adjusting k). 0-100', + ]; + type: 'u8'; + }, + { + name: 'ammJitIntensity'; + docs: [ + 'the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.', + '(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM.', + ]; + type: 'u8'; + }, + { + name: 'oracleSource'; + docs: [ + 'the oracle provider information. used to decode/scale the oracle public key', + ]; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'lastOracleValid'; + docs: [ + 'tracks whether the oracle was considered valid at the last AMM update', + ]; + type: 'bool'; + }, + { + name: 'targetBaseAssetAmountPerLp'; + docs: [ + 'the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split', + 'precision: BASE_PRECISION', + ]; + type: 'i32'; + }, + { + name: 'perLpBase'; + docs: [ + 'expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)', + ]; + type: 'i8'; + }, + { + name: 'oracleLowRiskSlotDelayOverride'; + docs: [ + 'the override for the state.min_perp_auction_duration', + '0 is no override, -1 is disable speed bump, 1-100 is literal speed bump', + ]; + type: 'i8'; + }, + { + name: 'ammSpreadAdjustment'; + docs: [ + 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', + ]; + type: 'i8'; + }, + { + name: 'oracleSlotDelayOverride'; + type: 'i8'; + }, + { + name: 'mmOracleSequenceId'; + type: 'u64'; + }, + { + name: 'netUnsettledFundingPnl'; + type: 'i64'; + }, + { + name: 'quoteAssetAmountWithUnsettledLp'; + type: 'i64'; + }, + { + name: 'referencePriceOffset'; + type: 'i32'; + }, + { + name: 'ammInventorySpreadAdjustment'; + docs: [ + 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', + ]; + type: 'i8'; + }, + { + name: 'referencePriceOffsetDeadbandPct'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 2]; + }; + }, + { + name: 'lastFundingOracleTwap'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'addAmmConstituentMappingDatum'; + type: { + kind: 'struct'; + fields: [ + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'weight'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ammCache'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'cache'; + type: { + vec: { + defined: { + name: 'cacheInfo'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'ammConstituentDatum'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'lastSlot'; + type: 'u64'; + }, + { + name: 'weight'; + docs: [ + 'PERCENTAGE_PRECISION. The weight this constituent has on the perp market', + ]; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ammConstituentMapping'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'weights'; + type: { + vec: { + defined: { + name: 'ammConstituentDatum'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'assetTier'; + type: { + kind: 'enum'; + variants: [ + { + name: 'collateral'; + }, + { + name: 'protected'; + }, + { + name: 'cross'; + }, + { + name: 'isolated'; + }, + { + name: 'unlisted'; + }, + ]; + }; + }, + { + name: 'builderInfo'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'maxFeeTenthBps'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 6]; + }; + }, + ]; + }; + }, + { + name: 'cacheInfo'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'lastFeePoolTokenAmount'; + type: 'u128'; + }, + { + name: 'lastNetPnlPoolTokenAmount'; + type: 'i128'; + }, + { + name: 'lastExchangeFees'; + type: 'u128'; + }, + { + name: 'lastSettleAmmExFees'; + type: 'u128'; + }, + { + name: 'lastSettleAmmPnl'; + type: 'i128'; + }, + { + name: 'position'; + docs: ['BASE PRECISION']; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'lastSettleAmount'; + type: 'u64'; + }, + { + name: 'lastSettleSlot'; + type: 'u64'; + }, + { + name: 'lastSettleTs'; + type: 'i64'; + }, + { + name: 'quoteOwedFromLpPool'; + type: 'i64'; + }, + { + name: 'ammInventoryLimit'; + type: 'i64'; + }, + { + name: 'oraclePrice'; + type: 'i64'; + }, + { + name: 'oracleSlot'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'oracleSource'; + type: 'u8'; + }, + { + name: 'oracleValidity'; + type: 'u8'; + }, + { + name: 'lpStatusForPerpMarket'; + type: 'u8'; + }, + { + name: 'ammPositionScalar'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 34]; + }; + }, + ]; + }; + }, + { + name: 'constituent'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: ['address of the constituent']; + type: 'pubkey'; + }, + { + name: 'mint'; + type: 'pubkey'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'vault'; + type: 'pubkey'; + }, + { + name: 'totalSwapFees'; + docs: [ + 'total fees received by the constituent. Positive = fees received, Negative = fees paid', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'spotBalance'; + docs: ['spot borrow-lend balance for constituent']; + type: { + defined: { + name: 'constituentSpotBalance'; + }; + }; + }, + { + name: 'lastSpotBalanceTokenAmount'; + type: 'i64'; + }, + { + name: 'cumulativeSpotInterestAccruedTokenAmount'; + type: 'i64'; + }, + { + name: 'maxWeightDeviation'; + docs: [ + 'max deviation from target_weight allowed for the constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'swapFeeMin'; + docs: [ + 'min fee charged on swaps to/from this constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'swapFeeMax'; + docs: [ + 'max fee charged on swaps to/from this constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxBorrowTokenAmount'; + docs: ['Max Borrow amount:', 'precision: token precision']; + type: 'u64'; + }, + { + name: 'vaultTokenBalance'; + docs: ['ata token balance in token precision']; + type: 'u64'; + }, + { + name: 'lastOraclePrice'; + type: 'i64'; + }, + { + name: 'lastOracleSlot'; + type: 'u64'; + }, + { + name: 'oracleStalenessThreshold'; + docs: ['Delay allowed for valid AUM calculation']; + type: 'u64'; + }, + { + name: 'flashLoanInitialTokenAmount'; + type: 'u64'; + }, + { + name: 'nextSwapId'; + docs: [ + 'Every swap to/from this constituent has a monotonically increasing id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'derivativeWeight'; + docs: [ + 'percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight', + ]; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'constituentDerivativeDepegThreshold'; + type: 'u64'; + }, + { + name: 'constituentDerivativeIndex'; + docs: [ + 'The `constituent_index` of the parent constituent. -1 if it is a parent index', + 'Example: if in a pool with SOL (parent) and dSOL (derivative),', + 'SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,', + 'dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1', + ]; + type: 'i16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'decimals'; + type: 'u8'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'vaultBump'; + type: 'u8'; + }, + { + name: 'gammaInventory'; + type: 'u8'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 162]; + }; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'correlations'; + type: { + vec: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'constituentParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxWeightDeviation'; + type: { + option: 'i64'; + }; + }, + { + name: 'swapFeeMin'; + type: { + option: 'i64'; + }; + }, + { + name: 'swapFeeMax'; + type: { + option: 'i64'; + }; + }, + { + name: 'maxBorrowTokenAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'oracleStalenessThreshold'; + type: { + option: 'u64'; + }; + }, + { + name: 'costToTradeBps'; + type: { + option: 'i32'; + }; + }, + { + name: 'constituentDerivativeIndex'; + type: { + option: 'i16'; + }; + }, + { + name: 'derivativeWeight'; + type: { + option: 'u64'; + }; + }, + { + name: 'volatility'; + type: { + option: 'u64'; + }; + }, + { + name: 'gammaExecution'; + type: { + option: 'u8'; + }; + }, + { + name: 'gammaInventory'; + type: { + option: 'u8'; + }; + }, + { + name: 'xi'; + type: { + option: 'u8'; + }; + }, + ]; + }; + }, + { + name: 'constituentSpotBalance'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', + 'interest of corresponding market.', + 'precision: token precision', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeDeposits'; + docs: [ + 'The cumulative deposits/borrows a user has made into a market', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'marketIndex'; + docs: ['The market index of the corresponding spot market']; + type: 'u16'; + }, + { + name: 'balanceType'; + docs: ['Whether the position is deposit or borrow']; + type: { + defined: { + name: 'spotBalanceType'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 5]; + }; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'targets'; + type: { + vec: { + defined: { + name: 'targetsDatum'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'contractTier'; + type: { + kind: 'enum'; + variants: [ + { + name: 'a'; + }, + { + name: 'b'; + }, + { + name: 'c'; + }, + { + name: 'speculative'; + }, + { + name: 'highlySpeculative'; + }, + { + name: 'isolated'; + }, + ]; + }; + }, + { + name: 'contractType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'perpetual'; + }, + { + name: 'future'; + }, + { + name: 'prediction'; + }, + ]; + }; + }, + { + name: 'curveRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'pegMultiplierBefore'; + type: 'u128'; + }, + { + name: 'baseAssetReserveBefore'; + type: 'u128'; + }, + { + name: 'quoteAssetReserveBefore'; + type: 'u128'; + }, + { + name: 'sqrtKBefore'; + type: 'u128'; + }, + { + name: 'pegMultiplierAfter'; + type: 'u128'; + }, + { + name: 'baseAssetReserveAfter'; + type: 'u128'; + }, + { + name: 'quoteAssetReserveAfter'; + type: 'u128'; + }, + { + name: 'sqrtKAfter'; + type: 'u128'; + }, + { + name: 'baseAssetAmountLong'; + docs: ['precision: BASE_PRECISION']; + type: 'u128'; + }, + { + name: 'baseAssetAmountShort'; + docs: ['precision: BASE_PRECISION']; + type: 'u128'; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + { + name: 'totalFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'totalFeeMinusDistributions'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'adjustmentCost'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'fillRecord'; + type: 'u128'; + }, + { + name: 'numberOfUsers'; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }; + }, + { + name: 'deleteUserRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'keeper'; + type: { + option: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'depositDirection'; + type: { + kind: 'enum'; + variants: [ + { + name: 'deposit'; + }, + { + name: 'withdraw'; + }, + ]; + }; + }, + { + name: 'depositExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'transfer'; + }, + { + name: 'borrow'; + }, + { + name: 'repayBorrow'; + }, + { + name: 'reward'; + }, + ]; + }; + }, + { + name: 'depositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + docs: ['user account public key']; + type: 'pubkey'; + }, + { + name: 'direction'; + type: { + defined: { + name: 'depositDirection'; + }; + }; + }, + { + name: 'depositRecordId'; + type: 'u64'; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'marketIndex'; + docs: ['spot market index']; + type: 'u16'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'marketDepositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'marketWithdrawBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'marketCumulativeDepositInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'marketCumulativeBorrowInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'totalDepositsAfter'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalWithdrawsAfter'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'explanation'; + type: { + defined: { + name: 'depositExplanation'; + }; + }; + }, + { + name: 'transferUser'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'signer'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'userTokenAmountAfter'; + docs: ['precision: token mint precision']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'feeStructure'; + type: { + kind: 'struct'; + fields: [ + { + name: 'feeTiers'; + type: { + array: [ + { + defined: { + name: 'feeTier'; + }; + }, + 10, + ]; + }; + }, + { + name: 'fillerRewardStructure'; + type: { + defined: { + name: 'orderFillerRewardStructure'; + }; + }; + }, + { + name: 'referrerRewardEpochUpperBound'; + type: 'u64'; + }, + { + name: 'flatFillerFee'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'feeTier'; + type: { + kind: 'struct'; + fields: [ + { + name: 'feeNumerator'; + type: 'u32'; + }, + { + name: 'feeDenominator'; + type: 'u32'; + }, + { + name: 'makerRebateNumerator'; + type: 'u32'; + }, + { + name: 'makerRebateDenominator'; + type: 'u32'; + }, + { + name: 'referrerRewardNumerator'; + type: 'u32'; + }, + { + name: 'referrerRewardDenominator'; + type: 'u32'; + }, + { + name: 'refereeFeeNumerator'; + type: 'u32'; + }, + { + name: 'refereeFeeDenominator'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'fuelOverflow'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The authority of this overflow account']; + type: 'pubkey'; + }, + { + name: 'fuelInsurance'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelDeposits'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelBorrows'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelPositions'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelTaker'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelMaker'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastFuelSweepTs'; + type: 'u32'; + }, + { + name: 'lastResetTs'; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u128', 6]; + }; + }, + ]; + }; + }, + { + name: 'fuelSeasonRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'fuelInsurance'; + type: 'u128'; + }, + { + name: 'fuelDeposits'; + type: 'u128'; + }, + { + name: 'fuelBorrows'; + type: 'u128'; + }, + { + name: 'fuelPositions'; + type: 'u128'; + }, + { + name: 'fuelTaker'; + type: 'u128'; + }, + { + name: 'fuelMaker'; + type: 'u128'; + }, + { + name: 'fuelTotal'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'fuelSweepRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'userStatsFuelInsurance'; + type: 'u32'; + }, + { + name: 'userStatsFuelDeposits'; + type: 'u32'; + }, + { + name: 'userStatsFuelBorrows'; + type: 'u32'; + }, + { + name: 'userStatsFuelPositions'; + type: 'u32'; + }, + { + name: 'userStatsFuelTaker'; + type: 'u32'; + }, + { + name: 'userStatsFuelMaker'; + type: 'u32'; + }, + { + name: 'fuelOverflowFuelInsurance'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelDeposits'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelBorrows'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelPositions'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelTaker'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelMaker'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'fundingPaymentRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fundingPayment'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + docs: ['precision: BASE_PRECISION']; + type: 'i64'; + }, + { + name: 'userLastCumulativeFunding'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i64'; + }, + { + name: 'ammCumulativeFundingLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'ammCumulativeFundingShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'fundingRateRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fundingRate'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i64'; + }, + { + name: 'fundingRateLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'fundingRateShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'cumulativeFundingRateLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'cumulativeFundingRateShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'oraclePriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'markPriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'periodRevenue'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + { + name: 'baseAssetAmountWithUnsettledLp'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'highLeverageModeConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'currentUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'u8'; + }, + { + name: 'padding1'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'currentMaintenanceUsers'; + type: 'u32'; + }, + { + name: 'padding2'; + type: { + array: ['u8', 24]; + }; + }, + ]; + }; + }, + { + name: 'historicalIndexData'; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastIndexBidPrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexAskPrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwap5min'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwapTs'; + docs: ['unix_timestamp of last snapshot']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'historicalOracleData'; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOracleConf'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastOracleDelay'; + docs: ['number of slots since last update']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwap5min'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwapTs'; + docs: ['unix_timestamp of last snapshot']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'totalInAmount'; + docs: ['total amount to be sold']; + type: 'u64'; + }, + { + name: 'currentInAmount'; + docs: ['amount already sold']; + type: 'u64'; + }, + { + name: 'currentOutAmount'; + docs: ['amount already bought']; + type: 'u64'; + }, + { + name: 'currentOutAmountTransferred'; + docs: ['amount already transferred to revenue pool']; + type: 'u64'; + }, + { + name: 'currentInAmountSinceLastTransfer'; + docs: ['amount already bought in epoch']; + type: 'u64'; + }, + { + name: 'epochStartTs'; + docs: ['start time of epoch']; + type: 'i64'; + }, + { + name: 'epochInAmount'; + docs: ['amount already bought in epoch']; + type: 'u64'; + }, + { + name: 'epochMaxInAmount'; + docs: ['max amount to swap in epoch']; + type: 'u64'; + }, + { + name: 'epochDuration'; + docs: ['duration of epoch']; + type: 'i64'; + }, + { + name: 'outMarketIndex'; + docs: ['market index to sell']; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + docs: ['market index to buy']; + type: 'u16'; + }, + { + name: 'maxSlippageBps'; + type: 'u16'; + }, + { + name: 'swapMode'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + { + name: 'padding2'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfigParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'totalInAmount'; + type: 'u64'; + }, + { + name: 'epochMaxInAmount'; + type: 'u64'; + }, + { + name: 'epochDuration'; + type: 'i64'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'maxSlippageBps'; + type: 'u16'; + }, + { + name: 'swapMode'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + ]; + }; + }, + { + name: 'insuranceClaim'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'revenueWithdrawSinceLastSettle'; + docs: [ + 'The amount of revenue last settled', + 'Positive if funds left the perp market,', + 'negative if funds were pulled into the perp market', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + docs: [ + 'The max amount of revenue that can be withdrawn per period', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + docs: [ + 'The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'quoteSettledInsurance'; + docs: [ + 'The amount of insurance that has been used to resolve bankruptcy and pnl deficits', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastRevenueWithdrawTs'; + docs: ['The last time revenue was settled in/out of market']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'insuranceFund'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'vault'; + type: 'pubkey'; + }, + { + name: 'totalShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'userShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'sharesBase'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'unstakingPeriod'; + type: 'i64'; + }, + { + name: 'lastRevenueSettleTs'; + type: 'i64'; + }, + { + name: 'revenueSettlePeriod'; + type: 'i64'; + }, + { + name: 'totalFactor'; + type: 'u32'; + }, + { + name: 'userFactor'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'insuranceFundRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'userIfFactor'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'totalIfFactor'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'vaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'insuranceVaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'totalIfSharesBefore'; + type: 'u128'; + }, + { + name: 'totalIfSharesAfter'; + type: 'u128'; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'ifShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastWithdrawRequestShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'ifBase'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastValidTs'; + type: 'i64'; + }, + { + name: 'lastWithdrawRequestValue'; + type: 'u64'; + }, + { + name: 'lastWithdrawRequestTs'; + type: 'i64'; + }, + { + name: 'costBasis'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 14]; + }; + }, + ]; + }; + }, + { + name: 'insuranceFundStakeRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'action'; + type: { + defined: { + name: 'stakeAction'; + }; + }; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'insuranceVaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'ifSharesBefore'; + type: 'u128'; + }, + { + name: 'userIfSharesBefore'; + type: 'u128'; + }, + { + name: 'totalIfSharesBefore'; + type: 'u128'; + }, + { + name: 'ifSharesAfter'; + type: 'u128'; + }, + { + name: 'userIfSharesAfter'; + type: 'u128'; + }, + { + name: 'totalIfSharesAfter'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'insuranceFundSwapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'rebalanceConfig'; + type: 'pubkey'; + }, + { + name: 'inIfTotalSharesBefore'; + type: 'u128'; + }, + { + name: 'outIfTotalSharesBefore'; + type: 'u128'; + }, + { + name: 'inIfUserSharesBefore'; + type: 'u128'; + }, + { + name: 'outIfUserSharesBefore'; + type: 'u128'; + }, + { + name: 'inIfTotalSharesAfter'; + type: 'u128'; + }, + { + name: 'outIfTotalSharesAfter'; + type: 'u128'; + }, + { + name: 'inIfUserSharesAfter'; + type: 'u128'; + }, + { + name: 'outIfUserSharesAfter'; + type: 'u128'; + }, + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'outAmount'; + type: 'u64'; + }, + { + name: 'outOraclePrice'; + type: 'u64'; + }, + { + name: 'outOraclePriceTwap'; + type: 'i64'; + }, + { + name: 'inVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'outVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'inFundVaultAmountAfter'; + type: 'u64'; + }, + { + name: 'outFundVaultAmountAfter'; + type: 'u64'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }; + }, + { + name: 'lpAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'addLiquidity'; + }, + { + name: 'removeLiquidity'; + }, + { + name: 'settleLiquidity'; + }, + { + name: 'removeLiquidityDerisk'; + }, + ]; + }; + }, + { + name: 'lpBorrowLendDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'direction'; + type: { + defined: { + name: 'depositDirection'; + }; + }; + }, + { + name: 'tokenBalance'; + type: 'i64'; + }, + { + name: 'lastTokenBalance'; + type: 'i64'; + }, + { + name: 'interestAccruedTokenAmount'; + type: 'i64'; + }, + { + name: 'amountDepositWithdraw'; + type: 'u64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpMintRedeemRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'description'; + type: 'u8'; + }, + { + name: 'amount'; + docs: ['precision: continutent mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'fee'; + docs: [ + 'precision: fee on amount, constituent market mint precision', + ]; + type: 'i128'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'mint'; + docs: ['token mint']; + type: 'pubkey'; + }, + { + name: 'lpAmount'; + docs: ['lp amount, lp mint precision']; + type: 'u64'; + }, + { + name: 'lpFee'; + docs: ['lp fee, lp mint precision']; + type: 'i64'; + }, + { + name: 'lpPrice'; + docs: ['the fair price of the lp token, PRICE_PRECISION']; + type: 'u128'; + }, + { + name: 'mintRedeemId'; + type: 'u64'; + }, + { + name: 'lastAum'; + docs: ['LPPool last_aum']; + type: 'u128'; + }, + { + name: 'lastAumSlot'; + type: 'u64'; + }, + { + name: 'inMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inMarketTargetWeight'; + type: 'i64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpPool'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: ['address of the vault.']; + type: 'pubkey'; + }, + { + name: 'mint'; + type: 'pubkey'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + { + name: 'constituentTargetBase'; + type: 'pubkey'; + }, + { + name: 'constituentCorrelations'; + type: 'pubkey'; + }, + { + name: 'maxAum'; + docs: [ + 'The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)', + 'which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)', + 'pub quote_constituent_index: u16,', + 'QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastAum'; + docs: ['QUOTE_PRECISION: AUM of the vault in USD, updated lazily']; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeQuoteSentToPerpMarkets'; + docs: ['QUOTE PRECISION: Cumulative quotes from settles']; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeQuoteReceivedFromPerpMarkets'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalMintRedeemFeesPaid'; + docs: [ + 'QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'lastAumSlot'; + docs: ['timestamp of last AUM slot']; + type: 'u64'; + }, + { + name: 'maxSettleQuoteAmount'; + type: 'u64'; + }, + { + name: 'padding'; + docs: ['timestamp of last vAMM revenue rebalance']; + type: 'u64'; + }, + { + name: 'mintRedeemId'; + docs: [ + 'Every mint/redeem has a monotonically increasing id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'settleId'; + type: 'u64'; + }, + { + name: 'minMintFee'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'tokenSupply'; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'constituents'; + type: 'u16'; + }, + { + name: 'quoteConsituentIndex'; + type: 'u16'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'targetOracleDelayFeeBpsPer10Slots'; + type: 'u8'; + }, + { + name: 'targetPositionDelayFeeBpsPer10Slots'; + type: 'u8'; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 174]; + }; + }, + ]; + }; + }, + { + name: 'lpRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'action'; + type: { + defined: { + name: 'lpAction'; + }; + }; + }, + { + name: 'nShares'; + docs: ['precision: AMM_RESERVE_PRECISION']; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'deltaBaseAssetAmount'; + docs: ['precision: BASE_PRECISION']; + type: 'i64'; + }, + { + name: 'deltaQuoteAssetAmount'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'pnl'; + docs: [ + 'realized pnl of the position settlement', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'lpSettleRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'lastTs'; + type: 'i64'; + }, + { + name: 'lastSlot'; + type: 'u64'; + }, + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'settleToLpAmount'; + type: 'i64'; + }, + { + name: 'perpAmmPnlDelta'; + type: 'i64'; + }, + { + name: 'perpAmmExFeeDelta'; + type: 'i64'; + }, + { + name: 'lpAum'; + type: 'u128'; + }, + { + name: 'lpPrice'; + type: 'u128'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpSwapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'outAmount'; + docs: ['precision: out market mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'inAmount'; + docs: ['precision: in market mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'outFee'; + docs: ['precision: fee on amount_out, in market mint precision']; + type: 'i128'; + }, + { + name: 'inFee'; + docs: ['precision: fee on amount_in, out market mint precision']; + type: 'i128'; + }, + { + name: 'outSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'inSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'outConstituentIndex'; + type: 'u16'; + }, + { + name: 'inConstituentIndex'; + type: 'u16'; + }, + { + name: 'outOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'inOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastAum'; + docs: ['LPPool last_aum, QUOTE_PRECISION']; + type: 'u128'; + }, + { + name: 'lastAumSlot'; + type: 'u64'; + }, + { + name: 'inMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'outMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inMarketTargetWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'outMarketTargetWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inSwapId'; + type: 'u64'; + }, + { + name: 'outSwapId'; + type: 'u64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'liquidateBorrowForPerpPnlRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marketOraclePrice'; + type: 'i64'; + }, + { + name: 'pnlTransfer'; + type: 'u128'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityPrice'; + type: 'i64'; + }, + { + name: 'liabilityTransfer'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'liquidatePerpPnlForDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marketOraclePrice'; + type: 'i64'; + }, + { + name: 'pnlTransfer'; + type: 'u128'; + }, + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'assetPrice'; + type: 'i64'; + }, + { + name: 'assetTransfer'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'liquidatePerpRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'oraclePrice'; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + type: 'i64'; + }, + { + name: 'quoteAssetAmount'; + type: 'i64'; + }, + { + name: 'lpShares'; + docs: ['precision: AMM_RESERVE_PRECISION']; + type: 'u64'; + }, + { + name: 'fillRecordId'; + type: 'u64'; + }, + { + name: 'userOrderId'; + type: 'u32'; + }, + { + name: 'liquidatorOrderId'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'ifFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'liquidateSpotRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'assetPrice'; + type: 'i64'; + }, + { + name: 'assetTransfer'; + type: 'u128'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityPrice'; + type: 'i64'; + }, + { + name: 'liabilityTransfer'; + docs: ['precision: token mint precision']; + type: 'u128'; + }, + { + name: 'ifFee'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'liquidationRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'liquidationType'; + type: { + defined: { + name: 'liquidationType'; + }; + }; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'liquidator'; + type: 'pubkey'; + }, + { + name: 'marginRequirement'; + type: 'u128'; + }, + { + name: 'totalCollateral'; + type: 'i128'; + }, + { + name: 'marginFreed'; + type: 'u64'; + }, + { + name: 'liquidationId'; + type: 'u16'; + }, + { + name: 'bankrupt'; + type: 'bool'; + }, + { + name: 'canceledOrderIds'; + type: { + vec: 'u32'; + }; + }, + { + name: 'liquidatePerp'; + type: { + defined: { + name: 'liquidatePerpRecord'; + }; + }; + }, + { + name: 'liquidateSpot'; + type: { + defined: { + name: 'liquidateSpotRecord'; + }; + }; + }, + { + name: 'liquidateBorrowForPerpPnl'; + type: { + defined: { + name: 'liquidateBorrowForPerpPnlRecord'; + }; + }; + }, + { + name: 'liquidatePerpPnlForDeposit'; + type: { + defined: { + name: 'liquidatePerpPnlForDepositRecord'; + }; + }; + }, + { + name: 'perpBankruptcy'; + type: { + defined: { + name: 'perpBankruptcyRecord'; + }; + }; + }, + { + name: 'spotBankruptcy'; + type: { + defined: { + name: 'spotBankruptcyRecord'; + }; + }; + }, + ]; + }; + }, + { + name: 'liquidationType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'liquidatePerp'; + }, + { + name: 'liquidateSpot'; + }, + { + name: 'liquidateBorrowForPerpPnl'; + }, + { + name: 'liquidatePerpPnlForDeposit'; + }, + { + name: 'perpBankruptcy'; + }, + { + name: 'spotBankruptcy'; + }, + ]; + }; + }, + { + name: 'lpPoolParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxSettleQuoteAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'volatility'; + type: { + option: 'u64'; + }; + }, + { + name: 'gammaExecution'; + type: { + option: 'u8'; + }; + }, + { + name: 'xi'; + type: { + option: 'u8'; + }; + }, + { + name: 'maxAum'; + type: { + option: 'u128'; + }; + }, + { + name: 'whitelistMint'; + type: { + option: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'marginMode'; + type: { + kind: 'enum'; + variants: [ + { + name: 'default'; + }, + { + name: 'highLeverage'; + }, + { + name: 'highLeverageMaintenance'; + }, + ]; + }; + }, + { + name: 'marketStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'initialized'; + }, + { + name: 'active'; + }, + { + name: 'fundingPaused'; + }, + { + name: 'ammPaused'; + }, + { + name: 'fillPaused'; + }, + { + name: 'withdrawPaused'; + }, + { + name: 'reduceOnly'; + }, + { + name: 'settlement'; + }, + { + name: 'delisted'; + }, + ]; + }; + }, + { + name: 'marketType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'spot'; + }, + { + name: 'perp'; + }, + ]; + }; + }, + { + name: 'modifyOrderParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'direction'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'baseAssetAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'price'; + type: { + option: 'u64'; + }; + }, + { + name: 'reduceOnly'; + type: { + option: 'bool'; + }; + }, + { + name: 'postOnly'; + type: { + option: { + defined: { + name: 'postOnlyParam'; + }; + }; + }; + }, + { + name: 'bitFlags'; + type: { + option: 'u8'; + }; + }, + { + name: 'maxTs'; + type: { + option: 'i64'; + }; + }, + { + name: 'triggerPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerCondition'; + type: { + option: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }; + }, + { + name: 'oraclePriceOffset'; + type: { + option: 'i32'; + }; + }, + { + name: 'auctionDuration'; + type: { + option: 'u8'; + }; + }, + { + name: 'auctionStartPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'auctionEndPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'policy'; + type: { + option: 'u8'; + }; + }, + ]; + }; + }, + { + name: 'newUserRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'referrer'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'openbookV2FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'openbookV2ProgramId'; + type: 'pubkey'; + }, + { + name: 'openbookV2Market'; + type: 'pubkey'; + }, + { + name: 'openbookV2MarketAuthority'; + type: 'pubkey'; + }, + { + name: 'openbookV2EventHeap'; + type: 'pubkey'; + }, + { + name: 'openbookV2Bids'; + type: 'pubkey'; + }, + { + name: 'openbookV2Asks'; + type: 'pubkey'; + }, + { + name: 'openbookV2BaseVault'; + type: 'pubkey'; + }, + { + name: 'openbookV2QuoteVault'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'oracleGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'priceDivergence'; + type: { + defined: { + name: 'priceDivergenceGuardRails'; + }; + }; + }, + { + name: 'validity'; + type: { + defined: { + name: 'validityGuardRails'; + }; + }; + }, + ]; + }; + }, + { + name: 'oracleSource'; + type: { + kind: 'enum'; + variants: [ + { + name: 'pyth'; + }, + { + name: 'switchboard'; + }, + { + name: 'quoteAsset'; + }, + { + name: 'pyth1K'; + }, + { + name: 'pyth1M'; + }, + { + name: 'pythStableCoin'; + }, + { + name: 'prelaunch'; + }, + { + name: 'pythPull'; + }, + { + name: 'pyth1KPull'; + }, + { + name: 'pyth1MPull'; + }, + { + name: 'pythStableCoinPull'; + }, + { + name: 'switchboardOnDemand'; + }, + { + name: 'pythLazer'; + }, + { + name: 'pythLazer1K'; + }, + { + name: 'pythLazer1M'; + }, + { + name: 'pythLazerStableCoin'; + }, + ]; + }; + }, + { + name: 'order'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'slot'; + docs: ['The slot the order was placed']; + type: 'u64'; + }, + { + name: 'price'; + docs: [ + 'The limit price for the order (can be 0 for market orders)', + "For orders with an auction, this price isn't used until the auction is complete", + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'baseAssetAmount'; + docs: [ + 'The size of the order', + 'precision for perps: BASE_PRECISION', + 'precision for spot: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'baseAssetAmountFilled'; + docs: [ + 'The amount of the order filled', + 'precision for perps: BASE_PRECISION', + 'precision for spot: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'quoteAssetAmountFilled'; + docs: [ + 'The amount of quote filled for the order', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'triggerPrice'; + docs: [ + 'At what price the order will be triggered. Only relevant for trigger orders', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'auctionStartPrice'; + docs: [ + 'The start price for the auction. Only relevant for market/oracle orders', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'auctionEndPrice'; + docs: [ + 'The end price for the auction. Only relevant for market/oracle orders', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxTs'; + docs: ['The time when the order will expire']; + type: 'i64'; + }, + { + name: 'oraclePriceOffset'; + docs: [ + 'If set, the order limit price is the oracle price + this offset', + 'precision: PRICE_PRECISION', + ]; + type: 'i32'; + }, + { + name: 'orderId'; + docs: [ + 'The id for the order. Each users has their own order id space', + ]; + type: 'u32'; + }, + { + name: 'marketIndex'; + docs: ['The perp/spot market index']; + type: 'u16'; + }, + { + name: 'status'; + docs: ['Whether the order is open or unused']; + type: { + defined: { + name: 'orderStatus'; + }; + }; + }, + { + name: 'orderType'; + docs: ['The type of order']; + type: { + defined: { + name: 'orderType'; + }; + }; + }, + { + name: 'marketType'; + docs: ['Whether market is spot or perp']; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'userOrderId'; + docs: [ + 'User generated order id. Can make it easier to place/cancel orders', + ]; + type: 'u8'; + }, + { + name: 'existingPositionDirection'; + docs: ['What the users position was when the order was placed']; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'direction'; + docs: [ + 'Whether the user is going long or short. LONG = bid, SHORT = ask', + ]; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'reduceOnly'; + docs: ['Whether the order is allowed to only reduce position size']; + type: 'bool'; + }, + { + name: 'postOnly'; + docs: ['Whether the order must be a maker']; + type: 'bool'; + }, + { + name: 'immediateOrCancel'; + docs: [ + 'Whether the order must be canceled the same slot it is placed', + ]; + type: 'bool'; + }, + { + name: 'triggerCondition'; + docs: [ + 'Whether the order is triggered above or below the trigger price. Only relevant for trigger orders', + ]; + type: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }, + { + name: 'auctionDuration'; + docs: ['How many slots the auction lasts']; + type: 'u8'; + }, + { + name: 'postedSlotTail'; + docs: [ + 'Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)', + ]; + type: 'u8'; + }, + { + name: 'bitFlags'; + docs: [ + 'Bitflags for further classification', + '0: is_signed_message', + ]; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 1]; + }; + }, + ]; + }; + }, + { + name: 'orderAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'place'; + }, + { + name: 'cancel'; + }, + { + name: 'fill'; + }, + { + name: 'trigger'; + }, + { + name: 'expire'; + }, + ]; + }; + }, + { + name: 'orderActionExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'insufficientFreeCollateral'; + }, + { + name: 'oraclePriceBreachedLimitPrice'; + }, + { + name: 'marketOrderFilledToLimitPrice'; + }, + { + name: 'orderExpired'; + }, + { + name: 'liquidation'; + }, + { + name: 'orderFilledWithAmm'; + }, + { + name: 'orderFilledWithAmmJit'; + }, + { + name: 'orderFilledWithMatch'; + }, + { + name: 'orderFilledWithMatchJit'; + }, + { + name: 'marketExpired'; + }, + { + name: 'riskingIncreasingOrder'; + }, + { + name: 'reduceOnlyOrderIncreasedPosition'; + }, + { + name: 'orderFillWithSerum'; + }, + { + name: 'noBorrowLiquidity'; + }, + { + name: 'orderFillWithPhoenix'; + }, + { + name: 'orderFilledWithAmmJitLpSplit'; + }, + { + name: 'orderFilledWithLpJit'; + }, + { + name: 'deriskLp'; + }, + { + name: 'orderFilledWithOpenbookV2'; + }, + { + name: 'transferPerpPosition'; + }, + ]; + }; + }, + { + name: 'orderActionRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'action'; + type: { + defined: { + name: 'orderAction'; + }; + }; + }, + { + name: 'actionExplanation'; + type: { + defined: { + name: 'orderActionExplanation'; + }; + }; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'filler'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'fillerReward'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'fillRecordId'; + type: { + option: 'u64'; + }; + }, + { + name: 'baseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'quoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'i64'; + }; + }, + { + name: 'referrerReward'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u32'; + }; + }, + { + name: 'quoteAssetAmountSurplus'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'i64'; + }; + }, + { + name: 'spotFulfillmentMethodFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'taker'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'takerOrderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'takerOrderDirection'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'takerOrderBaseAssetAmount'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerOrderCumulativeBaseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerOrderCumulativeQuoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'maker'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'makerOrderDirection'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'makerOrderBaseAssetAmount'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerOrderCumulativeBaseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerOrderCumulativeQuoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'bitFlags'; + docs: ['Bit flags:', '0: is_signed_message']; + type: 'u8'; + }, + { + name: 'takerExistingQuoteEntryAmount'; + docs: [ + 'precision: QUOTE_PRECISION', + 'Only Some if the taker reduced position', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'takerExistingBaseAssetAmount'; + docs: [ + 'precision: BASE_PRECISION', + 'Only Some if the taker flipped position direction', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'makerExistingQuoteEntryAmount'; + docs: [ + 'precision: QUOTE_PRECISION', + 'Only Some if the maker reduced position', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'makerExistingBaseAssetAmount'; + docs: [ + 'precision: BASE_PRECISION', + 'Only Some if the maker flipped position direction', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerPrice'; + docs: ['precision: PRICE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'builderIdx'; + docs: [ + "the idx of the builder in the taker's [`RevenueShareEscrow`] account", + ]; + type: { + option: 'u8'; + }; + }, + { + name: 'builderFee'; + docs: ['precision: QUOTE_PRECISION builder fee paid by the taker']; + type: { + option: 'u64'; + }; + }, + ]; + }; + }, + { + name: 'orderFillerRewardStructure'; + type: { + kind: 'struct'; + fields: [ + { + name: 'rewardNumerator'; + type: 'u32'; + }, + { + name: 'rewardDenominator'; + type: 'u32'; + }, + { + name: 'timeBasedRewardLowerBound'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + ]; + }; + }, + { + name: 'orderParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'orderType'; + type: { + defined: { + name: 'orderType'; + }; + }; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'direction'; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'userOrderId'; + type: 'u8'; + }, + { + name: 'baseAssetAmount'; + type: 'u64'; + }, + { + name: 'price'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'postOnly'; + type: { + defined: { + name: 'postOnlyParam'; + }; + }; + }, + { + name: 'bitFlags'; + type: 'u8'; + }, + { + name: 'maxTs'; + type: { + option: 'i64'; + }; + }, + { + name: 'triggerPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerCondition'; + type: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }, + { + name: 'oraclePriceOffset'; + type: { + option: 'i32'; + }; + }, + { + name: 'auctionDuration'; + type: { + option: 'u8'; + }; + }, + { + name: 'auctionStartPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'auctionEndPrice'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'orderRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'order'; + type: { + defined: { + name: 'order'; + }; + }; + }, + ]; + }; + }, + { + name: 'orderStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'init'; + }, + { + name: 'open'; + }, + { + name: 'filled'; + }, + { + name: 'canceled'; + }, + ]; + }; + }, + { + name: 'orderTriggerCondition'; + type: { + kind: 'enum'; + variants: [ + { + name: 'above'; + }, + { + name: 'below'; + }, + { + name: 'triggeredAbove'; + }, + { + name: 'triggeredBelow'; + }, + ]; + }; + }, + { + name: 'orderType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'market'; + }, + { + name: 'limit'; + }, + { + name: 'triggerMarket'; + }, + { + name: 'triggerLimit'; + }, + { + name: 'oracle'; + }, + ]; + }; + }, + { + name: 'overrideAmmCacheParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'quoteOwedFromLpPool'; + type: { + option: 'i64'; + }; + }, + { + name: 'lastSettleSlot'; + type: { + option: 'u64'; + }; + }, + { + name: 'lastFeePoolTokenAmount'; + type: { + option: 'u128'; + }; + }, + { + name: 'lastNetPnlPoolTokenAmount'; + type: { + option: 'i128'; + }; + }, + { + name: 'ammPositionScalar'; + type: { + option: 'u8'; + }; + }, + { + name: 'ammInventoryLimit'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'perpBankruptcyRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'pnl'; + type: 'i128'; + }, + { + name: 'ifPayment'; + type: 'u128'; + }, + { + name: 'clawbackUser'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'clawbackUserPayment'; + type: { + option: 'u128'; + }; + }, + { + name: 'cumulativeFundingRateDelta'; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: [ + "The perp market's address. It is a pda of the market index", + ]; + type: 'pubkey'; + }, + { + name: 'amm'; + docs: ['The automated market maker']; + type: { + defined: { + name: 'amm'; + }; + }; + }, + { + name: 'pnlPool'; + docs: [ + "The market's pnl pool. When users settle negative pnl, the balance increases.", + 'When users settle positive pnl, the balance decreases. Can not go negative.', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'name'; + docs: ['Encoded display name for the perp market e.g. SOL-PERP']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'insuranceClaim'; + docs: ["The perp market's claim on the insurance fund"]; + type: { + defined: { + name: 'insuranceClaim'; + }; + }; + }, + { + name: 'unrealizedPnlMaxImbalance'; + docs: [ + 'The max pnl imbalance before positive pnl asset weight is discounted', + "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", + 'the amm has negative pnl and the initial asset weight for positive pnl is discounted', + 'precision = QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'expiryTs'; + docs: [ + 'The ts when the market will be expired. Only set if market is in reduce only mode', + ]; + type: 'i64'; + }, + { + name: 'expiryPrice'; + docs: [ + 'The price at which positions will be settled. Only set if market is expired', + 'precision = PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'nextFillRecordId'; + docs: [ + 'Every trade has a fill record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'nextFundingRateRecordId'; + docs: [ + 'Every funding rate update has a record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'nextCurveRecordId'; + docs: [ + 'Every amm k updated has a record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'imfFactor'; + docs: [ + 'The initial margin fraction factor. Used to increase margin ratio for large positions', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlImfFactor'; + docs: [ + 'The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: [ + 'The fee the liquidator is paid for taking over perp position', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + docs: [ + 'The fee the insurance fund receives from liquidation', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'marginRatioInitial'; + docs: [ + 'The margin ratio which determines how much collateral is required to open a position', + 'e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + docs: [ + 'The margin ratio which determines when a user will be liquidated', + 'e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position', + 'else they will be liquidated', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlInitialAssetWeight'; + docs: [ + 'The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlMaintenanceAssetWeight'; + docs: [ + 'The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'numberOfUsersWithBase'; + docs: ['number of users in a position (base)']; + type: 'u32'; + }, + { + name: 'numberOfUsers'; + docs: ['number of users in a position (pnl) or pnl (quote)']; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'status'; + docs: [ + 'Whether a market is active, reduce only, expired, etc', + 'Affects whether users can open/close positions', + ]; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + { + name: 'contractType'; + docs: ['Currently only Perpetual markets are supported']; + type: { + defined: { + name: 'contractType'; + }; + }; + }, + { + name: 'contractTier'; + docs: [ + 'The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance', + 'It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first', + ]; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'quoteSpotMarketIndex'; + docs: ['The spot market that pnl is settled in']; + type: 'u16'; + }, + { + name: 'feeAdjustment'; + docs: [ + 'Between -100 and 100, represents what % to increase/decrease the fee by', + 'E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps', + 'if this is 50 and the fee is 5bps, the new fee will be 7.5bps', + ]; + type: 'i16'; + }, + { + name: 'fuelBoostPosition'; + docs: ['fuel multiplier for perp funding', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostTaker'; + docs: ['fuel multiplier for perp taker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostMaker'; + docs: ['fuel multiplier for perp maker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'highLeverageMarginRatioInitial'; + type: 'u16'; + }, + { + name: 'highLeverageMarginRatioMaintenance'; + type: 'u16'; + }, + { + name: 'protectedMakerLimitPriceDivisor'; + type: 'u8'; + }, + { + name: 'protectedMakerDynamicDivisor'; + type: 'u8'; + }, + { + name: 'lpFeeTransferScalar'; + type: 'u8'; + }, + { + name: 'lpStatus'; + type: 'u8'; + }, + { + name: 'lpPausedOperations'; + type: 'u8'; + }, + { + name: 'lpExchangeFeeExcluscionScalar'; + type: 'u8'; + }, + { + name: 'lastFillPrice'; + type: 'u64'; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 23]; + }; + }, + ]; + }; + }, + { + name: 'perpPosition'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastCumulativeFundingRate'; + docs: [ + "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + docs: [ + 'the size of the users perp position', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteAssetAmount'; + docs: [ + 'Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees', + 'Updated when the user open/closes position or settles pnl. Includes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteBreakEvenAmount'; + docs: [ + 'The amount of quote the user would need to exit their position at to break even', + 'Updated when the user open/closes position or settles pnl. Includes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteEntryAmount'; + docs: [ + 'The amount quote the user entered the position with. Equal to base asset amount * avg entry price', + 'Updated when the user open/closes position. Excludes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'openBids'; + docs: [ + 'The amount of non reduce only trigger orders the user has open', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'openAsks'; + docs: [ + 'The amount of non reduce only trigger orders the user has open', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'settledPnl'; + docs: [ + 'The amount of pnl settled in this market since opening the position', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lpShares'; + docs: [ + 'The number of lp (liquidity provider) shares the user has in this perp market', + 'LP shares allow users to provide liquidity via the AMM', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastBaseAssetAmountPerLp'; + docs: [ + 'The last base asset amount per lp the amm had', + 'Used to settle the users lp position', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastQuoteAssetAmountPerLp'; + docs: [ + 'The last quote asset amount per lp the amm had', + 'Used to settle the users lp position', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'padding'; + type: { + array: ['u8', 2]; + }; + }, + { + name: 'maxMarginRatio'; + type: 'u16'; + }, + { + name: 'marketIndex'; + docs: ['The market index for the perp market']; + type: 'u16'; + }, + { + name: 'openOrders'; + docs: ['The number of open orders']; + type: 'u8'; + }, + { + name: 'perLpBase'; + type: 'i8'; + }, + ]; + }; + }, + { + name: 'phoenixV1FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'phoenixProgramId'; + type: 'pubkey'; + }, + { + name: 'phoenixLogAuthority'; + type: 'pubkey'; + }, + { + name: 'phoenixMarket'; + type: 'pubkey'; + }, + { + name: 'phoenixBaseVault'; + type: 'pubkey'; + }, + { + name: 'phoenixQuoteVault'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'poolBalance'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", + 'deposit interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'marketIndex'; + docs: ['The spot market the pool is for']; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 6]; + }; + }, + ]; + }; + }, + { + name: 'positionDirection'; + type: { + kind: 'enum'; + variants: [ + { + name: 'long'; + }, + { + name: 'short'; + }, + ]; + }; + }, + { + name: 'postOnlyParam'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'mustPostOnly'; + }, + { + name: 'tryPostOnly'; + }, + { + name: 'slide'; + }, + ]; + }; + }, + { + name: 'prelaunchOracle'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'price'; + type: 'i64'; + }, + { + name: 'maxPrice'; + type: 'i64'; + }, + { + name: 'confidence'; + type: 'u64'; + }, + { + name: 'lastUpdateSlot'; + type: 'u64'; + }, + { + name: 'ammLastUpdateSlot'; + type: 'u64'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 70]; + }; + }, + ]; + }; + }, + { + name: 'prelaunchOracleParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'price'; + type: { + option: 'i64'; + }; + }, + { + name: 'maxPrice'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'priceDivergenceGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'markOraclePercentDivergence'; + type: 'u64'; + }, + { + name: 'oracleTwap5minPercentDivergence'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'protectedMakerModeConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'currentUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 31]; + }; + }, + ]; + }; + }, + { + name: 'pythLazerOracle'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'price'; + type: 'i64'; + }, + { + name: 'publishTime'; + type: 'u64'; + }, + { + name: 'postedSlot'; + type: 'u64'; + }, + { + name: 'exponent'; + type: 'i32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'conf'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'referrerName'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'userStats'; + type: 'pubkey'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }; + }, + { + name: 'revenueShare'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'rust'; + packed: true; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['the owner of this account, a builder or referrer']; + type: 'pubkey'; + }, + { + name: 'totalReferrerRewards'; + type: 'u64'; + }, + { + name: 'totalBuilderRewards'; + type: 'u64'; + }, + { + name: 'padding'; + type: { + array: ['u8', 18]; + }; + }, + ]; + }; + }, + { + name: 'revenueShareEscrow'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['the owner of this account, a user']; + type: 'pubkey'; + }, + { + name: 'referrer'; + type: 'pubkey'; + }, + { + name: 'referrerBoostExpireTs'; + type: 'u32'; + }, + { + name: 'referrerRewardOffset'; + type: 'i8'; + }, + { + name: 'refereeFeeNumeratorOffset'; + type: 'i8'; + }, + { + name: 'referrerBoostNumerator'; + type: 'i8'; + }, + { + name: 'reservedFixed'; + type: { + array: ['u8', 17]; + }; + }, + { + name: 'padding0'; + type: 'u32'; + }, + { + name: 'orders'; + type: { + vec: { + defined: { + name: 'revenueShareOrder'; + }; + }; + }; + }, + { + name: 'padding1'; + type: 'u32'; + }, + { + name: 'approvedBuilders'; + type: { + vec: { + defined: { + name: 'builderInfo'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'revenueShareOrder'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'feesAccrued'; + docs: [ + 'fees accrued so far for this order slot. This is not exclusively fees from this order_id', + 'and may include fees from other orders in the same market. This may be swept to the', + "builder's SpotPosition during settle_pnl.", + ]; + type: 'u64'; + }, + { + name: 'orderId'; + docs: [ + "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open", + ]; + type: 'u32'; + }, + { + name: 'feeTenthBps'; + docs: [ + 'the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%', + ]; + type: 'u16'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'subAccountId'; + docs: [ + "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open", + ]; + type: 'u16'; + }, + { + name: 'builderIdx'; + docs: [ + "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", + 'if bit_flag = Referral.', + ]; + type: 'u8'; + }, + { + name: 'bitFlags'; + docs: [ + 'bitflags that describe the state of the order.', + '[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.', + "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", + '[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.', + "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", + '[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.', + 'If it is set, no other bitflag should be set.', + ]; + type: 'u8'; + }, + { + name: 'userOrderIndex'; + docs: [ + "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches.", + ]; + type: 'u8'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 10]; + }; + }, + ]; + }; + }, + { + name: 'revenueShareSettleRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'builder'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'referrer'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'feeSettled'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'builderSubAccountId'; + type: 'u16'; + }, + { + name: 'builderTotalReferrerRewards'; + type: 'u64'; + }, + { + name: 'builderTotalBuilderRewards'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'serumV3FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'serumProgramId'; + type: 'pubkey'; + }, + { + name: 'serumMarket'; + type: 'pubkey'; + }, + { + name: 'serumRequestQueue'; + type: 'pubkey'; + }, + { + name: 'serumEventQueue'; + type: 'pubkey'; + }, + { + name: 'serumBids'; + type: 'pubkey'; + }, + { + name: 'serumAsks'; + type: 'pubkey'; + }, + { + name: 'serumBaseVault'; + type: 'pubkey'; + }, + { + name: 'serumQuoteVault'; + type: 'pubkey'; + }, + { + name: 'serumOpenOrders'; + type: 'pubkey'; + }, + { + name: 'serumSignerNonce'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'settlePnlExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'expiredPosition'; + }, + ]; + }; + }, + { + name: 'settlePnlMode'; + type: { + kind: 'enum'; + variants: [ + { + name: 'mustSettle'; + }, + { + name: 'trySettle'; + }, + ]; + }; + }, + { + name: 'settlePnlRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'pnl'; + type: 'i128'; + }, + { + name: 'baseAssetAmount'; + type: 'i64'; + }, + { + name: 'quoteAssetAmountAfter'; + type: 'i64'; + }, + { + name: 'quoteEntryAmount'; + type: 'i64'; + }, + { + name: 'settlePrice'; + type: 'i64'; + }, + { + name: 'explanation'; + type: { + defined: { + name: 'settlePnlExplanation'; + }; + }; + }, + ]; + }; + }, + { + name: 'signedMsgOrderId'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'uuid'; + type: { + array: ['u8', 8]; + }; + }, + { + name: 'maxSlot'; + type: 'u64'; + }, + { + name: 'orderId'; + type: 'u32'; + }, + { + name: 'padding'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'signedMsgOrderRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'hash'; + type: 'string'; + }, + { + name: 'matchingOrderParams'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'userOrderId'; + type: 'u32'; + }, + { + name: 'signedMsgOrderMaxSlot'; + type: 'u64'; + }, + { + name: 'signedMsgOrderUuid'; + type: { + array: ['u8', 8]; + }; + }, + { + name: 'ts'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'signedMsgUserOrders'; + docs: [ + '* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently', + ]; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authorityPubkey'; + type: 'pubkey'; + }, + { + name: 'padding'; + type: 'u32'; + }, + { + name: 'signedMsgOrderData'; + type: { + vec: { + defined: { + name: 'signedMsgOrderId'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'signedMsgWsDelegates'; + docs: [ + '* Used to store authenticated delegates for swift-like ws connections', + ]; + type: { + kind: 'struct'; + fields: [ + { + name: 'delegates'; + type: { + vec: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'spotBalanceType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'deposit'; + }, + { + name: 'borrow'; + }, + ]; + }; + }, + { + name: 'spotBankruptcyRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'borrowAmount'; + type: 'u128'; + }, + { + name: 'ifPayment'; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestDelta'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'spotFulfillmentConfigStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'enabled'; + }, + { + name: 'disabled'; + }, + ]; + }; + }, + { + name: 'spotFulfillmentType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'serumV3'; + }, + { + name: 'match'; + }, + { + name: 'phoenixV1'; + }, + { + name: 'openbookV2'; + }, + ]; + }; + }, + { + name: 'spotInterestRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'depositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'borrowBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeBorrowInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'optimalUtilization'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'spotMarket'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: [ + 'The address of the spot market. It is a pda of the market index', + ]; + type: 'pubkey'; + }, + { + name: 'oracle'; + docs: ['The oracle used to price the markets deposits/borrows']; + type: 'pubkey'; + }, + { + name: 'mint'; + docs: ['The token mint of the market']; + type: 'pubkey'; + }, + { + name: 'vault'; + docs: [ + "The vault used to store the market's deposits", + 'The amount in the vault should be equal to or greater than deposits - borrows', + ]; + type: 'pubkey'; + }, + { + name: 'name'; + docs: ['The encoded display name for the market e.g. SOL']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'historicalOracleData'; + type: { + defined: { + name: 'historicalOracleData'; + }; + }; + }, + { + name: 'historicalIndexData'; + type: { + defined: { + name: 'historicalIndexData'; + }; + }; + }, + { + name: 'revenuePool'; + docs: [ + 'Revenue the protocol has collected in this markets token', + 'e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'spotFeePool'; + docs: [ + 'The fees collected from swaps between this market and the quote market', + 'Is settled to the quote markets revenue pool', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'insuranceFund'; + docs: [ + 'Details on the insurance fund covering bankruptcies in this markets token', + 'Covers bankruptcies for borrows with this markets token and perps settling in this markets token', + ]; + type: { + defined: { + name: 'insuranceFund'; + }; + }; + }, + { + name: 'totalSpotFee'; + docs: [ + 'The total spot fees collected for this market', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'depositBalance'; + docs: [ + 'The sum of the scaled balances for deposits across users and pool balances', + 'To convert to the deposit token amount, multiply by the cumulative deposit interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'borrowBalance'; + docs: [ + 'The sum of the scaled balances for borrows across users and pool balances', + 'To convert to the borrow token amount, multiply by the cumulative borrow interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeDepositInterest'; + docs: [ + 'The cumulative interest earned by depositors', + 'Used to calculate the deposit token amount from the deposit balance', + 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeBorrowInterest'; + docs: [ + 'The cumulative interest earned by borrowers', + 'Used to calculate the borrow token amount from the borrow balance', + 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalSocialLoss'; + docs: [ + "The total socialized loss from borrows, in the mint's token", + 'precision: token mint precision', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalQuoteSocialLoss'; + docs: [ + "The total socialized loss from borrows, in the quote market's token", + 'preicision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'withdrawGuardThreshold'; + docs: [ + 'no withdraw limits/guards when deposits below this threshold', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'maxTokenDeposits'; + docs: [ + 'The max amount of token deposits in this market', + '0 if there is no limit', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'depositTokenTwap'; + docs: [ + '24hr average of deposit token amount', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'borrowTokenTwap'; + docs: [ + '24hr average of borrow token amount', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'utilizationTwap'; + docs: [ + '24hr average of utilization', + 'which is borrow amount over token amount', + 'precision: SPOT_UTILIZATION_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastInterestTs'; + docs: [ + 'Last time the cumulative deposit and borrow interest was updated', + ]; + type: 'u64'; + }, + { + name: 'lastTwapTs'; + docs: [ + 'Last time the deposit/borrow/utilization averages were updated', + ]; + type: 'u64'; + }, + { + name: 'expiryTs'; + docs: [ + 'The time the market is set to expire. Only set if market is in reduce only mode', + ]; + type: 'i64'; + }, + { + name: 'orderStepSize'; + docs: [ + 'Spot orders must be a multiple of the step size', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'orderTickSize'; + docs: [ + 'Spot orders must be a multiple of the tick size', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minOrderSize'; + docs: ['The minimum order size', 'precision: token mint precision']; + type: 'u64'; + }, + { + name: 'maxPositionSize'; + docs: [ + 'The maximum spot position size', + 'if the limit is 0, there is no limit', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'nextFillRecordId'; + docs: [ + 'Every spot trade has a fill record id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'nextDepositRecordId'; + docs: [ + 'Every deposit has a deposit record id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'initialAssetWeight'; + docs: [ + 'The initial asset weight used to calculate a deposits contribution to a users initial total collateral', + 'e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + docs: [ + 'The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral', + 'e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + docs: [ + 'The initial liability weight used to calculate a borrows contribution to a users initial margin requirement', + 'e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + docs: [ + 'The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement', + 'e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'imfFactor'; + docs: [ + 'The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: [ + 'The fee the liquidator is paid for taking over borrow/deposit', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + docs: [ + 'The fee the insurance fund receives from liquidation', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'optimalUtilization'; + docs: [ + 'The optimal utilization rate for this market.', + 'Used to determine the markets borrow rate', + 'precision: SPOT_UTILIZATION_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + docs: [ + 'The borrow rate for this market when the market has optimal utilization', + 'precision: SPOT_RATE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + docs: [ + 'The borrow rate for this market when the market has 1000 utilization', + 'precision: SPOT_RATE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'decimals'; + docs: [ + "The market's token mint's decimals. To from decimals to a precision, 10^decimals", + ]; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'ordersEnabled'; + docs: ['Whether or not spot trading is enabled']; + type: 'bool'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + { + name: 'assetTier'; + docs: [ + 'The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated', + ]; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'ifPausedOperations'; + type: 'u8'; + }, + { + name: 'feeAdjustment'; + type: 'i16'; + }, + { + name: 'maxTokenBorrowsFraction'; + docs: [ + 'What fraction of max_token_deposits', + 'disabled when 0, 1 => 1/10000 => .01% of max_token_deposits', + 'precision: X/10000', + ]; + type: 'u16'; + }, + { + name: 'flashLoanAmount'; + docs: [ + 'For swaps, the amount of token loaned out in the begin_swap ix', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'flashLoanInitialTokenAmount'; + docs: [ + 'For swaps, the amount in the users token account in the begin_swap ix', + 'Used to calculate how much of the token left the system in end_swap ix', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'totalSwapFee'; + docs: [ + 'The total fees received from swaps', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'scaleInitialAssetWeightStart'; + docs: [ + 'When to begin scaling down the initial asset weight', + 'disabled when 0', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minBorrowRate'; + docs: [ + 'The min borrow rate for this market when the market regardless of utilization', + '1 => 1/200 => .5%', + 'precision: X/200', + ]; + type: 'u8'; + }, + { + name: 'fuelBoostDeposits'; + docs: ['fuel multiplier for spot deposits', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostBorrows'; + docs: ['fuel multiplier for spot borrows', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostTaker'; + docs: ['fuel multiplier for spot taker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostMaker'; + docs: ['fuel multiplier for spot maker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostInsurance'; + docs: ['fuel multiplier for spot insurance stake', 'precision: 10']; + type: 'u8'; + }, + { + name: 'tokenProgramFlag'; + type: 'u8'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 40]; + }; + }, + ]; + }; + }, + { + name: 'spotMarketVaultDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'depositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestBefore'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestAfter'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'depositTokenAmountBefore'; + type: 'u64'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'spotPosition'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', + 'interest of corresponding market.', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'openBids'; + docs: [ + 'How many spot non reduce only trigger orders the user has open', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'openAsks'; + docs: [ + 'How many spot non reduce only trigger orders the user has open', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'cumulativeDeposits'; + docs: [ + 'The cumulative deposits/borrows a user has made into a market', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'marketIndex'; + docs: ['The market index of the corresponding spot market']; + type: 'u16'; + }, + { + name: 'balanceType'; + docs: ['Whether the position is deposit or borrow']; + type: { + defined: { + name: 'spotBalanceType'; + }; + }; + }, + { + name: 'openOrders'; + docs: ['Number of open orders']; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'stakeAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'stake'; + }, + { + name: 'unstakeRequest'; + }, + { + name: 'unstakeCancelRequest'; + }, + { + name: 'unstake'; + }, + { + name: 'unstakeTransfer'; + }, + { + name: 'stakeTransfer'; + }, + { + name: 'adminDeposit'; + }, + ]; + }; + }, + { + name: 'state'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'admin'; + type: 'pubkey'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + { + name: 'discountMint'; + type: 'pubkey'; + }, + { + name: 'signer'; + type: 'pubkey'; + }, + { + name: 'srmVault'; + type: 'pubkey'; + }, + { + name: 'perpFeeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + { + name: 'spotFeeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + { + name: 'oracleGuardRails'; + type: { + defined: { + name: 'oracleGuardRails'; + }; + }; + }, + { + name: 'numberOfAuthorities'; + type: 'u64'; + }, + { + name: 'numberOfSubAccounts'; + type: 'u64'; + }, + { + name: 'lpCooldownTime'; + type: 'u64'; + }, + { + name: 'liquidationMarginBufferRatio'; + type: 'u32'; + }, + { + name: 'settlementDuration'; + type: 'u16'; + }, + { + name: 'numberOfMarkets'; + type: 'u16'; + }, + { + name: 'numberOfSpotMarkets'; + type: 'u16'; + }, + { + name: 'signerNonce'; + type: 'u8'; + }, + { + name: 'minPerpAuctionDuration'; + type: 'u8'; + }, + { + name: 'defaultMarketOrderTimeInForce'; + type: 'u8'; + }, + { + name: 'defaultSpotAuctionDuration'; + type: 'u8'; + }, + { + name: 'exchangeStatus'; + type: 'u8'; + }, + { + name: 'liquidationDuration'; + type: 'u8'; + }, + { + name: 'initialPctToLiquidate'; + type: 'u16'; + }, + { + name: 'maxNumberOfSubAccounts'; + type: 'u16'; + }, + { + name: 'maxInitializeUserFee'; + type: 'u16'; + }, + { + name: 'featureBitFlags'; + type: 'u8'; + }, + { + name: 'lpPoolFeatureBitFlags'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 8]; + }; + }, + ]; + }; + }, + { + name: 'swapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'amountOut'; + docs: ['precision: out market mint precision']; + type: 'u64'; + }, + { + name: 'amountIn'; + docs: ['precision: in market mint precision']; + type: 'u64'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'inOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'fee'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'swapReduceOnly'; + type: { + kind: 'enum'; + variants: [ + { + name: 'in'; + }, + { + name: 'out'; + }, + ]; + }; + }, + { + name: 'targetsDatum'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'costToTradeBps'; + type: 'i32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'targetBase'; + type: 'i64'; + }, + { + name: 'lastOracleSlot'; + type: 'u64'; + }, + { + name: 'lastPositionSlot'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'transferProtocolIfSharesToRevenuePoolRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'shares'; + type: 'u128'; + }, + { + name: 'ifVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'protocolSharesBefore'; + type: 'u128'; + }, + { + name: 'transferAmount'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'updatePerpMarketSummaryStatsParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'quoteAssetAmountWithUnsettledLp'; + type: { + option: 'i64'; + }; + }, + { + name: 'netUnsettledFundingPnl'; + type: { + option: 'i64'; + }; + }, + { + name: 'updateAmmSummaryStats'; + type: { + option: 'bool'; + }; + }, + { + name: 'excludeTotalLiqFee'; + type: { + option: 'bool'; + }; + }, + ]; + }; + }, + { + name: 'user'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The owner/authority of the account']; + type: 'pubkey'; + }, + { + name: 'delegate'; + docs: [ + "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw", + ]; + type: 'pubkey'; + }, + { + name: 'name'; + docs: ['Encoded display name e.g. "toly"']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'spotPositions'; + docs: ["The user's spot positions"]; + type: { + array: [ + { + defined: { + name: 'spotPosition'; + }; + }, + 8, + ]; + }; + }, + { + name: 'perpPositions'; + docs: ["The user's perp positions"]; + type: { + array: [ + { + defined: { + name: 'perpPosition'; + }; + }, + 8, + ]; + }; + }, + { + name: 'orders'; + docs: ["The user's orders"]; + type: { + array: [ + { + defined: { + name: 'order'; + }; + }, + 32, + ]; + }; + }, + { + name: 'lastAddPerpLpSharesTs'; + docs: ['The last time the user added perp lp positions']; + type: 'i64'; + }, + { + name: 'totalDeposits'; + docs: [ + 'The total values of deposits the user has made', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalWithdraws'; + docs: [ + 'The total values of withdrawals the user has made', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalSocialLoss'; + docs: [ + 'The total socialized loss the users has incurred upon the protocol', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'settledPerpPnl'; + docs: [ + 'Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'cumulativeSpotFees'; + docs: [ + 'Fees (taker fees, maker rebate, filler reward) for spot', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'cumulativePerpFunding'; + docs: [ + 'Cumulative funding paid/received for perps', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'liquidationMarginFreed'; + docs: [ + 'The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time', + 'Defaults to zero when not being liquidated', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastActiveSlot'; + docs: [ + 'The last slot a user was active. Used to determine if a user is idle', + ]; + type: 'u64'; + }, + { + name: 'nextOrderId'; + docs: [ + 'Every user order has an order id. This is the next order id to be used', + ]; + type: 'u32'; + }, + { + name: 'maxMarginRatio'; + docs: ['Custom max initial margin ratio for the user']; + type: 'u32'; + }, + { + name: 'nextLiquidationId'; + docs: ['The next liquidation id to be used for user']; + type: 'u16'; + }, + { + name: 'subAccountId'; + docs: ['The sub account id for this user']; + type: 'u16'; + }, + { + name: 'status'; + docs: ['Whether the user is active, being liquidated or bankrupt']; + type: 'u8'; + }, + { + name: 'isMarginTradingEnabled'; + docs: ['Whether the user has enabled margin trading']; + type: 'bool'; + }, + { + name: 'idle'; + docs: [ + "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", + 'Off-chain keeper bots can ignore users that are idle', + ]; + type: 'bool'; + }, + { + name: 'openOrders'; + docs: ['number of open orders']; + type: 'u8'; + }, + { + name: 'hasOpenOrder'; + docs: ['Whether or not user has open order']; + type: 'bool'; + }, + { + name: 'openAuctions'; + docs: ['number of open orders with auction']; + type: 'u8'; + }, + { + name: 'hasOpenAuction'; + docs: ['Whether or not user has open order with auction']; + type: 'bool'; + }, + { + name: 'marginMode'; + type: { + defined: { + name: 'marginMode'; + }; + }; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'padding1'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'lastFuelBonusUpdateTs'; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 12]; + }; + }, + ]; + }; + }, + { + name: 'userFees'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'totalFeePaid'; + docs: ['Total taker fee paid', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalFeeRebate'; + docs: ['Total maker fee rebate', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalTokenDiscount'; + docs: [ + 'Total discount from holding token', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalRefereeDiscount'; + docs: [ + 'Total discount from being referred', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalReferrerReward'; + docs: ['Total reward to referrer', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'currentEpochReferrerReward'; + docs: [ + 'Total reward to referrer this epoch', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'userStats'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The authority for all of a users sub accounts']; + type: 'pubkey'; + }, + { + name: 'referrer'; + docs: ['The address that referred this user']; + type: 'pubkey'; + }, + { + name: 'fees'; + docs: ['Stats on the fees paid by the user']; + type: { + defined: { + name: 'userFees'; + }; + }; + }, + { + name: 'nextEpochTs'; + docs: [ + 'The timestamp of the next epoch', + 'Epoch is used to limit referrer rewards earned in single epoch', + ]; + type: 'i64'; + }, + { + name: 'makerVolume30d'; + docs: [ + 'Rolling 30day maker volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'takerVolume30d'; + docs: [ + 'Rolling 30day taker volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'fillerVolume30d'; + docs: [ + 'Rolling 30day filler volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMakerVolume30dTs'; + docs: ['last time the maker volume was updated']; + type: 'i64'; + }, + { + name: 'lastTakerVolume30dTs'; + docs: ['last time the taker volume was updated']; + type: 'i64'; + }, + { + name: 'lastFillerVolume30dTs'; + docs: ['last time the filler volume was updated']; + type: 'i64'; + }, + { + name: 'ifStakedQuoteAssetAmount'; + docs: ['The amount of tokens staked in the quote spot markets if']; + type: 'u64'; + }, + { + name: 'numberOfSubAccounts'; + docs: ['The current number of sub accounts']; + type: 'u16'; + }, + { + name: 'numberOfSubAccountsCreated'; + docs: [ + 'The number of sub accounts created. Can be greater than the number of sub accounts if user', + 'has deleted sub accounts', + ]; + type: 'u16'; + }, + { + name: 'referrerStatus'; + docs: [ + 'Flags for referrer status:', + 'First bit (LSB): 1 if user is a referrer, 0 otherwise', + 'Second bit: 1 if user was referred, 0 otherwise', + ]; + type: 'u8'; + }, + { + name: 'disableUpdatePerpBidAskTwap'; + type: 'bool'; + }, + { + name: 'padding1'; + type: { + array: ['u8', 1]; + }; + }, + { + name: 'fuelOverflowStatus'; + docs: ['whether the user has a FuelOverflow account']; + type: 'u8'; + }, + { + name: 'fuelInsurance'; + docs: ['accumulated fuel for token amounts of insurance']; + type: 'u32'; + }, + { + name: 'fuelDeposits'; + docs: ['accumulated fuel for notional of deposits']; + type: 'u32'; + }, + { + name: 'fuelBorrows'; + docs: ['accumulate fuel bonus for notional of borrows']; + type: 'u32'; + }, + { + name: 'fuelPositions'; + docs: ['accumulated fuel for perp open interest']; + type: 'u32'; + }, + { + name: 'fuelTaker'; + docs: ['accumulate fuel bonus for taker volume']; + type: 'u32'; + }, + { + name: 'fuelMaker'; + docs: ['accumulate fuel bonus for maker volume']; + type: 'u32'; + }, + { + name: 'ifStakedGovTokenAmount'; + docs: [ + 'The amount of tokens staked in the governance spot markets if', + ]; + type: 'u64'; + }, + { + name: 'lastFuelIfBonusUpdateTs'; + docs: [ + 'last unix ts user stats data was used to update if fuel (u32 to save space)', + ]; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 12]; + }; + }, + ]; + }; + }, + { + name: 'validityGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'slotsBeforeStaleForAmm'; + type: 'i64'; + }, + { + name: 'slotsBeforeStaleForMargin'; + type: 'i64'; + }, + { + name: 'confidenceIntervalMaxSize'; + type: 'u64'; + }, + { + name: 'tooVolatileRatio'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'i128'; + docs: ['`i128` with legacy bit layout']; + type: { + kind: 'struct'; + fields: [ + { + array: ['u8', 16]; + }, + ]; + }; + }, + { + name: 'u128'; + docs: ['`u128` with legacy bit layout']; + type: { + kind: 'struct'; + fields: [ + { + array: ['u8', 16]; + }, + ]; + }; + }, + ]; +}; diff --git a/sdk/src/marinade/index.ts b/sdk/src/marinade/index.ts index 3818408da3..7d0dac39bf 100644 --- a/sdk/src/marinade/index.ts +++ b/sdk/src/marinade/index.ts @@ -1,4 +1,4 @@ -import { AnchorProvider, BN, Program } from '@coral-xyz/anchor'; +import { AnchorProvider, BN, Program } from '@coral-xyz/anchor-29'; import { MarinadeFinance, IDL } from './types'; import { PublicKey, diff --git a/sdk/src/memcmp.ts b/sdk/src/memcmp.ts index c73d21efdb..d43d517156 100644 --- a/sdk/src/memcmp.ts +++ b/sdk/src/memcmp.ts @@ -1,6 +1,6 @@ import { MemcmpFilter, PublicKey } from '@solana/web3.js'; import bs58 from 'bs58'; -import { BorshAccountsCoder } from '@coral-xyz/anchor'; +import { BorshAccountsCoder } from '@coral-xyz/anchor-29'; import { encodeName } from './userName'; export function getUserFilter(): MemcmpFilter { diff --git a/sdk/src/openbook/openbookV2Subscriber.ts b/sdk/src/openbook/openbookV2Subscriber.ts index 39348252ca..37ea79cf4f 100644 --- a/sdk/src/openbook/openbookV2Subscriber.ts +++ b/sdk/src/openbook/openbookV2Subscriber.ts @@ -1,7 +1,7 @@ import { Connection, Keypair, PublicKey } from '@solana/web3.js'; import { BulkAccountLoader } from '../accounts/bulkAccountLoader'; import { PRICE_PRECISION } from '../constants/numericConstants'; -import { AnchorProvider, BN, Idl, Program, Wallet } from '@coral-xyz/anchor'; +import { AnchorProvider, BN, Idl, Program, Wallet } from '@coral-xyz/anchor-29'; import { L2Level, L2OrderBookGenerator } from '../dlob/orderBookLevels'; import { Market, OpenBookV2Client } from '@openbook-dex/openbook-v2'; import openbookV2Idl from '../idl/openbook.json'; diff --git a/sdk/src/oracles/oracleClientCache.ts b/sdk/src/oracles/oracleClientCache.ts index 96ee3c78b5..472e2beb2a 100644 --- a/sdk/src/oracles/oracleClientCache.ts +++ b/sdk/src/oracles/oracleClientCache.ts @@ -3,6 +3,7 @@ import { OracleSource } from '../types'; import { getOracleClient } from '../factory/oracleClient'; import { Connection } from '@solana/web3.js'; import { Program } from '@coral-xyz/anchor'; +import { Drift } from '../idl/drift'; export class OracleClientCache { cache = new Map(); @@ -11,7 +12,7 @@ export class OracleClientCache { public get( oracleSource: OracleSource, connection: Connection, - program: Program + program: Program ) { const key = Object.keys(oracleSource)[0]; if (this.cache.has(key)) { diff --git a/sdk/src/oracles/prelaunchOracleClient.ts b/sdk/src/oracles/prelaunchOracleClient.ts index e3147e9f82..3a55f9fc7d 100644 --- a/sdk/src/oracles/prelaunchOracleClient.ts +++ b/sdk/src/oracles/prelaunchOracleClient.ts @@ -2,12 +2,13 @@ import { Connection, PublicKey } from '@solana/web3.js'; import { OracleClient, OraclePriceData } from './types'; import { Program } from '@coral-xyz/anchor'; import { PrelaunchOracle } from '../types'; +import { Drift } from '../idl/drift'; export class PrelaunchOracleClient implements OracleClient { private connection: Connection; - private program: Program; + private program: Program; - public constructor(connection: Connection, program: Program) { + public constructor(connection: Connection, program: Program) { this.connection = connection; this.program = program; } diff --git a/sdk/src/oracles/pythLazerClient.ts b/sdk/src/oracles/pythLazerClient.ts index 9e341215db..bbf077092b 100644 --- a/sdk/src/oracles/pythLazerClient.ts +++ b/sdk/src/oracles/pythLazerClient.ts @@ -7,15 +7,15 @@ import { QUOTE_PRECISION, TEN, } from '../constants/numericConstants'; -import { DRIFT_PROGRAM_ID } from '../config'; import { Wallet } from '../wallet'; import driftIDL from '../idl/drift.json'; +import { Drift } from '../idl/drift'; export class PythLazerClient implements OracleClient { private connection: Connection; private multiple: BN; private stableCoin: boolean; - private program: Program; + private program: Program; readonly decodeFunc: (name: string, data: Buffer) => any; public constructor( @@ -34,11 +34,7 @@ export class PythLazerClient implements OracleClient { commitment: connection.commitment, } ); - this.program = new Program( - driftIDL as Idl, - new PublicKey(DRIFT_PROGRAM_ID), - provider - ); + this.program = new Program(driftIDL as Idl, provider); this.decodeFunc = this.program.account.pythLazerOracle.coder.accounts.decodeUnchecked.bind( this.program.account.pythLazerOracle.coder.accounts diff --git a/sdk/src/oracles/pythPullClient.ts b/sdk/src/oracles/pythPullClient.ts index 0359b35928..7ac96ac8b1 100644 --- a/sdk/src/oracles/pythPullClient.ts +++ b/sdk/src/oracles/pythPullClient.ts @@ -1,6 +1,6 @@ import { Connection, Keypair, PublicKey } from '@solana/web3.js'; import { OracleClient, OraclePriceData } from './types'; -import { AnchorProvider, BN, Program } from '@coral-xyz/anchor'; +import { AnchorProvider, BN, Program } from '@coral-xyz/anchor-29'; import { ONE, PRICE_PRECISION, diff --git a/sdk/src/oracles/switchboardClient.ts b/sdk/src/oracles/switchboardClient.ts index 775bc74570..bd3036a3f1 100644 --- a/sdk/src/oracles/switchboardClient.ts +++ b/sdk/src/oracles/switchboardClient.ts @@ -2,7 +2,7 @@ import { Connection, PublicKey } from '@solana/web3.js'; import { PRICE_PRECISION, TEN } from '../constants/numericConstants'; import { OracleClient, OraclePriceData } from './types'; import switchboardV2Idl from '../idl/switchboard.json'; -import { BorshAccountsCoder, BN, Idl } from '@coral-xyz/anchor'; +import { BorshAccountsCoder, BN, Idl } from '@coral-xyz/anchor-29'; type SwitchboardDecimal = { scale: number; diff --git a/sdk/src/oracles/switchboardOnDemandClient.ts b/sdk/src/oracles/switchboardOnDemandClient.ts index aaeb6ac003..ff99740d60 100644 --- a/sdk/src/oracles/switchboardOnDemandClient.ts +++ b/sdk/src/oracles/switchboardOnDemandClient.ts @@ -1,12 +1,12 @@ import { Connection, PublicKey } from '@solana/web3.js'; import { OracleClient, OraclePriceData } from './types'; -import { BN } from '@coral-xyz/anchor'; import switchboardOnDemandIdl from '../idl/switchboard_on_demand_30.json'; import { PRICE_PRECISION_EXP } from '../constants/numericConstants'; import { + BN, BorshAccountsCoder as BorshAccountsCoder30, Idl as Idl30, -} from '@coral-xyz/anchor-30'; +} from '@coral-xyz/anchor'; const SB_PRECISION_EXP = new BN(18); const SB_PRECISION = new BN(10).pow(SB_PRECISION_EXP.sub(PRICE_PRECISION_EXP)); diff --git a/sdk/src/tokenFaucet.ts b/sdk/src/tokenFaucet.ts index f110283143..e8331a71f7 100644 --- a/sdk/src/tokenFaucet.ts +++ b/sdk/src/tokenFaucet.ts @@ -1,5 +1,5 @@ import * as anchor from '@coral-xyz/anchor'; -import { AnchorProvider, Idl, Program } from '@coral-xyz/anchor'; +import { AnchorProvider, Idl, Program } from '@coral-xyz/anchor-29'; import { TOKEN_PROGRAM_ID, Account, diff --git a/sdk/src/types.ts b/sdk/src/types.ts index d86b5af399..f535194b5b 100644 --- a/sdk/src/types.ts +++ b/sdk/src/types.ts @@ -1131,14 +1131,12 @@ export type PerpPosition = { openAsks: BN; settledPnl: BN; lpShares: BN; - /** TODO: remove this field - it doesn't exist on chain */ - remainderBaseAssetAmount: number; + positionFlag: number; maxMarginRatio: number; lastBaseAssetAmountPerLp: BN; lastQuoteAssetAmountPerLp: BN; perLpBase: number; isolatedPositionScaledBalance: BN; - positionFlag: number; }; export class PositionFlag { @@ -1162,7 +1160,7 @@ export type UserStatsAccount = { totalTokenDiscount: BN; totalRefereeDiscount: BN; totalReferrerReward: BN; - current_epoch_referrer_reward: BN; + currentEpochReferrerReward: BN; }; referrer: PublicKey; referrerStatus: number; @@ -1181,6 +1179,77 @@ export type UserStatsAccount = { ifStakedGovTokenAmount: BN; }; +export function parseUserStatsAccount(account: { + makerVolume30d: BN; + takerVolume30d: BN; + fillerVolume30d: BN; + lastMakerVolume30dTs: BN; + lastTakerVolume30dTs: BN; + lastFillerVolume30dTs: BN; + [key: string]: any; +}): UserStatsAccount { + return { + ...account, + makerVolume30D: account.makerVolume30d, + takerVolume30D: account.takerVolume30d, + fillerVolume30D: account.fillerVolume30d, + lastMakerVolume30DTs: account.lastMakerVolume30dTs, + lastTakerVolume30DTs: account.lastTakerVolume30dTs, + lastFillerVolume30DTs: account.lastFillerVolume30dTs, + } as unknown as UserStatsAccount; +} + +/** + * Parses an Anchor-generated AMM account to the SDK's AMM type. + * Handles field name mappings and provides defaults for missing fields. + */ +export function parseAMM(amm: { + last24hAvgFundingRate?: BN; + lastMarkPriceTwap5min?: BN; + volume24h?: BN; + cumulativeFundingRate?: BN; + cumulativeFundingRateLong?: BN; + cumulativeFundingRateShort?: BN; + [key: string]: any; +}): AMM { + return { + ...amm, + last24HAvgFundingRate: + amm.last24HAvgFundingRate ?? amm.last24hAvgFundingRate ?? ZERO, + lastMarkPriceTwap5Min: + amm.lastMarkPriceTwap5Min ?? amm.lastMarkPriceTwap5min ?? ZERO, + volume24H: amm.volume24H ?? amm.volume24h ?? ZERO, + // TODO: map to long/short + cumulativeFundingRate: ZERO, + } as unknown as AMM; +} + +/** + * Parses an Anchor-generated PerpMarket account to the SDK's PerpMarketAccount type. + * Handles field name mappings and provides defaults for missing fields. + */ +export function parsePerpMarketAccount(account: { + amm?: any; + [key: string]: any; +}): PerpMarketAccount { + return { + ...account, + amm: account.amm ? parseAMM(account.amm) : account.amm, + } as unknown as PerpMarketAccount; +} + +/** + * Parses an Anchor-generated SpotMarket account to the SDK's SpotMarketAccount type. + * Handles field name mappings and provides defaults for missing fields. + */ +export function parseSpotMarketAccount(account: { + [key: string]: any; +}): SpotMarketAccount { + return { + ...account, + } as unknown as SpotMarketAccount; +} + export type FuelOverflowAccount = { authority: PublicKey; fuelInsurance: BN; @@ -1800,7 +1869,6 @@ export type LPPoolAccount = { tokenSupply: BN; volatility: BN; constituents: number; - quoteConstituentIndex: number; bump: number; gammaExecution: number; xi: number; diff --git a/sdk/src/user.ts b/sdk/src/user.ts index d2fd16d5a3..3e586e531b 100644 --- a/sdk/src/user.ts +++ b/sdk/src/user.ts @@ -333,7 +333,6 @@ export class User { public getEmptyPosition(marketIndex: number): PerpPosition { return { baseAssetAmount: ZERO, - remainderBaseAssetAmount: 0, lastCumulativeFundingRate: ZERO, marketIndex, quoteAssetAmount: ZERO, diff --git a/sdk/tests/dlob/helpers.ts b/sdk/tests/dlob/helpers.ts index 69ff661bc0..612fbddea0 100644 --- a/sdk/tests/dlob/helpers.ts +++ b/sdk/tests/dlob/helpers.ts @@ -40,7 +40,6 @@ export const mockPerpPosition: PerpPosition = { openAsks: new BN(0), settledPnl: new BN(0), lpShares: new BN(0), - remainderBaseAssetAmount: 0, lastBaseAssetAmountPerLp: new BN(0), lastQuoteAssetAmountPerLp: new BN(0), perLpBase: 0, diff --git a/tests/delistMarket.ts b/tests/delistMarket.ts index 300a4ced63..82c50bd364 100644 --- a/tests/delistMarket.ts +++ b/tests/delistMarket.ts @@ -444,9 +444,6 @@ describe('delist market', () => { .getUserAccount() .perpPositions[0].baseAssetAmount.eq(ZERO) ); - // assert( - // liquidatorDriftClient.getUserAccount().perpPositions[0].remainderBaseAssetAmount != 0 - // ); console.log( 'liquidatorDriftClient perps:', liquidatorDriftClient.getUserAccount().perpPositions[0] @@ -478,10 +475,6 @@ describe('delist market', () => { .getUserAccount() .perpPositions[0].baseAssetAmount.eq(ZERO) ); - assert( - liquidatorDriftClient.getUserAccount().perpPositions[0] - .remainderBaseAssetAmount == 0 - ); assert(market001.numberOfUsersWithBase == 2); assert(market001.numberOfUsers == 3); diff --git a/yarn.lock b/yarn.lock index 2678bc1b59..2f449466ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,18 +2,22 @@ # yarn lockfile v1 -"@babel/runtime@^7.10.5", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.17.2", "@babel/runtime@^7.25.0": +"@babel/runtime@^7.10.5", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.17.2": version "7.27.6" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.27.6.tgz#ec4070a04d76bae8ddbb10770ba55714a417b7c6" integrity sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q== -"@coral-xyz/anchor-30@npm:@coral-xyz/anchor@0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.1.tgz#17f3e9134c28cd0ea83574c6bab4e410bcecec5d" - integrity sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ== +"@babel/runtime@^7.25.0": + version "7.28.4" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.28.4.tgz#a70226016fabe25c5783b2f22d3e1c9bc5ca3326" + integrity sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ== + +"@coral-xyz/anchor-29@npm:@coral-xyz/anchor@0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.29.0.tgz#bd0be95bedfb30a381c3e676e5926124c310ff12" + integrity sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA== dependencies: - "@coral-xyz/anchor-errors" "^0.30.1" - "@coral-xyz/borsh" "^0.30.1" + "@coral-xyz/borsh" "^0.29.0" "@noble/hashes" "^1.3.1" "@solana/web3.js" "^1.68.0" bn.js "^5.1.2" @@ -28,12 +32,31 @@ superstruct "^0.15.4" toml "^3.0.0" -"@coral-xyz/anchor-errors@^0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor-errors/-/anchor-errors-0.30.1.tgz#bdfd3a353131345244546876eb4afc0e125bec30" - integrity sha512-9Mkradf5yS5xiLWrl9WrpjqOrAV+/W2RQHDlbnAZBivoGpOs1ECjoDCkVk4aRG8ZdiFiB8zQEVlxf+8fKkmSfQ== +"@coral-xyz/anchor-31@npm:@coral-xyz/anchor@0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.31.1.tgz#0fdeebf45a3cb2e47e8ebbb815ca98542152962c" + integrity sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA== + dependencies: + "@coral-xyz/anchor-errors" "^0.31.1" + "@coral-xyz/borsh" "^0.31.1" + "@noble/hashes" "^1.3.1" + "@solana/web3.js" "^1.69.0" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + eventemitter3 "^4.0.7" + pako "^2.0.3" + superstruct "^0.15.4" + toml "^3.0.0" + +"@coral-xyz/anchor-errors@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor-errors/-/anchor-errors-0.31.1.tgz#d635cbac2533973ae6bfb5d3ba1de89ce5aece2d" + integrity sha512-NhNEku4F3zzUSBtrYz84FzYWm48+9OvmT1Hhnwr6GnPQry2dsEqH/ti/7ASjjpoFTWRnPXrjAIT1qM6Isop+LQ== -"@coral-xyz/anchor@0.29.0", "@coral-xyz/anchor@^0.29.0": +"@coral-xyz/anchor@^0.29.0": version "0.29.0" resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.29.0.tgz#bd0be95bedfb30a381c3e676e5926124c310ff12" integrity sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA== @@ -53,6 +76,25 @@ superstruct "^0.15.4" toml "^3.0.0" +"@coral-xyz/anchor@npm:@coral-xyz/anchor@0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.31.1.tgz#0fdeebf45a3cb2e47e8ebbb815ca98542152962c" + integrity sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA== + dependencies: + "@coral-xyz/anchor-errors" "^0.31.1" + "@coral-xyz/borsh" "^0.31.1" + "@noble/hashes" "^1.3.1" + "@solana/web3.js" "^1.69.0" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + eventemitter3 "^4.0.7" + pako "^2.0.3" + superstruct "^0.15.4" + toml "^3.0.0" + "@coral-xyz/borsh@^0.28.0": version "0.28.0" resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.28.0.tgz#fa368a2f2475bbf6f828f4657f40a52102e02b6d" @@ -69,10 +111,10 @@ bn.js "^5.1.2" buffer-layout "^1.2.0" -"@coral-xyz/borsh@^0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.30.1.tgz#869d8833abe65685c72e9199b8688477a4f6b0e3" - integrity sha512-aaxswpPrCFKl8vZTbxLssA2RvwX2zmKLlRCIktJOwW+VpVwYtXRtlWiIP+c2pPRKneiTiWCN2GEMSH9j1zTlWQ== +"@coral-xyz/borsh@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.31.1.tgz#5328e1e0921b75d7f4a62dd3f61885a938bc7241" + integrity sha512-9N8AU9F0ubriKfNE3g1WF0/4dtlGXoBN/hd1PvbNBamBNwRgHxH4P+o3Zt7rSEloW1HUs6LfZEchlx9fW7POYw== dependencies: bn.js "^5.1.2" buffer-layout "^1.2.0" @@ -225,13 +267,20 @@ snake-case "^3.0.4" spok "^1.4.3" -"@noble/curves@^1.0.0", "@noble/curves@^1.4.2": +"@noble/curves@^1.0.0": version "1.9.2" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.2.tgz#73388356ce733922396214a933ff7c95afcef911" integrity sha512-HxngEd2XUcg9xi20JkwlLCtYwfoFw4JGkuZpT+WlsPD4gB/cxkvTD8fSsoAnphGZhFdZYKeQIPCuFlWPm1uE0g== dependencies: "@noble/hashes" "1.8.0" +"@noble/curves@^1.4.2": + version "1.9.7" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.7.tgz#79d04b4758a43e4bca2cbdc62e7771352fa6b951" + integrity sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw== + dependencies: + "@noble/hashes" "1.8.0" + "@noble/ed25519@^1.7.0", "@noble/ed25519@^1.7.1": version "1.7.5" resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.5.tgz#94df8bdb9fec9c4644a56007eecb57b0e9fbd0d7" @@ -570,6 +619,17 @@ "@solana/spl-token-metadata" "^0.1.2" buffer "^6.0.3" +"@solana/spl-token@^0.4.14": + version "0.4.14" + resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.4.14.tgz#b86bc8a17f50e9680137b585eca5f5eb9d55c025" + integrity sha512-u09zr96UBpX4U685MnvQsNzlvw9TiY005hk1vJmJr7gMJldoPG1eYU5/wNEyOA5lkMLiR/gOi9SFD4MefOYEsA== + dependencies: + "@solana/buffer-layout" "^4.0.0" + "@solana/buffer-layout-utils" "^0.2.0" + "@solana/spl-token-group" "^0.0.7" + "@solana/spl-token-metadata" "^0.1.6" + buffer "^6.0.3" + "@solana/web3.js@1.73.2": version "1.73.2" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.73.2.tgz#4b30cd402b35733dae3a7d0b638be26a7742b395" @@ -592,7 +652,7 @@ rpc-websockets "^7.5.0" superstruct "^0.14.2" -"@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0", "@solana/web3.js@^1.32.0", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.90.0", "@solana/web3.js@^1.98.0", "@solana/web3.js@^1.98.2": +"@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.90.0": version "1.98.2" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.2.tgz#45167a5cfb64436944bf4dc1e8be8482bd6d4c14" integrity sha512-BqVwEG+TaG2yCkBMbD3C4hdpustR4FpuUFRPUmqRZYYlPI9Hg4XMWxHWOWRzHE9Lkc9NDjzXFX7lDXSgzC7R1A== @@ -613,6 +673,27 @@ rpc-websockets "^9.0.2" superstruct "^2.0.2" +"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.69.0", "@solana/web3.js@^1.98.2", "@solana/web3.js@^1.98.4": + version "1.98.4" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.4.tgz#df51d78be9d865181ec5138b4e699d48e6895bbe" + integrity sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw== + dependencies: + "@babel/runtime" "^7.25.0" + "@noble/curves" "^1.4.2" + "@noble/hashes" "^1.4.0" + "@solana/buffer-layout" "^4.0.1" + "@solana/codecs-numbers" "^2.1.0" + agentkeepalive "^4.5.0" + bn.js "^5.2.1" + borsh "^0.7.0" + bs58 "^4.0.1" + buffer "6.0.3" + fast-stable-stringify "^1.0.0" + jayson "^4.1.1" + node-fetch "^2.7.0" + rpc-websockets "^9.0.2" + superstruct "^2.0.2" + "@solana/web3.js@~1.77.3": version "1.77.4" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.77.4.tgz#aad8c44a02ced319493308ef765a2b36a9e9fa8c" @@ -641,26 +722,10 @@ dependencies: tslib "^2.8.0" -"@switchboard-xyz/common@3.0.14": - version "3.0.14" - resolved "https://registry.yarnpkg.com/@switchboard-xyz/common/-/common-3.0.14.tgz#5b363995bd0fefa22198286992dbe54f3e544b08" - integrity sha512-LpxzEywO0DjPYIgPzQYkf32C7agwW4YRsPN6BcIvYrw0iJdDMtPZ3SQfIGHLSlD1fwvn2KLUYuGaKegeq4aBTw== - dependencies: - "@solana/web3.js" "^1.98.0" - axios "^1.8.3" - big.js "^6.2.2" - bn.js "^5.2.1" - bs58 "^6.0.0" - buffer "^6.0.3" - decimal.js "^10.4.3" - js-sha256 "^0.11.0" - protobufjs "^7.4.0" - yaml "^2.6.1" - -"@switchboard-xyz/common@>=3.0.0": - version "3.4.1" - resolved "https://registry.yarnpkg.com/@switchboard-xyz/common/-/common-3.4.1.tgz#3144c0730649e60129ea8c9b3c04062ceff35c6e" - integrity sha512-TropBlBYuDeBnmGHkPSmgC3clLqAxy51ZGbwk4ejAgadnszWOgYHcH7taRG4Ha17DYSCWw/LGMBKbunGo+Aoaw== +"@switchboard-xyz/common@5.5.0", "@switchboard-xyz/common@^5.2.9": + version "5.5.0" + resolved "https://registry.yarnpkg.com/@switchboard-xyz/common/-/common-5.5.0.tgz#b064eb911909cae2b2b732ec9fb8b5c073316eeb" + integrity sha512-Wvs9KJw+YSe8O2IOsMUvPE8aQHb0t2vi/9hEQC7Pc6279s7tTTI8eVgT/0Jb2z897OHgIZTD3oGQ8IEBqIgV0w== dependencies: "@solana/web3.js" "^1.98.2" axios "^1.9.0" @@ -671,21 +736,25 @@ decimal.js "^10.4.3" js-sha256 "^0.11.0" protobufjs "^7.4.0" - yaml "^2.6.1" - zod "4.0.0-beta.20250505T195954" -"@switchboard-xyz/on-demand@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@switchboard-xyz/on-demand/-/on-demand-2.4.1.tgz#3db64b0596d9daa0b010ee44193d5512e0ba512d" - integrity sha512-eSlBp+c8lxpcSgh0/2xK8OaLHPziTSZlcs8V96gZGdiCJz1KgWJRNE1qnIJDOwaGdFecZdwcmajfQRtLRLED3w== +"@switchboard-xyz/on-demand@3.7.3": + version "3.7.3" + resolved "https://registry.yarnpkg.com/@switchboard-xyz/on-demand/-/on-demand-3.7.3.tgz#07e4df25e145e86e5c5dab496704056bda07c2bc" + integrity sha512-sG9errSwjYlQbIlQl0iptUQcbKrPe7QVxX20+qXuucG3qIWlA/w6sXGnITeYbt+BERyBYdfue0viBjmjOsCZrg== dependencies: - "@coral-xyz/anchor-30" "npm:@coral-xyz/anchor@0.30.1" + "@coral-xyz/anchor-31" "npm:@coral-xyz/anchor@0.31.1" "@isaacs/ttlcache" "^1.4.1" - "@switchboard-xyz/common" ">=3.0.0" - axios "^1.8.3" + "@solana/spl-token" "^0.4.14" + "@solana/web3.js" "^1.98.4" + "@switchboard-xyz/common" "^5.2.9" + axios "^1.9" bs58 "^6.0.0" buffer "^6.0.3" + events "^3.3.0" + isomorphic-ws "^5.0.0" js-yaml "^4.1.0" + tweetnacl "^1.0.3" + ws "^8.18.1" "@types/bn.js@5.1.6": version "5.1.6" @@ -717,11 +786,11 @@ integrity sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw== "@types/node@*", "@types/node@>=13.7.0": - version "24.0.13" - resolved "https://registry.yarnpkg.com/@types/node/-/node-24.0.13.tgz#93ed8c05c7b188a59760be0ce2ee3fa7ad0f83f6" - integrity sha512-Qm9OYVOFHFYg3wJoTSrz80hoec5Lia/dPp84do3X7dZvLikQvM1YpmvTBEdIr/e+U8HTkFjLHLnl78K/qjf+jQ== + version "24.10.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-24.10.1.tgz#91e92182c93db8bd6224fca031e2370cef9a8f01" + integrity sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ== dependencies: - undici-types "~7.8.0" + undici-types "~7.16.0" "@types/node@^12.12.54": version "12.20.55" @@ -850,11 +919,6 @@ resolved "https://registry.yarnpkg.com/@ungap/structured-clone/-/structured-clone-1.3.0.tgz#d06bbb384ebcf6c505fde1c3d0ed4ddffe0aaff8" integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g== -"@zod/core@0.11.6": - version "0.11.6" - resolved "https://registry.yarnpkg.com/@zod/core/-/core-0.11.6.tgz#9216e98848dc9364eda35e3da90f5362f10e8887" - integrity sha512-03Bv82fFSfjDAvMfdHHdGSS6SOJs0iCcJlWJv1kJHRtoTT02hZpyip/2Lk6oo4l4FtjuwTrsEQTwg/LD8I7dJA== - JSONStream@^1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -963,7 +1027,7 @@ axios-retry@^3.8.0: "@babel/runtime" "^7.15.4" is-retry-allowed "^2.2.0" -axios@^1.5.1, axios@^1.8.3, axios@^1.9.0: +axios@^1.5.1: version "1.10.0" resolved "https://registry.yarnpkg.com/axios/-/axios-1.10.0.tgz#af320aee8632eaf2a400b6a1979fa75856f38d54" integrity sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw== @@ -972,6 +1036,15 @@ axios@^1.5.1, axios@^1.8.3, axios@^1.9.0: form-data "^4.0.0" proxy-from-env "^1.1.0" +axios@^1.9, axios@^1.9.0: + version "1.13.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.13.2.tgz#9ada120b7b5ab24509553ec3e40123521117f687" + integrity sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA== + dependencies: + follow-redirects "^1.15.6" + form-data "^4.0.4" + proxy-from-env "^1.1.0" + backslash@<0.2.1: version "0.2.0" resolved "https://registry.yarnpkg.com/backslash/-/backslash-0.2.0.tgz#6c3c1fce7e7e714ccfc10fd74f0f73410677375f" @@ -1017,9 +1090,9 @@ bigint-buffer@^1.1.5: bindings "^1.3.0" bignumber.js@^9.0.1: - version "9.3.0" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.3.0.tgz#bdba7e2a4c1a2eba08290e8dcad4f36393c92acd" - integrity sha512-EM7aMFTXbptt/wZdMlBv2t8IViwQL+h6SLHosp8Yf0dqJMTnY6iL32opnAB6kAdL0SZPuvcAzFr31o0c/R3/RA== + version "9.3.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.3.1.tgz#759c5aaddf2ffdc4f154f7b493e1c8770f88c4d7" + integrity sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ== bindings@^1.3.0: version "1.5.0" @@ -1240,9 +1313,9 @@ commander@^12.1.0: integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== commander@^14.0.0: - version "14.0.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.0.tgz#f244fc74a92343514e56229f16ef5c5e22ced5e9" - integrity sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA== + version "14.0.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.2.tgz#b71fd37fe4069e4c3c7c13925252ada4eba14e8e" + integrity sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ== commander@^2.20.3: version "2.20.3" @@ -1560,6 +1633,11 @@ eventemitter3@^5.0.1: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== +events@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + eyes@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" @@ -1666,9 +1744,9 @@ flatted@^3.2.9: integrity sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg== follow-redirects@^1.15.6: - version "1.15.9" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" - integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== + version "1.15.11" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.11.tgz#777d73d72a92f8ec4d2e410eb47352a56b8e8340" + integrity sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ== for-each@^0.3.5: version "0.3.5" @@ -1677,10 +1755,10 @@ for-each@^0.3.5: dependencies: is-callable "^1.2.7" -form-data@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.3.tgz#608b1b3f3e28be0fccf5901fc85fb3641e5cf0ae" - integrity sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA== +form-data@^4.0.0, form-data@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.5.tgz#b49e48858045ff4cbf6b03e1805cebcad3679053" + integrity sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w== dependencies: asynckit "^0.4.0" combined-stream "^1.0.8" @@ -1978,6 +2056,11 @@ isomorphic-ws@^4.0.1: resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== +isomorphic-ws@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz#e5529148912ecb9b451b46ed44d53dae1ce04bbf" + integrity sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw== + jayson@^3.4.4: version "3.7.0" resolved "https://registry.yarnpkg.com/jayson/-/jayson-3.7.0.tgz#b735b12d06d348639ae8230d7a1e2916cb078f25" @@ -2040,9 +2123,9 @@ js-sha256@^0.9.0: integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== js-yaml@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" - integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + version "4.1.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.1.tgz#854c292467705b699476e1a2decc0c8a3458806b" + integrity sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA== dependencies: argparse "^2.0.1" @@ -2379,7 +2462,7 @@ prettier@^2.5.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== -protobufjs@^7.2.5, protobufjs@^7.4.0: +protobufjs@^7.2.5: version "7.5.3" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.5.3.tgz#13f95a9e3c84669995ec3652db2ac2fb00b89363" integrity sha512-sildjKwVqOI2kmFDiXQ6aEB0fjYTafpEvIBs8tOR8qI4spuL9OPROLVu2qZqi/xgCfsHIwVqlaF8JBjWFHnKbw== @@ -2397,6 +2480,24 @@ protobufjs@^7.2.5, protobufjs@^7.4.0: "@types/node" ">=13.7.0" long "^5.0.0" +protobufjs@^7.4.0: + version "7.5.4" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.5.4.tgz#885d31fe9c4b37f25d1bb600da30b1c5b37d286a" + integrity sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/node" ">=13.7.0" + long "^5.0.0" + proxy-from-env@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" @@ -2460,9 +2561,9 @@ rpc-websockets@^7.5.0, rpc-websockets@^7.5.1: utf-8-validate "^5.0.2" rpc-websockets@^9.0.2: - version "9.1.1" - resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.1.1.tgz#5764336f3623ee1c5cc8653b7335183e3c0c78bd" - integrity sha512-1IXGM/TfPT6nfYMIXkJdzn+L4JEsmb0FL1O2OBjaH03V3yuUDdKFulGLMFG6ErV+8pZ5HVC0limve01RyO+saA== + version "9.3.2" + resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-9.3.2.tgz#26b4d7ebaf8e53422528619a3c314e83590d85bf" + integrity sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA== dependencies: "@swc/helpers" "^0.5.11" "@types/uuid" "^8.3.4" @@ -2750,6 +2851,11 @@ tslib@^2.0.3, tslib@^2.8.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== +tweetnacl@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" + integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" @@ -2787,10 +2893,10 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici-types@~7.8.0: - version "7.8.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.8.0.tgz#de00b85b710c54122e44fbfd911f8d70174cd294" - integrity sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw== +undici-types@~7.16.0: + version "7.16.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.16.0.tgz#ffccdff36aea4884cbfce9a750a0580224f58a46" + integrity sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw== uri-js@^4.2.2: version "4.4.1" @@ -2889,7 +2995,7 @@ ws@^7.4.5, ws@^7.5.10: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== -ws@^8.5.0, ws@^8.6.0: +ws@^8.18.1, ws@^8.5.0, ws@^8.6.0: version "8.18.3" resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472" integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg== @@ -2899,11 +3005,6 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yaml@^2.6.1: - version "2.8.0" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.8.0.tgz#15f8c9866211bdc2d3781a0890e44d4fa1a5fff6" - integrity sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ== - yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" @@ -2927,13 +3028,6 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== -zod@4.0.0-beta.20250505T195954: - version "4.0.0-beta.20250505T195954" - resolved "https://registry.yarnpkg.com/zod/-/zod-4.0.0-beta.20250505T195954.tgz#ba9da025671de2dde9d4d033089f03c37a35022f" - integrity sha512-iB8WvxkobVIXMARvQu20fKvbS7mUTiYRpcD8OQV1xjRhxO0EEpYIRJBk6yfBzHAHEdOSDh3SxDITr5Eajr2vtg== - dependencies: - "@zod/core" "0.11.6" - zod@4.0.17: version "4.0.17" resolved "https://registry.yarnpkg.com/zod/-/zod-4.0.17.tgz#95931170715f73f7426c385c237b7477750d6c8d" From 33a9c8e07a62a28a11f6c3434fa151d12ac139ea Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 8 Dec 2025 13:39:10 +0800 Subject: [PATCH 18/25] update idl build commands --- package.json | 2 +- sdk/src/idl/drift.json | 13331 ++--- sdk/src/idl/drift.ts | 45518 ++++++++-------- .../run-anchor-local-validator-tests.sh | 1 + test-scripts/run-anchor-tests.sh | 1 + test-scripts/single-anchor-test.sh | 1 + 6 files changed, 28827 insertions(+), 30027 deletions(-) diff --git a/package.json b/package.json index 096b64278b..146e55ada6 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "prettify:fix": "prettier --write './sdk/src/**/*.ts' './tests/**.ts' './cli/**.ts'", "lint": "eslint . --ext ts --quiet --format unix", "lint:fix": "eslint . --ext ts --fix", - "update-idl": "anchor build -- --features anchor-test && cp target/idl/drift.json sdk/src/idl/drift.json" + "update-idl": "anchor build -- --features anchor-test && cp target/idl/drift.json sdk/src/idl/drift.json && cp target/types/drift.ts sdk/src/idl/drift.ts" }, "engines": { "node": ">=12" diff --git a/sdk/src/idl/drift.json b/sdk/src/idl/drift.json index 1220d11cb0..41ed94abba 100644 --- a/sdk/src/idl/drift.json +++ b/sdk/src/idl/drift.json @@ -2,7 +2,7 @@ "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH", "metadata": { "name": "drift", - "version": "2.150.0", + "version": "2.151.0", "spec": "0.1.0", "description": "Created with Anchor" }, @@ -283,762 +283,505 @@ 87, 237 ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - }, - { - "name": "reduceOnly", - "type": { - "option": { - "defined": "SwapReduceOnly" - } - } - } - ] - }, - { - "name": "updateUserName", "accounts": [ { - "name": "user", - "isMut": true, - "isSigner": false + "name": "admin", + "writable": true, + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "state" }, { - "name": "name", - "type": { - "array": [ - "u8", - 32 + "name": "amm_cache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } ] } - } - ] - }, - { - "name": "updateUserCustomMarginRatio", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "perp_market" }, { - "name": "marginRatio", - "type": "u32" - } - ] - }, - { - "name": "updateUserPerpPositionCustomMarginRatio", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "system_program", + "address": "11111111111111111111111111111111" } ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "marginRatio", - "type": "u16" - } - ] + "args": [] }, { - "name": "updateUserMarginTradingEnabled", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - } + "name": "admin_deposit", + "discriminator": [ + 210, + 66, + 65, + 182, + 102, + 214, + 176, + 30 ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "marginTradingEnabled", - "type": "bool" - } - ] - }, - { - "name": "updateUserPoolId", "accounts": [ { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "state" }, - { - "name": "poolId", - "type": "u8" - } - ] - }, - { - "name": "updateUserDelegate", - "accounts": [ { "name": "user", - "isMut": true, - "isSigner": false + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "admin", + "writable": true, + "signer": true }, { - "name": "delegate", - "type": "publicKey" - } - ] - }, - { - "name": "updateUserReduceOnly", - "accounts": [ + "name": "spot_market_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "market_index" + } + ] + } + }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "admin_token_account", + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "token_program" } ], "args": [ { - "name": "subAccountId", + "name": "market_index", "type": "u16" }, { - "name": "reduceOnly", - "type": "bool" + "name": "amount", + "type": "u64" } ] }, { - "name": "updateUserProtectedMakerOrders", + "name": "admin_update_user_stats_paused_operations", + "discriminator": [ + 183, + 104, + 63, + 150, + 240, + 199, + 3, + 10 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "admin", + "signer": true }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "state" }, { - "name": "protectedMakerModeConfig", - "isMut": true, - "isSigner": false + "name": "user_stats", + "writable": true } ], "args": [ { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "protectedMakerOrders", - "type": "bool" + "name": "paused_operations", + "type": "u8" } ] }, { - "name": "deleteUser", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false - }, - { - "name": "state", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": true, - "isSigner": true - } + "name": "begin_insurance_fund_swap", + "discriminator": [ + 176, + 69, + 143, + 205, + 32, + 132, + 163, + 0 ], - "args": [] - }, - { - "name": "forceDeleteUser", "accounts": [ { - "name": "user", - "isMut": true, - "isSigner": false + "name": "state" }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "authority", + "writable": true, + "signer": true }, { - "name": "state", - "isMut": true, - "isSigner": false - }, - { - "name": "authority", - "isMut": true, - "isSigner": false - }, - { - "name": "keeper", - "isMut": true, - "isSigner": true + "name": "out_insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] + } }, { - "name": "driftSigner", - "isMut": false, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "deleteSignedMsgUserOrders", - "accounts": [ - { - "name": "signedMsgUserOrders", - "isMut": true, - "isSigner": false + "name": "in_insurance_fund_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] + } }, { - "name": "state", - "isMut": true, - "isSigner": false + "name": "out_token_account", + "writable": true }, { - "name": "authority", - "isMut": false, - "isSigner": true - } - ], - "args": [] - }, - { - "name": "reclaimRent", - "accounts": [ - { - "name": "user", - "isMut": true, - "isSigner": false + "name": "in_token_account", + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false + "name": "if_rebalance_config", + "writable": true }, { - "name": "state", - "isMut": false, - "isSigner": false + "name": "token_program" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "drift_signer" }, { - "name": "rent", - "isMut": false, - "isSigner": false + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" } ], - "args": [] - }, - { - "name": "enableUserHighLeverageMode", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, + "args": [ { - "name": "user", - "isMut": true, - "isSigner": false + "name": "in_market_index", + "type": "u16" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "out_market_index", + "type": "u16" }, { - "name": "highLeverageModeConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" + "name": "amount_in", + "type": "u64" } ] }, { - "name": "fillPerpOrder", + "name": "begin_lp_swap", + "discriminator": [ + 64, + 44, + 24, + 199, + 48, + 125, + 67, + 91 + ], "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false + "name": "state" }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "admin", + "writable": true, + "signer": true }, { - "name": "filler", - "isMut": true, - "isSigner": false + "name": "signer_out_token_account", + "docs": [ + "Signer token accounts" + ], + "writable": true }, { - "name": "fillerStats", - "isMut": true, - "isSigner": false + "name": "signer_in_token_account", + "writable": true }, { - "name": "user", - "isMut": true, - "isSigner": false + "name": "constituent_out_token_account", + "docs": [ + "Constituent token accounts" + ], + "writable": true }, { - "name": "userStats", - "isMut": true, - "isSigner": false - } - ], - "args": [ + "name": "constituent_in_token_account", + "writable": true + }, { - "name": "orderId", - "type": { - "option": "u32" + "name": "out_constituent", + "docs": [ + "Constituents" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "out_market_index" + } + ] } }, { - "name": "makerOrderId", - "type": { - "option": "u32" + "name": "in_constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lp_pool" + }, + { + "kind": "arg", + "path": "in_market_index" + } + ] } - } - ] - }, - { - "name": "revertFill", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false }, { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "lp_pool" }, { - "name": "filler", - "isMut": true, - "isSigner": false + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" }, { - "name": "fillerStats", - "isMut": true, - "isSigner": false + "name": "token_program" } ], - "args": [] - }, - { - "name": "fillSpotOrder", - "accounts": [ + "args": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "filler", - "isMut": true, - "isSigner": false - }, - { - "name": "fillerStats", - "isMut": true, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": "SpotFulfillmentType" - } - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "triggerOrder", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "in_market_index", + "type": "u16" }, { - "name": "filler", - "isMut": true, - "isSigner": false + "name": "out_market_index", + "type": "u16" }, { - "name": "user", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "orderId", - "type": "u32" + "name": "amount_in", + "type": "u64" } ] }, { - "name": "forceCancelOrders", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "filler", - "isMut": true, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "updateUserIdle", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "filler", - "isMut": true, - "isSigner": false - }, - { - "name": "user", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "logUserBalances", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "user", - "isMut": true, - "isSigner": false - } + "name": "begin_swap", + "discriminator": [ + 174, + 109, + 228, + 1, + 242, + 105, + 232, + 105 ], - "args": [] - }, - { - "name": "disableUserHighLeverageMode", "accounts": [ { - "name": "state", - "isMut": false, - "isSigner": false - }, - { - "name": "authority", - "isMut": false, - "isSigner": true + "name": "state" }, { "name": "user", - "isMut": true, - "isSigner": false + "writable": true }, { - "name": "highLeverageModeConfig", - "isMut": true, - "isSigner": false - } - ], - "args": [ - { - "name": "disableMaintenance", - "type": "bool" - } - ] - }, - { - "name": "updateUserStatsReferrerStatus", - "accounts": [ - { - "name": "state", - "isMut": false, - "isSigner": false + "name": "user_stats", + "writable": true }, { "name": "authority", - "isMut": false, - "isSigner": true - }, - { - "name": "userStats", - "isMut": true, - "isSigner": false - } - ], - "args": [] - }, - { - "name": "adminUpdateUserStatsPausedOperations", - "accounts": [ - { - "name": "admin", - "writable": true, "signer": true }, { - "name": "state" - }, - { - "name": "amm_cache", + "name": "out_spot_market_vault", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 97, - 109, - 109, + 115, + 112, + 111, + 116, 95, - 99, + 109, 97, - 99, - 104, + 114, + 107, 101, + 116, 95, - 115, - 101, - 101, - 100 + 118, + 97, + 117, + 108, + 116 ] + }, + { + "kind": "arg", + "path": "out_market_index" } ] } }, { - "name": "perp_market" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "admin_deposit", - "discriminator": [ - 210, - 66, - 65, - 182, - 102, - 214, - 176, - 30 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "spot_market_vault", + "name": "in_spot_market_vault", "writable": true, "pda": { "seeds": [ @@ -1066,122 +809,261 @@ }, { "kind": "arg", - "path": "market_index" + "path": "in_market_index" } ] } }, { - "name": "admin_token_account", + "name": "out_token_account", + "writable": true + }, + { + "name": "in_token_account", "writable": true }, { "name": "token_program" + }, + { + "name": "drift_signer" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" } ], "args": [ { - "name": "market_index", + "name": "in_market_index", "type": "u16" }, { - "name": "amount", + "name": "out_market_index", + "type": "u16" + }, + { + "name": "amount_in", "type": "u64" } ] }, { - "name": "admin_disable_update_perp_bid_ask_twap", + "name": "cancel_order", "discriminator": [ - 17, - 164, - 82, - 45, - 183, - 86, - 191, - 199 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { + 95, + 129, + 237, + 240, + 8, + 49, + 223, + 132 + ], + "accounts": [ + { "name": "state" }, { - "name": "user_stats", + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "order_id", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "cancel_order_by_user_id", + "discriminator": [ + 107, + 211, + 250, + 133, + 18, + 37, + 57, + 100 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", "writable": true + }, + { + "name": "authority", + "signer": true } ], "args": [ { - "name": "pausedOperations", + "name": "user_order_id", "type": "u8" } ] }, { - "name": "begin_insurance_fund_swap", + "name": "cancel_orders", "discriminator": [ - 176, - 69, - 143, - 205, - 32, - 132, - 163, - 0 + 238, + 225, + 95, + 158, + 227, + 103, + 8, + 194 ], "accounts": [ { "name": "state" }, + { + "name": "user", + "writable": true + }, { "name": "authority", - "writable": true, "signer": true + } + ], + "args": [ + { + "name": "market_type", + "type": { + "option": { + "defined": { + "name": "MarketType" + } + } + } }, { - "name": "out_insurance_fund_vault", + "name": "market_index", + "type": { + "option": "u16" + } + }, + { + "name": "direction", + "type": { + "option": { + "defined": { + "name": "PositionDirection" + } + } + } + } + ] + }, + { + "name": "cancel_orders_by_ids", + "discriminator": [ + 134, + 19, + 144, + 165, + 94, + 240, + 210, + 94 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "order_ids", + "type": { + "vec": "u32" + } + } + ] + }, + { + "name": "cancel_request_remove_insurance_fund_stake", + "discriminator": [ + 97, + 235, + 78, + 62, + 212, + 42, + 241, + 127 + ], + "accounts": [ + { + "name": "spot_market", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 105, - 110, 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, + 112, + 111, + 116, 95, - 118, + 109, 97, - 117, - 108, + 114, + 107, + 101, 116 ] }, { "kind": "arg", - "path": "out_market_index" + "path": "market_index" } ] } }, { - "name": "in_insurance_fund_vault", + "name": "insurance_fund_stake", + "writable": true + }, + { + "name": "user_stats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insurance_fund_stake", + "user_stats" + ] + }, + { + "name": "insurance_fund_vault", "writable": true, "pda": { "seeds": [ @@ -1212,493 +1094,274 @@ }, { "kind": "arg", - "path": "in_market_index" + "path": "market_index" } ] } - }, - { - "name": "out_token_account", - "writable": true - }, - { - "name": "in_token_account", - "writable": true - }, - { - "name": "if_rebalance_config", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "drift_signer" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" } ], "args": [ { - "name": "in_market_index", - "type": "u16" - }, - { - "name": "out_market_index", + "name": "market_index", "type": "u16" - }, - { - "name": "amount_in", - "type": "u64" } ] }, { - "name": "begin_lp_swap", + "name": "change_approved_builder", "discriminator": [ - 64, - 44, - 24, - 199, - 48, - 125, - 67, - 91 + 179, + 134, + 211, + 45, + 195, + 5, + 189, + 173 ], "accounts": [ { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "signer_out_token_account", - "docs": [ - "Signer token accounts" - ], - "writable": true - }, - { - "name": "signer_in_token_account", - "writable": true - }, - { - "name": "constituent_out_token_account", - "docs": [ - "Constituent token accounts" - ], - "writable": true - }, - { - "name": "constituent_in_token_account", - "writable": true - }, - { - "name": "out_constituent", - "docs": [ - "Constituents" - ], + "name": "escrow", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ + 82, + 69, + 86, + 95, + 69, + 83, 67, + 82, 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 + 87 ] }, { "kind": "account", - "path": "lp_pool" - }, - { - "kind": "arg", - "path": "out_market_index" + "path": "authority" } ] } }, { - "name": "in_constituent", + "name": "authority", + "signer": true, + "relations": [ + "escrow" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "builder", + "type": "pubkey" + }, + { + "name": "max_fee_bps", + "type": "u16" + }, + { + "name": "add", + "type": "bool" + } + ] + }, + { + "name": "change_signed_msg_ws_delegate_status", + "discriminator": [ + 252, + 202, + 252, + 219, + 179, + 27, + 84, + 138 + ], + "accounts": [ + { + "name": "signed_msg_ws_delegates", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 67, - 79, - 78, 83, - 84, 73, - 84, - 85, - 69, + 71, 78, - 84 + 69, + 68, + 95, + 77, + 83, + 71, + 95, + 87, + 83 ] }, { "kind": "account", - "path": "lp_pool" - }, - { - "kind": "arg", - "path": "in_market_index" + "path": "authority" } ] } }, { - "name": "lp_pool" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" + "name": "authority", + "writable": true, + "signer": true }, { - "name": "token_program" + "name": "system_program", + "address": "11111111111111111111111111111111" } ], "args": [ { - "name": "in_market_index", - "type": "u16" - }, - { - "name": "out_market_index", - "type": "u16" + "name": "delegate", + "type": "pubkey" }, { - "name": "amount_in", - "type": "u64" + "name": "add", + "type": "bool" } ] }, { - "name": "begin_swap", + "name": "delete_amm_cache", "discriminator": [ - 174, - 109, - 228, - 1, - 242, - 105, + 216, + 130, + 215, + 206, + 233, 232, - 105 + 191, + 88 ], "accounts": [ { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "user_stats", - "writable": true + "name": "admin", + "writable": true, + "signer": true }, { - "name": "authority", - "signer": true + "name": "state" }, { - "name": "out_spot_market_vault", + "name": "amm_cache", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 115, - 112, - 111, - 116, - 95, + 97, 109, + 109, + 95, + 99, 97, - 114, - 107, + 99, + 104, 101, - 116, 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "out_market_index" - } - ] - } - }, - { - "name": "in_spot_market_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 + 101, + 100 ] - }, - { - "kind": "arg", - "path": "in_market_index" } ] } - }, - { - "name": "out_token_account", - "writable": true - }, - { - "name": "in_token_account", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "drift_signer" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" } ], - "args": [ - { - "name": "in_market_index", - "type": "u16" - }, - { - "name": "out_market_index", - "type": "u16" - }, - { - "name": "amount_in", - "type": "u64" - } - ] + "args": [] }, { - "name": "cancel_order", + "name": "delete_initialized_perp_market", "discriminator": [ - 95, - 129, - 237, - 240, - 8, - 49, - 223, - 132 + 91, + 154, + 24, + 87, + 106, + 59, + 190, + 66 ], "accounts": [ { - "name": "state" + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "user", + "name": "state", "writable": true }, { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "order_id", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "cancel_order_by_user_id", - "discriminator": [ - 107, - 211, - 250, - 133, - 18, - 37, - 57, - 100 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", + "name": "perp_market", "writable": true - }, - { - "name": "authority", - "signer": true } ], "args": [ { - "name": "user_order_id", - "type": "u8" + "name": "market_index", + "type": "u16" } ] }, { - "name": "cancel_orders", + "name": "delete_initialized_spot_market", "discriminator": [ - 238, - 225, - 95, - 158, - 227, - 103, - 8, - 194 + 31, + 140, + 67, + 191, + 189, + 20, + 101, + 221 ], "accounts": [ { - "name": "state" + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] }, { - "name": "user", + "name": "state", "writable": true }, { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "market_type", - "type": { - "option": { - "defined": { - "name": "MarketType" - } - } - } - }, - { - "name": "market_index", - "type": { - "option": "u16" - } - }, - { - "name": "direction", - "type": { - "option": { - "defined": { - "name": "PositionDirection" - } - } - } - } - ] - }, - { - "name": "cancel_orders_by_ids", - "discriminator": [ - 134, - 19, - 144, - 165, - 94, - 240, - 210, - 94 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", + "name": "spot_market", "writable": true }, { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "order_ids", - "type": { - "vec": "u32" - } - } - ] - }, - { - "name": "cancel_request_remove_insurance_fund_stake", - "discriminator": [ - 97, - 235, - 78, - 62, - 212, - 42, - 241, - 127 - ], - "accounts": [ - { - "name": "spot_market", + "name": "spot_market_vault", "writable": true, "pda": { "seeds": [ @@ -1715,6 +1378,12 @@ 114, 107, 101, + 116, + 95, + 118, + 97, + 117, + 108, 116 ] }, @@ -1725,22 +1394,6 @@ ] } }, - { - "name": "insurance_fund_stake", - "writable": true - }, - { - "name": "user_stats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insurance_fund_stake", - "user_stats" - ] - }, { "name": "insurance_fund_vault", "writable": true, @@ -1777,6 +1430,12 @@ } ] } + }, + { + "name": "drift_signer" + }, + { + "name": "token_program" } ], "args": [ @@ -1787,92 +1446,88 @@ ] }, { - "name": "change_approved_builder", + "name": "delete_prelaunch_oracle", "discriminator": [ - 179, - 134, - 211, - 45, - 195, - 5, - 189, - 173 + 59, + 169, + 100, + 49, + 69, + 17, + 173, + 253 ], "accounts": [ { - "name": "escrow", + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "prelaunch_oracle", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 82, - 69, - 86, - 95, - 69, - 83, - 67, - 82, - 79, - 87 + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 ] }, { - "kind": "account", - "path": "authority" + "kind": "arg", + "path": "perp_market_index" } ] } }, { - "name": "authority", - "signer": true, - "relations": [ - "escrow" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true + "name": "perp_market" }, { - "name": "system_program", - "address": "11111111111111111111111111111111" + "name": "state" } ], "args": [ { - "name": "builder", - "type": "pubkey" - }, - { - "name": "max_fee_bps", + "name": "perp_market_index", "type": "u16" - }, - { - "name": "add", - "type": "bool" } ] }, { - "name": "change_signed_msg_ws_delegate_status", + "name": "delete_signed_msg_user_orders", "discriminator": [ - 252, - 202, - 252, - 219, - 179, - 27, - 84, - 138 + 221, + 247, + 128, + 253, + 212, + 254, + 46, + 153 ], "accounts": [ { - "name": "signed_msg_ws_delegates", + "name": "signed_msg_user_orders", "writable": true, "pda": { "seeds": [ @@ -1888,10 +1543,7 @@ 95, 77, 83, - 71, - 95, - 87, - 83 + 71 ] }, { @@ -1902,134 +1554,154 @@ } }, { - "name": "authority", - "writable": true, - "signer": true + "name": "state", + "writable": true }, { - "name": "system_program", - "address": "11111111111111111111111111111111" + "name": "authority", + "signer": true } ], - "args": [ + "args": [] + }, + { + "name": "delete_user", + "discriminator": [ + 186, + 85, + 17, + 249, + 219, + 231, + 98, + 251 + ], + "accounts": [ { - "name": "delegate", - "type": "pubkey" + "name": "user", + "writable": true }, { - "name": "add", - "type": "bool" + "name": "user_stats", + "writable": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "writable": true, + "signer": true, + "relations": [ + "user", + "user_stats" + ] } - ] + ], + "args": [] }, { - "name": "delete_amm_cache", + "name": "deposit", "discriminator": [ - 216, - 130, - 215, - 206, - 233, - 232, - 191, - 88 + 242, + 35, + 198, + 137, + 82, + 225, + 242, + 182 ], "accounts": [ { - "name": "admin", - "writable": true, - "signer": true + "name": "state" }, { - "name": "state" + "name": "user", + "writable": true }, { - "name": "amm_cache", + "name": "user_stats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spot_market_vault", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 97, - 109, - 109, + 115, + 112, + 111, + 116, 95, - 99, + 109, 97, - 99, - 104, + 114, + 107, 101, + 116, 95, - 115, - 101, - 101, - 100 + 118, + 97, + 117, + 108, + 116 ] + }, + { + "kind": "arg", + "path": "market_index" } ] } - } - ], - "args": [] - }, - { - "name": "delete_initialized_perp_market", - "discriminator": [ - 91, - 154, - 24, - 87, - 106, - 59, - 190, - 66 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] }, { - "name": "state", + "name": "user_token_account", "writable": true }, { - "name": "perp_market", - "writable": true + "name": "token_program" } ], "args": [ { "name": "market_index", "type": "u16" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "reduce_only", + "type": "bool" } ] }, { - "name": "delete_initialized_spot_market", + "name": "deposit_into_insurance_fund_stake", "discriminator": [ - 31, - 140, - 67, - 191, - 189, - 20, - 101, - 221 + 4, + 22, + 226, + 201, + 124, + 44, + 82, + 230 ], "accounts": [ { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] + "name": "signer", + "signer": true }, { "name": "state", @@ -2037,10 +1709,6 @@ }, { "name": "spot_market", - "writable": true - }, - { - "name": "spot_market_vault", "writable": true, "pda": { "seeds": [ @@ -2057,12 +1725,6 @@ 114, 107, 101, - 116, - 95, - 118, - 97, - 117, - 108, 116 ] }, @@ -2074,7 +1736,7 @@ } }, { - "name": "insurance_fund_vault", + "name": "insurance_fund_stake", "writable": true, "pda": { "seeds": [ @@ -2096,13 +1758,17 @@ 110, 100, 95, - 118, + 115, + 116, 97, - 117, - 108, - 116 + 107, + 101 ] }, + { + "kind": "account", + "path": "user_stats" + }, { "kind": "arg", "path": "market_index" @@ -2111,202 +1777,167 @@ } }, { - "name": "drift_signer" - }, - { - "name": "token_program" - } - ], - "args": [ - { - "name": "market_index", - "type": "u16" - } - ] - }, - { - "name": "delete_prelaunch_oracle", - "discriminator": [ - 59, - 169, - 100, - 49, - 69, - 17, - 173, - 253 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] + "name": "user_stats", + "writable": true }, { - "name": "prelaunch_oracle", + "name": "spot_market_vault", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ + 115, 112, + 111, + 116, + 95, + 109, + 97, 114, + 107, 101, - 108, - 97, - 117, - 110, - 99, - 104, + 116, 95, - 111, - 114, + 118, 97, - 99, + 117, 108, - 101 + 116 ] }, { "kind": "arg", - "path": "perp_market_index" + "path": "market_index" } ] } }, { - "name": "perp_market" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "perp_market_index", - "type": "u16" - } - ] - }, - { - "name": "delete_signed_msg_user_orders", - "discriminator": [ - 221, - 247, - 128, - 253, - 212, - 254, - 46, - 153 - ], - "accounts": [ - { - "name": "signed_msg_user_orders", + "name": "insurance_fund_vault", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 83, - 73, - 71, - 78, - 69, - 68, + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, 95, - 77, - 83, - 71 + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 ] }, { - "kind": "account", - "path": "authority" + "kind": "arg", + "path": "market_index" } ] } }, { - "name": "state", + "name": "user_token_account", "writable": true }, { - "name": "authority", - "signer": true + "name": "token_program" + }, + { + "name": "drift_signer" } ], - "args": [] + "args": [ + { + "name": "market_index", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] }, { - "name": "delete_user", + "name": "deposit_into_perp_market_fee_pool", "discriminator": [ - 186, - 85, - 17, - 249, - 219, - 231, - 98, - 251 + 34, + 58, + 57, + 68, + 97, + 80, + 244, + 6 ], "accounts": [ { - "name": "user", - "writable": true - }, - { - "name": "user_stats", + "name": "state", "writable": true }, { - "name": "state", + "name": "perp_market", "writable": true }, { - "name": "authority", - "writable": true, + "name": "admin", "signer": true, "relations": [ - "user", - "user_stats" + "state" ] - } - ], - "args": [] - }, - { - "name": "deposit", - "discriminator": [ - 242, - 35, - 198, - 137, - 82, - 225, - 242, - 182 - ], - "accounts": [ - { - "name": "state" }, { - "name": "user", + "name": "source_vault", "writable": true }, { - "name": "user_stats", - "writable": true + "name": "drift_signer" }, { - "name": "authority", - "signer": true + "name": "quote_spot_market", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } }, { "name": "spot_market_vault", @@ -2336,128 +1967,50 @@ ] }, { - "kind": "arg", - "path": "market_index" + "kind": "const", + "value": [ + 0, + 0 + ] } ] } }, - { - "name": "user_token_account", - "writable": true - }, { "name": "token_program" } ], "args": [ - { - "name": "market_index", - "type": "u16" - }, { "name": "amount", "type": "u64" - }, - { - "name": "reduce_only", - "type": "bool" } ] }, { - "name": "deposit_into_insurance_fund_stake", + "name": "deposit_into_spot_market_revenue_pool", "discriminator": [ - 4, - 22, - 226, - 201, - 124, - 44, - 82, - 230 + 92, + 40, + 151, + 42, + 122, + 254, + 139, + 246 ], "accounts": [ { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true + "name": "state" }, { "name": "spot_market", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "market_index" - } - ] - } + "writable": true }, { - "name": "insurance_fund_stake", + "name": "authority", "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101 - ] - }, - { - "kind": "account", - "path": "user_stats" - }, - { - "kind": "arg", - "path": "market_index" - } - ] - } - }, - { - "name": "user_stats", - "writable": true + "signer": true }, { "name": "spot_market_vault", @@ -2487,45 +2040,8 @@ ] }, { - "kind": "arg", - "path": "market_index" - } - ] - } - }, - { - "name": "insurance_fund_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "market_index" + "kind": "account", + "path": "spot_market" } ] } @@ -2536,16 +2052,9 @@ }, { "name": "token_program" - }, - { - "name": "drift_signer" } ], "args": [ - { - "name": "market_index", - "type": "u16" - }, { "name": "amount", "type": "u64" @@ -2553,107 +2062,36 @@ ] }, { - "name": "deposit_into_perp_market_fee_pool", + "name": "deposit_into_spot_market_vault", "discriminator": [ - 34, - 58, - 57, - 68, - 97, - 80, - 244, - 6 + 48, + 252, + 119, + 73, + 255, + 205, + 174, + 247 ], "accounts": [ { - "name": "state", - "writable": true + "name": "state" }, { - "name": "perp_market", + "name": "spot_market", "writable": true }, { "name": "admin", - "signer": true, - "relations": [ - "state" - ] + "signer": true }, { "name": "source_vault", "writable": true }, - { - "name": "drift_signer" - }, - { - "name": "quote_spot_market", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, { "name": "spot_market_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } + "writable": true }, { "name": "token_program" @@ -2667,124 +2105,7 @@ ] }, { - "name": "deposit_into_spot_market_revenue_pool", - "discriminator": [ - 92, - 40, - 151, - 42, - 122, - 254, - 139, - 246 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spot_market", - "writable": true - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "spot_market_vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "spot_market" - } - ] - } - }, - { - "name": "user_token_account", - "writable": true - }, - { - "name": "token_program" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "deposit_into_spot_market_vault", - "discriminator": [ - 48, - 252, - 119, - 73, - 255, - 205, - 174, - 247 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spot_market", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "source_vault", - "writable": true - }, - { - "name": "spot_market_vault", - "writable": true - }, - { - "name": "token_program" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "deposit_to_program_vault", + "name": "deposit_to_program_vault", "discriminator": [ 235, 171, @@ -17819,1068 +17140,991 @@ } }, { - "name": "PrelaunchOracle", + "name": "ConstituentParams", "type": { "kind": "struct", "fields": [ { - "name": "price", - "type": "i64" + "name": "max_weight_deviation", + "type": { + "option": "i64" + } }, { - "name": "maxPrice", - "type": "i64" + "name": "swap_fee_min", + "type": { + "option": "i64" + } }, { - "name": "confidence", - "type": "u64" + "name": "swap_fee_max", + "type": { + "option": "i64" + } }, { - "name": "lastUpdateSlot", - "type": "u64" + "name": "max_borrow_token_amount", + "type": { + "option": "u64" + } }, { - "name": "ammLastUpdateSlot", - "type": "u64" + "name": "oracle_staleness_threshold", + "type": { + "option": "u64" + } }, { - "name": "perpMarketIndex", - "type": "u16" + "name": "cost_to_trade_bps", + "type": { + "option": "i32" + } }, { - "name": "padding", + "name": "constituent_derivative_index", "type": { - "array": [ - "u8", - 70 - ] + "option": "i16" } - } - ] - } - }, - { - "name": "PerpMarket", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "The perp market's address. It is a pda of the market index" - ], - "type": "publicKey" }, { - "name": "amm", - "docs": [ - "The automated market maker" - ], + "name": "derivative_weight", "type": { - "defined": "AMM" + "option": "u64" } }, { - "name": "pnlPool", - "docs": [ - "The market's pnl pool. When users settle negative pnl, the balance increases.", - "When users settle positive pnl, the balance decreases. Can not go negative." - ], + "name": "volatility", "type": { - "defined": "PoolBalance" + "option": "u64" } }, { - "name": "name", - "docs": [ - "Encoded display name for the perp market e.g. SOL-PERP" - ], + "name": "gamma_execution", "type": { - "array": [ - "u8", - 32 - ] + "option": "u8" } }, { - "name": "insuranceClaim", - "docs": [ - "The perp market's claim on the insurance fund" - ], + "name": "gamma_inventory", "type": { - "defined": "InsuranceClaim" + "option": "u8" } }, { - "name": "unrealizedPnlMaxImbalance", - "docs": [ - "The max pnl imbalance before positive pnl asset weight is discounted", - "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", - "the amm has negative pnl and the initial asset weight for positive pnl is discounted", - "precision = QUOTE_PRECISION" - ], - "type": "u64" - }, + "name": "xi", + "type": { + "option": "u8" + } + } + ] + } + }, + { + "name": "ConstituentSpotBalance", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "expiryTs", + "name": "scaled_balance", "docs": [ - "The ts when the market will be expired. Only set if market is in reduce only mode" + "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", + "interest of corresponding market.", + "precision: token precision" ], - "type": "i64" + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "expiryPrice", + "name": "cumulative_deposits", "docs": [ - "The price at which positions will be settled. Only set if market is expired", - "precision = PRICE_PRECISION" + "The cumulative deposits/borrows a user has made into a market", + "precision: token mint precision" ], "type": "i64" }, { - "name": "nextFillRecordId", - "docs": [ - "Every trade has a fill record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "nextFundingRateRecordId", + "name": "market_index", "docs": [ - "Every funding rate update has a record id. This is the next id to be used" + "The market index of the corresponding spot market" ], - "type": "u64" + "type": "u16" }, { - "name": "nextCurveRecordId", + "name": "balance_type", "docs": [ - "Every amm k updated has a record id. This is the next id to be used" + "Whether the position is deposit or borrow" ], - "type": "u64" + "type": { + "defined": { + "name": "SpotBalanceType" + } + } }, { - "name": "imfFactor", - "docs": [ - "The initial margin fraction factor. Used to increase margin ratio for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, + "name": "padding", + "type": { + "array": [ + "u8", + 5 + ] + } + } + ] + } + }, + { + "name": "ConstituentTargetBase", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "unrealizedPnlImfFactor", - "docs": [ - "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", - "precision: MARGIN_PRECISION" - ], - "type": "u32" + "name": "lp_pool", + "type": "pubkey" }, { - "name": "liquidatorFee", - "docs": [ - "The fee the liquidator is paid for taking over perp position", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" + "name": "bump", + "type": "u8" }, { - "name": "ifLiquidationFee", - "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" + "name": "_padding", + "type": { + "array": [ + "u8", + 3 + ] + } }, { - "name": "marginRatioInitial", - "docs": [ - "The margin ratio which determines how much collateral is required to open a position", - "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, + "name": "targets", + "type": { + "vec": { + "defined": { + "name": "TargetsDatum" + } + } + } + } + ] + } + }, + { + "name": "ContractTier", + "type": { + "kind": "enum", + "variants": [ { - "name": "marginRatioMaintenance", - "docs": [ - "The margin ratio which determines when a user will be liquidated", - "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", - "else they will be liquidated", - "precision: MARGIN_PRECISION" - ], - "type": "u32" + "name": "A" }, { - "name": "unrealizedPnlInitialAssetWeight", - "docs": [ - "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "B" }, { - "name": "unrealizedPnlMaintenanceAssetWeight", - "docs": [ - "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "C" }, { - "name": "numberOfUsersWithBase", - "docs": [ - "number of users in a position (base)" - ], - "type": "u32" + "name": "Speculative" }, { - "name": "numberOfUsers", - "docs": [ - "number of users in a position (pnl) or pnl (quote)" - ], - "type": "u32" + "name": "HighlySpeculative" }, { - "name": "marketIndex", - "type": "u16" + "name": "Isolated" + } + ] + } + }, + { + "name": "ContractType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Perpetual" }, { - "name": "status", - "docs": [ - "Whether a market is active, reduce only, expired, etc", - "Affects whether users can open/close positions" - ], - "type": { - "defined": "MarketStatus" - } + "name": "Future" }, { - "name": "contractType", - "docs": [ - "Currently only Perpetual markets are supported" - ], - "type": { - "defined": "ContractType" - } + "name": "Prediction" + } + ] + } + }, + { + "name": "CurveRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "contractTier", - "docs": [ - "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", - "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" - ], - "type": { - "defined": "ContractTier" - } + "name": "record_id", + "type": "u64" }, { - "name": "pausedOperations", - "type": "u8" + "name": "peg_multiplier_before", + "type": "u128" }, { - "name": "quoteSpotMarketIndex", - "docs": [ - "The spot market that pnl is settled in" - ], - "type": "u16" + "name": "base_asset_reserve_before", + "type": "u128" }, { - "name": "feeAdjustment", - "docs": [ - "Between -100 and 100, represents what % to increase/decrease the fee by", - "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", - "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" - ], - "type": "i16" + "name": "quote_asset_reserve_before", + "type": "u128" }, { - "name": "fuelBoostPosition", - "docs": [ - "fuel multiplier for perp funding", - "precision: 10" - ], - "type": "u8" + "name": "sqrt_k_before", + "type": "u128" }, { - "name": "fuelBoostTaker", - "docs": [ - "fuel multiplier for perp taker", - "precision: 10" - ], - "type": "u8" + "name": "peg_multiplier_after", + "type": "u128" }, { - "name": "fuelBoostMaker", - "docs": [ - "fuel multiplier for perp maker", - "precision: 10" - ], - "type": "u8" + "name": "base_asset_reserve_after", + "type": "u128" }, { - "name": "poolId", - "type": "u8" + "name": "quote_asset_reserve_after", + "type": "u128" }, { - "name": "highLeverageMarginRatioInitial", - "type": "u16" + "name": "sqrt_k_after", + "type": "u128" }, { - "name": "highLeverageMarginRatioMaintenance", - "type": "u16" + "name": "base_asset_amount_long", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "u128" }, { - "name": "protectedMakerLimitPriceDivisor", - "type": "u8" + "name": "base_asset_amount_short", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "u128" }, { - "name": "protectedMakerDynamicDivisor", - "type": "u8" + "name": "base_asset_amount_with_amm", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i128" }, { - "name": "lpFeeTransferScalar", - "type": "u8" + "name": "total_fee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" }, { - "name": "lpStatus", - "type": "u8" + "name": "total_fee_minus_distributions", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" }, { - "name": "lpPausedOperations", - "type": "u8" + "name": "adjustment_cost", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" }, { - "name": "lpExchangeFeeExcluscionScalar", - "type": "u8" + "name": "oracle_price", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" }, { - "name": "lastFillPrice", - "type": "u64" + "name": "fill_record", + "type": "u128" }, { - "name": "lpPoolId", - "type": "u8" + "name": "number_of_users", + "type": "u32" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 23 - ] - } + "name": "market_index", + "type": "u16" } ] } }, { - "name": "ProtectedMakerModeConfig", + "name": "DeleteUserRecord", "type": { "kind": "struct", "fields": [ { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "currentUsers", - "type": "u32" + "name": "ts", + "docs": [ + "unix_timestamp of action" + ], + "type": "i64" }, { - "name": "reduceOnly", - "type": "u8" + "name": "user_authority", + "type": "pubkey" }, { - "name": "padding", + "name": "user", + "type": "pubkey" + }, + { + "name": "sub_account_id", + "type": "u16" + }, + { + "name": "keeper", "type": { - "array": [ - "u8", - 31 - ] + "option": "pubkey" } } ] } }, { - "name": "PythLazerOracle", + "name": "DepositDirection", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "price", - "type": "i64" + "name": "Deposit" }, { - "name": "publishTime", - "type": "u64" + "name": "Withdraw" + } + ] + } + }, + { + "name": "DepositExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "None" }, { - "name": "postedSlot", - "type": "u64" + "name": "Transfer" }, { - "name": "exponent", - "type": "i32" + "name": "Borrow" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } + "name": "RepayBorrow" }, { - "name": "conf", - "type": "u64" + "name": "Reward" } ] } }, { - "name": "RevenueShare", + "name": "DepositRecord", "type": { "kind": "struct", "fields": [ { - "name": "authority", + "name": "ts", "docs": [ - "the owner of this account, a builder or referrer" + "unix_timestamp of action" ], - "type": "publicKey" + "type": "i64" }, { - "name": "totalReferrerRewards", - "type": "u64" + "name": "user_authority", + "type": "pubkey" }, { - "name": "totalBuilderRewards", - "type": "u64" + "name": "user", + "docs": [ + "user account public key" + ], + "type": "pubkey" }, { - "name": "padding", + "name": "direction", "type": { - "array": [ - "u8", - 18 - ] + "defined": { + "name": "DepositDirection" + } } - } - ] - } - }, - { - "name": "RevenueShareEscrow", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "authority", + "name": "deposit_record_id", + "type": "u64" + }, + { + "name": "amount", "docs": [ - "the owner of this account, a user" + "precision: token mint precision" ], - "type": "publicKey" + "type": "u64" }, { - "name": "referrer", - "type": "publicKey" + "name": "market_index", + "docs": [ + "spot market index" + ], + "type": "u16" }, { - "name": "referrerBoostExpireTs", - "type": "u32" + "name": "oracle_price", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" }, { - "name": "referrerRewardOffset", - "type": "i8" + "name": "market_deposit_balance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" }, { - "name": "refereeFeeNumeratorOffset", - "type": "i8" + "name": "market_withdraw_balance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" }, { - "name": "referrerBoostNumerator", - "type": "i8" + "name": "market_cumulative_deposit_interest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" }, { - "name": "reservedFixed", - "type": { - "array": [ - "u8", - 17 - ] - } + "name": "market_cumulative_borrow_interest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" }, { - "name": "padding0", - "type": "u32" + "name": "total_deposits_after", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" }, { - "name": "orders", + "name": "total_withdraws_after", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "explanation", "type": { - "vec": { - "defined": "RevenueShareOrder" + "defined": { + "name": "DepositExplanation" } } }, { - "name": "padding1", - "type": "u32" + "name": "transfer_user", + "type": { + "option": "pubkey" + } }, { - "name": "approvedBuilders", + "name": "signer", "type": { - "vec": { - "defined": "BuilderInfo" - } + "option": "pubkey" } + }, + { + "name": "user_token_amount_after", + "docs": [ + "precision: token mint precision" + ], + "type": "i128" } ] } }, { - "name": "SignedMsgUserOrders", - "docs": [ - "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" - ], + "name": "FeeStructure", "type": { "kind": "struct", "fields": [ { - "name": "authorityPubkey", - "type": "publicKey" - }, - { - "name": "padding", - "type": "u32" + "name": "fee_tiers", + "type": { + "array": [ + { + "defined": { + "name": "FeeTier" + } + }, + 10 + ] + } }, { - "name": "signedMsgOrderData", + "name": "filler_reward_structure", "type": { - "vec": { - "defined": "SignedMsgOrderId" + "defined": { + "name": "OrderFillerRewardStructure" } } - } - ] - } - }, - { - "name": "SignedMsgWsDelegates", - "docs": [ - "* Used to store authenticated delegates for swift-like ws connections" - ], - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "delegates", - "type": { - "vec": "publicKey" - } + "name": "referrer_reward_epoch_upper_bound", + "type": "u64" + }, + { + "name": "flat_filler_fee", + "type": "u64" } ] } }, { - "name": "SpotMarket", + "name": "FeeTier", "type": { "kind": "struct", "fields": [ { - "name": "pubkey", - "docs": [ - "The address of the spot market. It is a pda of the market index" - ], - "type": "publicKey" + "name": "fee_numerator", + "type": "u32" }, { - "name": "oracle", - "docs": [ - "The oracle used to price the markets deposits/borrows" - ], - "type": "publicKey" + "name": "fee_denominator", + "type": "u32" }, { - "name": "mint", - "docs": [ - "The token mint of the market" - ], - "type": "publicKey" + "name": "maker_rebate_numerator", + "type": "u32" }, { - "name": "vault", - "docs": [ - "The vault used to store the market's deposits", - "The amount in the vault should be equal to or greater than deposits - borrows" - ], - "type": "publicKey" + "name": "maker_rebate_denominator", + "type": "u32" }, { - "name": "name", + "name": "referrer_reward_numerator", + "type": "u32" + }, + { + "name": "referrer_reward_denominator", + "type": "u32" + }, + { + "name": "referee_fee_numerator", + "type": "u32" + }, + { + "name": "referee_fee_denominator", + "type": "u32" + } + ] + } + }, + { + "name": "FuelOverflow", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", "docs": [ - "The encoded display name for the market e.g. SOL" + "The authority of this overflow account" ], + "type": "pubkey" + }, + { + "name": "fuel_insurance", "type": { - "array": [ - "u8", - 32 - ] + "defined": { + "name": "u128" + } } }, { - "name": "historicalOracleData", + "name": "fuel_deposits", "type": { - "defined": "HistoricalOracleData" + "defined": { + "name": "u128" + } } }, { - "name": "historicalIndexData", + "name": "fuel_borrows", "type": { - "defined": "HistoricalIndexData" + "defined": { + "name": "u128" + } } }, { - "name": "revenuePool", - "docs": [ - "Revenue the protocol has collected in this markets token", - "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" - ], + "name": "fuel_positions", "type": { - "defined": "PoolBalance" + "defined": { + "name": "u128" + } } }, { - "name": "spotFeePool", - "docs": [ - "The fees collected from swaps between this market and the quote market", - "Is settled to the quote markets revenue pool" - ], + "name": "fuel_taker", "type": { - "defined": "PoolBalance" + "defined": { + "name": "u128" + } } }, { - "name": "insuranceFund", - "docs": [ - "Details on the insurance fund covering bankruptcies in this markets token", - "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" - ], + "name": "fuel_maker", "type": { - "defined": "InsuranceFund" + "defined": { + "name": "u128" + } } }, { - "name": "totalSpotFee", - "docs": [ - "The total spot fees collected for this market", - "precision: QUOTE_PRECISION" - ], - "type": "u128" + "name": "last_fuel_sweep_ts", + "type": "u32" }, { - "name": "depositBalance", - "docs": [ - "The sum of the scaled balances for deposits across users and pool balances", - "To convert to the deposit token amount, multiply by the cumulative deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" + "name": "last_reset_ts", + "type": "u32" }, { - "name": "borrowBalance", - "docs": [ - "The sum of the scaled balances for borrows across users and pool balances", - "To convert to the borrow token amount, multiply by the cumulative borrow interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" + "name": "padding", + "type": { + "array": [ + "u128", + 6 + ] + } + } + ] + } + }, + { + "name": "FuelSeasonRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "cumulativeDepositInterest", - "docs": [ - "The cumulative interest earned by depositors", - "Used to calculate the deposit token amount from the deposit balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], + "name": "authority", + "type": "pubkey" + }, + { + "name": "fuel_insurance", "type": "u128" }, { - "name": "cumulativeBorrowInterest", - "docs": [ - "The cumulative interest earned by borrowers", - "Used to calculate the borrow token amount from the borrow balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], + "name": "fuel_deposits", "type": "u128" }, { - "name": "totalSocialLoss", - "docs": [ - "The total socialized loss from borrows, in the mint's token", - "precision: token mint precision" - ], + "name": "fuel_borrows", "type": "u128" }, { - "name": "totalQuoteSocialLoss", - "docs": [ - "The total socialized loss from borrows, in the quote market's token", - "preicision: QUOTE_PRECISION" - ], + "name": "fuel_positions", "type": "u128" }, { - "name": "withdrawGuardThreshold", - "docs": [ - "no withdraw limits/guards when deposits below this threshold", - "precision: token mint precision" - ], - "type": "u64" + "name": "fuel_taker", + "type": "u128" }, { - "name": "maxTokenDeposits", - "docs": [ - "The max amount of token deposits in this market", - "0 if there is no limit", - "precision: token mint precision" - ], - "type": "u64" + "name": "fuel_maker", + "type": "u128" }, { - "name": "depositTokenTwap", - "docs": [ - "24hr average of deposit token amount", - "precision: token mint precision" - ], - "type": "u64" + "name": "fuel_total", + "type": "u128" + } + ] + } + }, + { + "name": "FuelSweepRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "borrowTokenTwap", - "docs": [ - "24hr average of borrow token amount", - "precision: token mint precision" - ], - "type": "u64" + "name": "authority", + "type": "pubkey" }, { - "name": "utilizationTwap", - "docs": [ - "24hr average of utilization", - "which is borrow amount over token amount", - "precision: SPOT_UTILIZATION_PRECISION" - ], - "type": "u64" + "name": "user_stats_fuel_insurance", + "type": "u32" }, { - "name": "lastInterestTs", - "docs": [ - "Last time the cumulative deposit and borrow interest was updated" - ], - "type": "u64" + "name": "user_stats_fuel_deposits", + "type": "u32" }, { - "name": "lastTwapTs", - "docs": [ - "Last time the deposit/borrow/utilization averages were updated" - ], - "type": "u64" + "name": "user_stats_fuel_borrows", + "type": "u32" }, { - "name": "expiryTs", - "docs": [ - "The time the market is set to expire. Only set if market is in reduce only mode" - ], - "type": "i64" + "name": "user_stats_fuel_positions", + "type": "u32" }, { - "name": "orderStepSize", - "docs": [ - "Spot orders must be a multiple of the step size", - "precision: token mint precision" - ], - "type": "u64" + "name": "user_stats_fuel_taker", + "type": "u32" }, { - "name": "orderTickSize", - "docs": [ - "Spot orders must be a multiple of the tick size", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "user_stats_fuel_maker", + "type": "u32" }, { - "name": "minOrderSize", - "docs": [ - "The minimum order size", - "precision: token mint precision" - ], - "type": "u64" + "name": "fuel_overflow_fuel_insurance", + "type": "u128" }, { - "name": "maxPositionSize", - "docs": [ - "The maximum spot position size", - "if the limit is 0, there is no limit", - "precision: token mint precision" - ], - "type": "u64" + "name": "fuel_overflow_fuel_deposits", + "type": "u128" }, { - "name": "nextFillRecordId", - "docs": [ - "Every spot trade has a fill record id. This is the next id to use" - ], - "type": "u64" + "name": "fuel_overflow_fuel_borrows", + "type": "u128" }, { - "name": "nextDepositRecordId", - "docs": [ - "Every deposit has a deposit record id. This is the next id to use" - ], - "type": "u64" + "name": "fuel_overflow_fuel_positions", + "type": "u128" }, { - "name": "initialAssetWeight", - "docs": [ - "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", - "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "fuel_overflow_fuel_taker", + "type": "u128" }, { - "name": "maintenanceAssetWeight", - "docs": [ - "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", - "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "fuel_overflow_fuel_maker", + "type": "u128" + } + ] + } + }, + { + "name": "FundingPaymentRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "initialLiabilityWeight", - "docs": [ - "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", - "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "user_authority", + "type": "pubkey" }, { - "name": "maintenanceLiabilityWeight", - "docs": [ - "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", - "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" + "name": "user", + "type": "pubkey" }, { - "name": "imfFactor", - "docs": [ - "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" + "name": "market_index", + "type": "u16" }, { - "name": "liquidatorFee", + "name": "funding_payment", "docs": [ - "The fee the liquidator is paid for taking over borrow/deposit", - "precision: LIQUIDATOR_FEE_PRECISION" + "precision: QUOTE_PRECISION" ], - "type": "u32" + "type": "i64" }, { - "name": "ifLiquidationFee", + "name": "base_asset_amount", "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" + "precision: BASE_PRECISION" ], - "type": "u32" + "type": "i64" }, { - "name": "optimalUtilization", + "name": "user_last_cumulative_funding", "docs": [ - "The optimal utilization rate for this market.", - "Used to determine the markets borrow rate", - "precision: SPOT_UTILIZATION_PRECISION" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u32" + "type": "i64" }, { - "name": "optimalBorrowRate", + "name": "amm_cumulative_funding_long", "docs": [ - "The borrow rate for this market when the market has optimal utilization", - "precision: SPOT_RATE_PRECISION" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u32" + "type": "i128" }, { - "name": "maxBorrowRate", + "name": "amm_cumulative_funding_short", "docs": [ - "The borrow rate for this market when the market has 1000 utilization", - "precision: SPOT_RATE_PRECISION" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u32" + "type": "i128" + } + ] + } + }, + { + "name": "FundingRateRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "decimals", - "docs": [ - "The market's token mint's decimals. To from decimals to a precision, 10^decimals" - ], - "type": "u32" + "name": "record_id", + "type": "u64" }, { - "name": "marketIndex", + "name": "market_index", "type": "u16" }, { - "name": "ordersEnabled", + "name": "funding_rate", "docs": [ - "Whether or not spot trading is enabled" + "precision: FUNDING_RATE_PRECISION" ], - "type": "bool" - }, - { - "name": "oracleSource", - "type": { - "defined": "OracleSource" - } - }, - { - "name": "status", - "type": { - "defined": "MarketStatus" - } + "type": "i64" }, { - "name": "assetTier", + "name": "funding_rate_long", "docs": [ - "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" + "precision: FUNDING_RATE_PRECISION" ], - "type": { - "defined": "AssetTier" - } - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "ifPausedOperations", - "type": "u8" - }, - { - "name": "feeAdjustment", - "type": "i16" + "type": "i128" }, { - "name": "maxTokenBorrowsFraction", + "name": "funding_rate_short", "docs": [ - "What fraction of max_token_deposits", - "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", - "precision: X/10000" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u16" + "type": "i128" }, { - "name": "flashLoanAmount", + "name": "cumulative_funding_rate_long", "docs": [ - "For swaps, the amount of token loaned out in the begin_swap ix", - "precision: token mint precision" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "flashLoanInitialTokenAmount", + "name": "cumulative_funding_rate_short", "docs": [ - "For swaps, the amount in the users token account in the begin_swap ix", - "Used to calculate how much of the token left the system in end_swap ix", - "precision: token mint precision" + "precision: FUNDING_RATE_PRECISION" ], - "type": "u64" + "type": "i128" }, { - "name": "totalSwapFee", + "name": "oracle_price_twap", "docs": [ - "The total fees received from swaps", - "precision: token mint precision" + "precision: PRICE_PRECISION" ], - "type": "u64" + "type": "i64" }, { - "name": "scaleInitialAssetWeightStart", + "name": "mark_price_twap", "docs": [ - "When to begin scaling down the initial asset weight", - "disabled when 0", - "precision: QUOTE_PRECISION" + "precision: PRICE_PRECISION" ], "type": "u64" }, { - "name": "minBorrowRate", + "name": "period_revenue", "docs": [ - "The min borrow rate for this market when the market regardless of utilization", - "1 => 1/200 => .5%", - "precision: X/200" + "precision: QUOTE_PRECISION" ], - "type": "u8" + "type": "i64" }, { - "name": "fuelBoostDeposits", + "name": "base_asset_amount_with_amm", "docs": [ - "fuel multiplier for spot deposits", - "precision: 10" + "precision: BASE_PRECISION" ], - "type": "u8" + "type": "i128" }, { - "name": "fuelBoostBorrows", + "name": "base_asset_amount_with_unsettled_lp", "docs": [ - "fuel multiplier for spot borrows", - "precision: 10" + "precision: BASE_PRECISION" ], - "type": "u8" - }, + "type": "i128" + } + ] + } + }, + { + "name": "HighLeverageModeConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "fuelBoostTaker", - "docs": [ - "fuel multiplier for spot taker", - "precision: 10" - ], - "type": "u8" + "name": "max_users", + "type": "u32" }, { - "name": "fuelBoostMaker", - "docs": [ - "fuel multiplier for spot maker", - "precision: 10" - ], - "type": "u8" + "name": "current_users", + "type": "u32" }, { - "name": "fuelBoostInsurance", - "docs": [ - "fuel multiplier for spot insurance stake", - "precision: 10" - ], + "name": "reduce_only", "type": "u8" }, { - "name": "tokenProgramFlag", - "type": "u8" + "name": "padding1", + "type": { + "array": [ + "u8", + 3 + ] + } }, { - "name": "poolId", - "type": "u8" + "name": "current_maintenance_users", + "type": "u32" }, { - "name": "padding", + "name": "padding2", "type": { "array": [ "u8", - 40 + 24 ] } } @@ -18888,926 +18132,725 @@ } }, { - "name": "State", + "name": "HistoricalIndexData", "type": { "kind": "struct", "fields": [ { - "name": "admin", - "type": "publicKey" - }, - { - "name": "whitelistMint", - "type": "publicKey" - }, - { - "name": "discountMint", - "type": "publicKey" - }, - { - "name": "signer", - "type": "publicKey" + "name": "last_index_bid_price", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "srmVault", - "type": "publicKey" + "name": "last_index_ask_price", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "perpFeeStructure", - "type": { - "defined": "FeeStructure" - } + "name": "last_index_price_twap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "spotFeeStructure", - "type": { - "defined": "FeeStructure" - } + "name": "last_index_price_twap_5min", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "oracleGuardRails", - "type": { - "defined": "OracleGuardRails" - } - }, - { - "name": "numberOfAuthorities", - "type": "u64" - }, - { - "name": "numberOfSubAccounts", - "type": "u64" - }, - { - "name": "lpCooldownTime", - "type": "u64" - }, - { - "name": "liquidationMarginBufferRatio", - "type": "u32" - }, - { - "name": "settlementDuration", - "type": "u16" - }, - { - "name": "numberOfMarkets", - "type": "u16" - }, - { - "name": "numberOfSpotMarkets", - "type": "u16" - }, - { - "name": "signerNonce", - "type": "u8" - }, - { - "name": "minPerpAuctionDuration", - "type": "u8" - }, - { - "name": "defaultMarketOrderTimeInForce", - "type": "u8" - }, - { - "name": "defaultSpotAuctionDuration", - "type": "u8" - }, - { - "name": "exchangeStatus", - "type": "u8" - }, - { - "name": "liquidationDuration", - "type": "u8" - }, - { - "name": "initialPctToLiquidate", - "type": "u16" - }, - { - "name": "maxNumberOfSubAccounts", - "type": "u16" - }, - { - "name": "maxInitializeUserFee", - "type": "u16" - }, - { - "name": "featureBitFlags", - "type": "u8" - }, - { - "name": "lpPoolFeatureBitFlags", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 8 - ] - } + "name": "last_index_price_twap_ts", + "docs": [ + "unix_timestamp of last snapshot" + ], + "type": "i64" } ] } }, { - "name": "User", + "name": "HistoricalOracleData", "type": { "kind": "struct", "fields": [ { - "name": "authority", - "docs": [ - "The owner/authority of the account" - ], - "type": "publicKey" - }, - { - "name": "delegate", + "name": "last_oracle_price", "docs": [ - "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw" + "precision: PRICE_PRECISION" ], - "type": "publicKey" + "type": "i64" }, { - "name": "name", + "name": "last_oracle_conf", "docs": [ - "Encoded display name e.g. \"toly\"" + "precision: PRICE_PRECISION" ], - "type": { - "array": [ - "u8", - 32 - ] - } + "type": "u64" }, { - "name": "spotPositions", + "name": "last_oracle_delay", "docs": [ - "The user's spot positions" + "number of slots since last update" ], - "type": { - "array": [ - { - "defined": "SpotPosition" - }, - 8 - ] - } + "type": "i64" }, { - "name": "perpPositions", + "name": "last_oracle_price_twap", "docs": [ - "The user's perp positions" + "precision: PRICE_PRECISION" ], - "type": { - "array": [ - { - "defined": "PerpPosition" - }, - 8 - ] - } + "type": "i64" }, { - "name": "orders", + "name": "last_oracle_price_twap_5min", "docs": [ - "The user's orders" + "precision: PRICE_PRECISION" ], - "type": { - "array": [ - { - "defined": "Order" - }, - 32 - ] - } + "type": "i64" }, { - "name": "lastAddPerpLpSharesTs", + "name": "last_oracle_price_twap_ts", "docs": [ - "The last time the user added perp lp positions" + "unix_timestamp of last snapshot" ], "type": "i64" + } + ] + } + }, + { + "name": "IfRebalanceConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" }, { - "name": "totalDeposits", + "name": "total_in_amount", "docs": [ - "The total values of deposits the user has made", - "precision: QUOTE_PRECISION" + "total amount to be sold" ], "type": "u64" }, { - "name": "totalWithdraws", + "name": "current_in_amount", "docs": [ - "The total values of withdrawals the user has made", - "precision: QUOTE_PRECISION" + "amount already sold" ], "type": "u64" }, { - "name": "totalSocialLoss", + "name": "current_out_amount", "docs": [ - "The total socialized loss the users has incurred upon the protocol", - "precision: QUOTE_PRECISION" + "amount already bought" ], "type": "u64" }, { - "name": "settledPerpPnl", + "name": "current_out_amount_transferred", "docs": [ - "Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps", - "precision: QUOTE_PRECISION" + "amount already transferred to revenue pool" ], - "type": "i64" + "type": "u64" }, { - "name": "cumulativeSpotFees", + "name": "current_in_amount_since_last_transfer", "docs": [ - "Fees (taker fees, maker rebate, filler reward) for spot", - "precision: QUOTE_PRECISION" + "amount already bought in epoch" ], - "type": "i64" + "type": "u64" }, { - "name": "cumulativePerpFunding", + "name": "epoch_start_ts", "docs": [ - "Cumulative funding paid/received for perps", - "precision: QUOTE_PRECISION" + "start time of epoch" ], "type": "i64" }, { - "name": "liquidationMarginFreed", + "name": "epoch_in_amount", "docs": [ - "The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time", - "Defaults to zero when not being liquidated", - "precision: QUOTE_PRECISION" + "amount already bought in epoch" ], "type": "u64" }, { - "name": "lastActiveSlot", + "name": "epoch_max_in_amount", "docs": [ - "The last slot a user was active. Used to determine if a user is idle" + "max amount to swap in epoch" ], "type": "u64" }, { - "name": "nextOrderId", + "name": "epoch_duration", "docs": [ - "Every user order has an order id. This is the next order id to be used" + "duration of epoch" ], - "type": "u32" + "type": "i64" }, { - "name": "maxMarginRatio", + "name": "out_market_index", "docs": [ - "Custom max initial margin ratio for the user" + "market index to sell" ], - "type": "u32" + "type": "u16" }, { - "name": "nextLiquidationId", + "name": "in_market_index", "docs": [ - "The next liquidation id to be used for user" + "market index to buy" ], "type": "u16" }, { - "name": "subAccountId", - "docs": [ - "The sub account id for this user" - ], + "name": "max_slippage_bps", "type": "u16" }, + { + "name": "swap_mode", + "type": "u8" + }, { "name": "status", - "docs": [ - "Whether the user is active, being liquidated or bankrupt" - ], "type": "u8" }, { - "name": "isMarginTradingEnabled", - "docs": [ - "Whether the user has enabled margin trading" - ], - "type": "bool" + "name": "padding2", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "IfRebalanceConfigParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "total_in_amount", + "type": "u64" }, { - "name": "idle", - "docs": [ - "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", - "Off-chain keeper bots can ignore users that are idle" - ], - "type": "bool" + "name": "epoch_max_in_amount", + "type": "u64" }, { - "name": "openOrders", - "docs": [ - "number of open orders" - ], - "type": "u8" + "name": "epoch_duration", + "type": "i64" }, { - "name": "hasOpenOrder", - "docs": [ - "Whether or not user has open order" - ], - "type": "bool" + "name": "out_market_index", + "type": "u16" }, { - "name": "openAuctions", - "docs": [ - "number of open orders with auction" - ], - "type": "u8" + "name": "in_market_index", + "type": "u16" }, { - "name": "hasOpenAuction", - "docs": [ - "Whether or not user has open order with auction" - ], - "type": "bool" - }, - { - "name": "marginMode", - "type": { - "defined": "MarginMode" - } + "name": "max_slippage_bps", + "type": "u16" }, { - "name": "poolId", + "name": "swap_mode", "type": "u8" }, { - "name": "padding1", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "lastFuelBonusUpdateTs", - "type": "u32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 12 - ] - } + "name": "status", + "type": "u8" } ] } }, { - "name": "UserStats", + "name": "InsuranceClaim", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "authority", - "docs": [ - "The authority for all of a users sub accounts" - ], - "type": "publicKey" - }, - { - "name": "referrer", - "docs": [ - "The address that referred this user" - ], - "type": "publicKey" - }, - { - "name": "fees", - "docs": [ - "Stats on the fees paid by the user" - ], - "type": { - "defined": "UserFees" - } - }, - { - "name": "nextEpochTs", + "name": "revenue_withdraw_since_last_settle", "docs": [ - "The timestamp of the next epoch", - "Epoch is used to limit referrer rewards earned in single epoch" + "The amount of revenue last settled", + "Positive if funds left the perp market,", + "negative if funds were pulled into the perp market", + "precision: QUOTE_PRECISION" ], "type": "i64" }, { - "name": "makerVolume30d", + "name": "max_revenue_withdraw_per_period", "docs": [ - "Rolling 30day maker volume for user", + "The max amount of revenue that can be withdrawn per period", "precision: QUOTE_PRECISION" ], "type": "u64" }, { - "name": "takerVolume30d", + "name": "quote_max_insurance", "docs": [ - "Rolling 30day taker volume for user", + "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits", "precision: QUOTE_PRECISION" ], "type": "u64" }, { - "name": "fillerVolume30d", + "name": "quote_settled_insurance", "docs": [ - "Rolling 30day filler volume for user", + "The amount of insurance that has been used to resolve bankruptcy and pnl deficits", "precision: QUOTE_PRECISION" ], "type": "u64" }, { - "name": "lastMakerVolume30dTs", + "name": "last_revenue_withdraw_ts", "docs": [ - "last time the maker volume was updated" + "The last time revenue was settled in/out of market" ], "type": "i64" + } + ] + } + }, + { + "name": "InsuranceFund", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "vault", + "type": "pubkey" }, { - "name": "lastTakerVolume30dTs", - "docs": [ - "last time the taker volume was updated" - ], - "type": "i64" + "name": "total_shares", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "lastFillerVolume30dTs", - "docs": [ - "last time the filler volume was updated" - ], - "type": "i64" + "name": "user_shares", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "ifStakedQuoteAssetAmount", - "docs": [ - "The amount of tokens staked in the quote spot markets if" - ], - "type": "u64" + "name": "shares_base", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "numberOfSubAccounts", - "docs": [ - "The current number of sub accounts" - ], - "type": "u16" + "name": "unstaking_period", + "type": "i64" }, { - "name": "numberOfSubAccountsCreated", - "docs": [ - "The number of sub accounts created. Can be greater than the number of sub accounts if user", - "has deleted sub accounts" - ], - "type": "u16" + "name": "last_revenue_settle_ts", + "type": "i64" }, { - "name": "referrerStatus", - "docs": [ - "Flags for referrer status:", - "First bit (LSB): 1 if user is a referrer, 0 otherwise", - "Second bit: 1 if user was referred, 0 otherwise" - ], - "type": "u8" + "name": "revenue_settle_period", + "type": "i64" }, { - "name": "disableUpdatePerpBidAskTwap", - "type": "bool" + "name": "total_factor", + "type": "u32" }, { - "name": "pausedOperations", - "type": "u8" + "name": "user_factor", + "type": "u32" + } + ] + } + }, + { + "name": "InsuranceFundRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, { - "name": "fuelOverflowStatus", - "docs": [ - "whether the user has a FuelOverflow account" - ], - "type": "u8" + "name": "spot_market_index", + "type": "u16" }, { - "name": "fuelInsurance", - "docs": [ - "accumulated fuel for token amounts of insurance" - ], - "type": "u32" + "name": "perp_market_index", + "type": "u16" }, { - "name": "fuelDeposits", + "name": "user_if_factor", "docs": [ - "accumulated fuel for notional of deposits" + "precision: PERCENTAGE_PRECISION" ], "type": "u32" }, { - "name": "fuelBorrows", + "name": "total_if_factor", "docs": [ - "accumulate fuel bonus for notional of borrows" + "precision: PERCENTAGE_PRECISION" ], "type": "u32" }, { - "name": "fuelPositions", + "name": "vault_amount_before", "docs": [ - "accumulated fuel for perp open interest" + "precision: token mint precision" ], - "type": "u32" + "type": "u64" }, { - "name": "fuelTaker", + "name": "insurance_vault_amount_before", "docs": [ - "accumulate fuel bonus for taker volume" + "precision: token mint precision" ], - "type": "u32" + "type": "u64" }, { - "name": "fuelMaker", - "docs": [ - "accumulate fuel bonus for maker volume" - ], - "type": "u32" + "name": "total_if_shares_before", + "type": "u128" }, { - "name": "ifStakedGovTokenAmount", - "docs": [ - "The amount of tokens staked in the governance spot markets if" - ], - "type": "u64" + "name": "total_if_shares_after", + "type": "u128" }, { - "name": "lastFuelIfBonusUpdateTs", + "name": "amount", "docs": [ - "last unix ts user stats data was used to update if fuel (u32 to save space)" + "precision: token mint precision" ], - "type": "u32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 12 - ] - } + "type": "i64" } ] } }, { - "name": "ReferrerName", + "name": "InsuranceFundStake", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { "name": "authority", - "type": "publicKey" + "type": "pubkey" }, { - "name": "user", - "type": "publicKey" + "name": "if_shares", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "userStats", - "type": "publicKey" + "name": "last_withdraw_request_shares", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "name", + "name": "if_base", "type": { - "array": [ - "u8", - 32 - ] + "defined": { + "name": "u128" + } } - } - ] - } - }, - { - "name": "FuelOverflow", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "authority", - "docs": [ - "The authority of this overflow account" - ], - "type": "publicKey" - }, - { - "name": "fuelInsurance", - "type": "u128" - }, - { - "name": "fuelDeposits", - "type": "u128" - }, - { - "name": "fuelBorrows", - "type": "u128" - }, - { - "name": "fuelPositions", - "type": "u128" + "name": "last_valid_ts", + "type": "i64" }, { - "name": "fuelTaker", - "type": "u128" + "name": "last_withdraw_request_value", + "type": "u64" }, { - "name": "fuelMaker", - "type": "u128" + "name": "last_withdraw_request_ts", + "type": "i64" }, { - "name": "lastFuelSweepTs", - "type": "u32" + "name": "cost_basis", + "type": "i64" }, { - "name": "lastResetTs", - "type": "u32" + "name": "market_index", + "type": "u16" }, { "name": "padding", "type": { "array": [ - "u128", - 6 + "u8", + 14 ] } } ] } - } - ], - "types": [ + }, { - "name": "UpdatePerpMarketSummaryStatsParams", + "name": "InsuranceFundStakeRecord", "type": { "kind": "struct", "fields": [ { - "name": "quoteAssetAmountWithUnsettledLp", - "type": { - "option": "i64" - } + "name": "ts", + "type": "i64" }, { - "name": "netUnsettledFundingPnl", - "type": { - "option": "i64" - } + "name": "user_authority", + "type": "pubkey" }, { - "name": "updateAmmSummaryStats", + "name": "action", "type": { - "option": "bool" + "defined": { + "name": "StakeAction" + } } }, { - "name": "excludeTotalLiqFee", - "type": { - "option": "bool" - } + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "market_index", + "type": "u16" + }, + { + "name": "insurance_vault_amount_before", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "if_shares_before", + "type": "u128" + }, + { + "name": "user_if_shares_before", + "type": "u128" + }, + { + "name": "total_if_shares_before", + "type": "u128" + }, + { + "name": "if_shares_after", + "type": "u128" + }, + { + "name": "user_if_shares_after", + "type": "u128" + }, + { + "name": "total_if_shares_after", + "type": "u128" } ] } }, { - "name": "ConstituentParams", + "name": "InsuranceFundSwapRecord", "type": { "kind": "struct", "fields": [ { - "name": "max_weight_deviation", - "type": { - "option": "i64" - } + "name": "rebalance_config", + "type": "pubkey" }, { - "name": "swap_fee_min", - "type": { - "option": "i64" - } + "name": "in_if_total_shares_before", + "type": "u128" }, { - "name": "swap_fee_max", - "type": { - "option": "i64" - } + "name": "out_if_total_shares_before", + "type": "u128" }, { - "name": "max_borrow_token_amount", - "type": { - "option": "u64" - } + "name": "in_if_user_shares_before", + "type": "u128" }, { - "name": "oracle_staleness_threshold", - "type": { - "option": "u64" - } + "name": "out_if_user_shares_before", + "type": "u128" }, { - "name": "cost_to_trade_bps", - "type": { - "option": "i32" - } + "name": "in_if_total_shares_after", + "type": "u128" }, { - "name": "constituent_derivative_index", - "type": { - "option": "i16" - } + "name": "out_if_total_shares_after", + "type": "u128" }, { - "name": "derivative_weight", - "type": { - "option": "u64" - } + "name": "in_if_user_shares_after", + "type": "u128" }, { - "name": "volatility", - "type": { - "option": "u64" - } + "name": "out_if_user_shares_after", + "type": "u128" }, { - "name": "gamma_execution", - "type": { - "option": "u8" - } + "name": "ts", + "type": "i64" }, { - "name": "gamma_inventory", - "type": { - "option": "u8" - } + "name": "in_amount", + "type": "u64" }, { - "name": "xi", - "type": { - "option": "u8" - } - } - ] - } - }, - { - "name": "ConstituentSpotBalance", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ + "name": "out_amount", + "type": "u64" + }, { - "name": "scaled_balance", - "docs": [ - "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", - "interest of corresponding market.", - "precision: token precision" - ], - "type": { - "defined": { - "name": "u128" - } - } + "name": "out_oracle_price", + "type": "u64" }, { - "name": "cumulative_deposits", - "docs": [ - "The cumulative deposits/borrows a user has made into a market", - "precision: token mint precision" - ], + "name": "out_oracle_price_twap", "type": "i64" }, { - "name": "market_index", - "docs": [ - "The market index of the corresponding spot market" - ], - "type": "u16" + "name": "in_vault_amount_before", + "type": "u64" }, { - "name": "balance_type", - "docs": [ - "Whether the position is deposit or borrow" - ], - "type": { - "defined": { - "name": "SpotBalanceType" - } - } + "name": "out_vault_amount_before", + "type": "u64" }, { - "name": "padding", - "type": { - "array": [ - "u8", - 5 - ] - } + "name": "in_fund_vault_amount_after", + "type": "u64" + }, + { + "name": "out_fund_vault_amount_after", + "type": "u64" + }, + { + "name": "in_market_index", + "type": "u16" + }, + { + "name": "out_market_index", + "type": "u16" } ] } }, { - "name": "ConstituentTargetBase", - "repr": { - "kind": "c" - }, + "name": "LPAction", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "lp_pool", - "type": "pubkey" + "name": "AddLiquidity" }, { - "name": "bump", - "type": "u8" + "name": "RemoveLiquidity" }, { - "name": "_padding", - "type": { - "array": [ - "u8", - 3 - ] - } + "name": "SettleLiquidity" }, { - "name": "targets", - "type": { - "vec": { - "defined": { - "name": "TargetsDatum" - } - } - } + "name": "RemoveLiquidityDerisk" } ] } }, { - "name": "ContractTier", + "name": "LPBorrowLendDepositRecord", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "A" + "name": "ts", + "type": "i64" }, { - "name": "B" + "name": "slot", + "type": "u64" }, { - "name": "C" + "name": "spot_market_index", + "type": "u16" }, { - "name": "Speculative" + "name": "constituent_index", + "type": "u16" }, { - "name": "HighlySpeculative" + "name": "direction", + "type": { + "defined": { + "name": "DepositDirection" + } + } }, { - "name": "Isolated" - } - ] - } - }, - { - "name": "ContractType", - "type": { - "kind": "enum", - "variants": [ + "name": "token_balance", + "type": "i64" + }, { - "name": "Perpetual" + "name": "last_token_balance", + "type": "i64" }, { - "name": "Future" + "name": "interest_accrued_token_amount", + "type": "i64" }, { - "name": "Prediction" + "name": "amount_deposit_withdraw", + "type": "u64" + }, + { + "name": "lp_pool", + "type": "pubkey" } ] } }, { - "name": "CurveRecord", + "name": "LPMintRedeemRecord", "type": { "kind": "struct", "fields": [ @@ -19816,1069 +18859,1071 @@ "type": "i64" }, { - "name": "record_id", + "name": "slot", "type": "u64" }, { - "name": "peg_multiplier_before", - "type": "u128" - }, - { - "name": "base_asset_reserve_before", - "type": "u128" - }, - { - "name": "quote_asset_reserve_before", - "type": "u128" + "name": "authority", + "type": "pubkey" }, { - "name": "sqrt_k_before", - "type": "u128" + "name": "description", + "type": "u8" }, { - "name": "peg_multiplier_after", + "name": "amount", + "docs": [ + "precision: continutent mint precision, gross fees" + ], "type": "u128" }, { - "name": "base_asset_reserve_after", - "type": "u128" + "name": "fee", + "docs": [ + "precision: fee on amount, constituent market mint precision" + ], + "type": "i128" }, { - "name": "quote_asset_reserve_after", - "type": "u128" + "name": "spot_market_index", + "type": "u16" }, { - "name": "sqrt_k_after", - "type": "u128" + "name": "constituent_index", + "type": "u16" }, { - "name": "base_asset_amount_long", + "name": "oracle_price", "docs": [ - "precision: BASE_PRECISION" + "precision: PRICE_PRECISION" ], - "type": "u128" + "type": "i64" }, { - "name": "base_asset_amount_short", + "name": "mint", "docs": [ - "precision: BASE_PRECISION" + "token mint" ], - "type": "u128" + "type": "pubkey" }, { - "name": "base_asset_amount_with_amm", + "name": "lp_amount", "docs": [ - "precision: BASE_PRECISION" + "lp amount, lp mint precision" ], - "type": "i128" + "type": "u64" }, { - "name": "total_fee", + "name": "lp_fee", "docs": [ - "precision: QUOTE_PRECISION" + "lp fee, lp mint precision" ], - "type": "i128" + "type": "i64" }, { - "name": "total_fee_minus_distributions", + "name": "lp_price", "docs": [ - "precision: QUOTE_PRECISION" + "the fair price of the lp token, PRICE_PRECISION" ], - "type": "i128" + "type": "u128" }, { - "name": "adjustment_cost", + "name": "mint_redeem_id", + "type": "u64" + }, + { + "name": "last_aum", "docs": [ - "precision: QUOTE_PRECISION" + "LPPool last_aum" ], - "type": "i128" + "type": "u128" }, { - "name": "oracle_price", + "name": "last_aum_slot", + "type": "u64" + }, + { + "name": "in_market_current_weight", "docs": [ - "precision: PRICE_PRECISION" + "PERCENTAGE_PRECISION" ], "type": "i64" }, { - "name": "fill_record", - "type": "u128" - }, - { - "name": "number_of_users", - "type": "u32" + "name": "in_market_target_weight", + "type": "i64" }, { - "name": "market_index", - "type": "u16" + "name": "lp_pool", + "type": "pubkey" } ] } }, { - "name": "DeleteUserRecord", + "name": "LPPool", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "ts", + "name": "pubkey", "docs": [ - "unix_timestamp of action" + "address of the vault." ], - "type": "i64" + "type": "pubkey" }, { - "name": "user_authority", + "name": "mint", "type": "pubkey" }, { - "name": "user", + "name": "whitelist_mint", "type": "pubkey" }, { - "name": "sub_account_id", - "type": "u16" + "name": "constituent_target_base", + "type": "pubkey" }, { - "name": "keeper", + "name": "constituent_correlations", + "type": "pubkey" + }, + { + "name": "max_aum", + "docs": [ + "The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)", + "which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)", + "pub quote_constituent_index: u16,", + "QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this" + ], "type": { - "option": "pubkey" + "defined": { + "name": "u128" + } } - } - ] - } - }, - { - "name": "DepositDirection", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Deposit" }, { - "name": "Withdraw" - } - ] - } - }, - { - "name": "DepositExplanation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "None" + "name": "last_aum", + "docs": [ + "QUOTE_PRECISION: AUM of the vault in USD, updated lazily" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "Transfer" + "name": "cumulative_quote_sent_to_perp_markets", + "docs": [ + "QUOTE PRECISION: Cumulative quotes from settles" + ], + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "Borrow" + "name": "cumulative_quote_received_from_perp_markets", + "type": { + "defined": { + "name": "u128" + } + } }, { - "name": "RepayBorrow" - }, - { - "name": "Reward" - } - ] - } - }, - { - "name": "DepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "docs": [ - "unix_timestamp of action" - ], - "type": "i64" - }, - { - "name": "user_authority", - "type": "pubkey" - }, - { - "name": "user", + "name": "total_mint_redeem_fees_paid", "docs": [ - "user account public key" + "QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens" ], - "type": "pubkey" - }, - { - "name": "direction", "type": { "defined": { - "name": "DepositDirection" + "name": "i128" } } }, { - "name": "deposit_record_id", + "name": "last_aum_slot", + "docs": [ + "timestamp of last AUM slot" + ], "type": "u64" }, { - "name": "amount", + "name": "max_settle_quote_amount", + "type": "u64" + }, + { + "name": "_padding", "docs": [ - "precision: token mint precision" + "timestamp of last vAMM revenue rebalance" ], "type": "u64" }, { - "name": "market_index", + "name": "mint_redeem_id", "docs": [ - "spot market index" + "Every mint/redeem has a monotonically increasing id. This is the next id to use" ], - "type": "u16" + "type": "u64" }, { - "name": "oracle_price", + "name": "settle_id", + "type": "u64" + }, + { + "name": "min_mint_fee", "docs": [ - "precision: PRICE_PRECISION" + "PERCENTAGE_PRECISION" ], "type": "i64" }, { - "name": "market_deposit_balance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" + "name": "token_supply", + "type": "u64" }, { - "name": "market_withdraw_balance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" + "name": "volatility", + "type": "u64" }, { - "name": "market_cumulative_deposit_interest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" + "name": "constituents", + "type": "u16" }, { - "name": "market_cumulative_borrow_interest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" + "name": "quote_consituent_index", + "type": "u16" }, { - "name": "total_deposits_after", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "bump", + "type": "u8" }, { - "name": "total_withdraws_after", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "gamma_execution", + "type": "u8" }, { - "name": "explanation", - "type": { - "defined": { - "name": "DepositExplanation" - } - } + "name": "xi", + "type": "u8" }, { - "name": "transfer_user", - "type": { - "option": "pubkey" - } + "name": "target_oracle_delay_fee_bps_per_10_slots", + "type": "u8" }, { - "name": "signer", - "type": { - "option": "pubkey" - } + "name": "target_position_delay_fee_bps_per_10_slots", + "type": "u8" }, { - "name": "user_token_amount_after", - "docs": [ - "precision: token mint precision" - ], - "type": "i128" + "name": "lp_pool_id", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 174 + ] + } } ] } }, { - "name": "FeeStructure", + "name": "LPRecord", "type": { "kind": "struct", "fields": [ { - "name": "fee_tiers", - "type": { - "array": [ - { - "defined": { - "name": "FeeTier" - } - }, - 10 - ] - } + "name": "ts", + "type": "i64" }, { - "name": "filler_reward_structure", + "name": "user", + "type": "pubkey" + }, + { + "name": "action", "type": { "defined": { - "name": "OrderFillerRewardStructure" + "name": "LPAction" } } }, { - "name": "referrer_reward_epoch_upper_bound", + "name": "n_shares", + "docs": [ + "precision: AMM_RESERVE_PRECISION" + ], "type": "u64" }, { - "name": "flat_filler_fee", - "type": "u64" + "name": "market_index", + "type": "u16" + }, + { + "name": "delta_base_asset_amount", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "delta_quote_asset_amount", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "pnl", + "docs": [ + "realized pnl of the position settlement", + "precision: QUOTE_PRECISION" + ], + "type": "i64" } ] } }, { - "name": "FeeTier", + "name": "LPSettleRecord", "type": { "kind": "struct", "fields": [ { - "name": "fee_numerator", - "type": "u32" + "name": "record_id", + "type": "u64" }, { - "name": "fee_denominator", - "type": "u32" + "name": "last_ts", + "type": "i64" }, { - "name": "maker_rebate_numerator", - "type": "u32" + "name": "last_slot", + "type": "u64" }, { - "name": "maker_rebate_denominator", - "type": "u32" + "name": "ts", + "type": "i64" }, { - "name": "referrer_reward_numerator", - "type": "u32" + "name": "slot", + "type": "u64" }, { - "name": "referrer_reward_denominator", - "type": "u32" + "name": "perp_market_index", + "type": "u16" }, { - "name": "referee_fee_numerator", - "type": "u32" + "name": "settle_to_lp_amount", + "type": "i64" }, { - "name": "referee_fee_denominator", - "type": "u32" + "name": "perp_amm_pnl_delta", + "type": "i64" + }, + { + "name": "perp_amm_ex_fee_delta", + "type": "i64" + }, + { + "name": "lp_aum", + "type": "u128" + }, + { + "name": "lp_price", + "type": "u128" + }, + { + "name": "lp_pool", + "type": "pubkey" } ] } }, { - "name": "FuelOverflow", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, + "name": "LPSwapRecord", "type": { "kind": "struct", "fields": [ { - "name": "authority", - "docs": [ - "The authority of this overflow account" - ], - "type": "pubkey" + "name": "ts", + "type": "i64" }, { - "name": "fuel_insurance", - "type": { - "defined": { - "name": "u128" - } - } + "name": "slot", + "type": "u64" }, { - "name": "fuel_deposits", - "type": { - "defined": { - "name": "u128" - } - } + "name": "authority", + "type": "pubkey" }, { - "name": "fuel_borrows", - "type": { - "defined": { - "name": "u128" - } - } + "name": "out_amount", + "docs": [ + "precision: out market mint precision, gross fees" + ], + "type": "u128" }, { - "name": "fuel_positions", - "type": { - "defined": { - "name": "u128" - } - } + "name": "in_amount", + "docs": [ + "precision: in market mint precision, gross fees" + ], + "type": "u128" }, { - "name": "fuel_taker", - "type": { - "defined": { - "name": "u128" - } - } + "name": "out_fee", + "docs": [ + "precision: fee on amount_out, in market mint precision" + ], + "type": "i128" }, { - "name": "fuel_maker", - "type": { - "defined": { - "name": "u128" - } - } + "name": "in_fee", + "docs": [ + "precision: fee on amount_in, out market mint precision" + ], + "type": "i128" }, { - "name": "last_fuel_sweep_ts", - "type": "u32" + "name": "out_spot_market_index", + "type": "u16" }, { - "name": "last_reset_ts", - "type": "u32" + "name": "in_spot_market_index", + "type": "u16" }, { - "name": "padding", - "type": { - "array": [ - "u128", - 6 - ] - } - } - ] - } - }, - { - "name": "FuelSeasonRecord", - "type": { - "kind": "struct", - "fields": [ + "name": "out_constituent_index", + "type": "u16" + }, { - "name": "ts", + "name": "in_constituent_index", + "type": "u16" + }, + { + "name": "out_oracle_price", + "docs": [ + "precision: PRICE_PRECISION" + ], "type": "i64" }, { - "name": "authority", - "type": "pubkey" + "name": "in_oracle_price", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" }, { - "name": "fuel_insurance", + "name": "last_aum", + "docs": [ + "LPPool last_aum, QUOTE_PRECISION" + ], "type": "u128" }, { - "name": "fuel_deposits", - "type": "u128" + "name": "last_aum_slot", + "type": "u64" }, { - "name": "fuel_borrows", - "type": "u128" + "name": "in_market_current_weight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" }, { - "name": "fuel_positions", - "type": "u128" + "name": "out_market_current_weight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" }, { - "name": "fuel_taker", - "type": "u128" + "name": "in_market_target_weight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" }, { - "name": "fuel_maker", - "type": "u128" + "name": "out_market_target_weight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" }, { - "name": "fuel_total", - "type": "u128" + "name": "in_swap_id", + "type": "u64" + }, + { + "name": "out_swap_id", + "type": "u64" + }, + { + "name": "lp_pool", + "type": "pubkey" } ] } }, { - "name": "FuelSweepRecord", + "name": "LiquidateBorrowForPerpPnlRecord", "type": { "kind": "struct", "fields": [ { - "name": "ts", - "type": "i64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "user_stats_fuel_insurance", - "type": "u32" - }, - { - "name": "user_stats_fuel_deposits", - "type": "u32" + "name": "perp_market_index", + "type": "u16" }, { - "name": "user_stats_fuel_borrows", - "type": "u32" + "name": "market_oracle_price", + "type": "i64" }, { - "name": "user_stats_fuel_positions", - "type": "u32" + "name": "pnl_transfer", + "type": "u128" }, { - "name": "user_stats_fuel_taker", - "type": "u32" + "name": "liability_market_index", + "type": "u16" }, { - "name": "user_stats_fuel_maker", - "type": "u32" + "name": "liability_price", + "type": "i64" }, { - "name": "fuel_overflow_fuel_insurance", + "name": "liability_transfer", "type": "u128" + } + ] + } + }, + { + "name": "LiquidatePerpPnlForDepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "perp_market_index", + "type": "u16" }, { - "name": "fuel_overflow_fuel_deposits", - "type": "u128" + "name": "market_oracle_price", + "type": "i64" }, { - "name": "fuel_overflow_fuel_borrows", + "name": "pnl_transfer", "type": "u128" }, { - "name": "fuel_overflow_fuel_positions", - "type": "u128" + "name": "asset_market_index", + "type": "u16" }, { - "name": "fuel_overflow_fuel_taker", - "type": "u128" + "name": "asset_price", + "type": "i64" }, { - "name": "fuel_overflow_fuel_maker", + "name": "asset_transfer", "type": "u128" } ] } }, { - "name": "FundingPaymentRecord", + "name": "LiquidatePerpRecord", "type": { "kind": "struct", "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user_authority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, { "name": "market_index", "type": "u16" }, { - "name": "funding_payment", - "docs": [ - "precision: QUOTE_PRECISION" - ], + "name": "oracle_price", "type": "i64" }, { "name": "base_asset_amount", - "docs": [ - "precision: BASE_PRECISION" - ], "type": "i64" }, { - "name": "user_last_cumulative_funding", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], + "name": "quote_asset_amount", "type": "i64" }, { - "name": "amm_cumulative_funding_long", + "name": "lp_shares", "docs": [ - "precision: FUNDING_RATE_PRECISION" + "precision: AMM_RESERVE_PRECISION" ], - "type": "i128" + "type": "u64" }, { - "name": "amm_cumulative_funding_short", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - } - ] - } - }, - { - "name": "FundingRateRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "record_id", + "name": "fill_record_id", "type": "u64" }, { - "name": "market_index", - "type": "u16" + "name": "user_order_id", + "type": "u32" }, { - "name": "funding_rate", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" + "name": "liquidator_order_id", + "type": "u32" }, { - "name": "funding_rate_long", + "name": "liquidator_fee", "docs": [ - "precision: FUNDING_RATE_PRECISION" + "precision: QUOTE_PRECISION" ], - "type": "i128" + "type": "u64" }, { - "name": "funding_rate_short", + "name": "if_fee", "docs": [ - "precision: FUNDING_RATE_PRECISION" + "precision: QUOTE_PRECISION" ], - "type": "i128" - }, + "type": "u64" + } + ] + } + }, + { + "name": "LiquidateSpotRecord", + "type": { + "kind": "struct", + "fields": [ { - "name": "cumulative_funding_rate_long", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" + "name": "asset_market_index", + "type": "u16" }, { - "name": "cumulative_funding_rate_short", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" + "name": "asset_price", + "type": "i64" }, { - "name": "oracle_price_twap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" + "name": "asset_transfer", + "type": "u128" }, { - "name": "mark_price_twap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "liability_market_index", + "type": "u16" }, { - "name": "period_revenue", - "docs": [ - "precision: QUOTE_PRECISION" - ], + "name": "liability_price", "type": "i64" }, { - "name": "base_asset_amount_with_amm", + "name": "liability_transfer", "docs": [ - "precision: BASE_PRECISION" + "precision: token mint precision" ], - "type": "i128" + "type": "u128" }, { - "name": "base_asset_amount_with_unsettled_lp", + "name": "if_fee", "docs": [ - "precision: BASE_PRECISION" + "precision: token mint precision" ], - "type": "i128" + "type": "u64" } ] } }, { - "name": "HighLeverageModeConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, + "name": "LiquidationRecord", "type": { "kind": "struct", "fields": [ { - "name": "max_users", - "type": "u32" + "name": "ts", + "type": "i64" }, { - "name": "current_users", - "type": "u32" + "name": "liquidation_type", + "type": { + "defined": { + "name": "LiquidationType" + } + } }, { - "name": "reduce_only", - "type": "u8" + "name": "user", + "type": "pubkey" }, { - "name": "padding1", + "name": "liquidator", + "type": "pubkey" + }, + { + "name": "margin_requirement", + "type": "u128" + }, + { + "name": "total_collateral", + "type": "i128" + }, + { + "name": "margin_freed", + "type": "u64" + }, + { + "name": "liquidation_id", + "type": "u16" + }, + { + "name": "bankrupt", + "type": "bool" + }, + { + "name": "canceled_order_ids", "type": { - "array": [ - "u8", - 3 - ] + "vec": "u32" } }, { - "name": "current_maintenance_users", - "type": "u32" + "name": "liquidate_perp", + "type": { + "defined": { + "name": "LiquidatePerpRecord" + } + } }, { - "name": "padding2", + "name": "liquidate_spot", "type": { - "array": [ - "u8", - 24 - ] + "defined": { + "name": "LiquidateSpotRecord" + } + } + }, + { + "name": "liquidate_borrow_for_perp_pnl", + "type": { + "defined": { + "name": "LiquidateBorrowForPerpPnlRecord" + } + } + }, + { + "name": "liquidate_perp_pnl_for_deposit", + "type": { + "defined": { + "name": "LiquidatePerpPnlForDepositRecord" + } + } + }, + { + "name": "perp_bankruptcy", + "type": { + "defined": { + "name": "PerpBankruptcyRecord" + } + } + }, + { + "name": "spot_bankruptcy", + "type": { + "defined": { + "name": "SpotBankruptcyRecord" + } } } ] } }, { - "name": "HistoricalIndexData", + "name": "LiquidationType", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "last_index_bid_price", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "LiquidatePerp" }, { - "name": "last_index_ask_price", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "LiquidateSpot" }, { - "name": "last_index_price_twap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "LiquidateBorrowForPerpPnl" }, { - "name": "last_index_price_twap_5min", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "LiquidatePerpPnlForDeposit" }, { - "name": "last_index_price_twap_ts", - "docs": [ - "unix_timestamp of last snapshot" - ], - "type": "i64" + "name": "PerpBankruptcy" + }, + { + "name": "SpotBankruptcy" } ] } }, { - "name": "HistoricalOracleData", + "name": "LpPoolParams", "type": { "kind": "struct", "fields": [ { - "name": "last_oracle_price", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" + "name": "max_settle_quote_amount", + "type": { + "option": "u64" + } }, { - "name": "last_oracle_conf", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "volatility", + "type": { + "option": "u64" + } }, { - "name": "last_oracle_delay", - "docs": [ - "number of slots since last update" - ], - "type": "i64" + "name": "gamma_execution", + "type": { + "option": "u8" + } }, { - "name": "last_oracle_price_twap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" + "name": "xi", + "type": { + "option": "u8" + } }, { - "name": "last_oracle_price_twap_5min", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" + "name": "max_aum", + "type": { + "option": "u128" + } }, { - "name": "last_oracle_price_twap_ts", - "docs": [ - "unix_timestamp of last snapshot" - ], - "type": "i64" + "name": "whitelist_mint", + "type": { + "option": "pubkey" + } } ] } }, { - "name": "IfRebalanceConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, + "name": "MarginMode", "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "total_in_amount", - "docs": [ - "total amount to be sold" - ], - "type": "u64" - }, + "kind": "enum", + "variants": [ { - "name": "current_in_amount", - "docs": [ - "amount already sold" - ], - "type": "u64" + "name": "Default" }, { - "name": "current_out_amount", - "docs": [ - "amount already bought" - ], - "type": "u64" + "name": "HighLeverage" }, { - "name": "current_out_amount_transferred", - "docs": [ - "amount already transferred to revenue pool" - ], - "type": "u64" - }, + "name": "HighLeverageMaintenance" + } + ] + } + }, + { + "name": "MarketStatus", + "type": { + "kind": "enum", + "variants": [ { - "name": "current_in_amount_since_last_transfer", - "docs": [ - "amount already bought in epoch" - ], - "type": "u64" + "name": "Initialized" }, { - "name": "epoch_start_ts", - "docs": [ - "start time of epoch" - ], - "type": "i64" + "name": "Active" }, { - "name": "epoch_in_amount", - "docs": [ - "amount already bought in epoch" - ], - "type": "u64" + "name": "FundingPaused" }, { - "name": "epoch_max_in_amount", - "docs": [ - "max amount to swap in epoch" - ], - "type": "u64" + "name": "AmmPaused" }, { - "name": "epoch_duration", - "docs": [ - "duration of epoch" - ], - "type": "i64" + "name": "FillPaused" }, { - "name": "out_market_index", - "docs": [ - "market index to sell" - ], - "type": "u16" + "name": "WithdrawPaused" }, { - "name": "in_market_index", - "docs": [ - "market index to buy" - ], - "type": "u16" + "name": "ReduceOnly" }, { - "name": "max_slippage_bps", - "type": "u16" + "name": "Settlement" }, { - "name": "swap_mode", - "type": "u8" - }, + "name": "Delisted" + } + ] + } + }, + { + "name": "MarketType", + "type": { + "kind": "enum", + "variants": [ { - "name": "status", - "type": "u8" + "name": "Spot" }, { - "name": "padding2", - "type": { - "array": [ - "u8", - 32 - ] - } + "name": "Perp" } ] } }, { - "name": "IfRebalanceConfigParams", + "name": "ModifyOrderParams", "type": { "kind": "struct", "fields": [ { - "name": "total_in_amount", - "type": "u64" + "name": "direction", + "type": { + "option": { + "defined": { + "name": "PositionDirection" + } + } + } }, { - "name": "epoch_max_in_amount", - "type": "u64" + "name": "base_asset_amount", + "type": { + "option": "u64" + } }, { - "name": "epoch_duration", - "type": "i64" + "name": "price", + "type": { + "option": "u64" + } }, { - "name": "out_market_index", - "type": "u16" + "name": "reduce_only", + "type": { + "option": "bool" + } }, { - "name": "in_market_index", - "type": "u16" + "name": "post_only", + "type": { + "option": { + "defined": { + "name": "PostOnlyParam" + } + } + } }, { - "name": "max_slippage_bps", - "type": "u16" + "name": "bit_flags", + "type": { + "option": "u8" + } }, { - "name": "swap_mode", - "type": "u8" + "name": "max_ts", + "type": { + "option": "i64" + } }, { - "name": "status", - "type": "u8" + "name": "trigger_price", + "type": { + "option": "u64" + } + }, + { + "name": "trigger_condition", + "type": { + "option": { + "defined": { + "name": "OrderTriggerCondition" + } + } + } + }, + { + "name": "oracle_price_offset", + "type": { + "option": "i32" + } + }, + { + "name": "auction_duration", + "type": { + "option": "u8" + } + }, + { + "name": "auction_start_price", + "type": { + "option": "i64" + } + }, + { + "name": "auction_end_price", + "type": { + "option": "i64" + } + }, + { + "name": "policy", + "type": { + "option": "u8" + } } ] } }, { - "name": "InsuranceClaim", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, + "name": "NewUserRecord", "type": { "kind": "struct", "fields": [ { - "name": "revenue_withdraw_since_last_settle", + "name": "ts", "docs": [ - "The amount of revenue last settled", - "Positive if funds left the perp market,", - "negative if funds were pulled into the perp market", - "precision: QUOTE_PRECISION" + "unix_timestamp of action" ], "type": "i64" }, { - "name": "max_revenue_withdraw_per_period", - "docs": [ - "The max amount of revenue that can be withdrawn per period", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "user_authority", + "type": "pubkey" }, { - "name": "quote_max_insurance", - "docs": [ - "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "user", + "type": "pubkey" }, { - "name": "quote_settled_insurance", - "docs": [ - "The amount of insurance that has been used to resolve bankruptcy and pnl deficits", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "sub_account_id", + "type": "u16" }, { - "name": "last_revenue_withdraw_ts", - "docs": [ - "The last time revenue was settled in/out of market" - ], - "type": "i64" + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "referrer", + "type": "pubkey" } ] } }, { - "name": "InsuranceFund", + "name": "OpenbookV2FulfillmentConfig", "serialization": "bytemuckunsafe", "repr": { "kind": "c" @@ -20887,121 +19932,155 @@ "kind": "struct", "fields": [ { - "name": "vault", + "name": "pubkey", "type": "pubkey" }, { - "name": "total_shares", + "name": "openbook_v2_program_id", + "type": "pubkey" + }, + { + "name": "openbook_v2_market", + "type": "pubkey" + }, + { + "name": "openbook_v2_market_authority", + "type": "pubkey" + }, + { + "name": "openbook_v2_event_heap", + "type": "pubkey" + }, + { + "name": "openbook_v2_bids", + "type": "pubkey" + }, + { + "name": "openbook_v2_asks", + "type": "pubkey" + }, + { + "name": "openbook_v2_base_vault", + "type": "pubkey" + }, + { + "name": "openbook_v2_quote_vault", + "type": "pubkey" + }, + { + "name": "market_index", + "type": "u16" + }, + { + "name": "fulfillment_type", "type": { "defined": { - "name": "u128" + "name": "SpotFulfillmentType" } } }, { - "name": "user_shares", + "name": "status", "type": { "defined": { - "name": "u128" + "name": "SpotFulfillmentConfigStatus" } } }, { - "name": "shares_base", + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "OracleGuardRails", + "type": { + "kind": "struct", + "fields": [ + { + "name": "price_divergence", "type": { "defined": { - "name": "u128" + "name": "PriceDivergenceGuardRails" } } }, { - "name": "unstaking_period", - "type": "i64" + "name": "validity", + "type": { + "defined": { + "name": "ValidityGuardRails" + } + } + } + ] + } + }, + { + "name": "OracleSource", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Pyth" }, { - "name": "last_revenue_settle_ts", - "type": "i64" + "name": "Switchboard" }, { - "name": "revenue_settle_period", - "type": "i64" + "name": "QuoteAsset" }, { - "name": "total_factor", - "type": "u32" + "name": "Pyth1K" }, { - "name": "user_factor", - "type": "u32" - } - ] - } - }, - { - "name": "InsuranceFundRecord", - "type": { - "kind": "struct", - "fields": [ + "name": "Pyth1M" + }, { - "name": "ts", - "type": "i64" + "name": "PythStableCoin" }, { - "name": "spot_market_index", - "type": "u16" + "name": "Prelaunch" }, { - "name": "perp_market_index", - "type": "u16" + "name": "PythPull" }, { - "name": "user_if_factor", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" + "name": "Pyth1KPull" }, { - "name": "total_if_factor", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" + "name": "Pyth1MPull" }, { - "name": "vault_amount_before", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" + "name": "PythStableCoinPull" }, { - "name": "insurance_vault_amount_before", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" + "name": "SwitchboardOnDemand" }, { - "name": "total_if_shares_before", - "type": "u128" + "name": "PythLazer" }, { - "name": "total_if_shares_after", - "type": "u128" + "name": "PythLazer1K" }, { - "name": "amount", - "docs": [ - "precision: token mint precision" - ], - "type": "i64" + "name": "PythLazer1M" + }, + { + "name": "PythLazerStableCoin" } ] } }, { - "name": "InsuranceFundStake", + "name": "Order", "serialization": "bytemuckunsafe", "repr": { "kind": "c" @@ -21010,241 +20089,324 @@ "kind": "struct", "fields": [ { - "name": "authority", - "type": "pubkey" - }, - { - "name": "if_shares", - "type": { - "defined": { - "name": "u128" - } - } + "name": "slot", + "docs": [ + "The slot the order was placed" + ], + "type": "u64" }, { - "name": "last_withdraw_request_shares", - "type": { - "defined": { - "name": "u128" - } - } + "name": "price", + "docs": [ + "The limit price for the order (can be 0 for market orders)", + "For orders with an auction, this price isn't used until the auction is complete", + "precision: PRICE_PRECISION" + ], + "type": "u64" }, { - "name": "if_base", - "type": { - "defined": { - "name": "u128" - } - } + "name": "base_asset_amount", + "docs": [ + "The size of the order", + "precision for perps: BASE_PRECISION", + "precision for spot: token mint precision" + ], + "type": "u64" }, { - "name": "last_valid_ts", - "type": "i64" + "name": "base_asset_amount_filled", + "docs": [ + "The amount of the order filled", + "precision for perps: BASE_PRECISION", + "precision for spot: token mint precision" + ], + "type": "u64" }, { - "name": "last_withdraw_request_value", + "name": "quote_asset_amount_filled", + "docs": [ + "The amount of quote filled for the order", + "precision: QUOTE_PRECISION" + ], "type": "u64" }, { - "name": "last_withdraw_request_ts", + "name": "trigger_price", + "docs": [ + "At what price the order will be triggered. Only relevant for trigger orders", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "auction_start_price", + "docs": [ + "The start price for the auction. Only relevant for market/oracle orders", + "precision: PRICE_PRECISION" + ], "type": "i64" }, { - "name": "cost_basis", + "name": "auction_end_price", + "docs": [ + "The end price for the auction. Only relevant for market/oracle orders", + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "max_ts", + "docs": [ + "The time when the order will expire" + ], "type": "i64" }, + { + "name": "oracle_price_offset", + "docs": [ + "If set, the order limit price is the oracle price + this offset", + "precision: PRICE_PRECISION" + ], + "type": "i32" + }, + { + "name": "order_id", + "docs": [ + "The id for the order. Each users has their own order id space" + ], + "type": "u32" + }, { "name": "market_index", + "docs": [ + "The perp/spot market index" + ], "type": "u16" }, { - "name": "padding", + "name": "status", + "docs": [ + "Whether the order is open or unused" + ], "type": { - "array": [ - "u8", - 14 - ] + "defined": { + "name": "OrderStatus" + } } - } - ] - } - }, - { - "name": "InsuranceFundStakeRecord", - "type": { - "kind": "struct", - "fields": [ + }, { - "name": "ts", - "type": "i64" + "name": "order_type", + "docs": [ + "The type of order" + ], + "type": { + "defined": { + "name": "OrderType" + } + } }, { - "name": "user_authority", - "type": "pubkey" + "name": "market_type", + "docs": [ + "Whether market is spot or perp" + ], + "type": { + "defined": { + "name": "MarketType" + } + } }, { - "name": "action", + "name": "user_order_id", + "docs": [ + "User generated order id. Can make it easier to place/cancel orders" + ], + "type": "u8" + }, + { + "name": "existing_position_direction", + "docs": [ + "What the users position was when the order was placed" + ], "type": { "defined": { - "name": "StakeAction" + "name": "PositionDirection" } } }, { - "name": "amount", + "name": "direction", "docs": [ - "precision: token mint precision" + "Whether the user is going long or short. LONG = bid, SHORT = ask" ], - "type": "u64" + "type": { + "defined": { + "name": "PositionDirection" + } + } }, { - "name": "market_index", - "type": "u16" + "name": "reduce_only", + "docs": [ + "Whether the order is allowed to only reduce position size" + ], + "type": "bool" }, { - "name": "insurance_vault_amount_before", + "name": "post_only", "docs": [ - "precision: token mint precision" + "Whether the order must be a maker" ], - "type": "u64" + "type": "bool" }, { - "name": "if_shares_before", - "type": "u128" + "name": "immediate_or_cancel", + "docs": [ + "Whether the order must be canceled the same slot it is placed" + ], + "type": "bool" }, { - "name": "user_if_shares_before", - "type": "u128" + "name": "trigger_condition", + "docs": [ + "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders" + ], + "type": { + "defined": { + "name": "OrderTriggerCondition" + } + } }, { - "name": "total_if_shares_before", - "type": "u128" + "name": "auction_duration", + "docs": [ + "How many slots the auction lasts" + ], + "type": "u8" }, { - "name": "if_shares_after", - "type": "u128" + "name": "posted_slot_tail", + "docs": [ + "Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)" + ], + "type": "u8" }, { - "name": "user_if_shares_after", - "type": "u128" + "name": "bit_flags", + "docs": [ + "Bitflags for further classification", + "0: is_signed_message" + ], + "type": "u8" }, { - "name": "total_if_shares_after", - "type": "u128" + "name": "padding", + "type": { + "array": [ + "u8", + 1 + ] + } } ] } }, { - "name": "InsuranceFundSwapRecord", + "name": "OrderAction", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "rebalance_config", - "type": "pubkey" + "name": "Place" }, { - "name": "in_if_total_shares_before", - "type": "u128" + "name": "Cancel" }, { - "name": "out_if_total_shares_before", - "type": "u128" + "name": "Fill" }, { - "name": "in_if_user_shares_before", - "type": "u128" + "name": "Trigger" }, { - "name": "out_if_user_shares_before", - "type": "u128" + "name": "Expire" + } + ] + } + }, + { + "name": "OrderActionExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "None" }, { - "name": "in_if_total_shares_after", - "type": "u128" + "name": "InsufficientFreeCollateral" }, { - "name": "out_if_total_shares_after", - "type": "u128" + "name": "OraclePriceBreachedLimitPrice" }, { - "name": "in_if_user_shares_after", - "type": "u128" + "name": "MarketOrderFilledToLimitPrice" }, { - "name": "out_if_user_shares_after", - "type": "u128" + "name": "OrderExpired" }, { - "name": "ts", - "type": "i64" + "name": "Liquidation" }, { - "name": "in_amount", - "type": "u64" + "name": "OrderFilledWithAMM" }, { - "name": "out_amount", - "type": "u64" + "name": "OrderFilledWithAMMJit" }, { - "name": "out_oracle_price", - "type": "u64" + "name": "OrderFilledWithMatch" }, { - "name": "out_oracle_price_twap", - "type": "i64" + "name": "OrderFilledWithMatchJit" }, { - "name": "in_vault_amount_before", - "type": "u64" + "name": "MarketExpired" }, { - "name": "out_vault_amount_before", - "type": "u64" + "name": "RiskingIncreasingOrder" }, { - "name": "in_fund_vault_amount_after", - "type": "u64" + "name": "ReduceOnlyOrderIncreasedPosition" }, { - "name": "out_fund_vault_amount_after", - "type": "u64" + "name": "OrderFillWithSerum" }, { - "name": "in_market_index", - "type": "u16" + "name": "NoBorrowLiquidity" }, { - "name": "out_market_index", - "type": "u16" - } - ] - } - }, - { - "name": "LPAction", - "type": { - "kind": "enum", - "variants": [ + "name": "OrderFillWithPhoenix" + }, { - "name": "AddLiquidity" + "name": "OrderFilledWithAMMJitLPSplit" }, { - "name": "RemoveLiquidity" + "name": "OrderFilledWithLPJit" }, { - "name": "SettleLiquidity" + "name": "DeriskLp" }, { - "name": "RemoveLiquidityDerisk" + "name": "OrderFilledWithOpenbookV2" + }, + { + "name": "TransferPerpPosition" } ] } }, { - "name": "LPBorrowLendDepositRecord", + "name": "OrderActionRecord", "type": { "kind": "struct", "fields": [ @@ -21253,336 +20415,434 @@ "type": "i64" }, { - "name": "slot", - "type": "u64" + "name": "action", + "type": { + "defined": { + "name": "OrderAction" + } + } }, { - "name": "spot_market_index", - "type": "u16" + "name": "action_explanation", + "type": { + "defined": { + "name": "OrderActionExplanation" + } + } }, { - "name": "constituent_index", + "name": "market_index", "type": "u16" }, { - "name": "direction", + "name": "market_type", "type": { "defined": { - "name": "DepositDirection" + "name": "MarketType" } } }, { - "name": "token_balance", - "type": "i64" + "name": "filler", + "type": { + "option": "pubkey" + } }, { - "name": "last_token_balance", - "type": "i64" + "name": "filler_reward", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } }, { - "name": "interest_accrued_token_amount", - "type": "i64" + "name": "fill_record_id", + "type": { + "option": "u64" + } }, { - "name": "amount_deposit_withdraw", - "type": "u64" + "name": "base_asset_amount_filled", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } }, { - "name": "lp_pool", - "type": "pubkey" - } - ] - } - }, - { - "name": "LPMintRedeemRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" + "name": "quote_asset_amount_filled", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } }, { - "name": "slot", - "type": "u64" + "name": "taker_fee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } }, { - "name": "authority", - "type": "pubkey" + "name": "maker_fee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "i64" + } }, { - "name": "description", - "type": "u8" + "name": "referrer_reward", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u32" + } }, { - "name": "amount", + "name": "quote_asset_amount_surplus", "docs": [ - "precision: continutent mint precision, gross fees" + "precision: QUOTE_PRECISION" ], - "type": "u128" + "type": { + "option": "i64" + } }, { - "name": "fee", + "name": "spot_fulfillment_method_fee", "docs": [ - "precision: fee on amount, constituent market mint precision" + "precision: QUOTE_PRECISION" ], - "type": "i128" + "type": { + "option": "u64" + } }, { - "name": "spot_market_index", - "type": "u16" + "name": "taker", + "type": { + "option": "pubkey" + } }, { - "name": "constituent_index", - "type": "u16" + "name": "taker_order_id", + "type": { + "option": "u32" + } }, { - "name": "oracle_price", + "name": "taker_order_direction", + "type": { + "option": { + "defined": { + "name": "PositionDirection" + } + } + } + }, + { + "name": "taker_order_base_asset_amount", "docs": [ - "precision: PRICE_PRECISION" + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" ], - "type": "i64" + "type": { + "option": "u64" + } }, { - "name": "mint", + "name": "taker_order_cumulative_base_asset_amount_filled", "docs": [ - "token mint" + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" ], - "type": "pubkey" + "type": { + "option": "u64" + } }, { - "name": "lp_amount", + "name": "taker_order_cumulative_quote_asset_amount_filled", "docs": [ - "lp amount, lp mint precision" + "precision: QUOTE_PRECISION" ], - "type": "u64" + "type": { + "option": "u64" + } }, { - "name": "lp_fee", + "name": "maker", + "type": { + "option": "pubkey" + } + }, + { + "name": "maker_order_id", + "type": { + "option": "u32" + } + }, + { + "name": "maker_order_direction", + "type": { + "option": { + "defined": { + "name": "PositionDirection" + } + } + } + }, + { + "name": "maker_order_base_asset_amount", "docs": [ - "lp fee, lp mint precision" + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" ], - "type": "i64" + "type": { + "option": "u64" + } }, { - "name": "lp_price", + "name": "maker_order_cumulative_base_asset_amount_filled", "docs": [ - "the fair price of the lp token, PRICE_PRECISION" + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" ], - "type": "u128" + "type": { + "option": "u64" + } }, { - "name": "mint_redeem_id", - "type": "u64" + "name": "maker_order_cumulative_quote_asset_amount_filled", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } }, { - "name": "last_aum", + "name": "oracle_price", "docs": [ - "LPPool last_aum" + "precision: PRICE_PRECISION" ], - "type": "u128" + "type": "i64" }, { - "name": "last_aum_slot", - "type": "u64" + "name": "bit_flags", + "docs": [ + "Bit flags:", + "0: is_signed_message" + ], + "type": "u8" }, { - "name": "in_market_current_weight", + "name": "taker_existing_quote_entry_amount", "docs": [ - "PERCENTAGE_PRECISION" + "precision: QUOTE_PRECISION", + "Only Some if the taker reduced position" ], - "type": "i64" + "type": { + "option": "u64" + } }, { - "name": "in_market_target_weight", - "type": "i64" - }, - { - "name": "lp_pool", - "type": "pubkey" - } - ] - } - }, - { - "name": "LPPool", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", + "name": "taker_existing_base_asset_amount", "docs": [ - "address of the vault." + "precision: BASE_PRECISION", + "Only Some if the taker flipped position direction" ], - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "whitelist_mint", - "type": "pubkey" + "type": { + "option": "u64" + } }, { - "name": "constituent_target_base", - "type": "pubkey" + "name": "maker_existing_quote_entry_amount", + "docs": [ + "precision: QUOTE_PRECISION", + "Only Some if the maker reduced position" + ], + "type": { + "option": "u64" + } }, { - "name": "constituent_correlations", - "type": "pubkey" + "name": "maker_existing_base_asset_amount", + "docs": [ + "precision: BASE_PRECISION", + "Only Some if the maker flipped position direction" + ], + "type": { + "option": "u64" + } }, { - "name": "max_aum", + "name": "trigger_price", "docs": [ - "The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)", - "which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)", - "pub quote_constituent_index: u16,", - "QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this" + "precision: PRICE_PRECISION" ], "type": { - "defined": { - "name": "u128" - } + "option": "u64" } }, { - "name": "last_aum", + "name": "builder_idx", "docs": [ - "QUOTE_PRECISION: AUM of the vault in USD, updated lazily" + "the idx of the builder in the taker's [`RevenueShareEscrow`] account" ], "type": { - "defined": { - "name": "u128" - } + "option": "u8" } }, { - "name": "cumulative_quote_sent_to_perp_markets", + "name": "builder_fee", "docs": [ - "QUOTE PRECISION: Cumulative quotes from settles" + "precision: QUOTE_PRECISION builder fee paid by the taker" ], "type": { - "defined": { - "name": "u128" - } + "option": "u64" } + } + ] + } + }, + { + "name": "OrderFillerRewardStructure", + "type": { + "kind": "struct", + "fields": [ + { + "name": "reward_numerator", + "type": "u32" }, { - "name": "cumulative_quote_received_from_perp_markets", + "name": "reward_denominator", + "type": "u32" + }, + { + "name": "time_based_reward_lower_bound", "type": { "defined": { "name": "u128" } } - }, + } + ] + } + }, + { + "name": "OrderParams", + "type": { + "kind": "struct", + "fields": [ { - "name": "total_mint_redeem_fees_paid", - "docs": [ - "QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens" - ], + "name": "order_type", "type": { "defined": { - "name": "i128" + "name": "OrderType" } } }, { - "name": "last_aum_slot", - "docs": [ - "timestamp of last AUM slot" - ], - "type": "u64" + "name": "market_type", + "type": { + "defined": { + "name": "MarketType" + } + } }, { - "name": "max_settle_quote_amount", - "type": "u64" + "name": "direction", + "type": { + "defined": { + "name": "PositionDirection" + } + } }, { - "name": "_padding", - "docs": [ - "timestamp of last vAMM revenue rebalance" - ], - "type": "u64" + "name": "user_order_id", + "type": "u8" }, { - "name": "mint_redeem_id", - "docs": [ - "Every mint/redeem has a monotonically increasing id. This is the next id to use" - ], + "name": "base_asset_amount", "type": "u64" }, { - "name": "settle_id", + "name": "price", "type": "u64" }, { - "name": "min_mint_fee", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "token_supply", - "type": "u64" + "name": "market_index", + "type": "u16" }, { - "name": "volatility", - "type": "u64" + "name": "reduce_only", + "type": "bool" }, { - "name": "constituents", - "type": "u16" + "name": "post_only", + "type": { + "defined": { + "name": "PostOnlyParam" + } + } }, { - "name": "quote_consituent_index", - "type": "u16" + "name": "bit_flags", + "type": "u8" }, { - "name": "bump", - "type": "u8" + "name": "max_ts", + "type": { + "option": "i64" + } }, { - "name": "gamma_execution", - "type": "u8" + "name": "trigger_price", + "type": { + "option": "u64" + } }, { - "name": "xi", - "type": "u8" + "name": "trigger_condition", + "type": { + "defined": { + "name": "OrderTriggerCondition" + } + } }, { - "name": "target_oracle_delay_fee_bps_per_10_slots", - "type": "u8" + "name": "oracle_price_offset", + "type": { + "option": "i32" + } }, { - "name": "target_position_delay_fee_bps_per_10_slots", - "type": "u8" + "name": "auction_duration", + "type": { + "option": "u8" + } }, { - "name": "lp_pool_id", - "type": "u8" + "name": "auction_start_price", + "type": { + "option": "i64" + } }, { - "name": "padding", + "name": "auction_end_price", "type": { - "array": [ - "u8", - 174 - ] + "option": "i64" } } ] } }, { - "name": "LPRecord", + "name": "OrderRecord", "type": { "kind": "struct", "fields": [ @@ -21595,782 +20855,995 @@ "type": "pubkey" }, { - "name": "action", + "name": "order", "type": { "defined": { - "name": "LPAction" + "name": "Order" } } - }, + } + ] + } + }, + { + "name": "OrderStatus", + "type": { + "kind": "enum", + "variants": [ { - "name": "n_shares", - "docs": [ - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u64" + "name": "Init" }, { - "name": "market_index", - "type": "u16" + "name": "Open" }, { - "name": "delta_base_asset_amount", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i64" + "name": "Filled" }, { - "name": "delta_quote_asset_amount", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "pnl", - "docs": [ - "realized pnl of the position settlement", - "precision: QUOTE_PRECISION" - ], - "type": "i64" + "name": "Canceled" } ] } }, { - "name": "LPSettleRecord", + "name": "OrderTriggerCondition", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "record_id", - "type": "u64" + "name": "Above" }, { - "name": "last_ts", - "type": "i64" + "name": "Below" }, { - "name": "last_slot", - "type": "u64" + "name": "TriggeredAbove" }, { - "name": "ts", - "type": "i64" + "name": "TriggeredBelow" + } + ] + } + }, + { + "name": "OrderType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Market" }, { - "name": "slot", - "type": "u64" + "name": "Limit" }, { - "name": "perp_market_index", - "type": "u16" + "name": "TriggerMarket" }, { - "name": "settle_to_lp_amount", - "type": "i64" + "name": "TriggerLimit" }, { - "name": "perp_amm_pnl_delta", - "type": "i64" + "name": "Oracle" + } + ] + } + }, + { + "name": "OverrideAmmCacheParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quote_owed_from_lp_pool", + "type": { + "option": "i64" + } }, { - "name": "perp_amm_ex_fee_delta", - "type": "i64" + "name": "last_settle_slot", + "type": { + "option": "u64" + } }, { - "name": "lp_aum", - "type": "u128" + "name": "last_fee_pool_token_amount", + "type": { + "option": "u128" + } }, { - "name": "lp_price", - "type": "u128" + "name": "last_net_pnl_pool_token_amount", + "type": { + "option": "i128" + } }, { - "name": "lp_pool", - "type": "pubkey" + "name": "amm_position_scalar", + "type": { + "option": "u8" + } + }, + { + "name": "amm_inventory_limit", + "type": { + "option": "i64" + } } ] } }, { - "name": "LPSwapRecord", + "name": "PerpBankruptcyRecord", "type": { "kind": "struct", "fields": [ { - "name": "ts", - "type": "i64" + "name": "market_index", + "type": "u16" }, { - "name": "slot", - "type": "u64" + "name": "pnl", + "type": "i128" }, { - "name": "authority", - "type": "pubkey" + "name": "if_payment", + "type": "u128" }, { - "name": "out_amount", - "docs": [ - "precision: out market mint precision, gross fees" - ], - "type": "u128" + "name": "clawback_user", + "type": { + "option": "pubkey" + } }, { - "name": "in_amount", - "docs": [ - "precision: in market mint precision, gross fees" - ], - "type": "u128" + "name": "clawback_user_payment", + "type": { + "option": "u128" + } }, { - "name": "out_fee", + "name": "cumulative_funding_rate_delta", + "type": "i128" + } + ] + } + }, + { + "name": "PerpMarket", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", "docs": [ - "precision: fee on amount_out, in market mint precision" + "The perp market's address. It is a pda of the market index" ], - "type": "i128" + "type": "pubkey" }, { - "name": "in_fee", + "name": "amm", "docs": [ - "precision: fee on amount_in, out market mint precision" + "The automated market maker" ], - "type": "i128" + "type": { + "defined": { + "name": "AMM" + } + } }, { - "name": "out_spot_market_index", - "type": "u16" + "name": "pnl_pool", + "docs": [ + "The market's pnl pool. When users settle negative pnl, the balance increases.", + "When users settle positive pnl, the balance decreases. Can not go negative." + ], + "type": { + "defined": { + "name": "PoolBalance" + } + } }, { - "name": "in_spot_market_index", - "type": "u16" + "name": "name", + "docs": [ + "Encoded display name for the perp market e.g. SOL-PERP" + ], + "type": { + "array": [ + "u8", + 32 + ] + } }, { - "name": "out_constituent_index", - "type": "u16" + "name": "insurance_claim", + "docs": [ + "The perp market's claim on the insurance fund" + ], + "type": { + "defined": { + "name": "InsuranceClaim" + } + } }, { - "name": "in_constituent_index", - "type": "u16" + "name": "unrealized_pnl_max_imbalance", + "docs": [ + "The max pnl imbalance before positive pnl asset weight is discounted", + "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", + "the amm has negative pnl and the initial asset weight for positive pnl is discounted", + "precision = QUOTE_PRECISION" + ], + "type": "u64" }, { - "name": "out_oracle_price", + "name": "expiry_ts", "docs": [ - "precision: PRICE_PRECISION" + "The ts when the market will be expired. Only set if market is in reduce only mode" ], "type": "i64" }, { - "name": "in_oracle_price", + "name": "expiry_price", "docs": [ - "precision: PRICE_PRECISION" + "The price at which positions will be settled. Only set if market is expired", + "precision = PRICE_PRECISION" ], "type": "i64" }, { - "name": "last_aum", + "name": "next_fill_record_id", "docs": [ - "LPPool last_aum, QUOTE_PRECISION" + "Every trade has a fill record id. This is the next id to be used" ], - "type": "u128" + "type": "u64" }, { - "name": "last_aum_slot", + "name": "next_funding_rate_record_id", + "docs": [ + "Every funding rate update has a record id. This is the next id to be used" + ], "type": "u64" }, { - "name": "in_market_current_weight", + "name": "next_curve_record_id", "docs": [ - "PERCENTAGE_PRECISION" + "Every amm k updated has a record id. This is the next id to be used" ], - "type": "i64" + "type": "u64" }, { - "name": "out_market_current_weight", + "name": "imf_factor", "docs": [ - "PERCENTAGE_PRECISION" + "The initial margin fraction factor. Used to increase margin ratio for large positions", + "precision: MARGIN_PRECISION" ], - "type": "i64" + "type": "u32" }, { - "name": "in_market_target_weight", + "name": "unrealized_pnl_imf_factor", "docs": [ - "PERCENTAGE_PRECISION" + "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", + "precision: MARGIN_PRECISION" ], - "type": "i64" + "type": "u32" }, { - "name": "out_market_target_weight", + "name": "liquidator_fee", "docs": [ - "PERCENTAGE_PRECISION" + "The fee the liquidator is paid for taking over perp position", + "precision: LIQUIDATOR_FEE_PRECISION" ], - "type": "i64" + "type": "u32" }, { - "name": "in_swap_id", - "type": "u64" + "name": "if_liquidation_fee", + "docs": [ + "The fee the insurance fund receives from liquidation", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" }, { - "name": "out_swap_id", - "type": "u64" + "name": "margin_ratio_initial", + "docs": [ + "The margin ratio which determines how much collateral is required to open a position", + "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", + "precision: MARGIN_PRECISION" + ], + "type": "u32" }, { - "name": "lp_pool", - "type": "pubkey" - } - ] - } - }, - { - "name": "LiquidateBorrowForPerpPnlRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perp_market_index", - "type": "u16" + "name": "margin_ratio_maintenance", + "docs": [ + "The margin ratio which determines when a user will be liquidated", + "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", + "else they will be liquidated", + "precision: MARGIN_PRECISION" + ], + "type": "u32" }, { - "name": "market_oracle_price", - "type": "i64" + "name": "unrealized_pnl_initial_asset_weight", + "docs": [ + "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" }, { - "name": "pnl_transfer", - "type": "u128" + "name": "unrealized_pnl_maintenance_asset_weight", + "docs": [ + "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" }, { - "name": "liability_market_index", - "type": "u16" + "name": "number_of_users_with_base", + "docs": [ + "number of users in a position (base)" + ], + "type": "u32" }, { - "name": "liability_price", - "type": "i64" + "name": "number_of_users", + "docs": [ + "number of users in a position (pnl) or pnl (quote)" + ], + "type": "u32" }, { - "name": "liability_transfer", - "type": "u128" - } - ] - } - }, - { - "name": "LiquidatePerpPnlForDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perp_market_index", + "name": "market_index", "type": "u16" }, { - "name": "market_oracle_price", - "type": "i64" + "name": "status", + "docs": [ + "Whether a market is active, reduce only, expired, etc", + "Affects whether users can open/close positions" + ], + "type": { + "defined": { + "name": "MarketStatus" + } + } }, { - "name": "pnl_transfer", - "type": "u128" + "name": "contract_type", + "docs": [ + "Currently only Perpetual markets are supported" + ], + "type": { + "defined": { + "name": "ContractType" + } + } }, { - "name": "asset_market_index", - "type": "u16" + "name": "contract_tier", + "docs": [ + "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", + "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" + ], + "type": { + "defined": { + "name": "ContractTier" + } + } }, { - "name": "asset_price", - "type": "i64" + "name": "paused_operations", + "type": "u8" }, { - "name": "asset_transfer", - "type": "u128" - } - ] - } - }, - { - "name": "LiquidatePerpRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "market_index", + "name": "quote_spot_market_index", + "docs": [ + "The spot market that pnl is settled in" + ], "type": "u16" }, { - "name": "oracle_price", - "type": "i64" + "name": "fee_adjustment", + "docs": [ + "Between -100 and 100, represents what % to increase/decrease the fee by", + "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", + "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" + ], + "type": "i16" }, { - "name": "base_asset_amount", - "type": "i64" + "name": "fuel_boost_position", + "docs": [ + "fuel multiplier for perp funding", + "precision: 10" + ], + "type": "u8" }, { - "name": "quote_asset_amount", - "type": "i64" + "name": "fuel_boost_taker", + "docs": [ + "fuel multiplier for perp taker", + "precision: 10" + ], + "type": "u8" }, { - "name": "lp_shares", + "name": "fuel_boost_maker", "docs": [ - "precision: AMM_RESERVE_PRECISION" + "fuel multiplier for perp maker", + "precision: 10" ], - "type": "u64" + "type": "u8" }, { - "name": "fill_record_id", - "type": "u64" + "name": "pool_id", + "type": "u8" }, { - "name": "user_order_id", - "type": "u32" + "name": "high_leverage_margin_ratio_initial", + "type": "u16" }, { - "name": "liquidator_order_id", - "type": "u32" + "name": "high_leverage_margin_ratio_maintenance", + "type": "u16" }, { - "name": "liquidator_fee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "protected_maker_limit_price_divisor", + "type": "u8" }, { - "name": "if_fee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - } - ] - } - }, - { - "name": "LiquidateSpotRecord", - "type": { - "kind": "struct", - "fields": [ + "name": "protected_maker_dynamic_divisor", + "type": "u8" + }, { - "name": "asset_market_index", - "type": "u16" + "name": "lp_fee_transfer_scalar", + "type": "u8" }, { - "name": "asset_price", - "type": "i64" + "name": "lp_status", + "type": "u8" }, { - "name": "asset_transfer", - "type": "u128" + "name": "lp_paused_operations", + "type": "u8" }, { - "name": "liability_market_index", - "type": "u16" + "name": "lp_exchange_fee_excluscion_scalar", + "type": "u8" }, { - "name": "liability_price", - "type": "i64" + "name": "last_fill_price", + "type": "u64" }, { - "name": "liability_transfer", - "docs": [ - "precision: token mint precision" - ], - "type": "u128" + "name": "lp_pool_id", + "type": "u8" }, { - "name": "if_fee", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" + "name": "padding", + "type": { + "array": [ + "u8", + 23 + ] + } } ] } }, { - "name": "LiquidationRecord", + "name": "PerpPosition", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "ts", + "name": "last_cumulative_funding_rate", + "docs": [ + "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", + "precision: FUNDING_RATE_PRECISION" + ], "type": "i64" }, { - "name": "liquidation_type", - "type": { - "defined": { - "name": "LiquidationType" - } - } + "name": "base_asset_amount", + "docs": [ + "the size of the users perp position", + "precision: BASE_PRECISION" + ], + "type": "i64" }, { - "name": "user", - "type": "pubkey" + "name": "quote_asset_amount", + "docs": [ + "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees", + "Updated when the user open/closes position or settles pnl. Includes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" }, { - "name": "liquidator", - "type": "pubkey" + "name": "quote_break_even_amount", + "docs": [ + "The amount of quote the user would need to exit their position at to break even", + "Updated when the user open/closes position or settles pnl. Includes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" }, { - "name": "margin_requirement", - "type": "u128" + "name": "quote_entry_amount", + "docs": [ + "The amount quote the user entered the position with. Equal to base asset amount * avg entry price", + "Updated when the user open/closes position. Excludes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" }, { - "name": "total_collateral", - "type": "i128" + "name": "open_bids", + "docs": [ + "The amount of non reduce only trigger orders the user has open", + "precision: BASE_PRECISION" + ], + "type": "i64" }, { - "name": "margin_freed", - "type": "u64" + "name": "open_asks", + "docs": [ + "The amount of non reduce only trigger orders the user has open", + "precision: BASE_PRECISION" + ], + "type": "i64" }, { - "name": "liquidation_id", - "type": "u16" + "name": "settled_pnl", + "docs": [ + "The amount of pnl settled in this market since opening the position", + "precision: QUOTE_PRECISION" + ], + "type": "i64" }, { - "name": "bankrupt", - "type": "bool" + "name": "lp_shares", + "docs": [ + "The number of lp (liquidity provider) shares the user has in this perp market", + "LP shares allow users to provide liquidity via the AMM", + "precision: BASE_PRECISION" + ], + "type": "u64" }, { - "name": "canceled_order_ids", - "type": { - "vec": "u32" - } + "name": "last_base_asset_amount_per_lp", + "docs": [ + "The last base asset amount per lp the amm had", + "Used to settle the users lp position", + "precision: BASE_PRECISION" + ], + "type": "i64" }, { - "name": "liquidate_perp", - "type": { - "defined": { - "name": "LiquidatePerpRecord" - } - } + "name": "last_quote_asset_amount_per_lp", + "docs": [ + "The last quote asset amount per lp the amm had", + "Used to settle the users lp position", + "precision: QUOTE_PRECISION" + ], + "type": "i64" }, { - "name": "liquidate_spot", + "name": "padding", "type": { - "defined": { - "name": "LiquidateSpotRecord" - } + "array": [ + "u8", + 2 + ] } }, { - "name": "liquidate_borrow_for_perp_pnl", - "type": { - "defined": { - "name": "LiquidateBorrowForPerpPnlRecord" - } - } + "name": "max_margin_ratio", + "type": "u16" }, { - "name": "liquidate_perp_pnl_for_deposit", - "type": { - "defined": { - "name": "LiquidatePerpPnlForDepositRecord" - } - } + "name": "market_index", + "docs": [ + "The market index for the perp market" + ], + "type": "u16" }, { - "name": "perp_bankruptcy", - "type": { - "defined": { - "name": "PerpBankruptcyRecord" - } - } + "name": "open_orders", + "docs": [ + "The number of open orders" + ], + "type": "u8" }, { - "name": "spot_bankruptcy", - "type": { - "defined": { - "name": "SpotBankruptcyRecord" - } - } + "name": "per_lp_base", + "type": "i8" } ] } }, { - "name": "LiquidationType", + "name": "PhoenixV1FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "LiquidatePerp" + "name": "pubkey", + "type": "pubkey" }, { - "name": "LiquidateSpot" + "name": "phoenix_program_id", + "type": "pubkey" }, { - "name": "LiquidateBorrowForPerpPnl" + "name": "phoenix_log_authority", + "type": "pubkey" }, { - "name": "LiquidatePerpPnlForDeposit" + "name": "phoenix_market", + "type": "pubkey" }, { - "name": "PerpBankruptcy" + "name": "phoenix_base_vault", + "type": "pubkey" }, { - "name": "SpotBankruptcy" - } - ] - } - }, - { - "name": "LpPoolParams", - "type": { - "kind": "struct", - "fields": [ + "name": "phoenix_quote_vault", + "type": "pubkey" + }, { - "name": "max_settle_quote_amount", - "type": { - "option": "u64" - } + "name": "market_index", + "type": "u16" }, { - "name": "volatility", + "name": "fulfillment_type", "type": { - "option": "u64" + "defined": { + "name": "SpotFulfillmentType" + } } }, { - "name": "gamma_execution", + "name": "status", "type": { - "option": "u8" + "defined": { + "name": "SpotFulfillmentConfigStatus" + } } }, { - "name": "xi", + "name": "padding", "type": { - "option": "u8" + "array": [ + "u8", + 4 + ] } - }, + } + ] + } + }, + { + "name": "PoolBalance", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "max_aum", + "name": "scaled_balance", + "docs": [ + "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", + "deposit interest", + "precision: SPOT_BALANCE_PRECISION" + ], "type": { - "option": "u128" + "defined": { + "name": "u128" + } } }, { - "name": "whitelist_mint", + "name": "market_index", + "docs": [ + "The spot market the pool is for" + ], + "type": "u16" + }, + { + "name": "padding", "type": { - "option": "pubkey" + "array": [ + "u8", + 6 + ] } } ] } }, { - "name": "MarginMode", + "name": "PositionDirection", "type": { "kind": "enum", "variants": [ { - "name": "Default" - }, - { - "name": "HighLeverage" + "name": "Long" }, { - "name": "HighLeverageMaintenance" + "name": "Short" } ] } }, { - "name": "MarketStatus", + "name": "PostOnlyParam", "type": { "kind": "enum", "variants": [ { - "name": "Initialized" + "name": "None" }, { - "name": "Active" + "name": "MustPostOnly" }, { - "name": "FundingPaused" + "name": "TryPostOnly" }, { - "name": "AmmPaused" + "name": "Slide" + } + ] + } + }, + { + "name": "PrelaunchOracle", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "i64" }, { - "name": "FillPaused" + "name": "max_price", + "type": "i64" }, { - "name": "WithdrawPaused" + "name": "confidence", + "type": "u64" }, { - "name": "ReduceOnly" + "name": "last_update_slot", + "type": "u64" }, { - "name": "Settlement" + "name": "amm_last_update_slot", + "type": "u64" }, { - "name": "Delisted" + "name": "perp_market_index", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 70 + ] + } } ] } }, { - "name": "MarketType", + "name": "PrelaunchOracleParams", "type": { - "kind": "enum", - "variants": [ + "kind": "struct", + "fields": [ { - "name": "Spot" + "name": "perp_market_index", + "type": "u16" }, { - "name": "Perp" + "name": "price", + "type": { + "option": "i64" + } + }, + { + "name": "max_price", + "type": { + "option": "i64" + } } ] } }, { - "name": "ModifyOrderParams", + "name": "PriceDivergenceGuardRails", "type": { "kind": "struct", "fields": [ { - "name": "direction", - "type": { - "option": { - "defined": { - "name": "PositionDirection" - } - } - } + "name": "mark_oracle_percent_divergence", + "type": "u64" }, { - "name": "base_asset_amount", - "type": { - "option": "u64" - } + "name": "oracle_twap_5min_percent_divergence", + "type": "u64" + } + ] + } + }, + { + "name": "ProtectedMakerModeConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "max_users", + "type": "u32" }, { - "name": "price", - "type": { - "option": "u64" - } + "name": "current_users", + "type": "u32" }, { "name": "reduce_only", - "type": { - "option": "bool" - } + "type": "u8" }, { - "name": "post_only", + "name": "padding", "type": { - "option": { - "defined": { - "name": "PostOnlyParam" - } - } + "array": [ + "u8", + 31 + ] } - }, + } + ] + } + }, + { + "name": "PythLazerOracle", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "bit_flags", - "type": { - "option": "u8" - } + "name": "price", + "type": "i64" }, { - "name": "max_ts", - "type": { - "option": "i64" - } + "name": "publish_time", + "type": "u64" }, { - "name": "trigger_price", - "type": { - "option": "u64" - } + "name": "posted_slot", + "type": "u64" }, { - "name": "trigger_condition", - "type": { - "option": { - "defined": { - "name": "OrderTriggerCondition" - } - } - } + "name": "exponent", + "type": "i32" }, { - "name": "oracle_price_offset", + "name": "_padding", "type": { - "option": "i32" + "array": [ + "u8", + 4 + ] } }, { - "name": "auction_duration", - "type": { - "option": "u8" - } + "name": "conf", + "type": "u64" + } + ] + } + }, + { + "name": "ReferrerName", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" }, { - "name": "auction_start_price", - "type": { - "option": "i64" - } + "name": "user", + "type": "pubkey" }, { - "name": "auction_end_price", - "type": { - "option": "i64" - } + "name": "user_stats", + "type": "pubkey" }, { - "name": "policy", + "name": "name", "type": { - "option": "u8" + "array": [ + "u8", + 32 + ] } } ] } }, { - "name": "NewUserRecord", + "name": "RevenueShare", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "rust", + "packed": true + }, "type": { "kind": "struct", "fields": [ { - "name": "ts", + "name": "authority", "docs": [ - "unix_timestamp of action" + "the owner of this account, a builder or referrer" ], - "type": "i64" - }, - { - "name": "user_authority", "type": "pubkey" }, { - "name": "user", - "type": "pubkey" + "name": "total_referrer_rewards", + "type": "u64" }, { - "name": "sub_account_id", - "type": "u16" + "name": "total_builder_rewards", + "type": "u64" }, { - "name": "name", + "name": "padding", "type": { "array": [ "u8", - 32 + 18 ] } - }, - { - "name": "referrer", - "type": "pubkey" } ] } }, { - "name": "OpenbookV2FulfillmentConfig", - "serialization": "bytemuckunsafe", + "name": "RevenueShareEscrow", "repr": { "kind": "c" }, @@ -22378,58 +21851,148 @@ "kind": "struct", "fields": [ { - "name": "pubkey", + "name": "authority", + "docs": [ + "the owner of this account, a user" + ], "type": "pubkey" }, { - "name": "openbook_v2_program_id", + "name": "referrer", "type": "pubkey" }, { - "name": "openbook_v2_market", - "type": "pubkey" + "name": "referrer_boost_expire_ts", + "type": "u32" }, { - "name": "openbook_v2_market_authority", - "type": "pubkey" + "name": "referrer_reward_offset", + "type": "i8" }, { - "name": "openbook_v2_event_heap", - "type": "pubkey" + "name": "referee_fee_numerator_offset", + "type": "i8" }, { - "name": "openbook_v2_bids", - "type": "pubkey" + "name": "referrer_boost_numerator", + "type": "i8" }, { - "name": "openbook_v2_asks", - "type": "pubkey" + "name": "reserved_fixed", + "type": { + "array": [ + "u8", + 17 + ] + } }, { - "name": "openbook_v2_base_vault", - "type": "pubkey" + "name": "padding0", + "type": "u32" }, { - "name": "openbook_v2_quote_vault", - "type": "pubkey" + "name": "orders", + "type": { + "vec": { + "defined": { + "name": "RevenueShareOrder" + } + } + } }, { - "name": "market_index", - "type": "u16" + "name": "padding1", + "type": "u32" }, { - "name": "fulfillment_type", + "name": "approved_builders", "type": { - "defined": { - "name": "SpotFulfillmentType" + "vec": { + "defined": { + "name": "BuilderInfo" + } } } + } + ] + } + }, + { + "name": "RevenueShareOrder", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "fees_accrued", + "docs": [ + "fees accrued so far for this order slot. This is not exclusively fees from this order_id", + "and may include fees from other orders in the same market. This may be swept to the", + "builder's SpotPosition during settle_pnl." + ], + "type": "u64" }, { - "name": "status", + "name": "order_id", + "docs": [ + "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open" + ], + "type": "u32" + }, + { + "name": "fee_tenth_bps", + "docs": [ + "the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%" + ], + "type": "u16" + }, + { + "name": "market_index", + "type": "u16" + }, + { + "name": "sub_account_id", + "docs": [ + "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open" + ], + "type": "u16" + }, + { + "name": "builder_idx", + "docs": [ + "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", + "if bit_flag = Referral." + ], + "type": "u8" + }, + { + "name": "bit_flags", + "docs": [ + "bitflags that describe the state of the order.", + "[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.", + "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", + "[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.", + "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", + "[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.", + "If it is set, no other bitflag should be set." + ], + "type": "u8" + }, + { + "name": "user_order_index", + "docs": [ + "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches." + ], + "type": "u8" + }, + { + "name": "market_type", "type": { "defined": { - "name": "SpotFulfillmentConfigStatus" + "name": "MarketType" } } }, @@ -22438,7 +22001,7 @@ "type": { "array": [ "u8", - 4 + 10 ] } } @@ -22446,4649 +22009,1223 @@ } }, { - "name": "OracleGuardRails", + "name": "RevenueShareSettleRecord", "type": { "kind": "struct", "fields": [ { - "name": "price_divergence", + "name": "ts", + "type": "i64" + }, + { + "name": "builder", "type": { - "defined": { - "name": "PriceDivergenceGuardRails" - } + "option": "pubkey" } }, { - "name": "validity", + "name": "referrer", + "type": { + "option": "pubkey" + } + }, + { + "name": "fee_settled", + "type": "u64" + }, + { + "name": "market_index", + "type": "u16" + }, + { + "name": "market_type", "type": { "defined": { - "name": "ValidityGuardRails" + "name": "MarketType" } } + }, + { + "name": "builder_sub_account_id", + "type": "u16" + }, + { + "name": "builder_total_referrer_rewards", + "type": "u64" + }, + { + "name": "builder_total_builder_rewards", + "type": "u64" } ] } }, { - "name": "OracleSource", + "name": "SerumV3FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ - { - "name": "Pyth" - }, + "kind": "struct", + "fields": [ { - "name": "Switchboard" + "name": "pubkey", + "type": "pubkey" }, { - "name": "QuoteAsset" + "name": "serum_program_id", + "type": "pubkey" }, { - "name": "Pyth1K" + "name": "serum_market", + "type": "pubkey" }, { - "name": "Pyth1M" + "name": "serum_request_queue", + "type": "pubkey" }, { - "name": "PythStableCoin" + "name": "serum_event_queue", + "type": "pubkey" }, { - "name": "Prelaunch" + "name": "serum_bids", + "type": "pubkey" }, { - "name": "PythPull" + "name": "serum_asks", + "type": "pubkey" }, { - "name": "Pyth1KPull" + "name": "serum_base_vault", + "type": "pubkey" }, { - "name": "Pyth1MPull" + "name": "serum_quote_vault", + "type": "pubkey" }, { - "name": "PythStableCoinPull" + "name": "serum_open_orders", + "type": "pubkey" }, { - "name": "SwitchboardOnDemand" + "name": "serum_signer_nonce", + "type": "u64" }, { - "name": "PythLazer" + "name": "market_index", + "type": "u16" }, { - "name": "PythLazer1K" + "name": "fulfillment_type", + "type": { + "defined": { + "name": "SpotFulfillmentType" + } + } }, { - "name": "PythLazer1M" + "name": "status", + "type": { + "defined": { + "name": "SpotFulfillmentConfigStatus" + } + } }, { - "name": "PythLazerStableCoin" + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } } ] } }, { - "name": "Order", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, + "name": "SettlePnlExplanation", "type": { - "kind": "struct", - "fields": [ + "kind": "enum", + "variants": [ { - "name": "slot", - "docs": [ - "The slot the order was placed" - ], - "type": "u64" + "name": "None" }, { - "name": "price", - "docs": [ - "The limit price for the order (can be 0 for market orders)", - "For orders with an auction, this price isn't used until the auction is complete", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, + "name": "ExpiredPosition" + } + ] + } + }, + { + "name": "SettlePnlMode", + "type": { + "kind": "enum", + "variants": [ { - "name": "base_asset_amount", - "docs": [ - "The size of the order", - "precision for perps: BASE_PRECISION", - "precision for spot: token mint precision" - ], - "type": "u64" + "name": "MustSettle" }, { - "name": "base_asset_amount_filled", - "docs": [ - "The amount of the order filled", - "precision for perps: BASE_PRECISION", - "precision for spot: token mint precision" - ], - "type": "u64" - }, + "name": "TrySettle" + } + ] + } + }, + { + "name": "SettlePnlRecord", + "type": { + "kind": "struct", + "fields": [ { - "name": "quote_asset_amount_filled", - "docs": [ - "The amount of quote filled for the order", - "precision: QUOTE_PRECISION" - ], - "type": "u64" + "name": "ts", + "type": "i64" }, { - "name": "trigger_price", - "docs": [ - "At what price the order will be triggered. Only relevant for trigger orders", - "precision: PRICE_PRECISION" - ], - "type": "u64" + "name": "user", + "type": "pubkey" }, { - "name": "auction_start_price", - "docs": [ - "The start price for the auction. Only relevant for market/oracle orders", - "precision: PRICE_PRECISION" - ], - "type": "i64" + "name": "market_index", + "type": "u16" }, { - "name": "auction_end_price", - "docs": [ - "The end price for the auction. Only relevant for market/oracle orders", - "precision: PRICE_PRECISION" - ], - "type": "i64" + "name": "pnl", + "type": "i128" }, { - "name": "max_ts", - "docs": [ - "The time when the order will expire" - ], + "name": "base_asset_amount", "type": "i64" }, { - "name": "oracle_price_offset", - "docs": [ - "If set, the order limit price is the oracle price + this offset", - "precision: PRICE_PRECISION" - ], - "type": "i32" - }, - { - "name": "order_id", - "docs": [ - "The id for the order. Each users has their own order id space" - ], - "type": "u32" + "name": "quote_asset_amount_after", + "type": "i64" }, { - "name": "market_index", - "docs": [ - "The perp/spot market index" - ], - "type": "u16" + "name": "quote_entry_amount", + "type": "i64" }, { - "name": "status", - "docs": [ - "Whether the order is open or unused" - ], - "type": { - "defined": { - "name": "OrderStatus" - } - } + "name": "settle_price", + "type": "i64" }, { - "name": "order_type", - "docs": [ - "The type of order" - ], + "name": "explanation", "type": { "defined": { - "name": "OrderType" + "name": "SettlePnlExplanation" } } - }, + } + ] + } + }, + { + "name": "SignedMsgOrderId", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ { - "name": "market_type", - "docs": [ - "Whether market is spot or perp" - ], + "name": "uuid", "type": { - "defined": { - "name": "MarketType" - } + "array": [ + "u8", + 8 + ] } }, { - "name": "user_order_id", - "docs": [ - "User generated order id. Can make it easier to place/cancel orders" - ], - "type": "u8" - }, - { - "name": "existing_position_direction", - "docs": [ - "What the users position was when the order was placed" - ], - "type": { - "defined": { - "name": "PositionDirection" - } - } + "name": "max_slot", + "type": "u64" }, { - "name": "direction", - "docs": [ - "Whether the user is going long or short. LONG = bid, SHORT = ask" - ], - "type": { - "defined": { - "name": "PositionDirection" - } - } + "name": "order_id", + "type": "u32" }, { - "name": "reduce_only", - "docs": [ - "Whether the order is allowed to only reduce position size" - ], - "type": "bool" - }, + "name": "padding", + "type": "u32" + } + ] + } + }, + { + "name": "SignedMsgOrderRecord", + "type": { + "kind": "struct", + "fields": [ { - "name": "post_only", - "docs": [ - "Whether the order must be a maker" - ], - "type": "bool" + "name": "user", + "type": "pubkey" }, { - "name": "immediate_or_cancel", - "docs": [ - "Whether the order must be canceled the same slot it is placed" - ], - "type": "bool" + "name": "hash", + "type": "string" }, { - "name": "trigger_condition", - "docs": [ - "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders" - ], + "name": "matching_order_params", "type": { "defined": { - "name": "OrderTriggerCondition" + "name": "OrderParams" } } }, { - "name": "auction_duration", - "docs": [ - "How many slots the auction lasts" - ], - "type": "u8" - }, - { - "name": "posted_slot_tail", - "docs": [ - "Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)" - ], - "type": "u8" + "name": "user_order_id", + "type": "u32" }, { - "name": "bit_flags", - "docs": [ - "Bitflags for further classification", - "0: is_signed_message" - ], - "type": "u8" + "name": "signed_msg_order_max_slot", + "type": "u64" }, { - "name": "padding", + "name": "signed_msg_order_uuid", "type": { "array": [ "u8", - 1 + 8 ] } + }, + { + "name": "ts", + "type": "i64" } ] } }, { - "name": "OrderAction", + "name": "SignedMsgUserOrders", + "docs": [ + "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" + ], + "repr": { + "kind": "c" + }, "type": { - "kind": "enum", - "variants": [ - { - "name": "Place" - }, + "kind": "struct", + "fields": [ { - "name": "Cancel" + "name": "authority_pubkey", + "type": "pubkey" }, { - "name": "Fill" + "name": "padding", + "type": "u32" }, { - "name": "Trigger" - }, + "name": "signed_msg_order_data", + "type": { + "vec": { + "defined": { + "name": "SignedMsgOrderId" + } + } + } + } + ] + } + }, + { + "name": "SignedMsgWsDelegates", + "docs": [ + "* Used to store authenticated delegates for swift-like ws connections" + ], + "type": { + "kind": "struct", + "fields": [ { - "name": "Expire" + "name": "delegates", + "type": { + "vec": "pubkey" + } } ] } }, { - "name": "OrderActionExplanation", + "name": "SpotBalanceType", "type": { "kind": "enum", "variants": [ { - "name": "None" + "name": "Deposit" }, { - "name": "InsufficientFreeCollateral" - }, + "name": "Borrow" + } + ] + } + }, + { + "name": "SpotBankruptcyRecord", + "type": { + "kind": "struct", + "fields": [ { - "name": "OraclePriceBreachedLimitPrice" + "name": "market_index", + "type": "u16" }, { - "name": "MarketOrderFilledToLimitPrice" + "name": "borrow_amount", + "type": "u128" }, { - "name": "OrderExpired" + "name": "if_payment", + "type": "u128" }, { - "name": "Liquidation" - }, + "name": "cumulative_deposit_interest_delta", + "type": "u128" + } + ] + } + }, + { + "name": "SpotFulfillmentConfigStatus", + "type": { + "kind": "enum", + "variants": [ { - "name": "OrderFilledWithAMM" + "name": "Enabled" }, { - "name": "OrderFilledWithAMMJit" - }, + "name": "Disabled" + } + ] + } + }, + { + "name": "SpotFulfillmentType", + "type": { + "kind": "enum", + "variants": [ { - "name": "OrderFilledWithMatch" + "name": "SerumV3" }, { - "name": "OrderFilledWithMatchJit" + "name": "Match" }, { - "name": "MarketExpired" + "name": "PhoenixV1" }, { - "name": "RiskingIncreasingOrder" - }, + "name": "OpenbookV2" + } + ] + } + }, + { + "name": "SpotInterestRecord", + "type": { + "kind": "struct", + "fields": [ { - "name": "ReduceOnlyOrderIncreasedPosition" + "name": "ts", + "type": "i64" }, { - "name": "OrderFillWithSerum" + "name": "market_index", + "type": "u16" }, { - "name": "NoBorrowLiquidity" + "name": "deposit_balance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" }, { - "name": "OrderFillWithPhoenix" + "name": "cumulative_deposit_interest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" }, { - "name": "OrderFilledWithAMMJitLPSplit" + "name": "borrow_balance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" }, { - "name": "OrderFilledWithLPJit" + "name": "cumulative_borrow_interest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" }, { - "name": "DeriskLp" + "name": "optimal_utilization", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" }, { - "name": "OrderFilledWithOpenbookV2" + "name": "optimal_borrow_rate", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" }, { - "name": "TransferPerpPosition" + "name": "max_borrow_rate", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" } ] } }, { - "name": "OrderActionRecord", + "name": "SpotMarket", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, "type": { "kind": "struct", "fields": [ { - "name": "ts", - "type": "i64" + "name": "pubkey", + "docs": [ + "The address of the spot market. It is a pda of the market index" + ], + "type": "pubkey" }, { - "name": "action", - "type": { - "defined": { - "name": "OrderAction" - } - } + "name": "oracle", + "docs": [ + "The oracle used to price the markets deposits/borrows" + ], + "type": "pubkey" }, { - "name": "action_explanation", - "type": { - "defined": { - "name": "OrderActionExplanation" - } - } + "name": "mint", + "docs": [ + "The token mint of the market" + ], + "type": "pubkey" }, { - "name": "market_index", - "type": "u16" + "name": "vault", + "docs": [ + "The vault used to store the market's deposits", + "The amount in the vault should be equal to or greater than deposits - borrows" + ], + "type": "pubkey" }, { - "name": "market_type", + "name": "name", + "docs": [ + "The encoded display name for the market e.g. SOL" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "historical_oracle_data", "type": { "defined": { - "name": "MarketType" + "name": "HistoricalOracleData" } } }, { - "name": "filler", + "name": "historical_index_data", "type": { - "option": "pubkey" + "defined": { + "name": "HistoricalIndexData" + } } }, { - "name": "filler_reward", + "name": "revenue_pool", "docs": [ - "precision: QUOTE_PRECISION" + "Revenue the protocol has collected in this markets token", + "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" ], "type": { - "option": "u64" + "defined": { + "name": "PoolBalance" + } } }, { - "name": "fill_record_id", + "name": "spot_fee_pool", + "docs": [ + "The fees collected from swaps between this market and the quote market", + "Is settled to the quote markets revenue pool" + ], "type": { - "option": "u64" + "defined": { + "name": "PoolBalance" + } } }, { - "name": "base_asset_amount_filled", + "name": "insurance_fund", "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + "Details on the insurance fund covering bankruptcies in this markets token", + "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" ], "type": { - "option": "u64" + "defined": { + "name": "InsuranceFund" + } } }, { - "name": "quote_asset_amount_filled", + "name": "total_spot_fee", "docs": [ + "The total spot fees collected for this market", "precision: QUOTE_PRECISION" ], "type": { - "option": "u64" + "defined": { + "name": "u128" + } } }, { - "name": "taker_fee", + "name": "deposit_balance", "docs": [ - "precision: QUOTE_PRECISION" + "The sum of the scaled balances for deposits across users and pool balances", + "To convert to the deposit token amount, multiply by the cumulative deposit interest", + "precision: SPOT_BALANCE_PRECISION" ], "type": { - "option": "u64" + "defined": { + "name": "u128" + } } }, { - "name": "maker_fee", + "name": "borrow_balance", "docs": [ - "precision: QUOTE_PRECISION" + "The sum of the scaled balances for borrows across users and pool balances", + "To convert to the borrow token amount, multiply by the cumulative borrow interest", + "precision: SPOT_BALANCE_PRECISION" ], "type": { - "option": "i64" + "defined": { + "name": "u128" + } } }, { - "name": "referrer_reward", + "name": "cumulative_deposit_interest", "docs": [ - "precision: QUOTE_PRECISION" + "The cumulative interest earned by depositors", + "Used to calculate the deposit token amount from the deposit balance", + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" ], "type": { - "option": "u32" + "defined": { + "name": "u128" + } } }, { - "name": "quote_asset_amount_surplus", + "name": "cumulative_borrow_interest", "docs": [ - "precision: QUOTE_PRECISION" + "The cumulative interest earned by borrowers", + "Used to calculate the borrow token amount from the borrow balance", + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" ], "type": { - "option": "i64" + "defined": { + "name": "u128" + } } }, { - "name": "spot_fulfillment_method_fee", + "name": "total_social_loss", "docs": [ - "precision: QUOTE_PRECISION" + "The total socialized loss from borrows, in the mint's token", + "precision: token mint precision" ], "type": { - "option": "u64" - } - }, - { - "name": "taker", - "type": { - "option": "pubkey" - } - }, - { - "name": "taker_order_id", - "type": { - "option": "u32" + "defined": { + "name": "u128" + } } }, { - "name": "taker_order_direction", + "name": "total_quote_social_loss", + "docs": [ + "The total socialized loss from borrows, in the quote market's token", + "preicision: QUOTE_PRECISION" + ], "type": { - "option": { - "defined": { - "name": "PositionDirection" - } + "defined": { + "name": "u128" } } }, { - "name": "taker_order_base_asset_amount", + "name": "withdraw_guard_threshold", "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + "no withdraw limits/guards when deposits below this threshold", + "precision: token mint precision" ], - "type": { - "option": "u64" - } + "type": "u64" }, { - "name": "taker_order_cumulative_base_asset_amount_filled", + "name": "max_token_deposits", "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + "The max amount of token deposits in this market", + "0 if there is no limit", + "precision: token mint precision" ], - "type": { - "option": "u64" - } + "type": "u64" }, { - "name": "taker_order_cumulative_quote_asset_amount_filled", + "name": "deposit_token_twap", "docs": [ - "precision: QUOTE_PRECISION" + "24hr average of deposit token amount", + "precision: token mint precision" ], - "type": { - "option": "u64" - } + "type": "u64" }, { - "name": "maker", - "type": { - "option": "pubkey" - } + "name": "borrow_token_twap", + "docs": [ + "24hr average of borrow token amount", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "maker_order_id", - "type": { - "option": "u32" - } + "name": "utilization_twap", + "docs": [ + "24hr average of utilization", + "which is borrow amount over token amount", + "precision: SPOT_UTILIZATION_PRECISION" + ], + "type": "u64" }, { - "name": "maker_order_direction", - "type": { - "option": { - "defined": { - "name": "PositionDirection" - } - } - } + "name": "last_interest_ts", + "docs": [ + "Last time the cumulative deposit and borrow interest was updated" + ], + "type": "u64" }, { - "name": "maker_order_base_asset_amount", + "name": "last_twap_ts", "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + "Last time the deposit/borrow/utilization averages were updated" ], - "type": { - "option": "u64" - } + "type": "u64" }, { - "name": "maker_order_cumulative_base_asset_amount_filled", + "name": "expiry_ts", "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + "The time the market is set to expire. Only set if market is in reduce only mode" ], - "type": { - "option": "u64" - } + "type": "i64" }, { - "name": "maker_order_cumulative_quote_asset_amount_filled", + "name": "order_step_size", "docs": [ - "precision: QUOTE_PRECISION" + "Spot orders must be a multiple of the step size", + "precision: token mint precision" ], - "type": { - "option": "u64" - } + "type": "u64" }, { - "name": "oracle_price", + "name": "order_tick_size", "docs": [ + "Spot orders must be a multiple of the tick size", "precision: PRICE_PRECISION" ], - "type": "i64" + "type": "u64" }, { - "name": "bit_flags", + "name": "min_order_size", "docs": [ - "Bit flags:", - "0: is_signed_message" + "The minimum order size", + "precision: token mint precision" ], - "type": "u8" + "type": "u64" }, { - "name": "taker_existing_quote_entry_amount", + "name": "max_position_size", "docs": [ - "precision: QUOTE_PRECISION", - "Only Some if the taker reduced position" + "The maximum spot position size", + "if the limit is 0, there is no limit", + "precision: token mint precision" ], - "type": { - "option": "u64" - } + "type": "u64" }, { - "name": "taker_existing_base_asset_amount", + "name": "next_fill_record_id", "docs": [ - "precision: BASE_PRECISION", - "Only Some if the taker flipped position direction" + "Every spot trade has a fill record id. This is the next id to use" ], - "type": { - "option": "u64" - } + "type": "u64" }, { - "name": "maker_existing_quote_entry_amount", + "name": "next_deposit_record_id", "docs": [ - "precision: QUOTE_PRECISION", - "Only Some if the maker reduced position" + "Every deposit has a deposit record id. This is the next id to use" ], - "type": { - "option": "u64" - } + "type": "u64" }, { - "name": "maker_existing_base_asset_amount", + "name": "initial_asset_weight", "docs": [ - "precision: BASE_PRECISION", - "Only Some if the maker flipped position direction" + "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", + "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", + "precision: SPOT_WEIGHT_PRECISION" ], - "type": { - "option": "u64" - } + "type": "u32" }, { - "name": "trigger_price", + "name": "maintenance_asset_weight", "docs": [ - "precision: PRICE_PRECISION" + "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", + "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", + "precision: SPOT_WEIGHT_PRECISION" ], - "type": { - "option": "u64" - } + "type": "u32" }, { - "name": "builder_idx", + "name": "initial_liability_weight", "docs": [ - "the idx of the builder in the taker's [`RevenueShareEscrow`] account" + "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", + "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", + "precision: SPOT_WEIGHT_PRECISION" ], - "type": { - "option": "u8" - } + "type": "u32" }, { - "name": "builder_fee", + "name": "maintenance_liability_weight", "docs": [ - "precision: QUOTE_PRECISION builder fee paid by the taker" + "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", + "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", + "precision: SPOT_WEIGHT_PRECISION" ], - "type": { - "option": "u64" - } - } - ] - } - }, - { - "name": "OrderFillerRewardStructure", - "type": { - "kind": "struct", - "fields": [ - { - "name": "reward_numerator", "type": "u32" }, { - "name": "reward_denominator", - "type": "u32" - }, - { - "name": "time_based_reward_lower_bound", - "type": { - "defined": { - "name": "u128" - } - } - } - ] - } - }, - { - "name": "OrderParams", - "type": { - "kind": "struct", - "fields": [ + "name": "imf_factor", + "docs": [ + "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, { - "name": "order_type", - "type": { - "defined": { - "name": "OrderType" - } - } + "name": "liquidator_fee", + "docs": [ + "The fee the liquidator is paid for taking over borrow/deposit", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" }, { - "name": "market_type", - "type": { - "defined": { - "name": "MarketType" - } - } + "name": "if_liquidation_fee", + "docs": [ + "The fee the insurance fund receives from liquidation", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" }, { - "name": "direction", - "type": { - "defined": { - "name": "PositionDirection" - } - } + "name": "optimal_utilization", + "docs": [ + "The optimal utilization rate for this market.", + "Used to determine the markets borrow rate", + "precision: SPOT_UTILIZATION_PRECISION" + ], + "type": "u32" }, { - "name": "user_order_id", - "type": "u8" + "name": "optimal_borrow_rate", + "docs": [ + "The borrow rate for this market when the market has optimal utilization", + "precision: SPOT_RATE_PRECISION" + ], + "type": "u32" }, { - "name": "base_asset_amount", - "type": "u64" + "name": "max_borrow_rate", + "docs": [ + "The borrow rate for this market when the market has 1000 utilization", + "precision: SPOT_RATE_PRECISION" + ], + "type": "u32" }, { - "name": "price", - "type": "u64" + "name": "decimals", + "docs": [ + "The market's token mint's decimals. To from decimals to a precision, 10^decimals" + ], + "type": "u32" }, { "name": "market_index", "type": "u16" }, { - "name": "reduce_only", + "name": "orders_enabled", + "docs": [ + "Whether or not spot trading is enabled" + ], "type": "bool" }, { - "name": "post_only", + "name": "oracle_source", "type": { "defined": { - "name": "PostOnlyParam" + "name": "OracleSource" } } }, { - "name": "bit_flags", - "type": "u8" - }, - { - "name": "max_ts", - "type": { - "option": "i64" - } - }, - { - "name": "trigger_price", + "name": "status", "type": { - "option": "u64" + "defined": { + "name": "MarketStatus" + } } }, { - "name": "trigger_condition", + "name": "asset_tier", + "docs": [ + "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" + ], "type": { "defined": { - "name": "OrderTriggerCondition" + "name": "AssetTier" } } }, { - "name": "oracle_price_offset", - "type": { - "option": "i32" - } + "name": "paused_operations", + "type": "u8" }, { - "name": "auction_duration", - "type": { - "option": "u8" - } + "name": "if_paused_operations", + "type": "u8" }, { - "name": "auction_start_price", - "type": { - "option": "i64" - } + "name": "fee_adjustment", + "type": "i16" }, { - "name": "auction_end_price", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "OrderRecord", - "type": { - "kind": "struct", - "fields": [ + "name": "max_token_borrows_fraction", + "docs": [ + "What fraction of max_token_deposits", + "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", + "precision: X/10000" + ], + "type": "u16" + }, { - "name": "ts", - "type": "i64" + "name": "flash_loan_amount", + "docs": [ + "For swaps, the amount of token loaned out in the begin_swap ix", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "user", - "type": "pubkey" + "name": "flash_loan_initial_token_amount", + "docs": [ + "For swaps, the amount in the users token account in the begin_swap ix", + "Used to calculate how much of the token left the system in end_swap ix", + "precision: token mint precision" + ], + "type": "u64" }, { - "name": "order", - "type": { - "defined": { - "name": "Order" - } - } - } - ] - } - }, - { - "name": "OrderStatus", - "type": { - "kind": "enum", - "variants": [ + "name": "total_swap_fee", + "docs": [ + "The total fees received from swaps", + "precision: token mint precision" + ], + "type": "u64" + }, { - "name": "Init" + "name": "scale_initial_asset_weight_start", + "docs": [ + "When to begin scaling down the initial asset weight", + "disabled when 0", + "precision: QUOTE_PRECISION" + ], + "type": "u64" }, { - "name": "Open" + "name": "min_borrow_rate", + "docs": [ + "The min borrow rate for this market when the market regardless of utilization", + "1 => 1/200 => .5%", + "precision: X/200" + ], + "type": "u8" }, { - "name": "Filled" + "name": "fuel_boost_deposits", + "docs": [ + "fuel multiplier for spot deposits", + "precision: 10" + ], + "type": "u8" }, { - "name": "Canceled" - } - ] - } - }, - { - "name": "OrderTriggerCondition", - "type": { - "kind": "enum", - "variants": [ + "name": "fuel_boost_borrows", + "docs": [ + "fuel multiplier for spot borrows", + "precision: 10" + ], + "type": "u8" + }, { - "name": "Above" + "name": "fuel_boost_taker", + "docs": [ + "fuel multiplier for spot taker", + "precision: 10" + ], + "type": "u8" }, { - "name": "Below" + "name": "fuel_boost_maker", + "docs": [ + "fuel multiplier for spot maker", + "precision: 10" + ], + "type": "u8" }, { - "name": "TriggeredAbove" + "name": "fuel_boost_insurance", + "docs": [ + "fuel multiplier for spot insurance stake", + "precision: 10" + ], + "type": "u8" }, { - "name": "TriggeredBelow" - } - ] - } - }, - { - "name": "OrderType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Market" - }, - { - "name": "Limit" - }, - { - "name": "TriggerMarket" - }, - { - "name": "TriggerLimit" - }, - { - "name": "Oracle" - } - ] - } - }, - { - "name": "OverrideAmmCacheParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quote_owed_from_lp_pool", - "type": { - "option": "i64" - } - }, - { - "name": "last_settle_slot", - "type": { - "option": "u64" - } - }, - { - "name": "last_fee_pool_token_amount", - "type": { - "option": "u128" - } - }, - { - "name": "last_net_pnl_pool_token_amount", - "type": { - "option": "i128" - } - }, - { - "name": "amm_position_scalar", - "type": { - "option": "u8" - } - }, - { - "name": "amm_inventory_limit", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "PerpBankruptcyRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "market_index", - "type": "u16" - }, - { - "name": "pnl", - "type": "i128" - }, - { - "name": "if_payment", - "type": "u128" - }, - { - "name": "clawback_user", - "type": { - "option": "pubkey" - } - }, - { - "name": "clawback_user_payment", - "type": { - "option": "u128" - } - }, - { - "name": "cumulative_funding_rate_delta", - "type": "i128" - } - ] - } - }, - { - "name": "PerpMarket", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "The perp market's address. It is a pda of the market index" - ], - "type": "pubkey" - }, - { - "name": "amm", - "docs": [ - "The automated market maker" - ], - "type": { - "defined": { - "name": "AMM" - } - } + "name": "token_program_flag", + "type": "u8" }, { - "name": "pnl_pool", - "docs": [ - "The market's pnl pool. When users settle negative pnl, the balance increases.", - "When users settle positive pnl, the balance decreases. Can not go negative." - ], - "type": { - "defined": { - "name": "PoolBalance" - } - } + "name": "pool_id", + "type": "u8" }, { - "name": "name", - "docs": [ - "Encoded display name for the perp market e.g. SOL-PERP" - ], + "name": "padding", "type": { "array": [ "u8", - 32 + 40 ] } - }, - { - "name": "insurance_claim", - "docs": [ - "The perp market's claim on the insurance fund" - ], - "type": { - "defined": { - "name": "InsuranceClaim" - } - } - }, - { - "name": "unrealized_pnl_max_imbalance", - "docs": [ - "The max pnl imbalance before positive pnl asset weight is discounted", - "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", - "the amm has negative pnl and the initial asset weight for positive pnl is discounted", - "precision = QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "expiry_ts", - "docs": [ - "The ts when the market will be expired. Only set if market is in reduce only mode" - ], - "type": "i64" - }, - { - "name": "expiry_price", - "docs": [ - "The price at which positions will be settled. Only set if market is expired", - "precision = PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "next_fill_record_id", - "docs": [ - "Every trade has a fill record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "next_funding_rate_record_id", - "docs": [ - "Every funding rate update has a record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "next_curve_record_id", - "docs": [ - "Every amm k updated has a record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "imf_factor", - "docs": [ - "The initial margin fraction factor. Used to increase margin ratio for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealized_pnl_imf_factor", - "docs": [ - "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "liquidator_fee", - "docs": [ - "The fee the liquidator is paid for taking over perp position", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "if_liquidation_fee", - "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "margin_ratio_initial", - "docs": [ - "The margin ratio which determines how much collateral is required to open a position", - "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "margin_ratio_maintenance", - "docs": [ - "The margin ratio which determines when a user will be liquidated", - "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", - "else they will be liquidated", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealized_pnl_initial_asset_weight", - "docs": [ - "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealized_pnl_maintenance_asset_weight", - "docs": [ - "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "number_of_users_with_base", - "docs": [ - "number of users in a position (base)" - ], - "type": "u32" - }, - { - "name": "number_of_users", - "docs": [ - "number of users in a position (pnl) or pnl (quote)" - ], - "type": "u32" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "status", - "docs": [ - "Whether a market is active, reduce only, expired, etc", - "Affects whether users can open/close positions" - ], - "type": { - "defined": { - "name": "MarketStatus" - } - } - }, - { - "name": "contract_type", - "docs": [ - "Currently only Perpetual markets are supported" - ], - "type": { - "defined": { - "name": "ContractType" - } - } - }, - { - "name": "contract_tier", - "docs": [ - "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", - "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" - ], - "type": { - "defined": { - "name": "ContractTier" - } - } - }, - { - "name": "paused_operations", - "type": "u8" - }, - { - "name": "quote_spot_market_index", - "docs": [ - "The spot market that pnl is settled in" - ], - "type": "u16" - }, - { - "name": "fee_adjustment", - "docs": [ - "Between -100 and 100, represents what % to increase/decrease the fee by", - "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", - "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" - ], - "type": "i16" - }, - { - "name": "fuel_boost_position", - "docs": [ - "fuel multiplier for perp funding", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuel_boost_taker", - "docs": [ - "fuel multiplier for perp taker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuel_boost_maker", - "docs": [ - "fuel multiplier for perp maker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "pool_id", - "type": "u8" - }, - { - "name": "high_leverage_margin_ratio_initial", - "type": "u16" - }, - { - "name": "high_leverage_margin_ratio_maintenance", - "type": "u16" - }, - { - "name": "protected_maker_limit_price_divisor", - "type": "u8" - }, - { - "name": "protected_maker_dynamic_divisor", - "type": "u8" - }, - { - "name": "lp_fee_transfer_scalar", - "type": "u8" - }, - { - "name": "lp_status", - "type": "u8" - }, - { - "name": "lp_paused_operations", - "type": "u8" - }, - { - "name": "lp_exchange_fee_excluscion_scalar", - "type": "u8" - }, - { - "name": "last_fill_price", - "type": "u64" - }, - { - "name": "lp_pool_id", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 23 - ] - } - } - ] - } - }, - { - "name": "PerpPosition", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "last_cumulative_funding_rate", - "docs": [ - "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "base_asset_amount", - "docs": [ - "the size of the users perp position", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quote_asset_amount", - "docs": [ - "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees", - "Updated when the user open/closes position or settles pnl. Includes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quote_break_even_amount", - "docs": [ - "The amount of quote the user would need to exit their position at to break even", - "Updated when the user open/closes position or settles pnl. Includes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quote_entry_amount", - "docs": [ - "The amount quote the user entered the position with. Equal to base asset amount * avg entry price", - "Updated when the user open/closes position. Excludes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "open_bids", - "docs": [ - "The amount of non reduce only trigger orders the user has open", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "open_asks", - "docs": [ - "The amount of non reduce only trigger orders the user has open", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "settled_pnl", - "docs": [ - "The amount of pnl settled in this market since opening the position", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lp_shares", - "docs": [ - "The number of lp (liquidity provider) shares the user has in this perp market", - "LP shares allow users to provide liquidity via the AMM", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "last_base_asset_amount_per_lp", - "docs": [ - "The last base asset amount per lp the amm had", - "Used to settle the users lp position", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "last_quote_asset_amount_per_lp", - "docs": [ - "The last quote asset amount per lp the amm had", - "Used to settle the users lp position", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 2 - ] - } - }, - { - "name": "max_margin_ratio", - "type": "u16" - }, - { - "name": "market_index", - "docs": [ - "The market index for the perp market" - ], - "type": "u16" - }, - { - "name": "open_orders", - "docs": [ - "The number of open orders" - ], - "type": "u8" - }, - { - "name": "per_lp_base", - "type": "i8" - } - ] - } - }, - { - "name": "PhoenixV1FulfillmentConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "phoenix_program_id", - "type": "pubkey" - }, - { - "name": "phoenix_log_authority", - "type": "pubkey" - }, - { - "name": "phoenix_market", - "type": "pubkey" - }, - { - "name": "phoenix_base_vault", - "type": "pubkey" - }, - { - "name": "phoenix_quote_vault", - "type": "pubkey" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "fulfillment_type", - "type": { - "defined": { - "name": "SpotFulfillmentType" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "SpotFulfillmentConfigStatus" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "PoolBalance", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "scaled_balance", - "docs": [ - "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", - "deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "market_index", - "docs": [ - "The spot market the pool is for" - ], - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 6 - ] - } - } - ] - } - }, - { - "name": "PositionDirection", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Long" - }, - { - "name": "Short" - } - ] - } - }, - { - "name": "PostOnlyParam", - "type": { - "kind": "enum", - "variants": [ - { - "name": "None" - }, - { - "name": "MustPostOnly" - }, - { - "name": "TryPostOnly" - }, - { - "name": "Slide" - } - ] - } - }, - { - "name": "PrelaunchOracle", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "price", - "type": "i64" - }, - { - "name": "max_price", - "type": "i64" - }, - { - "name": "confidence", - "type": "u64" - }, - { - "name": "last_update_slot", - "type": "u64" - }, - { - "name": "amm_last_update_slot", - "type": "u64" - }, - { - "name": "perp_market_index", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 70 - ] - } - } - ] - } - }, - { - "name": "PrelaunchOracleParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perp_market_index", - "type": "u16" - }, - { - "name": "price", - "type": { - "option": "i64" - } - }, - { - "name": "max_price", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "PriceDivergenceGuardRails", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mark_oracle_percent_divergence", - "type": "u64" - }, - { - "name": "oracle_twap_5min_percent_divergence", - "type": "u64" - } - ] - } - }, - { - "name": "ProtectedMakerModeConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "max_users", - "type": "u32" - }, - { - "name": "current_users", - "type": "u32" - }, - { - "name": "reduce_only", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 31 - ] - } - } - ] - } - }, - { - "name": "PythLazerOracle", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "price", - "type": "i64" - }, - { - "name": "publish_time", - "type": "u64" - }, - { - "name": "posted_slot", - "type": "u64" - }, - { - "name": "exponent", - "type": "i32" - }, - { - "name": "_padding", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "conf", - "type": "u64" - } - ] - } - }, - { - "name": "ReferrerName", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "user_stats", - "type": "pubkey" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "RevenueShare", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "rust", - "packed": true - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "the owner of this account, a builder or referrer" - ], - "type": "pubkey" - }, - { - "name": "total_referrer_rewards", - "type": "u64" - }, - { - "name": "total_builder_rewards", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 18 - ] - } - } - ] - } - }, - { - "name": "RevenueShareEscrow", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "the owner of this account, a user" - ], - "type": "pubkey" - }, - { - "name": "referrer", - "type": "pubkey" - }, - { - "name": "referrer_boost_expire_ts", - "type": "u32" - }, - { - "name": "referrer_reward_offset", - "type": "i8" - }, - { - "name": "referee_fee_numerator_offset", - "type": "i8" - }, - { - "name": "referrer_boost_numerator", - "type": "i8" - }, - { - "name": "reserved_fixed", - "type": { - "array": [ - "u8", - 17 - ] - } - }, - { - "name": "padding0", - "type": "u32" - }, - { - "name": "orders", - "type": { - "vec": { - "defined": { - "name": "RevenueShareOrder" - } - } - } - }, - { - "name": "padding1", - "type": "u32" - }, - { - "name": "approved_builders", - "type": { - "vec": { - "defined": { - "name": "BuilderInfo" - } - } - } - } - ] - } - }, - { - "name": "RevenueShareOrder", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "fees_accrued", - "docs": [ - "fees accrued so far for this order slot. This is not exclusively fees from this order_id", - "and may include fees from other orders in the same market. This may be swept to the", - "builder's SpotPosition during settle_pnl." - ], - "type": "u64" - }, - { - "name": "order_id", - "docs": [ - "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open" - ], - "type": "u32" - }, - { - "name": "fee_tenth_bps", - "docs": [ - "the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%" - ], - "type": "u16" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "sub_account_id", - "docs": [ - "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open" - ], - "type": "u16" - }, - { - "name": "builder_idx", - "docs": [ - "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", - "if bit_flag = Referral." - ], - "type": "u8" - }, - { - "name": "bit_flags", - "docs": [ - "bitflags that describe the state of the order.", - "[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.", - "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", - "[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.", - "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", - "[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.", - "If it is set, no other bitflag should be set." - ], - "type": "u8" - }, - { - "name": "user_order_index", - "docs": [ - "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches." - ], - "type": "u8" - }, - { - "name": "market_type", - "type": { - "defined": { - "name": "MarketType" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 10 - ] - } - } - ] - } - }, - { - "name": "RevenueShareSettleRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "builder", - "type": { - "option": "pubkey" - } - }, - { - "name": "referrer", - "type": { - "option": "pubkey" - } - }, - { - "name": "fee_settled", - "type": "u64" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "market_type", - "type": { - "defined": { - "name": "MarketType" - } - } - }, - { - "name": "builder_sub_account_id", - "type": "u16" - }, - { - "name": "builder_total_referrer_rewards", - "type": "u64" - }, - { - "name": "builder_total_builder_rewards", - "type": "u64" - } - ] - } - }, - { - "name": "SerumV3FulfillmentConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "serum_program_id", - "type": "pubkey" - }, - { - "name": "serum_market", - "type": "pubkey" - }, - { - "name": "serum_request_queue", - "type": "pubkey" - }, - { - "name": "serum_event_queue", - "type": "pubkey" - }, - { - "name": "serum_bids", - "type": "pubkey" - }, - { - "name": "serum_asks", - "type": "pubkey" - }, - { - "name": "serum_base_vault", - "type": "pubkey" - }, - { - "name": "serum_quote_vault", - "type": "pubkey" - }, - { - "name": "serum_open_orders", - "type": "pubkey" - }, - { - "name": "serum_signer_nonce", - "type": "u64" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "fulfillment_type", - "type": { - "defined": { - "name": "SpotFulfillmentType" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "SpotFulfillmentConfigStatus" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "SettlePnlExplanation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "None" - }, - { - "name": "ExpiredPosition" - } - ] - } - }, - { - "name": "SettlePnlMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "MustSettle" - }, - { - "name": "TrySettle" - } - ] - } - }, - { - "name": "SettlePnlRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "pnl", - "type": "i128" - }, - { - "name": "base_asset_amount", - "type": "i64" - }, - { - "name": "quote_asset_amount_after", - "type": "i64" - }, - { - "name": "quote_entry_amount", - "type": "i64" - }, - { - "name": "settle_price", - "type": "i64" - }, - { - "name": "explanation", - "type": { - "defined": { - "name": "SettlePnlExplanation" - } - } - } - ] - } - }, - { - "name": "SignedMsgOrderId", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "uuid", - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "max_slot", - "type": "u64" - }, - { - "name": "order_id", - "type": "u32" - }, - { - "name": "padding", - "type": "u32" - } - ] - } - }, - { - "name": "SignedMsgOrderRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "hash", - "type": "string" - }, - { - "name": "matching_order_params", - "type": { - "defined": { - "name": "OrderParams" - } - } - }, - { - "name": "user_order_id", - "type": "u32" - }, - { - "name": "signed_msg_order_max_slot", - "type": "u64" - }, - { - "name": "signed_msg_order_uuid", - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "ts", - "type": "i64" - } - ] - } - }, - { - "name": "SignedMsgUserOrders", - "docs": [ - "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" - ], - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority_pubkey", - "type": "pubkey" - }, - { - "name": "padding", - "type": "u32" - }, - { - "name": "signed_msg_order_data", - "type": { - "vec": { - "defined": { - "name": "SignedMsgOrderId" - } - } - } - } - ] - } - }, - { - "name": "SignedMsgWsDelegates", - "docs": [ - "* Used to store authenticated delegates for swift-like ws connections" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "delegates", - "type": { - "vec": "pubkey" - } - } - ] - } - }, - { - "name": "SpotBalanceType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Deposit" - }, - { - "name": "Borrow" - } - ] - } - }, - { - "name": "SpotBankruptcyRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "market_index", - "type": "u16" - }, - { - "name": "borrow_amount", - "type": "u128" - }, - { - "name": "if_payment", - "type": "u128" - }, - { - "name": "cumulative_deposit_interest_delta", - "type": "u128" - } - ] - } - }, - { - "name": "SpotFulfillmentConfigStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Enabled" - }, - { - "name": "Disabled" - } - ] - } - }, - { - "name": "SpotFulfillmentType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "SerumV3" - }, - { - "name": "Match" - }, - { - "name": "PhoenixV1" - }, - { - "name": "OpenbookV2" - } - ] - } - }, - { - "name": "SpotInterestRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "deposit_balance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulative_deposit_interest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "borrow_balance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulative_borrow_interest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "optimal_utilization", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimal_borrow_rate", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "max_borrow_rate", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - } - ] - } - }, - { - "name": "SpotMarket", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "The address of the spot market. It is a pda of the market index" - ], - "type": "pubkey" - }, - { - "name": "oracle", - "docs": [ - "The oracle used to price the markets deposits/borrows" - ], - "type": "pubkey" - }, - { - "name": "mint", - "docs": [ - "The token mint of the market" - ], - "type": "pubkey" - }, - { - "name": "vault", - "docs": [ - "The vault used to store the market's deposits", - "The amount in the vault should be equal to or greater than deposits - borrows" - ], - "type": "pubkey" - }, - { - "name": "name", - "docs": [ - "The encoded display name for the market e.g. SOL" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "historical_oracle_data", - "type": { - "defined": { - "name": "HistoricalOracleData" - } - } - }, - { - "name": "historical_index_data", - "type": { - "defined": { - "name": "HistoricalIndexData" - } - } - }, - { - "name": "revenue_pool", - "docs": [ - "Revenue the protocol has collected in this markets token", - "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" - ], - "type": { - "defined": { - "name": "PoolBalance" - } - } - }, - { - "name": "spot_fee_pool", - "docs": [ - "The fees collected from swaps between this market and the quote market", - "Is settled to the quote markets revenue pool" - ], - "type": { - "defined": { - "name": "PoolBalance" - } - } - }, - { - "name": "insurance_fund", - "docs": [ - "Details on the insurance fund covering bankruptcies in this markets token", - "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" - ], - "type": { - "defined": { - "name": "InsuranceFund" - } - } - }, - { - "name": "total_spot_fee", - "docs": [ - "The total spot fees collected for this market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "deposit_balance", - "docs": [ - "The sum of the scaled balances for deposits across users and pool balances", - "To convert to the deposit token amount, multiply by the cumulative deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "borrow_balance", - "docs": [ - "The sum of the scaled balances for borrows across users and pool balances", - "To convert to the borrow token amount, multiply by the cumulative borrow interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulative_deposit_interest", - "docs": [ - "The cumulative interest earned by depositors", - "Used to calculate the deposit token amount from the deposit balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulative_borrow_interest", - "docs": [ - "The cumulative interest earned by borrowers", - "Used to calculate the borrow token amount from the borrow balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "total_social_loss", - "docs": [ - "The total socialized loss from borrows, in the mint's token", - "precision: token mint precision" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "total_quote_social_loss", - "docs": [ - "The total socialized loss from borrows, in the quote market's token", - "preicision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "withdraw_guard_threshold", - "docs": [ - "no withdraw limits/guards when deposits below this threshold", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "max_token_deposits", - "docs": [ - "The max amount of token deposits in this market", - "0 if there is no limit", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "deposit_token_twap", - "docs": [ - "24hr average of deposit token amount", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "borrow_token_twap", - "docs": [ - "24hr average of borrow token amount", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "utilization_twap", - "docs": [ - "24hr average of utilization", - "which is borrow amount over token amount", - "precision: SPOT_UTILIZATION_PRECISION" - ], - "type": "u64" - }, - { - "name": "last_interest_ts", - "docs": [ - "Last time the cumulative deposit and borrow interest was updated" - ], - "type": "u64" - }, - { - "name": "last_twap_ts", - "docs": [ - "Last time the deposit/borrow/utilization averages were updated" - ], - "type": "u64" - }, - { - "name": "expiry_ts", - "docs": [ - "The time the market is set to expire. Only set if market is in reduce only mode" - ], - "type": "i64" - }, - { - "name": "order_step_size", - "docs": [ - "Spot orders must be a multiple of the step size", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "order_tick_size", - "docs": [ - "Spot orders must be a multiple of the tick size", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "min_order_size", - "docs": [ - "The minimum order size", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "max_position_size", - "docs": [ - "The maximum spot position size", - "if the limit is 0, there is no limit", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "next_fill_record_id", - "docs": [ - "Every spot trade has a fill record id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "next_deposit_record_id", - "docs": [ - "Every deposit has a deposit record id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "initial_asset_weight", - "docs": [ - "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", - "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "maintenance_asset_weight", - "docs": [ - "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", - "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "initial_liability_weight", - "docs": [ - "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", - "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "maintenance_liability_weight", - "docs": [ - "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", - "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "imf_factor", - "docs": [ - "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "liquidator_fee", - "docs": [ - "The fee the liquidator is paid for taking over borrow/deposit", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "if_liquidation_fee", - "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimal_utilization", - "docs": [ - "The optimal utilization rate for this market.", - "Used to determine the markets borrow rate", - "precision: SPOT_UTILIZATION_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimal_borrow_rate", - "docs": [ - "The borrow rate for this market when the market has optimal utilization", - "precision: SPOT_RATE_PRECISION" - ], - "type": "u32" - }, - { - "name": "max_borrow_rate", - "docs": [ - "The borrow rate for this market when the market has 1000 utilization", - "precision: SPOT_RATE_PRECISION" - ], - "type": "u32" - }, - { - "name": "decimals", - "docs": [ - "The market's token mint's decimals. To from decimals to a precision, 10^decimals" - ], - "type": "u32" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "orders_enabled", - "docs": [ - "Whether or not spot trading is enabled" - ], - "type": "bool" - }, - { - "name": "oracle_source", - "type": { - "defined": { - "name": "OracleSource" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "MarketStatus" - } - } - }, - { - "name": "asset_tier", - "docs": [ - "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" - ], - "type": { - "defined": { - "name": "AssetTier" - } - } - }, - { - "name": "paused_operations", - "type": "u8" - }, - { - "name": "if_paused_operations", - "type": "u8" - }, - { - "name": "fee_adjustment", - "type": "i16" - }, - { - "name": "max_token_borrows_fraction", - "docs": [ - "What fraction of max_token_deposits", - "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", - "precision: X/10000" - ], - "type": "u16" - }, - { - "name": "flash_loan_amount", - "docs": [ - "For swaps, the amount of token loaned out in the begin_swap ix", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "flash_loan_initial_token_amount", - "docs": [ - "For swaps, the amount in the users token account in the begin_swap ix", - "Used to calculate how much of the token left the system in end_swap ix", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "total_swap_fee", - "docs": [ - "The total fees received from swaps", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "scale_initial_asset_weight_start", - "docs": [ - "When to begin scaling down the initial asset weight", - "disabled when 0", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "min_borrow_rate", - "docs": [ - "The min borrow rate for this market when the market regardless of utilization", - "1 => 1/200 => .5%", - "precision: X/200" - ], - "type": "u8" - }, - { - "name": "fuel_boost_deposits", - "docs": [ - "fuel multiplier for spot deposits", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuel_boost_borrows", - "docs": [ - "fuel multiplier for spot borrows", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuel_boost_taker", - "docs": [ - "fuel multiplier for spot taker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuel_boost_maker", - "docs": [ - "fuel multiplier for spot maker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuel_boost_insurance", - "docs": [ - "fuel multiplier for spot insurance stake", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "token_program_flag", - "type": "u8" - }, - { - "name": "pool_id", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 40 - ] - } - } - ] - } - }, - { - "name": "SpotMarketVaultDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "market_index", - "type": "u16" - }, - { - "name": "deposit_balance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulative_deposit_interest_before", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulative_deposit_interest_after", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "deposit_token_amount_before", - "type": "u64" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "SpotPosition", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "scaled_balance", - "docs": [ - "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", - "interest of corresponding market.", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u64" - }, - { - "name": "open_bids", - "docs": [ - "How many spot non reduce only trigger orders the user has open", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "open_asks", - "docs": [ - "How many spot non reduce only trigger orders the user has open", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "cumulative_deposits", - "docs": [ - "The cumulative deposits/borrows a user has made into a market", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "market_index", - "docs": [ - "The market index of the corresponding spot market" - ], - "type": "u16" - }, - { - "name": "balance_type", - "docs": [ - "Whether the position is deposit or borrow" - ], - "type": { - "defined": { - "name": "SpotBalanceType" - } - } - }, - { - "name": "open_orders", - "docs": [ - "Number of open orders" - ], - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "StakeAction", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Stake" - }, - { - "name": "UnstakeRequest" - }, - { - "name": "UnstakeCancelRequest" - }, - { - "name": "Unstake" - }, - { - "name": "UnstakeTransfer" - }, - { - "name": "StakeTransfer" - }, - { - "name": "AdminDeposit" - } - ] - } - }, - { - "name": "State", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "admin", - "type": "pubkey" - }, - { - "name": "whitelist_mint", - "type": "pubkey" - }, - { - "name": "discount_mint", - "type": "pubkey" - }, - { - "name": "signer", - "type": "pubkey" - }, - { - "name": "srm_vault", - "type": "pubkey" - }, - { - "name": "perp_fee_structure", - "type": { - "defined": { - "name": "FeeStructure" - } - ] - }, - { - "name": "Match", - "fields": [ - "publicKey", - "u16", - "u64" - ] - } - ] - } - }, - { - "name": "SpotFulfillmentMethod", - "type": { - "kind": "enum", - "variants": [ - { - "name": "ExternalMarket" - }, - { - "name": "Match", - "fields": [ - "publicKey", - "u16" - ] - } - ] - } - }, - { - "name": "ConstituentStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "ReduceOnly" - }, - { - "name": "Decommissioned" - } - ] - } - }, - { - "name": "MarginCalculationMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Standard", - "fields": [ - { - "name": "trackOpenOrdersFraction", - "type": "bool" - } - ] - }, - { - "name": "Liquidation", - "fields": [ - { - "name": "marketToTrackMarginRequirement", - "type": { - "option": { - "defined": "MarketIdentifier" - } - } - } - ] - } - ] - } - }, - { - "name": "OracleSource", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Pyth" - }, - { - "name": "Switchboard" - }, - { - "name": "QuoteAsset" - }, - { - "name": "Pyth1K" - }, - { - "name": "Pyth1M" - }, - { - "name": "PythStableCoin" - }, - { - "name": "Prelaunch" - }, - { - "name": "PythPull" - }, - { - "name": "Pyth1KPull" - }, - { - "name": "Pyth1MPull" - }, - { - "name": "PythStableCoinPull" - }, - { - "name": "SwitchboardOnDemand" - }, - { - "name": "PythLazer" - }, - { - "name": "PythLazer1K" - }, - { - "name": "PythLazer1M" - }, - { - "name": "PythLazerStableCoin" - } - ] - } - }, - { - "name": "OrderParamsBitFlag", - "type": { - "kind": "enum", - "variants": [ - { - "name": "ImmediateOrCancel" - }, - { - "name": "UpdateHighLeverageMode" - } - ] - } - }, - { - "name": "PostOnlyParam", - "type": { - "kind": "enum", - "variants": [ - { - "name": "None" - }, - { - "name": "MustPostOnly" - }, - { - "name": "TryPostOnly" - }, - { - "name": "Slide" - } - ] - } - }, - { - "name": "ModifyOrderPolicy", - "type": { - "kind": "enum", - "variants": [ - { - "name": "MustModify" - }, - { - "name": "ExcludePreviousFill" - } - ] - } - }, - { - "name": "PlaceAndTakeOrderSuccessCondition", - "type": { - "kind": "enum", - "variants": [ - { - "name": "PartialFill" - }, - { - "name": "FullFill" - } - ] - } - }, - { - "name": "PerpOperation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "UpdateFunding" - }, - { - "name": "AmmFill" - }, - { - "name": "Fill" - }, - { - "name": "SettlePnl" - }, - { - "name": "SettlePnlWithPosition" - }, - { - "name": "Liquidation" - }, - { - "name": "AmmImmediateFill" - }, - { - "name": "SettleRevPool" - } - ] - } - }, - { - "name": "SpotOperation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "UpdateCumulativeInterest" - }, - { - "name": "Fill" - }, - { - "name": "Deposit" - }, - { - "name": "Withdraw" - }, - { - "name": "Liquidation" - } - ] - } - }, - { - "name": "InsuranceFundOperation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Init" - }, - { - "name": "Add" - }, - { - "name": "RequestRemove" - }, - { - "name": "Remove" - } - ] - } - }, - { - "name": "PerpLpOperation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "TrackAmmRevenue" - }, - { - "name": "SettleQuoteOwed" - } - ] - } - }, - { - "name": "ConstituentLpOperation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Swap" - }, - { - "name": "Deposit" - }, - { - "name": "Withdraw" - } - ] - } - }, - { - "name": "MarketStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Initialized" - }, - { - "name": "Active" - }, - { - "name": "FundingPaused" - }, - { - "name": "AmmPaused" - }, - { - "name": "FillPaused" - }, - { - "name": "WithdrawPaused" - }, - { - "name": "ReduceOnly" - }, - { - "name": "Settlement" - }, - { - "name": "Delisted" - } - ] - } - }, - { - "name": "LpStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Uncollateralized" - }, - { - "name": "Active" - }, - { - "name": "Decommissioning" - } - ] - } - }, - { - "name": "ContractType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Perpetual" - }, - { - "name": "Future" - }, - { - "name": "Prediction" - } - ] - } - }, - { - "name": "ContractTier", - "type": { - "kind": "enum", - "variants": [ - { - "name": "A" - }, - { - "name": "B" - }, - { - "name": "C" - }, - { - "name": "Speculative" - }, - { - "name": "HighlySpeculative" - }, - { - "name": "Isolated" - } - ] - } - }, - { - "name": "RevenueShareOrderBitFlag", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Init" - }, - { - "name": "Open" - }, - { - "name": "Completed" - }, - { - "name": "Referral" - } - ] - } - }, - { - "name": "SettlePnlMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "MustSettle" - }, - { - "name": "TrySettle" - } - ] - } - }, - { - "name": "SpotBalanceType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Deposit" - }, - { - "name": "Borrow" - } - ] - } - }, - { - "name": "SpotFulfillmentConfigStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Enabled" - }, - { - "name": "Disabled" - } - ] - } - }, - { - "name": "AssetTier", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Collateral" - }, - { - "name": "Protected" - }, - { - "name": "Cross" - }, - { - "name": "Isolated" - }, - { - "name": "Unlisted" - } - ] - } - }, - { - "name": "TokenProgramFlag", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Token2022" - }, - { - "name": "TransferHook" - } - ] - } - }, - { - "name": "ExchangeStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "DepositPaused" - }, - { - "name": "WithdrawPaused" - }, - { - "name": "AmmPaused" - }, - { - "name": "FillPaused" - }, - { - "name": "LiqPaused" - }, - { - "name": "FundingPaused" - }, - { - "name": "SettlePnlPaused" - }, - { - "name": "AmmImmediateFillPaused" - } - ] - } - }, - { - "name": "FeatureBitFlags", - "type": { - "kind": "enum", - "variants": [ - { - "name": "MmOracleUpdate" - }, - { - "name": "MedianTriggerPrice" - }, - { - "name": "BuilderCodes" - }, - { - "name": "BuilderReferral" - } - ] - } - }, - { - "name": "LpPoolFeatureBitFlags", - "type": { - "kind": "enum", - "variants": [ - { - "name": "SettleLpPool" - }, - { - "name": "SwapLpPool" - }, - { - "name": "MintRedeemLpPool" - } - ] - } - }, - { - "name": "UserStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "BeingLiquidated" - }, - { - "name": "Bankrupt" - }, - { - "name": "ReduceOnly" - }, - { - "name": "AdvancedLp" - }, - { - "name": "ProtectedMakerOrders" - } - ] - } - }, - { - "name": "AssetType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Base" - }, - { - "name": "Quote" - } - ] - } - }, - { - "name": "OrderStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Init" - }, - { - "name": "Open" - }, - { - "name": "Filled" - }, - { - "name": "Canceled" - } - ] - } - }, - { - "name": "OrderType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Market" - }, - { - "name": "Limit" - }, - { - "name": "TriggerMarket" - }, - { - "name": "TriggerLimit" - }, - { - "name": "Oracle" - } - ] - } - }, - { - "name": "OrderTriggerCondition", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Above" - }, - { - "name": "Below" - }, - { - "name": "TriggeredAbove" - }, - { - "name": "TriggeredBelow" - } - ] - } - }, - { - "name": "MarketType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Spot" - }, - { - "name": "Perp" - } - ] - } - }, - { - "name": "OrderBitFlag", - "type": { - "kind": "enum", - "variants": [ - { - "name": "SignedMessage" - }, - { - "name": "OracleTriggerMarket" - }, - { - "name": "SafeTriggerOrder" - }, - { - "name": "NewTriggerReduceOnly" - }, - { - "name": "HasBuilder" - } - ] - } - }, - { - "name": "ReferrerStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "IsReferrer" - }, - { - "name": "IsReferred" - }, - { - "name": "BuilderReferral" - } - ] - } - }, - { - "name": "MarginMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Default" - }, - { - "name": "HighLeverage" - }, - { - "name": "HighLeverageMaintenance" - } - ] - } - }, - { - "name": "FuelOverflowStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Exists" - } - ] - } - }, - { - "name": "UserStatsPausedOperations", - "type": { - "kind": "enum", - "variants": [ - { - "name": "UpdateBidAskTwap" - }, - { - "name": "AmmAtomicFill" - }, - { - "name": "AmmAtomicRiskIncreasingFill" - } - ] - } - }, - { - "name": "SignatureVerificationError", - "type": { - "kind": "enum", - "variants": [ - { - "name": "InvalidEd25519InstructionProgramId" - }, - { - "name": "InvalidEd25519InstructionDataLength" - }, - { - "name": "InvalidSignatureIndex" - }, - { - "name": "InvalidSignatureOffset" - }, - { - "name": "InvalidPublicKeyOffset" - }, - { - "name": "InvalidMessageOffset" - }, - { - "name": "InvalidMessageDataSize" - }, - { - "name": "InvalidInstructionIndex" - }, - { - "name": "MessageOffsetOverflow" - }, - { - "name": "InvalidMessageHex" - }, - { - "name": "InvalidMessageData" - }, - { - "name": "LoadInstructionAtFailed" } ] } - } - ], - "events": [ - { - "name": "NewUserRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "userAuthority", - "type": "publicKey", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "subAccountId", - "type": "u16", - "index": false - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - }, - "index": false - }, - { - "name": "referrer", - "type": "publicKey", - "index": false - } - ] - }, - { - "name": "DepositRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "userAuthority", - "type": "publicKey", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "direction", - "type": { - "defined": "DepositDirection" - }, - "index": false - }, - { - "name": "depositRecordId", - "type": "u64", - "index": false - }, - { - "name": "amount", - "type": "u64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "oraclePrice", - "type": "i64", - "index": false - }, - { - "name": "marketDepositBalance", - "type": "u128", - "index": false - }, - { - "name": "marketWithdrawBalance", - "type": "u128", - "index": false - }, - { - "name": "marketCumulativeDepositInterest", - "type": "u128", - "index": false - }, - { - "name": "marketCumulativeBorrowInterest", - "type": "u128", - "index": false - }, - { - "name": "totalDepositsAfter", - "type": "u64", - "index": false - }, - { - "name": "totalWithdrawsAfter", - "type": "u64", - "index": false - }, - { - "name": "explanation", - "type": { - "defined": "DepositExplanation" - }, - "index": false - }, - { - "name": "transferUser", - "type": { - "option": "publicKey" - }, - "index": false - }, - { - "name": "signer", - "type": { - "option": "publicKey" - }, - "index": false - }, - { - "name": "userTokenAmountAfter", - "type": "i128", - "index": false - } - ] - }, - { - "name": "SpotInterestRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "depositBalance", - "type": "u128", - "index": false - }, - { - "name": "cumulativeDepositInterest", - "type": "u128", - "index": false - }, - { - "name": "borrowBalance", - "type": "u128", - "index": false - }, - { - "name": "cumulativeBorrowInterest", - "type": "u128", - "index": false - }, - { - "name": "optimalUtilization", - "type": "u32", - "index": false - }, - { - "name": "optimalBorrowRate", - "type": "u32", - "index": false - }, - { - "name": "maxBorrowRate", - "type": "u32", - "index": false - } - ] - }, - { - "name": "FundingPaymentRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "userAuthority", - "type": "publicKey", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "fundingPayment", - "type": "i64", - "index": false - }, - { - "name": "baseAssetAmount", - "type": "i64", - "index": false - }, - { - "name": "userLastCumulativeFunding", - "type": "i64", - "index": false - }, - { - "name": "ammCumulativeFundingLong", - "type": "i128", - "index": false - }, - { - "name": "ammCumulativeFundingShort", - "type": "i128", - "index": false - } - ] - }, - { - "name": "FundingRateRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "recordId", - "type": "u64", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "fundingRate", - "type": "i64", - "index": false - }, - { - "name": "fundingRateLong", - "type": "i128", - "index": false - }, - { - "name": "fundingRateShort", - "type": "i128", - "index": false - }, - { - "name": "cumulativeFundingRateLong", - "type": "i128", - "index": false - }, - { - "name": "cumulativeFundingRateShort", - "type": "i128", - "index": false - }, - { - "name": "oraclePriceTwap", - "type": "i64", - "index": false - }, - { - "name": "markPriceTwap", - "type": "u64", - "index": false - }, - { - "name": "periodRevenue", - "type": "i64", - "index": false - }, - { - "name": "baseAssetAmountWithAmm", - "type": "i128", - "index": false - }, - { - "name": "baseAssetAmountWithUnsettledLp", - "type": "i128", - "index": false - } - ] - }, - { - "name": "CurveRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "recordId", - "type": "u64", - "index": false - }, - { - "name": "pegMultiplierBefore", - "type": "u128", - "index": false - }, - { - "name": "baseAssetReserveBefore", - "type": "u128", - "index": false - }, - { - "name": "quoteAssetReserveBefore", - "type": "u128", - "index": false - }, - { - "name": "sqrtKBefore", - "type": "u128", - "index": false - }, - { - "name": "pegMultiplierAfter", - "type": "u128", - "index": false - }, - { - "name": "baseAssetReserveAfter", - "type": "u128", - "index": false - }, - { - "name": "quoteAssetReserveAfter", - "type": "u128", - "index": false - }, - { - "name": "sqrtKAfter", - "type": "u128", - "index": false - }, - { - "name": "baseAssetAmountLong", - "type": "u128", - "index": false - }, - { - "name": "baseAssetAmountShort", - "type": "u128", - "index": false - }, - { - "name": "baseAssetAmountWithAmm", - "type": "i128", - "index": false - }, - { - "name": "totalFee", - "type": "i128", - "index": false - }, - { - "name": "totalFeeMinusDistributions", - "type": "i128", - "index": false - }, - { - "name": "adjustmentCost", - "type": "i128", - "index": false - }, - { - "name": "oraclePrice", - "type": "i64", - "index": false - }, - { - "name": "fillRecord", - "type": "u128", - "index": false - }, - { - "name": "numberOfUsers", - "type": "u32", - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - } - ] - }, - { - "name": "SignedMsgOrderRecord", - "fields": [ - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "hash", - "type": "string", - "index": false - }, - { - "name": "matchingOrderParams", - "type": { - "defined": "OrderParams" - }, - "index": false - }, - { - "name": "userOrderId", - "type": "u32", - "index": false - }, - { - "name": "signedMsgOrderMaxSlot", - "type": "u64", - "index": false - }, - { - "name": "signedMsgOrderUuid", - "type": { - "array": [ - "u8", - 8 - ] - }, - "index": false - }, - { - "name": "ts", - "type": "i64", - "index": false - } - ] }, { - "name": "OrderRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "user", - "type": "publicKey", - "index": false - }, - { - "name": "order", - "type": { - "defined": "Order" + "name": "SpotMarketVaultDepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" }, - "index": false - } - ] + { + "name": "market_index", + "type": "u16" + }, + { + "name": "deposit_balance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulative_deposit_interest_before", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulative_deposit_interest_after", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "deposit_token_amount_before", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" + } + ] + } }, { - "name": "OrderActionRecord", - "fields": [ - { - "name": "ts", - "type": "i64", - "index": false - }, - { - "name": "action", - "type": { - "defined": "OrderAction" + "name": "SpotPosition", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "scaled_balance", + "docs": [ + "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", + "interest of corresponding market.", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u64" }, - "index": false - }, - { - "name": "actionExplanation", - "type": { - "defined": "OrderActionExplanation" + { + "name": "open_bids", + "docs": [ + "How many spot non reduce only trigger orders the user has open", + "precision: token mint precision" + ], + "type": "i64" }, - "index": false - }, - { - "name": "marketIndex", - "type": "u16", - "index": false - }, - { - "name": "marketType", - "type": { - "defined": "MarketType" + { + "name": "open_asks", + "docs": [ + "How many spot non reduce only trigger orders the user has open", + "precision: token mint precision" + ], + "type": "i64" }, - "index": false - }, - { - "name": "filler", - "type": { - "option": "publicKey" + { + "name": "cumulative_deposits", + "docs": [ + "The cumulative deposits/borrows a user has made into a market", + "precision: token mint precision" + ], + "type": "i64" }, - "index": false - }, - { - "name": "fillerReward", - "type": { - "option": "u64" + { + "name": "market_index", + "docs": [ + "The market index of the corresponding spot market" + ], + "type": "u16" }, - "index": false - }, - { - "name": "fillRecordId", - "type": { - "option": "u64" + { + "name": "balance_type", + "docs": [ + "Whether the position is deposit or borrow" + ], + "type": { + "defined": { + "name": "SpotBalanceType" + } + } }, - "index": false - }, - { - "name": "baseAssetAmountFilled", - "type": { - "option": "u64" + { + "name": "open_orders", + "docs": [ + "Number of open orders" + ], + "type": "u8" }, - "index": false - }, - { - "name": "quoteAssetAmountFilled", - "type": { - "option": "u64" + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "StakeAction", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Stake" }, - "index": false - }, - { - "name": "takerFee", - "type": { - "option": "u64" + { + "name": "UnstakeRequest" }, - "index": false - }, - { - "name": "makerFee", - "type": { - "option": "i64" + { + "name": "UnstakeCancelRequest" }, - "index": false - }, - { - "name": "referrerReward", - "type": { - "option": "u32" + { + "name": "Unstake" }, - "index": false - }, - { - "name": "quoteAssetAmountSurplus", - "type": { - "option": "i64" + { + "name": "UnstakeTransfer" }, - "index": false - }, - { - "name": "spotFulfillmentMethodFee", - "type": { - "option": "u64" + { + "name": "StakeTransfer" }, - "index": false - }, - { - "name": "taker", - "type": { - "option": "publicKey" + { + "name": "AdminDeposit" + } + ] + } + }, + { + "name": "State", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "admin", + "type": "pubkey" }, - "index": false - }, - { - "name": "takerOrderId", - "type": { - "option": "u32" + { + "name": "whitelist_mint", + "type": "pubkey" }, - "index": false - }, - { - "name": "takerOrderDirection", - "type": { - "option": { - "defined": "PositionDirection" + { + "name": "discount_mint", + "type": "pubkey" + }, + { + "name": "signer", + "type": "pubkey" + }, + { + "name": "srm_vault", + "type": "pubkey" + }, + { + "name": "perp_fee_structure", + "type": { + "defined": { + "name": "FeeStructure" + } } }, { @@ -27815,16 +23952,11 @@ }, { "name": "disable_update_perp_bid_ask_twap", - "type": "bool" + "type": "u8" }, { - "name": "padding1", - "type": { - "array": [ - "u8", - 1 - ] - } + "name": "paused_operations", + "type": "u8" }, { "name": "fuel_overflow_status", @@ -27959,8 +24091,5 @@ ] } } - ], - "metadata": { - "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH" - } + ] } \ No newline at end of file diff --git a/sdk/src/idl/drift.ts b/sdk/src/idl/drift.ts index 4db21d06fd..76098a5770 100644 --- a/sdk/src/idl/drift.ts +++ b/sdk/src/idl/drift.ts @@ -5,21429 +5,24097 @@ * IDL can be found at `target/idl/drift.json`. */ export type Drift = { - address: 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; - metadata: { - name: 'drift'; - version: '2.150.0'; - spec: '0.1.0'; - description: 'Created with Anchor'; - }; - instructions: [ - { - name: 'addAmmConstituentMappingData'; - discriminator: [164, 236, 130, 40, 118, 179, 46, 235]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - }, - { - name: 'ammConstituentMapping'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [65, 77, 77, 95, 77, 65, 80]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituentTargetBase'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'ammConstituentMappingData'; - type: { - vec: { - defined: { - name: 'addAmmConstituentMappingDatum'; - }; - }; - }; - }, - ]; - }, - { - name: 'addInsuranceFundStake'; - discriminator: [251, 144, 115, 11, 222, 47, 62, 236]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['insuranceFundStake', 'userStats']; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'addMarketToAmmCache'; - discriminator: [112, 149, 195, 222, 124, 7, 87, 237]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - { - name: 'perpMarket'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'adminDeposit'; - discriminator: [210, 66, 65, 182, 102, 214, 176, 30]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'adminTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'adminDisableUpdatePerpBidAskTwap'; - discriminator: [17, 164, 82, 45, 183, 86, 191, 199]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'disable'; - type: 'bool'; - }, - ]; - }, - { - name: 'beginInsuranceFundSwap'; - discriminator: [176, 69, 143, 205, 32, 132, 163, 0]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'outInsuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inInsuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outTokenAccount'; - writable: true; - }, - { - name: 'inTokenAccount'; - writable: true; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'amountIn'; - type: 'u64'; - }, - ]; - }, - { - name: 'beginLpSwap'; - discriminator: [64, 44, 24, 199, 48, 125, 67, 91]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'signerOutTokenAccount'; - docs: ['Signer token accounts']; - writable: true; - }, - { - name: 'signerInTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - docs: ['Constituent token accounts']; - writable: true; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - }, - { - name: 'outConstituent'; - docs: ['Constituents']; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpPool'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'amountIn'; - type: 'u64'; - }, - ]; - }, - { - name: 'beginSwap'; - discriminator: [174, 109, 228, 1, 242, 105, 232, 105]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'outSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outTokenAccount'; - writable: true; - }, - { - name: 'inTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'amountIn'; - type: 'u64'; - }, - ]; - }, - { - name: 'cancelOrder'; - discriminator: [95, 129, 237, 240, 8, 49, 223, 132]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'cancelOrderByUserId'; - discriminator: [107, 211, 250, 133, 18, 37, 57, 100]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'userOrderId'; - type: 'u8'; - }, - ]; - }, - { - name: 'cancelOrders'; - discriminator: [238, 225, 95, 158, 227, 103, 8, 194]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'marketType'; - type: { - option: { - defined: { - name: 'marketType'; - }; - }; - }; - }, - { - name: 'marketIndex'; - type: { - option: 'u16'; - }; - }, - { - name: 'direction'; - type: { - option: { - defined: { - name: 'positionDirection'; - }; - }; - }; - }, - ]; - }, - { - name: 'cancelOrdersByIds'; - discriminator: [134, 19, 144, 165, 94, 240, 210, 94]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'orderIds'; - type: { - vec: 'u32'; - }; - }, - ]; - }, - { - name: 'cancelRequestRemoveInsuranceFundStake'; - discriminator: [97, 235, 78, 62, 212, 42, 241, 127]; - accounts: [ - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['insuranceFundStake', 'userStats']; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'changeApprovedBuilder'; - discriminator: [179, 134, 211, 45, 195, 5, 189, 173]; - accounts: [ - { - name: 'escrow'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - relations: ['escrow']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'builder'; - type: 'pubkey'; - }, - { - name: 'maxFeeBps'; - type: 'u16'; - }, - { - name: 'add'; - type: 'bool'; - }, - ]; - }, - { - name: 'changeSignedMsgWsDelegateStatus'; - discriminator: [252, 202, 252, 219, 179, 27, 84, 138]; - accounts: [ - { - name: 'signedMsgWsDelegates'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'delegate'; - type: 'pubkey'; - }, - { - name: 'add'; - type: 'bool'; - }, - ]; - }, - { - name: 'deleteAmmCache'; - discriminator: [216, 130, 215, 206, 233, 232, 191, 88]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'deleteInitializedPerpMarket'; - discriminator: [91, 154, 24, 87, 106, 59, 190, 66]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'deleteInitializedSpotMarket'; - discriminator: [31, 140, 67, 191, 189, 20, 101, 221]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'deletePrelaunchOracle'; - discriminator: [59, 169, 100, 49, 69, 17, 173, 253]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'prelaunchOracle'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101, - ]; - }, - { - kind: 'arg'; - path: 'perpMarketIndex'; - }, - ]; - }; - }, - { - name: 'perpMarket'; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'deleteSignedMsgUserOrders'; - discriminator: [221, 247, 128, 253, 212, 254, 46, 153]; - accounts: [ - { - name: 'signedMsgUserOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'deleteUser'; - discriminator: [186, 85, 17, 249, 219, 231, 98, 251]; - accounts: [ - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - writable: true; - signer: true; - relations: ['user', 'userStats']; - }, - ]; - args: []; - }, - { - name: 'deposit'; - discriminator: [242, 35, 198, 137, 82, 225, 242, 182]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - ]; - }, - { - name: 'depositIntoInsuranceFundStake'; - discriminator: [4, 22, 226, 201, 124, 44, 82, 230]; - accounts: [ - { - name: 'signer'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101, - ]; - }, - { - kind: 'account'; - path: 'userStats'; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'depositIntoPerpMarketFeePool'; - discriminator: [34, 58, 57, 68, 97, 80, 244, 6]; - accounts: [ - { - name: 'state'; - writable: true; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'sourceVault'; - writable: true; - }, - { - name: 'driftSigner'; - }, - { - name: 'quoteSpotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'depositIntoSpotMarketRevenuePool'; - discriminator: [92, 40, 151, 42, 122, 254, 139, 246]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'spotMarket'; - }, - ]; - }; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'depositIntoSpotMarketVault'; - discriminator: [48, 252, 119, 73, 255, 205, 174, 247]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'admin'; - signer: true; - }, - { - name: 'sourceVault'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'depositToProgramVault'; - discriminator: [235, 171, 121, 80, 57, 239, 147, 220]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'constituent'; - writable: true; - }, - { - name: 'constituentTokenAccount'; - writable: true; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'mint'; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'disableUserHighLeverageMode'; - discriminator: [183, 155, 45, 0, 226, 85, 213, 69]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'highLeverageModeConfig'; - writable: true; - }, - ]; - args: [ - { - name: 'disableMaintenance'; - type: 'bool'; - }, - ]; - }, - { - name: 'enableUserHighLeverageMode'; - discriminator: [231, 24, 230, 112, 201, 173, 73, 184]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'highLeverageModeConfig'; - writable: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - ]; - }, - { - name: 'endInsuranceFundSwap'; - discriminator: [206, 230, 98, 8, 249, 158, 169, 167]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'outInsuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inInsuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outTokenAccount'; - writable: true; - }, - { - name: 'inTokenAccount'; - writable: true; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'endLpSwap'; - discriminator: [99, 125, 214, 165, 129, 175, 253, 135]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'signerOutTokenAccount'; - docs: ['Signer token accounts']; - writable: true; - }, - { - name: 'signerInTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - docs: ['Constituent token accounts']; - writable: true; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - }, - { - name: 'outConstituent'; - docs: ['Constituents']; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpPool'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'endSwap'; - discriminator: [177, 184, 27, 193, 34, 13, 210, 145]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'outSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outTokenAccount'; - writable: true; - }, - { - name: 'inTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - { - name: 'reduceOnly'; - type: { - option: { - defined: { - name: 'swapReduceOnly'; - }; - }; - }; - }, - ]; - }, - { - name: 'fillPerpOrder'; - discriminator: [13, 188, 248, 103, 134, 217, 106, 240]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'fillerStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'makerOrderId'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'fillSpotOrder'; - discriminator: [212, 206, 130, 173, 21, 34, 199, 40]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'fillerStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'fulfillmentType'; - type: { - option: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }; - }, - { - name: 'makerOrderId'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'forceCancelOrders'; - discriminator: [64, 181, 196, 63, 222, 72, 64, 232]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'forceDeleteUser'; - discriminator: [2, 241, 195, 172, 227, 24, 254, 158]; - accounts: [ - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - writable: true; - relations: ['user', 'userStats']; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'driftSigner'; - }, - ]; - args: []; - }, - { - name: 'initialize'; - discriminator: [175, 175, 109, 31, 13, 152, 155, 237]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [100, 114, 105, 102, 116, 95, 115, 116, 97, 116, 101]; - }, - ]; - }; - }, - { - name: 'quoteAssetMint'; - }, - { - name: 'driftSigner'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: []; - }, - { - name: 'initializeAmmCache'; - discriminator: [38, 60, 171, 158, 203, 58, 137, 8]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'initializeConstituent'; - discriminator: [12, 196, 45, 218, 93, 89, 0, 33]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'constituentTargetBase'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituentCorrelations'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'spotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'spotMarketMint'; - }, - { - name: 'constituentVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'decimals'; - type: 'u8'; - }, - { - name: 'maxWeightDeviation'; - type: 'i64'; - }, - { - name: 'swapFeeMin'; - type: 'i64'; - }, - { - name: 'swapFeeMax'; - type: 'i64'; - }, - { - name: 'maxBorrowTokenAmount'; - type: 'u64'; - }, - { - name: 'oracleStalenessThreshold'; - type: 'u64'; - }, - { - name: 'costToTrade'; - type: 'i32'; - }, - { - name: 'constituentDerivativeIndex'; - type: { - option: 'i16'; - }; - }, - { - name: 'constituentDerivativeDepegThreshold'; - type: 'u64'; - }, - { - name: 'derivativeWeight'; - type: 'u64'; - }, - { - name: 'volatility'; - type: 'u64'; - }, - { - name: 'gammaExecution'; - type: 'u8'; - }, - { - name: 'gammaInventory'; - type: 'u8'; - }, - { - name: 'xi'; - type: 'u8'; - }, - { - name: 'newConstituentCorrelations'; - type: { - vec: 'i64'; - }; - }, - ]; - }, - { - name: 'initializeFuelOverflow'; - discriminator: [88, 223, 132, 161, 208, 88, 142, 42]; - accounts: [ - { - name: 'fuelOverflow'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 102, - 117, - 101, - 108, - 95, - 111, - 118, - 101, - 114, - 102, - 108, - 111, - 119, - ]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - relations: ['userStats']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'initializeHighLeverageModeConfig'; - discriminator: [213, 167, 93, 246, 208, 130, 90, 248]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'highLeverageModeConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 104, - 105, - 103, - 104, - 95, - 108, - 101, - 118, - 101, - 114, - 97, - 103, - 101, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - ]; - }, - { - name: 'initializeIfRebalanceConfig'; - discriminator: [8, 85, 184, 167, 176, 61, 173, 226]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 102, - 95, - 114, - 101, - 98, - 97, - 108, - 97, - 110, - 99, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - { - kind: 'arg'; - path: 'params.in_market_index'; - }, - { - kind: 'arg'; - path: 'params.out_market_index'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'ifRebalanceConfigParams'; - }; - }; - }, - ]; - }, - { - name: 'initializeInsuranceFundStake'; - discriminator: [187, 179, 243, 70, 248, 90, 92, 147]; - accounts: [ - { - name: 'spotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101, - ]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - relations: ['userStats']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializeLpPool'; - discriminator: [242, 64, 1, 222, 142, 46, 204, 227]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [108, 112, 95, 112, 111, 111, 108]; - }, - { - kind: 'arg'; - path: 'id'; - }, - ]; - }; - }, - { - name: 'mint'; - }, - { - name: 'lpPoolTokenVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'ammConstituentMapping'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [65, 77, 77, 95, 77, 65, 80]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituentTargetBase'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituentCorrelations'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'tokenProgram'; - address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'lpPoolId'; - type: 'u8'; - }, - { - name: 'minMintFee'; - type: 'i64'; - }, - { - name: 'maxAum'; - type: 'u128'; - }, - { - name: 'maxSettleQuoteAmountPerMarket'; - type: 'u64'; - }, - { - name: 'whitelistMint'; - type: 'pubkey'; - }, - ]; - }, - { - name: 'initializeOpenbookV2FulfillmentConfig'; - discriminator: [7, 221, 103, 153, 107, 57, 27, 197]; - accounts: [ - { - name: 'baseSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'quoteSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'openbookV2Program'; - }, - { - name: 'openbookV2Market'; - }, - { - name: 'driftSigner'; - }, - { - name: 'openbookV2FulfillmentConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 111, - 112, - 101, - 110, - 98, - 111, - 111, - 107, - 95, - 118, - 50, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - { - kind: 'account'; - path: 'openbookV2Market'; - }, - ]; - }; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializePerpMarket'; - discriminator: [132, 9, 229, 118, 117, 118, 117, 62]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'perpMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 101, 114, 112, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'account'; - path: 'state.number_of_markets'; - account: 'state'; - }, - ]; - }; - }, - { - name: 'oracle'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'ammBaseAssetReserve'; - type: 'u128'; - }, - { - name: 'ammQuoteAssetReserve'; - type: 'u128'; - }, - { - name: 'ammPeriodicity'; - type: 'i64'; - }, - { - name: 'ammPegMultiplier'; - type: 'u128'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'contractTier'; - type: { - defined: { - name: 'contractTier'; - }; - }; - }, - { - name: 'marginRatioInitial'; - type: 'u32'; - }, - { - name: 'marginRatioMaintenance'; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - type: 'u32'; - }, - { - name: 'imfFactor'; - type: 'u32'; - }, - { - name: 'activeStatus'; - type: 'bool'; - }, - { - name: 'baseSpread'; - type: 'u32'; - }, - { - name: 'maxSpread'; - type: 'u32'; - }, - { - name: 'maxOpenInterest'; - type: 'u128'; - }, - { - name: 'maxRevenueWithdrawPerPeriod'; - type: 'u64'; - }, - { - name: 'quoteMaxInsurance'; - type: 'u64'; - }, - { - name: 'orderStepSize'; - type: 'u64'; - }, - { - name: 'orderTickSize'; - type: 'u64'; - }, - { - name: 'minOrderSize'; - type: 'u64'; - }, - { - name: 'concentrationCoefScale'; - type: 'u128'; - }, - { - name: 'curveUpdateIntensity'; - type: 'u8'; - }, - { - name: 'ammJitIntensity'; - type: 'u8'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'lpPoolId'; - type: 'u8'; - }, - ]; - }, - { - name: 'initializePhoenixFulfillmentConfig'; - discriminator: [135, 132, 110, 107, 185, 160, 169, 154]; - accounts: [ - { - name: 'baseSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'quoteSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'phoenixProgram'; - }, - { - name: 'phoenixMarket'; - }, - { - name: 'driftSigner'; - }, - { - name: 'phoenixFulfillmentConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 104, - 111, - 101, - 110, - 105, - 120, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - { - kind: 'account'; - path: 'phoenixMarket'; - }, - ]; - }; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializePredictionMarket'; - discriminator: [248, 70, 198, 224, 224, 105, 125, 195]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'initializePrelaunchOracle'; - discriminator: [169, 178, 84, 25, 175, 62, 29, 247]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'prelaunchOracle'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101, - ]; - }, - { - kind: 'arg'; - path: 'params.perp_market_index'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'prelaunchOracleParams'; - }; - }; - }, - ]; - }, - { - name: 'initializeProtectedMakerModeConfig'; - discriminator: [67, 103, 220, 67, 88, 32, 252, 8]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'protectedMakerModeConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 111, - 116, - 101, - 99, - 116, - 101, - 100, - 95, - 109, - 97, - 107, - 101, - 114, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - ]; - }, - { - name: 'initializePythLazerOracle'; - discriminator: [140, 107, 33, 214, 235, 219, 103, 20]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lazerOracle'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 121, 116, 104, 95, 108, 97, 122, 101, 114]; - }, - { - kind: 'arg'; - path: 'feedId'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'feedId'; - type: 'u32'; - }, - ]; - }, - { - name: 'initializePythPullOracle'; - discriminator: [249, 140, 253, 243, 248, 74, 240, 238]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'pythSolanaReceiver'; - address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; - }, - { - name: 'priceFeed'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; - }, - { - kind: 'arg'; - path: 'feedId'; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'feedId'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'initializeReferrerName'; - discriminator: [235, 126, 231, 10, 42, 164, 26, 61]; - accounts: [ - { - name: 'referrerName'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 114, - 101, - 102, - 101, - 114, - 114, - 101, - 114, - 95, - 110, - 97, - 109, - 101, - ]; - }, - { - kind: 'arg'; - path: 'name'; - }, - ]; - }; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'initializeRevenueShare'; - discriminator: [57, 9, 123, 131, 82, 52, 50, 13]; - accounts: [ - { - name: 'revenueShare'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [82, 69, 86, 95, 83, 72, 65, 82, 69]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'initializeRevenueShareEscrow'; - discriminator: [187, 18, 123, 88, 238, 104, 84, 154]; - accounts: [ - { - name: 'escrow'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - relations: ['userStats']; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'numOrders'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializeSerumFulfillmentConfig'; - discriminator: [193, 211, 132, 172, 70, 171, 7, 94]; - accounts: [ - { - name: 'baseSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'quoteSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'serumProgram'; - }, - { - name: 'serumMarket'; - }, - { - name: 'serumOpenOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 101, - 114, - 117, - 109, - 95, - 111, - 112, - 101, - 110, - 95, - 111, - 114, - 100, - 101, - 114, - 115, - ]; - }, - { - kind: 'account'; - path: 'serumMarket'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'serumFulfillmentConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 101, - 114, - 117, - 109, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - { - kind: 'account'; - path: 'serumMarket'; - }, - ]; - }; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializeSignedMsgUserOrders'; - discriminator: [164, 99, 156, 126, 156, 57, 99, 180]; - accounts: [ - { - name: 'signedMsgUserOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'numOrders'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializeSignedMsgWsDelegates'; - discriminator: [40, 132, 96, 219, 184, 193, 80, 8]; - accounts: [ - { - name: 'signedMsgWsDelegates'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'delegates'; - type: { - vec: 'pubkey'; - }; - }, - ]; - }, - { - name: 'initializeSpotMarket'; - discriminator: [234, 196, 128, 44, 94, 15, 48, 201]; - accounts: [ - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'account'; - path: 'state.number_of_spot_markets'; - account: 'state'; - }, - ]; - }; - }, - { - name: 'spotMarketMint'; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'state.number_of_spot_markets'; - account: 'state'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'state.number_of_spot_markets'; - account: 'state'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'optimalUtilization'; - type: 'u32'; - }, - { - name: 'optimalBorrowRate'; - type: 'u32'; - }, - { - name: 'maxBorrowRate'; - type: 'u32'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'initialAssetWeight'; - type: 'u32'; - }, - { - name: 'maintenanceAssetWeight'; - type: 'u32'; - }, - { - name: 'initialLiabilityWeight'; - type: 'u32'; - }, - { - name: 'maintenanceLiabilityWeight'; - type: 'u32'; - }, - { - name: 'imfFactor'; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - type: 'u32'; - }, - { - name: 'activeStatus'; - type: 'bool'; - }, - { - name: 'assetTier'; - type: { - defined: { - name: 'assetTier'; - }; - }; - }, - { - name: 'scaleInitialAssetWeightStart'; - type: 'u64'; - }, - { - name: 'withdrawGuardThreshold'; - type: 'u64'; - }, - { - name: 'orderTickSize'; - type: 'u64'; - }, - { - name: 'orderStepSize'; - type: 'u64'; - }, - { - name: 'ifTotalFactor'; - type: 'u32'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'initializeUser'; - discriminator: [111, 17, 185, 250, 60, 122, 38, 254]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['userStats']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'initializeUserStats'; - discriminator: [254, 243, 72, 98, 251, 130, 168, 213]; - accounts: [ - { - name: 'userStats'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114, 95, 115, 116, 97, 116, 115]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'liquidateBorrowForPerpPnl'; - discriminator: [169, 17, 32, 90, 207, 148, 209, 27]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'liquidatorMaxLiabilityTransfer'; - type: 'u128'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'liquidatePerp'; - discriminator: [75, 35, 119, 247, 191, 18, 139, 2]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'liquidatorMaxBaseAssetAmount'; - type: 'u64'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'liquidatePerpPnlForDeposit'; - discriminator: [237, 75, 198, 235, 233, 186, 75, 35]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'liquidatorMaxPnlTransfer'; - type: 'u128'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'liquidatePerpWithFill'; - discriminator: [95, 111, 124, 105, 86, 169, 187, 34]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'liquidateSpot'; - discriminator: [107, 0, 128, 41, 35, 229, 251, 18]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - { - name: 'liquidatorMaxLiabilityTransfer'; - type: 'u128'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'liquidateSpotWithSwapBegin'; - discriminator: [12, 43, 176, 83, 156, 251, 117, 13]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'liabilitySpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'liabilityMarketIndex'; - }, - ]; - }; - }, - { - name: 'assetSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'assetMarketIndex'; - }, - ]; - }; - }, - { - name: 'liabilityTokenAccount'; - writable: true; - }, - { - name: 'assetTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - { - name: 'swapAmount'; - type: 'u64'; - }, - ]; - }, - { - name: 'liquidateSpotWithSwapEnd'; - discriminator: [142, 88, 163, 160, 223, 75, 55, 225]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'liabilitySpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'liabilityMarketIndex'; - }, - ]; - }; - }, - { - name: 'assetSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'assetMarketIndex'; - }, - ]; - }; - }, - { - name: 'liabilityTokenAccount'; - writable: true; - }, - { - name: 'assetTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'logUserBalances'; - discriminator: [162, 21, 35, 251, 32, 57, 161, 210]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'lpPoolAddLiquidity'; - discriminator: [49, 135, 246, 103, 93, 146, 220, 141]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'inMarketMint'; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'userInTokenAccount'; - writable: true; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'userLpTokenAccount'; - writable: true; - }, - { - name: 'lpMint'; - writable: true; - }, - { - name: 'constituentTargetBase'; - }, - { - name: 'lpPoolTokenVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u128'; - }, - { - name: 'minMintAmount'; - type: 'u64'; - }, - ]; - }, - { - name: 'lpPoolRemoveLiquidity'; - discriminator: [164, 36, 193, 252, 196, 157, 138, 43]; - accounts: [ - { - name: 'state'; - }, - { - name: 'driftSigner'; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'outMarketMint'; - }, - { - name: 'outConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'userOutTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'userLpTokenAccount'; - writable: true; - }, - { - name: 'spotMarketTokenAccount'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpMint'; - writable: true; - }, - { - name: 'constituentTargetBase'; - }, - { - name: 'lpPoolTokenVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'tokenProgram'; - }, - { - name: 'ammCache'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - { - name: 'minOutAmount'; - type: 'u128'; - }, - ]; - }, - { - name: 'lpPoolSwap'; - discriminator: [36, 161, 39, 49, 227, 1, 35, 226]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - }, - { - name: 'constituentTargetBase'; - }, - { - name: 'constituentCorrelations'; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - writable: true; - }, - { - name: 'userInTokenAccount'; - writable: true; - }, - { - name: 'userOutTokenAccount'; - writable: true; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inMarketMint'; - }, - { - name: 'outMarketMint'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - { - name: 'minOutAmount'; - type: 'u64'; - }, - ]; - }, - { - name: 'modifyOrder'; - discriminator: [47, 124, 117, 255, 201, 197, 130, 94]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'modifyOrderParams'; - type: { - defined: { - name: 'modifyOrderParams'; - }; - }; - }, - ]; - }, - { - name: 'modifyOrderByUserId'; - discriminator: [158, 77, 4, 253, 252, 194, 161, 179]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'userOrderId'; - type: 'u8'; - }, - { - name: 'modifyOrderParams'; - type: { - defined: { - name: 'modifyOrderParams'; - }; - }; - }, - ]; - }, - { - name: 'moveAmmPrice'; - discriminator: [235, 109, 2, 82, 219, 118, 6, 159]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'baseAssetReserve'; - type: 'u128'; - }, - { - name: 'quoteAssetReserve'; - type: 'u128'; - }, - { - name: 'sqrtK'; - type: 'u128'; - }, - ]; - }, - { - name: 'openbookV2FulfillmentConfigStatus'; - discriminator: [25, 173, 19, 189, 4, 211, 64, 238]; - accounts: [ - { - name: 'state'; - }, - { - name: 'openbookV2FulfillmentConfig'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - ]; - }, - { - name: 'overrideAmmCacheInfo'; - discriminator: [189, 198, 128, 9, 49, 145, 201, 115]; - accounts: [ - { - name: 'state'; - writable: true; - }, - { - name: 'admin'; - signer: true; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'overrideParams'; - type: { - defined: { - name: 'overrideAmmCacheParams'; - }; - }; - }, - ]; - }, - { - name: 'pauseSpotMarketDepositWithdraw'; - discriminator: [183, 119, 59, 170, 137, 35, 242, 86]; - accounts: [ - { - name: 'state'; - }, - { - name: 'keeper'; - signer: true; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'spotMarket'; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'phoenixFulfillmentConfigStatus'; - discriminator: [96, 31, 113, 32, 12, 203, 7, 154]; - accounts: [ - { - name: 'state'; - }, - { - name: 'phoenixFulfillmentConfig'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - ]; - }, - { - name: 'placeAndMakePerpOrder'; - discriminator: [149, 117, 11, 237, 47, 95, 89, 237]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'taker'; - writable: true; - }, - { - name: 'takerStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'takerOrderId'; - type: 'u32'; - }, - ]; - }, - { - name: 'placeAndMakeSignedMsgPerpOrder'; - discriminator: [16, 26, 123, 131, 94, 29, 175, 98]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'taker'; - writable: true; - }, - { - name: 'takerStats'; - writable: true; - }, - { - name: 'takerSignedMsgUserOrders'; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'taker'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'signedMsgOrderUuid'; - type: { - array: ['u8', 8]; - }; - }, - ]; - }, - { - name: 'placeAndMakeSpotOrder'; - discriminator: [149, 158, 85, 66, 239, 9, 243, 98]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'taker'; - writable: true; - }, - { - name: 'takerStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'takerOrderId'; - type: 'u32'; - }, - { - name: 'fulfillmentType'; - type: { - option: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }; - }, - ]; - }, - { - name: 'placeAndTakePerpOrder'; - discriminator: [213, 51, 1, 187, 108, 220, 230, 224]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'successCondition'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'placeAndTakeSpotOrder'; - discriminator: [191, 3, 138, 71, 114, 198, 202, 100]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'fulfillmentType'; - type: { - option: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }; - }, - { - name: 'makerOrderId'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'placeOrders'; - discriminator: [60, 63, 50, 123, 12, 197, 60, 190]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - vec: { - defined: { - name: 'orderParams'; - }; - }; - }; - }, - ]; - }, - { - name: 'placePerpOrder'; - discriminator: [69, 161, 93, 202, 120, 126, 76, 185]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - ]; - }, - { - name: 'placeSignedMsgTakerOrder'; - discriminator: [32, 79, 101, 139, 25, 6, 98, 15]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'signedMsgUserOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'user'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'ixSysvar'; - docs: [ - 'the supplied Sysvar could be anything else.', - 'The Instruction Sysvar has not been implemented', - 'in the Anchor framework yet, so this is the safe approach.', - ]; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'signedMsgOrderParamsMessageBytes'; - type: 'bytes'; - }, - { - name: 'isDelegateSigner'; - type: 'bool'; - }, - ]; - }, - { - name: 'placeSpotOrder'; - discriminator: [45, 79, 81, 160, 248, 90, 91, 220]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - ]; - }, - { - name: 'postMultiPythPullOracleUpdatesAtomic'; - discriminator: [243, 79, 204, 228, 227, 208, 100, 244]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'pythSolanaReceiver'; - address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; - }, - { - name: 'guardianSet'; - }, - ]; - args: [ - { - name: 'params'; - type: 'bytes'; - }, - ]; - }, - { - name: 'postPythLazerOracleUpdate'; - discriminator: [218, 237, 170, 245, 39, 143, 166, 33]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'pythLazerStorage'; - address: '3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL'; - }, - { - name: 'ixSysvar'; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'pythMessage'; - type: 'bytes'; - }, - ]; - }, - { - name: 'postPythPullOracleUpdateAtomic'; - discriminator: [116, 122, 137, 158, 224, 195, 173, 119]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'pythSolanaReceiver'; - address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; - }, - { - name: 'guardianSet'; - }, - { - name: 'priceFeed'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; - }, - { - kind: 'arg'; - path: 'feedId'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'feedId'; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'params'; - type: 'bytes'; - }, - ]; - }, - { - name: 'recenterPerpMarketAmm'; - discriminator: [24, 87, 10, 115, 165, 190, 80, 139]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'pegMultiplier'; - type: 'u128'; - }, - { - name: 'sqrtK'; - type: 'u128'; - }, - ]; - }, - { - name: 'recenterPerpMarketAmmCrank'; - discriminator: [166, 19, 64, 10, 14, 51, 101, 122]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'spotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'account'; - path: 'perpMarket'; - }, - ]; - }; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'depth'; - type: { - option: 'u128'; - }; - }, - ]; - }, - { - name: 'reclaimRent'; - discriminator: [218, 200, 19, 197, 227, 89, 192, 22]; - accounts: [ - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - relations: ['user', 'userStats']; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'removeAmmConstituentMappingData'; - discriminator: [20, 183, 211, 162, 16, 52, 229, 115]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - }, - { - name: 'ammConstituentMapping'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [65, 77, 77, 95, 77, 65, 80]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'removeInsuranceFundStake'; - discriminator: [128, 166, 142, 9, 254, 187, 143, 174]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['insuranceFundStake', 'userStats']; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'repegAmmCurve'; - discriminator: [3, 36, 102, 89, 180, 128, 120, 213]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - ]; - args: [ - { - name: 'newPegCandidate'; - type: 'u128'; - }, - ]; - }, - { - name: 'requestRemoveInsuranceFundStake'; - discriminator: [142, 70, 204, 92, 73, 106, 180, 52]; - accounts: [ - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['insuranceFundStake', 'userStats']; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'resetFuelSeason'; - discriminator: [199, 122, 192, 255, 32, 99, 63, 200]; - accounts: [ - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - relations: ['userStats']; - }, - { - name: 'state'; - }, - { - name: 'admin'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'resetPerpMarketAmmOracleTwap'; - discriminator: [127, 10, 55, 164, 123, 226, 47, 24]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - ]; - args: []; - }, - { - name: 'resizeRevenueShareEscrowOrders'; - discriminator: [32, 124, 247, 225, 151, 213, 225, 38]; - accounts: [ - { - name: 'escrow'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - relations: ['escrow']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'numOrders'; - type: 'u16'; - }, - ]; - }, - { - name: 'resizeSignedMsgUserOrders'; - discriminator: [137, 10, 87, 150, 18, 115, 79, 168]; - accounts: [ - { - name: 'signedMsgUserOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - relations: ['user']; - }, - { - name: 'user'; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'numOrders'; - type: 'u16'; - }, - ]; - }, - { - name: 'resolvePerpBankruptcy'; - discriminator: [224, 16, 176, 214, 162, 213, 183, 222]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'quoteSpotMarketIndex'; - type: 'u16'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'resolvePerpPnlDeficit'; - discriminator: [168, 204, 68, 150, 159, 126, 95, 148]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'resolveSpotBankruptcy'; - discriminator: [124, 194, 240, 254, 198, 213, 52, 122]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'revertFill'; - discriminator: [236, 238, 176, 69, 239, 10, 181, 193]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'fillerStats'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'setUserStatusToBeingLiquidated'; - discriminator: [106, 133, 160, 206, 193, 171, 192, 194]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'settleExpiredMarket'; - discriminator: [120, 89, 11, 25, 122, 77, 72, 193]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'settleExpiredMarketPoolsToRevenuePool'; - discriminator: [55, 19, 238, 169, 227, 90, 200, 184]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'settleFundingPayment'; - discriminator: [222, 90, 202, 94, 28, 45, 115, 183]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'settleMultiplePnls'; - discriminator: [127, 66, 117, 57, 40, 50, 152, 127]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndexes'; - type: { - vec: 'u16'; - }; - }, - { - name: 'mode'; - type: { - defined: { - name: 'settlePnlMode'; - }; - }; - }, - ]; - }, - { - name: 'settlePerpToLpPool'; - discriminator: [5, 98, 46, 188, 10, 59, 2, 249]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'ammCache'; - writable: true; - }, - { - name: 'quoteMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'constituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'constituentQuoteTokenAccount'; - writable: true; - }, - { - name: 'quoteTokenVault'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - ]; - args: []; - }, - { - name: 'settlePnl'; - discriminator: [43, 61, 234, 45, 15, 95, 152, 153]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'settleRevenueToInsuranceFund'; - discriminator: [200, 120, 93, 136, 69, 38, 199, 159]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'sweepFuel'; - discriminator: [175, 107, 19, 56, 165, 241, 43, 69]; - accounts: [ - { - name: 'fuelOverflow'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - relations: ['fuelOverflow', 'userStats']; - }, - { - name: 'signer'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'transferDeposit'; - discriminator: [20, 20, 147, 223, 41, 63, 204, 111]; - accounts: [ - { - name: 'fromUser'; - writable: true; - }, - { - name: 'toUser'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['fromUser', 'toUser', 'userStats']; - }, - { - name: 'state'; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'transferPerpPosition'; - discriminator: [23, 172, 188, 168, 134, 210, 3, 108]; - accounts: [ - { - name: 'fromUser'; - writable: true; - }, - { - name: 'toUser'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: { - option: 'i64'; - }; - }, - ]; - }, - { - name: 'transferPools'; - discriminator: [197, 103, 154, 25, 107, 90, 60, 94]; - accounts: [ - { - name: 'fromUser'; - writable: true; - }, - { - name: 'toUser'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['fromUser', 'toUser', 'userStats']; - }, - { - name: 'state'; - }, - { - name: 'depositFromSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'depositFromMarketIndex'; - }, - ]; - }; - }, - { - name: 'depositToSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'depositToMarketIndex'; - }, - ]; - }; - }, - { - name: 'borrowFromSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'borrowFromMarketIndex'; - }, - ]; - }; - }, - { - name: 'borrowToSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'borrowToMarketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - ]; - args: [ - { - name: 'depositFromMarketIndex'; - type: 'u16'; - }, - { - name: 'depositToMarketIndex'; - type: 'u16'; - }, - { - name: 'borrowFromMarketIndex'; - type: 'u16'; - }, - { - name: 'borrowToMarketIndex'; - type: 'u16'; - }, - { - name: 'depositAmount'; - type: { - option: 'u64'; - }; - }, - { - name: 'borrowAmount'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'transferProtocolIfSharesToRevenuePool'; - discriminator: [236, 136, 147, 153, 146, 205, 104, 29]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'triggerOrder'; - discriminator: [63, 112, 51, 233, 232, 47, 240, 199]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateAdmin'; - discriminator: [161, 176, 40, 213, 60, 184, 179, 228]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'admin'; - type: 'pubkey'; - }, - ]; - }, - { - name: 'updateAmmCache'; - discriminator: [88, 4, 63, 94, 83, 224, 255, 130]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'ammCache'; - writable: true; - }, - { - name: 'quoteMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateAmmConstituentMappingData'; - discriminator: [84, 70, 33, 167, 133, 107, 59, 24]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - }, - { - name: 'ammConstituentMapping'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [65, 77, 77, 95, 77, 65, 80]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'ammConstituentMappingData'; - type: { - vec: { - defined: { - name: 'addAmmConstituentMappingDatum'; - }; - }; - }; - }, - ]; - }, - { - name: 'updateAmmJitIntensity'; - discriminator: [181, 191, 53, 109, 166, 249, 55, 142]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'ammJitIntensity'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateAmms'; - discriminator: [201, 106, 217, 253, 4, 175, 228, 97]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'marketIndexes'; - type: { - vec: 'u16'; - }; - }, - ]; - }, - { - name: 'updateConstituentCorrelationData'; - discriminator: [79, 14, 19, 73, 221, 106, 62, 109]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - }, - { - name: 'constituentCorrelations'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'index1'; - type: 'u16'; - }, - { - name: 'index2'; - type: 'u16'; - }, - { - name: 'correlation'; - type: 'i64'; - }, - ]; - }, - { - name: 'updateConstituentOracleInfo'; - discriminator: [198, 117, 231, 250, 147, 33, 127, 161]; - accounts: [ - { - name: 'state'; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'constituent'; - writable: true; - }, - { - name: 'spotMarket'; - }, - { - name: 'oracle'; - }, - ]; - args: []; - }, - { - name: 'updateConstituentParams'; - discriminator: [238, 130, 122, 31, 12, 104, 192, 122]; - accounts: [ - { - name: 'lpPool'; - }, - { - name: 'constituentTargetBase'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'constituent'; - writable: true; - }, - ]; - args: [ - { - name: 'constituentParams'; - type: { - defined: { - name: 'constituentParams'; - }; - }; - }, - ]; - }, - { - name: 'updateConstituentPausedOperations'; - discriminator: [185, 122, 153, 191, 131, 177, 132, 208]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'constituent'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateConstituentStatus'; - discriminator: [76, 159, 211, 239, 182, 214, 6, 15]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'constituent'; - writable: true; - }, - ]; - args: [ - { - name: 'newStatus'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateDelegateUserGovTokenInsuranceStake'; - discriminator: [241, 29, 215, 228, 142, 116, 22, 160]; - accounts: [ - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [15, 0]; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [15, 0]; - }, - ]; - }; - }, - { - name: 'state'; - }, - ]; - args: []; - }, - { - name: 'updateDiscountMint'; - discriminator: [32, 252, 122, 211, 66, 31, 47, 241]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'discountMint'; - type: 'pubkey'; - }, - ]; - }, - { - name: 'updateExchangeStatus'; - discriminator: [83, 160, 252, 250, 129, 116, 49, 223]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'exchangeStatus'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsBuilderCodes'; - discriminator: [1, 128, 177, 51, 173, 45, 11, 102]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsMedianTriggerPrice'; - discriminator: [64, 185, 221, 45, 87, 147, 12, 19]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsMintRedeemLpPool'; - discriminator: [26, 11, 142, 122, 206, 159, 9, 45]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsMmOracle'; - discriminator: [218, 134, 33, 186, 231, 59, 130, 149]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsSettleLpPool'; - discriminator: [186, 28, 78, 230, 155, 83, 242, 26]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsSwapLpPool'; - discriminator: [83, 16, 150, 12, 102, 3, 22, 58]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFundingRate'; - discriminator: [201, 178, 116, 212, 166, 144, 72, 238]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateHighLeverageModeConfig'; - discriminator: [64, 122, 212, 93, 141, 217, 202, 55]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'highLeverageModeConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 104, - 105, - 103, - 104, - 95, - 108, - 101, - 118, - 101, - 114, - 97, - 103, - 101, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - ]; - }; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - { - name: 'currentUsers'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'updateIfRebalanceConfig'; - discriminator: [142, 245, 249, 66, 249, 181, 22, 83]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'ifRebalanceConfigParams'; - }; - }; - }, - ]; - }, - { - name: 'updateInitialAmmCacheInfo'; - discriminator: [157, 210, 109, 67, 212, 170, 12, 107]; - accounts: [ - { - name: 'state'; - writable: true; - }, - { - name: 'admin'; - signer: true; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateInitialPctToLiquidate'; - discriminator: [210, 133, 225, 128, 194, 50, 13, 109]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'initialPctToLiquidate'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateInsuranceFundUnstakingPeriod'; - discriminator: [44, 69, 43, 226, 204, 223, 202, 52]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'insuranceFundUnstakingPeriod'; - type: 'i64'; - }, - ]; - }, - { - name: 'updateK'; - discriminator: [72, 98, 9, 139, 129, 229, 172, 56]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'sqrtK'; - type: 'u128'; - }, - ]; - }, - { - name: 'updateLiquidationDuration'; - discriminator: [28, 154, 20, 249, 102, 192, 73, 71]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'liquidationDuration'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateLiquidationMarginBufferRatio'; - discriminator: [132, 224, 243, 160, 154, 82, 97, 215]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'liquidationMarginBufferRatio'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateLpConstituentTargetBase'; - discriminator: [157, 65, 50, 207, 59, 236, 161, 110]; - accounts: [ - { - name: 'state'; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'ammConstituentMapping'; - }, - { - name: 'constituentTargetBase'; - writable: true; - }, - { - name: 'ammCache'; - }, - { - name: 'lpPool'; - }, - ]; - args: []; - }, - { - name: 'updateLpPoolAum'; - discriminator: [88, 113, 137, 206, 246, 247, 171, 142]; - accounts: [ - { - name: 'state'; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'constituentTargetBase'; - writable: true; - }, - { - name: 'ammCache'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'updateLpPoolParams'; - discriminator: [217, 92, 2, 255, 27, 167, 178, 81]; - accounts: [ - { - name: 'lpPool'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'lpPoolParams'; - type: { - defined: { - name: 'lpPoolParams'; - }; - }; - }, - ]; - }, - { - name: 'updateOracleGuardRails'; - discriminator: [131, 112, 10, 59, 32, 54, 40, 164]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'oracleGuardRails'; - type: { - defined: { - name: 'oracleGuardRails'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpAuctionDuration'; - discriminator: [126, 110, 52, 174, 30, 206, 215, 90]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'minPerpAuctionDuration'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpBidAskTwap'; - discriminator: [247, 23, 255, 65, 212, 90, 221, 194]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'keeperStats'; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'updatePerpFeeStructure'; - discriminator: [23, 178, 111, 203, 73, 22, 140, 75]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'feeStructure'; - type: { - defined: { - name: 'feeStructure'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpMarketAmmOracleTwap'; - discriminator: [241, 74, 114, 123, 206, 153, 24, 202]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - ]; - args: []; - }, - { - name: 'updatePerpMarketAmmSpreadAdjustment'; - discriminator: [155, 195, 149, 43, 220, 82, 173, 205]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'ammSpreadAdjustment'; - type: 'i8'; - }, - { - name: 'ammInventorySpreadAdjustment'; - type: 'i8'; - }, - { - name: 'referencePriceOffset'; - type: 'i32'; - }, - ]; - }, - { - name: 'updatePerpMarketAmmSummaryStats'; - discriminator: [122, 101, 249, 238, 209, 9, 241, 245]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'spotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'account'; - path: 'perpMarket'; - }, - ]; - }; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'updatePerpMarketSummaryStatsParams'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpMarketBaseSpread'; - discriminator: [71, 95, 84, 168, 9, 157, 198, 65]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'baseSpread'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketConcentrationCoef'; - discriminator: [24, 78, 232, 126, 169, 176, 230, 16]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'concentrationScale'; - type: 'u128'; - }, - ]; - }, - { - name: 'updatePerpMarketContractTier'; - discriminator: [236, 128, 15, 95, 203, 214, 68, 117]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'contractTier'; - type: { - defined: { - name: 'contractTier'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpMarketCurveUpdateIntensity'; - discriminator: [50, 131, 6, 156, 226, 231, 189, 72]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'curveUpdateIntensity'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketExpiry'; - discriminator: [44, 221, 227, 151, 131, 140, 22, 110]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'expiryTs'; - type: 'i64'; - }, - ]; - }, - { - name: 'updatePerpMarketFeeAdjustment'; - discriminator: [194, 174, 87, 102, 43, 148, 32, 112]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'feeAdjustment'; - type: 'i16'; - }, - ]; - }, - { - name: 'updatePerpMarketFundingPeriod'; - discriminator: [171, 161, 69, 91, 129, 139, 161, 28]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'fundingPeriod'; - type: 'i64'; - }, - ]; - }, - { - name: 'updatePerpMarketHighLeverageMarginRatio'; - discriminator: [88, 112, 86, 49, 24, 116, 74, 157]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'marginRatioInitial'; - type: 'u16'; - }, - { - name: 'marginRatioMaintenance'; - type: 'u16'; - }, - ]; - }, - { - name: 'updatePerpMarketImfFactor'; - discriminator: [207, 194, 56, 132, 35, 67, 71, 244]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'imfFactor'; - type: 'u32'; - }, - { - name: 'unrealizedPnlImfFactor'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketLiquidationFee'; - discriminator: [90, 137, 9, 145, 41, 8, 148, 117]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'liquidatorFee'; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketLpPoolFeeTransferScalar'; - discriminator: [94, 228, 237, 109, 100, 185, 4, 81]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'optionalLpFeeTransferScalar'; - type: { - option: 'u8'; - }; - }, - { - name: 'optionalLpNetPnlTransferScalar'; - type: { - option: 'u8'; - }; - }, - ]; - }, - { - name: 'updatePerpMarketLpPoolId'; - discriminator: [119, 208, 154, 88, 165, 92, 21, 188]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'lpPoolId'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketLpPoolPausedOperations'; - discriminator: [181, 94, 93, 146, 51, 89, 32, 135]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'lpPausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketLpPoolStatus'; - discriminator: [67, 6, 252, 61, 54, 88, 89, 233]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'lpStatus'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketMarginRatio'; - discriminator: [130, 173, 107, 45, 119, 105, 26, 113]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'marginRatioInitial'; - type: 'u32'; - }, - { - name: 'marginRatioMaintenance'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxFillReserveFraction'; - discriminator: [19, 172, 114, 154, 42, 135, 161, 133]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxFillReserveFraction'; - type: 'u16'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxImbalances'; - discriminator: [15, 206, 73, 133, 60, 8, 86, 89]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'unrealizedMaxImbalance'; - type: 'u64'; - }, - { - name: 'maxRevenueWithdrawPerPeriod'; - type: 'u64'; - }, - { - name: 'quoteMaxInsurance'; - type: 'u64'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxOpenInterest'; - discriminator: [194, 79, 149, 224, 246, 102, 186, 140]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxOpenInterest'; - type: 'u128'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxSlippageRatio'; - discriminator: [235, 37, 40, 196, 70, 146, 54, 201]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxSlippageRatio'; - type: 'u16'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxSpread'; - discriminator: [80, 252, 122, 62, 40, 218, 91, 100]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxSpread'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketMinOrderSize'; - discriminator: [226, 74, 5, 89, 108, 223, 46, 141]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'orderSize'; - type: 'u64'; - }, - ]; - }, - { - name: 'updatePerpMarketName'; - discriminator: [211, 31, 21, 210, 64, 108, 66, 201]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'updatePerpMarketNumberOfUsers'; - discriminator: [35, 62, 144, 177, 180, 62, 215, 196]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'numberOfUsers'; - type: { - option: 'u32'; - }; - }, - { - name: 'numberOfUsersWithBase'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'updatePerpMarketOracle'; - discriminator: [182, 113, 111, 160, 67, 174, 89, 191]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'oldOracle'; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'oracle'; - type: 'pubkey'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'skipInvariantCheck'; - type: 'bool'; - }, - ]; - }, - { - name: 'updatePerpMarketOracleLowRiskSlotDelayOverride'; - discriminator: [124, 108, 147, 229, 109, 117, 123, 3]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'oracleLowRiskSlotDelayOverride'; - type: 'i8'; - }, - ]; - }, - { - name: 'updatePerpMarketOracleSlotDelayOverride'; - discriminator: [165, 91, 239, 227, 63, 172, 227, 8]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'oracleSlotDelayOverride'; - type: 'i8'; - }, - ]; - }, - { - name: 'updatePerpMarketPausedOperations'; - discriminator: [53, 16, 136, 132, 30, 220, 121, 85]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketPnlPool'; - discriminator: [50, 202, 249, 224, 166, 184, 13, 143]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'updatePerpMarketProtectedMakerParams'; - discriminator: [249, 213, 115, 34, 253, 239, 75, 173]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'protectedMakerLimitPriceDivisor'; - type: { - option: 'u8'; - }; - }, - { - name: 'protectedMakerDynamicDivisor'; - type: { - option: 'u8'; - }; - }, - ]; - }, - { - name: 'updatePerpMarketReferencePriceOffsetDeadbandPct'; - discriminator: [214, 73, 166, 11, 218, 76, 110, 163]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'referencePriceOffsetDeadbandPct'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketStatus'; - discriminator: [71, 201, 175, 122, 255, 207, 196, 207]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'marketStatus'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpMarketStepSizeAndTickSize'; - discriminator: [231, 255, 97, 25, 146, 139, 174, 4]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'stepSize'; - type: 'u64'; - }, - { - name: 'tickSize'; - type: 'u64'; - }, - ]; - }, - { - name: 'updatePerpMarketUnrealizedAssetWeight'; - discriminator: [135, 132, 205, 165, 109, 150, 166, 106]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'unrealizedInitialAssetWeight'; - type: 'u32'; - }, - { - name: 'unrealizedMaintenanceAssetWeight'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePrelaunchOracle'; - discriminator: [220, 132, 27, 27, 233, 220, 61, 219]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - }, - { - name: 'oracle'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'updatePrelaunchOracleParams'; - discriminator: [98, 205, 147, 243, 18, 75, 83, 207]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'prelaunchOracle'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101, - ]; - }, - { - kind: 'arg'; - path: 'params.perp_market_index'; - }, - ]; - }; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'prelaunchOracleParams'; - }; - }; - }, - ]; - }, - { - name: 'updateProtectedMakerModeConfig'; - discriminator: [86, 166, 235, 253, 67, 202, 223, 17]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'protectedMakerModeConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 111, - 116, - 101, - 99, - 116, - 101, - 100, - 95, - 109, - 97, - 107, - 101, - 114, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - ]; - }; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - { - name: 'currentUsers'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'updatePythPullOracle'; - discriminator: [230, 191, 189, 94, 108, 59, 74, 197]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'pythSolanaReceiver'; - address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; - }, - { - name: 'encodedVaa'; - }, - { - name: 'priceFeed'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; - }, - { - kind: 'arg'; - path: 'feedId'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'feedId'; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'params'; - type: 'bytes'; - }, - ]; - }, - { - name: 'updateSerumFulfillmentConfigStatus'; - discriminator: [171, 109, 240, 251, 95, 1, 149, 89]; - accounts: [ - { - name: 'state'; - }, - { - name: 'serumFulfillmentConfig'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - ]; - }, - { - name: 'updateSpotAuctionDuration'; - discriminator: [182, 178, 203, 72, 187, 143, 157, 107]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'defaultSpotAuctionDuration'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateSpotFeeStructure'; - discriminator: [97, 216, 105, 131, 113, 246, 142, 141]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'feeStructure'; - type: { - defined: { - name: 'feeStructure'; - }; - }; - }, - ]; - }, - { - name: 'updateSpotMarketAssetTier'; - discriminator: [253, 209, 231, 14, 242, 208, 243, 130]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'assetTier'; - type: { - defined: { - name: 'assetTier'; - }; - }; - }, - ]; - }, - { - name: 'updateSpotMarketBorrowRate'; - discriminator: [71, 239, 236, 153, 210, 62, 254, 76]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'optimalUtilization'; - type: 'u32'; - }, - { - name: 'optimalBorrowRate'; - type: 'u32'; - }, - { - name: 'maxBorrowRate'; - type: 'u32'; - }, - { - name: 'minBorrowRate'; - type: { - option: 'u8'; - }; - }, - ]; - }, - { - name: 'updateSpotMarketCumulativeInterest'; - discriminator: [39, 166, 139, 243, 158, 165, 155, 225]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'spotMarket'; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateSpotMarketExpiry'; - discriminator: [208, 11, 211, 159, 226, 24, 11, 247]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'expiryTs'; - type: 'i64'; - }, - ]; - }, - { - name: 'updateSpotMarketFeeAdjustment'; - discriminator: [148, 182, 3, 126, 157, 114, 220, 99]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'feeAdjustment'; - type: 'i16'; - }, - ]; - }, - { - name: 'updateSpotMarketIfFactor'; - discriminator: [147, 30, 224, 34, 18, 230, 105, 4]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'userIfFactor'; - type: 'u32'; - }, - { - name: 'totalIfFactor'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateSpotMarketIfPausedOperations'; - discriminator: [101, 215, 79, 74, 59, 41, 79, 12]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateSpotMarketLiquidationFee'; - discriminator: [11, 13, 255, 53, 56, 136, 104, 177]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'liquidatorFee'; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateSpotMarketMarginWeights'; - discriminator: [109, 33, 87, 195, 255, 36, 6, 81]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'initialAssetWeight'; - type: 'u32'; - }, - { - name: 'maintenanceAssetWeight'; - type: 'u32'; - }, - { - name: 'initialLiabilityWeight'; - type: 'u32'; - }, - { - name: 'maintenanceLiabilityWeight'; - type: 'u32'; - }, - { - name: 'imfFactor'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateSpotMarketMaxTokenBorrows'; - discriminator: [57, 102, 204, 212, 253, 95, 13, 199]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxTokenBorrowsFraction'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateSpotMarketMaxTokenDeposits'; - discriminator: [56, 191, 79, 18, 26, 121, 80, 208]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxTokenDeposits'; - type: 'u64'; - }, - ]; - }, - { - name: 'updateSpotMarketMinOrderSize'; - discriminator: [93, 128, 11, 119, 26, 20, 181, 50]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'orderSize'; - type: 'u64'; - }, - ]; - }, - { - name: 'updateSpotMarketName'; - discriminator: [17, 208, 1, 1, 162, 211, 188, 224]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'updateSpotMarketOracle'; - discriminator: [114, 184, 102, 37, 246, 186, 180, 99]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'oldOracle'; - }, - ]; - args: [ - { - name: 'oracle'; - type: 'pubkey'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'skipInvariantCheck'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateSpotMarketOrdersEnabled'; - discriminator: [190, 79, 206, 15, 26, 229, 229, 43]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'ordersEnabled'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateSpotMarketPausedOperations'; - discriminator: [100, 61, 153, 81, 180, 12, 6, 248]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateSpotMarketPoolId'; - discriminator: [22, 213, 197, 160, 139, 193, 81, 149]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'poolId'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateSpotMarketRevenueSettlePeriod'; - discriminator: [81, 92, 126, 41, 250, 225, 156, 219]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'revenueSettlePeriod'; - type: 'i64'; - }, - ]; - }, - { - name: 'updateSpotMarketScaleInitialAssetWeightStart'; - discriminator: [217, 204, 204, 118, 204, 130, 225, 147]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'scaleInitialAssetWeightStart'; - type: 'u64'; - }, - ]; - }, - { - name: 'updateSpotMarketStatus'; - discriminator: [78, 94, 16, 188, 193, 110, 231, 31]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'marketStatus'; - }; - }; - }, - ]; - }, - { - name: 'updateSpotMarketStepSizeAndTickSize'; - discriminator: [238, 153, 137, 80, 206, 59, 250, 61]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'stepSize'; - type: 'u64'; - }, - { - name: 'tickSize'; - type: 'u64'; - }, - ]; - }, - { - name: 'updateStateMaxInitializeUserFee'; - discriminator: [237, 225, 25, 237, 193, 45, 77, 97]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'maxInitializeUserFee'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateStateMaxNumberOfSubAccounts'; - discriminator: [155, 123, 214, 2, 221, 166, 204, 85]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'maxNumberOfSubAccounts'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateStateSettlementDuration'; - discriminator: [97, 68, 199, 235, 131, 80, 61, 173]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'settlementDuration'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateUserCustomMarginRatio'; - discriminator: [21, 221, 140, 187, 32, 129, 11, 123]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'marginRatio'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateUserDelegate'; - discriminator: [139, 205, 141, 141, 113, 36, 94, 187]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'delegate'; - type: 'pubkey'; - }, - ]; - }, - { - name: 'updateUserGovTokenInsuranceStake'; - discriminator: [143, 99, 235, 187, 20, 159, 184, 84]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [15, 0]; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'signer'; - signer: true; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [15, 0]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateUserIdle'; - discriminator: [253, 133, 67, 22, 103, 161, 20, 100]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'updateUserMarginTradingEnabled'; - discriminator: [194, 92, 204, 223, 246, 188, 31, 203]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'marginTradingEnabled'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateUserName'; - discriminator: [135, 25, 185, 56, 165, 53, 34, 136]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'updateUserPerpPositionCustomMarginRatio'; - discriminator: [121, 137, 157, 155, 89, 186, 145, 113]; - accounts: [ - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'marginRatio'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateUserPoolId'; - discriminator: [219, 86, 73, 106, 56, 218, 128, 109]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'poolId'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateUserProtectedMakerOrders'; - discriminator: [114, 39, 123, 198, 187, 25, 90, 219]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'protectedMakerModeConfig'; - writable: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'protectedMakerOrders'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateUserQuoteAssetInsuranceStake'; - discriminator: [251, 101, 156, 7, 2, 63, 30, 23]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'signer'; - signer: true; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateUserReduceOnly'; - discriminator: [199, 71, 42, 67, 144, 19, 86, 109]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateUserStatsReferrerStatus'; - discriminator: [174, 154, 72, 42, 191, 148, 145, 205]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'updateWithdrawGuardThreshold'; - discriminator: [56, 18, 39, 61, 155, 211, 44, 133]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'withdrawGuardThreshold'; - type: 'u64'; - }, - ]; - }, - { - name: 'viewLpPoolAddLiquidityFees'; - discriminator: [80, 66, 226, 161, 70, 142, 119, 84]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'inMarketMint'; - }, - { - name: 'inConstituent'; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpMint'; - }, - { - name: 'constituentTargetBase'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u128'; - }, - ]; - }, - { - name: 'viewLpPoolRemoveLiquidityFees'; - discriminator: [47, 12, 9, 102, 12, 226, 197, 89]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'outMarketMint'; - }, - { - name: 'outConstituent'; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpMint'; - }, - { - name: 'constituentTargetBase'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - ]; - }, - { - name: 'viewLpPoolSwapFees'; - discriminator: [126, 189, 109, 189, 170, 156, 3, 46]; - accounts: [ - { - name: 'driftSigner'; - }, - { - name: 'state'; - }, - { - name: 'lpPool'; - }, - { - name: 'constituentTargetBase'; - }, - { - name: 'constituentCorrelations'; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - writable: true; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - { - name: 'inTargetWeight'; - type: 'i64'; - }, - { - name: 'outTargetWeight'; - type: 'i64'; - }, - ]; - }, - { - name: 'withdraw'; - discriminator: [183, 18, 70, 156, 148, 109, 161, 34]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['user', 'userStats']; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - ]; - }, - { - name: 'withdrawFromProgramVault'; - discriminator: [120, 40, 183, 149, 232, 18, 224, 151]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'driftSigner'; - }, - { - name: 'constituent'; - writable: true; - }, - { - name: 'constituentTokenAccount'; - writable: true; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'mint'; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'zeroMmOracleFields'; - discriminator: [192, 226, 39, 204, 207, 120, 148, 250]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: 'ammCache'; - discriminator: [213, 114, 161, 56, 20, 22, 2, 59]; - }, - { - name: 'ammConstituentMapping'; - discriminator: [254, 89, 5, 173, 66, 54, 214, 247]; - }, - { - name: 'constituent'; - discriminator: [0, 61, 36, 35, 177, 76, 216, 205]; - }, - { - name: 'constituentCorrelations'; - discriminator: [124, 203, 115, 33, 18, 162, 67, 216]; - }, - { - name: 'constituentTargetBase'; - discriminator: [255, 142, 134, 71, 125, 66, 198, 99]; - }, - { - name: 'fuelOverflow'; - discriminator: [182, 64, 231, 177, 226, 142, 69, 58]; - }, - { - name: 'highLeverageModeConfig'; - discriminator: [3, 196, 90, 189, 193, 64, 228, 234]; - }, - { - name: 'ifRebalanceConfig'; - discriminator: [214, 84, 40, 251, 107, 144, 173, 239]; - }, - { - name: 'insuranceFundStake'; - discriminator: [110, 202, 14, 42, 95, 73, 90, 95]; - }, - { - name: 'lpPool'; - discriminator: [228, 152, 141, 224, 161, 170, 11, 89]; - }, - { - name: 'openbookV2FulfillmentConfig'; - discriminator: [3, 43, 58, 106, 131, 132, 199, 171]; - }, - { - name: 'perpMarket'; - discriminator: [10, 223, 12, 44, 107, 245, 55, 247]; - }, - { - name: 'phoenixV1FulfillmentConfig'; - discriminator: [233, 45, 62, 40, 35, 129, 48, 72]; - }, - { - name: 'prelaunchOracle'; - discriminator: [92, 14, 139, 234, 72, 244, 68, 26]; - }, - { - name: 'protectedMakerModeConfig'; - discriminator: [47, 86, 90, 9, 224, 255, 10, 69]; - }, - { - name: 'pythLazerOracle'; - discriminator: [159, 7, 161, 249, 34, 81, 121, 133]; - }, - { - name: 'referrerName'; - discriminator: [105, 133, 170, 110, 52, 42, 28, 182]; - }, - { - name: 'revenueShare'; - discriminator: [55, 40, 228, 7, 139, 52, 180, 110]; - }, - { - name: 'revenueShareEscrow'; - discriminator: [98, 167, 3, 46, 74, 177, 173, 252]; - }, - { - name: 'serumV3FulfillmentConfig'; - discriminator: [65, 160, 197, 112, 239, 168, 103, 185]; - }, - { - name: 'signedMsgUserOrders'; - discriminator: [70, 6, 50, 248, 222, 1, 143, 49]; - }, - { - name: 'signedMsgWsDelegates'; - discriminator: [190, 115, 111, 44, 216, 252, 108, 85]; - }, - { - name: 'spotMarket'; - discriminator: [100, 177, 8, 107, 168, 65, 65, 39]; - }, - { - name: 'state'; - discriminator: [216, 146, 107, 94, 104, 75, 182, 177]; - }, - { - name: 'user'; - discriminator: [159, 117, 95, 227, 239, 151, 58, 236]; - }, - { - name: 'userStats'; - discriminator: [176, 223, 136, 27, 122, 79, 32, 227]; - }, - ]; - events: [ - { - name: 'curveRecord'; - discriminator: [101, 238, 40, 228, 70, 46, 61, 117]; - }, - { - name: 'deleteUserRecord'; - discriminator: [71, 111, 190, 118, 7, 3, 132, 222]; - }, - { - name: 'depositRecord'; - discriminator: [180, 241, 218, 207, 102, 135, 44, 134]; - }, - { - name: 'fuelSeasonRecord'; - discriminator: [19, 137, 119, 33, 224, 249, 6, 87]; - }, - { - name: 'fuelSweepRecord'; - discriminator: [41, 84, 37, 246, 132, 240, 131, 8]; - }, - { - name: 'fundingPaymentRecord'; - discriminator: [8, 59, 96, 20, 137, 201, 56, 95]; - }, - { - name: 'fundingRateRecord'; - discriminator: [68, 3, 255, 26, 133, 91, 147, 254]; - }, - { - name: 'insuranceFundRecord'; - discriminator: [56, 222, 215, 235, 78, 197, 99, 146]; - }, - { - name: 'insuranceFundStakeRecord'; - discriminator: [68, 66, 156, 7, 216, 148, 250, 114]; - }, - { - name: 'insuranceFundSwapRecord'; - discriminator: [85, 190, 99, 203, 237, 33, 227, 100]; - }, - { - name: 'lpBorrowLendDepositRecord'; - discriminator: [242, 181, 11, 56, 243, 61, 79, 210]; - }, - { - name: 'lpMintRedeemRecord'; - discriminator: [53, 178, 142, 73, 78, 91, 91, 8]; - }, - { - name: 'lpRecord'; - discriminator: [101, 22, 54, 38, 178, 13, 142, 111]; - }, - { - name: 'lpSettleRecord'; - discriminator: [208, 191, 131, 110, 173, 48, 7, 2]; - }, - { - name: 'lpSwapRecord'; - discriminator: [159, 62, 130, 196, 96, 79, 176, 254]; - }, - { - name: 'liquidationRecord'; - discriminator: [127, 17, 0, 108, 182, 13, 231, 53]; - }, - { - name: 'newUserRecord'; - discriminator: [236, 186, 113, 219, 42, 51, 149, 249]; - }, - { - name: 'orderActionRecord'; - discriminator: [224, 52, 67, 71, 194, 237, 109, 1]; - }, - { - name: 'orderRecord'; - discriminator: [104, 19, 64, 56, 89, 21, 2, 90]; - }, - { - name: 'revenueShareSettleRecord'; - discriminator: [61, 162, 89, 10, 24, 20, 59, 45]; - }, - { - name: 'settlePnlRecord'; - discriminator: [57, 68, 105, 26, 119, 198, 213, 89]; - }, - { - name: 'signedMsgOrderRecord'; - discriminator: [211, 197, 25, 18, 142, 86, 113, 27]; - }, - { - name: 'spotInterestRecord'; - discriminator: [183, 186, 203, 186, 225, 187, 95, 130]; - }, - { - name: 'spotMarketVaultDepositRecord'; - discriminator: [178, 217, 23, 188, 127, 190, 32, 73]; - }, - { - name: 'swapRecord'; - discriminator: [162, 187, 123, 194, 138, 56, 250, 241]; - }, - { - name: 'transferProtocolIfSharesToRevenuePoolRecord'; - discriminator: [209, 118, 142, 167, 130, 46, 164, 151]; - }, - ]; - errors: [ - { - code: 6000; - name: 'invalidSpotMarketAuthority'; - msg: 'Invalid Spot Market Authority'; - }, - { - code: 6001; - name: 'invalidInsuranceFundAuthority'; - msg: 'Clearing house not insurance fund authority'; - }, - { - code: 6002; - name: 'insufficientDeposit'; - msg: 'Insufficient deposit'; - }, - { - code: 6003; - name: 'insufficientCollateral'; - msg: 'Insufficient collateral'; - }, - { - code: 6004; - name: 'sufficientCollateral'; - msg: 'Sufficient collateral'; - }, - { - code: 6005; - name: 'maxNumberOfPositions'; - msg: 'Max number of positions taken'; - }, - { - code: 6006; - name: 'adminControlsPricesDisabled'; - msg: 'Admin Controls Prices Disabled'; - }, - { - code: 6007; - name: 'marketDelisted'; - msg: 'Market Delisted'; - }, - { - code: 6008; - name: 'marketIndexAlreadyInitialized'; - msg: 'Market Index Already Initialized'; - }, - { - code: 6009; - name: 'userAccountAndUserPositionsAccountMismatch'; - msg: 'User Account And User Positions Account Mismatch'; - }, - { - code: 6010; - name: 'userHasNoPositionInMarket'; - msg: 'User Has No Position In Market'; - }, - { - code: 6011; - name: 'invalidInitialPeg'; - msg: 'Invalid Initial Peg'; - }, - { - code: 6012; - name: 'invalidRepegRedundant'; - msg: 'AMM repeg already configured with amt given'; - }, - { - code: 6013; - name: 'invalidRepegDirection'; - msg: 'AMM repeg incorrect repeg direction'; - }, - { - code: 6014; - name: 'invalidRepegProfitability'; - msg: 'AMM repeg out of bounds pnl'; - }, - { - code: 6015; - name: 'slippageOutsideLimit'; - msg: 'Slippage Outside Limit Price'; - }, - { - code: 6016; - name: 'orderSizeTooSmall'; - msg: 'Order Size Too Small'; - }, - { - code: 6017; - name: 'invalidUpdateK'; - msg: 'Price change too large when updating K'; - }, - { - code: 6018; - name: 'adminWithdrawTooLarge'; - msg: 'Admin tried to withdraw amount larger than fees collected'; - }, - { - code: 6019; - name: 'mathError'; - msg: 'Math Error'; - }, - { - code: 6020; - name: 'bnConversionError'; - msg: 'Conversion to u128/u64 failed with an overflow or underflow'; - }, - { - code: 6021; - name: 'clockUnavailable'; - msg: 'Clock unavailable'; - }, - { - code: 6022; - name: 'unableToLoadOracle'; - msg: 'Unable To Load Oracles'; - }, - { - code: 6023; - name: 'priceBandsBreached'; - msg: 'Price Bands Breached'; - }, - { - code: 6024; - name: 'exchangePaused'; - msg: 'Exchange is paused'; - }, - { - code: 6025; - name: 'invalidWhitelistToken'; - msg: 'Invalid whitelist token'; - }, - { - code: 6026; - name: 'whitelistTokenNotFound'; - msg: 'Whitelist token not found'; - }, - { - code: 6027; - name: 'invalidDiscountToken'; - msg: 'Invalid discount token'; - }, - { - code: 6028; - name: 'discountTokenNotFound'; - msg: 'Discount token not found'; - }, - { - code: 6029; - name: 'referrerNotFound'; - msg: 'Referrer not found'; - }, - { - code: 6030; - name: 'referrerStatsNotFound'; - msg: 'referrerNotFound'; - }, - { - code: 6031; - name: 'referrerMustBeWritable'; - msg: 'referrerMustBeWritable'; - }, - { - code: 6032; - name: 'referrerStatsMustBeWritable'; - msg: 'referrerMustBeWritable'; - }, - { - code: 6033; - name: 'referrerAndReferrerStatsAuthorityUnequal'; - msg: 'referrerAndReferrerStatsAuthorityUnequal'; - }, - { - code: 6034; - name: 'invalidReferrer'; - msg: 'invalidReferrer'; - }, - { - code: 6035; - name: 'invalidOracle'; - msg: 'invalidOracle'; - }, - { - code: 6036; - name: 'oracleNotFound'; - msg: 'oracleNotFound'; - }, - { - code: 6037; - name: 'liquidationsBlockedByOracle'; - msg: 'Liquidations Blocked By Oracle'; - }, - { - code: 6038; - name: 'maxDeposit'; - msg: 'Can not deposit more than max deposit'; - }, - { - code: 6039; - name: 'cantDeleteUserWithCollateral'; - msg: 'Can not delete user that still has collateral'; - }, - { - code: 6040; - name: 'invalidFundingProfitability'; - msg: 'AMM funding out of bounds pnl'; - }, - { - code: 6041; - name: 'castingFailure'; - msg: 'Casting Failure'; - }, - { - code: 6042; - name: 'invalidOrder'; - msg: 'invalidOrder'; - }, - { - code: 6043; - name: 'invalidOrderMaxTs'; - msg: 'invalidOrderMaxTs'; - }, - { - code: 6044; - name: 'invalidOrderMarketType'; - msg: 'invalidOrderMarketType'; - }, - { - code: 6045; - name: 'invalidOrderForInitialMarginReq'; - msg: 'invalidOrderForInitialMarginReq'; - }, - { - code: 6046; - name: 'invalidOrderNotRiskReducing'; - msg: 'invalidOrderNotRiskReducing'; - }, - { - code: 6047; - name: 'invalidOrderSizeTooSmall'; - msg: 'invalidOrderSizeTooSmall'; - }, - { - code: 6048; - name: 'invalidOrderNotStepSizeMultiple'; - msg: 'invalidOrderNotStepSizeMultiple'; - }, - { - code: 6049; - name: 'invalidOrderBaseQuoteAsset'; - msg: 'invalidOrderBaseQuoteAsset'; - }, - { - code: 6050; - name: 'invalidOrderIoc'; - msg: 'invalidOrderIoc'; - }, - { - code: 6051; - name: 'invalidOrderPostOnly'; - msg: 'invalidOrderPostOnly'; - }, - { - code: 6052; - name: 'invalidOrderIocPostOnly'; - msg: 'invalidOrderIocPostOnly'; - }, - { - code: 6053; - name: 'invalidOrderTrigger'; - msg: 'invalidOrderTrigger'; - }, - { - code: 6054; - name: 'invalidOrderAuction'; - msg: 'invalidOrderAuction'; - }, - { - code: 6055; - name: 'invalidOrderOracleOffset'; - msg: 'invalidOrderOracleOffset'; - }, - { - code: 6056; - name: 'invalidOrderMinOrderSize'; - msg: 'invalidOrderMinOrderSize'; - }, - { - code: 6057; - name: 'placePostOnlyLimitFailure'; - msg: 'Failed to Place Post-Only Limit Order'; - }, - { - code: 6058; - name: 'userHasNoOrder'; - msg: 'User has no order'; - }, - { - code: 6059; - name: 'orderAmountTooSmall'; - msg: 'Order Amount Too Small'; - }, - { - code: 6060; - name: 'maxNumberOfOrders'; - msg: 'Max number of orders taken'; - }, - { - code: 6061; - name: 'orderDoesNotExist'; - msg: 'Order does not exist'; - }, - { - code: 6062; - name: 'orderNotOpen'; - msg: 'Order not open'; - }, - { - code: 6063; - name: 'fillOrderDidNotUpdateState'; - msg: 'fillOrderDidNotUpdateState'; - }, - { - code: 6064; - name: 'reduceOnlyOrderIncreasedRisk'; - msg: 'Reduce only order increased risk'; - }, - { - code: 6065; - name: 'unableToLoadAccountLoader'; - msg: 'Unable to load AccountLoader'; - }, - { - code: 6066; - name: 'tradeSizeTooLarge'; - msg: 'Trade Size Too Large'; - }, - { - code: 6067; - name: 'userCantReferThemselves'; - msg: 'User cant refer themselves'; - }, - { - code: 6068; - name: 'didNotReceiveExpectedReferrer'; - msg: 'Did not receive expected referrer'; - }, - { - code: 6069; - name: 'couldNotDeserializeReferrer'; - msg: 'Could not deserialize referrer'; - }, - { - code: 6070; - name: 'couldNotDeserializeReferrerStats'; - msg: 'Could not deserialize referrer stats'; - }, - { - code: 6071; - name: 'userOrderIdAlreadyInUse'; - msg: 'User Order Id Already In Use'; - }, - { - code: 6072; - name: 'noPositionsLiquidatable'; - msg: 'No positions liquidatable'; - }, - { - code: 6073; - name: 'invalidMarginRatio'; - msg: 'Invalid Margin Ratio'; - }, - { - code: 6074; - name: 'cantCancelPostOnlyOrder'; - msg: 'Cant Cancel Post Only Order'; - }, - { - code: 6075; - name: 'invalidOracleOffset'; - msg: 'invalidOracleOffset'; - }, - { - code: 6076; - name: 'cantExpireOrders'; - msg: 'cantExpireOrders'; - }, - { - code: 6077; - name: 'couldNotLoadMarketData'; - msg: 'couldNotLoadMarketData'; - }, - { - code: 6078; - name: 'perpMarketNotFound'; - msg: 'perpMarketNotFound'; - }, - { - code: 6079; - name: 'invalidMarketAccount'; - msg: 'invalidMarketAccount'; - }, - { - code: 6080; - name: 'unableToLoadPerpMarketAccount'; - msg: 'unableToLoadMarketAccount'; - }, - { - code: 6081; - name: 'marketWrongMutability'; - msg: 'marketWrongMutability'; - }, - { - code: 6082; - name: 'unableToCastUnixTime'; - msg: 'unableToCastUnixTime'; - }, - { - code: 6083; - name: 'couldNotFindSpotPosition'; - msg: 'couldNotFindSpotPosition'; - }, - { - code: 6084; - name: 'noSpotPositionAvailable'; - msg: 'noSpotPositionAvailable'; - }, - { - code: 6085; - name: 'invalidSpotMarketInitialization'; - msg: 'invalidSpotMarketInitialization'; - }, - { - code: 6086; - name: 'couldNotLoadSpotMarketData'; - msg: 'couldNotLoadSpotMarketData'; - }, - { - code: 6087; - name: 'spotMarketNotFound'; - msg: 'spotMarketNotFound'; - }, - { - code: 6088; - name: 'invalidSpotMarketAccount'; - msg: 'invalidSpotMarketAccount'; - }, - { - code: 6089; - name: 'unableToLoadSpotMarketAccount'; - msg: 'unableToLoadSpotMarketAccount'; - }, - { - code: 6090; - name: 'spotMarketWrongMutability'; - msg: 'spotMarketWrongMutability'; - }, - { - code: 6091; - name: 'spotMarketInterestNotUpToDate'; - msg: 'spotInterestNotUpToDate'; - }, - { - code: 6092; - name: 'spotMarketInsufficientDeposits'; - msg: 'spotMarketInsufficientDeposits'; - }, - { - code: 6093; - name: 'userMustSettleTheirOwnPositiveUnsettledPnl'; - msg: 'userMustSettleTheirOwnPositiveUnsettledPnl'; - }, - { - code: 6094; - name: 'cantUpdatePoolBalanceType'; - msg: 'cantUpdatePoolBalanceType'; - }, - { - code: 6095; - name: 'insufficientCollateralForSettlingPnl'; - msg: 'insufficientCollateralForSettlingPnl'; - }, - { - code: 6096; - name: 'ammNotUpdatedInSameSlot'; - msg: 'ammNotUpdatedInSameSlot'; - }, - { - code: 6097; - name: 'auctionNotComplete'; - msg: 'auctionNotComplete'; - }, - { - code: 6098; - name: 'makerNotFound'; - msg: 'makerNotFound'; - }, - { - code: 6099; - name: 'makerStatsNotFound'; - msg: 'makerNotFound'; - }, - { - code: 6100; - name: 'makerMustBeWritable'; - msg: 'makerMustBeWritable'; - }, - { - code: 6101; - name: 'makerStatsMustBeWritable'; - msg: 'makerMustBeWritable'; - }, - { - code: 6102; - name: 'makerOrderNotFound'; - msg: 'makerOrderNotFound'; - }, - { - code: 6103; - name: 'couldNotDeserializeMaker'; - msg: 'couldNotDeserializeMaker'; - }, - { - code: 6104; - name: 'couldNotDeserializeMakerStats'; - msg: 'couldNotDeserializeMaker'; - }, - { - code: 6105; - name: 'auctionPriceDoesNotSatisfyMaker'; - msg: 'auctionPriceDoesNotSatisfyMaker'; - }, - { - code: 6106; - name: 'makerCantFulfillOwnOrder'; - msg: 'makerCantFulfillOwnOrder'; - }, - { - code: 6107; - name: 'makerOrderMustBePostOnly'; - msg: 'makerOrderMustBePostOnly'; - }, - { - code: 6108; - name: 'cantMatchTwoPostOnlys'; - msg: 'cantMatchTwoPostOnlys'; - }, - { - code: 6109; - name: 'orderBreachesOraclePriceLimits'; - msg: 'orderBreachesOraclePriceLimits'; - }, - { - code: 6110; - name: 'orderMustBeTriggeredFirst'; - msg: 'orderMustBeTriggeredFirst'; - }, - { - code: 6111; - name: 'orderNotTriggerable'; - msg: 'orderNotTriggerable'; - }, - { - code: 6112; - name: 'orderDidNotSatisfyTriggerCondition'; - msg: 'orderDidNotSatisfyTriggerCondition'; - }, - { - code: 6113; - name: 'positionAlreadyBeingLiquidated'; - msg: 'positionAlreadyBeingLiquidated'; - }, - { - code: 6114; - name: 'positionDoesntHaveOpenPositionOrOrders'; - msg: 'positionDoesntHaveOpenPositionOrOrders'; - }, - { - code: 6115; - name: 'allOrdersAreAlreadyLiquidations'; - msg: 'allOrdersAreAlreadyLiquidations'; - }, - { - code: 6116; - name: 'cantCancelLiquidationOrder'; - msg: 'cantCancelLiquidationOrder'; - }, - { - code: 6117; - name: 'userIsBeingLiquidated'; - msg: 'userIsBeingLiquidated'; - }, - { - code: 6118; - name: 'liquidationsOngoing'; - msg: 'liquidationsOngoing'; - }, - { - code: 6119; - name: 'wrongSpotBalanceType'; - msg: 'wrongSpotBalanceType'; - }, - { - code: 6120; - name: 'userCantLiquidateThemself'; - msg: 'userCantLiquidateThemself'; - }, - { - code: 6121; - name: 'invalidPerpPositionToLiquidate'; - msg: 'invalidPerpPositionToLiquidate'; - }, - { - code: 6122; - name: 'invalidBaseAssetAmountForLiquidatePerp'; - msg: 'invalidBaseAssetAmountForLiquidatePerp'; - }, - { - code: 6123; - name: 'invalidPositionLastFundingRate'; - msg: 'invalidPositionLastFundingRate'; - }, - { - code: 6124; - name: 'invalidPositionDelta'; - msg: 'invalidPositionDelta'; - }, - { - code: 6125; - name: 'userBankrupt'; - msg: 'userBankrupt'; - }, - { - code: 6126; - name: 'userNotBankrupt'; - msg: 'userNotBankrupt'; - }, - { - code: 6127; - name: 'userHasInvalidBorrow'; - msg: 'userHasInvalidBorrow'; - }, - { - code: 6128; - name: 'dailyWithdrawLimit'; - msg: 'dailyWithdrawLimit'; - }, - { - code: 6129; - name: 'defaultError'; - msg: 'defaultError'; - }, - { - code: 6130; - name: 'insufficientLpTokens'; - msg: 'Insufficient LP tokens'; - }, - { - code: 6131; - name: 'cantLpWithPerpPosition'; - msg: 'Cant LP with a market position'; - }, - { - code: 6132; - name: 'unableToBurnLpTokens'; - msg: 'Unable to burn LP tokens'; - }, - { - code: 6133; - name: 'tryingToRemoveLiquidityTooFast'; - msg: 'Trying to remove liqudity too fast after adding it'; - }, - { - code: 6134; - name: 'invalidSpotMarketVault'; - msg: 'Invalid Spot Market Vault'; - }, - { - code: 6135; - name: 'invalidSpotMarketState'; - msg: 'Invalid Spot Market State'; - }, - { - code: 6136; - name: 'invalidSerumProgram'; - msg: 'invalidSerumProgram'; - }, - { - code: 6137; - name: 'invalidSerumMarket'; - msg: 'invalidSerumMarket'; - }, - { - code: 6138; - name: 'invalidSerumBids'; - msg: 'invalidSerumBids'; - }, - { - code: 6139; - name: 'invalidSerumAsks'; - msg: 'invalidSerumAsks'; - }, - { - code: 6140; - name: 'invalidSerumOpenOrders'; - msg: 'invalidSerumOpenOrders'; - }, - { - code: 6141; - name: 'failedSerumCpi'; - msg: 'failedSerumCpi'; - }, - { - code: 6142; - name: 'failedToFillOnExternalMarket'; - msg: 'failedToFillOnExternalMarket'; - }, - { - code: 6143; - name: 'invalidFulfillmentConfig'; - msg: 'invalidFulfillmentConfig'; - }, - { - code: 6144; - name: 'invalidFeeStructure'; - msg: 'invalidFeeStructure'; - }, - { - code: 6145; - name: 'insufficientIfShares'; - msg: 'Insufficient IF shares'; - }, - { - code: 6146; - name: 'marketActionPaused'; - msg: 'the Market has paused this action'; - }, - { - code: 6147; - name: 'marketPlaceOrderPaused'; - msg: 'the Market status doesnt allow placing orders'; - }, - { - code: 6148; - name: 'marketFillOrderPaused'; - msg: 'the Market status doesnt allow filling orders'; - }, - { - code: 6149; - name: 'marketWithdrawPaused'; - msg: 'the Market status doesnt allow withdraws'; - }, - { - code: 6150; - name: 'protectedAssetTierViolation'; - msg: 'Action violates the Protected Asset Tier rules'; - }, - { - code: 6151; - name: 'isolatedAssetTierViolation'; - msg: 'Action violates the Isolated Asset Tier rules'; - }, - { - code: 6152; - name: 'userCantBeDeleted'; - msg: 'User Cant Be Deleted'; - }, - { - code: 6153; - name: 'reduceOnlyWithdrawIncreasedRisk'; - msg: 'Reduce Only Withdraw Increased Risk'; - }, - { - code: 6154; - name: 'maxOpenInterest'; - msg: 'Max Open Interest'; - }, - { - code: 6155; - name: 'cantResolvePerpBankruptcy'; - msg: 'Cant Resolve Perp Bankruptcy'; - }, - { - code: 6156; - name: 'liquidationDoesntSatisfyLimitPrice'; - msg: 'Liquidation Doesnt Satisfy Limit Price'; - }, - { - code: 6157; - name: 'marginTradingDisabled'; - msg: 'Margin Trading Disabled'; - }, - { - code: 6158; - name: 'invalidMarketStatusToSettlePnl'; - msg: 'Invalid Market Status to Settle Perp Pnl'; - }, - { - code: 6159; - name: 'perpMarketNotInSettlement'; - msg: 'perpMarketNotInSettlement'; - }, - { - code: 6160; - name: 'perpMarketNotInReduceOnly'; - msg: 'perpMarketNotInReduceOnly'; - }, - { - code: 6161; - name: 'perpMarketSettlementBufferNotReached'; - msg: 'perpMarketSettlementBufferNotReached'; - }, - { - code: 6162; - name: 'perpMarketSettlementUserHasOpenOrders'; - msg: 'perpMarketSettlementUserHasOpenOrders'; - }, - { - code: 6163; - name: 'perpMarketSettlementUserHasActiveLp'; - msg: 'perpMarketSettlementUserHasActiveLp'; - }, - { - code: 6164; - name: 'unableToSettleExpiredUserPosition'; - msg: 'unableToSettleExpiredUserPosition'; - }, - { - code: 6165; - name: 'unequalMarketIndexForSpotTransfer'; - msg: 'unequalMarketIndexForSpotTransfer'; - }, - { - code: 6166; - name: 'invalidPerpPositionDetected'; - msg: 'invalidPerpPositionDetected'; - }, - { - code: 6167; - name: 'invalidSpotPositionDetected'; - msg: 'invalidSpotPositionDetected'; - }, - { - code: 6168; - name: 'invalidAmmDetected'; - msg: 'invalidAmmDetected'; - }, - { - code: 6169; - name: 'invalidAmmForFillDetected'; - msg: 'invalidAmmForFillDetected'; - }, - { - code: 6170; - name: 'invalidAmmLimitPriceOverride'; - msg: 'invalidAmmLimitPriceOverride'; - }, - { - code: 6171; - name: 'invalidOrderFillPrice'; - msg: 'invalidOrderFillPrice'; - }, - { - code: 6172; - name: 'spotMarketBalanceInvariantViolated'; - msg: 'spotMarketBalanceInvariantViolated'; - }, - { - code: 6173; - name: 'spotMarketVaultInvariantViolated'; - msg: 'spotMarketVaultInvariantViolated'; - }, - { - code: 6174; - name: 'invalidPda'; - msg: 'invalidPda'; - }, - { - code: 6175; - name: 'invalidPdaSigner'; - msg: 'invalidPdaSigner'; - }, - { - code: 6176; - name: 'revenueSettingsCannotSettleToIf'; - msg: 'revenueSettingsCannotSettleToIf'; - }, - { - code: 6177; - name: 'noRevenueToSettleToIf'; - msg: 'noRevenueToSettleToIf'; - }, - { - code: 6178; - name: 'noAmmPerpPnlDeficit'; - msg: 'noAmmPerpPnlDeficit'; - }, - { - code: 6179; - name: 'sufficientPerpPnlPool'; - msg: 'sufficientPerpPnlPool'; - }, - { - code: 6180; - name: 'insufficientPerpPnlPool'; - msg: 'insufficientPerpPnlPool'; - }, - { - code: 6181; - name: 'perpPnlDeficitBelowThreshold'; - msg: 'perpPnlDeficitBelowThreshold'; - }, - { - code: 6182; - name: 'maxRevenueWithdrawPerPeriodReached'; - msg: 'maxRevenueWithdrawPerPeriodReached'; - }, - { - code: 6183; - name: 'maxIfWithdrawReached'; - msg: 'invalidSpotPositionDetected'; - }, - { - code: 6184; - name: 'noIfWithdrawAvailable'; - msg: 'noIfWithdrawAvailable'; - }, - { - code: 6185; - name: 'invalidIfUnstake'; - msg: 'invalidIfUnstake'; - }, - { - code: 6186; - name: 'invalidIfUnstakeSize'; - msg: 'invalidIfUnstakeSize'; - }, - { - code: 6187; - name: 'invalidIfUnstakeCancel'; - msg: 'invalidIfUnstakeCancel'; - }, - { - code: 6188; - name: 'invalidIfForNewStakes'; - msg: 'invalidIfForNewStakes'; - }, - { - code: 6189; - name: 'invalidIfRebase'; - msg: 'invalidIfRebase'; - }, - { - code: 6190; - name: 'invalidInsuranceUnstakeSize'; - msg: 'invalidInsuranceUnstakeSize'; - }, - { - code: 6191; - name: 'invalidOrderLimitPrice'; - msg: 'invalidOrderLimitPrice'; - }, - { - code: 6192; - name: 'invalidIfDetected'; - msg: 'invalidIfDetected'; - }, - { - code: 6193; - name: 'invalidAmmMaxSpreadDetected'; - msg: 'invalidAmmMaxSpreadDetected'; - }, - { - code: 6194; - name: 'invalidConcentrationCoef'; - msg: 'invalidConcentrationCoef'; - }, - { - code: 6195; - name: 'invalidSrmVault'; - msg: 'invalidSrmVault'; - }, - { - code: 6196; - name: 'invalidVaultOwner'; - msg: 'invalidVaultOwner'; - }, - { - code: 6197; - name: 'invalidMarketStatusForFills'; - msg: 'invalidMarketStatusForFills'; - }, - { - code: 6198; - name: 'ifWithdrawRequestInProgress'; - msg: 'ifWithdrawRequestInProgress'; - }, - { - code: 6199; - name: 'noIfWithdrawRequestInProgress'; - msg: 'noIfWithdrawRequestInProgress'; - }, - { - code: 6200; - name: 'ifWithdrawRequestTooSmall'; - msg: 'ifWithdrawRequestTooSmall'; - }, - { - code: 6201; - name: 'incorrectSpotMarketAccountPassed'; - msg: 'incorrectSpotMarketAccountPassed'; - }, - { - code: 6202; - name: 'blockchainClockInconsistency'; - msg: 'blockchainClockInconsistency'; - }, - { - code: 6203; - name: 'invalidIfSharesDetected'; - msg: 'invalidIfSharesDetected'; - }, - { - code: 6204; - name: 'newLpSizeTooSmall'; - msg: 'newLpSizeTooSmall'; - }, - { - code: 6205; - name: 'marketStatusInvalidForNewLp'; - msg: 'marketStatusInvalidForNewLp'; - }, - { - code: 6206; - name: 'invalidMarkTwapUpdateDetected'; - msg: 'invalidMarkTwapUpdateDetected'; - }, - { - code: 6207; - name: 'marketSettlementAttemptOnActiveMarket'; - msg: 'marketSettlementAttemptOnActiveMarket'; - }, - { - code: 6208; - name: 'marketSettlementRequiresSettledLp'; - msg: 'marketSettlementRequiresSettledLp'; - }, - { - code: 6209; - name: 'marketSettlementAttemptTooEarly'; - msg: 'marketSettlementAttemptTooEarly'; - }, - { - code: 6210; - name: 'marketSettlementTargetPriceInvalid'; - msg: 'marketSettlementTargetPriceInvalid'; - }, - { - code: 6211; - name: 'unsupportedSpotMarket'; - msg: 'unsupportedSpotMarket'; - }, - { - code: 6212; - name: 'spotOrdersDisabled'; - msg: 'spotOrdersDisabled'; - }, - { - code: 6213; - name: 'marketBeingInitialized'; - msg: 'Market Being Initialized'; - }, - { - code: 6214; - name: 'invalidUserSubAccountId'; - msg: 'Invalid Sub Account Id'; - }, - { - code: 6215; - name: 'invalidTriggerOrderCondition'; - msg: 'Invalid Trigger Order Condition'; - }, - { - code: 6216; - name: 'invalidSpotPosition'; - msg: 'Invalid Spot Position'; - }, - { - code: 6217; - name: 'cantTransferBetweenSameUserAccount'; - msg: 'Cant transfer between same user account'; - }, - { - code: 6218; - name: 'invalidPerpPosition'; - msg: 'Invalid Perp Position'; - }, - { - code: 6219; - name: 'unableToGetLimitPrice'; - msg: 'Unable To Get Limit Price'; - }, - { - code: 6220; - name: 'invalidLiquidation'; - msg: 'Invalid Liquidation'; - }, - { - code: 6221; - name: 'spotFulfillmentConfigDisabled'; - msg: 'Spot Fulfillment Config Disabled'; - }, - { - code: 6222; - name: 'invalidMaker'; - msg: 'Invalid Maker'; - }, - { - code: 6223; - name: 'failedUnwrap'; - msg: 'Failed Unwrap'; - }, - { - code: 6224; - name: 'maxNumberOfUsers'; - msg: 'Max Number Of Users'; - }, - { - code: 6225; - name: 'invalidOracleForSettlePnl'; - msg: 'invalidOracleForSettlePnl'; - }, - { - code: 6226; - name: 'marginOrdersOpen'; - msg: 'marginOrdersOpen'; - }, - { - code: 6227; - name: 'tierViolationLiquidatingPerpPnl'; - msg: 'tierViolationLiquidatingPerpPnl'; - }, - { - code: 6228; - name: 'couldNotLoadUserData'; - msg: 'couldNotLoadUserData'; - }, - { - code: 6229; - name: 'userWrongMutability'; - msg: 'userWrongMutability'; - }, - { - code: 6230; - name: 'invalidUserAccount'; - msg: 'invalidUserAccount'; - }, - { - code: 6231; - name: 'couldNotLoadUserStatsData'; - msg: 'couldNotLoadUserData'; - }, - { - code: 6232; - name: 'userStatsWrongMutability'; - msg: 'userWrongMutability'; - }, - { - code: 6233; - name: 'invalidUserStatsAccount'; - msg: 'invalidUserAccount'; - }, - { - code: 6234; - name: 'userNotFound'; - msg: 'userNotFound'; - }, - { - code: 6235; - name: 'unableToLoadUserAccount'; - msg: 'unableToLoadUserAccount'; - }, - { - code: 6236; - name: 'userStatsNotFound'; - msg: 'userStatsNotFound'; - }, - { - code: 6237; - name: 'unableToLoadUserStatsAccount'; - msg: 'unableToLoadUserStatsAccount'; - }, - { - code: 6238; - name: 'userNotInactive'; - msg: 'User Not Inactive'; - }, - { - code: 6239; - name: 'revertFill'; - msg: 'revertFill'; - }, - { - code: 6240; - name: 'invalidMarketAccountforDeletion'; - msg: 'Invalid MarketAccount for Deletion'; - }, - { - code: 6241; - name: 'invalidSpotFulfillmentParams'; - msg: 'Invalid Spot Fulfillment Params'; - }, - { - code: 6242; - name: 'failedToGetMint'; - msg: 'Failed to Get Mint'; - }, - { - code: 6243; - name: 'failedPhoenixCpi'; - msg: 'failedPhoenixCpi'; - }, - { - code: 6244; - name: 'failedToDeserializePhoenixMarket'; - msg: 'failedToDeserializePhoenixMarket'; - }, - { - code: 6245; - name: 'invalidPricePrecision'; - msg: 'invalidPricePrecision'; - }, - { - code: 6246; - name: 'invalidPhoenixProgram'; - msg: 'invalidPhoenixProgram'; - }, - { - code: 6247; - name: 'invalidPhoenixMarket'; - msg: 'invalidPhoenixMarket'; - }, - { - code: 6248; - name: 'invalidSwap'; - msg: 'invalidSwap'; - }, - { - code: 6249; - name: 'swapLimitPriceBreached'; - msg: 'swapLimitPriceBreached'; - }, - { - code: 6250; - name: 'spotMarketReduceOnly'; - msg: 'spotMarketReduceOnly'; - }, - { - code: 6251; - name: 'fundingWasNotUpdated'; - msg: 'fundingWasNotUpdated'; - }, - { - code: 6252; - name: 'impossibleFill'; - msg: 'impossibleFill'; - }, - { - code: 6253; - name: 'cantUpdatePerpBidAskTwap'; - msg: 'cantUpdatePerpBidAskTwap'; - }, - { - code: 6254; - name: 'userReduceOnly'; - msg: 'userReduceOnly'; - }, - { - code: 6255; - name: 'invalidMarginCalculation'; - msg: 'invalidMarginCalculation'; - }, - { - code: 6256; - name: 'cantPayUserInitFee'; - msg: 'cantPayUserInitFee'; - }, - { - code: 6257; - name: 'cantReclaimRent'; - msg: 'cantReclaimRent'; - }, - { - code: 6258; - name: 'insuranceFundOperationPaused'; - msg: 'insuranceFundOperationPaused'; - }, - { - code: 6259; - name: 'noUnsettledPnl'; - msg: 'noUnsettledPnl'; - }, - { - code: 6260; - name: 'pnlPoolCantSettleUser'; - msg: 'pnlPoolCantSettleUser'; - }, - { - code: 6261; - name: 'oracleNonPositive'; - msg: 'oracleInvalid'; - }, - { - code: 6262; - name: 'oracleTooVolatile'; - msg: 'oracleTooVolatile'; - }, - { - code: 6263; - name: 'oracleTooUncertain'; - msg: 'oracleTooUncertain'; - }, - { - code: 6264; - name: 'oracleStaleForMargin'; - msg: 'oracleStaleForMargin'; - }, - { - code: 6265; - name: 'oracleInsufficientDataPoints'; - msg: 'oracleInsufficientDataPoints'; - }, - { - code: 6266; - name: 'oracleStaleForAmm'; - msg: 'oracleStaleForAmm'; - }, - { - code: 6267; - name: 'unableToParsePullOracleMessage'; - msg: 'Unable to parse pull oracle message'; - }, - { - code: 6268; - name: 'maxBorrows'; - msg: 'Can not borow more than max borrows'; - }, - { - code: 6269; - name: 'oracleUpdatesNotMonotonic'; - msg: 'Updates must be monotonically increasing'; - }, - { - code: 6270; - name: 'oraclePriceFeedMessageMismatch'; - msg: 'Trying to update price feed with the wrong feed id'; - }, - { - code: 6271; - name: 'oracleUnsupportedMessageType'; - msg: 'The message in the update must be a PriceFeedMessage'; - }, - { - code: 6272; - name: 'oracleDeserializeMessageFailed'; - msg: 'Could not deserialize the message in the update'; - }, - { - code: 6273; - name: 'oracleWrongGuardianSetOwner'; - msg: 'Wrong guardian set owner in update price atomic'; - }, - { - code: 6274; - name: 'oracleWrongWriteAuthority'; - msg: 'Oracle post update atomic price feed account must be drift program'; - }, - { - code: 6275; - name: 'oracleWrongVaaOwner'; - msg: 'Oracle vaa owner must be wormhole program'; - }, - { - code: 6276; - name: 'oracleTooManyPriceAccountUpdates'; - msg: 'Multi updates must have 2 or fewer accounts passed in remaining accounts'; - }, - { - code: 6277; - name: 'oracleMismatchedVaaAndPriceUpdates'; - msg: "Don't have the same remaining accounts number and pyth updates left"; - }, - { - code: 6278; - name: 'oracleBadRemainingAccountPublicKey'; - msg: 'Remaining account passed does not match oracle update derived pda'; - }, - { - code: 6279; - name: 'failedOpenbookV2cpi'; - msg: 'failedOpenbookV2cpi'; - }, - { - code: 6280; - name: 'invalidOpenbookV2Program'; - msg: 'invalidOpenbookV2Program'; - }, - { - code: 6281; - name: 'invalidOpenbookV2Market'; - msg: 'invalidOpenbookV2Market'; - }, - { - code: 6282; - name: 'nonZeroTransferFee'; - msg: 'Non zero transfer fee'; - }, - { - code: 6283; - name: 'liquidationOrderFailedToFill'; - msg: 'Liquidation order failed to fill'; - }, - { - code: 6284; - name: 'invalidPredictionMarketOrder'; - msg: 'Invalid prediction market order'; - }, - { - code: 6285; - name: 'invalidVerificationIxIndex'; - msg: 'Ed25519 Ix must be before place and make SignedMsg order ix'; - }, - { - code: 6286; - name: 'sigVerificationFailed'; - msg: 'SignedMsg message verificaiton failed'; - }, - { - code: 6287; - name: 'mismatchedSignedMsgOrderParamsMarketIndex'; - msg: 'Market index mismatched b/w taker and maker SignedMsg order params'; - }, - { - code: 6288; - name: 'invalidSignedMsgOrderParam'; - msg: 'Invalid SignedMsg order param'; - }, - { - code: 6289; - name: 'placeAndTakeOrderSuccessConditionFailed'; - msg: 'Place and take order success condition failed'; - }, - { - code: 6290; - name: 'invalidHighLeverageModeConfig'; - msg: 'Invalid High Leverage Mode Config'; - }, - { - code: 6291; - name: 'invalidRfqUserAccount'; - msg: 'Invalid RFQ User Account'; - }, - { - code: 6292; - name: 'rfqUserAccountWrongMutability'; - msg: 'RFQUserAccount should be mutable'; - }, - { - code: 6293; - name: 'rfqUserAccountFull'; - msg: 'RFQUserAccount has too many active RFQs'; - }, - { - code: 6294; - name: 'rfqOrderNotFilled'; - msg: 'RFQ order not filled as expected'; - }, - { - code: 6295; - name: 'invalidRfqOrder'; - msg: 'RFQ orders must be jit makers'; - }, - { - code: 6296; - name: 'invalidRfqMatch'; - msg: 'RFQ matches must be valid'; - }, - { - code: 6297; - name: 'invalidSignedMsgUserAccount'; - msg: 'Invalid SignedMsg user account'; - }, - { - code: 6298; - name: 'signedMsgUserAccountWrongMutability'; - msg: 'SignedMsg account wrong mutability'; - }, - { - code: 6299; - name: 'signedMsgUserOrdersAccountFull'; - msg: 'SignedMsgUserAccount has too many active orders'; - }, - { - code: 6300; - name: 'signedMsgOrderDoesNotExist'; - msg: 'Order with SignedMsg uuid does not exist'; - }, - { - code: 6301; - name: 'invalidSignedMsgOrderId'; - msg: 'SignedMsg order id cannot be 0s'; - }, - { - code: 6302; - name: 'invalidPoolId'; - msg: 'Invalid pool id'; - }, - { - code: 6303; - name: 'invalidProtectedMakerModeConfig'; - msg: 'Invalid Protected Maker Mode Config'; - }, - { - code: 6304; - name: 'invalidPythLazerStorageOwner'; - msg: 'Invalid pyth lazer storage owner'; - }, - { - code: 6305; - name: 'unverifiedPythLazerMessage'; - msg: 'Verification of pyth lazer message failed'; - }, - { - code: 6306; - name: 'invalidPythLazerMessage'; - msg: 'Invalid pyth lazer message'; - }, - { - code: 6307; - name: 'pythLazerMessagePriceFeedMismatch'; - msg: 'Pyth lazer message does not correspond to correct fed id'; - }, - { - code: 6308; - name: 'invalidLiquidateSpotWithSwap'; - msg: 'invalidLiquidateSpotWithSwap'; - }, - { - code: 6309; - name: 'signedMsgUserContextUserMismatch'; - msg: 'User in SignedMsg message does not match user in ix context'; - }, - { - code: 6310; - name: 'userFuelOverflowThresholdNotMet'; - msg: 'User fuel overflow threshold not met'; - }, - { - code: 6311; - name: 'fuelOverflowAccountNotFound'; - msg: 'FuelOverflow account not found'; - }, - { - code: 6312; - name: 'invalidTransferPerpPosition'; - msg: 'Invalid Transfer Perp Position'; - }, - { - code: 6313; - name: 'invalidSignedMsgUserOrdersResize'; - msg: 'Invalid SignedMsgUserOrders resize'; - }, - { - code: 6314; - name: 'couldNotDeserializeHighLeverageModeConfig'; - msg: 'Could not deserialize high leverage mode config'; - }, - { - code: 6315; - name: 'invalidIfRebalanceConfig'; - msg: 'Invalid If Rebalance Config'; - }, - { - code: 6316; - name: 'invalidIfRebalanceSwap'; - msg: 'Invalid If Rebalance Swap'; - }, - { - code: 6317; - name: 'invalidRevenueShareResize'; - msg: 'Invalid RevenueShare resize'; - }, - { - code: 6318; - name: 'builderRevoked'; - msg: 'Builder has been revoked'; - }, - { - code: 6319; - name: 'invalidBuilderFee'; - msg: 'Builder fee is greater than max fee bps'; - }, - { - code: 6320; - name: 'revenueShareEscrowAuthorityMismatch'; - msg: 'RevenueShareEscrow authority mismatch'; - }, - { - code: 6321; - name: 'revenueShareEscrowOrdersAccountFull'; - msg: 'RevenueShareEscrow has too many active orders'; - }, - { - code: 6322; - name: 'invalidRevenueShareAccount'; - msg: 'Invalid RevenueShareAccount'; - }, - { - code: 6323; - name: 'cannotRevokeBuilderWithOpenOrders'; - msg: 'Cannot revoke builder with open orders'; - }, - { - code: 6324; - name: 'unableToLoadRevenueShareAccount'; - msg: 'Unable to load builder account'; - }, - { - code: 6325; - name: 'invalidConstituent'; - msg: 'Invalid Constituent'; - }, - { - code: 6326; - name: 'invalidAmmConstituentMappingArgument'; - msg: 'Invalid Amm Constituent Mapping argument'; - }, - { - code: 6327; - name: 'constituentNotFound'; - msg: 'Constituent not found'; - }, - { - code: 6328; - name: 'constituentCouldNotLoad'; - msg: 'Constituent could not load'; - }, - { - code: 6329; - name: 'constituentWrongMutability'; - msg: 'Constituent wrong mutability'; - }, - { - code: 6330; - name: 'wrongNumberOfConstituents'; - msg: 'Wrong number of constituents passed to instruction'; - }, - { - code: 6331; - name: 'insufficientConstituentTokenBalance'; - msg: 'Insufficient constituent token balance'; - }, - { - code: 6332; - name: 'ammCacheStale'; - msg: 'Amm Cache data too stale'; - }, - { - code: 6333; - name: 'lpPoolAumDelayed'; - msg: 'LP Pool AUM not updated recently'; - }, - { - code: 6334; - name: 'constituentOracleStale'; - msg: 'Constituent oracle is stale'; - }, - { - code: 6335; - name: 'lpInvariantFailed'; - msg: 'LP Invariant failed'; - }, - { - code: 6336; - name: 'invalidConstituentDerivativeWeights'; - msg: 'Invalid constituent derivative weights'; - }, - { - code: 6337; - name: 'maxDlpAumBreached'; - msg: 'Max DLP AUM Breached'; - }, - { - code: 6338; - name: 'settleLpPoolDisabled'; - msg: 'Settle Lp Pool Disabled'; - }, - { - code: 6339; - name: 'mintRedeemLpPoolDisabled'; - msg: 'Mint/Redeem Lp Pool Disabled'; - }, - { - code: 6340; - name: 'lpPoolSettleInvariantBreached'; - msg: 'Settlement amount exceeded'; - }, - { - code: 6341; - name: 'invalidConstituentOperation'; - msg: 'Invalid constituent operation'; - }, - { - code: 6342; - name: 'unauthorized'; - msg: 'Unauthorized for operation'; - }, - { - code: 6343; - name: 'invalidLpPoolId'; - msg: 'Invalid Lp Pool Id for Operation'; - }, - { - code: 6344; - name: 'marketIndexNotFoundAmmCache'; - msg: 'marketIndexNotFoundAmmCache'; - }, - ]; - types: [ - { - name: 'amm'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'oracle'; - docs: ['oracle price data public key']; - type: 'pubkey'; - }, - { - name: 'historicalOracleData'; - docs: ['stores historically witnessed oracle data']; - type: { - defined: { - name: 'historicalOracleData'; - }; - }; - }, - { - name: 'baseAssetAmountPerLp'; - docs: [ - 'accumulated base asset amount since inception per lp share', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteAssetAmountPerLp'; - docs: [ - 'accumulated quote asset amount since inception per lp share', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'feePool'; - docs: [ - 'partition of fees from perp market trading moved from pnl settlements', - ]; - type: { - defined: { - name: 'poolBalance'; - }; - }; - }, - { - name: 'baseAssetReserve'; - docs: [ - '`x` reserves for constant product mm formula (x * y = k)', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'quoteAssetReserve'; - docs: [ - '`y` reserves for constant product mm formula (x * y = k)', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'concentrationCoef'; - docs: [ - 'determines how close the min/max base asset reserve sit vs base reserves', - 'allow for decreasing slippage without increasing liquidity and v.v.', - 'precision: PERCENTAGE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'minBaseAssetReserve'; - docs: [ - 'minimum base_asset_reserve allowed before AMM is unavailable', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'maxBaseAssetReserve'; - docs: [ - 'maximum base_asset_reserve allowed before AMM is unavailable', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'sqrtK'; - docs: [ - '`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'pegMultiplier'; - docs: [ - 'normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced', - 'precision: PEG_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'terminalQuoteAssetReserve'; - docs: [ - 'y when market is balanced. stored to save computation', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'baseAssetAmountLong'; - docs: [ - 'always non-negative. tracks number of total longs in market (regardless of counterparty)', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'baseAssetAmountShort'; - docs: [ - 'always non-positive. tracks number of total shorts in market (regardless of counterparty)', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'baseAssetAmountWithAmm'; - docs: [ - 'tracks net position (longs-shorts) in market with AMM as counterparty', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'baseAssetAmountWithUnsettledLp'; - docs: [ - 'tracks net position (longs-shorts) in market with LPs as counterparty', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'maxOpenInterest'; - docs: [ - 'max allowed open interest, blocks trades that breach this value', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'quoteAssetAmount'; - docs: [ - "sum of all user's perp quote_asset_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteEntryAmountLong'; - docs: [ - "sum of all long user's quote_entry_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteEntryAmountShort'; - docs: [ - "sum of all short user's quote_entry_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteBreakEvenAmountLong'; - docs: [ - "sum of all long user's quote_break_even_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteBreakEvenAmountShort'; - docs: [ - "sum of all short user's quote_break_even_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'userLpShares'; - docs: [ - 'total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastFundingRate'; - docs: [ - 'last funding rate in this perp market (unit is quote per base)', - 'precision: FUNDING_RATE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastFundingRateLong'; - docs: [ - 'last funding rate for longs in this perp market (unit is quote per base)', - 'precision: FUNDING_RATE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastFundingRateShort'; - docs: [ - 'last funding rate for shorts in this perp market (unit is quote per base)', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'last24hAvgFundingRate'; - docs: [ - 'estimate of last 24h of funding rate perp market (unit is quote per base)', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'totalFee'; - docs: [ - 'total fees collected by this perp market', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'totalMmFee'; - docs: [ - "total fees collected by the vAMM's bid/ask spread", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'totalExchangeFee'; - docs: [ - 'total fees collected by exchange fee schedule', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalFeeMinusDistributions'; - docs: [ - 'total fees minus any recognized upnl and pool withdraws', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'totalFeeWithdrawn'; - docs: [ - 'sum of all fees from fee pool withdrawn to revenue pool', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalLiquidationFee'; - docs: [ - 'all fees collected by market for liquidations', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeFundingRateLong'; - docs: [ - 'accumulated funding rate for longs since inception in market', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'cumulativeFundingRateShort'; - docs: [ - 'accumulated funding rate for shorts since inception in market', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'totalSocialLoss'; - docs: [ - 'accumulated social loss paid by users since inception in market', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'askBaseAssetReserve'; - docs: [ - 'transformed base_asset_reserve for users going long', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'askQuoteAssetReserve'; - docs: [ - 'transformed quote_asset_reserve for users going long', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'bidBaseAssetReserve'; - docs: [ - 'transformed base_asset_reserve for users going short', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'bidQuoteAssetReserve'; - docs: [ - 'transformed quote_asset_reserve for users going short', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastOracleNormalisedPrice'; - docs: [ - 'the last seen oracle price partially shrunk toward the amm reserve price', - 'precision: PRICE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastOracleReservePriceSpreadPct'; - docs: [ - 'the gap between the oracle price and the reserve price = y * peg_multiplier / x', - ]; - type: 'i64'; - }, - { - name: 'lastBidPriceTwap'; - docs: [ - 'average estimate of bid price over funding_period', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastAskPriceTwap'; - docs: [ - 'average estimate of ask price over funding_period', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastMarkPriceTwap'; - docs: [ - 'average estimate of (bid+ask)/2 price over funding_period', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastMarkPriceTwap5min'; - docs: ['average estimate of (bid+ask)/2 price over FIVE_MINUTES']; - type: 'u64'; - }, - { - name: 'lastUpdateSlot'; - docs: ['the last blockchain slot the amm was updated']; - type: 'u64'; - }, - { - name: 'lastOracleConfPct'; - docs: [ - 'the pct size of the oracle confidence interval', - 'precision: PERCENTAGE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'netRevenueSinceLastFunding'; - docs: [ - 'the total_fee_minus_distribution change since the last funding update', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastFundingRateTs'; - docs: ['the last funding rate update unix_timestamp']; - type: 'i64'; - }, - { - name: 'fundingPeriod'; - docs: ['the periodicity of the funding rate updates']; - type: 'i64'; - }, - { - name: 'orderStepSize'; - docs: [ - 'the base step size (increment) of orders', - 'precision: BASE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'orderTickSize'; - docs: [ - 'the price tick size of orders', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'minOrderSize'; - docs: [ - 'the minimum base size of an order', - 'precision: BASE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'mmOracleSlot'; - docs: [ - 'the max base size a single user can have', - 'precision: BASE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'volume24h'; - docs: ['estimated total of volume in market', 'QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'longIntensityVolume'; - docs: ['the volume intensity of long fills against AMM']; - type: 'u64'; - }, - { - name: 'shortIntensityVolume'; - docs: ['the volume intensity of short fills against AMM']; - type: 'u64'; - }, - { - name: 'lastTradeTs'; - docs: [ - 'the blockchain unix timestamp at the time of the last trade', - ]; - type: 'i64'; - }, - { - name: 'markStd'; - docs: [ - 'estimate of standard deviation of the fill (mark) prices', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'oracleStd'; - docs: [ - 'estimate of standard deviation of the oracle price at each update', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastMarkPriceTwapTs'; - docs: ['the last unix_timestamp the mark twap was updated']; - type: 'i64'; - }, - { - name: 'baseSpread'; - docs: [ - 'the minimum spread the AMM can quote. also used as step size for some spread logic increases.', - ]; - type: 'u32'; - }, - { - name: 'maxSpread'; - docs: ['the maximum spread the AMM can quote']; - type: 'u32'; - }, - { - name: 'longSpread'; - docs: ['the spread for asks vs the reserve price']; - type: 'u32'; - }, - { - name: 'shortSpread'; - docs: ['the spread for bids vs the reserve price']; - type: 'u32'; - }, - { - name: 'mmOraclePrice'; - docs: ['MM oracle price']; - type: 'i64'; - }, - { - name: 'maxFillReserveFraction'; - docs: [ - 'the fraction of total available liquidity a single fill on the AMM can consume', - ]; - type: 'u16'; - }, - { - name: 'maxSlippageRatio'; - docs: ['the maximum slippage a single fill on the AMM can push']; - type: 'u16'; - }, - { - name: 'curveUpdateIntensity'; - docs: [ - 'the update intensity of AMM formulaic updates (adjusting k). 0-100', - ]; - type: 'u8'; - }, - { - name: 'ammJitIntensity'; - docs: [ - 'the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.', - '(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM.', - ]; - type: 'u8'; - }, - { - name: 'oracleSource'; - docs: [ - 'the oracle provider information. used to decode/scale the oracle public key', - ]; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'lastOracleValid'; - docs: [ - 'tracks whether the oracle was considered valid at the last AMM update', - ]; - type: 'bool'; - }, - { - name: 'targetBaseAssetAmountPerLp'; - docs: [ - 'the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split', - 'precision: BASE_PRECISION', - ]; - type: 'i32'; - }, - { - name: 'perLpBase'; - docs: [ - 'expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)', - ]; - type: 'i8'; - }, - { - name: 'oracleLowRiskSlotDelayOverride'; - docs: [ - 'the override for the state.min_perp_auction_duration', - '0 is no override, -1 is disable speed bump, 1-100 is literal speed bump', - ]; - type: 'i8'; - }, - { - name: 'ammSpreadAdjustment'; - docs: [ - 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', - ]; - type: 'i8'; - }, - { - name: 'oracleSlotDelayOverride'; - type: 'i8'; - }, - { - name: 'mmOracleSequenceId'; - type: 'u64'; - }, - { - name: 'netUnsettledFundingPnl'; - type: 'i64'; - }, - { - name: 'quoteAssetAmountWithUnsettledLp'; - type: 'i64'; - }, - { - name: 'referencePriceOffset'; - type: 'i32'; - }, - { - name: 'ammInventorySpreadAdjustment'; - docs: [ - 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', - ]; - type: 'i8'; - }, - { - name: 'referencePriceOffsetDeadbandPct'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 2]; - }; - }, - { - name: 'lastFundingOracleTwap'; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'addAmmConstituentMappingDatum'; - type: { - kind: 'struct'; - fields: [ - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'weight'; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'ammCache'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'cache'; - type: { - vec: { - defined: { - name: 'cacheInfo'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'ammConstituentDatum'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - { - name: 'lastSlot'; - type: 'u64'; - }, - { - name: 'weight'; - docs: [ - 'PERCENTAGE_PRECISION. The weight this constituent has on the perp market', - ]; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'ammConstituentMapping'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'lpPool'; - type: 'pubkey'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'weights'; - type: { - vec: { - defined: { - name: 'ammConstituentDatum'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'assetTier'; - type: { - kind: 'enum'; - variants: [ - { - name: 'collateral'; - }, - { - name: 'protected'; - }, - { - name: 'cross'; - }, - { - name: 'isolated'; - }, - { - name: 'unlisted'; - }, - ]; - }; - }, - { - name: 'builderInfo'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'maxFeeTenthBps'; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 6]; - }; - }, - ]; - }; - }, - { - name: 'cacheInfo'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'oracle'; - type: 'pubkey'; - }, - { - name: 'lastFeePoolTokenAmount'; - type: 'u128'; - }, - { - name: 'lastNetPnlPoolTokenAmount'; - type: 'i128'; - }, - { - name: 'lastExchangeFees'; - type: 'u128'; - }, - { - name: 'lastSettleAmmExFees'; - type: 'u128'; - }, - { - name: 'lastSettleAmmPnl'; - type: 'i128'; - }, - { - name: 'position'; - docs: ['BASE PRECISION']; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'lastSettleAmount'; - type: 'u64'; - }, - { - name: 'lastSettleSlot'; - type: 'u64'; - }, - { - name: 'lastSettleTs'; - type: 'i64'; - }, - { - name: 'quoteOwedFromLpPool'; - type: 'i64'; - }, - { - name: 'ammInventoryLimit'; - type: 'i64'; - }, - { - name: 'oraclePrice'; - type: 'i64'; - }, - { - name: 'oracleSlot'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'oracleSource'; - type: 'u8'; - }, - { - name: 'oracleValidity'; - type: 'u8'; - }, - { - name: 'lpStatusForPerpMarket'; - type: 'u8'; - }, - { - name: 'ammPositionScalar'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 34]; - }; - }, - ]; - }; - }, - { - name: 'constituent'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - docs: ['address of the constituent']; - type: 'pubkey'; - }, - { - name: 'mint'; - type: 'pubkey'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - { - name: 'vault'; - type: 'pubkey'; - }, - { - name: 'totalSwapFees'; - docs: [ - 'total fees received by the constituent. Positive = fees received, Negative = fees paid', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'spotBalance'; - docs: ['spot borrow-lend balance for constituent']; - type: { - defined: { - name: 'constituentSpotBalance'; - }; - }; - }, - { - name: 'lastSpotBalanceTokenAmount'; - type: 'i64'; - }, - { - name: 'cumulativeSpotInterestAccruedTokenAmount'; - type: 'i64'; - }, - { - name: 'maxWeightDeviation'; - docs: [ - 'max deviation from target_weight allowed for the constituent', - 'precision: PERCENTAGE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'swapFeeMin'; - docs: [ - 'min fee charged on swaps to/from this constituent', - 'precision: PERCENTAGE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'swapFeeMax'; - docs: [ - 'max fee charged on swaps to/from this constituent', - 'precision: PERCENTAGE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'maxBorrowTokenAmount'; - docs: ['Max Borrow amount:', 'precision: token precision']; - type: 'u64'; - }, - { - name: 'vaultTokenBalance'; - docs: ['ata token balance in token precision']; - type: 'u64'; - }, - { - name: 'lastOraclePrice'; - type: 'i64'; - }, - { - name: 'lastOracleSlot'; - type: 'u64'; - }, - { - name: 'oracleStalenessThreshold'; - docs: ['Delay allowed for valid AUM calculation']; - type: 'u64'; - }, - { - name: 'flashLoanInitialTokenAmount'; - type: 'u64'; - }, - { - name: 'nextSwapId'; - docs: [ - 'Every swap to/from this constituent has a monotonically increasing id. This is the next id to use', - ]; - type: 'u64'; - }, - { - name: 'derivativeWeight'; - docs: [ - 'percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight', - ]; - type: 'u64'; - }, - { - name: 'volatility'; - type: 'u64'; - }, - { - name: 'constituentDerivativeDepegThreshold'; - type: 'u64'; - }, - { - name: 'constituentDerivativeIndex'; - docs: [ - 'The `constituent_index` of the parent constituent. -1 if it is a parent index', - 'Example: if in a pool with SOL (parent) and dSOL (derivative),', - 'SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,', - 'dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1', - ]; - type: 'i16'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'decimals'; - type: 'u8'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'vaultBump'; - type: 'u8'; - }, - { - name: 'gammaInventory'; - type: 'u8'; - }, - { - name: 'gammaExecution'; - type: 'u8'; - }, - { - name: 'xi'; - type: 'u8'; - }, - { - name: 'status'; - type: 'u8'; - }, - { - name: 'pausedOperations'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 162]; - }; - }, - ]; - }; - }, - { - name: 'constituentCorrelations'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'lpPool'; - type: 'pubkey'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'correlations'; - type: { - vec: 'i64'; - }; - }, - ]; - }; - }, - { - name: 'constituentParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'maxWeightDeviation'; - type: { - option: 'i64'; - }; - }, - { - name: 'swapFeeMin'; - type: { - option: 'i64'; - }; - }, - { - name: 'swapFeeMax'; - type: { - option: 'i64'; - }; - }, - { - name: 'maxBorrowTokenAmount'; - type: { - option: 'u64'; - }; - }, - { - name: 'oracleStalenessThreshold'; - type: { - option: 'u64'; - }; - }, - { - name: 'costToTradeBps'; - type: { - option: 'i32'; - }; - }, - { - name: 'constituentDerivativeIndex'; - type: { - option: 'i16'; - }; - }, - { - name: 'derivativeWeight'; - type: { - option: 'u64'; - }; - }, - { - name: 'volatility'; - type: { - option: 'u64'; - }; - }, - { - name: 'gammaExecution'; - type: { - option: 'u8'; - }; - }, - { - name: 'gammaInventory'; - type: { - option: 'u8'; - }; - }, - { - name: 'xi'; - type: { - option: 'u8'; - }; - }, - ]; - }; - }, - { - name: 'constituentSpotBalance'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'scaledBalance'; - docs: [ - 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', - 'interest of corresponding market.', - 'precision: token precision', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeDeposits'; - docs: [ - 'The cumulative deposits/borrows a user has made into a market', - 'precision: token mint precision', - ]; - type: 'i64'; - }, - { - name: 'marketIndex'; - docs: ['The market index of the corresponding spot market']; - type: 'u16'; - }, - { - name: 'balanceType'; - docs: ['Whether the position is deposit or borrow']; - type: { - defined: { - name: 'spotBalanceType'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 5]; - }; - }, - ]; - }; - }, - { - name: 'constituentTargetBase'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'lpPool'; - type: 'pubkey'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'targets'; - type: { - vec: { - defined: { - name: 'targetsDatum'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'contractTier'; - type: { - kind: 'enum'; - variants: [ - { - name: 'a'; - }, - { - name: 'b'; - }, - { - name: 'c'; - }, - { - name: 'speculative'; - }, - { - name: 'highlySpeculative'; - }, - { - name: 'isolated'; - }, - ]; - }; - }, - { - name: 'contractType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'perpetual'; - }, - { - name: 'future'; - }, - { - name: 'prediction'; - }, - ]; - }; - }, - { - name: 'curveRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'recordId'; - type: 'u64'; - }, - { - name: 'pegMultiplierBefore'; - type: 'u128'; - }, - { - name: 'baseAssetReserveBefore'; - type: 'u128'; - }, - { - name: 'quoteAssetReserveBefore'; - type: 'u128'; - }, - { - name: 'sqrtKBefore'; - type: 'u128'; - }, - { - name: 'pegMultiplierAfter'; - type: 'u128'; - }, - { - name: 'baseAssetReserveAfter'; - type: 'u128'; - }, - { - name: 'quoteAssetReserveAfter'; - type: 'u128'; - }, - { - name: 'sqrtKAfter'; - type: 'u128'; - }, - { - name: 'baseAssetAmountLong'; - docs: ['precision: BASE_PRECISION']; - type: 'u128'; - }, - { - name: 'baseAssetAmountShort'; - docs: ['precision: BASE_PRECISION']; - type: 'u128'; - }, - { - name: 'baseAssetAmountWithAmm'; - docs: ['precision: BASE_PRECISION']; - type: 'i128'; - }, - { - name: 'totalFee'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i128'; - }, - { - name: 'totalFeeMinusDistributions'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i128'; - }, - { - name: 'adjustmentCost'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i128'; - }, - { - name: 'oraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'fillRecord'; - type: 'u128'; - }, - { - name: 'numberOfUsers'; - type: 'u32'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }; - }, - { - name: 'deleteUserRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - docs: ['unix_timestamp of action']; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'keeper'; - type: { - option: 'pubkey'; - }; - }, - ]; - }; - }, - { - name: 'depositDirection'; - type: { - kind: 'enum'; - variants: [ - { - name: 'deposit'; - }, - { - name: 'withdraw'; - }, - ]; - }; - }, - { - name: 'depositExplanation'; - type: { - kind: 'enum'; - variants: [ - { - name: 'none'; - }, - { - name: 'transfer'; - }, - { - name: 'borrow'; - }, - { - name: 'repayBorrow'; - }, - { - name: 'reward'; - }, - ]; - }; - }, - { - name: 'depositRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - docs: ['unix_timestamp of action']; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'user'; - docs: ['user account public key']; - type: 'pubkey'; - }, - { - name: 'direction'; - type: { - defined: { - name: 'depositDirection'; - }; - }; - }, - { - name: 'depositRecordId'; - type: 'u64'; - }, - { - name: 'amount'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'marketIndex'; - docs: ['spot market index']; - type: 'u16'; - }, - { - name: 'oraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'marketDepositBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'marketWithdrawBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'marketCumulativeDepositInterest'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'marketCumulativeBorrowInterest'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'totalDepositsAfter'; - docs: ['precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'totalWithdrawsAfter'; - docs: ['precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'explanation'; - type: { - defined: { - name: 'depositExplanation'; - }; - }; - }, - { - name: 'transferUser'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'signer'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'userTokenAmountAfter'; - docs: ['precision: token mint precision']; - type: 'i128'; - }, - ]; - }; - }, - { - name: 'feeStructure'; - type: { - kind: 'struct'; - fields: [ - { - name: 'feeTiers'; - type: { - array: [ - { - defined: { - name: 'feeTier'; - }; - }, - 10, - ]; - }; - }, - { - name: 'fillerRewardStructure'; - type: { - defined: { - name: 'orderFillerRewardStructure'; - }; - }; - }, - { - name: 'referrerRewardEpochUpperBound'; - type: 'u64'; - }, - { - name: 'flatFillerFee'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'feeTier'; - type: { - kind: 'struct'; - fields: [ - { - name: 'feeNumerator'; - type: 'u32'; - }, - { - name: 'feeDenominator'; - type: 'u32'; - }, - { - name: 'makerRebateNumerator'; - type: 'u32'; - }, - { - name: 'makerRebateDenominator'; - type: 'u32'; - }, - { - name: 'referrerRewardNumerator'; - type: 'u32'; - }, - { - name: 'referrerRewardDenominator'; - type: 'u32'; - }, - { - name: 'refereeFeeNumerator'; - type: 'u32'; - }, - { - name: 'refereeFeeDenominator'; - type: 'u32'; - }, - ]; - }; - }, - { - name: 'fuelOverflow'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['The authority of this overflow account']; - type: 'pubkey'; - }, - { - name: 'fuelInsurance'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelDeposits'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelBorrows'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelPositions'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelTaker'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelMaker'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastFuelSweepTs'; - type: 'u32'; - }, - { - name: 'lastResetTs'; - type: 'u32'; - }, - { - name: 'padding'; - type: { - array: ['u128', 6]; - }; - }, - ]; - }; - }, - { - name: 'fuelSeasonRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'fuelInsurance'; - type: 'u128'; - }, - { - name: 'fuelDeposits'; - type: 'u128'; - }, - { - name: 'fuelBorrows'; - type: 'u128'; - }, - { - name: 'fuelPositions'; - type: 'u128'; - }, - { - name: 'fuelTaker'; - type: 'u128'; - }, - { - name: 'fuelMaker'; - type: 'u128'; - }, - { - name: 'fuelTotal'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'fuelSweepRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'userStatsFuelInsurance'; - type: 'u32'; - }, - { - name: 'userStatsFuelDeposits'; - type: 'u32'; - }, - { - name: 'userStatsFuelBorrows'; - type: 'u32'; - }, - { - name: 'userStatsFuelPositions'; - type: 'u32'; - }, - { - name: 'userStatsFuelTaker'; - type: 'u32'; - }, - { - name: 'userStatsFuelMaker'; - type: 'u32'; - }, - { - name: 'fuelOverflowFuelInsurance'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelDeposits'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelBorrows'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelPositions'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelTaker'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelMaker'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'fundingPaymentRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fundingPayment'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i64'; - }, - { - name: 'baseAssetAmount'; - docs: ['precision: BASE_PRECISION']; - type: 'i64'; - }, - { - name: 'userLastCumulativeFunding'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i64'; - }, - { - name: 'ammCumulativeFundingLong'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'ammCumulativeFundingShort'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - ]; - }; - }, - { - name: 'fundingRateRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'recordId'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fundingRate'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i64'; - }, - { - name: 'fundingRateLong'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'fundingRateShort'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'cumulativeFundingRateLong'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'cumulativeFundingRateShort'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'oraclePriceTwap'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'markPriceTwap'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'periodRevenue'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i64'; - }, - { - name: 'baseAssetAmountWithAmm'; - docs: ['precision: BASE_PRECISION']; - type: 'i128'; - }, - { - name: 'baseAssetAmountWithUnsettledLp'; - docs: ['precision: BASE_PRECISION']; - type: 'i128'; - }, - ]; - }; - }, - { - name: 'highLeverageModeConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - { - name: 'currentUsers'; - type: 'u32'; - }, - { - name: 'reduceOnly'; - type: 'u8'; - }, - { - name: 'padding1'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'currentMaintenanceUsers'; - type: 'u32'; - }, - { - name: 'padding2'; - type: { - array: ['u8', 24]; - }; - }, - ]; - }; - }, - { - name: 'historicalIndexData'; - type: { - kind: 'struct'; - fields: [ - { - name: 'lastIndexBidPrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastIndexAskPrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastIndexPriceTwap'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastIndexPriceTwap5min'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastIndexPriceTwapTs'; - docs: ['unix_timestamp of last snapshot']; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'historicalOracleData'; - type: { - kind: 'struct'; - fields: [ - { - name: 'lastOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'lastOracleConf'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastOracleDelay'; - docs: ['number of slots since last update']; - type: 'i64'; - }, - { - name: 'lastOraclePriceTwap'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'lastOraclePriceTwap5min'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'lastOraclePriceTwapTs'; - docs: ['unix_timestamp of last snapshot']; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'ifRebalanceConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - type: 'pubkey'; - }, - { - name: 'totalInAmount'; - docs: ['total amount to be sold']; - type: 'u64'; - }, - { - name: 'currentInAmount'; - docs: ['amount already sold']; - type: 'u64'; - }, - { - name: 'currentOutAmount'; - docs: ['amount already bought']; - type: 'u64'; - }, - { - name: 'currentOutAmountTransferred'; - docs: ['amount already transferred to revenue pool']; - type: 'u64'; - }, - { - name: 'currentInAmountSinceLastTransfer'; - docs: ['amount already bought in epoch']; - type: 'u64'; - }, - { - name: 'epochStartTs'; - docs: ['start time of epoch']; - type: 'i64'; - }, - { - name: 'epochInAmount'; - docs: ['amount already bought in epoch']; - type: 'u64'; - }, - { - name: 'epochMaxInAmount'; - docs: ['max amount to swap in epoch']; - type: 'u64'; - }, - { - name: 'epochDuration'; - docs: ['duration of epoch']; - type: 'i64'; - }, - { - name: 'outMarketIndex'; - docs: ['market index to sell']; - type: 'u16'; - }, - { - name: 'inMarketIndex'; - docs: ['market index to buy']; - type: 'u16'; - }, - { - name: 'maxSlippageBps'; - type: 'u16'; - }, - { - name: 'swapMode'; - type: 'u8'; - }, - { - name: 'status'; - type: 'u8'; - }, - { - name: 'padding2'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }; - }, - { - name: 'ifRebalanceConfigParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'totalInAmount'; - type: 'u64'; - }, - { - name: 'epochMaxInAmount'; - type: 'u64'; - }, - { - name: 'epochDuration'; - type: 'i64'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'maxSlippageBps'; - type: 'u16'; - }, - { - name: 'swapMode'; - type: 'u8'; - }, - { - name: 'status'; - type: 'u8'; - }, - ]; - }; - }, - { - name: 'insuranceClaim'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'revenueWithdrawSinceLastSettle'; - docs: [ - 'The amount of revenue last settled', - 'Positive if funds left the perp market,', - 'negative if funds were pulled into the perp market', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'maxRevenueWithdrawPerPeriod'; - docs: [ - 'The max amount of revenue that can be withdrawn per period', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'quoteMaxInsurance'; - docs: [ - 'The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'quoteSettledInsurance'; - docs: [ - 'The amount of insurance that has been used to resolve bankruptcy and pnl deficits', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastRevenueWithdrawTs'; - docs: ['The last time revenue was settled in/out of market']; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'insuranceFund'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'vault'; - type: 'pubkey'; - }, - { - name: 'totalShares'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'userShares'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'sharesBase'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'unstakingPeriod'; - type: 'i64'; - }, - { - name: 'lastRevenueSettleTs'; - type: 'i64'; - }, - { - name: 'revenueSettlePeriod'; - type: 'i64'; - }, - { - name: 'totalFactor'; - type: 'u32'; - }, - { - name: 'userFactor'; - type: 'u32'; - }, - ]; - }; - }, - { - name: 'insuranceFundRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'userIfFactor'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - { - name: 'totalIfFactor'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - { - name: 'vaultAmountBefore'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'insuranceVaultAmountBefore'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'totalIfSharesBefore'; - type: 'u128'; - }, - { - name: 'totalIfSharesAfter'; - type: 'u128'; - }, - { - name: 'amount'; - docs: ['precision: token mint precision']; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'ifShares'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastWithdrawRequestShares'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'ifBase'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastValidTs'; - type: 'i64'; - }, - { - name: 'lastWithdrawRequestValue'; - type: 'u64'; - }, - { - name: 'lastWithdrawRequestTs'; - type: 'i64'; - }, - { - name: 'costBasis'; - type: 'i64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 14]; - }; - }, - ]; - }; - }, - { - name: 'insuranceFundStakeRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'action'; - type: { - defined: { - name: 'stakeAction'; - }; - }; - }, - { - name: 'amount'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'insuranceVaultAmountBefore'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'ifSharesBefore'; - type: 'u128'; - }, - { - name: 'userIfSharesBefore'; - type: 'u128'; - }, - { - name: 'totalIfSharesBefore'; - type: 'u128'; - }, - { - name: 'ifSharesAfter'; - type: 'u128'; - }, - { - name: 'userIfSharesAfter'; - type: 'u128'; - }, - { - name: 'totalIfSharesAfter'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'insuranceFundSwapRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'rebalanceConfig'; - type: 'pubkey'; - }, - { - name: 'inIfTotalSharesBefore'; - type: 'u128'; - }, - { - name: 'outIfTotalSharesBefore'; - type: 'u128'; - }, - { - name: 'inIfUserSharesBefore'; - type: 'u128'; - }, - { - name: 'outIfUserSharesBefore'; - type: 'u128'; - }, - { - name: 'inIfTotalSharesAfter'; - type: 'u128'; - }, - { - name: 'outIfTotalSharesAfter'; - type: 'u128'; - }, - { - name: 'inIfUserSharesAfter'; - type: 'u128'; - }, - { - name: 'outIfUserSharesAfter'; - type: 'u128'; - }, - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - { - name: 'outAmount'; - type: 'u64'; - }, - { - name: 'outOraclePrice'; - type: 'u64'; - }, - { - name: 'outOraclePriceTwap'; - type: 'i64'; - }, - { - name: 'inVaultAmountBefore'; - type: 'u64'; - }, - { - name: 'outVaultAmountBefore'; - type: 'u64'; - }, - { - name: 'inFundVaultAmountAfter'; - type: 'u64'; - }, - { - name: 'outFundVaultAmountAfter'; - type: 'u64'; - }, - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - ]; - }; - }, - { - name: 'lpAction'; - type: { - kind: 'enum'; - variants: [ - { - name: 'addLiquidity'; - }, - { - name: 'removeLiquidity'; - }, - { - name: 'settleLiquidity'; - }, - { - name: 'removeLiquidityDerisk'; - }, - ]; - }; - }, - { - name: 'lpBorrowLendDepositRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'direction'; - type: { - defined: { - name: 'depositDirection'; - }; - }; - }, - { - name: 'tokenBalance'; - type: 'i64'; - }, - { - name: 'lastTokenBalance'; - type: 'i64'; - }, - { - name: 'interestAccruedTokenAmount'; - type: 'i64'; - }, - { - name: 'amountDepositWithdraw'; - type: 'u64'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'lpMintRedeemRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'description'; - type: 'u8'; - }, - { - name: 'amount'; - docs: ['precision: continutent mint precision, gross fees']; - type: 'u128'; - }, - { - name: 'fee'; - docs: [ - 'precision: fee on amount, constituent market mint precision', - ]; - type: 'i128'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'oraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'mint'; - docs: ['token mint']; - type: 'pubkey'; - }, - { - name: 'lpAmount'; - docs: ['lp amount, lp mint precision']; - type: 'u64'; - }, - { - name: 'lpFee'; - docs: ['lp fee, lp mint precision']; - type: 'i64'; - }, - { - name: 'lpPrice'; - docs: ['the fair price of the lp token, PRICE_PRECISION']; - type: 'u128'; - }, - { - name: 'mintRedeemId'; - type: 'u64'; - }, - { - name: 'lastAum'; - docs: ['LPPool last_aum']; - type: 'u128'; - }, - { - name: 'lastAumSlot'; - type: 'u64'; - }, - { - name: 'inMarketCurrentWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'inMarketTargetWeight'; - type: 'i64'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'lpPool'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - docs: ['address of the vault.']; - type: 'pubkey'; - }, - { - name: 'mint'; - type: 'pubkey'; - }, - { - name: 'whitelistMint'; - type: 'pubkey'; - }, - { - name: 'constituentTargetBase'; - type: 'pubkey'; - }, - { - name: 'constituentCorrelations'; - type: 'pubkey'; - }, - { - name: 'maxAum'; - docs: [ - 'The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)', - 'which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)', - 'pub quote_constituent_index: u16,', - 'QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastAum'; - docs: ['QUOTE_PRECISION: AUM of the vault in USD, updated lazily']; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeQuoteSentToPerpMarkets'; - docs: ['QUOTE PRECISION: Cumulative quotes from settles']; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeQuoteReceivedFromPerpMarkets'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalMintRedeemFeesPaid'; - docs: [ - 'QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'lastAumSlot'; - docs: ['timestamp of last AUM slot']; - type: 'u64'; - }, - { - name: 'maxSettleQuoteAmount'; - type: 'u64'; - }, - { - name: 'padding'; - docs: ['timestamp of last vAMM revenue rebalance']; - type: 'u64'; - }, - { - name: 'mintRedeemId'; - docs: [ - 'Every mint/redeem has a monotonically increasing id. This is the next id to use', - ]; - type: 'u64'; - }, - { - name: 'settleId'; - type: 'u64'; - }, - { - name: 'minMintFee'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'tokenSupply'; - type: 'u64'; - }, - { - name: 'volatility'; - type: 'u64'; - }, - { - name: 'constituents'; - type: 'u16'; - }, - { - name: 'quoteConsituentIndex'; - type: 'u16'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'gammaExecution'; - type: 'u8'; - }, - { - name: 'xi'; - type: 'u8'; - }, - { - name: 'targetOracleDelayFeeBpsPer10Slots'; - type: 'u8'; - }, - { - name: 'targetPositionDelayFeeBpsPer10Slots'; - type: 'u8'; - }, - { - name: 'lpPoolId'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 174]; - }; - }, - ]; - }; - }, - { - name: 'lpRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'action'; - type: { - defined: { - name: 'lpAction'; - }; - }; - }, - { - name: 'nShares'; - docs: ['precision: AMM_RESERVE_PRECISION']; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'deltaBaseAssetAmount'; - docs: ['precision: BASE_PRECISION']; - type: 'i64'; - }, - { - name: 'deltaQuoteAssetAmount'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i64'; - }, - { - name: 'pnl'; - docs: [ - 'realized pnl of the position settlement', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'lpSettleRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'recordId'; - type: 'u64'; - }, - { - name: 'lastTs'; - type: 'i64'; - }, - { - name: 'lastSlot'; - type: 'u64'; - }, - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'settleToLpAmount'; - type: 'i64'; - }, - { - name: 'perpAmmPnlDelta'; - type: 'i64'; - }, - { - name: 'perpAmmExFeeDelta'; - type: 'i64'; - }, - { - name: 'lpAum'; - type: 'u128'; - }, - { - name: 'lpPrice'; - type: 'u128'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'lpSwapRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'outAmount'; - docs: ['precision: out market mint precision, gross fees']; - type: 'u128'; - }, - { - name: 'inAmount'; - docs: ['precision: in market mint precision, gross fees']; - type: 'u128'; - }, - { - name: 'outFee'; - docs: ['precision: fee on amount_out, in market mint precision']; - type: 'i128'; - }, - { - name: 'inFee'; - docs: ['precision: fee on amount_in, out market mint precision']; - type: 'i128'; - }, - { - name: 'outSpotMarketIndex'; - type: 'u16'; - }, - { - name: 'inSpotMarketIndex'; - type: 'u16'; - }, - { - name: 'outConstituentIndex'; - type: 'u16'; - }, - { - name: 'inConstituentIndex'; - type: 'u16'; - }, - { - name: 'outOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'inOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'lastAum'; - docs: ['LPPool last_aum, QUOTE_PRECISION']; - type: 'u128'; - }, - { - name: 'lastAumSlot'; - type: 'u64'; - }, - { - name: 'inMarketCurrentWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'outMarketCurrentWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'inMarketTargetWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'outMarketTargetWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'inSwapId'; - type: 'u64'; - }, - { - name: 'outSwapId'; - type: 'u64'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'liquidateBorrowForPerpPnlRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'marketOraclePrice'; - type: 'i64'; - }, - { - name: 'pnlTransfer'; - type: 'u128'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityPrice'; - type: 'i64'; - }, - { - name: 'liabilityTransfer'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'liquidatePerpPnlForDepositRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'marketOraclePrice'; - type: 'i64'; - }, - { - name: 'pnlTransfer'; - type: 'u128'; - }, - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'assetPrice'; - type: 'i64'; - }, - { - name: 'assetTransfer'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'liquidatePerpRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'oraclePrice'; - type: 'i64'; - }, - { - name: 'baseAssetAmount'; - type: 'i64'; - }, - { - name: 'quoteAssetAmount'; - type: 'i64'; - }, - { - name: 'lpShares'; - docs: ['precision: AMM_RESERVE_PRECISION']; - type: 'u64'; - }, - { - name: 'fillRecordId'; - type: 'u64'; - }, - { - name: 'userOrderId'; - type: 'u32'; - }, - { - name: 'liquidatorOrderId'; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - docs: ['precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'ifFee'; - docs: ['precision: QUOTE_PRECISION']; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'liquidateSpotRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'assetPrice'; - type: 'i64'; - }, - { - name: 'assetTransfer'; - type: 'u128'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityPrice'; - type: 'i64'; - }, - { - name: 'liabilityTransfer'; - docs: ['precision: token mint precision']; - type: 'u128'; - }, - { - name: 'ifFee'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'liquidationRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'liquidationType'; - type: { - defined: { - name: 'liquidationType'; - }; - }; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'liquidator'; - type: 'pubkey'; - }, - { - name: 'marginRequirement'; - type: 'u128'; - }, - { - name: 'totalCollateral'; - type: 'i128'; - }, - { - name: 'marginFreed'; - type: 'u64'; - }, - { - name: 'liquidationId'; - type: 'u16'; - }, - { - name: 'bankrupt'; - type: 'bool'; - }, - { - name: 'canceledOrderIds'; - type: { - vec: 'u32'; - }; - }, - { - name: 'liquidatePerp'; - type: { - defined: { - name: 'liquidatePerpRecord'; - }; - }; - }, - { - name: 'liquidateSpot'; - type: { - defined: { - name: 'liquidateSpotRecord'; - }; - }; - }, - { - name: 'liquidateBorrowForPerpPnl'; - type: { - defined: { - name: 'liquidateBorrowForPerpPnlRecord'; - }; - }; - }, - { - name: 'liquidatePerpPnlForDeposit'; - type: { - defined: { - name: 'liquidatePerpPnlForDepositRecord'; - }; - }; - }, - { - name: 'perpBankruptcy'; - type: { - defined: { - name: 'perpBankruptcyRecord'; - }; - }; - }, - { - name: 'spotBankruptcy'; - type: { - defined: { - name: 'spotBankruptcyRecord'; - }; - }; - }, - ]; - }; - }, - { - name: 'liquidationType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'liquidatePerp'; - }, - { - name: 'liquidateSpot'; - }, - { - name: 'liquidateBorrowForPerpPnl'; - }, - { - name: 'liquidatePerpPnlForDeposit'; - }, - { - name: 'perpBankruptcy'; - }, - { - name: 'spotBankruptcy'; - }, - ]; - }; - }, - { - name: 'lpPoolParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'maxSettleQuoteAmount'; - type: { - option: 'u64'; - }; - }, - { - name: 'volatility'; - type: { - option: 'u64'; - }; - }, - { - name: 'gammaExecution'; - type: { - option: 'u8'; - }; - }, - { - name: 'xi'; - type: { - option: 'u8'; - }; - }, - { - name: 'maxAum'; - type: { - option: 'u128'; - }; - }, - { - name: 'whitelistMint'; - type: { - option: 'pubkey'; - }; - }, - ]; - }; - }, - { - name: 'marginMode'; - type: { - kind: 'enum'; - variants: [ - { - name: 'default'; - }, - { - name: 'highLeverage'; - }, - { - name: 'highLeverageMaintenance'; - }, - ]; - }; - }, - { - name: 'marketStatus'; - type: { - kind: 'enum'; - variants: [ - { - name: 'initialized'; - }, - { - name: 'active'; - }, - { - name: 'fundingPaused'; - }, - { - name: 'ammPaused'; - }, - { - name: 'fillPaused'; - }, - { - name: 'withdrawPaused'; - }, - { - name: 'reduceOnly'; - }, - { - name: 'settlement'; - }, - { - name: 'delisted'; - }, - ]; - }; - }, - { - name: 'marketType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'spot'; - }, - { - name: 'perp'; - }, - ]; - }; - }, - { - name: 'modifyOrderParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'direction'; - type: { - option: { - defined: { - name: 'positionDirection'; - }; - }; - }; - }, - { - name: 'baseAssetAmount'; - type: { - option: 'u64'; - }; - }, - { - name: 'price'; - type: { - option: 'u64'; - }; - }, - { - name: 'reduceOnly'; - type: { - option: 'bool'; - }; - }, - { - name: 'postOnly'; - type: { - option: { - defined: { - name: 'postOnlyParam'; - }; - }; - }; - }, - { - name: 'bitFlags'; - type: { - option: 'u8'; - }; - }, - { - name: 'maxTs'; - type: { - option: 'i64'; - }; - }, - { - name: 'triggerPrice'; - type: { - option: 'u64'; - }; - }, - { - name: 'triggerCondition'; - type: { - option: { - defined: { - name: 'orderTriggerCondition'; - }; - }; - }; - }, - { - name: 'oraclePriceOffset'; - type: { - option: 'i32'; - }; - }, - { - name: 'auctionDuration'; - type: { - option: 'u8'; - }; - }, - { - name: 'auctionStartPrice'; - type: { - option: 'i64'; - }; - }, - { - name: 'auctionEndPrice'; - type: { - option: 'i64'; - }; - }, - { - name: 'policy'; - type: { - option: 'u8'; - }; - }, - ]; - }; - }, - { - name: 'newUserRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - docs: ['unix_timestamp of action']; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'referrer'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'openbookV2FulfillmentConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - type: 'pubkey'; - }, - { - name: 'openbookV2ProgramId'; - type: 'pubkey'; - }, - { - name: 'openbookV2Market'; - type: 'pubkey'; - }, - { - name: 'openbookV2MarketAuthority'; - type: 'pubkey'; - }, - { - name: 'openbookV2EventHeap'; - type: 'pubkey'; - }, - { - name: 'openbookV2Bids'; - type: 'pubkey'; - }, - { - name: 'openbookV2Asks'; - type: 'pubkey'; - }, - { - name: 'openbookV2BaseVault'; - type: 'pubkey'; - }, - { - name: 'openbookV2QuoteVault'; - type: 'pubkey'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fulfillmentType'; - type: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }, - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - ]; - }; - }, - { - name: 'oracleGuardRails'; - type: { - kind: 'struct'; - fields: [ - { - name: 'priceDivergence'; - type: { - defined: { - name: 'priceDivergenceGuardRails'; - }; - }; - }, - { - name: 'validity'; - type: { - defined: { - name: 'validityGuardRails'; - }; - }; - }, - ]; - }; - }, - { - name: 'oracleSource'; - type: { - kind: 'enum'; - variants: [ - { - name: 'pyth'; - }, - { - name: 'switchboard'; - }, - { - name: 'quoteAsset'; - }, - { - name: 'pyth1K'; - }, - { - name: 'pyth1M'; - }, - { - name: 'pythStableCoin'; - }, - { - name: 'prelaunch'; - }, - { - name: 'pythPull'; - }, - { - name: 'pyth1KPull'; - }, - { - name: 'pyth1MPull'; - }, - { - name: 'pythStableCoinPull'; - }, - { - name: 'switchboardOnDemand'; - }, - { - name: 'pythLazer'; - }, - { - name: 'pythLazer1K'; - }, - { - name: 'pythLazer1M'; - }, - { - name: 'pythLazerStableCoin'; - }, - ]; - }; - }, - { - name: 'order'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'slot'; - docs: ['The slot the order was placed']; - type: 'u64'; - }, - { - name: 'price'; - docs: [ - 'The limit price for the order (can be 0 for market orders)', - "For orders with an auction, this price isn't used until the auction is complete", - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'baseAssetAmount'; - docs: [ - 'The size of the order', - 'precision for perps: BASE_PRECISION', - 'precision for spot: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'baseAssetAmountFilled'; - docs: [ - 'The amount of the order filled', - 'precision for perps: BASE_PRECISION', - 'precision for spot: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'quoteAssetAmountFilled'; - docs: [ - 'The amount of quote filled for the order', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'triggerPrice'; - docs: [ - 'At what price the order will be triggered. Only relevant for trigger orders', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'auctionStartPrice'; - docs: [ - 'The start price for the auction. Only relevant for market/oracle orders', - 'precision: PRICE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'auctionEndPrice'; - docs: [ - 'The end price for the auction. Only relevant for market/oracle orders', - 'precision: PRICE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'maxTs'; - docs: ['The time when the order will expire']; - type: 'i64'; - }, - { - name: 'oraclePriceOffset'; - docs: [ - 'If set, the order limit price is the oracle price + this offset', - 'precision: PRICE_PRECISION', - ]; - type: 'i32'; - }, - { - name: 'orderId'; - docs: [ - 'The id for the order. Each users has their own order id space', - ]; - type: 'u32'; - }, - { - name: 'marketIndex'; - docs: ['The perp/spot market index']; - type: 'u16'; - }, - { - name: 'status'; - docs: ['Whether the order is open or unused']; - type: { - defined: { - name: 'orderStatus'; - }; - }; - }, - { - name: 'orderType'; - docs: ['The type of order']; - type: { - defined: { - name: 'orderType'; - }; - }; - }, - { - name: 'marketType'; - docs: ['Whether market is spot or perp']; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'userOrderId'; - docs: [ - 'User generated order id. Can make it easier to place/cancel orders', - ]; - type: 'u8'; - }, - { - name: 'existingPositionDirection'; - docs: ['What the users position was when the order was placed']; - type: { - defined: { - name: 'positionDirection'; - }; - }; - }, - { - name: 'direction'; - docs: [ - 'Whether the user is going long or short. LONG = bid, SHORT = ask', - ]; - type: { - defined: { - name: 'positionDirection'; - }; - }; - }, - { - name: 'reduceOnly'; - docs: ['Whether the order is allowed to only reduce position size']; - type: 'bool'; - }, - { - name: 'postOnly'; - docs: ['Whether the order must be a maker']; - type: 'bool'; - }, - { - name: 'immediateOrCancel'; - docs: [ - 'Whether the order must be canceled the same slot it is placed', - ]; - type: 'bool'; - }, - { - name: 'triggerCondition'; - docs: [ - 'Whether the order is triggered above or below the trigger price. Only relevant for trigger orders', - ]; - type: { - defined: { - name: 'orderTriggerCondition'; - }; - }; - }, - { - name: 'auctionDuration'; - docs: ['How many slots the auction lasts']; - type: 'u8'; - }, - { - name: 'postedSlotTail'; - docs: [ - 'Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)', - ]; - type: 'u8'; - }, - { - name: 'bitFlags'; - docs: [ - 'Bitflags for further classification', - '0: is_signed_message', - ]; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 1]; - }; - }, - ]; - }; - }, - { - name: 'orderAction'; - type: { - kind: 'enum'; - variants: [ - { - name: 'place'; - }, - { - name: 'cancel'; - }, - { - name: 'fill'; - }, - { - name: 'trigger'; - }, - { - name: 'expire'; - }, - ]; - }; - }, - { - name: 'orderActionExplanation'; - type: { - kind: 'enum'; - variants: [ - { - name: 'none'; - }, - { - name: 'insufficientFreeCollateral'; - }, - { - name: 'oraclePriceBreachedLimitPrice'; - }, - { - name: 'marketOrderFilledToLimitPrice'; - }, - { - name: 'orderExpired'; - }, - { - name: 'liquidation'; - }, - { - name: 'orderFilledWithAmm'; - }, - { - name: 'orderFilledWithAmmJit'; - }, - { - name: 'orderFilledWithMatch'; - }, - { - name: 'orderFilledWithMatchJit'; - }, - { - name: 'marketExpired'; - }, - { - name: 'riskingIncreasingOrder'; - }, - { - name: 'reduceOnlyOrderIncreasedPosition'; - }, - { - name: 'orderFillWithSerum'; - }, - { - name: 'noBorrowLiquidity'; - }, - { - name: 'orderFillWithPhoenix'; - }, - { - name: 'orderFilledWithAmmJitLpSplit'; - }, - { - name: 'orderFilledWithLpJit'; - }, - { - name: 'deriskLp'; - }, - { - name: 'orderFilledWithOpenbookV2'; - }, - { - name: 'transferPerpPosition'; - }, - ]; - }; - }, - { - name: 'orderActionRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'action'; - type: { - defined: { - name: 'orderAction'; - }; - }; - }, - { - name: 'actionExplanation'; - type: { - defined: { - name: 'orderActionExplanation'; - }; - }; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'marketType'; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'filler'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'fillerReward'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'fillRecordId'; - type: { - option: 'u64'; - }; - }, - { - name: 'baseAssetAmountFilled'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'quoteAssetAmountFilled'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'takerFee'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'makerFee'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'i64'; - }; - }, - { - name: 'referrerReward'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u32'; - }; - }, - { - name: 'quoteAssetAmountSurplus'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'i64'; - }; - }, - { - name: 'spotFulfillmentMethodFee'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'taker'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'takerOrderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'takerOrderDirection'; - type: { - option: { - defined: { - name: 'positionDirection'; - }; - }; - }; - }, - { - name: 'takerOrderBaseAssetAmount'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'takerOrderCumulativeBaseAssetAmountFilled'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'takerOrderCumulativeQuoteAssetAmountFilled'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'maker'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'makerOrderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'makerOrderDirection'; - type: { - option: { - defined: { - name: 'positionDirection'; - }; - }; - }; - }, - { - name: 'makerOrderBaseAssetAmount'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'makerOrderCumulativeBaseAssetAmountFilled'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'makerOrderCumulativeQuoteAssetAmountFilled'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'oraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'bitFlags'; - docs: ['Bit flags:', '0: is_signed_message']; - type: 'u8'; - }, - { - name: 'takerExistingQuoteEntryAmount'; - docs: [ - 'precision: QUOTE_PRECISION', - 'Only Some if the taker reduced position', - ]; - type: { - option: 'u64'; - }; - }, - { - name: 'takerExistingBaseAssetAmount'; - docs: [ - 'precision: BASE_PRECISION', - 'Only Some if the taker flipped position direction', - ]; - type: { - option: 'u64'; - }; - }, - { - name: 'makerExistingQuoteEntryAmount'; - docs: [ - 'precision: QUOTE_PRECISION', - 'Only Some if the maker reduced position', - ]; - type: { - option: 'u64'; - }; - }, - { - name: 'makerExistingBaseAssetAmount'; - docs: [ - 'precision: BASE_PRECISION', - 'Only Some if the maker flipped position direction', - ]; - type: { - option: 'u64'; - }; - }, - { - name: 'triggerPrice'; - docs: ['precision: PRICE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'builderIdx'; - docs: [ - "the idx of the builder in the taker's [`RevenueShareEscrow`] account", - ]; - type: { - option: 'u8'; - }; - }, - { - name: 'builderFee'; - docs: ['precision: QUOTE_PRECISION builder fee paid by the taker']; - type: { - option: 'u64'; - }; - }, - ]; - }; - }, - { - name: 'orderFillerRewardStructure'; - type: { - kind: 'struct'; - fields: [ - { - name: 'rewardNumerator'; - type: 'u32'; - }, - { - name: 'rewardDenominator'; - type: 'u32'; - }, - { - name: 'timeBasedRewardLowerBound'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - ]; - }; - }, - { - name: 'orderParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'orderType'; - type: { - defined: { - name: 'orderType'; - }; - }; - }, - { - name: 'marketType'; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'direction'; - type: { - defined: { - name: 'positionDirection'; - }; - }; - }, - { - name: 'userOrderId'; - type: 'u8'; - }, - { - name: 'baseAssetAmount'; - type: 'u64'; - }, - { - name: 'price'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - { - name: 'postOnly'; - type: { - defined: { - name: 'postOnlyParam'; - }; - }; - }, - { - name: 'bitFlags'; - type: 'u8'; - }, - { - name: 'maxTs'; - type: { - option: 'i64'; - }; - }, - { - name: 'triggerPrice'; - type: { - option: 'u64'; - }; - }, - { - name: 'triggerCondition'; - type: { - defined: { - name: 'orderTriggerCondition'; - }; - }; - }, - { - name: 'oraclePriceOffset'; - type: { - option: 'i32'; - }; - }, - { - name: 'auctionDuration'; - type: { - option: 'u8'; - }; - }, - { - name: 'auctionStartPrice'; - type: { - option: 'i64'; - }; - }, - { - name: 'auctionEndPrice'; - type: { - option: 'i64'; - }; - }, - ]; - }; - }, - { - name: 'orderRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'order'; - type: { - defined: { - name: 'order'; - }; - }; - }, - ]; - }; - }, - { - name: 'orderStatus'; - type: { - kind: 'enum'; - variants: [ - { - name: 'init'; - }, - { - name: 'open'; - }, - { - name: 'filled'; - }, - { - name: 'canceled'; - }, - ]; - }; - }, - { - name: 'orderTriggerCondition'; - type: { - kind: 'enum'; - variants: [ - { - name: 'above'; - }, - { - name: 'below'; - }, - { - name: 'triggeredAbove'; - }, - { - name: 'triggeredBelow'; - }, - ]; - }; - }, - { - name: 'orderType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'market'; - }, - { - name: 'limit'; - }, - { - name: 'triggerMarket'; - }, - { - name: 'triggerLimit'; - }, - { - name: 'oracle'; - }, - ]; - }; - }, - { - name: 'overrideAmmCacheParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'quoteOwedFromLpPool'; - type: { - option: 'i64'; - }; - }, - { - name: 'lastSettleSlot'; - type: { - option: 'u64'; - }; - }, - { - name: 'lastFeePoolTokenAmount'; - type: { - option: 'u128'; - }; - }, - { - name: 'lastNetPnlPoolTokenAmount'; - type: { - option: 'i128'; - }; - }, - { - name: 'ammPositionScalar'; - type: { - option: 'u8'; - }; - }, - { - name: 'ammInventoryLimit'; - type: { - option: 'i64'; - }; - }, - ]; - }; - }, - { - name: 'perpBankruptcyRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'pnl'; - type: 'i128'; - }, - { - name: 'ifPayment'; - type: 'u128'; - }, - { - name: 'clawbackUser'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'clawbackUserPayment'; - type: { - option: 'u128'; - }; - }, - { - name: 'cumulativeFundingRateDelta'; - type: 'i128'; - }, - ]; - }; - }, - { - name: 'perpMarket'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - docs: [ - "The perp market's address. It is a pda of the market index", - ]; - type: 'pubkey'; - }, - { - name: 'amm'; - docs: ['The automated market maker']; - type: { - defined: { - name: 'amm'; - }; - }; - }, - { - name: 'pnlPool'; - docs: [ - "The market's pnl pool. When users settle negative pnl, the balance increases.", - 'When users settle positive pnl, the balance decreases. Can not go negative.', - ]; - type: { - defined: { - name: 'poolBalance'; - }; - }; - }, - { - name: 'name'; - docs: ['Encoded display name for the perp market e.g. SOL-PERP']; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'insuranceClaim'; - docs: ["The perp market's claim on the insurance fund"]; - type: { - defined: { - name: 'insuranceClaim'; - }; - }; - }, - { - name: 'unrealizedPnlMaxImbalance'; - docs: [ - 'The max pnl imbalance before positive pnl asset weight is discounted', - "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", - 'the amm has negative pnl and the initial asset weight for positive pnl is discounted', - 'precision = QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'expiryTs'; - docs: [ - 'The ts when the market will be expired. Only set if market is in reduce only mode', - ]; - type: 'i64'; - }, - { - name: 'expiryPrice'; - docs: [ - 'The price at which positions will be settled. Only set if market is expired', - 'precision = PRICE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'nextFillRecordId'; - docs: [ - 'Every trade has a fill record id. This is the next id to be used', - ]; - type: 'u64'; - }, - { - name: 'nextFundingRateRecordId'; - docs: [ - 'Every funding rate update has a record id. This is the next id to be used', - ]; - type: 'u64'; - }, - { - name: 'nextCurveRecordId'; - docs: [ - 'Every amm k updated has a record id. This is the next id to be used', - ]; - type: 'u64'; - }, - { - name: 'imfFactor'; - docs: [ - 'The initial margin fraction factor. Used to increase margin ratio for large positions', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'unrealizedPnlImfFactor'; - docs: [ - 'The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - docs: [ - 'The fee the liquidator is paid for taking over perp position', - 'precision: LIQUIDATOR_FEE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - docs: [ - 'The fee the insurance fund receives from liquidation', - 'precision: LIQUIDATOR_FEE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'marginRatioInitial'; - docs: [ - 'The margin ratio which determines how much collateral is required to open a position', - 'e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'marginRatioMaintenance'; - docs: [ - 'The margin ratio which determines when a user will be liquidated', - 'e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position', - 'else they will be liquidated', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'unrealizedPnlInitialAssetWeight'; - docs: [ - 'The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'unrealizedPnlMaintenanceAssetWeight'; - docs: [ - 'The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'numberOfUsersWithBase'; - docs: ['number of users in a position (base)']; - type: 'u32'; - }, - { - name: 'numberOfUsers'; - docs: ['number of users in a position (pnl) or pnl (quote)']; - type: 'u32'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'status'; - docs: [ - 'Whether a market is active, reduce only, expired, etc', - 'Affects whether users can open/close positions', - ]; - type: { - defined: { - name: 'marketStatus'; - }; - }; - }, - { - name: 'contractType'; - docs: ['Currently only Perpetual markets are supported']; - type: { - defined: { - name: 'contractType'; - }; - }; - }, - { - name: 'contractTier'; - docs: [ - 'The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance', - 'It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first', - ]; - type: { - defined: { - name: 'contractTier'; - }; - }; - }, - { - name: 'pausedOperations'; - type: 'u8'; - }, - { - name: 'quoteSpotMarketIndex'; - docs: ['The spot market that pnl is settled in']; - type: 'u16'; - }, - { - name: 'feeAdjustment'; - docs: [ - 'Between -100 and 100, represents what % to increase/decrease the fee by', - 'E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps', - 'if this is 50 and the fee is 5bps, the new fee will be 7.5bps', - ]; - type: 'i16'; - }, - { - name: 'fuelBoostPosition'; - docs: ['fuel multiplier for perp funding', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostTaker'; - docs: ['fuel multiplier for perp taker', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostMaker'; - docs: ['fuel multiplier for perp maker', 'precision: 10']; - type: 'u8'; - }, - { - name: 'poolId'; - type: 'u8'; - }, - { - name: 'highLeverageMarginRatioInitial'; - type: 'u16'; - }, - { - name: 'highLeverageMarginRatioMaintenance'; - type: 'u16'; - }, - { - name: 'protectedMakerLimitPriceDivisor'; - type: 'u8'; - }, - { - name: 'protectedMakerDynamicDivisor'; - type: 'u8'; - }, - { - name: 'lpFeeTransferScalar'; - type: 'u8'; - }, - { - name: 'lpStatus'; - type: 'u8'; - }, - { - name: 'lpPausedOperations'; - type: 'u8'; - }, - { - name: 'lpExchangeFeeExcluscionScalar'; - type: 'u8'; - }, - { - name: 'lastFillPrice'; - type: 'u64'; - }, - { - name: 'lpPoolId'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 23]; - }; - }, - ]; - }; - }, - { - name: 'perpPosition'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'lastCumulativeFundingRate'; - docs: [ - "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", - 'precision: FUNDING_RATE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'baseAssetAmount'; - docs: [ - 'the size of the users perp position', - 'precision: BASE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'quoteAssetAmount'; - docs: [ - 'Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees', - 'Updated when the user open/closes position or settles pnl. Includes fees/funding', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'quoteBreakEvenAmount'; - docs: [ - 'The amount of quote the user would need to exit their position at to break even', - 'Updated when the user open/closes position or settles pnl. Includes fees/funding', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'quoteEntryAmount'; - docs: [ - 'The amount quote the user entered the position with. Equal to base asset amount * avg entry price', - 'Updated when the user open/closes position. Excludes fees/funding', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'openBids'; - docs: [ - 'The amount of non reduce only trigger orders the user has open', - 'precision: BASE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'openAsks'; - docs: [ - 'The amount of non reduce only trigger orders the user has open', - 'precision: BASE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'settledPnl'; - docs: [ - 'The amount of pnl settled in this market since opening the position', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lpShares'; - docs: [ - 'The number of lp (liquidity provider) shares the user has in this perp market', - 'LP shares allow users to provide liquidity via the AMM', - 'precision: BASE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastBaseAssetAmountPerLp'; - docs: [ - 'The last base asset amount per lp the amm had', - 'Used to settle the users lp position', - 'precision: BASE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastQuoteAssetAmountPerLp'; - docs: [ - 'The last quote asset amount per lp the amm had', - 'Used to settle the users lp position', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'padding'; - type: { - array: ['u8', 2]; - }; - }, - { - name: 'maxMarginRatio'; - type: 'u16'; - }, - { - name: 'marketIndex'; - docs: ['The market index for the perp market']; - type: 'u16'; - }, - { - name: 'openOrders'; - docs: ['The number of open orders']; - type: 'u8'; - }, - { - name: 'perLpBase'; - type: 'i8'; - }, - ]; - }; - }, - { - name: 'phoenixV1FulfillmentConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - type: 'pubkey'; - }, - { - name: 'phoenixProgramId'; - type: 'pubkey'; - }, - { - name: 'phoenixLogAuthority'; - type: 'pubkey'; - }, - { - name: 'phoenixMarket'; - type: 'pubkey'; - }, - { - name: 'phoenixBaseVault'; - type: 'pubkey'; - }, - { - name: 'phoenixQuoteVault'; - type: 'pubkey'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fulfillmentType'; - type: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }, - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - ]; - }; - }, - { - name: 'poolBalance'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'scaledBalance'; - docs: [ - "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", - 'deposit interest', - 'precision: SPOT_BALANCE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'marketIndex'; - docs: ['The spot market the pool is for']; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 6]; - }; - }, - ]; - }; - }, - { - name: 'positionDirection'; - type: { - kind: 'enum'; - variants: [ - { - name: 'long'; - }, - { - name: 'short'; - }, - ]; - }; - }, - { - name: 'postOnlyParam'; - type: { - kind: 'enum'; - variants: [ - { - name: 'none'; - }, - { - name: 'mustPostOnly'; - }, - { - name: 'tryPostOnly'; - }, - { - name: 'slide'; - }, - ]; - }; - }, - { - name: 'prelaunchOracle'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'price'; - type: 'i64'; - }, - { - name: 'maxPrice'; - type: 'i64'; - }, - { - name: 'confidence'; - type: 'u64'; - }, - { - name: 'lastUpdateSlot'; - type: 'u64'; - }, - { - name: 'ammLastUpdateSlot'; - type: 'u64'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 70]; - }; - }, - ]; - }; - }, - { - name: 'prelaunchOracleParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'price'; - type: { - option: 'i64'; - }; - }, - { - name: 'maxPrice'; - type: { - option: 'i64'; - }; - }, - ]; - }; - }, - { - name: 'priceDivergenceGuardRails'; - type: { - kind: 'struct'; - fields: [ - { - name: 'markOraclePercentDivergence'; - type: 'u64'; - }, - { - name: 'oracleTwap5minPercentDivergence'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'protectedMakerModeConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - { - name: 'currentUsers'; - type: 'u32'; - }, - { - name: 'reduceOnly'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 31]; - }; - }, - ]; - }; - }, - { - name: 'pythLazerOracle'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'price'; - type: 'i64'; - }, - { - name: 'publishTime'; - type: 'u64'; - }, - { - name: 'postedSlot'; - type: 'u64'; - }, - { - name: 'exponent'; - type: 'i32'; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - { - name: 'conf'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'referrerName'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'userStats'; - type: 'pubkey'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }; - }, - { - name: 'revenueShare'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'rust'; - packed: true; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['the owner of this account, a builder or referrer']; - type: 'pubkey'; - }, - { - name: 'totalReferrerRewards'; - type: 'u64'; - }, - { - name: 'totalBuilderRewards'; - type: 'u64'; - }, - { - name: 'padding'; - type: { - array: ['u8', 18]; - }; - }, - ]; - }; - }, - { - name: 'revenueShareEscrow'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['the owner of this account, a user']; - type: 'pubkey'; - }, - { - name: 'referrer'; - type: 'pubkey'; - }, - { - name: 'referrerBoostExpireTs'; - type: 'u32'; - }, - { - name: 'referrerRewardOffset'; - type: 'i8'; - }, - { - name: 'refereeFeeNumeratorOffset'; - type: 'i8'; - }, - { - name: 'referrerBoostNumerator'; - type: 'i8'; - }, - { - name: 'reservedFixed'; - type: { - array: ['u8', 17]; - }; - }, - { - name: 'padding0'; - type: 'u32'; - }, - { - name: 'orders'; - type: { - vec: { - defined: { - name: 'revenueShareOrder'; - }; - }; - }; - }, - { - name: 'padding1'; - type: 'u32'; - }, - { - name: 'approvedBuilders'; - type: { - vec: { - defined: { - name: 'builderInfo'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'revenueShareOrder'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'feesAccrued'; - docs: [ - 'fees accrued so far for this order slot. This is not exclusively fees from this order_id', - 'and may include fees from other orders in the same market. This may be swept to the', - "builder's SpotPosition during settle_pnl.", - ]; - type: 'u64'; - }, - { - name: 'orderId'; - docs: [ - "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open", - ]; - type: 'u32'; - }, - { - name: 'feeTenthBps'; - docs: [ - 'the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%', - ]; - type: 'u16'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'subAccountId'; - docs: [ - "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open", - ]; - type: 'u16'; - }, - { - name: 'builderIdx'; - docs: [ - "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", - 'if bit_flag = Referral.', - ]; - type: 'u8'; - }, - { - name: 'bitFlags'; - docs: [ - 'bitflags that describe the state of the order.', - '[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.', - "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", - '[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.', - "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", - '[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.', - 'If it is set, no other bitflag should be set.', - ]; - type: 'u8'; - }, - { - name: 'userOrderIndex'; - docs: [ - "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches.", - ]; - type: 'u8'; - }, - { - name: 'marketType'; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 10]; - }; - }, - ]; - }; - }, - { - name: 'revenueShareSettleRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'builder'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'referrer'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'feeSettled'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'marketType'; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'builderSubAccountId'; - type: 'u16'; - }, - { - name: 'builderTotalReferrerRewards'; - type: 'u64'; - }, - { - name: 'builderTotalBuilderRewards'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'serumV3FulfillmentConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - type: 'pubkey'; - }, - { - name: 'serumProgramId'; - type: 'pubkey'; - }, - { - name: 'serumMarket'; - type: 'pubkey'; - }, - { - name: 'serumRequestQueue'; - type: 'pubkey'; - }, - { - name: 'serumEventQueue'; - type: 'pubkey'; - }, - { - name: 'serumBids'; - type: 'pubkey'; - }, - { - name: 'serumAsks'; - type: 'pubkey'; - }, - { - name: 'serumBaseVault'; - type: 'pubkey'; - }, - { - name: 'serumQuoteVault'; - type: 'pubkey'; - }, - { - name: 'serumOpenOrders'; - type: 'pubkey'; - }, - { - name: 'serumSignerNonce'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fulfillmentType'; - type: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }, - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - ]; - }; - }, - { - name: 'settlePnlExplanation'; - type: { - kind: 'enum'; - variants: [ - { - name: 'none'; - }, - { - name: 'expiredPosition'; - }, - ]; - }; - }, - { - name: 'settlePnlMode'; - type: { - kind: 'enum'; - variants: [ - { - name: 'mustSettle'; - }, - { - name: 'trySettle'; - }, - ]; - }; - }, - { - name: 'settlePnlRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'pnl'; - type: 'i128'; - }, - { - name: 'baseAssetAmount'; - type: 'i64'; - }, - { - name: 'quoteAssetAmountAfter'; - type: 'i64'; - }, - { - name: 'quoteEntryAmount'; - type: 'i64'; - }, - { - name: 'settlePrice'; - type: 'i64'; - }, - { - name: 'explanation'; - type: { - defined: { - name: 'settlePnlExplanation'; - }; - }; - }, - ]; - }; - }, - { - name: 'signedMsgOrderId'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'uuid'; - type: { - array: ['u8', 8]; - }; - }, - { - name: 'maxSlot'; - type: 'u64'; - }, - { - name: 'orderId'; - type: 'u32'; - }, - { - name: 'padding'; - type: 'u32'; - }, - ]; - }; - }, - { - name: 'signedMsgOrderRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'hash'; - type: 'string'; - }, - { - name: 'matchingOrderParams'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'userOrderId'; - type: 'u32'; - }, - { - name: 'signedMsgOrderMaxSlot'; - type: 'u64'; - }, - { - name: 'signedMsgOrderUuid'; - type: { - array: ['u8', 8]; - }; - }, - { - name: 'ts'; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'signedMsgUserOrders'; - docs: [ - '* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently', - ]; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authorityPubkey'; - type: 'pubkey'; - }, - { - name: 'padding'; - type: 'u32'; - }, - { - name: 'signedMsgOrderData'; - type: { - vec: { - defined: { - name: 'signedMsgOrderId'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'signedMsgWsDelegates'; - docs: [ - '* Used to store authenticated delegates for swift-like ws connections', - ]; - type: { - kind: 'struct'; - fields: [ - { - name: 'delegates'; - type: { - vec: 'pubkey'; - }; - }, - ]; - }; - }, - { - name: 'spotBalanceType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'deposit'; - }, - { - name: 'borrow'; - }, - ]; - }; - }, - { - name: 'spotBankruptcyRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'borrowAmount'; - type: 'u128'; - }, - { - name: 'ifPayment'; - type: 'u128'; - }, - { - name: 'cumulativeDepositInterestDelta'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'spotFulfillmentConfigStatus'; - type: { - kind: 'enum'; - variants: [ - { - name: 'enabled'; - }, - { - name: 'disabled'; - }, - ]; - }; - }, - { - name: 'spotFulfillmentType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'serumV3'; - }, - { - name: 'match'; - }, - { - name: 'phoenixV1'; - }, - { - name: 'openbookV2'; - }, - ]; - }; - }, - { - name: 'spotInterestRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'depositBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'cumulativeDepositInterest'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'borrowBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'cumulativeBorrowInterest'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'optimalUtilization'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - { - name: 'optimalBorrowRate'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - { - name: 'maxBorrowRate'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - ]; - }; - }, - { - name: 'spotMarket'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - docs: [ - 'The address of the spot market. It is a pda of the market index', - ]; - type: 'pubkey'; - }, - { - name: 'oracle'; - docs: ['The oracle used to price the markets deposits/borrows']; - type: 'pubkey'; - }, - { - name: 'mint'; - docs: ['The token mint of the market']; - type: 'pubkey'; - }, - { - name: 'vault'; - docs: [ - "The vault used to store the market's deposits", - 'The amount in the vault should be equal to or greater than deposits - borrows', - ]; - type: 'pubkey'; - }, - { - name: 'name'; - docs: ['The encoded display name for the market e.g. SOL']; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'historicalOracleData'; - type: { - defined: { - name: 'historicalOracleData'; - }; - }; - }, - { - name: 'historicalIndexData'; - type: { - defined: { - name: 'historicalIndexData'; - }; - }; - }, - { - name: 'revenuePool'; - docs: [ - 'Revenue the protocol has collected in this markets token', - 'e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool', - ]; - type: { - defined: { - name: 'poolBalance'; - }; - }; - }, - { - name: 'spotFeePool'; - docs: [ - 'The fees collected from swaps between this market and the quote market', - 'Is settled to the quote markets revenue pool', - ]; - type: { - defined: { - name: 'poolBalance'; - }; - }; - }, - { - name: 'insuranceFund'; - docs: [ - 'Details on the insurance fund covering bankruptcies in this markets token', - 'Covers bankruptcies for borrows with this markets token and perps settling in this markets token', - ]; - type: { - defined: { - name: 'insuranceFund'; - }; - }; - }, - { - name: 'totalSpotFee'; - docs: [ - 'The total spot fees collected for this market', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'depositBalance'; - docs: [ - 'The sum of the scaled balances for deposits across users and pool balances', - 'To convert to the deposit token amount, multiply by the cumulative deposit interest', - 'precision: SPOT_BALANCE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'borrowBalance'; - docs: [ - 'The sum of the scaled balances for borrows across users and pool balances', - 'To convert to the borrow token amount, multiply by the cumulative borrow interest', - 'precision: SPOT_BALANCE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeDepositInterest'; - docs: [ - 'The cumulative interest earned by depositors', - 'Used to calculate the deposit token amount from the deposit balance', - 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeBorrowInterest'; - docs: [ - 'The cumulative interest earned by borrowers', - 'Used to calculate the borrow token amount from the borrow balance', - 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalSocialLoss'; - docs: [ - "The total socialized loss from borrows, in the mint's token", - 'precision: token mint precision', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalQuoteSocialLoss'; - docs: [ - "The total socialized loss from borrows, in the quote market's token", - 'preicision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'withdrawGuardThreshold'; - docs: [ - 'no withdraw limits/guards when deposits below this threshold', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'maxTokenDeposits'; - docs: [ - 'The max amount of token deposits in this market', - '0 if there is no limit', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'depositTokenTwap'; - docs: [ - '24hr average of deposit token amount', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'borrowTokenTwap'; - docs: [ - '24hr average of borrow token amount', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'utilizationTwap'; - docs: [ - '24hr average of utilization', - 'which is borrow amount over token amount', - 'precision: SPOT_UTILIZATION_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastInterestTs'; - docs: [ - 'Last time the cumulative deposit and borrow interest was updated', - ]; - type: 'u64'; - }, - { - name: 'lastTwapTs'; - docs: [ - 'Last time the deposit/borrow/utilization averages were updated', - ]; - type: 'u64'; - }, - { - name: 'expiryTs'; - docs: [ - 'The time the market is set to expire. Only set if market is in reduce only mode', - ]; - type: 'i64'; - }, - { - name: 'orderStepSize'; - docs: [ - 'Spot orders must be a multiple of the step size', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'orderTickSize'; - docs: [ - 'Spot orders must be a multiple of the tick size', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'minOrderSize'; - docs: ['The minimum order size', 'precision: token mint precision']; - type: 'u64'; - }, - { - name: 'maxPositionSize'; - docs: [ - 'The maximum spot position size', - 'if the limit is 0, there is no limit', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'nextFillRecordId'; - docs: [ - 'Every spot trade has a fill record id. This is the next id to use', - ]; - type: 'u64'; - }, - { - name: 'nextDepositRecordId'; - docs: [ - 'Every deposit has a deposit record id. This is the next id to use', - ]; - type: 'u64'; - }, - { - name: 'initialAssetWeight'; - docs: [ - 'The initial asset weight used to calculate a deposits contribution to a users initial total collateral', - 'e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'maintenanceAssetWeight'; - docs: [ - 'The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral', - 'e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'initialLiabilityWeight'; - docs: [ - 'The initial liability weight used to calculate a borrows contribution to a users initial margin requirement', - 'e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'maintenanceLiabilityWeight'; - docs: [ - 'The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement', - 'e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'imfFactor'; - docs: [ - 'The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - docs: [ - 'The fee the liquidator is paid for taking over borrow/deposit', - 'precision: LIQUIDATOR_FEE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - docs: [ - 'The fee the insurance fund receives from liquidation', - 'precision: LIQUIDATOR_FEE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'optimalUtilization'; - docs: [ - 'The optimal utilization rate for this market.', - 'Used to determine the markets borrow rate', - 'precision: SPOT_UTILIZATION_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'optimalBorrowRate'; - docs: [ - 'The borrow rate for this market when the market has optimal utilization', - 'precision: SPOT_RATE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'maxBorrowRate'; - docs: [ - 'The borrow rate for this market when the market has 1000 utilization', - 'precision: SPOT_RATE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'decimals'; - docs: [ - "The market's token mint's decimals. To from decimals to a precision, 10^decimals", - ]; - type: 'u32'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'ordersEnabled'; - docs: ['Whether or not spot trading is enabled']; - type: 'bool'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'status'; - type: { - defined: { - name: 'marketStatus'; - }; - }; - }, - { - name: 'assetTier'; - docs: [ - 'The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated', - ]; - type: { - defined: { - name: 'assetTier'; - }; - }; - }, - { - name: 'pausedOperations'; - type: 'u8'; - }, - { - name: 'ifPausedOperations'; - type: 'u8'; - }, - { - name: 'feeAdjustment'; - type: 'i16'; - }, - { - name: 'maxTokenBorrowsFraction'; - docs: [ - 'What fraction of max_token_deposits', - 'disabled when 0, 1 => 1/10000 => .01% of max_token_deposits', - 'precision: X/10000', - ]; - type: 'u16'; - }, - { - name: 'flashLoanAmount'; - docs: [ - 'For swaps, the amount of token loaned out in the begin_swap ix', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'flashLoanInitialTokenAmount'; - docs: [ - 'For swaps, the amount in the users token account in the begin_swap ix', - 'Used to calculate how much of the token left the system in end_swap ix', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'totalSwapFee'; - docs: [ - 'The total fees received from swaps', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'scaleInitialAssetWeightStart'; - docs: [ - 'When to begin scaling down the initial asset weight', - 'disabled when 0', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'minBorrowRate'; - docs: [ - 'The min borrow rate for this market when the market regardless of utilization', - '1 => 1/200 => .5%', - 'precision: X/200', - ]; - type: 'u8'; - }, - { - name: 'fuelBoostDeposits'; - docs: ['fuel multiplier for spot deposits', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostBorrows'; - docs: ['fuel multiplier for spot borrows', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostTaker'; - docs: ['fuel multiplier for spot taker', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostMaker'; - docs: ['fuel multiplier for spot maker', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostInsurance'; - docs: ['fuel multiplier for spot insurance stake', 'precision: 10']; - type: 'u8'; - }, - { - name: 'tokenProgramFlag'; - type: 'u8'; - }, - { - name: 'poolId'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 40]; - }; - }, - ]; - }; - }, - { - name: 'spotMarketVaultDepositRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'depositBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'cumulativeDepositInterestBefore'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'cumulativeDepositInterestAfter'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'depositTokenAmountBefore'; - type: 'u64'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'spotPosition'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'scaledBalance'; - docs: [ - 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', - 'interest of corresponding market.', - 'precision: SPOT_BALANCE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'openBids'; - docs: [ - 'How many spot non reduce only trigger orders the user has open', - 'precision: token mint precision', - ]; - type: 'i64'; - }, - { - name: 'openAsks'; - docs: [ - 'How many spot non reduce only trigger orders the user has open', - 'precision: token mint precision', - ]; - type: 'i64'; - }, - { - name: 'cumulativeDeposits'; - docs: [ - 'The cumulative deposits/borrows a user has made into a market', - 'precision: token mint precision', - ]; - type: 'i64'; - }, - { - name: 'marketIndex'; - docs: ['The market index of the corresponding spot market']; - type: 'u16'; - }, - { - name: 'balanceType'; - docs: ['Whether the position is deposit or borrow']; - type: { - defined: { - name: 'spotBalanceType'; - }; - }; - }, - { - name: 'openOrders'; - docs: ['Number of open orders']; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - ]; - }; - }, - { - name: 'stakeAction'; - type: { - kind: 'enum'; - variants: [ - { - name: 'stake'; - }, - { - name: 'unstakeRequest'; - }, - { - name: 'unstakeCancelRequest'; - }, - { - name: 'unstake'; - }, - { - name: 'unstakeTransfer'; - }, - { - name: 'stakeTransfer'; - }, - { - name: 'adminDeposit'; - }, - ]; - }; - }, - { - name: 'state'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'admin'; - type: 'pubkey'; - }, - { - name: 'whitelistMint'; - type: 'pubkey'; - }, - { - name: 'discountMint'; - type: 'pubkey'; - }, - { - name: 'signer'; - type: 'pubkey'; - }, - { - name: 'srmVault'; - type: 'pubkey'; - }, - { - name: 'perpFeeStructure'; - type: { - defined: { - name: 'feeStructure'; - }; - }; - }, - { - name: 'spotFeeStructure'; - type: { - defined: { - name: 'feeStructure'; - }; - }; - }, - { - name: 'oracleGuardRails'; - type: { - defined: { - name: 'oracleGuardRails'; - }; - }; - }, - { - name: 'numberOfAuthorities'; - type: 'u64'; - }, - { - name: 'numberOfSubAccounts'; - type: 'u64'; - }, - { - name: 'lpCooldownTime'; - type: 'u64'; - }, - { - name: 'liquidationMarginBufferRatio'; - type: 'u32'; - }, - { - name: 'settlementDuration'; - type: 'u16'; - }, - { - name: 'numberOfMarkets'; - type: 'u16'; - }, - { - name: 'numberOfSpotMarkets'; - type: 'u16'; - }, - { - name: 'signerNonce'; - type: 'u8'; - }, - { - name: 'minPerpAuctionDuration'; - type: 'u8'; - }, - { - name: 'defaultMarketOrderTimeInForce'; - type: 'u8'; - }, - { - name: 'defaultSpotAuctionDuration'; - type: 'u8'; - }, - { - name: 'exchangeStatus'; - type: 'u8'; - }, - { - name: 'liquidationDuration'; - type: 'u8'; - }, - { - name: 'initialPctToLiquidate'; - type: 'u16'; - }, - { - name: 'maxNumberOfSubAccounts'; - type: 'u16'; - }, - { - name: 'maxInitializeUserFee'; - type: 'u16'; - }, - { - name: 'featureBitFlags'; - type: 'u8'; - }, - { - name: 'lpPoolFeatureBitFlags'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 8]; - }; - }, - ]; - }; - }, - { - name: 'swapRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'amountOut'; - docs: ['precision: out market mint precision']; - type: 'u64'; - }, - { - name: 'amountIn'; - docs: ['precision: in market mint precision']; - type: 'u64'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'inOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'fee'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'swapReduceOnly'; - type: { - kind: 'enum'; - variants: [ - { - name: 'in'; - }, - { - name: 'out'; - }, - ]; - }; - }, - { - name: 'targetsDatum'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'costToTradeBps'; - type: 'i32'; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - { - name: 'targetBase'; - type: 'i64'; - }, - { - name: 'lastOracleSlot'; - type: 'u64'; - }, - { - name: 'lastPositionSlot'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'transferProtocolIfSharesToRevenuePoolRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - { - name: 'shares'; - type: 'u128'; - }, - { - name: 'ifVaultAmountBefore'; - type: 'u64'; - }, - { - name: 'protocolSharesBefore'; - type: 'u128'; - }, - { - name: 'transferAmount'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'updatePerpMarketSummaryStatsParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'quoteAssetAmountWithUnsettledLp'; - type: { - option: 'i64'; - }; - }, - { - name: 'netUnsettledFundingPnl'; - type: { - option: 'i64'; - }; - }, - { - name: 'updateAmmSummaryStats'; - type: { - option: 'bool'; - }; - }, - { - name: 'excludeTotalLiqFee'; - type: { - option: 'bool'; - }; - }, - ]; - }; - }, - { - name: 'user'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['The owner/authority of the account']; - type: 'pubkey'; - }, - { - name: 'delegate'; - docs: [ - "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw", - ]; - type: 'pubkey'; - }, - { - name: 'name'; - docs: ['Encoded display name e.g. "toly"']; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'spotPositions'; - docs: ["The user's spot positions"]; - type: { - array: [ - { - defined: { - name: 'spotPosition'; - }; - }, - 8, - ]; - }; - }, - { - name: 'perpPositions'; - docs: ["The user's perp positions"]; - type: { - array: [ - { - defined: { - name: 'perpPosition'; - }; - }, - 8, - ]; - }; - }, - { - name: 'orders'; - docs: ["The user's orders"]; - type: { - array: [ - { - defined: { - name: 'order'; - }; - }, - 32, - ]; - }; - }, - { - name: 'lastAddPerpLpSharesTs'; - docs: ['The last time the user added perp lp positions']; - type: 'i64'; - }, - { - name: 'totalDeposits'; - docs: [ - 'The total values of deposits the user has made', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'totalWithdraws'; - docs: [ - 'The total values of withdrawals the user has made', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'totalSocialLoss'; - docs: [ - 'The total socialized loss the users has incurred upon the protocol', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'settledPerpPnl'; - docs: [ - 'Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'cumulativeSpotFees'; - docs: [ - 'Fees (taker fees, maker rebate, filler reward) for spot', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'cumulativePerpFunding'; - docs: [ - 'Cumulative funding paid/received for perps', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'liquidationMarginFreed'; - docs: [ - 'The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time', - 'Defaults to zero when not being liquidated', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastActiveSlot'; - docs: [ - 'The last slot a user was active. Used to determine if a user is idle', - ]; - type: 'u64'; - }, - { - name: 'nextOrderId'; - docs: [ - 'Every user order has an order id. This is the next order id to be used', - ]; - type: 'u32'; - }, - { - name: 'maxMarginRatio'; - docs: ['Custom max initial margin ratio for the user']; - type: 'u32'; - }, - { - name: 'nextLiquidationId'; - docs: ['The next liquidation id to be used for user']; - type: 'u16'; - }, - { - name: 'subAccountId'; - docs: ['The sub account id for this user']; - type: 'u16'; - }, - { - name: 'status'; - docs: ['Whether the user is active, being liquidated or bankrupt']; - type: 'u8'; - }, - { - name: 'isMarginTradingEnabled'; - docs: ['Whether the user has enabled margin trading']; - type: 'bool'; - }, - { - name: 'idle'; - docs: [ - "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", - 'Off-chain keeper bots can ignore users that are idle', - ]; - type: 'bool'; - }, - { - name: 'openOrders'; - docs: ['number of open orders']; - type: 'u8'; - }, - { - name: 'hasOpenOrder'; - docs: ['Whether or not user has open order']; - type: 'bool'; - }, - { - name: 'openAuctions'; - docs: ['number of open orders with auction']; - type: 'u8'; - }, - { - name: 'hasOpenAuction'; - docs: ['Whether or not user has open order with auction']; - type: 'bool'; - }, - { - name: 'marginMode'; - type: { - defined: { - name: 'marginMode'; - }; - }; - }, - { - name: 'poolId'; - type: 'u8'; - }, - { - name: 'padding1'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'lastFuelBonusUpdateTs'; - type: 'u32'; - }, - { - name: 'padding'; - type: { - array: ['u8', 12]; - }; - }, - ]; - }; - }, - { - name: 'userFees'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'totalFeePaid'; - docs: ['Total taker fee paid', 'precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'totalFeeRebate'; - docs: ['Total maker fee rebate', 'precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'totalTokenDiscount'; - docs: [ - 'Total discount from holding token', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'totalRefereeDiscount'; - docs: [ - 'Total discount from being referred', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'totalReferrerReward'; - docs: ['Total reward to referrer', 'precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'currentEpochReferrerReward'; - docs: [ - 'Total reward to referrer this epoch', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'userStats'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['The authority for all of a users sub accounts']; - type: 'pubkey'; - }, - { - name: 'referrer'; - docs: ['The address that referred this user']; - type: 'pubkey'; - }, - { - name: 'fees'; - docs: ['Stats on the fees paid by the user']; - type: { - defined: { - name: 'userFees'; - }; - }; - }, - { - name: 'nextEpochTs'; - docs: [ - 'The timestamp of the next epoch', - 'Epoch is used to limit referrer rewards earned in single epoch', - ]; - type: 'i64'; - }, - { - name: 'makerVolume30d'; - docs: [ - 'Rolling 30day maker volume for user', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'takerVolume30d'; - docs: [ - 'Rolling 30day taker volume for user', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'fillerVolume30d'; - docs: [ - 'Rolling 30day filler volume for user', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastMakerVolume30dTs'; - docs: ['last time the maker volume was updated']; - type: 'i64'; - }, - { - name: 'lastTakerVolume30dTs'; - docs: ['last time the taker volume was updated']; - type: 'i64'; - }, - { - name: 'lastFillerVolume30dTs'; - docs: ['last time the filler volume was updated']; - type: 'i64'; - }, - { - name: 'ifStakedQuoteAssetAmount'; - docs: ['The amount of tokens staked in the quote spot markets if']; - type: 'u64'; - }, - { - name: 'numberOfSubAccounts'; - docs: ['The current number of sub accounts']; - type: 'u16'; - }, - { - name: 'numberOfSubAccountsCreated'; - docs: [ - 'The number of sub accounts created. Can be greater than the number of sub accounts if user', - 'has deleted sub accounts', - ]; - type: 'u16'; - }, - { - name: 'referrerStatus'; - docs: [ - 'Flags for referrer status:', - 'First bit (LSB): 1 if user is a referrer, 0 otherwise', - 'Second bit: 1 if user was referred, 0 otherwise', - ]; - type: 'u8'; - }, - { - name: 'disableUpdatePerpBidAskTwap'; - type: 'bool'; - }, - { - name: 'padding1'; - type: { - array: ['u8', 1]; - }; - }, - { - name: 'fuelOverflowStatus'; - docs: ['whether the user has a FuelOverflow account']; - type: 'u8'; - }, - { - name: 'fuelInsurance'; - docs: ['accumulated fuel for token amounts of insurance']; - type: 'u32'; - }, - { - name: 'fuelDeposits'; - docs: ['accumulated fuel for notional of deposits']; - type: 'u32'; - }, - { - name: 'fuelBorrows'; - docs: ['accumulate fuel bonus for notional of borrows']; - type: 'u32'; - }, - { - name: 'fuelPositions'; - docs: ['accumulated fuel for perp open interest']; - type: 'u32'; - }, - { - name: 'fuelTaker'; - docs: ['accumulate fuel bonus for taker volume']; - type: 'u32'; - }, - { - name: 'fuelMaker'; - docs: ['accumulate fuel bonus for maker volume']; - type: 'u32'; - }, - { - name: 'ifStakedGovTokenAmount'; - docs: [ - 'The amount of tokens staked in the governance spot markets if', - ]; - type: 'u64'; - }, - { - name: 'lastFuelIfBonusUpdateTs'; - docs: [ - 'last unix ts user stats data was used to update if fuel (u32 to save space)', - ]; - type: 'u32'; - }, - { - name: 'padding'; - type: { - array: ['u8', 12]; - }; - }, - ]; - }; - }, - { - name: 'validityGuardRails'; - type: { - kind: 'struct'; - fields: [ - { - name: 'slotsBeforeStaleForAmm'; - type: 'i64'; - }, - { - name: 'slotsBeforeStaleForMargin'; - type: 'i64'; - }, - { - name: 'confidenceIntervalMaxSize'; - type: 'u64'; - }, - { - name: 'tooVolatileRatio'; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'i128'; - docs: ['`i128` with legacy bit layout']; - type: { - kind: 'struct'; - fields: [ - { - array: ['u8', 16]; - }, - ]; - }; - }, - { - name: 'u128'; - docs: ['`u128` with legacy bit layout']; - type: { - kind: 'struct'; - fields: [ - { - array: ['u8', 16]; - }, - ]; - }; - }, - ]; + "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH", + "metadata": { + "name": "drift", + "version": "2.151.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "addAmmConstituentMappingData", + "discriminator": [ + 164, + 236, + 130, + 40, + 118, + 179, + 46, + 235 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool" + }, + { + "name": "ammConstituentMapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituentTargetBase", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "ammConstituentMappingData", + "type": { + "vec": { + "defined": { + "name": "addAmmConstituentMappingDatum" + } + } + } + } + ] + }, + { + "name": "addInsuranceFundStake", + "discriminator": [ + 251, + 144, + 115, + 11, + 222, + 47, + 62, + 236 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insuranceFundStake", + "userStats" + ] + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "addMarketToAmmCache", + "discriminator": [ + 112, + 149, + 195, + 222, + 124, + 7, + 87, + 237 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + }, + { + "name": "perpMarket" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "adminDeposit", + "discriminator": [ + 210, + 66, + 65, + 182, + 102, + 214, + 176, + 30 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "adminTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "adminUpdateUserStatsPausedOperations", + "discriminator": [ + 183, + 104, + 63, + 150, + 240, + 199, + 3, + 10 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "beginInsuranceFundSwap", + "discriminator": [ + 176, + 69, + 143, + 205, + 32, + 132, + 163, + 0 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "outInsuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inInsuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outTokenAccount", + "writable": true + }, + { + "name": "inTokenAccount", + "writable": true + }, + { + "name": "ifRebalanceConfig", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "amountIn", + "type": "u64" + } + ] + }, + { + "name": "beginLpSwap", + "discriminator": [ + 64, + 44, + 24, + 199, + 48, + 125, + 67, + 91 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "signerOutTokenAccount", + "docs": [ + "Signer token accounts" + ], + "writable": true + }, + { + "name": "signerInTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "docs": [ + "Constituent token accounts" + ], + "writable": true + }, + { + "name": "constituentInTokenAccount", + "writable": true + }, + { + "name": "outConstituent", + "docs": [ + "Constituents" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "lpPool" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "amountIn", + "type": "u64" + } + ] + }, + { + "name": "beginSwap", + "discriminator": [ + 174, + 109, + 228, + 1, + 242, + 105, + 232, + 105 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "outSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outTokenAccount", + "writable": true + }, + { + "name": "inTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "amountIn", + "type": "u64" + } + ] + }, + { + "name": "cancelOrder", + "discriminator": [ + 95, + 129, + 237, + 240, + 8, + 49, + 223, + 132 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "orderId", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "cancelOrderByUserId", + "discriminator": [ + 107, + 211, + 250, + 133, + 18, + 37, + 57, + 100 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "userOrderId", + "type": "u8" + } + ] + }, + { + "name": "cancelOrders", + "discriminator": [ + 238, + 225, + 95, + 158, + 227, + 103, + 8, + 194 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "marketType", + "type": { + "option": { + "defined": { + "name": "marketType" + } + } + } + }, + { + "name": "marketIndex", + "type": { + "option": "u16" + } + }, + { + "name": "direction", + "type": { + "option": { + "defined": { + "name": "positionDirection" + } + } + } + } + ] + }, + { + "name": "cancelOrdersByIds", + "discriminator": [ + 134, + 19, + 144, + 165, + 94, + 240, + 210, + 94 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "orderIds", + "type": { + "vec": "u32" + } + } + ] + }, + { + "name": "cancelRequestRemoveInsuranceFundStake", + "discriminator": [ + 97, + 235, + 78, + 62, + 212, + 42, + 241, + 127 + ], + "accounts": [ + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insuranceFundStake", + "userStats" + ] + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "changeApprovedBuilder", + "discriminator": [ + 179, + 134, + 211, + 45, + 195, + 5, + 189, + 173 + ], + "accounts": [ + { + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "signer": true, + "relations": [ + "escrow" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "builder", + "type": "pubkey" + }, + { + "name": "maxFeeBps", + "type": "u16" + }, + { + "name": "add", + "type": "bool" + } + ] + }, + { + "name": "changeSignedMsgWsDelegateStatus", + "discriminator": [ + 252, + 202, + 252, + 219, + 179, + 27, + 84, + 138 + ], + "accounts": [ + { + "name": "signedMsgWsDelegates", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71, + 95, + 87, + 83 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "delegate", + "type": "pubkey" + }, + { + "name": "add", + "type": "bool" + } + ] + }, + { + "name": "deleteAmmCache", + "discriminator": [ + 216, + 130, + 215, + 206, + 233, + 232, + 191, + 88 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "deleteInitializedPerpMarket", + "discriminator": [ + 91, + 154, + 24, + 87, + 106, + 59, + 190, + 66 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "deleteInitializedSpotMarket", + "discriminator": [ + 31, + 140, + 67, + 191, + 189, + 20, + 101, + 221 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "deletePrelaunchOracle", + "discriminator": [ + 59, + 169, + 100, + 49, + 69, + 17, + 173, + 253 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "prelaunchOracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "perpMarketIndex" + } + ] + } + }, + { + "name": "perpMarket" + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "perpMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "deleteSignedMsgUserOrders", + "discriminator": [ + 221, + 247, + 128, + 253, + 212, + 254, + 46, + 153 + ], + "accounts": [ + { + "name": "signedMsgUserOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [] + }, + { + "name": "deleteUser", + "discriminator": [ + 186, + 85, + 17, + 249, + 219, + 231, + 98, + 251 + ], + "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "writable": true, + "signer": true, + "relations": [ + "user", + "userStats" + ] + } + ], + "args": [] + }, + { + "name": "deposit", + "discriminator": [ + 242, + 35, + 198, + 137, + 82, + 225, + 242, + 182 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "reduceOnly", + "type": "bool" + } + ] + }, + { + "name": "depositIntoInsuranceFundStake", + "discriminator": [ + 4, + 22, + 226, + 201, + 124, + 44, + 82, + 230 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101 + ] + }, + { + "kind": "account", + "path": "userStats" + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "depositIntoPerpMarketFeePool", + "discriminator": [ + 34, + 58, + 57, + 68, + 97, + 80, + 244, + 6 + ], + "accounts": [ + { + "name": "state", + "writable": true + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "sourceVault", + "writable": true + }, + { + "name": "driftSigner" + }, + { + "name": "quoteSpotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "depositIntoSpotMarketRevenuePool", + "discriminator": [ + 92, + 40, + 151, + 42, + 122, + 254, + 139, + 246 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spotMarket" + } + ] + } + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "depositIntoSpotMarketVault", + "discriminator": [ + 48, + 252, + 119, + 73, + 255, + 205, + 174, + 247 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "admin", + "signer": true + }, + { + "name": "sourceVault", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "depositToProgramVault", + "discriminator": [ + 235, + 171, + 121, + 80, + 57, + 239, + 147, + 220 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "constituent", + "writable": true + }, + { + "name": "constituentTokenAccount", + "writable": true + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "mint" + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "disableUserHighLeverageMode", + "discriminator": [ + 183, + 155, + 45, + 0, + 226, + 85, + 213, + 69 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "highLeverageModeConfig", + "writable": true + } + ], + "args": [ + { + "name": "disableMaintenance", + "type": "bool" + } + ] + }, + { + "name": "enableUserHighLeverageMode", + "discriminator": [ + 231, + 24, + 230, + 112, + 201, + 173, + 73, + 184 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "highLeverageModeConfig", + "writable": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + } + ] + }, + { + "name": "endInsuranceFundSwap", + "discriminator": [ + 206, + 230, + 98, + 8, + 249, + 158, + 169, + 167 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "outInsuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inInsuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outTokenAccount", + "writable": true + }, + { + "name": "inTokenAccount", + "writable": true + }, + { + "name": "ifRebalanceConfig", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "endLpSwap", + "discriminator": [ + 99, + 125, + 214, + 165, + 129, + 175, + 253, + 135 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "signerOutTokenAccount", + "docs": [ + "Signer token accounts" + ], + "writable": true + }, + { + "name": "signerInTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "docs": [ + "Constituent token accounts" + ], + "writable": true + }, + { + "name": "constituentInTokenAccount", + "writable": true + }, + { + "name": "outConstituent", + "docs": [ + "Constituents" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "lpPool" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "endSwap", + "discriminator": [ + 177, + 184, + 27, + 193, + 34, + 13, + 210, + 145 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "outSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outTokenAccount", + "writable": true + }, + { + "name": "inTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + }, + { + "name": "reduceOnly", + "type": { + "option": { + "defined": { + "name": "swapReduceOnly" + } + } + } + } + ] + }, + { + "name": "fillPerpOrder", + "discriminator": [ + 13, + 188, + 248, + 103, + 134, + 217, + 106, + 240 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "fillerStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "orderId", + "type": { + "option": "u32" + } + }, + { + "name": "makerOrderId", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "fillSpotOrder", + "discriminator": [ + 212, + 206, + 130, + 173, + 21, + 34, + 199, + 40 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "fillerStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "orderId", + "type": { + "option": "u32" + } + }, + { + "name": "fulfillmentType", + "type": { + "option": { + "defined": { + "name": "spotFulfillmentType" + } + } + } + }, + { + "name": "makerOrderId", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "forceCancelOrders", + "discriminator": [ + 64, + 181, + 196, + 63, + 222, + 72, + 64, + 232 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "forceDeleteUser", + "discriminator": [ + 2, + 241, + 195, + 172, + 227, + 24, + 254, + 158 + ], + "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "writable": true, + "relations": [ + "user", + "userStats" + ] + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "driftSigner" + } + ], + "args": [] + }, + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 114, + 105, + 102, + 116, + 95, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "quoteAssetMint" + }, + { + "name": "driftSigner" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [] + }, + { + "name": "initializeAmmCache", + "discriminator": [ + 38, + 60, + 171, + 158, + 203, + 58, + 137, + 8 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initializeConstituent", + "discriminator": [ + 12, + 196, + 45, + 218, + 93, + 89, + 0, + 33 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "constituentTargetBase", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituentCorrelations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "spotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "spotMarketMint" + }, + { + "name": "constituentVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "decimals", + "type": "u8" + }, + { + "name": "maxWeightDeviation", + "type": "i64" + }, + { + "name": "swapFeeMin", + "type": "i64" + }, + { + "name": "swapFeeMax", + "type": "i64" + }, + { + "name": "maxBorrowTokenAmount", + "type": "u64" + }, + { + "name": "oracleStalenessThreshold", + "type": "u64" + }, + { + "name": "costToTrade", + "type": "i32" + }, + { + "name": "constituentDerivativeIndex", + "type": { + "option": "i16" + } + }, + { + "name": "constituentDerivativeDepegThreshold", + "type": "u64" + }, + { + "name": "derivativeWeight", + "type": "u64" + }, + { + "name": "volatility", + "type": "u64" + }, + { + "name": "gammaExecution", + "type": "u8" + }, + { + "name": "gammaInventory", + "type": "u8" + }, + { + "name": "xi", + "type": "u8" + }, + { + "name": "newConstituentCorrelations", + "type": { + "vec": "i64" + } + } + ] + }, + { + "name": "initializeFuelOverflow", + "discriminator": [ + 88, + 223, + 132, + 161, + 208, + 88, + 142, + 42 + ], + "accounts": [ + { + "name": "fuelOverflow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 117, + 101, + 108, + 95, + 111, + 118, + 101, + 114, + 102, + 108, + 111, + 119 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "relations": [ + "userStats" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initializeHighLeverageModeConfig", + "discriminator": [ + 213, + 167, + 93, + 246, + 208, + 130, + 90, + 248 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "highLeverageModeConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + } + ] + }, + { + "name": "initializeIfRebalanceConfig", + "discriminator": [ + 8, + 85, + 184, + 167, + 176, + 61, + 173, + 226 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "ifRebalanceConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 102, + 95, + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "arg", + "path": "params.in_market_index" + }, + { + "kind": "arg", + "path": "params.out_market_index" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ifRebalanceConfigParams" + } + } + } + ] + }, + { + "name": "initializeInsuranceFundStake", + "discriminator": [ + 187, + 179, + 243, + 70, + 248, + 90, + 92, + 147 + ], + "accounts": [ + { + "name": "spotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state" + }, + { + "name": "authority", + "signer": true, + "relations": [ + "userStats" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "initializeLpPool", + "discriminator": [ + 242, + 64, + 1, + 222, + 142, + 46, + 204, + 227 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 112, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "arg", + "path": "id" + } + ] + } + }, + { + "name": "mint" + }, + { + "name": "lpPoolTokenVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "ammConstituentMapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituentTargetBase", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituentCorrelations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "lpPoolId", + "type": "u8" + }, + { + "name": "minMintFee", + "type": "i64" + }, + { + "name": "maxAum", + "type": "u128" + }, + { + "name": "maxSettleQuoteAmountPerMarket", + "type": "u64" + }, + { + "name": "whitelistMint", + "type": "pubkey" + } + ] + }, + { + "name": "initializeOpenbookV2FulfillmentConfig", + "discriminator": [ + 7, + 221, + 103, + 153, + 107, + 57, + 27, + 197 + ], + "accounts": [ + { + "name": "baseSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "quoteSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "openbookV2Program" + }, + { + "name": "openbookV2Market" + }, + { + "name": "driftSigner" + }, + { + "name": "openbookV2FulfillmentConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 112, + 101, + 110, + 98, + 111, + 111, + 107, + 95, + 118, + 50, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "openbookV2Market" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "initializePerpMarket", + "discriminator": [ + 132, + 9, + 229, + 118, + 117, + 118, + 117, + 62 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "perpMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 101, + 114, + 112, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_markets", + "account": "state" + } + ] + } + }, + { + "name": "oracle" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "ammBaseAssetReserve", + "type": "u128" + }, + { + "name": "ammQuoteAssetReserve", + "type": "u128" + }, + { + "name": "ammPeriodicity", + "type": "i64" + }, + { + "name": "ammPegMultiplier", + "type": "u128" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "contractTier", + "type": { + "defined": { + "name": "contractTier" + } + } + }, + { + "name": "marginRatioInitial", + "type": "u32" + }, + { + "name": "marginRatioMaintenance", + "type": "u32" + }, + { + "name": "liquidatorFee", + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "type": "u32" + }, + { + "name": "imfFactor", + "type": "u32" + }, + { + "name": "activeStatus", + "type": "bool" + }, + { + "name": "baseSpread", + "type": "u32" + }, + { + "name": "maxSpread", + "type": "u32" + }, + { + "name": "maxOpenInterest", + "type": "u128" + }, + { + "name": "maxRevenueWithdrawPerPeriod", + "type": "u64" + }, + { + "name": "quoteMaxInsurance", + "type": "u64" + }, + { + "name": "orderStepSize", + "type": "u64" + }, + { + "name": "orderTickSize", + "type": "u64" + }, + { + "name": "minOrderSize", + "type": "u64" + }, + { + "name": "concentrationCoefScale", + "type": "u128" + }, + { + "name": "curveUpdateIntensity", + "type": "u8" + }, + { + "name": "ammJitIntensity", + "type": "u8" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "lpPoolId", + "type": "u8" + } + ] + }, + { + "name": "initializePhoenixFulfillmentConfig", + "discriminator": [ + 135, + 132, + 110, + 107, + 185, + 160, + 169, + 154 + ], + "accounts": [ + { + "name": "baseSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "quoteSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "phoenixProgram" + }, + { + "name": "phoenixMarket" + }, + { + "name": "driftSigner" + }, + { + "name": "phoenixFulfillmentConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 104, + 111, + 101, + 110, + 105, + 120, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "phoenixMarket" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "initializePredictionMarket", + "discriminator": [ + 248, + 70, + 198, + 224, + 224, + 105, + 125, + 195 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [] + }, + { + "name": "initializePrelaunchOracle", + "discriminator": [ + 169, + 178, + 84, + 25, + 175, + 62, + 29, + 247 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "prelaunchOracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "params.perp_market_index" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "prelaunchOracleParams" + } + } + } + ] + }, + { + "name": "initializeProtectedMakerModeConfig", + "discriminator": [ + 67, + 103, + 220, + 67, + 88, + 32, + 252, + 8 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "protectedMakerModeConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + } + ] + }, + { + "name": "initializePythLazerOracle", + "discriminator": [ + 140, + 107, + 33, + 214, + 235, + 219, + 103, + 20 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lazerOracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 108, + 97, + 122, + 101, + 114 + ] + }, + { + "kind": "arg", + "path": "feedId" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "feedId", + "type": "u32" + } + ] + }, + { + "name": "initializePythPullOracle", + "discriminator": [ + 249, + 140, + 253, + 243, + 248, + 74, + 240, + 238 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "pythSolanaReceiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "priceFeed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feedId" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "feedId", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "initializeReferrerName", + "discriminator": [ + 235, + 126, + 231, + 10, + 42, + 164, + 26, + 61 + ], + "accounts": [ + { + "name": "referrerName", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 102, + 101, + 114, + 114, + 101, + 114, + 95, + 110, + 97, + 109, + 101 + ] + }, + { + "kind": "arg", + "path": "name" + } + ] + } + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "initializeRevenueShare", + "discriminator": [ + 57, + 9, + 123, + 131, + 82, + 52, + 50, + 13 + ], + "accounts": [ + { + "name": "revenueShare", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 83, + 72, + 65, + 82, + 69 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority" + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initializeRevenueShareEscrow", + "discriminator": [ + 187, + 18, + 123, + 88, + 238, + 104, + 84, + 154 + ], + "accounts": [ + { + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "relations": [ + "userStats" + ] + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state" + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "numOrders", + "type": "u16" + } + ] + }, + { + "name": "initializeSerumFulfillmentConfig", + "discriminator": [ + 193, + 211, + 132, + 172, + 70, + 171, + 7, + 94 + ], + "accounts": [ + { + "name": "baseSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "quoteSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "serumProgram" + }, + { + "name": "serumMarket" + }, + { + "name": "serumOpenOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 114, + 117, + 109, + 95, + 111, + 112, + 101, + 110, + 95, + 111, + 114, + 100, + 101, + 114, + 115 + ] + }, + { + "kind": "account", + "path": "serumMarket" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "serumFulfillmentConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 114, + 117, + 109, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "serumMarket" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "initializeSignedMsgUserOrders", + "discriminator": [ + 164, + 99, + 156, + 126, + 156, + 57, + 99, + 180 + ], + "accounts": [ + { + "name": "signedMsgUserOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority" + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "numOrders", + "type": "u16" + } + ] + }, + { + "name": "initializeSignedMsgWsDelegates", + "discriminator": [ + 40, + 132, + 96, + 219, + 184, + 193, + 80, + 8 + ], + "accounts": [ + { + "name": "signedMsgWsDelegates", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71, + 95, + 87, + 83 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "delegates", + "type": { + "vec": "pubkey" + } + } + ] + }, + { + "name": "initializeSpotMarket", + "discriminator": [ + 234, + 196, + 128, + 44, + 94, + 15, + 48, + 201 + ], + "accounts": [ + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "state" + } + ] + } + }, + { + "name": "spotMarketMint" + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "state" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "state" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "state", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "optimalUtilization", + "type": "u32" + }, + { + "name": "optimalBorrowRate", + "type": "u32" + }, + { + "name": "maxBorrowRate", + "type": "u32" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "initialAssetWeight", + "type": "u32" + }, + { + "name": "maintenanceAssetWeight", + "type": "u32" + }, + { + "name": "initialLiabilityWeight", + "type": "u32" + }, + { + "name": "maintenanceLiabilityWeight", + "type": "u32" + }, + { + "name": "imfFactor", + "type": "u32" + }, + { + "name": "liquidatorFee", + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "type": "u32" + }, + { + "name": "activeStatus", + "type": "bool" + }, + { + "name": "assetTier", + "type": { + "defined": { + "name": "assetTier" + } + } + }, + { + "name": "scaleInitialAssetWeightStart", + "type": "u64" + }, + { + "name": "withdrawGuardThreshold", + "type": "u64" + }, + { + "name": "orderTickSize", + "type": "u64" + }, + { + "name": "orderStepSize", + "type": "u64" + }, + { + "name": "ifTotalFactor", + "type": "u32" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "initializeUser", + "discriminator": [ + 111, + 17, + 185, + 250, + 60, + 122, + 38, + 254 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "userStats" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "initializeUserStats", + "discriminator": [ + 254, + 243, + 72, + 98, + 251, + 130, + 168, + 213 + ], + "accounts": [ + { + "name": "userStats", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114, + 95, + 115, + 116, + 97, + 116, + 115 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "liquidateBorrowForPerpPnl", + "discriminator": [ + 169, + 17, + 32, + 90, + 207, + 148, + 209, + 27 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "liquidatorMaxLiabilityTransfer", + "type": "u128" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "liquidatePerp", + "discriminator": [ + 75, + 35, + 119, + 247, + 191, + 18, + 139, + 2 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "liquidatorMaxBaseAssetAmount", + "type": "u64" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "liquidatePerpPnlForDeposit", + "discriminator": [ + 237, + 75, + 198, + 235, + 233, + 186, + 75, + 35 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "liquidatorMaxPnlTransfer", + "type": "u128" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "liquidatePerpWithFill", + "discriminator": [ + 95, + 111, + 124, + 105, + 86, + 169, + 187, + 34 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "liquidateSpot", + "discriminator": [ + 107, + 0, + 128, + 41, + 35, + 229, + 251, + 18 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + }, + { + "name": "liquidatorMaxLiabilityTransfer", + "type": "u128" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "liquidateSpotWithSwapBegin", + "discriminator": [ + 12, + 43, + 176, + 83, + 156, + 251, + 117, + 13 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "liabilitySpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "liabilityMarketIndex" + } + ] + } + }, + { + "name": "assetSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "assetMarketIndex" + } + ] + } + }, + { + "name": "liabilityTokenAccount", + "writable": true + }, + { + "name": "assetTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + }, + { + "name": "swapAmount", + "type": "u64" + } + ] + }, + { + "name": "liquidateSpotWithSwapEnd", + "discriminator": [ + 142, + 88, + 163, + 160, + 223, + 75, + 55, + 225 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "liabilitySpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "liabilityMarketIndex" + } + ] + } + }, + { + "name": "assetSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "assetMarketIndex" + } + ] + } + }, + { + "name": "liabilityTokenAccount", + "writable": true + }, + { + "name": "assetTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "logUserBalances", + "discriminator": [ + 162, + 21, + 35, + 251, + 32, + 57, + 161, + 210 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "lpPoolAddLiquidity", + "discriminator": [ + 49, + 135, + 246, + 103, + 93, + 146, + 220, + 141 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "inMarketMint" + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "userInTokenAccount", + "writable": true + }, + { + "name": "constituentInTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "userLpTokenAccount", + "writable": true + }, + { + "name": "lpMint", + "writable": true + }, + { + "name": "constituentTargetBase" + }, + { + "name": "lpPoolTokenVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u128" + }, + { + "name": "minMintAmount", + "type": "u64" + } + ] + }, + { + "name": "lpPoolRemoveLiquidity", + "discriminator": [ + 164, + 36, + 193, + 252, + 196, + 157, + 138, + 43 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "driftSigner" + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "outMarketMint" + }, + { + "name": "outConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "userOutTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "userLpTokenAccount", + "writable": true + }, + { + "name": "spotMarketTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "lpMint", + "writable": true + }, + { + "name": "constituentTargetBase" + }, + { + "name": "lpPoolTokenVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "tokenProgram" + }, + { + "name": "ammCache", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u64" + }, + { + "name": "minOutAmount", + "type": "u128" + } + ] + }, + { + "name": "lpPoolSwap", + "discriminator": [ + 36, + 161, + 39, + 49, + 227, + 1, + 35, + 226 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool" + }, + { + "name": "constituentTargetBase" + }, + { + "name": "constituentCorrelations" + }, + { + "name": "constituentInTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "writable": true + }, + { + "name": "userInTokenAccount", + "writable": true + }, + { + "name": "userOutTokenAccount", + "writable": true + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inMarketMint" + }, + { + "name": "outMarketMint" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u64" + }, + { + "name": "minOutAmount", + "type": "u64" + } + ] + }, + { + "name": "modifyOrder", + "discriminator": [ + 47, + 124, + 117, + 255, + 201, + 197, + 130, + 94 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "orderId", + "type": { + "option": "u32" + } + }, + { + "name": "modifyOrderParams", + "type": { + "defined": { + "name": "modifyOrderParams" + } + } + } + ] + }, + { + "name": "modifyOrderByUserId", + "discriminator": [ + 158, + 77, + 4, + 253, + 252, + 194, + 161, + 179 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "userOrderId", + "type": "u8" + }, + { + "name": "modifyOrderParams", + "type": { + "defined": { + "name": "modifyOrderParams" + } + } + } + ] + }, + { + "name": "moveAmmPrice", + "discriminator": [ + 235, + 109, + 2, + 82, + 219, + 118, + 6, + 159 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "baseAssetReserve", + "type": "u128" + }, + { + "name": "quoteAssetReserve", + "type": "u128" + }, + { + "name": "sqrtK", + "type": "u128" + } + ] + }, + { + "name": "openbookV2FulfillmentConfigStatus", + "discriminator": [ + 25, + 173, + 19, + 189, + 4, + 211, + 64, + 238 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "openbookV2FulfillmentConfig", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + } + ] + }, + { + "name": "overrideAmmCacheInfo", + "discriminator": [ + 189, + 198, + 128, + 9, + 49, + 145, + 201, + 115 + ], + "accounts": [ + { + "name": "state", + "writable": true + }, + { + "name": "admin", + "signer": true + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "overrideParams", + "type": { + "defined": { + "name": "overrideAmmCacheParams" + } + } + } + ] + }, + { + "name": "pauseSpotMarketDepositWithdraw", + "discriminator": [ + 183, + 119, + 59, + 170, + 137, + 35, + 242, + 86 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "keeper", + "signer": true + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spotMarket" + } + ] + } + } + ], + "args": [] + }, + { + "name": "phoenixFulfillmentConfigStatus", + "discriminator": [ + 96, + 31, + 113, + 32, + 12, + 203, + 7, + 154 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "phoenixFulfillmentConfig", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + } + ] + }, + { + "name": "placeAndMakePerpOrder", + "discriminator": [ + 149, + 117, + 11, + 237, + 47, + 95, + 89, + 237 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "taker", + "writable": true + }, + { + "name": "takerStats", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "takerOrderId", + "type": "u32" + } + ] + }, + { + "name": "placeAndMakeSignedMsgPerpOrder", + "discriminator": [ + 16, + 26, + 123, + 131, + 94, + 29, + 175, + 98 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "taker", + "writable": true + }, + { + "name": "takerStats", + "writable": true + }, + { + "name": "takerSignedMsgUserOrders", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "taker" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "signedMsgOrderUuid", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + }, + { + "name": "placeAndMakeSpotOrder", + "discriminator": [ + 149, + 158, + 85, + 66, + 239, + 9, + 243, + 98 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "taker", + "writable": true + }, + { + "name": "takerStats", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "takerOrderId", + "type": "u32" + }, + { + "name": "fulfillmentType", + "type": { + "option": { + "defined": { + "name": "spotFulfillmentType" + } + } + } + } + ] + }, + { + "name": "placeAndTakePerpOrder", + "discriminator": [ + 213, + 51, + 1, + 187, + 108, + 220, + 230, + 224 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "successCondition", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "placeAndTakeSpotOrder", + "discriminator": [ + 191, + 3, + 138, + 71, + 114, + 198, + 202, + 100 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "fulfillmentType", + "type": { + "option": { + "defined": { + "name": "spotFulfillmentType" + } + } + } + }, + { + "name": "makerOrderId", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "placeOrders", + "discriminator": [ + 60, + 63, + 50, + 123, + 12, + 197, + 60, + 190 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "vec": { + "defined": { + "name": "orderParams" + } + } + } + } + ] + }, + { + "name": "placePerpOrder", + "discriminator": [ + 69, + 161, + 93, + 202, + 120, + 126, + 76, + 185 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + } + ] + }, + { + "name": "placeSignedMsgTakerOrder", + "discriminator": [ + 32, + 79, + 101, + 139, + 25, + 6, + 98, + 15 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "signedMsgUserOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "user" + } + ] + } + }, + { + "name": "authority", + "signer": true + }, + { + "name": "ixSysvar", + "docs": [ + "the supplied Sysvar could be anything else.", + "The Instruction Sysvar has not been implemented", + "in the Anchor framework yet, so this is the safe approach." + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "signedMsgOrderParamsMessageBytes", + "type": "bytes" + }, + { + "name": "isDelegateSigner", + "type": "bool" + } + ] + }, + { + "name": "placeSpotOrder", + "discriminator": [ + 45, + 79, + 81, + 160, + 248, + 90, + 91, + 220 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + } + ] + }, + { + "name": "postMultiPythPullOracleUpdatesAtomic", + "discriminator": [ + 243, + 79, + 204, + 228, + 227, + 208, + 100, + 244 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "pythSolanaReceiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "guardianSet" + } + ], + "args": [ + { + "name": "params", + "type": "bytes" + } + ] + }, + { + "name": "postPythLazerOracleUpdate", + "discriminator": [ + 218, + 237, + 170, + 245, + 39, + 143, + 166, + 33 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "pythLazerStorage", + "address": "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL" + }, + { + "name": "ixSysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "pythMessage", + "type": "bytes" + } + ] + }, + { + "name": "postPythPullOracleUpdateAtomic", + "discriminator": [ + 116, + 122, + 137, + 158, + 224, + 195, + 173, + 119 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "pythSolanaReceiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "guardianSet" + }, + { + "name": "priceFeed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feedId" + } + ] + } + } + ], + "args": [ + { + "name": "feedId", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "params", + "type": "bytes" + } + ] + }, + { + "name": "recenterPerpMarketAmm", + "discriminator": [ + 24, + 87, + 10, + 115, + 165, + 190, + 80, + 139 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "pegMultiplier", + "type": "u128" + }, + { + "name": "sqrtK", + "type": "u128" + } + ] + }, + { + "name": "recenterPerpMarketAmmCrank", + "discriminator": [ + 166, + 19, + 64, + 10, + 14, + 51, + 101, + 122 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "spotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "perpMarket" + } + ] + } + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "depth", + "type": { + "option": "u128" + } + } + ] + }, + { + "name": "reclaimRent", + "discriminator": [ + 218, + 200, + 19, + 197, + 227, + 89, + 192, + 22 + ], + "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state" + }, + { + "name": "authority", + "signer": true, + "relations": [ + "user", + "userStats" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "removeAmmConstituentMappingData", + "discriminator": [ + 20, + 183, + 211, + 162, + 16, + 52, + 229, + 115 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool" + }, + { + "name": "ammConstituentMapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + } + ] + }, + { + "name": "removeInsuranceFundStake", + "discriminator": [ + 128, + 166, + 142, + 9, + 254, + 187, + 143, + 174 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insuranceFundStake", + "userStats" + ] + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "repegAmmCurve", + "discriminator": [ + 3, + 36, + 102, + 89, + 180, + 128, + 120, + 213 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ + { + "name": "newPegCandidate", + "type": "u128" + } + ] + }, + { + "name": "requestRemoveInsuranceFundStake", + "discriminator": [ + 142, + 70, + 204, + 92, + 73, + 106, + 180, + 52 + ], + "accounts": [ + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insuranceFundStake", + "userStats" + ] + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "resetFuelSeason", + "discriminator": [ + 199, + 122, + 192, + 255, + 32, + 99, + 63, + 200 + ], + "accounts": [ + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "relations": [ + "userStats" + ] + }, + { + "name": "state" + }, + { + "name": "admin", + "signer": true + } + ], + "args": [] + }, + { + "name": "resetPerpMarketAmmOracleTwap", + "discriminator": [ + 127, + 10, + 55, + 164, + 123, + 226, + 47, + 24 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [] + }, + { + "name": "resizeRevenueShareEscrowOrders", + "discriminator": [ + 32, + 124, + 247, + 225, + 151, + 213, + 225, + 38 + ], + "accounts": [ + { + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "relations": [ + "escrow" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "numOrders", + "type": "u16" + } + ] + }, + { + "name": "resizeSignedMsgUserOrders", + "discriminator": [ + 137, + 10, + 87, + 150, + 18, + 115, + 79, + 168 + ], + "accounts": [ + { + "name": "signedMsgUserOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "relations": [ + "user" + ] + }, + { + "name": "user" + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "numOrders", + "type": "u16" + } + ] + }, + { + "name": "resolvePerpBankruptcy", + "discriminator": [ + 224, + 16, + 176, + 214, + 162, + 213, + 183, + 222 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "quoteSpotMarketIndex", + "type": "u16" + }, + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "resolvePerpPnlDeficit", + "discriminator": [ + 168, + 204, + 68, + 150, + 159, + 126, + 95, + 148 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "perpMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "resolveSpotBankruptcy", + "discriminator": [ + 124, + 194, + 240, + 254, + 198, + 213, + 52, + 122 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "revertFill", + "discriminator": [ + 236, + 238, + 176, + 69, + 239, + 10, + 181, + 193 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "fillerStats", + "writable": true + } + ], + "args": [] + }, + { + "name": "setUserStatusToBeingLiquidated", + "discriminator": [ + 106, + 133, + 160, + 206, + 193, + 171, + 192, + 194 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [] + }, + { + "name": "settleExpiredMarket", + "discriminator": [ + 120, + 89, + 11, + 25, + 122, + 77, + 72, + 193 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "settleExpiredMarketPoolsToRevenuePool", + "discriminator": [ + 55, + 19, + 238, + 169, + 227, + 90, + 200, + 184 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [] + }, + { + "name": "settleFundingPayment", + "discriminator": [ + 222, + 90, + 202, + 94, + 28, + 45, + 115, + 183 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "settleMultiplePnls", + "discriminator": [ + 127, + 66, + 117, + 57, + 40, + 50, + 152, + 127 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [ + { + "name": "marketIndexes", + "type": { + "vec": "u16" + } + }, + { + "name": "mode", + "type": { + "defined": { + "name": "settlePnlMode" + } + } + } + ] + }, + { + "name": "settlePerpToLpPool", + "discriminator": [ + 5, + 98, + 46, + 188, + 10, + 59, + 2, + 249 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "ammCache", + "writable": true + }, + { + "name": "quoteMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "constituentQuoteTokenAccount", + "writable": true + }, + { + "name": "quoteTokenVault", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + } + ], + "args": [] + }, + { + "name": "settlePnl", + "discriminator": [ + 43, + 61, + 234, + 45, + 15, + 95, + 152, + 153 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "settleRevenueToInsuranceFund", + "discriminator": [ + 200, + 120, + 93, + 136, + 69, + 38, + 199, + 159 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "spotMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "sweepFuel", + "discriminator": [ + 175, + 107, + 19, + 56, + 165, + 241, + 43, + 69 + ], + "accounts": [ + { + "name": "fuelOverflow", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "relations": [ + "fuelOverflow", + "userStats" + ] + }, + { + "name": "signer", + "signer": true + } + ], + "args": [] + }, + { + "name": "transferDeposit", + "discriminator": [ + 20, + 20, + 147, + 223, + 41, + 63, + 204, + 111 + ], + "accounts": [ + { + "name": "fromUser", + "writable": true + }, + { + "name": "toUser", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "fromUser", + "toUser", + "userStats" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "transferPerpPosition", + "discriminator": [ + 23, + 172, + 188, + 168, + 134, + 210, + 3, + 108 + ], + "accounts": [ + { + "name": "fromUser", + "writable": true + }, + { + "name": "toUser", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": { + "option": "i64" + } + } + ] + }, + { + "name": "transferPools", + "discriminator": [ + 197, + 103, + 154, + 25, + 107, + 90, + 60, + 94 + ], + "accounts": [ + { + "name": "fromUser", + "writable": true + }, + { + "name": "toUser", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "fromUser", + "toUser", + "userStats" + ] + }, + { + "name": "state" + }, + { + "name": "depositFromSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "depositFromMarketIndex" + } + ] + } + }, + { + "name": "depositToSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "depositToMarketIndex" + } + ] + } + }, + { + "name": "borrowFromSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "borrowFromMarketIndex" + } + ] + } + }, + { + "name": "borrowToSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "borrowToMarketIndex" + } + ] + } + }, + { + "name": "driftSigner" + } + ], + "args": [ + { + "name": "depositFromMarketIndex", + "type": "u16" + }, + { + "name": "depositToMarketIndex", + "type": "u16" + }, + { + "name": "borrowFromMarketIndex", + "type": "u16" + }, + { + "name": "borrowToMarketIndex", + "type": "u16" + }, + { + "name": "depositAmount", + "type": { + "option": "u64" + } + }, + { + "name": "borrowAmount", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "transferProtocolIfSharesToRevenuePool", + "discriminator": [ + 236, + 136, + 147, + 153, + 146, + 205, + 104, + 29 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "ifRebalanceConfig", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "triggerOrder", + "discriminator": [ + 63, + 112, + 51, + 233, + 232, + 47, + 240, + 199 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "user", + "writable": true + } + ], + "args": [ + { + "name": "orderId", + "type": "u32" + } + ] + }, + { + "name": "updateAdmin", + "discriminator": [ + 161, + 176, + 40, + 213, + 60, + 184, + 179, + 228 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "admin", + "type": "pubkey" + } + ] + }, + { + "name": "updateAmmCache", + "discriminator": [ + 88, + 4, + 63, + 94, + 83, + 224, + 255, + 130 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "ammCache", + "writable": true + }, + { + "name": "quoteMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateAmmConstituentMappingData", + "discriminator": [ + 84, + 70, + 33, + 167, + 133, + 107, + 59, + 24 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool" + }, + { + "name": "ammConstituentMapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "ammConstituentMappingData", + "type": { + "vec": { + "defined": { + "name": "addAmmConstituentMappingDatum" + } + } + } + } + ] + }, + { + "name": "updateAmmJitIntensity", + "discriminator": [ + 181, + 191, + 53, + 109, + 166, + 249, + 55, + 142 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "ammJitIntensity", + "type": "u8" + } + ] + }, + { + "name": "updateAmms", + "discriminator": [ + 201, + 106, + 217, + 253, + 4, + 175, + 228, + 97 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "marketIndexes", + "type": { + "vec": "u16" + } + } + ] + }, + { + "name": "updateConstituentCorrelationData", + "discriminator": [ + 79, + 14, + 19, + 73, + 221, + 106, + 62, + 109 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool" + }, + { + "name": "constituentCorrelations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "index1", + "type": "u16" + }, + { + "name": "index2", + "type": "u16" + }, + { + "name": "correlation", + "type": "i64" + } + ] + }, + { + "name": "updateConstituentOracleInfo", + "discriminator": [ + 198, + 117, + 231, + 250, + 147, + 33, + 127, + 161 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "constituent", + "writable": true + }, + { + "name": "spotMarket" + }, + { + "name": "oracle" + } + ], + "args": [] + }, + { + "name": "updateConstituentParams", + "discriminator": [ + 238, + 130, + 122, + 31, + 12, + 104, + 192, + 122 + ], + "accounts": [ + { + "name": "lpPool" + }, + { + "name": "constituentTargetBase", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "constituent", + "writable": true + } + ], + "args": [ + { + "name": "constituentParams", + "type": { + "defined": { + "name": "constituentParams" + } + } + } + ] + }, + { + "name": "updateConstituentPausedOperations", + "discriminator": [ + 185, + 122, + 153, + 191, + 131, + 177, + 132, + 208 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "constituent", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updateConstituentStatus", + "discriminator": [ + 76, + 159, + 211, + 239, + 182, + 214, + 6, + 15 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "constituent", + "writable": true + } + ], + "args": [ + { + "name": "newStatus", + "type": "u8" + } + ] + }, + { + "name": "updateDelegateUserGovTokenInsuranceStake", + "discriminator": [ + 241, + 29, + 215, + 228, + 142, + 116, + 22, + 160 + ], + "accounts": [ + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } + }, + { + "name": "insuranceFundStake" + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } + }, + { + "name": "state" + } + ], + "args": [] + }, + { + "name": "updateDiscountMint", + "discriminator": [ + 32, + 252, + 122, + 211, + 66, + 31, + 47, + 241 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "discountMint", + "type": "pubkey" + } + ] + }, + { + "name": "updateExchangeStatus", + "discriminator": [ + 83, + 160, + 252, + 250, + 129, + 116, + 49, + 223 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "exchangeStatus", + "type": "u8" + } + ] + }, + { + "name": "updateFeatureBitFlagsBuilderCodes", + "discriminator": [ + 1, + 128, + 177, + 51, + 173, + 45, + 11, + 102 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsMedianTriggerPrice", + "discriminator": [ + 64, + 185, + 221, + 45, + 87, + 147, + 12, + 19 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsMintRedeemLpPool", + "discriminator": [ + 26, + 11, + 142, + 122, + 206, + 159, + 9, + 45 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsMmOracle", + "discriminator": [ + 218, + 134, + 33, + 186, + 231, + 59, + 130, + 149 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsSettleLpPool", + "discriminator": [ + 186, + 28, + 78, + 230, + 155, + 83, + 242, + 26 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsSwapLpPool", + "discriminator": [ + 83, + 16, + 150, + 12, + 102, + 3, + 22, + 58 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFundingRate", + "discriminator": [ + 201, + 178, + 116, + 212, + 166, + 144, + 72, + 238 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "updateHighLeverageModeConfig", + "discriminator": [ + 64, + 122, + 212, + 93, + 141, + 217, + 202, + 55 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "highLeverageModeConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "bool" + }, + { + "name": "currentUsers", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "updateIfRebalanceConfig", + "discriminator": [ + 142, + 245, + 249, + 66, + 249, + 181, + 22, + 83 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "ifRebalanceConfig", + "writable": true + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ifRebalanceConfigParams" + } + } + } + ] + }, + { + "name": "updateInitialAmmCacheInfo", + "discriminator": [ + 157, + 210, + 109, + 67, + 212, + 170, + 12, + 107 + ], + "accounts": [ + { + "name": "state", + "writable": true + }, + { + "name": "admin", + "signer": true + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateInitialPctToLiquidate", + "discriminator": [ + 210, + 133, + 225, + 128, + 194, + 50, + 13, + 109 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "initialPctToLiquidate", + "type": "u16" + } + ] + }, + { + "name": "updateInsuranceFundUnstakingPeriod", + "discriminator": [ + 44, + 69, + 43, + 226, + 204, + 223, + 202, + 52 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "insuranceFundUnstakingPeriod", + "type": "i64" + } + ] + }, + { + "name": "updateK", + "discriminator": [ + 72, + 98, + 9, + 139, + 129, + 229, + 172, + 56 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "sqrtK", + "type": "u128" + } + ] + }, + { + "name": "updateLiquidationDuration", + "discriminator": [ + 28, + 154, + 20, + 249, + 102, + 192, + 73, + 71 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "liquidationDuration", + "type": "u8" + } + ] + }, + { + "name": "updateLiquidationMarginBufferRatio", + "discriminator": [ + 132, + 224, + 243, + 160, + 154, + 82, + 97, + 215 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "liquidationMarginBufferRatio", + "type": "u32" + } + ] + }, + { + "name": "updateLpConstituentTargetBase", + "discriminator": [ + 157, + 65, + 50, + 207, + 59, + 236, + 161, + 110 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "ammConstituentMapping" + }, + { + "name": "constituentTargetBase", + "writable": true + }, + { + "name": "ammCache" + }, + { + "name": "lpPool" + } + ], + "args": [] + }, + { + "name": "updateLpPoolAum", + "discriminator": [ + 88, + 113, + 137, + 206, + 246, + 247, + 171, + 142 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "constituentTargetBase", + "writable": true + }, + { + "name": "ammCache", + "writable": true + } + ], + "args": [] + }, + { + "name": "updateLpPoolParams", + "discriminator": [ + 217, + 92, + 2, + 255, + 27, + 167, + 178, + 81 + ], + "accounts": [ + { + "name": "lpPool", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "lpPoolParams", + "type": { + "defined": { + "name": "lpPoolParams" + } + } + } + ] + }, + { + "name": "updateOracleGuardRails", + "discriminator": [ + 131, + 112, + 10, + 59, + 32, + 54, + 40, + 164 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "oracleGuardRails", + "type": { + "defined": { + "name": "oracleGuardRails" + } + } + } + ] + }, + { + "name": "updatePerpAuctionDuration", + "discriminator": [ + 126, + 110, + 52, + 174, + 30, + 206, + 215, + 90 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "minPerpAuctionDuration", + "type": "u8" + } + ] + }, + { + "name": "updatePerpBidAskTwap", + "discriminator": [ + 247, + 23, + 255, + 65, + 212, + 90, + 221, + 194 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "keeperStats" + }, + { + "name": "authority", + "signer": true + } + ], + "args": [] + }, + { + "name": "updatePerpFeeStructure", + "discriminator": [ + 23, + 178, + 111, + 203, + 73, + 22, + 140, + 75 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "feeStructure", + "type": { + "defined": { + "name": "feeStructure" + } + } + } + ] + }, + { + "name": "updatePerpMarketAmmOracleTwap", + "discriminator": [ + 241, + 74, + 114, + 123, + 206, + 153, + 24, + 202 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [] + }, + { + "name": "updatePerpMarketAmmSpreadAdjustment", + "discriminator": [ + 155, + 195, + 149, + 43, + 220, + 82, + 173, + 205 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "ammSpreadAdjustment", + "type": "i8" + }, + { + "name": "ammInventorySpreadAdjustment", + "type": "i8" + }, + { + "name": "referencePriceOffset", + "type": "i32" + } + ] + }, + { + "name": "updatePerpMarketAmmSummaryStats", + "discriminator": [ + 122, + 101, + 249, + 238, + 209, + 9, + 241, + 245 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "spotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "perpMarket" + } + ] + } + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updatePerpMarketSummaryStatsParams" + } + } + } + ] + }, + { + "name": "updatePerpMarketBaseSpread", + "discriminator": [ + 71, + 95, + 84, + 168, + 9, + 157, + 198, + 65 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "baseSpread", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketConcentrationCoef", + "discriminator": [ + 24, + 78, + 232, + 126, + 169, + 176, + 230, + 16 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "concentrationScale", + "type": "u128" + } + ] + }, + { + "name": "updatePerpMarketContractTier", + "discriminator": [ + 236, + 128, + 15, + 95, + 203, + 214, + 68, + 117 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "contractTier", + "type": { + "defined": { + "name": "contractTier" + } + } + } + ] + }, + { + "name": "updatePerpMarketCurveUpdateIntensity", + "discriminator": [ + 50, + 131, + 6, + 156, + 226, + 231, + 189, + 72 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "curveUpdateIntensity", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketExpiry", + "discriminator": [ + 44, + 221, + 227, + 151, + 131, + 140, + 22, + 110 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "expiryTs", + "type": "i64" + } + ] + }, + { + "name": "updatePerpMarketFeeAdjustment", + "discriminator": [ + 194, + 174, + 87, + 102, + 43, + 148, + 32, + 112 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "feeAdjustment", + "type": "i16" + } + ] + }, + { + "name": "updatePerpMarketFundingPeriod", + "discriminator": [ + 171, + 161, + 69, + 91, + 129, + 139, + 161, + 28 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "fundingPeriod", + "type": "i64" + } + ] + }, + { + "name": "updatePerpMarketHighLeverageMarginRatio", + "discriminator": [ + 88, + 112, + 86, + 49, + 24, + 116, + 74, + 157 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "marginRatioInitial", + "type": "u16" + }, + { + "name": "marginRatioMaintenance", + "type": "u16" + } + ] + }, + { + "name": "updatePerpMarketImfFactor", + "discriminator": [ + 207, + 194, + 56, + 132, + 35, + 67, + 71, + 244 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "imfFactor", + "type": "u32" + }, + { + "name": "unrealizedPnlImfFactor", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketLiquidationFee", + "discriminator": [ + 90, + 137, + 9, + 145, + 41, + 8, + 148, + 117 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "liquidatorFee", + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketLpPoolFeeTransferScalar", + "discriminator": [ + 94, + 228, + 237, + 109, + 100, + 185, + 4, + 81 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "optionalLpFeeTransferScalar", + "type": { + "option": "u8" + } + }, + { + "name": "optionalLpNetPnlTransferScalar", + "type": { + "option": "u8" + } + } + ] + }, + { + "name": "updatePerpMarketLpPoolId", + "discriminator": [ + 119, + 208, + 154, + 88, + 165, + 92, + 21, + 188 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "lpPoolId", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketLpPoolPausedOperations", + "discriminator": [ + 181, + 94, + 93, + 146, + 51, + 89, + 32, + 135 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "lpPausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketLpPoolStatus", + "discriminator": [ + 67, + 6, + 252, + 61, + 54, + 88, + 89, + 233 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ + { + "name": "lpStatus", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketMarginRatio", + "discriminator": [ + 130, + 173, + 107, + 45, + 119, + 105, + 26, + 113 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "marginRatioInitial", + "type": "u32" + }, + { + "name": "marginRatioMaintenance", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketMaxFillReserveFraction", + "discriminator": [ + 19, + 172, + 114, + 154, + 42, + 135, + 161, + 133 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxFillReserveFraction", + "type": "u16" + } + ] + }, + { + "name": "updatePerpMarketMaxImbalances", + "discriminator": [ + 15, + 206, + 73, + 133, + 60, + 8, + 86, + 89 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "unrealizedMaxImbalance", + "type": "u64" + }, + { + "name": "maxRevenueWithdrawPerPeriod", + "type": "u64" + }, + { + "name": "quoteMaxInsurance", + "type": "u64" + } + ] + }, + { + "name": "updatePerpMarketMaxOpenInterest", + "discriminator": [ + 194, + 79, + 149, + 224, + 246, + 102, + 186, + 140 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxOpenInterest", + "type": "u128" + } + ] + }, + { + "name": "updatePerpMarketMaxSlippageRatio", + "discriminator": [ + 235, + 37, + 40, + 196, + 70, + 146, + 54, + 201 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxSlippageRatio", + "type": "u16" + } + ] + }, + { + "name": "updatePerpMarketMaxSpread", + "discriminator": [ + 80, + 252, + 122, + 62, + 40, + 218, + 91, + 100 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxSpread", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketMinOrderSize", + "discriminator": [ + 226, + 74, + 5, + 89, + 108, + 223, + 46, + 141 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "orderSize", + "type": "u64" + } + ] + }, + { + "name": "updatePerpMarketName", + "discriminator": [ + 211, + 31, + 21, + 210, + 64, + 108, + 66, + 201 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "updatePerpMarketNumberOfUsers", + "discriminator": [ + 35, + 62, + 144, + 177, + 180, + 62, + 215, + 196 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "numberOfUsers", + "type": { + "option": "u32" + } + }, + { + "name": "numberOfUsersWithBase", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "updatePerpMarketOracle", + "discriminator": [ + 182, + 113, + 111, + 160, + 67, + 174, + 89, + 191 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "oldOracle" + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "skipInvariantCheck", + "type": "bool" + } + ] + }, + { + "name": "updatePerpMarketOracleLowRiskSlotDelayOverride", + "discriminator": [ + 124, + 108, + 147, + 229, + 109, + 117, + 123, + 3 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "oracleLowRiskSlotDelayOverride", + "type": "i8" + } + ] + }, + { + "name": "updatePerpMarketOracleSlotDelayOverride", + "discriminator": [ + 165, + 91, + 239, + 227, + 63, + 172, + 227, + 8 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "oracleSlotDelayOverride", + "type": "i8" + } + ] + }, + { + "name": "updatePerpMarketPausedOperations", + "discriminator": [ + 53, + 16, + 136, + 132, + 30, + 220, + 121, + 85 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketPnlPool", + "discriminator": [ + 50, + 202, + 249, + 224, + 166, + 184, + 13, + 143 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "updatePerpMarketProtectedMakerParams", + "discriminator": [ + 249, + 213, + 115, + 34, + 253, + 239, + 75, + 173 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "protectedMakerLimitPriceDivisor", + "type": { + "option": "u8" + } + }, + { + "name": "protectedMakerDynamicDivisor", + "type": { + "option": "u8" + } + } + ] + }, + { + "name": "updatePerpMarketReferencePriceOffsetDeadbandPct", + "discriminator": [ + 214, + 73, + 166, + 11, + 218, + 76, + 110, + 163 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "referencePriceOffsetDeadbandPct", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketStatus", + "discriminator": [ + 71, + 201, + 175, + 122, + 255, + 207, + 196, + 207 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "marketStatus" + } + } + } + ] + }, + { + "name": "updatePerpMarketStepSizeAndTickSize", + "discriminator": [ + 231, + 255, + 97, + 25, + 146, + 139, + 174, + 4 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "stepSize", + "type": "u64" + }, + { + "name": "tickSize", + "type": "u64" + } + ] + }, + { + "name": "updatePerpMarketUnrealizedAssetWeight", + "discriminator": [ + 135, + 132, + 205, + 165, + 109, + 150, + 166, + 106 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "unrealizedInitialAssetWeight", + "type": "u32" + }, + { + "name": "unrealizedMaintenanceAssetWeight", + "type": "u32" + } + ] + }, + { + "name": "updatePrelaunchOracle", + "discriminator": [ + 220, + 132, + 27, + 27, + 233, + 220, + 61, + 219 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket" + }, + { + "name": "oracle", + "writable": true + } + ], + "args": [] + }, + { + "name": "updatePrelaunchOracleParams", + "discriminator": [ + 98, + 205, + 147, + 243, + 18, + 75, + 83, + 207 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "prelaunchOracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "params.perp_market_index" + } + ] + } + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "prelaunchOracleParams" + } + } + } + ] + }, + { + "name": "updateProtectedMakerModeConfig", + "discriminator": [ + 86, + 166, + 235, + 253, + 67, + 202, + 223, + 17 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "protectedMakerModeConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "bool" + }, + { + "name": "currentUsers", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "updatePythPullOracle", + "discriminator": [ + 230, + 191, + 189, + 94, + 108, + 59, + 74, + 197 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "pythSolanaReceiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "encodedVaa" + }, + { + "name": "priceFeed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feedId" + } + ] + } + } + ], + "args": [ + { + "name": "feedId", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "params", + "type": "bytes" + } + ] + }, + { + "name": "updateSerumFulfillmentConfigStatus", + "discriminator": [ + 171, + 109, + 240, + 251, + 95, + 1, + 149, + 89 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "serumFulfillmentConfig", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + } + ] + }, + { + "name": "updateSpotAuctionDuration", + "discriminator": [ + 182, + 178, + 203, + 72, + 187, + 143, + 157, + 107 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "defaultSpotAuctionDuration", + "type": "u8" + } + ] + }, + { + "name": "updateSpotFeeStructure", + "discriminator": [ + 97, + 216, + 105, + 131, + 113, + 246, + 142, + 141 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "feeStructure", + "type": { + "defined": { + "name": "feeStructure" + } + } + } + ] + }, + { + "name": "updateSpotMarketAssetTier", + "discriminator": [ + 253, + 209, + 231, + 14, + 242, + 208, + 243, + 130 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "assetTier", + "type": { + "defined": { + "name": "assetTier" + } + } + } + ] + }, + { + "name": "updateSpotMarketBorrowRate", + "discriminator": [ + 71, + 239, + 236, + 153, + 210, + 62, + 254, + 76 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "optimalUtilization", + "type": "u32" + }, + { + "name": "optimalBorrowRate", + "type": "u32" + }, + { + "name": "maxBorrowRate", + "type": "u32" + }, + { + "name": "minBorrowRate", + "type": { + "option": "u8" + } + } + ] + }, + { + "name": "updateSpotMarketCumulativeInterest", + "discriminator": [ + 39, + 166, + 139, + 243, + 158, + 165, + 155, + 225 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spotMarket" + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateSpotMarketExpiry", + "discriminator": [ + 208, + 11, + 211, + 159, + 226, + 24, + 11, + 247 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "expiryTs", + "type": "i64" + } + ] + }, + { + "name": "updateSpotMarketFeeAdjustment", + "discriminator": [ + 148, + 182, + 3, + 126, + 157, + 114, + 220, + 99 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "feeAdjustment", + "type": "i16" + } + ] + }, + { + "name": "updateSpotMarketIfFactor", + "discriminator": [ + 147, + 30, + 224, + 34, + 18, + 230, + 105, + 4 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "userIfFactor", + "type": "u32" + }, + { + "name": "totalIfFactor", + "type": "u32" + } + ] + }, + { + "name": "updateSpotMarketIfPausedOperations", + "discriminator": [ + 101, + 215, + 79, + 74, + 59, + 41, + 79, + 12 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updateSpotMarketLiquidationFee", + "discriminator": [ + 11, + 13, + 255, + 53, + 56, + 136, + 104, + 177 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "liquidatorFee", + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "type": "u32" + } + ] + }, + { + "name": "updateSpotMarketMarginWeights", + "discriminator": [ + 109, + 33, + 87, + 195, + 255, + 36, + 6, + 81 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "initialAssetWeight", + "type": "u32" + }, + { + "name": "maintenanceAssetWeight", + "type": "u32" + }, + { + "name": "initialLiabilityWeight", + "type": "u32" + }, + { + "name": "maintenanceLiabilityWeight", + "type": "u32" + }, + { + "name": "imfFactor", + "type": "u32" + } + ] + }, + { + "name": "updateSpotMarketMaxTokenBorrows", + "discriminator": [ + 57, + 102, + 204, + 212, + 253, + 95, + 13, + 199 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxTokenBorrowsFraction", + "type": "u16" + } + ] + }, + { + "name": "updateSpotMarketMaxTokenDeposits", + "discriminator": [ + 56, + 191, + 79, + 18, + 26, + 121, + 80, + 208 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxTokenDeposits", + "type": "u64" + } + ] + }, + { + "name": "updateSpotMarketMinOrderSize", + "discriminator": [ + 93, + 128, + 11, + 119, + 26, + 20, + 181, + 50 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "orderSize", + "type": "u64" + } + ] + }, + { + "name": "updateSpotMarketName", + "discriminator": [ + 17, + 208, + 1, + 1, + 162, + 211, + 188, + 224 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "updateSpotMarketOracle", + "discriminator": [ + 114, + 184, + 102, + 37, + 246, + 186, + 180, + 99 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "oldOracle" + } + ], + "args": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "skipInvariantCheck", + "type": "bool" + } + ] + }, + { + "name": "updateSpotMarketOrdersEnabled", + "discriminator": [ + 190, + 79, + 206, + 15, + 26, + 229, + 229, + 43 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "ordersEnabled", + "type": "bool" + } + ] + }, + { + "name": "updateSpotMarketPausedOperations", + "discriminator": [ + 100, + 61, + 153, + 81, + 180, + 12, + 6, + 248 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updateSpotMarketPoolId", + "discriminator": [ + 22, + 213, + 197, + 160, + 139, + 193, + 81, + 149 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "poolId", + "type": "u8" + } + ] + }, + { + "name": "updateSpotMarketRevenueSettlePeriod", + "discriminator": [ + 81, + 92, + 126, + 41, + 250, + 225, + 156, + 219 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "revenueSettlePeriod", + "type": "i64" + } + ] + }, + { + "name": "updateSpotMarketScaleInitialAssetWeightStart", + "discriminator": [ + 217, + 204, + 204, + 118, + 204, + 130, + 225, + 147 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "scaleInitialAssetWeightStart", + "type": "u64" + } + ] + }, + { + "name": "updateSpotMarketStatus", + "discriminator": [ + 78, + 94, + 16, + 188, + 193, + 110, + 231, + 31 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "marketStatus" + } + } + } + ] + }, + { + "name": "updateSpotMarketStepSizeAndTickSize", + "discriminator": [ + 238, + 153, + 137, + 80, + 206, + 59, + 250, + 61 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "stepSize", + "type": "u64" + }, + { + "name": "tickSize", + "type": "u64" + } + ] + }, + { + "name": "updateStateMaxInitializeUserFee", + "discriminator": [ + 237, + 225, + 25, + 237, + 193, + 45, + 77, + 97 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "maxInitializeUserFee", + "type": "u16" + } + ] + }, + { + "name": "updateStateMaxNumberOfSubAccounts", + "discriminator": [ + 155, + 123, + 214, + 2, + 221, + 166, + 204, + 85 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "maxNumberOfSubAccounts", + "type": "u16" + } + ] + }, + { + "name": "updateStateSettlementDuration", + "discriminator": [ + 97, + 68, + 199, + 235, + 131, + 80, + 61, + 173 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "settlementDuration", + "type": "u16" + } + ] + }, + { + "name": "updateUserCustomMarginRatio", + "discriminator": [ + 21, + 221, + 140, + 187, + 32, + 129, + 11, + 123 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "marginRatio", + "type": "u32" + } + ] + }, + { + "name": "updateUserDelegate", + "discriminator": [ + 139, + 205, + 141, + 141, + 113, + 36, + 94, + 187 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "delegate", + "type": "pubkey" + } + ] + }, + { + "name": "updateUserGovTokenInsuranceStake", + "discriminator": [ + 143, + 99, + 235, + 187, + 20, + 159, + 184, + 84 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "signer", + "signer": true + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateUserIdle", + "discriminator": [ + 253, + 133, + 67, + 22, + 103, + 161, + 20, + 100 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "updateUserMarginTradingEnabled", + "discriminator": [ + 194, + 92, + 204, + 223, + 246, + 188, + 31, + 203 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "marginTradingEnabled", + "type": "bool" + } + ] + }, + { + "name": "updateUserName", + "discriminator": [ + 135, + 25, + 185, + 56, + 165, + 53, + 34, + 136 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "updateUserPerpPositionCustomMarginRatio", + "discriminator": [ + 121, + 137, + 157, + 155, + 89, + 186, + 145, + 113 + ], + "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "marginRatio", + "type": "u16" + } + ] + }, + { + "name": "updateUserPoolId", + "discriminator": [ + 219, + 86, + 73, + 106, + 56, + 218, + 128, + 109 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "poolId", + "type": "u8" + } + ] + }, + { + "name": "updateUserProtectedMakerOrders", + "discriminator": [ + 114, + 39, + 123, + 198, + 187, + 25, + 90, + 219 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "protectedMakerModeConfig", + "writable": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "protectedMakerOrders", + "type": "bool" + } + ] + }, + { + "name": "updateUserQuoteAssetInsuranceStake", + "discriminator": [ + 251, + 101, + 156, + 7, + 2, + 63, + 30, + 23 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "signer", + "signer": true + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateUserReduceOnly", + "discriminator": [ + 199, + 71, + 42, + 67, + 144, + 19, + 86, + 109 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "reduceOnly", + "type": "bool" + } + ] + }, + { + "name": "updateUserStatsReferrerStatus", + "discriminator": [ + 174, + 154, + 72, + 42, + 191, + 148, + 145, + 205 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [] + }, + { + "name": "updateWithdrawGuardThreshold", + "discriminator": [ + 56, + 18, + 39, + 61, + 155, + 211, + 44, + 133 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "withdrawGuardThreshold", + "type": "u64" + } + ] + }, + { + "name": "viewLpPoolAddLiquidityFees", + "discriminator": [ + 80, + 66, + 226, + 161, + 70, + 142, + 119, + 84 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "inMarketMint" + }, + { + "name": "inConstituent", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "lpMint" + }, + { + "name": "constituentTargetBase" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u128" + } + ] + }, + { + "name": "viewLpPoolRemoveLiquidityFees", + "discriminator": [ + 47, + 12, + 9, + 102, + 12, + 226, + 197, + 89 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "outMarketMint" + }, + { + "name": "outConstituent", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "lpMint" + }, + { + "name": "constituentTargetBase" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u64" + } + ] + }, + { + "name": "viewLpPoolSwapFees", + "discriminator": [ + 126, + 189, + 109, + 189, + 170, + 156, + 3, + 46 + ], + "accounts": [ + { + "name": "driftSigner" + }, + { + "name": "state" + }, + { + "name": "lpPool" + }, + { + "name": "constituentTargetBase" + }, + { + "name": "constituentCorrelations" + }, + { + "name": "constituentInTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "writable": true + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "authority", + "signer": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u64" + }, + { + "name": "inTargetWeight", + "type": "i64" + }, + { + "name": "outTargetWeight", + "type": "i64" + } + ] + }, + { + "name": "withdraw", + "discriminator": [ + 183, + 18, + 70, + 156, + 148, + 109, + 161, + 34 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "user", + "userStats" + ] + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "reduceOnly", + "type": "bool" + } + ] + }, + { + "name": "withdrawFromProgramVault", + "discriminator": [ + 120, + 40, + 183, + 149, + 232, + 18, + 224, + 151 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "driftSigner" + }, + { + "name": "constituent", + "writable": true + }, + { + "name": "constituentTokenAccount", + "writable": true + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "mint" + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "zeroMmOracleFields", + "discriminator": [ + 192, + 226, + 39, + 204, + 207, + 120, + 148, + 250 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [] + } + ], + "accounts": [ + { + "name": "ammCache", + "discriminator": [ + 213, + 114, + 161, + 56, + 20, + 22, + 2, + 59 + ] + }, + { + "name": "ammConstituentMapping", + "discriminator": [ + 254, + 89, + 5, + 173, + 66, + 54, + 214, + 247 + ] + }, + { + "name": "constituent", + "discriminator": [ + 0, + 61, + 36, + 35, + 177, + 76, + 216, + 205 + ] + }, + { + "name": "constituentCorrelations", + "discriminator": [ + 124, + 203, + 115, + 33, + 18, + 162, + 67, + 216 + ] + }, + { + "name": "constituentTargetBase", + "discriminator": [ + 255, + 142, + 134, + 71, + 125, + 66, + 198, + 99 + ] + }, + { + "name": "fuelOverflow", + "discriminator": [ + 182, + 64, + 231, + 177, + 226, + 142, + 69, + 58 + ] + }, + { + "name": "highLeverageModeConfig", + "discriminator": [ + 3, + 196, + 90, + 189, + 193, + 64, + 228, + 234 + ] + }, + { + "name": "ifRebalanceConfig", + "discriminator": [ + 214, + 84, + 40, + 251, + 107, + 144, + 173, + 239 + ] + }, + { + "name": "insuranceFundStake", + "discriminator": [ + 110, + 202, + 14, + 42, + 95, + 73, + 90, + 95 + ] + }, + { + "name": "lpPool", + "discriminator": [ + 228, + 152, + 141, + 224, + 161, + 170, + 11, + 89 + ] + }, + { + "name": "openbookV2FulfillmentConfig", + "discriminator": [ + 3, + 43, + 58, + 106, + 131, + 132, + 199, + 171 + ] + }, + { + "name": "perpMarket", + "discriminator": [ + 10, + 223, + 12, + 44, + 107, + 245, + 55, + 247 + ] + }, + { + "name": "phoenixV1FulfillmentConfig", + "discriminator": [ + 233, + 45, + 62, + 40, + 35, + 129, + 48, + 72 + ] + }, + { + "name": "prelaunchOracle", + "discriminator": [ + 92, + 14, + 139, + 234, + 72, + 244, + 68, + 26 + ] + }, + { + "name": "protectedMakerModeConfig", + "discriminator": [ + 47, + 86, + 90, + 9, + 224, + 255, + 10, + 69 + ] + }, + { + "name": "pythLazerOracle", + "discriminator": [ + 159, + 7, + 161, + 249, + 34, + 81, + 121, + 133 + ] + }, + { + "name": "referrerName", + "discriminator": [ + 105, + 133, + 170, + 110, + 52, + 42, + 28, + 182 + ] + }, + { + "name": "revenueShare", + "discriminator": [ + 55, + 40, + 228, + 7, + 139, + 52, + 180, + 110 + ] + }, + { + "name": "revenueShareEscrow", + "discriminator": [ + 98, + 167, + 3, + 46, + 74, + 177, + 173, + 252 + ] + }, + { + "name": "serumV3FulfillmentConfig", + "discriminator": [ + 65, + 160, + 197, + 112, + 239, + 168, + 103, + 185 + ] + }, + { + "name": "signedMsgUserOrders", + "discriminator": [ + 70, + 6, + 50, + 248, + 222, + 1, + 143, + 49 + ] + }, + { + "name": "signedMsgWsDelegates", + "discriminator": [ + 190, + 115, + 111, + 44, + 216, + 252, + 108, + 85 + ] + }, + { + "name": "spotMarket", + "discriminator": [ + 100, + 177, + 8, + 107, + 168, + 65, + 65, + 39 + ] + }, + { + "name": "state", + "discriminator": [ + 216, + 146, + 107, + 94, + 104, + 75, + 182, + 177 + ] + }, + { + "name": "user", + "discriminator": [ + 159, + 117, + 95, + 227, + 239, + 151, + 58, + 236 + ] + }, + { + "name": "userStats", + "discriminator": [ + 176, + 223, + 136, + 27, + 122, + 79, + 32, + 227 + ] + } + ], + "events": [ + { + "name": "curveRecord", + "discriminator": [ + 101, + 238, + 40, + 228, + 70, + 46, + 61, + 117 + ] + }, + { + "name": "deleteUserRecord", + "discriminator": [ + 71, + 111, + 190, + 118, + 7, + 3, + 132, + 222 + ] + }, + { + "name": "depositRecord", + "discriminator": [ + 180, + 241, + 218, + 207, + 102, + 135, + 44, + 134 + ] + }, + { + "name": "fuelSeasonRecord", + "discriminator": [ + 19, + 137, + 119, + 33, + 224, + 249, + 6, + 87 + ] + }, + { + "name": "fuelSweepRecord", + "discriminator": [ + 41, + 84, + 37, + 246, + 132, + 240, + 131, + 8 + ] + }, + { + "name": "fundingPaymentRecord", + "discriminator": [ + 8, + 59, + 96, + 20, + 137, + 201, + 56, + 95 + ] + }, + { + "name": "fundingRateRecord", + "discriminator": [ + 68, + 3, + 255, + 26, + 133, + 91, + 147, + 254 + ] + }, + { + "name": "insuranceFundRecord", + "discriminator": [ + 56, + 222, + 215, + 235, + 78, + 197, + 99, + 146 + ] + }, + { + "name": "insuranceFundStakeRecord", + "discriminator": [ + 68, + 66, + 156, + 7, + 216, + 148, + 250, + 114 + ] + }, + { + "name": "insuranceFundSwapRecord", + "discriminator": [ + 85, + 190, + 99, + 203, + 237, + 33, + 227, + 100 + ] + }, + { + "name": "lpBorrowLendDepositRecord", + "discriminator": [ + 242, + 181, + 11, + 56, + 243, + 61, + 79, + 210 + ] + }, + { + "name": "lpMintRedeemRecord", + "discriminator": [ + 53, + 178, + 142, + 73, + 78, + 91, + 91, + 8 + ] + }, + { + "name": "lpRecord", + "discriminator": [ + 101, + 22, + 54, + 38, + 178, + 13, + 142, + 111 + ] + }, + { + "name": "lpSettleRecord", + "discriminator": [ + 208, + 191, + 131, + 110, + 173, + 48, + 7, + 2 + ] + }, + { + "name": "lpSwapRecord", + "discriminator": [ + 159, + 62, + 130, + 196, + 96, + 79, + 176, + 254 + ] + }, + { + "name": "liquidationRecord", + "discriminator": [ + 127, + 17, + 0, + 108, + 182, + 13, + 231, + 53 + ] + }, + { + "name": "newUserRecord", + "discriminator": [ + 236, + 186, + 113, + 219, + 42, + 51, + 149, + 249 + ] + }, + { + "name": "orderActionRecord", + "discriminator": [ + 224, + 52, + 67, + 71, + 194, + 237, + 109, + 1 + ] + }, + { + "name": "orderRecord", + "discriminator": [ + 104, + 19, + 64, + 56, + 89, + 21, + 2, + 90 + ] + }, + { + "name": "revenueShareSettleRecord", + "discriminator": [ + 61, + 162, + 89, + 10, + 24, + 20, + 59, + 45 + ] + }, + { + "name": "settlePnlRecord", + "discriminator": [ + 57, + 68, + 105, + 26, + 119, + 198, + 213, + 89 + ] + }, + { + "name": "signedMsgOrderRecord", + "discriminator": [ + 211, + 197, + 25, + 18, + 142, + 86, + 113, + 27 + ] + }, + { + "name": "spotInterestRecord", + "discriminator": [ + 183, + 186, + 203, + 186, + 225, + 187, + 95, + 130 + ] + }, + { + "name": "spotMarketVaultDepositRecord", + "discriminator": [ + 178, + 217, + 23, + 188, + 127, + 190, + 32, + 73 + ] + }, + { + "name": "swapRecord", + "discriminator": [ + 162, + 187, + 123, + 194, + 138, + 56, + 250, + 241 + ] + }, + { + "name": "transferProtocolIfSharesToRevenuePoolRecord", + "discriminator": [ + 209, + 118, + 142, + 167, + 130, + 46, + 164, + 151 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "invalidEd25519InstructionProgramId", + "msg": "invalid ed25519 instruction program" + }, + { + "code": 6001, + "name": "invalidEd25519InstructionDataLength", + "msg": "invalid ed25519 instruction data length" + }, + { + "code": 6002, + "name": "invalidSignatureIndex", + "msg": "invalid signature index" + }, + { + "code": 6003, + "name": "invalidSignatureOffset", + "msg": "invalid signature offset" + }, + { + "code": 6004, + "name": "invalidPublicKeyOffset", + "msg": "invalid public key offset" + }, + { + "code": 6005, + "name": "invalidMessageOffset", + "msg": "invalid message offset" + }, + { + "code": 6006, + "name": "invalidMessageDataSize", + "msg": "invalid message data size" + }, + { + "code": 6007, + "name": "invalidInstructionIndex", + "msg": "invalid instruction index" + }, + { + "code": 6008, + "name": "messageOffsetOverflow", + "msg": "message offset overflow" + }, + { + "code": 6009, + "name": "invalidMessageHex", + "msg": "invalid message hex" + }, + { + "code": 6010, + "name": "invalidMessageData", + "msg": "invalid message data" + }, + { + "code": 6011, + "name": "loadInstructionAtFailed", + "msg": "loading custom ix at index failed" + } + ], + "types": [ + { + "name": "amm", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "docs": [ + "oracle price data public key" + ], + "type": "pubkey" + }, + { + "name": "historicalOracleData", + "docs": [ + "stores historically witnessed oracle data" + ], + "type": { + "defined": { + "name": "historicalOracleData" + } + } + }, + { + "name": "baseAssetAmountPerLp", + "docs": [ + "accumulated base asset amount since inception per lp share", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteAssetAmountPerLp", + "docs": [ + "accumulated quote asset amount since inception per lp share", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "feePool", + "docs": [ + "partition of fees from perp market trading moved from pnl settlements" + ], + "type": { + "defined": { + "name": "poolBalance" + } + } + }, + { + "name": "baseAssetReserve", + "docs": [ + "`x` reserves for constant product mm formula (x * y = k)", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "quoteAssetReserve", + "docs": [ + "`y` reserves for constant product mm formula (x * y = k)", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "concentrationCoef", + "docs": [ + "determines how close the min/max base asset reserve sit vs base reserves", + "allow for decreasing slippage without increasing liquidity and v.v.", + "precision: PERCENTAGE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "minBaseAssetReserve", + "docs": [ + "minimum base_asset_reserve allowed before AMM is unavailable", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "maxBaseAssetReserve", + "docs": [ + "maximum base_asset_reserve allowed before AMM is unavailable", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "sqrtK", + "docs": [ + "`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "pegMultiplier", + "docs": [ + "normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced", + "precision: PEG_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "terminalQuoteAssetReserve", + "docs": [ + "y when market is balanced. stored to save computation", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "baseAssetAmountLong", + "docs": [ + "always non-negative. tracks number of total longs in market (regardless of counterparty)", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "baseAssetAmountShort", + "docs": [ + "always non-positive. tracks number of total shorts in market (regardless of counterparty)", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "baseAssetAmountWithAmm", + "docs": [ + "tracks net position (longs-shorts) in market with AMM as counterparty", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "baseAssetAmountWithUnsettledLp", + "docs": [ + "tracks net position (longs-shorts) in market with LPs as counterparty", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "maxOpenInterest", + "docs": [ + "max allowed open interest, blocks trades that breach this value", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "quoteAssetAmount", + "docs": [ + "sum of all user's perp quote_asset_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteEntryAmountLong", + "docs": [ + "sum of all long user's quote_entry_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteEntryAmountShort", + "docs": [ + "sum of all short user's quote_entry_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteBreakEvenAmountLong", + "docs": [ + "sum of all long user's quote_break_even_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteBreakEvenAmountShort", + "docs": [ + "sum of all short user's quote_break_even_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "userLpShares", + "docs": [ + "total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastFundingRate", + "docs": [ + "last funding rate in this perp market (unit is quote per base)", + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastFundingRateLong", + "docs": [ + "last funding rate for longs in this perp market (unit is quote per base)", + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastFundingRateShort", + "docs": [ + "last funding rate for shorts in this perp market (unit is quote per base)", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "last24hAvgFundingRate", + "docs": [ + "estimate of last 24h of funding rate perp market (unit is quote per base)", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "totalFee", + "docs": [ + "total fees collected by this perp market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "totalMmFee", + "docs": [ + "total fees collected by the vAMM's bid/ask spread", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "totalExchangeFee", + "docs": [ + "total fees collected by exchange fee schedule", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalFeeMinusDistributions", + "docs": [ + "total fees minus any recognized upnl and pool withdraws", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "totalFeeWithdrawn", + "docs": [ + "sum of all fees from fee pool withdrawn to revenue pool", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalLiquidationFee", + "docs": [ + "all fees collected by market for liquidations", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeFundingRateLong", + "docs": [ + "accumulated funding rate for longs since inception in market" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "cumulativeFundingRateShort", + "docs": [ + "accumulated funding rate for shorts since inception in market" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "totalSocialLoss", + "docs": [ + "accumulated social loss paid by users since inception in market" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "askBaseAssetReserve", + "docs": [ + "transformed base_asset_reserve for users going long", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "askQuoteAssetReserve", + "docs": [ + "transformed quote_asset_reserve for users going long", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "bidBaseAssetReserve", + "docs": [ + "transformed base_asset_reserve for users going short", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "bidQuoteAssetReserve", + "docs": [ + "transformed quote_asset_reserve for users going short", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastOracleNormalisedPrice", + "docs": [ + "the last seen oracle price partially shrunk toward the amm reserve price", + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastOracleReservePriceSpreadPct", + "docs": [ + "the gap between the oracle price and the reserve price = y * peg_multiplier / x" + ], + "type": "i64" + }, + { + "name": "lastBidPriceTwap", + "docs": [ + "average estimate of bid price over funding_period", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastAskPriceTwap", + "docs": [ + "average estimate of ask price over funding_period", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastMarkPriceTwap", + "docs": [ + "average estimate of (bid+ask)/2 price over funding_period", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastMarkPriceTwap5min", + "docs": [ + "average estimate of (bid+ask)/2 price over FIVE_MINUTES" + ], + "type": "u64" + }, + { + "name": "lastUpdateSlot", + "docs": [ + "the last blockchain slot the amm was updated" + ], + "type": "u64" + }, + { + "name": "lastOracleConfPct", + "docs": [ + "the pct size of the oracle confidence interval", + "precision: PERCENTAGE_PRECISION" + ], + "type": "u64" + }, + { + "name": "netRevenueSinceLastFunding", + "docs": [ + "the total_fee_minus_distribution change since the last funding update", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastFundingRateTs", + "docs": [ + "the last funding rate update unix_timestamp" + ], + "type": "i64" + }, + { + "name": "fundingPeriod", + "docs": [ + "the periodicity of the funding rate updates" + ], + "type": "i64" + }, + { + "name": "orderStepSize", + "docs": [ + "the base step size (increment) of orders", + "precision: BASE_PRECISION" + ], + "type": "u64" + }, + { + "name": "orderTickSize", + "docs": [ + "the price tick size of orders", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "minOrderSize", + "docs": [ + "the minimum base size of an order", + "precision: BASE_PRECISION" + ], + "type": "u64" + }, + { + "name": "mmOracleSlot", + "docs": [ + "the max base size a single user can have", + "precision: BASE_PRECISION" + ], + "type": "u64" + }, + { + "name": "volume24h", + "docs": [ + "estimated total of volume in market", + "QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "longIntensityVolume", + "docs": [ + "the volume intensity of long fills against AMM" + ], + "type": "u64" + }, + { + "name": "shortIntensityVolume", + "docs": [ + "the volume intensity of short fills against AMM" + ], + "type": "u64" + }, + { + "name": "lastTradeTs", + "docs": [ + "the blockchain unix timestamp at the time of the last trade" + ], + "type": "i64" + }, + { + "name": "markStd", + "docs": [ + "estimate of standard deviation of the fill (mark) prices", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "oracleStd", + "docs": [ + "estimate of standard deviation of the oracle price at each update", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastMarkPriceTwapTs", + "docs": [ + "the last unix_timestamp the mark twap was updated" + ], + "type": "i64" + }, + { + "name": "baseSpread", + "docs": [ + "the minimum spread the AMM can quote. also used as step size for some spread logic increases." + ], + "type": "u32" + }, + { + "name": "maxSpread", + "docs": [ + "the maximum spread the AMM can quote" + ], + "type": "u32" + }, + { + "name": "longSpread", + "docs": [ + "the spread for asks vs the reserve price" + ], + "type": "u32" + }, + { + "name": "shortSpread", + "docs": [ + "the spread for bids vs the reserve price" + ], + "type": "u32" + }, + { + "name": "mmOraclePrice", + "docs": [ + "MM oracle price" + ], + "type": "i64" + }, + { + "name": "maxFillReserveFraction", + "docs": [ + "the fraction of total available liquidity a single fill on the AMM can consume" + ], + "type": "u16" + }, + { + "name": "maxSlippageRatio", + "docs": [ + "the maximum slippage a single fill on the AMM can push" + ], + "type": "u16" + }, + { + "name": "curveUpdateIntensity", + "docs": [ + "the update intensity of AMM formulaic updates (adjusting k). 0-100" + ], + "type": "u8" + }, + { + "name": "ammJitIntensity", + "docs": [ + "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.", + "(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM." + ], + "type": "u8" + }, + { + "name": "oracleSource", + "docs": [ + "the oracle provider information. used to decode/scale the oracle public key" + ], + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "lastOracleValid", + "docs": [ + "tracks whether the oracle was considered valid at the last AMM update" + ], + "type": "bool" + }, + { + "name": "targetBaseAssetAmountPerLp", + "docs": [ + "the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split", + "precision: BASE_PRECISION" + ], + "type": "i32" + }, + { + "name": "perLpBase", + "docs": [ + "expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)" + ], + "type": "i8" + }, + { + "name": "oracleLowRiskSlotDelayOverride", + "docs": [ + "the override for the state.min_perp_auction_duration", + "0 is no override, -1 is disable speed bump, 1-100 is literal speed bump" + ], + "type": "i8" + }, + { + "name": "ammSpreadAdjustment", + "docs": [ + "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" + ], + "type": "i8" + }, + { + "name": "oracleSlotDelayOverride", + "type": "i8" + }, + { + "name": "mmOracleSequenceId", + "type": "u64" + }, + { + "name": "netUnsettledFundingPnl", + "type": "i64" + }, + { + "name": "quoteAssetAmountWithUnsettledLp", + "type": "i64" + }, + { + "name": "referencePriceOffset", + "type": "i32" + }, + { + "name": "ammInventorySpreadAdjustment", + "docs": [ + "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" + ], + "type": "i8" + }, + { + "name": "referencePriceOffsetDeadbandPct", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "lastFundingOracleTwap", + "type": "i64" + } + ] + } + }, + { + "name": "addAmmConstituentMappingDatum", + "type": { + "kind": "struct", + "fields": [ + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "weight", + "type": "i64" + } + ] + } + }, + { + "name": "ammCache", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "cache", + "type": { + "vec": { + "defined": { + "name": "cacheInfo" + } + } + } + } + ] + } + }, + { + "name": "ammConstituentDatum", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "lastSlot", + "type": "u64" + }, + { + "name": "weight", + "docs": [ + "PERCENTAGE_PRECISION. The weight this constituent has on the perp market" + ], + "type": "i64" + } + ] + } + }, + { + "name": "ammConstituentMapping", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lpPool", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "weights", + "type": { + "vec": { + "defined": { + "name": "ammConstituentDatum" + } + } + } + } + ] + } + }, + { + "name": "assetTier", + "type": { + "kind": "enum", + "variants": [ + { + "name": "collateral" + }, + { + "name": "protected" + }, + { + "name": "cross" + }, + { + "name": "isolated" + }, + { + "name": "unlisted" + } + ] + } + }, + { + "name": "builderInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "maxFeeTenthBps", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 6 + ] + } + } + ] + } + }, + { + "name": "cacheInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "lastFeePoolTokenAmount", + "type": "u128" + }, + { + "name": "lastNetPnlPoolTokenAmount", + "type": "i128" + }, + { + "name": "lastExchangeFees", + "type": "u128" + }, + { + "name": "lastSettleAmmExFees", + "type": "u128" + }, + { + "name": "lastSettleAmmPnl", + "type": "i128" + }, + { + "name": "position", + "docs": [ + "BASE PRECISION" + ], + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "lastSettleAmount", + "type": "u64" + }, + { + "name": "lastSettleSlot", + "type": "u64" + }, + { + "name": "lastSettleTs", + "type": "i64" + }, + { + "name": "quoteOwedFromLpPool", + "type": "i64" + }, + { + "name": "ammInventoryLimit", + "type": "i64" + }, + { + "name": "oraclePrice", + "type": "i64" + }, + { + "name": "oracleSlot", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "oracleSource", + "type": "u8" + }, + { + "name": "oracleValidity", + "type": "u8" + }, + { + "name": "lpStatusForPerpMarket", + "type": "u8" + }, + { + "name": "ammPositionScalar", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 34 + ] + } + } + ] + } + }, + { + "name": "constituent", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "address of the constituent" + ], + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "lpPool", + "type": "pubkey" + }, + { + "name": "vault", + "type": "pubkey" + }, + { + "name": "totalSwapFees", + "docs": [ + "total fees received by the constituent. Positive = fees received, Negative = fees paid" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "spotBalance", + "docs": [ + "spot borrow-lend balance for constituent" + ], + "type": { + "defined": { + "name": "constituentSpotBalance" + } + } + }, + { + "name": "lastSpotBalanceTokenAmount", + "type": "i64" + }, + { + "name": "cumulativeSpotInterestAccruedTokenAmount", + "type": "i64" + }, + { + "name": "maxWeightDeviation", + "docs": [ + "max deviation from target_weight allowed for the constituent", + "precision: PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "swapFeeMin", + "docs": [ + "min fee charged on swaps to/from this constituent", + "precision: PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "swapFeeMax", + "docs": [ + "max fee charged on swaps to/from this constituent", + "precision: PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "maxBorrowTokenAmount", + "docs": [ + "Max Borrow amount:", + "precision: token precision" + ], + "type": "u64" + }, + { + "name": "vaultTokenBalance", + "docs": [ + "ata token balance in token precision" + ], + "type": "u64" + }, + { + "name": "lastOraclePrice", + "type": "i64" + }, + { + "name": "lastOracleSlot", + "type": "u64" + }, + { + "name": "oracleStalenessThreshold", + "docs": [ + "Delay allowed for valid AUM calculation" + ], + "type": "u64" + }, + { + "name": "flashLoanInitialTokenAmount", + "type": "u64" + }, + { + "name": "nextSwapId", + "docs": [ + "Every swap to/from this constituent has a monotonically increasing id. This is the next id to use" + ], + "type": "u64" + }, + { + "name": "derivativeWeight", + "docs": [ + "percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight" + ], + "type": "u64" + }, + { + "name": "volatility", + "type": "u64" + }, + { + "name": "constituentDerivativeDepegThreshold", + "type": "u64" + }, + { + "name": "constituentDerivativeIndex", + "docs": [ + "The `constituent_index` of the parent constituent. -1 if it is a parent index", + "Example: if in a pool with SOL (parent) and dSOL (derivative),", + "SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,", + "dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1" + ], + "type": "i16" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "decimals", + "type": "u8" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "vaultBump", + "type": "u8" + }, + { + "name": "gammaInventory", + "type": "u8" + }, + { + "name": "gammaExecution", + "type": "u8" + }, + { + "name": "xi", + "type": "u8" + }, + { + "name": "status", + "type": "u8" + }, + { + "name": "pausedOperations", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 162 + ] + } + } + ] + } + }, + { + "name": "constituentCorrelations", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lpPool", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "correlations", + "type": { + "vec": "i64" + } + } + ] + } + }, + { + "name": "constituentParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxWeightDeviation", + "type": { + "option": "i64" + } + }, + { + "name": "swapFeeMin", + "type": { + "option": "i64" + } + }, + { + "name": "swapFeeMax", + "type": { + "option": "i64" + } + }, + { + "name": "maxBorrowTokenAmount", + "type": { + "option": "u64" + } + }, + { + "name": "oracleStalenessThreshold", + "type": { + "option": "u64" + } + }, + { + "name": "costToTradeBps", + "type": { + "option": "i32" + } + }, + { + "name": "constituentDerivativeIndex", + "type": { + "option": "i16" + } + }, + { + "name": "derivativeWeight", + "type": { + "option": "u64" + } + }, + { + "name": "volatility", + "type": { + "option": "u64" + } + }, + { + "name": "gammaExecution", + "type": { + "option": "u8" + } + }, + { + "name": "gammaInventory", + "type": { + "option": "u8" + } + }, + { + "name": "xi", + "type": { + "option": "u8" + } + } + ] + } + }, + { + "name": "constituentSpotBalance", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "scaledBalance", + "docs": [ + "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", + "interest of corresponding market.", + "precision: token precision" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeDeposits", + "docs": [ + "The cumulative deposits/borrows a user has made into a market", + "precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "marketIndex", + "docs": [ + "The market index of the corresponding spot market" + ], + "type": "u16" + }, + { + "name": "balanceType", + "docs": [ + "Whether the position is deposit or borrow" + ], + "type": { + "defined": { + "name": "spotBalanceType" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 5 + ] + } + } + ] + } + }, + { + "name": "constituentTargetBase", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lpPool", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "targets", + "type": { + "vec": { + "defined": { + "name": "targetsDatum" + } + } + } + } + ] + } + }, + { + "name": "contractTier", + "type": { + "kind": "enum", + "variants": [ + { + "name": "a" + }, + { + "name": "b" + }, + { + "name": "c" + }, + { + "name": "speculative" + }, + { + "name": "highlySpeculative" + }, + { + "name": "isolated" + } + ] + } + }, + { + "name": "contractType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "perpetual" + }, + { + "name": "future" + }, + { + "name": "prediction" + } + ] + } + }, + { + "name": "curveRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "recordId", + "type": "u64" + }, + { + "name": "pegMultiplierBefore", + "type": "u128" + }, + { + "name": "baseAssetReserveBefore", + "type": "u128" + }, + { + "name": "quoteAssetReserveBefore", + "type": "u128" + }, + { + "name": "sqrtKBefore", + "type": "u128" + }, + { + "name": "pegMultiplierAfter", + "type": "u128" + }, + { + "name": "baseAssetReserveAfter", + "type": "u128" + }, + { + "name": "quoteAssetReserveAfter", + "type": "u128" + }, + { + "name": "sqrtKAfter", + "type": "u128" + }, + { + "name": "baseAssetAmountLong", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "u128" + }, + { + "name": "baseAssetAmountShort", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "u128" + }, + { + "name": "baseAssetAmountWithAmm", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i128" + }, + { + "name": "totalFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" + }, + { + "name": "totalFeeMinusDistributions", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" + }, + { + "name": "adjustmentCost", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" + }, + { + "name": "oraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "fillRecord", + "type": "u128" + }, + { + "name": "numberOfUsers", + "type": "u32" + }, + { + "name": "marketIndex", + "type": "u16" + } + ] + } + }, + { + "name": "deleteUserRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "docs": [ + "unix_timestamp of action" + ], + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "keeper", + "type": { + "option": "pubkey" + } + } + ] + } + }, + { + "name": "depositDirection", + "type": { + "kind": "enum", + "variants": [ + { + "name": "deposit" + }, + { + "name": "withdraw" + } + ] + } + }, + { + "name": "depositExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "none" + }, + { + "name": "transfer" + }, + { + "name": "borrow" + }, + { + "name": "repayBorrow" + }, + { + "name": "reward" + } + ] + } + }, + { + "name": "depositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "docs": [ + "unix_timestamp of action" + ], + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "user", + "docs": [ + "user account public key" + ], + "type": "pubkey" + }, + { + "name": "direction", + "type": { + "defined": { + "name": "depositDirection" + } + } + }, + { + "name": "depositRecordId", + "type": "u64" + }, + { + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "marketIndex", + "docs": [ + "spot market index" + ], + "type": "u16" + }, + { + "name": "oraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "marketDepositBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "marketWithdrawBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "marketCumulativeDepositInterest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "marketCumulativeBorrowInterest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "totalDepositsAfter", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalWithdrawsAfter", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "explanation", + "type": { + "defined": { + "name": "depositExplanation" + } + } + }, + { + "name": "transferUser", + "type": { + "option": "pubkey" + } + }, + { + "name": "signer", + "type": { + "option": "pubkey" + } + }, + { + "name": "userTokenAmountAfter", + "docs": [ + "precision: token mint precision" + ], + "type": "i128" + } + ] + } + }, + { + "name": "feeStructure", + "type": { + "kind": "struct", + "fields": [ + { + "name": "feeTiers", + "type": { + "array": [ + { + "defined": { + "name": "feeTier" + } + }, + 10 + ] + } + }, + { + "name": "fillerRewardStructure", + "type": { + "defined": { + "name": "orderFillerRewardStructure" + } + } + }, + { + "name": "referrerRewardEpochUpperBound", + "type": "u64" + }, + { + "name": "flatFillerFee", + "type": "u64" + } + ] + } + }, + { + "name": "feeTier", + "type": { + "kind": "struct", + "fields": [ + { + "name": "feeNumerator", + "type": "u32" + }, + { + "name": "feeDenominator", + "type": "u32" + }, + { + "name": "makerRebateNumerator", + "type": "u32" + }, + { + "name": "makerRebateDenominator", + "type": "u32" + }, + { + "name": "referrerRewardNumerator", + "type": "u32" + }, + { + "name": "referrerRewardDenominator", + "type": "u32" + }, + { + "name": "refereeFeeNumerator", + "type": "u32" + }, + { + "name": "refereeFeeDenominator", + "type": "u32" + } + ] + } + }, + { + "name": "fuelOverflow", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The authority of this overflow account" + ], + "type": "pubkey" + }, + { + "name": "fuelInsurance", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelDeposits", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelBorrows", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelPositions", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelTaker", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelMaker", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastFuelSweepTs", + "type": "u32" + }, + { + "name": "lastResetTs", + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u128", + 6 + ] + } + } + ] + } + }, + { + "name": "fuelSeasonRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "fuelInsurance", + "type": "u128" + }, + { + "name": "fuelDeposits", + "type": "u128" + }, + { + "name": "fuelBorrows", + "type": "u128" + }, + { + "name": "fuelPositions", + "type": "u128" + }, + { + "name": "fuelTaker", + "type": "u128" + }, + { + "name": "fuelMaker", + "type": "u128" + }, + { + "name": "fuelTotal", + "type": "u128" + } + ] + } + }, + { + "name": "fuelSweepRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "userStatsFuelInsurance", + "type": "u32" + }, + { + "name": "userStatsFuelDeposits", + "type": "u32" + }, + { + "name": "userStatsFuelBorrows", + "type": "u32" + }, + { + "name": "userStatsFuelPositions", + "type": "u32" + }, + { + "name": "userStatsFuelTaker", + "type": "u32" + }, + { + "name": "userStatsFuelMaker", + "type": "u32" + }, + { + "name": "fuelOverflowFuelInsurance", + "type": "u128" + }, + { + "name": "fuelOverflowFuelDeposits", + "type": "u128" + }, + { + "name": "fuelOverflowFuelBorrows", + "type": "u128" + }, + { + "name": "fuelOverflowFuelPositions", + "type": "u128" + }, + { + "name": "fuelOverflowFuelTaker", + "type": "u128" + }, + { + "name": "fuelOverflowFuelMaker", + "type": "u128" + } + ] + } + }, + { + "name": "fundingPaymentRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fundingPayment", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "baseAssetAmount", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "userLastCumulativeFunding", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "ammCumulativeFundingLong", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "ammCumulativeFundingShort", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + } + ] + } + }, + { + "name": "fundingRateRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "recordId", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fundingRate", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "fundingRateLong", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "fundingRateShort", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "cumulativeFundingRateLong", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "cumulativeFundingRateShort", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "oraclePriceTwap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "markPriceTwap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "periodRevenue", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "baseAssetAmountWithAmm", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i128" + }, + { + "name": "baseAssetAmountWithUnsettledLp", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i128" + } + ] + } + }, + { + "name": "highLeverageModeConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "currentUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "u8" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "currentMaintenanceUsers", + "type": "u32" + }, + { + "name": "padding2", + "type": { + "array": [ + "u8", + 24 + ] + } + } + ] + } + }, + { + "name": "historicalIndexData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lastIndexBidPrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastIndexAskPrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastIndexPriceTwap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastIndexPriceTwap5min", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastIndexPriceTwapTs", + "docs": [ + "unix_timestamp of last snapshot" + ], + "type": "i64" + } + ] + } + }, + { + "name": "historicalOracleData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lastOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastOracleConf", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastOracleDelay", + "docs": [ + "number of slots since last update" + ], + "type": "i64" + }, + { + "name": "lastOraclePriceTwap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastOraclePriceTwap5min", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastOraclePriceTwapTs", + "docs": [ + "unix_timestamp of last snapshot" + ], + "type": "i64" + } + ] + } + }, + { + "name": "ifRebalanceConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" + }, + { + "name": "totalInAmount", + "docs": [ + "total amount to be sold" + ], + "type": "u64" + }, + { + "name": "currentInAmount", + "docs": [ + "amount already sold" + ], + "type": "u64" + }, + { + "name": "currentOutAmount", + "docs": [ + "amount already bought" + ], + "type": "u64" + }, + { + "name": "currentOutAmountTransferred", + "docs": [ + "amount already transferred to revenue pool" + ], + "type": "u64" + }, + { + "name": "currentInAmountSinceLastTransfer", + "docs": [ + "amount already bought in epoch" + ], + "type": "u64" + }, + { + "name": "epochStartTs", + "docs": [ + "start time of epoch" + ], + "type": "i64" + }, + { + "name": "epochInAmount", + "docs": [ + "amount already bought in epoch" + ], + "type": "u64" + }, + { + "name": "epochMaxInAmount", + "docs": [ + "max amount to swap in epoch" + ], + "type": "u64" + }, + { + "name": "epochDuration", + "docs": [ + "duration of epoch" + ], + "type": "i64" + }, + { + "name": "outMarketIndex", + "docs": [ + "market index to sell" + ], + "type": "u16" + }, + { + "name": "inMarketIndex", + "docs": [ + "market index to buy" + ], + "type": "u16" + }, + { + "name": "maxSlippageBps", + "type": "u16" + }, + { + "name": "swapMode", + "type": "u8" + }, + { + "name": "status", + "type": "u8" + }, + { + "name": "padding2", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "ifRebalanceConfigParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "totalInAmount", + "type": "u64" + }, + { + "name": "epochMaxInAmount", + "type": "u64" + }, + { + "name": "epochDuration", + "type": "i64" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "maxSlippageBps", + "type": "u16" + }, + { + "name": "swapMode", + "type": "u8" + }, + { + "name": "status", + "type": "u8" + } + ] + } + }, + { + "name": "insuranceClaim", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "revenueWithdrawSinceLastSettle", + "docs": [ + "The amount of revenue last settled", + "Positive if funds left the perp market,", + "negative if funds were pulled into the perp market", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "maxRevenueWithdrawPerPeriod", + "docs": [ + "The max amount of revenue that can be withdrawn per period", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "quoteMaxInsurance", + "docs": [ + "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "quoteSettledInsurance", + "docs": [ + "The amount of insurance that has been used to resolve bankruptcy and pnl deficits", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastRevenueWithdrawTs", + "docs": [ + "The last time revenue was settled in/out of market" + ], + "type": "i64" + } + ] + } + }, + { + "name": "insuranceFund", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "vault", + "type": "pubkey" + }, + { + "name": "totalShares", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "userShares", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "sharesBase", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "unstakingPeriod", + "type": "i64" + }, + { + "name": "lastRevenueSettleTs", + "type": "i64" + }, + { + "name": "revenueSettlePeriod", + "type": "i64" + }, + { + "name": "totalFactor", + "type": "u32" + }, + { + "name": "userFactor", + "type": "u32" + } + ] + } + }, + { + "name": "insuranceFundRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "userIfFactor", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + }, + { + "name": "totalIfFactor", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + }, + { + "name": "vaultAmountBefore", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "insuranceVaultAmountBefore", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "totalIfSharesBefore", + "type": "u128" + }, + { + "name": "totalIfSharesAfter", + "type": "u128" + }, + { + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "i64" + } + ] + } + }, + { + "name": "insuranceFundStake", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "ifShares", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastWithdrawRequestShares", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "ifBase", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastValidTs", + "type": "i64" + }, + { + "name": "lastWithdrawRequestValue", + "type": "u64" + }, + { + "name": "lastWithdrawRequestTs", + "type": "i64" + }, + { + "name": "costBasis", + "type": "i64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 14 + ] + } + } + ] + } + }, + { + "name": "insuranceFundStakeRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "action", + "type": { + "defined": { + "name": "stakeAction" + } + } + }, + { + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "insuranceVaultAmountBefore", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "ifSharesBefore", + "type": "u128" + }, + { + "name": "userIfSharesBefore", + "type": "u128" + }, + { + "name": "totalIfSharesBefore", + "type": "u128" + }, + { + "name": "ifSharesAfter", + "type": "u128" + }, + { + "name": "userIfSharesAfter", + "type": "u128" + }, + { + "name": "totalIfSharesAfter", + "type": "u128" + } + ] + } + }, + { + "name": "insuranceFundSwapRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rebalanceConfig", + "type": "pubkey" + }, + { + "name": "inIfTotalSharesBefore", + "type": "u128" + }, + { + "name": "outIfTotalSharesBefore", + "type": "u128" + }, + { + "name": "inIfUserSharesBefore", + "type": "u128" + }, + { + "name": "outIfUserSharesBefore", + "type": "u128" + }, + { + "name": "inIfTotalSharesAfter", + "type": "u128" + }, + { + "name": "outIfTotalSharesAfter", + "type": "u128" + }, + { + "name": "inIfUserSharesAfter", + "type": "u128" + }, + { + "name": "outIfUserSharesAfter", + "type": "u128" + }, + { + "name": "ts", + "type": "i64" + }, + { + "name": "inAmount", + "type": "u64" + }, + { + "name": "outAmount", + "type": "u64" + }, + { + "name": "outOraclePrice", + "type": "u64" + }, + { + "name": "outOraclePriceTwap", + "type": "i64" + }, + { + "name": "inVaultAmountBefore", + "type": "u64" + }, + { + "name": "outVaultAmountBefore", + "type": "u64" + }, + { + "name": "inFundVaultAmountAfter", + "type": "u64" + }, + { + "name": "outFundVaultAmountAfter", + "type": "u64" + }, + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + } + ] + } + }, + { + "name": "lpAction", + "type": { + "kind": "enum", + "variants": [ + { + "name": "addLiquidity" + }, + { + "name": "removeLiquidity" + }, + { + "name": "settleLiquidity" + }, + { + "name": "removeLiquidityDerisk" + } + ] + } + }, + { + "name": "lpBorrowLendDepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "direction", + "type": { + "defined": { + "name": "depositDirection" + } + } + }, + { + "name": "tokenBalance", + "type": "i64" + }, + { + "name": "lastTokenBalance", + "type": "i64" + }, + { + "name": "interestAccruedTokenAmount", + "type": "i64" + }, + { + "name": "amountDepositWithdraw", + "type": "u64" + }, + { + "name": "lpPool", + "type": "pubkey" + } + ] + } + }, + { + "name": "lpMintRedeemRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "description", + "type": "u8" + }, + { + "name": "amount", + "docs": [ + "precision: continutent mint precision, gross fees" + ], + "type": "u128" + }, + { + "name": "fee", + "docs": [ + "precision: fee on amount, constituent market mint precision" + ], + "type": "i128" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "oraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "mint", + "docs": [ + "token mint" + ], + "type": "pubkey" + }, + { + "name": "lpAmount", + "docs": [ + "lp amount, lp mint precision" + ], + "type": "u64" + }, + { + "name": "lpFee", + "docs": [ + "lp fee, lp mint precision" + ], + "type": "i64" + }, + { + "name": "lpPrice", + "docs": [ + "the fair price of the lp token, PRICE_PRECISION" + ], + "type": "u128" + }, + { + "name": "mintRedeemId", + "type": "u64" + }, + { + "name": "lastAum", + "docs": [ + "LPPool last_aum" + ], + "type": "u128" + }, + { + "name": "lastAumSlot", + "type": "u64" + }, + { + "name": "inMarketCurrentWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inMarketTargetWeight", + "type": "i64" + }, + { + "name": "lpPool", + "type": "pubkey" + } + ] + } + }, + { + "name": "lpPool", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "address of the vault." + ], + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "whitelistMint", + "type": "pubkey" + }, + { + "name": "constituentTargetBase", + "type": "pubkey" + }, + { + "name": "constituentCorrelations", + "type": "pubkey" + }, + { + "name": "maxAum", + "docs": [ + "The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)", + "which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)", + "pub quote_constituent_index: u16,", + "QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastAum", + "docs": [ + "QUOTE_PRECISION: AUM of the vault in USD, updated lazily" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeQuoteSentToPerpMarkets", + "docs": [ + "QUOTE PRECISION: Cumulative quotes from settles" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeQuoteReceivedFromPerpMarkets", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalMintRedeemFeesPaid", + "docs": [ + "QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "lastAumSlot", + "docs": [ + "timestamp of last AUM slot" + ], + "type": "u64" + }, + { + "name": "maxSettleQuoteAmount", + "type": "u64" + }, + { + "name": "padding", + "docs": [ + "timestamp of last vAMM revenue rebalance" + ], + "type": "u64" + }, + { + "name": "mintRedeemId", + "docs": [ + "Every mint/redeem has a monotonically increasing id. This is the next id to use" + ], + "type": "u64" + }, + { + "name": "settleId", + "type": "u64" + }, + { + "name": "minMintFee", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "tokenSupply", + "type": "u64" + }, + { + "name": "volatility", + "type": "u64" + }, + { + "name": "constituents", + "type": "u16" + }, + { + "name": "quoteConsituentIndex", + "type": "u16" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "gammaExecution", + "type": "u8" + }, + { + "name": "xi", + "type": "u8" + }, + { + "name": "targetOracleDelayFeeBpsPer10Slots", + "type": "u8" + }, + { + "name": "targetPositionDelayFeeBpsPer10Slots", + "type": "u8" + }, + { + "name": "lpPoolId", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 174 + ] + } + } + ] + } + }, + { + "name": "lpRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "action", + "type": { + "defined": { + "name": "lpAction" + } + } + }, + { + "name": "nShares", + "docs": [ + "precision: AMM_RESERVE_PRECISION" + ], + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "deltaBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "deltaQuoteAssetAmount", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "pnl", + "docs": [ + "realized pnl of the position settlement", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + } + ] + } + }, + { + "name": "lpSettleRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "recordId", + "type": "u64" + }, + { + "name": "lastTs", + "type": "i64" + }, + { + "name": "lastSlot", + "type": "u64" + }, + { + "name": "ts", + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "settleToLpAmount", + "type": "i64" + }, + { + "name": "perpAmmPnlDelta", + "type": "i64" + }, + { + "name": "perpAmmExFeeDelta", + "type": "i64" + }, + { + "name": "lpAum", + "type": "u128" + }, + { + "name": "lpPrice", + "type": "u128" + }, + { + "name": "lpPool", + "type": "pubkey" + } + ] + } + }, + { + "name": "lpSwapRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "outAmount", + "docs": [ + "precision: out market mint precision, gross fees" + ], + "type": "u128" + }, + { + "name": "inAmount", + "docs": [ + "precision: in market mint precision, gross fees" + ], + "type": "u128" + }, + { + "name": "outFee", + "docs": [ + "precision: fee on amount_out, in market mint precision" + ], + "type": "i128" + }, + { + "name": "inFee", + "docs": [ + "precision: fee on amount_in, out market mint precision" + ], + "type": "i128" + }, + { + "name": "outSpotMarketIndex", + "type": "u16" + }, + { + "name": "inSpotMarketIndex", + "type": "u16" + }, + { + "name": "outConstituentIndex", + "type": "u16" + }, + { + "name": "inConstituentIndex", + "type": "u16" + }, + { + "name": "outOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastAum", + "docs": [ + "LPPool last_aum, QUOTE_PRECISION" + ], + "type": "u128" + }, + { + "name": "lastAumSlot", + "type": "u64" + }, + { + "name": "inMarketCurrentWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "outMarketCurrentWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inMarketTargetWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "outMarketTargetWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inSwapId", + "type": "u64" + }, + { + "name": "outSwapId", + "type": "u64" + }, + { + "name": "lpPool", + "type": "pubkey" + } + ] + } + }, + { + "name": "liquidateBorrowForPerpPnlRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "marketOraclePrice", + "type": "i64" + }, + { + "name": "pnlTransfer", + "type": "u128" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + }, + { + "name": "liabilityPrice", + "type": "i64" + }, + { + "name": "liabilityTransfer", + "type": "u128" + } + ] + } + }, + { + "name": "liquidatePerpPnlForDepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "marketOraclePrice", + "type": "i64" + }, + { + "name": "pnlTransfer", + "type": "u128" + }, + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "assetPrice", + "type": "i64" + }, + { + "name": "assetTransfer", + "type": "u128" + } + ] + } + }, + { + "name": "liquidatePerpRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "oraclePrice", + "type": "i64" + }, + { + "name": "baseAssetAmount", + "type": "i64" + }, + { + "name": "quoteAssetAmount", + "type": "i64" + }, + { + "name": "lpShares", + "docs": [ + "precision: AMM_RESERVE_PRECISION" + ], + "type": "u64" + }, + { + "name": "fillRecordId", + "type": "u64" + }, + { + "name": "userOrderId", + "type": "u32" + }, + { + "name": "liquidatorOrderId", + "type": "u32" + }, + { + "name": "liquidatorFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "ifFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + } + ] + } + }, + { + "name": "liquidateSpotRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "assetPrice", + "type": "i64" + }, + { + "name": "assetTransfer", + "type": "u128" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + }, + { + "name": "liabilityPrice", + "type": "i64" + }, + { + "name": "liabilityTransfer", + "docs": [ + "precision: token mint precision" + ], + "type": "u128" + }, + { + "name": "ifFee", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + } + ] + } + }, + { + "name": "liquidationRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "liquidationType", + "type": { + "defined": { + "name": "liquidationType" + } + } + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "liquidator", + "type": "pubkey" + }, + { + "name": "marginRequirement", + "type": "u128" + }, + { + "name": "totalCollateral", + "type": "i128" + }, + { + "name": "marginFreed", + "type": "u64" + }, + { + "name": "liquidationId", + "type": "u16" + }, + { + "name": "bankrupt", + "type": "bool" + }, + { + "name": "canceledOrderIds", + "type": { + "vec": "u32" + } + }, + { + "name": "liquidatePerp", + "type": { + "defined": { + "name": "liquidatePerpRecord" + } + } + }, + { + "name": "liquidateSpot", + "type": { + "defined": { + "name": "liquidateSpotRecord" + } + } + }, + { + "name": "liquidateBorrowForPerpPnl", + "type": { + "defined": { + "name": "liquidateBorrowForPerpPnlRecord" + } + } + }, + { + "name": "liquidatePerpPnlForDeposit", + "type": { + "defined": { + "name": "liquidatePerpPnlForDepositRecord" + } + } + }, + { + "name": "perpBankruptcy", + "type": { + "defined": { + "name": "perpBankruptcyRecord" + } + } + }, + { + "name": "spotBankruptcy", + "type": { + "defined": { + "name": "spotBankruptcyRecord" + } + } + } + ] + } + }, + { + "name": "liquidationType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "liquidatePerp" + }, + { + "name": "liquidateSpot" + }, + { + "name": "liquidateBorrowForPerpPnl" + }, + { + "name": "liquidatePerpPnlForDeposit" + }, + { + "name": "perpBankruptcy" + }, + { + "name": "spotBankruptcy" + } + ] + } + }, + { + "name": "lpPoolParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxSettleQuoteAmount", + "type": { + "option": "u64" + } + }, + { + "name": "volatility", + "type": { + "option": "u64" + } + }, + { + "name": "gammaExecution", + "type": { + "option": "u8" + } + }, + { + "name": "xi", + "type": { + "option": "u8" + } + }, + { + "name": "maxAum", + "type": { + "option": "u128" + } + }, + { + "name": "whitelistMint", + "type": { + "option": "pubkey" + } + } + ] + } + }, + { + "name": "marginMode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "default" + }, + { + "name": "highLeverage" + }, + { + "name": "highLeverageMaintenance" + } + ] + } + }, + { + "name": "marketStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "initialized" + }, + { + "name": "active" + }, + { + "name": "fundingPaused" + }, + { + "name": "ammPaused" + }, + { + "name": "fillPaused" + }, + { + "name": "withdrawPaused" + }, + { + "name": "reduceOnly" + }, + { + "name": "settlement" + }, + { + "name": "delisted" + } + ] + } + }, + { + "name": "marketType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "spot" + }, + { + "name": "perp" + } + ] + } + }, + { + "name": "modifyOrderParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "direction", + "type": { + "option": { + "defined": { + "name": "positionDirection" + } + } + } + }, + { + "name": "baseAssetAmount", + "type": { + "option": "u64" + } + }, + { + "name": "price", + "type": { + "option": "u64" + } + }, + { + "name": "reduceOnly", + "type": { + "option": "bool" + } + }, + { + "name": "postOnly", + "type": { + "option": { + "defined": { + "name": "postOnlyParam" + } + } + } + }, + { + "name": "bitFlags", + "type": { + "option": "u8" + } + }, + { + "name": "maxTs", + "type": { + "option": "i64" + } + }, + { + "name": "triggerPrice", + "type": { + "option": "u64" + } + }, + { + "name": "triggerCondition", + "type": { + "option": { + "defined": { + "name": "orderTriggerCondition" + } + } + } + }, + { + "name": "oraclePriceOffset", + "type": { + "option": "i32" + } + }, + { + "name": "auctionDuration", + "type": { + "option": "u8" + } + }, + { + "name": "auctionStartPrice", + "type": { + "option": "i64" + } + }, + { + "name": "auctionEndPrice", + "type": { + "option": "i64" + } + }, + { + "name": "policy", + "type": { + "option": "u8" + } + } + ] + } + }, + { + "name": "newUserRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "docs": [ + "unix_timestamp of action" + ], + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "referrer", + "type": "pubkey" + } + ] + } + }, + { + "name": "openbookV2FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" + }, + { + "name": "openbookV2ProgramId", + "type": "pubkey" + }, + { + "name": "openbookV2Market", + "type": "pubkey" + }, + { + "name": "openbookV2MarketAuthority", + "type": "pubkey" + }, + { + "name": "openbookV2EventHeap", + "type": "pubkey" + }, + { + "name": "openbookV2Bids", + "type": "pubkey" + }, + { + "name": "openbookV2Asks", + "type": "pubkey" + }, + { + "name": "openbookV2BaseVault", + "type": "pubkey" + }, + { + "name": "openbookV2QuoteVault", + "type": "pubkey" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fulfillmentType", + "type": { + "defined": { + "name": "spotFulfillmentType" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "oracleGuardRails", + "type": { + "kind": "struct", + "fields": [ + { + "name": "priceDivergence", + "type": { + "defined": { + "name": "priceDivergenceGuardRails" + } + } + }, + { + "name": "validity", + "type": { + "defined": { + "name": "validityGuardRails" + } + } + } + ] + } + }, + { + "name": "oracleSource", + "type": { + "kind": "enum", + "variants": [ + { + "name": "pyth" + }, + { + "name": "switchboard" + }, + { + "name": "quoteAsset" + }, + { + "name": "pyth1K" + }, + { + "name": "pyth1M" + }, + { + "name": "pythStableCoin" + }, + { + "name": "prelaunch" + }, + { + "name": "pythPull" + }, + { + "name": "pyth1KPull" + }, + { + "name": "pyth1MPull" + }, + { + "name": "pythStableCoinPull" + }, + { + "name": "switchboardOnDemand" + }, + { + "name": "pythLazer" + }, + { + "name": "pythLazer1K" + }, + { + "name": "pythLazer1M" + }, + { + "name": "pythLazerStableCoin" + } + ] + } + }, + { + "name": "order", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "slot", + "docs": [ + "The slot the order was placed" + ], + "type": "u64" + }, + { + "name": "price", + "docs": [ + "The limit price for the order (can be 0 for market orders)", + "For orders with an auction, this price isn't used until the auction is complete", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "baseAssetAmount", + "docs": [ + "The size of the order", + "precision for perps: BASE_PRECISION", + "precision for spot: token mint precision" + ], + "type": "u64" + }, + { + "name": "baseAssetAmountFilled", + "docs": [ + "The amount of the order filled", + "precision for perps: BASE_PRECISION", + "precision for spot: token mint precision" + ], + "type": "u64" + }, + { + "name": "quoteAssetAmountFilled", + "docs": [ + "The amount of quote filled for the order", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "triggerPrice", + "docs": [ + "At what price the order will be triggered. Only relevant for trigger orders", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "auctionStartPrice", + "docs": [ + "The start price for the auction. Only relevant for market/oracle orders", + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "auctionEndPrice", + "docs": [ + "The end price for the auction. Only relevant for market/oracle orders", + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "maxTs", + "docs": [ + "The time when the order will expire" + ], + "type": "i64" + }, + { + "name": "oraclePriceOffset", + "docs": [ + "If set, the order limit price is the oracle price + this offset", + "precision: PRICE_PRECISION" + ], + "type": "i32" + }, + { + "name": "orderId", + "docs": [ + "The id for the order. Each users has their own order id space" + ], + "type": "u32" + }, + { + "name": "marketIndex", + "docs": [ + "The perp/spot market index" + ], + "type": "u16" + }, + { + "name": "status", + "docs": [ + "Whether the order is open or unused" + ], + "type": { + "defined": { + "name": "orderStatus" + } + } + }, + { + "name": "orderType", + "docs": [ + "The type of order" + ], + "type": { + "defined": { + "name": "orderType" + } + } + }, + { + "name": "marketType", + "docs": [ + "Whether market is spot or perp" + ], + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "userOrderId", + "docs": [ + "User generated order id. Can make it easier to place/cancel orders" + ], + "type": "u8" + }, + { + "name": "existingPositionDirection", + "docs": [ + "What the users position was when the order was placed" + ], + "type": { + "defined": { + "name": "positionDirection" + } + } + }, + { + "name": "direction", + "docs": [ + "Whether the user is going long or short. LONG = bid, SHORT = ask" + ], + "type": { + "defined": { + "name": "positionDirection" + } + } + }, + { + "name": "reduceOnly", + "docs": [ + "Whether the order is allowed to only reduce position size" + ], + "type": "bool" + }, + { + "name": "postOnly", + "docs": [ + "Whether the order must be a maker" + ], + "type": "bool" + }, + { + "name": "immediateOrCancel", + "docs": [ + "Whether the order must be canceled the same slot it is placed" + ], + "type": "bool" + }, + { + "name": "triggerCondition", + "docs": [ + "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders" + ], + "type": { + "defined": { + "name": "orderTriggerCondition" + } + } + }, + { + "name": "auctionDuration", + "docs": [ + "How many slots the auction lasts" + ], + "type": "u8" + }, + { + "name": "postedSlotTail", + "docs": [ + "Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)" + ], + "type": "u8" + }, + { + "name": "bitFlags", + "docs": [ + "Bitflags for further classification", + "0: is_signed_message" + ], + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 1 + ] + } + } + ] + } + }, + { + "name": "orderAction", + "type": { + "kind": "enum", + "variants": [ + { + "name": "place" + }, + { + "name": "cancel" + }, + { + "name": "fill" + }, + { + "name": "trigger" + }, + { + "name": "expire" + } + ] + } + }, + { + "name": "orderActionExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "none" + }, + { + "name": "insufficientFreeCollateral" + }, + { + "name": "oraclePriceBreachedLimitPrice" + }, + { + "name": "marketOrderFilledToLimitPrice" + }, + { + "name": "orderExpired" + }, + { + "name": "liquidation" + }, + { + "name": "orderFilledWithAmm" + }, + { + "name": "orderFilledWithAmmJit" + }, + { + "name": "orderFilledWithMatch" + }, + { + "name": "orderFilledWithMatchJit" + }, + { + "name": "marketExpired" + }, + { + "name": "riskingIncreasingOrder" + }, + { + "name": "reduceOnlyOrderIncreasedPosition" + }, + { + "name": "orderFillWithSerum" + }, + { + "name": "noBorrowLiquidity" + }, + { + "name": "orderFillWithPhoenix" + }, + { + "name": "orderFilledWithAmmJitLpSplit" + }, + { + "name": "orderFilledWithLpJit" + }, + { + "name": "deriskLp" + }, + { + "name": "orderFilledWithOpenbookV2" + }, + { + "name": "transferPerpPosition" + } + ] + } + }, + { + "name": "orderActionRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "action", + "type": { + "defined": { + "name": "orderAction" + } + } + }, + { + "name": "actionExplanation", + "type": { + "defined": { + "name": "orderActionExplanation" + } + } + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "marketType", + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "filler", + "type": { + "option": "pubkey" + } + }, + { + "name": "fillerReward", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "fillRecordId", + "type": { + "option": "u64" + } + }, + { + "name": "baseAssetAmountFilled", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "quoteAssetAmountFilled", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "takerFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "i64" + } + }, + { + "name": "referrerReward", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u32" + } + }, + { + "name": "quoteAssetAmountSurplus", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "i64" + } + }, + { + "name": "spotFulfillmentMethodFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "taker", + "type": { + "option": "pubkey" + } + }, + { + "name": "takerOrderId", + "type": { + "option": "u32" + } + }, + { + "name": "takerOrderDirection", + "type": { + "option": { + "defined": { + "name": "positionDirection" + } + } + } + }, + { + "name": "takerOrderBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "takerOrderCumulativeBaseAssetAmountFilled", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "takerOrderCumulativeQuoteAssetAmountFilled", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "maker", + "type": { + "option": "pubkey" + } + }, + { + "name": "makerOrderId", + "type": { + "option": "u32" + } + }, + { + "name": "makerOrderDirection", + "type": { + "option": { + "defined": { + "name": "positionDirection" + } + } + } + }, + { + "name": "makerOrderBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerOrderCumulativeBaseAssetAmountFilled", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerOrderCumulativeQuoteAssetAmountFilled", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "oraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "bitFlags", + "docs": [ + "Bit flags:", + "0: is_signed_message" + ], + "type": "u8" + }, + { + "name": "takerExistingQuoteEntryAmount", + "docs": [ + "precision: QUOTE_PRECISION", + "Only Some if the taker reduced position" + ], + "type": { + "option": "u64" + } + }, + { + "name": "takerExistingBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION", + "Only Some if the taker flipped position direction" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerExistingQuoteEntryAmount", + "docs": [ + "precision: QUOTE_PRECISION", + "Only Some if the maker reduced position" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerExistingBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION", + "Only Some if the maker flipped position direction" + ], + "type": { + "option": "u64" + } + }, + { + "name": "triggerPrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "builderIdx", + "docs": [ + "the idx of the builder in the taker's [`RevenueShareEscrow`] account" + ], + "type": { + "option": "u8" + } + }, + { + "name": "builderFee", + "docs": [ + "precision: QUOTE_PRECISION builder fee paid by the taker" + ], + "type": { + "option": "u64" + } + } + ] + } + }, + { + "name": "orderFillerRewardStructure", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rewardNumerator", + "type": "u32" + }, + { + "name": "rewardDenominator", + "type": "u32" + }, + { + "name": "timeBasedRewardLowerBound", + "type": { + "defined": { + "name": "u128" + } + } + } + ] + } + }, + { + "name": "orderParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "orderType", + "type": { + "defined": { + "name": "orderType" + } + } + }, + { + "name": "marketType", + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "direction", + "type": { + "defined": { + "name": "positionDirection" + } + } + }, + { + "name": "userOrderId", + "type": "u8" + }, + { + "name": "baseAssetAmount", + "type": "u64" + }, + { + "name": "price", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "reduceOnly", + "type": "bool" + }, + { + "name": "postOnly", + "type": { + "defined": { + "name": "postOnlyParam" + } + } + }, + { + "name": "bitFlags", + "type": "u8" + }, + { + "name": "maxTs", + "type": { + "option": "i64" + } + }, + { + "name": "triggerPrice", + "type": { + "option": "u64" + } + }, + { + "name": "triggerCondition", + "type": { + "defined": { + "name": "orderTriggerCondition" + } + } + }, + { + "name": "oraclePriceOffset", + "type": { + "option": "i32" + } + }, + { + "name": "auctionDuration", + "type": { + "option": "u8" + } + }, + { + "name": "auctionStartPrice", + "type": { + "option": "i64" + } + }, + { + "name": "auctionEndPrice", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "orderRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "order", + "type": { + "defined": { + "name": "order" + } + } + } + ] + } + }, + { + "name": "orderStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "init" + }, + { + "name": "open" + }, + { + "name": "filled" + }, + { + "name": "canceled" + } + ] + } + }, + { + "name": "orderTriggerCondition", + "type": { + "kind": "enum", + "variants": [ + { + "name": "above" + }, + { + "name": "below" + }, + { + "name": "triggeredAbove" + }, + { + "name": "triggeredBelow" + } + ] + } + }, + { + "name": "orderType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "market" + }, + { + "name": "limit" + }, + { + "name": "triggerMarket" + }, + { + "name": "triggerLimit" + }, + { + "name": "oracle" + } + ] + } + }, + { + "name": "overrideAmmCacheParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quoteOwedFromLpPool", + "type": { + "option": "i64" + } + }, + { + "name": "lastSettleSlot", + "type": { + "option": "u64" + } + }, + { + "name": "lastFeePoolTokenAmount", + "type": { + "option": "u128" + } + }, + { + "name": "lastNetPnlPoolTokenAmount", + "type": { + "option": "i128" + } + }, + { + "name": "ammPositionScalar", + "type": { + "option": "u8" + } + }, + { + "name": "ammInventoryLimit", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "perpBankruptcyRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "pnl", + "type": "i128" + }, + { + "name": "ifPayment", + "type": "u128" + }, + { + "name": "clawbackUser", + "type": { + "option": "pubkey" + } + }, + { + "name": "clawbackUserPayment", + "type": { + "option": "u128" + } + }, + { + "name": "cumulativeFundingRateDelta", + "type": "i128" + } + ] + } + }, + { + "name": "perpMarket", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "The perp market's address. It is a pda of the market index" + ], + "type": "pubkey" + }, + { + "name": "amm", + "docs": [ + "The automated market maker" + ], + "type": { + "defined": { + "name": "amm" + } + } + }, + { + "name": "pnlPool", + "docs": [ + "The market's pnl pool. When users settle negative pnl, the balance increases.", + "When users settle positive pnl, the balance decreases. Can not go negative." + ], + "type": { + "defined": { + "name": "poolBalance" + } + } + }, + { + "name": "name", + "docs": [ + "Encoded display name for the perp market e.g. SOL-PERP" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "insuranceClaim", + "docs": [ + "The perp market's claim on the insurance fund" + ], + "type": { + "defined": { + "name": "insuranceClaim" + } + } + }, + { + "name": "unrealizedPnlMaxImbalance", + "docs": [ + "The max pnl imbalance before positive pnl asset weight is discounted", + "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", + "the amm has negative pnl and the initial asset weight for positive pnl is discounted", + "precision = QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "expiryTs", + "docs": [ + "The ts when the market will be expired. Only set if market is in reduce only mode" + ], + "type": "i64" + }, + { + "name": "expiryPrice", + "docs": [ + "The price at which positions will be settled. Only set if market is expired", + "precision = PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "nextFillRecordId", + "docs": [ + "Every trade has a fill record id. This is the next id to be used" + ], + "type": "u64" + }, + { + "name": "nextFundingRateRecordId", + "docs": [ + "Every funding rate update has a record id. This is the next id to be used" + ], + "type": "u64" + }, + { + "name": "nextCurveRecordId", + "docs": [ + "Every amm k updated has a record id. This is the next id to be used" + ], + "type": "u64" + }, + { + "name": "imfFactor", + "docs": [ + "The initial margin fraction factor. Used to increase margin ratio for large positions", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "unrealizedPnlImfFactor", + "docs": [ + "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "liquidatorFee", + "docs": [ + "The fee the liquidator is paid for taking over perp position", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "docs": [ + "The fee the insurance fund receives from liquidation", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" + }, + { + "name": "marginRatioInitial", + "docs": [ + "The margin ratio which determines how much collateral is required to open a position", + "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "marginRatioMaintenance", + "docs": [ + "The margin ratio which determines when a user will be liquidated", + "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", + "else they will be liquidated", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "unrealizedPnlInitialAssetWeight", + "docs": [ + "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "unrealizedPnlMaintenanceAssetWeight", + "docs": [ + "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "numberOfUsersWithBase", + "docs": [ + "number of users in a position (base)" + ], + "type": "u32" + }, + { + "name": "numberOfUsers", + "docs": [ + "number of users in a position (pnl) or pnl (quote)" + ], + "type": "u32" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "status", + "docs": [ + "Whether a market is active, reduce only, expired, etc", + "Affects whether users can open/close positions" + ], + "type": { + "defined": { + "name": "marketStatus" + } + } + }, + { + "name": "contractType", + "docs": [ + "Currently only Perpetual markets are supported" + ], + "type": { + "defined": { + "name": "contractType" + } + } + }, + { + "name": "contractTier", + "docs": [ + "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", + "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" + ], + "type": { + "defined": { + "name": "contractTier" + } + } + }, + { + "name": "pausedOperations", + "type": "u8" + }, + { + "name": "quoteSpotMarketIndex", + "docs": [ + "The spot market that pnl is settled in" + ], + "type": "u16" + }, + { + "name": "feeAdjustment", + "docs": [ + "Between -100 and 100, represents what % to increase/decrease the fee by", + "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", + "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" + ], + "type": "i16" + }, + { + "name": "fuelBoostPosition", + "docs": [ + "fuel multiplier for perp funding", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostTaker", + "docs": [ + "fuel multiplier for perp taker", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostMaker", + "docs": [ + "fuel multiplier for perp maker", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "poolId", + "type": "u8" + }, + { + "name": "highLeverageMarginRatioInitial", + "type": "u16" + }, + { + "name": "highLeverageMarginRatioMaintenance", + "type": "u16" + }, + { + "name": "protectedMakerLimitPriceDivisor", + "type": "u8" + }, + { + "name": "protectedMakerDynamicDivisor", + "type": "u8" + }, + { + "name": "lpFeeTransferScalar", + "type": "u8" + }, + { + "name": "lpStatus", + "type": "u8" + }, + { + "name": "lpPausedOperations", + "type": "u8" + }, + { + "name": "lpExchangeFeeExcluscionScalar", + "type": "u8" + }, + { + "name": "lastFillPrice", + "type": "u64" + }, + { + "name": "lpPoolId", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 23 + ] + } + } + ] + } + }, + { + "name": "perpPosition", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lastCumulativeFundingRate", + "docs": [ + "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "baseAssetAmount", + "docs": [ + "the size of the users perp position", + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "quoteAssetAmount", + "docs": [ + "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees", + "Updated when the user open/closes position or settles pnl. Includes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "quoteBreakEvenAmount", + "docs": [ + "The amount of quote the user would need to exit their position at to break even", + "Updated when the user open/closes position or settles pnl. Includes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "quoteEntryAmount", + "docs": [ + "The amount quote the user entered the position with. Equal to base asset amount * avg entry price", + "Updated when the user open/closes position. Excludes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "openBids", + "docs": [ + "The amount of non reduce only trigger orders the user has open", + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "openAsks", + "docs": [ + "The amount of non reduce only trigger orders the user has open", + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "settledPnl", + "docs": [ + "The amount of pnl settled in this market since opening the position", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lpShares", + "docs": [ + "The number of lp (liquidity provider) shares the user has in this perp market", + "LP shares allow users to provide liquidity via the AMM", + "precision: BASE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastBaseAssetAmountPerLp", + "docs": [ + "The last base asset amount per lp the amm had", + "Used to settle the users lp position", + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastQuoteAssetAmountPerLp", + "docs": [ + "The last quote asset amount per lp the amm had", + "Used to settle the users lp position", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "maxMarginRatio", + "type": "u16" + }, + { + "name": "marketIndex", + "docs": [ + "The market index for the perp market" + ], + "type": "u16" + }, + { + "name": "openOrders", + "docs": [ + "The number of open orders" + ], + "type": "u8" + }, + { + "name": "perLpBase", + "type": "i8" + } + ] + } + }, + { + "name": "phoenixV1FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" + }, + { + "name": "phoenixProgramId", + "type": "pubkey" + }, + { + "name": "phoenixLogAuthority", + "type": "pubkey" + }, + { + "name": "phoenixMarket", + "type": "pubkey" + }, + { + "name": "phoenixBaseVault", + "type": "pubkey" + }, + { + "name": "phoenixQuoteVault", + "type": "pubkey" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fulfillmentType", + "type": { + "defined": { + "name": "spotFulfillmentType" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "poolBalance", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "scaledBalance", + "docs": [ + "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", + "deposit interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "marketIndex", + "docs": [ + "The spot market the pool is for" + ], + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 6 + ] + } + } + ] + } + }, + { + "name": "positionDirection", + "type": { + "kind": "enum", + "variants": [ + { + "name": "long" + }, + { + "name": "short" + } + ] + } + }, + { + "name": "postOnlyParam", + "type": { + "kind": "enum", + "variants": [ + { + "name": "none" + }, + { + "name": "mustPostOnly" + }, + { + "name": "tryPostOnly" + }, + { + "name": "slide" + } + ] + } + }, + { + "name": "prelaunchOracle", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "i64" + }, + { + "name": "maxPrice", + "type": "i64" + }, + { + "name": "confidence", + "type": "u64" + }, + { + "name": "lastUpdateSlot", + "type": "u64" + }, + { + "name": "ammLastUpdateSlot", + "type": "u64" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 70 + ] + } + } + ] + } + }, + { + "name": "prelaunchOracleParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "price", + "type": { + "option": "i64" + } + }, + { + "name": "maxPrice", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "priceDivergenceGuardRails", + "type": { + "kind": "struct", + "fields": [ + { + "name": "markOraclePercentDivergence", + "type": "u64" + }, + { + "name": "oracleTwap5minPercentDivergence", + "type": "u64" + } + ] + } + }, + { + "name": "protectedMakerModeConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "currentUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 31 + ] + } + } + ] + } + }, + { + "name": "pythLazerOracle", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "i64" + }, + { + "name": "publishTime", + "type": "u64" + }, + { + "name": "postedSlot", + "type": "u64" + }, + { + "name": "exponent", + "type": "i32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "conf", + "type": "u64" + } + ] + } + }, + { + "name": "referrerName", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "userStats", + "type": "pubkey" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "revenueShare", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "rust", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "the owner of this account, a builder or referrer" + ], + "type": "pubkey" + }, + { + "name": "totalReferrerRewards", + "type": "u64" + }, + { + "name": "totalBuilderRewards", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 18 + ] + } + } + ] + } + }, + { + "name": "revenueShareEscrow", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "the owner of this account, a user" + ], + "type": "pubkey" + }, + { + "name": "referrer", + "type": "pubkey" + }, + { + "name": "referrerBoostExpireTs", + "type": "u32" + }, + { + "name": "referrerRewardOffset", + "type": "i8" + }, + { + "name": "refereeFeeNumeratorOffset", + "type": "i8" + }, + { + "name": "referrerBoostNumerator", + "type": "i8" + }, + { + "name": "reservedFixed", + "type": { + "array": [ + "u8", + 17 + ] + } + }, + { + "name": "padding0", + "type": "u32" + }, + { + "name": "orders", + "type": { + "vec": { + "defined": { + "name": "revenueShareOrder" + } + } + } + }, + { + "name": "padding1", + "type": "u32" + }, + { + "name": "approvedBuilders", + "type": { + "vec": { + "defined": { + "name": "builderInfo" + } + } + } + } + ] + } + }, + { + "name": "revenueShareOrder", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "feesAccrued", + "docs": [ + "fees accrued so far for this order slot. This is not exclusively fees from this order_id", + "and may include fees from other orders in the same market. This may be swept to the", + "builder's SpotPosition during settle_pnl." + ], + "type": "u64" + }, + { + "name": "orderId", + "docs": [ + "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open" + ], + "type": "u32" + }, + { + "name": "feeTenthBps", + "docs": [ + "the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%" + ], + "type": "u16" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "subAccountId", + "docs": [ + "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open" + ], + "type": "u16" + }, + { + "name": "builderIdx", + "docs": [ + "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", + "if bit_flag = Referral." + ], + "type": "u8" + }, + { + "name": "bitFlags", + "docs": [ + "bitflags that describe the state of the order.", + "[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.", + "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", + "[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.", + "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", + "[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.", + "If it is set, no other bitflag should be set." + ], + "type": "u8" + }, + { + "name": "userOrderIndex", + "docs": [ + "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches." + ], + "type": "u8" + }, + { + "name": "marketType", + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 10 + ] + } + } + ] + } + }, + { + "name": "revenueShareSettleRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "builder", + "type": { + "option": "pubkey" + } + }, + { + "name": "referrer", + "type": { + "option": "pubkey" + } + }, + { + "name": "feeSettled", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "marketType", + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "builderSubAccountId", + "type": "u16" + }, + { + "name": "builderTotalReferrerRewards", + "type": "u64" + }, + { + "name": "builderTotalBuilderRewards", + "type": "u64" + } + ] + } + }, + { + "name": "serumV3FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" + }, + { + "name": "serumProgramId", + "type": "pubkey" + }, + { + "name": "serumMarket", + "type": "pubkey" + }, + { + "name": "serumRequestQueue", + "type": "pubkey" + }, + { + "name": "serumEventQueue", + "type": "pubkey" + }, + { + "name": "serumBids", + "type": "pubkey" + }, + { + "name": "serumAsks", + "type": "pubkey" + }, + { + "name": "serumBaseVault", + "type": "pubkey" + }, + { + "name": "serumQuoteVault", + "type": "pubkey" + }, + { + "name": "serumOpenOrders", + "type": "pubkey" + }, + { + "name": "serumSignerNonce", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fulfillmentType", + "type": { + "defined": { + "name": "spotFulfillmentType" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "settlePnlExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "none" + }, + { + "name": "expiredPosition" + } + ] + } + }, + { + "name": "settlePnlMode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "mustSettle" + }, + { + "name": "trySettle" + } + ] + } + }, + { + "name": "settlePnlRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "pnl", + "type": "i128" + }, + { + "name": "baseAssetAmount", + "type": "i64" + }, + { + "name": "quoteAssetAmountAfter", + "type": "i64" + }, + { + "name": "quoteEntryAmount", + "type": "i64" + }, + { + "name": "settlePrice", + "type": "i64" + }, + { + "name": "explanation", + "type": { + "defined": { + "name": "settlePnlExplanation" + } + } + } + ] + } + }, + { + "name": "signedMsgOrderId", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "uuid", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "maxSlot", + "type": "u64" + }, + { + "name": "orderId", + "type": "u32" + }, + { + "name": "padding", + "type": "u32" + } + ] + } + }, + { + "name": "signedMsgOrderRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "hash", + "type": "string" + }, + { + "name": "matchingOrderParams", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "userOrderId", + "type": "u32" + }, + { + "name": "signedMsgOrderMaxSlot", + "type": "u64" + }, + { + "name": "signedMsgOrderUuid", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "ts", + "type": "i64" + } + ] + } + }, + { + "name": "signedMsgUserOrders", + "docs": [ + "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authorityPubkey", + "type": "pubkey" + }, + { + "name": "padding", + "type": "u32" + }, + { + "name": "signedMsgOrderData", + "type": { + "vec": { + "defined": { + "name": "signedMsgOrderId" + } + } + } + } + ] + } + }, + { + "name": "signedMsgWsDelegates", + "docs": [ + "* Used to store authenticated delegates for swift-like ws connections" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "delegates", + "type": { + "vec": "pubkey" + } + } + ] + } + }, + { + "name": "spotBalanceType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "deposit" + }, + { + "name": "borrow" + } + ] + } + }, + { + "name": "spotBankruptcyRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "borrowAmount", + "type": "u128" + }, + { + "name": "ifPayment", + "type": "u128" + }, + { + "name": "cumulativeDepositInterestDelta", + "type": "u128" + } + ] + } + }, + { + "name": "spotFulfillmentConfigStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "enabled" + }, + { + "name": "disabled" + } + ] + } + }, + { + "name": "spotFulfillmentType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "serumV3" + }, + { + "name": "match" + }, + { + "name": "phoenixV1" + }, + { + "name": "openbookV2" + } + ] + } + }, + { + "name": "spotInterestRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "depositBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulativeDepositInterest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "borrowBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulativeBorrowInterest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "optimalUtilization", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + }, + { + "name": "optimalBorrowRate", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + }, + { + "name": "maxBorrowRate", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + } + ] + } + }, + { + "name": "spotMarket", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "The address of the spot market. It is a pda of the market index" + ], + "type": "pubkey" + }, + { + "name": "oracle", + "docs": [ + "The oracle used to price the markets deposits/borrows" + ], + "type": "pubkey" + }, + { + "name": "mint", + "docs": [ + "The token mint of the market" + ], + "type": "pubkey" + }, + { + "name": "vault", + "docs": [ + "The vault used to store the market's deposits", + "The amount in the vault should be equal to or greater than deposits - borrows" + ], + "type": "pubkey" + }, + { + "name": "name", + "docs": [ + "The encoded display name for the market e.g. SOL" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "historicalOracleData", + "type": { + "defined": { + "name": "historicalOracleData" + } + } + }, + { + "name": "historicalIndexData", + "type": { + "defined": { + "name": "historicalIndexData" + } + } + }, + { + "name": "revenuePool", + "docs": [ + "Revenue the protocol has collected in this markets token", + "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" + ], + "type": { + "defined": { + "name": "poolBalance" + } + } + }, + { + "name": "spotFeePool", + "docs": [ + "The fees collected from swaps between this market and the quote market", + "Is settled to the quote markets revenue pool" + ], + "type": { + "defined": { + "name": "poolBalance" + } + } + }, + { + "name": "insuranceFund", + "docs": [ + "Details on the insurance fund covering bankruptcies in this markets token", + "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" + ], + "type": { + "defined": { + "name": "insuranceFund" + } + } + }, + { + "name": "totalSpotFee", + "docs": [ + "The total spot fees collected for this market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "depositBalance", + "docs": [ + "The sum of the scaled balances for deposits across users and pool balances", + "To convert to the deposit token amount, multiply by the cumulative deposit interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "borrowBalance", + "docs": [ + "The sum of the scaled balances for borrows across users and pool balances", + "To convert to the borrow token amount, multiply by the cumulative borrow interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeDepositInterest", + "docs": [ + "The cumulative interest earned by depositors", + "Used to calculate the deposit token amount from the deposit balance", + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeBorrowInterest", + "docs": [ + "The cumulative interest earned by borrowers", + "Used to calculate the borrow token amount from the borrow balance", + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalSocialLoss", + "docs": [ + "The total socialized loss from borrows, in the mint's token", + "precision: token mint precision" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalQuoteSocialLoss", + "docs": [ + "The total socialized loss from borrows, in the quote market's token", + "preicision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "withdrawGuardThreshold", + "docs": [ + "no withdraw limits/guards when deposits below this threshold", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "maxTokenDeposits", + "docs": [ + "The max amount of token deposits in this market", + "0 if there is no limit", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "depositTokenTwap", + "docs": [ + "24hr average of deposit token amount", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "borrowTokenTwap", + "docs": [ + "24hr average of borrow token amount", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "utilizationTwap", + "docs": [ + "24hr average of utilization", + "which is borrow amount over token amount", + "precision: SPOT_UTILIZATION_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastInterestTs", + "docs": [ + "Last time the cumulative deposit and borrow interest was updated" + ], + "type": "u64" + }, + { + "name": "lastTwapTs", + "docs": [ + "Last time the deposit/borrow/utilization averages were updated" + ], + "type": "u64" + }, + { + "name": "expiryTs", + "docs": [ + "The time the market is set to expire. Only set if market is in reduce only mode" + ], + "type": "i64" + }, + { + "name": "orderStepSize", + "docs": [ + "Spot orders must be a multiple of the step size", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "orderTickSize", + "docs": [ + "Spot orders must be a multiple of the tick size", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "minOrderSize", + "docs": [ + "The minimum order size", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "maxPositionSize", + "docs": [ + "The maximum spot position size", + "if the limit is 0, there is no limit", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "nextFillRecordId", + "docs": [ + "Every spot trade has a fill record id. This is the next id to use" + ], + "type": "u64" + }, + { + "name": "nextDepositRecordId", + "docs": [ + "Every deposit has a deposit record id. This is the next id to use" + ], + "type": "u64" + }, + { + "name": "initialAssetWeight", + "docs": [ + "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", + "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "maintenanceAssetWeight", + "docs": [ + "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", + "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "initialLiabilityWeight", + "docs": [ + "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", + "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "maintenanceLiabilityWeight", + "docs": [ + "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", + "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "imfFactor", + "docs": [ + "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "liquidatorFee", + "docs": [ + "The fee the liquidator is paid for taking over borrow/deposit", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "docs": [ + "The fee the insurance fund receives from liquidation", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" + }, + { + "name": "optimalUtilization", + "docs": [ + "The optimal utilization rate for this market.", + "Used to determine the markets borrow rate", + "precision: SPOT_UTILIZATION_PRECISION" + ], + "type": "u32" + }, + { + "name": "optimalBorrowRate", + "docs": [ + "The borrow rate for this market when the market has optimal utilization", + "precision: SPOT_RATE_PRECISION" + ], + "type": "u32" + }, + { + "name": "maxBorrowRate", + "docs": [ + "The borrow rate for this market when the market has 1000 utilization", + "precision: SPOT_RATE_PRECISION" + ], + "type": "u32" + }, + { + "name": "decimals", + "docs": [ + "The market's token mint's decimals. To from decimals to a precision, 10^decimals" + ], + "type": "u32" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "ordersEnabled", + "docs": [ + "Whether or not spot trading is enabled" + ], + "type": "bool" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "marketStatus" + } + } + }, + { + "name": "assetTier", + "docs": [ + "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" + ], + "type": { + "defined": { + "name": "assetTier" + } + } + }, + { + "name": "pausedOperations", + "type": "u8" + }, + { + "name": "ifPausedOperations", + "type": "u8" + }, + { + "name": "feeAdjustment", + "type": "i16" + }, + { + "name": "maxTokenBorrowsFraction", + "docs": [ + "What fraction of max_token_deposits", + "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", + "precision: X/10000" + ], + "type": "u16" + }, + { + "name": "flashLoanAmount", + "docs": [ + "For swaps, the amount of token loaned out in the begin_swap ix", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "flashLoanInitialTokenAmount", + "docs": [ + "For swaps, the amount in the users token account in the begin_swap ix", + "Used to calculate how much of the token left the system in end_swap ix", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "totalSwapFee", + "docs": [ + "The total fees received from swaps", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "scaleInitialAssetWeightStart", + "docs": [ + "When to begin scaling down the initial asset weight", + "disabled when 0", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "minBorrowRate", + "docs": [ + "The min borrow rate for this market when the market regardless of utilization", + "1 => 1/200 => .5%", + "precision: X/200" + ], + "type": "u8" + }, + { + "name": "fuelBoostDeposits", + "docs": [ + "fuel multiplier for spot deposits", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostBorrows", + "docs": [ + "fuel multiplier for spot borrows", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostTaker", + "docs": [ + "fuel multiplier for spot taker", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostMaker", + "docs": [ + "fuel multiplier for spot maker", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostInsurance", + "docs": [ + "fuel multiplier for spot insurance stake", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "tokenProgramFlag", + "type": "u8" + }, + { + "name": "poolId", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 40 + ] + } + } + ] + } + }, + { + "name": "spotMarketVaultDepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "depositBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulativeDepositInterestBefore", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulativeDepositInterestAfter", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "depositTokenAmountBefore", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "spotPosition", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "scaledBalance", + "docs": [ + "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", + "interest of corresponding market.", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u64" + }, + { + "name": "openBids", + "docs": [ + "How many spot non reduce only trigger orders the user has open", + "precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "openAsks", + "docs": [ + "How many spot non reduce only trigger orders the user has open", + "precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "cumulativeDeposits", + "docs": [ + "The cumulative deposits/borrows a user has made into a market", + "precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "marketIndex", + "docs": [ + "The market index of the corresponding spot market" + ], + "type": "u16" + }, + { + "name": "balanceType", + "docs": [ + "Whether the position is deposit or borrow" + ], + "type": { + "defined": { + "name": "spotBalanceType" + } + } + }, + { + "name": "openOrders", + "docs": [ + "Number of open orders" + ], + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "stakeAction", + "type": { + "kind": "enum", + "variants": [ + { + "name": "stake" + }, + { + "name": "unstakeRequest" + }, + { + "name": "unstakeCancelRequest" + }, + { + "name": "unstake" + }, + { + "name": "unstakeTransfer" + }, + { + "name": "stakeTransfer" + }, + { + "name": "adminDeposit" + } + ] + } + }, + { + "name": "state", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "admin", + "type": "pubkey" + }, + { + "name": "whitelistMint", + "type": "pubkey" + }, + { + "name": "discountMint", + "type": "pubkey" + }, + { + "name": "signer", + "type": "pubkey" + }, + { + "name": "srmVault", + "type": "pubkey" + }, + { + "name": "perpFeeStructure", + "type": { + "defined": { + "name": "feeStructure" + } + } + }, + { + "name": "spotFeeStructure", + "type": { + "defined": { + "name": "feeStructure" + } + } + }, + { + "name": "oracleGuardRails", + "type": { + "defined": { + "name": "oracleGuardRails" + } + } + }, + { + "name": "numberOfAuthorities", + "type": "u64" + }, + { + "name": "numberOfSubAccounts", + "type": "u64" + }, + { + "name": "lpCooldownTime", + "type": "u64" + }, + { + "name": "liquidationMarginBufferRatio", + "type": "u32" + }, + { + "name": "settlementDuration", + "type": "u16" + }, + { + "name": "numberOfMarkets", + "type": "u16" + }, + { + "name": "numberOfSpotMarkets", + "type": "u16" + }, + { + "name": "signerNonce", + "type": "u8" + }, + { + "name": "minPerpAuctionDuration", + "type": "u8" + }, + { + "name": "defaultMarketOrderTimeInForce", + "type": "u8" + }, + { + "name": "defaultSpotAuctionDuration", + "type": "u8" + }, + { + "name": "exchangeStatus", + "type": "u8" + }, + { + "name": "liquidationDuration", + "type": "u8" + }, + { + "name": "initialPctToLiquidate", + "type": "u16" + }, + { + "name": "maxNumberOfSubAccounts", + "type": "u16" + }, + { + "name": "maxInitializeUserFee", + "type": "u16" + }, + { + "name": "featureBitFlags", + "type": "u8" + }, + { + "name": "lpPoolFeatureBitFlags", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "swapRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "amountOut", + "docs": [ + "precision: out market mint precision" + ], + "type": "u64" + }, + { + "name": "amountIn", + "docs": [ + "precision: in market mint precision" + ], + "type": "u64" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "fee", + "type": "u64" + } + ] + } + }, + { + "name": "swapReduceOnly", + "type": { + "kind": "enum", + "variants": [ + { + "name": "in" + }, + { + "name": "out" + } + ] + } + }, + { + "name": "targetsDatum", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "costToTradeBps", + "type": "i32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "targetBase", + "type": "i64" + }, + { + "name": "lastOracleSlot", + "type": "u64" + }, + { + "name": "lastPositionSlot", + "type": "u64" + } + ] + } + }, + { + "name": "transferProtocolIfSharesToRevenuePoolRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "shares", + "type": "u128" + }, + { + "name": "ifVaultAmountBefore", + "type": "u64" + }, + { + "name": "protocolSharesBefore", + "type": "u128" + }, + { + "name": "transferAmount", + "type": "u64" + } + ] + } + }, + { + "name": "updatePerpMarketSummaryStatsParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quoteAssetAmountWithUnsettledLp", + "type": { + "option": "i64" + } + }, + { + "name": "netUnsettledFundingPnl", + "type": { + "option": "i64" + } + }, + { + "name": "updateAmmSummaryStats", + "type": { + "option": "bool" + } + }, + { + "name": "excludeTotalLiqFee", + "type": { + "option": "bool" + } + } + ] + } + }, + { + "name": "user", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The owner/authority of the account" + ], + "type": "pubkey" + }, + { + "name": "delegate", + "docs": [ + "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw" + ], + "type": "pubkey" + }, + { + "name": "name", + "docs": [ + "Encoded display name e.g. \"toly\"" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "spotPositions", + "docs": [ + "The user's spot positions" + ], + "type": { + "array": [ + { + "defined": { + "name": "spotPosition" + } + }, + 8 + ] + } + }, + { + "name": "perpPositions", + "docs": [ + "The user's perp positions" + ], + "type": { + "array": [ + { + "defined": { + "name": "perpPosition" + } + }, + 8 + ] + } + }, + { + "name": "orders", + "docs": [ + "The user's orders" + ], + "type": { + "array": [ + { + "defined": { + "name": "order" + } + }, + 32 + ] + } + }, + { + "name": "lastAddPerpLpSharesTs", + "docs": [ + "The last time the user added perp lp positions" + ], + "type": "i64" + }, + { + "name": "totalDeposits", + "docs": [ + "The total values of deposits the user has made", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalWithdraws", + "docs": [ + "The total values of withdrawals the user has made", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalSocialLoss", + "docs": [ + "The total socialized loss the users has incurred upon the protocol", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "settledPerpPnl", + "docs": [ + "Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "cumulativeSpotFees", + "docs": [ + "Fees (taker fees, maker rebate, filler reward) for spot", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "cumulativePerpFunding", + "docs": [ + "Cumulative funding paid/received for perps", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "liquidationMarginFreed", + "docs": [ + "The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time", + "Defaults to zero when not being liquidated", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastActiveSlot", + "docs": [ + "The last slot a user was active. Used to determine if a user is idle" + ], + "type": "u64" + }, + { + "name": "nextOrderId", + "docs": [ + "Every user order has an order id. This is the next order id to be used" + ], + "type": "u32" + }, + { + "name": "maxMarginRatio", + "docs": [ + "Custom max initial margin ratio for the user" + ], + "type": "u32" + }, + { + "name": "nextLiquidationId", + "docs": [ + "The next liquidation id to be used for user" + ], + "type": "u16" + }, + { + "name": "subAccountId", + "docs": [ + "The sub account id for this user" + ], + "type": "u16" + }, + { + "name": "status", + "docs": [ + "Whether the user is active, being liquidated or bankrupt" + ], + "type": "u8" + }, + { + "name": "isMarginTradingEnabled", + "docs": [ + "Whether the user has enabled margin trading" + ], + "type": "bool" + }, + { + "name": "idle", + "docs": [ + "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", + "Off-chain keeper bots can ignore users that are idle" + ], + "type": "bool" + }, + { + "name": "openOrders", + "docs": [ + "number of open orders" + ], + "type": "u8" + }, + { + "name": "hasOpenOrder", + "docs": [ + "Whether or not user has open order" + ], + "type": "bool" + }, + { + "name": "openAuctions", + "docs": [ + "number of open orders with auction" + ], + "type": "u8" + }, + { + "name": "hasOpenAuction", + "docs": [ + "Whether or not user has open order with auction" + ], + "type": "bool" + }, + { + "name": "marginMode", + "type": { + "defined": { + "name": "marginMode" + } + } + }, + { + "name": "poolId", + "type": "u8" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "lastFuelBonusUpdateTs", + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 12 + ] + } + } + ] + } + }, + { + "name": "userFees", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "totalFeePaid", + "docs": [ + "Total taker fee paid", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalFeeRebate", + "docs": [ + "Total maker fee rebate", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalTokenDiscount", + "docs": [ + "Total discount from holding token", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalRefereeDiscount", + "docs": [ + "Total discount from being referred", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalReferrerReward", + "docs": [ + "Total reward to referrer", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "currentEpochReferrerReward", + "docs": [ + "Total reward to referrer this epoch", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + } + ] + } + }, + { + "name": "userStats", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The authority for all of a users sub accounts" + ], + "type": "pubkey" + }, + { + "name": "referrer", + "docs": [ + "The address that referred this user" + ], + "type": "pubkey" + }, + { + "name": "fees", + "docs": [ + "Stats on the fees paid by the user" + ], + "type": { + "defined": { + "name": "userFees" + } + } + }, + { + "name": "nextEpochTs", + "docs": [ + "The timestamp of the next epoch", + "Epoch is used to limit referrer rewards earned in single epoch" + ], + "type": "i64" + }, + { + "name": "makerVolume30d", + "docs": [ + "Rolling 30day maker volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "takerVolume30d", + "docs": [ + "Rolling 30day taker volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "fillerVolume30d", + "docs": [ + "Rolling 30day filler volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastMakerVolume30dTs", + "docs": [ + "last time the maker volume was updated" + ], + "type": "i64" + }, + { + "name": "lastTakerVolume30dTs", + "docs": [ + "last time the taker volume was updated" + ], + "type": "i64" + }, + { + "name": "lastFillerVolume30dTs", + "docs": [ + "last time the filler volume was updated" + ], + "type": "i64" + }, + { + "name": "ifStakedQuoteAssetAmount", + "docs": [ + "The amount of tokens staked in the quote spot markets if" + ], + "type": "u64" + }, + { + "name": "numberOfSubAccounts", + "docs": [ + "The current number of sub accounts" + ], + "type": "u16" + }, + { + "name": "numberOfSubAccountsCreated", + "docs": [ + "The number of sub accounts created. Can be greater than the number of sub accounts if user", + "has deleted sub accounts" + ], + "type": "u16" + }, + { + "name": "referrerStatus", + "docs": [ + "Flags for referrer status:", + "First bit (LSB): 1 if user is a referrer, 0 otherwise", + "Second bit: 1 if user was referred, 0 otherwise" + ], + "type": "u8" + }, + { + "name": "disableUpdatePerpBidAskTwap", + "type": "u8" + }, + { + "name": "pausedOperations", + "type": "u8" + }, + { + "name": "fuelOverflowStatus", + "docs": [ + "whether the user has a FuelOverflow account" + ], + "type": "u8" + }, + { + "name": "fuelInsurance", + "docs": [ + "accumulated fuel for token amounts of insurance" + ], + "type": "u32" + }, + { + "name": "fuelDeposits", + "docs": [ + "accumulated fuel for notional of deposits" + ], + "type": "u32" + }, + { + "name": "fuelBorrows", + "docs": [ + "accumulate fuel bonus for notional of borrows" + ], + "type": "u32" + }, + { + "name": "fuelPositions", + "docs": [ + "accumulated fuel for perp open interest" + ], + "type": "u32" + }, + { + "name": "fuelTaker", + "docs": [ + "accumulate fuel bonus for taker volume" + ], + "type": "u32" + }, + { + "name": "fuelMaker", + "docs": [ + "accumulate fuel bonus for maker volume" + ], + "type": "u32" + }, + { + "name": "ifStakedGovTokenAmount", + "docs": [ + "The amount of tokens staked in the governance spot markets if" + ], + "type": "u64" + }, + { + "name": "lastFuelIfBonusUpdateTs", + "docs": [ + "last unix ts user stats data was used to update if fuel (u32 to save space)" + ], + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 12 + ] + } + } + ] + } + }, + { + "name": "validityGuardRails", + "type": { + "kind": "struct", + "fields": [ + { + "name": "slotsBeforeStaleForAmm", + "type": "i64" + }, + { + "name": "slotsBeforeStaleForMargin", + "type": "i64" + }, + { + "name": "confidenceIntervalMaxSize", + "type": "u64" + }, + { + "name": "tooVolatileRatio", + "type": "i64" + } + ] + } + }, + { + "name": "i128", + "docs": [ + "`i128` with legacy bit layout" + ], + "type": { + "kind": "struct", + "fields": [ + { + "array": [ + "u8", + 16 + ] + } + ] + } + }, + { + "name": "u128", + "docs": [ + "`u128` with legacy bit layout" + ], + "type": { + "kind": "struct", + "fields": [ + { + "array": [ + "u8", + 16 + ] + } + ] + } + } + ] }; diff --git a/test-scripts/run-anchor-local-validator-tests.sh b/test-scripts/run-anchor-local-validator-tests.sh index 8cacb1a6cb..4064876dca 100644 --- a/test-scripts/run-anchor-local-validator-tests.sh +++ b/test-scripts/run-anchor-local-validator-tests.sh @@ -1,6 +1,7 @@ if [ "$1" != "--skip-build" ]; then anchor build -- --features anchor-test && cp target/idl/drift.json sdk/src/idl/ + cp target/types/drift.ts sdk/src/idl/ fi export ANCHOR_WALLET=~/.config/solana/id.json diff --git a/test-scripts/run-anchor-tests.sh b/test-scripts/run-anchor-tests.sh index 19e5ca9625..dca4ddd545 100644 --- a/test-scripts/run-anchor-tests.sh +++ b/test-scripts/run-anchor-tests.sh @@ -6,6 +6,7 @@ trap 'echo -e "\nStopped by signal $? (SIGINT)"; exit 0' INT if [ "$1" != "--skip-build" ]; then anchor build -- --features anchor-test && anchor test --skip-build && cp target/idl/drift.json sdk/src/idl/ + cp target/types/drift.ts sdk/src/idl/ fi export ANCHOR_WALLET=~/.config/solana/id.json diff --git a/test-scripts/single-anchor-test.sh b/test-scripts/single-anchor-test.sh index f3fb157085..f7557dd199 100755 --- a/test-scripts/single-anchor-test.sh +++ b/test-scripts/single-anchor-test.sh @@ -2,6 +2,7 @@ if [ "$1" != "--skip-build" ] then anchor build -- --features anchor-test && anchor test --skip-build && cp target/idl/drift.json sdk/src/idl/ + cp target/idl/types.ts sdk/src/idl/ fi export ANCHOR_WALLET=~/.config/solana/id.json From 56188a6d1840d4f4811fdeb49a3a432fc1d017a4 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 8 Dec 2025 14:17:51 +0800 Subject: [PATCH 19/25] drift-macros 2021 edition for CI --- Cargo.lock | 2 +- programs/drift/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a084c5238..4292dd72d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -750,7 +750,7 @@ dependencies = [ [[package]] name = "drift-macros" version = "0.1.0" -source = "git+https://github.com/drift-labs/drift-macros?rev=f48c4c77#f48c4c77c8bc60d204458a414d3f1e9478444c39" +source = "git+https://github.com/drift-labs/drift-macros?rev=6e246ba#6e246bacf5fc3bb11d04710753a2f2f5ef0fb06d" dependencies = [ "quote", "static_assertions", diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index 5439045995..15e91a4506 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -44,7 +44,7 @@ enumflags2 = "0.6.4" phoenix-v1 = { git = "https://github.com/jordy25519/phoenix-v1", branch = "master", features = ["no-entrypoint"] } solana-security-txt = "1.1.0" static_assertions = "1.1.0" -drift-macros = { git = "https://github.com/drift-labs/drift-macros", rev = "f48c4c77" } +drift-macros = { git = "https://github.com/drift-labs/drift-macros", rev = "6e246ba" } switchboard = { path = "../switchboard", features = ["no-entrypoint"] } openbook-v2-light = { path = "../openbook_v2", features = ["no-entrypoint"] } switchboard-on-demand = { path = "../switchboard-on-demand", features = ["no-entrypoint"] } From 32da9d7a8ea229bfa8d2efdf72ce3055f07a0888 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 8 Dec 2025 14:19:29 +0800 Subject: [PATCH 20/25] prettify idl? --- sdk/src/idl/drift.ts | 43851 +++++++++++++++++++---------------------- 1 file changed, 19758 insertions(+), 24093 deletions(-) diff --git a/sdk/src/idl/drift.ts b/sdk/src/idl/drift.ts index 76098a5770..73f3277476 100644 --- a/sdk/src/idl/drift.ts +++ b/sdk/src/idl/drift.ts @@ -5,24097 +5,19762 @@ * IDL can be found at `target/idl/drift.json`. */ export type Drift = { - "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH", - "metadata": { - "name": "drift", - "version": "2.151.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "addAmmConstituentMappingData", - "discriminator": [ - 164, - 236, - 130, - 40, - 118, - 179, - 46, - 235 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool" - }, - { - "name": "ammConstituentMapping", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 65, - 77, - 77, - 95, - 77, - 65, - 80 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituentTargetBase", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "ammConstituentMappingData", - "type": { - "vec": { - "defined": { - "name": "addAmmConstituentMappingDatum" - } - } - } - } - ] - }, - { - "name": "addInsuranceFundStake", - "discriminator": [ - 251, - 144, - 115, - 11, - 222, - 47, - 62, - 236 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insuranceFundStake", - "userStats" - ] - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "addMarketToAmmCache", - "discriminator": [ - 112, - 149, - 195, - 222, - 124, - 7, - 87, - 237 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "perpMarket" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "adminDeposit", - "discriminator": [ - 210, - 66, - 65, - 182, - 102, - 214, - 176, - 30 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "adminTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "adminUpdateUserStatsPausedOperations", - "discriminator": [ - 183, - 104, - 63, - 150, - 240, - 199, - 3, - 10 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "beginInsuranceFundSwap", - "discriminator": [ - 176, - 69, - 143, - 205, - 32, - 132, - 163, - 0 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "outInsuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inInsuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outTokenAccount", - "writable": true - }, - { - "name": "inTokenAccount", - "writable": true - }, - { - "name": "ifRebalanceConfig", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "amountIn", - "type": "u64" - } - ] - }, - { - "name": "beginLpSwap", - "discriminator": [ - 64, - 44, - 24, - 199, - 48, - 125, - 67, - 91 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "signerOutTokenAccount", - "docs": [ - "Signer token accounts" - ], - "writable": true - }, - { - "name": "signerInTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "docs": [ - "Constituent token accounts" - ], - "writable": true - }, - { - "name": "constituentInTokenAccount", - "writable": true - }, - { - "name": "outConstituent", - "docs": [ - "Constituents" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "lpPool" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "amountIn", - "type": "u64" - } - ] - }, - { - "name": "beginSwap", - "discriminator": [ - 174, - 109, - 228, - 1, - 242, - 105, - 232, - 105 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "outSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outTokenAccount", - "writable": true - }, - { - "name": "inTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "amountIn", - "type": "u64" - } - ] - }, - { - "name": "cancelOrder", - "discriminator": [ - 95, - 129, - 237, - 240, - 8, - 49, - 223, - 132 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "cancelOrderByUserId", - "discriminator": [ - 107, - 211, - 250, - 133, - 18, - 37, - 57, - 100 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "userOrderId", - "type": "u8" - } - ] - }, - { - "name": "cancelOrders", - "discriminator": [ - 238, - 225, - 95, - 158, - 227, - 103, - 8, - 194 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "marketType", - "type": { - "option": { - "defined": { - "name": "marketType" - } - } - } - }, - { - "name": "marketIndex", - "type": { - "option": "u16" - } - }, - { - "name": "direction", - "type": { - "option": { - "defined": { - "name": "positionDirection" - } - } - } - } - ] - }, - { - "name": "cancelOrdersByIds", - "discriminator": [ - 134, - 19, - 144, - 165, - 94, - 240, - 210, - 94 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "orderIds", - "type": { - "vec": "u32" - } - } - ] - }, - { - "name": "cancelRequestRemoveInsuranceFundStake", - "discriminator": [ - 97, - 235, - 78, - 62, - 212, - 42, - 241, - 127 - ], - "accounts": [ - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insuranceFundStake", - "userStats" - ] - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "changeApprovedBuilder", - "discriminator": [ - 179, - 134, - 211, - 45, - 195, - 5, - 189, - 173 - ], - "accounts": [ - { - "name": "escrow", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 82, - 69, - 86, - 95, - 69, - 83, - 67, - 82, - 79, - 87 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "signer": true, - "relations": [ - "escrow" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "builder", - "type": "pubkey" - }, - { - "name": "maxFeeBps", - "type": "u16" - }, - { - "name": "add", - "type": "bool" - } - ] - }, - { - "name": "changeSignedMsgWsDelegateStatus", - "discriminator": [ - 252, - 202, - 252, - 219, - 179, - 27, - 84, - 138 - ], - "accounts": [ - { - "name": "signedMsgWsDelegates", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71, - 95, - 87, - 83 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "delegate", - "type": "pubkey" - }, - { - "name": "add", - "type": "bool" - } - ] - }, - { - "name": "deleteAmmCache", - "discriminator": [ - 216, - 130, - 215, - 206, - 233, - 232, - 191, - 88 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "deleteInitializedPerpMarket", - "discriminator": [ - 91, - 154, - 24, - 87, - 106, - 59, - 190, - 66 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "deleteInitializedSpotMarket", - "discriminator": [ - 31, - 140, - 67, - 191, - 189, - 20, - 101, - 221 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "deletePrelaunchOracle", - "discriminator": [ - 59, - 169, - 100, - 49, - 69, - 17, - 173, - 253 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "prelaunchOracle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101 - ] - }, - { - "kind": "arg", - "path": "perpMarketIndex" - } - ] - } - }, - { - "name": "perpMarket" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "perpMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "deleteSignedMsgUserOrders", - "discriminator": [ - 221, - 247, - 128, - 253, - 212, - 254, - 46, - 153 - ], - "accounts": [ - { - "name": "signedMsgUserOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [] - }, - { - "name": "deleteUser", - "discriminator": [ - 186, - 85, - 17, - 249, - 219, - 231, - 98, - 251 - ], - "accounts": [ - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "writable": true, - "signer": true, - "relations": [ - "user", - "userStats" - ] - } - ], - "args": [] - }, - { - "name": "deposit", - "discriminator": [ - 242, - 35, - 198, - 137, - 82, - 225, - 242, - 182 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "reduceOnly", - "type": "bool" - } - ] - }, - { - "name": "depositIntoInsuranceFundStake", - "discriminator": [ - 4, - 22, - 226, - 201, - 124, - 44, - 82, - 230 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101 - ] - }, - { - "kind": "account", - "path": "userStats" - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "depositIntoPerpMarketFeePool", - "discriminator": [ - 34, - 58, - 57, - 68, - 97, - 80, - 244, - 6 - ], - "accounts": [ - { - "name": "state", - "writable": true - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "sourceVault", - "writable": true - }, - { - "name": "driftSigner" - }, - { - "name": "quoteSpotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "depositIntoSpotMarketRevenuePool", - "discriminator": [ - 92, - 40, - 151, - 42, - 122, - 254, - 139, - 246 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "spotMarket" - } - ] - } - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "depositIntoSpotMarketVault", - "discriminator": [ - 48, - 252, - 119, - 73, - 255, - 205, - 174, - 247 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "sourceVault", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "depositToProgramVault", - "discriminator": [ - 235, - 171, - 121, - 80, - 57, - 239, - 147, - 220 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "constituent", - "writable": true - }, - { - "name": "constituentTokenAccount", - "writable": true - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "mint" - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "disableUserHighLeverageMode", - "discriminator": [ - 183, - 155, - 45, - 0, - 226, - 85, - 213, - 69 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "highLeverageModeConfig", - "writable": true - } - ], - "args": [ - { - "name": "disableMaintenance", - "type": "bool" - } - ] - }, - { - "name": "enableUserHighLeverageMode", - "discriminator": [ - 231, - 24, - 230, - 112, - 201, - 173, - 73, - 184 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "highLeverageModeConfig", - "writable": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - } - ] - }, - { - "name": "endInsuranceFundSwap", - "discriminator": [ - 206, - 230, - 98, - 8, - 249, - 158, - 169, - 167 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "outInsuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inInsuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outTokenAccount", - "writable": true - }, - { - "name": "inTokenAccount", - "writable": true - }, - { - "name": "ifRebalanceConfig", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "endLpSwap", - "discriminator": [ - 99, - 125, - 214, - 165, - 129, - 175, - 253, - 135 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "signerOutTokenAccount", - "docs": [ - "Signer token accounts" - ], - "writable": true - }, - { - "name": "signerInTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "docs": [ - "Constituent token accounts" - ], - "writable": true - }, - { - "name": "constituentInTokenAccount", - "writable": true - }, - { - "name": "outConstituent", - "docs": [ - "Constituents" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "lpPool" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "endSwap", - "discriminator": [ - 177, - 184, - 27, - 193, - 34, - 13, - 210, - 145 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "outSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outTokenAccount", - "writable": true - }, - { - "name": "inTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - }, - { - "name": "reduceOnly", - "type": { - "option": { - "defined": { - "name": "swapReduceOnly" - } - } - } - } - ] - }, - { - "name": "fillPerpOrder", - "discriminator": [ - 13, - 188, - 248, - 103, - 134, - 217, - 106, - 240 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "fillerStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "fillSpotOrder", - "discriminator": [ - 212, - 206, - 130, - 173, - 21, - 34, - 199, - 40 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "fillerStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": { - "name": "spotFulfillmentType" - } - } - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "forceCancelOrders", - "discriminator": [ - 64, - 181, - 196, - 63, - 222, - 72, - 64, - 232 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "user", - "writable": true - } - ], - "args": [] - }, - { - "name": "forceDeleteUser", - "discriminator": [ - 2, - 241, - 195, - 172, - 227, - 24, - 254, - 158 - ], - "accounts": [ - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "writable": true, - "relations": [ - "user", - "userStats" - ] - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "driftSigner" - } - ], - "args": [] - }, - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 114, - 105, - 102, - 116, - 95, - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "quoteAssetMint" - }, - { - "name": "driftSigner" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [] - }, - { - "name": "initializeAmmCache", - "discriminator": [ - 38, - 60, - 171, - 158, - 203, - 58, - 137, - 8 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initializeConstituent", - "discriminator": [ - 12, - 196, - 45, - 218, - 93, - 89, - 0, - 33 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "constituentTargetBase", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituentCorrelations", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "spotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "spotMarketMint" - }, - { - "name": "constituentVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "decimals", - "type": "u8" - }, - { - "name": "maxWeightDeviation", - "type": "i64" - }, - { - "name": "swapFeeMin", - "type": "i64" - }, - { - "name": "swapFeeMax", - "type": "i64" - }, - { - "name": "maxBorrowTokenAmount", - "type": "u64" - }, - { - "name": "oracleStalenessThreshold", - "type": "u64" - }, - { - "name": "costToTrade", - "type": "i32" - }, - { - "name": "constituentDerivativeIndex", - "type": { - "option": "i16" - } - }, - { - "name": "constituentDerivativeDepegThreshold", - "type": "u64" - }, - { - "name": "derivativeWeight", - "type": "u64" - }, - { - "name": "volatility", - "type": "u64" - }, - { - "name": "gammaExecution", - "type": "u8" - }, - { - "name": "gammaInventory", - "type": "u8" - }, - { - "name": "xi", - "type": "u8" - }, - { - "name": "newConstituentCorrelations", - "type": { - "vec": "i64" - } - } - ] - }, - { - "name": "initializeFuelOverflow", - "discriminator": [ - 88, - 223, - 132, - 161, - 208, - 88, - 142, - 42 - ], - "accounts": [ - { - "name": "fuelOverflow", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 102, - 117, - 101, - 108, - 95, - 111, - 118, - 101, - 114, - 102, - 108, - 111, - 119 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "relations": [ - "userStats" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initializeHighLeverageModeConfig", - "discriminator": [ - 213, - 167, - 93, - 246, - 208, - 130, - 90, - 248 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "highLeverageModeConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 104, - 105, - 103, - 104, - 95, - 108, - 101, - 118, - 101, - 114, - 97, - 103, - 101, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "maxUsers", - "type": "u32" - } - ] - }, - { - "name": "initializeIfRebalanceConfig", - "discriminator": [ - 8, - 85, - 184, - 167, - 176, - 61, - 173, - 226 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "ifRebalanceConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 102, - 95, - 114, - 101, - 98, - 97, - 108, - 97, - 110, - 99, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "arg", - "path": "params.in_market_index" - }, - { - "kind": "arg", - "path": "params.out_market_index" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ifRebalanceConfigParams" - } - } - } - ] - }, - { - "name": "initializeInsuranceFundStake", - "discriminator": [ - 187, - 179, - 243, - 70, - 248, - 90, - 92, - 147 - ], - "accounts": [ - { - "name": "spotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state" - }, - { - "name": "authority", - "signer": true, - "relations": [ - "userStats" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "initializeLpPool", - "discriminator": [ - 242, - 64, - 1, - 222, - 142, - 46, - 204, - 227 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 112, - 95, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "arg", - "path": "id" - } - ] - } - }, - { - "name": "mint" - }, - { - "name": "lpPoolTokenVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "ammConstituentMapping", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 65, - 77, - 77, - 95, - 77, - 65, - 80 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituentTargetBase", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituentCorrelations", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "lpPoolId", - "type": "u8" - }, - { - "name": "minMintFee", - "type": "i64" - }, - { - "name": "maxAum", - "type": "u128" - }, - { - "name": "maxSettleQuoteAmountPerMarket", - "type": "u64" - }, - { - "name": "whitelistMint", - "type": "pubkey" - } - ] - }, - { - "name": "initializeOpenbookV2FulfillmentConfig", - "discriminator": [ - 7, - 221, - 103, - 153, - 107, - 57, - 27, - 197 - ], - "accounts": [ - { - "name": "baseSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "quoteSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "openbookV2Program" - }, - { - "name": "openbookV2Market" - }, - { - "name": "driftSigner" - }, - { - "name": "openbookV2FulfillmentConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, - 112, - 101, - 110, - 98, - 111, - 111, - 107, - 95, - 118, - 50, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "openbookV2Market" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "initializePerpMarket", - "discriminator": [ - 132, - 9, - 229, - 118, - 117, - 118, - 117, - 62 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "perpMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 101, - 114, - 112, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "account", - "path": "state.number_of_markets", - "account": "state" - } - ] - } - }, - { - "name": "oracle" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "ammBaseAssetReserve", - "type": "u128" - }, - { - "name": "ammQuoteAssetReserve", - "type": "u128" - }, - { - "name": "ammPeriodicity", - "type": "i64" - }, - { - "name": "ammPegMultiplier", - "type": "u128" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "contractTier", - "type": { - "defined": { - "name": "contractTier" - } - } - }, - { - "name": "marginRatioInitial", - "type": "u32" - }, - { - "name": "marginRatioMaintenance", - "type": "u32" - }, - { - "name": "liquidatorFee", - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "type": "u32" - }, - { - "name": "imfFactor", - "type": "u32" - }, - { - "name": "activeStatus", - "type": "bool" - }, - { - "name": "baseSpread", - "type": "u32" - }, - { - "name": "maxSpread", - "type": "u32" - }, - { - "name": "maxOpenInterest", - "type": "u128" - }, - { - "name": "maxRevenueWithdrawPerPeriod", - "type": "u64" - }, - { - "name": "quoteMaxInsurance", - "type": "u64" - }, - { - "name": "orderStepSize", - "type": "u64" - }, - { - "name": "orderTickSize", - "type": "u64" - }, - { - "name": "minOrderSize", - "type": "u64" - }, - { - "name": "concentrationCoefScale", - "type": "u128" - }, - { - "name": "curveUpdateIntensity", - "type": "u8" - }, - { - "name": "ammJitIntensity", - "type": "u8" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "lpPoolId", - "type": "u8" - } - ] - }, - { - "name": "initializePhoenixFulfillmentConfig", - "discriminator": [ - 135, - 132, - 110, - 107, - 185, - 160, - 169, - 154 - ], - "accounts": [ - { - "name": "baseSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "quoteSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "phoenixProgram" - }, - { - "name": "phoenixMarket" - }, - { - "name": "driftSigner" - }, - { - "name": "phoenixFulfillmentConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 104, - 111, - 101, - 110, - 105, - 120, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "phoenixMarket" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "initializePredictionMarket", - "discriminator": [ - 248, - 70, - 198, - 224, - 224, - 105, - 125, - 195 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [] - }, - { - "name": "initializePrelaunchOracle", - "discriminator": [ - 169, - 178, - 84, - 25, - 175, - 62, - 29, - 247 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "prelaunchOracle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101 - ] - }, - { - "kind": "arg", - "path": "params.perp_market_index" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "prelaunchOracleParams" - } - } - } - ] - }, - { - "name": "initializeProtectedMakerModeConfig", - "discriminator": [ - 67, - 103, - 220, - 67, - 88, - 32, - 252, - 8 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "protectedMakerModeConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 111, - 116, - 101, - 99, - 116, - 101, - 100, - 95, - 109, - 97, - 107, - 101, - 114, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "maxUsers", - "type": "u32" - } - ] - }, - { - "name": "initializePythLazerOracle", - "discriminator": [ - 140, - 107, - 33, - 214, - 235, - 219, - 103, - 20 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lazerOracle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 121, - 116, - 104, - 95, - 108, - 97, - 122, - 101, - 114 - ] - }, - { - "kind": "arg", - "path": "feedId" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "feedId", - "type": "u32" - } - ] - }, - { - "name": "initializePythPullOracle", - "discriminator": [ - 249, - 140, - 253, - 243, - 248, - 74, - 240, - 238 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "pythSolanaReceiver", - "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" - }, - { - "name": "priceFeed", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 121, - 116, - 104, - 95, - 112, - 117, - 108, - 108 - ] - }, - { - "kind": "arg", - "path": "feedId" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "initializeReferrerName", - "discriminator": [ - 235, - 126, - 231, - 10, - 42, - 164, - 26, - 61 - ], - "accounts": [ - { - "name": "referrerName", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 102, - 101, - 114, - 114, - 101, - 114, - 95, - 110, - 97, - 109, - 101 - ] - }, - { - "kind": "arg", - "path": "name" - } - ] - } - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "initializeRevenueShare", - "discriminator": [ - 57, - 9, - 123, - 131, - 82, - 52, - 50, - 13 - ], - "accounts": [ - { - "name": "revenueShare", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 82, - 69, - 86, - 95, - 83, - 72, - 65, - 82, - 69 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority" - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initializeRevenueShareEscrow", - "discriminator": [ - 187, - 18, - 123, - 88, - 238, - 104, - 84, - 154 - ], - "accounts": [ - { - "name": "escrow", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 82, - 69, - 86, - 95, - 69, - 83, - 67, - 82, - 79, - 87 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "relations": [ - "userStats" - ] - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state" - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "numOrders", - "type": "u16" - } - ] - }, - { - "name": "initializeSerumFulfillmentConfig", - "discriminator": [ - 193, - 211, - 132, - 172, - 70, - 171, - 7, - 94 - ], - "accounts": [ - { - "name": "baseSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "quoteSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "serumProgram" - }, - { - "name": "serumMarket" - }, - { - "name": "serumOpenOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 114, - 117, - 109, - 95, - 111, - 112, - 101, - 110, - 95, - 111, - 114, - 100, - 101, - 114, - 115 - ] - }, - { - "kind": "account", - "path": "serumMarket" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "serumFulfillmentConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 114, - 117, - 109, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "serumMarket" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "initializeSignedMsgUserOrders", - "discriminator": [ - 164, - 99, - 156, - 126, - 156, - 57, - 99, - 180 - ], - "accounts": [ - { - "name": "signedMsgUserOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority" - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "numOrders", - "type": "u16" - } - ] - }, - { - "name": "initializeSignedMsgWsDelegates", - "discriminator": [ - 40, - 132, - 96, - 219, - 184, - 193, - 80, - 8 - ], - "accounts": [ - { - "name": "signedMsgWsDelegates", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71, - 95, - 87, - 83 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "delegates", - "type": { - "vec": "pubkey" - } - } - ] - }, - { - "name": "initializeSpotMarket", - "discriminator": [ - 234, - 196, - 128, - 44, - 94, - 15, - 48, - 201 - ], - "accounts": [ - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "account", - "path": "state.number_of_spot_markets", - "account": "state" - } - ] - } - }, - { - "name": "spotMarketMint" - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "state.number_of_spot_markets", - "account": "state" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "state.number_of_spot_markets", - "account": "state" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "state", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "optimalUtilization", - "type": "u32" - }, - { - "name": "optimalBorrowRate", - "type": "u32" - }, - { - "name": "maxBorrowRate", - "type": "u32" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "initialAssetWeight", - "type": "u32" - }, - { - "name": "maintenanceAssetWeight", - "type": "u32" - }, - { - "name": "initialLiabilityWeight", - "type": "u32" - }, - { - "name": "maintenanceLiabilityWeight", - "type": "u32" - }, - { - "name": "imfFactor", - "type": "u32" - }, - { - "name": "liquidatorFee", - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "type": "u32" - }, - { - "name": "activeStatus", - "type": "bool" - }, - { - "name": "assetTier", - "type": { - "defined": { - "name": "assetTier" - } - } - }, - { - "name": "scaleInitialAssetWeightStart", - "type": "u64" - }, - { - "name": "withdrawGuardThreshold", - "type": "u64" - }, - { - "name": "orderTickSize", - "type": "u64" - }, - { - "name": "orderStepSize", - "type": "u64" - }, - { - "name": "ifTotalFactor", - "type": "u32" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "initializeUser", - "discriminator": [ - 111, - 17, - 185, - 250, - 60, - 122, - 38, - 254 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "userStats" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "initializeUserStats", - "discriminator": [ - 254, - 243, - 72, - 98, - 251, - 130, - 168, - 213 - ], - "accounts": [ - { - "name": "userStats", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114, - 95, - 115, - 116, - 97, - 116, - 115 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "liquidateBorrowForPerpPnl", - "discriminator": [ - 169, - 17, - 32, - 90, - 207, - 148, - 209, - 27 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxLiabilityTransfer", - "type": "u128" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "liquidatePerp", - "discriminator": [ - 75, - 35, - 119, - 247, - 191, - 18, - 139, - 2 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxBaseAssetAmount", - "type": "u64" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "liquidatePerpPnlForDeposit", - "discriminator": [ - 237, - 75, - 198, - 235, - 233, - 186, - 75, - 35 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxPnlTransfer", - "type": "u128" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "liquidatePerpWithFill", - "discriminator": [ - 95, - 111, - 124, - 105, - 86, - 169, - 187, - 34 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "liquidateSpot", - "discriminator": [ - 107, - 0, - 128, - 41, - 35, - 229, - 251, - 18 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxLiabilityTransfer", - "type": "u128" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "liquidateSpotWithSwapBegin", - "discriminator": [ - 12, - 43, - 176, - 83, - 156, - 251, - 117, - 13 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "liabilitySpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "liabilityMarketIndex" - } - ] - } - }, - { - "name": "assetSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "assetMarketIndex" - } - ] - } - }, - { - "name": "liabilityTokenAccount", - "writable": true - }, - { - "name": "assetTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "swapAmount", - "type": "u64" - } - ] - }, - { - "name": "liquidateSpotWithSwapEnd", - "discriminator": [ - 142, - 88, - 163, - 160, - 223, - 75, - 55, - 225 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "liabilitySpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "liabilityMarketIndex" - } - ] - } - }, - { - "name": "assetSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "assetMarketIndex" - } - ] - } - }, - { - "name": "liabilityTokenAccount", - "writable": true - }, - { - "name": "assetTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "logUserBalances", - "discriminator": [ - 162, - 21, - 35, - 251, - 32, - 57, - 161, - 210 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "user", - "writable": true - } - ], - "args": [] - }, - { - "name": "lpPoolAddLiquidity", - "discriminator": [ - 49, - 135, - 246, - 103, - 93, - 146, - 220, - 141 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "inMarketMint" - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "userInTokenAccount", - "writable": true - }, - { - "name": "constituentInTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "userLpTokenAccount", - "writable": true - }, - { - "name": "lpMint", - "writable": true - }, - { - "name": "constituentTargetBase" - }, - { - "name": "lpPoolTokenVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u128" - }, - { - "name": "minMintAmount", - "type": "u64" - } - ] - }, - { - "name": "lpPoolRemoveLiquidity", - "discriminator": [ - 164, - 36, - 193, - 252, - 196, - 157, - 138, - 43 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "driftSigner" - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "outMarketMint" - }, - { - "name": "outConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "userOutTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "userLpTokenAccount", - "writable": true - }, - { - "name": "spotMarketTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "lpMint", - "writable": true - }, - { - "name": "constituentTargetBase" - }, - { - "name": "lpPoolTokenVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "tokenProgram" - }, - { - "name": "ammCache", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" - }, - { - "name": "minOutAmount", - "type": "u128" - } - ] - }, - { - "name": "lpPoolSwap", - "discriminator": [ - 36, - 161, - 39, - 49, - 227, - 1, - 35, - 226 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool" - }, - { - "name": "constituentTargetBase" - }, - { - "name": "constituentCorrelations" - }, - { - "name": "constituentInTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "writable": true - }, - { - "name": "userInTokenAccount", - "writable": true - }, - { - "name": "userOutTokenAccount", - "writable": true - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inMarketMint" - }, - { - "name": "outMarketMint" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" - }, - { - "name": "minOutAmount", - "type": "u64" - } - ] - }, - { - "name": "modifyOrder", - "discriminator": [ - 47, - 124, - 117, - 255, - 201, - 197, - 130, - 94 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - }, - { - "name": "modifyOrderParams", - "type": { - "defined": { - "name": "modifyOrderParams" - } - } - } - ] - }, - { - "name": "modifyOrderByUserId", - "discriminator": [ - 158, - 77, - 4, - 253, - 252, - 194, - 161, - 179 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "userOrderId", - "type": "u8" - }, - { - "name": "modifyOrderParams", - "type": { - "defined": { - "name": "modifyOrderParams" - } - } - } - ] - }, - { - "name": "moveAmmPrice", - "discriminator": [ - 235, - 109, - 2, - 82, - 219, - 118, - 6, - 159 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "baseAssetReserve", - "type": "u128" - }, - { - "name": "quoteAssetReserve", - "type": "u128" - }, - { - "name": "sqrtK", - "type": "u128" - } - ] - }, - { - "name": "openbookV2FulfillmentConfigStatus", - "discriminator": [ - 25, - 173, - 19, - 189, - 4, - 211, - 64, - 238 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "openbookV2FulfillmentConfig", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - } - ] - }, - { - "name": "overrideAmmCacheInfo", - "discriminator": [ - 189, - 198, - 128, - 9, - 49, - 145, - 201, - 115 - ], - "accounts": [ - { - "name": "state", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "overrideParams", - "type": { - "defined": { - "name": "overrideAmmCacheParams" - } - } - } - ] - }, - { - "name": "pauseSpotMarketDepositWithdraw", - "discriminator": [ - 183, - 119, - 59, - 170, - 137, - 35, - 242, - 86 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "keeper", - "signer": true - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "spotMarket" - } - ] - } - } - ], - "args": [] - }, - { - "name": "phoenixFulfillmentConfigStatus", - "discriminator": [ - 96, - 31, - 113, - 32, - 12, - 203, - 7, - 154 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "phoenixFulfillmentConfig", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - } - ] - }, - { - "name": "placeAndMakePerpOrder", - "discriminator": [ - 149, - 117, - 11, - 237, - 47, - 95, - 89, - 237 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "taker", - "writable": true - }, - { - "name": "takerStats", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "takerOrderId", - "type": "u32" - } - ] - }, - { - "name": "placeAndMakeSignedMsgPerpOrder", - "discriminator": [ - 16, - 26, - 123, - 131, - 94, - 29, - 175, - 98 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "taker", - "writable": true - }, - { - "name": "takerStats", - "writable": true - }, - { - "name": "takerSignedMsgUserOrders", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "taker" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "signedMsgOrderUuid", - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - }, - { - "name": "placeAndMakeSpotOrder", - "discriminator": [ - 149, - 158, - 85, - 66, - 239, - 9, - 243, - 98 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "taker", - "writable": true - }, - { - "name": "takerStats", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "takerOrderId", - "type": "u32" - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": { - "name": "spotFulfillmentType" - } - } - } - } - ] - }, - { - "name": "placeAndTakePerpOrder", - "discriminator": [ - 213, - 51, - 1, - 187, - 108, - 220, - 230, - 224 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "successCondition", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "placeAndTakeSpotOrder", - "discriminator": [ - 191, - 3, - 138, - 71, - 114, - 198, - 202, - 100 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": { - "name": "spotFulfillmentType" - } - } - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "placeOrders", - "discriminator": [ - 60, - 63, - 50, - 123, - 12, - 197, - 60, - 190 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "vec": { - "defined": { - "name": "orderParams" - } - } - } - } - ] - }, - { - "name": "placePerpOrder", - "discriminator": [ - 69, - 161, - 93, - 202, - 120, - 126, - 76, - 185 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - } - ] - }, - { - "name": "placeSignedMsgTakerOrder", - "discriminator": [ - 32, - 79, - 101, - 139, - 25, - 6, - 98, - 15 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "signedMsgUserOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "user" - } - ] - } - }, - { - "name": "authority", - "signer": true - }, - { - "name": "ixSysvar", - "docs": [ - "the supplied Sysvar could be anything else.", - "The Instruction Sysvar has not been implemented", - "in the Anchor framework yet, so this is the safe approach." - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "signedMsgOrderParamsMessageBytes", - "type": "bytes" - }, - { - "name": "isDelegateSigner", - "type": "bool" - } - ] - }, - { - "name": "placeSpotOrder", - "discriminator": [ - 45, - 79, - 81, - 160, - 248, - 90, - 91, - 220 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - } - ] - }, - { - "name": "postMultiPythPullOracleUpdatesAtomic", - "discriminator": [ - 243, - 79, - 204, - 228, - 227, - 208, - 100, - 244 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "pythSolanaReceiver", - "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" - }, - { - "name": "guardianSet" - } - ], - "args": [ - { - "name": "params", - "type": "bytes" - } - ] - }, - { - "name": "postPythLazerOracleUpdate", - "discriminator": [ - 218, - 237, - 170, - 245, - 39, - 143, - 166, - 33 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "pythLazerStorage", - "address": "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL" - }, - { - "name": "ixSysvar", - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "pythMessage", - "type": "bytes" - } - ] - }, - { - "name": "postPythPullOracleUpdateAtomic", - "discriminator": [ - 116, - 122, - 137, - 158, - 224, - 195, - 173, - 119 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "pythSolanaReceiver", - "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" - }, - { - "name": "guardianSet" - }, - { - "name": "priceFeed", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 121, - 116, - 104, - 95, - 112, - 117, - 108, - 108 - ] - }, - { - "kind": "arg", - "path": "feedId" - } - ] - } - } - ], - "args": [ - { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "params", - "type": "bytes" - } - ] - }, - { - "name": "recenterPerpMarketAmm", - "discriminator": [ - 24, - 87, - 10, - 115, - 165, - 190, - 80, - 139 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "pegMultiplier", - "type": "u128" - }, - { - "name": "sqrtK", - "type": "u128" - } - ] - }, - { - "name": "recenterPerpMarketAmmCrank", - "discriminator": [ - 166, - 19, - 64, - 10, - 14, - 51, - 101, - 122 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "spotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "account", - "path": "perpMarket" - } - ] - } - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "depth", - "type": { - "option": "u128" - } - } - ] - }, - { - "name": "reclaimRent", - "discriminator": [ - 218, - 200, - 19, - 197, - 227, - 89, - 192, - 22 - ], - "accounts": [ - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state" - }, - { - "name": "authority", - "signer": true, - "relations": [ - "user", - "userStats" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "removeAmmConstituentMappingData", - "discriminator": [ - 20, - 183, - 211, - 162, - 16, - 52, - 229, - 115 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool" - }, - { - "name": "ammConstituentMapping", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 65, - 77, - 77, - 95, - 77, - 65, - 80 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - } - ] - }, - { - "name": "removeInsuranceFundStake", - "discriminator": [ - 128, - 166, - 142, - 9, - 254, - 187, - 143, - 174 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insuranceFundStake", - "userStats" - ] - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "repegAmmCurve", - "discriminator": [ - 3, - 36, - 102, - 89, - 180, - 128, - 120, - 213 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [ - { - "name": "newPegCandidate", - "type": "u128" - } - ] - }, - { - "name": "requestRemoveInsuranceFundStake", - "discriminator": [ - 142, - 70, - 204, - 92, - 73, - 106, - 180, - 52 - ], - "accounts": [ - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insuranceFundStake", - "userStats" - ] - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "resetFuelSeason", - "discriminator": [ - 199, - 122, - 192, - 255, - 32, - 99, - 63, - 200 - ], - "accounts": [ - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "relations": [ - "userStats" - ] - }, - { - "name": "state" - }, - { - "name": "admin", - "signer": true - } - ], - "args": [] - }, - { - "name": "resetPerpMarketAmmOracleTwap", - "discriminator": [ - 127, - 10, - 55, - 164, - 123, - 226, - 47, - 24 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [] - }, - { - "name": "resizeRevenueShareEscrowOrders", - "discriminator": [ - 32, - 124, - 247, - 225, - 151, - 213, - 225, - 38 - ], - "accounts": [ - { - "name": "escrow", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 82, - 69, - 86, - 95, - 69, - 83, - 67, - 82, - 79, - 87 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "relations": [ - "escrow" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "numOrders", - "type": "u16" - } - ] - }, - { - "name": "resizeSignedMsgUserOrders", - "discriminator": [ - 137, - 10, - 87, - 150, - 18, - 115, - 79, - 168 - ], - "accounts": [ - { - "name": "signedMsgUserOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "relations": [ - "user" - ] - }, - { - "name": "user" - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "numOrders", - "type": "u16" - } - ] - }, - { - "name": "resolvePerpBankruptcy", - "discriminator": [ - 224, - 16, - 176, - 214, - 162, - 213, - 183, - 222 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "quoteSpotMarketIndex", - "type": "u16" - }, - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "resolvePerpPnlDeficit", - "discriminator": [ - 168, - 204, - 68, - 150, - 159, - 126, - 95, - 148 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "resolveSpotBankruptcy", - "discriminator": [ - 124, - 194, - 240, - 254, - 198, - 213, - 52, - 122 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "revertFill", - "discriminator": [ - 236, - 238, - 176, - 69, - 239, - 10, - 181, - 193 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "fillerStats", - "writable": true - } - ], - "args": [] - }, - { - "name": "setUserStatusToBeingLiquidated", - "discriminator": [ - 106, - 133, - 160, - 206, - 193, - 171, - 192, - 194 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [] - }, - { - "name": "settleExpiredMarket", - "discriminator": [ - 120, - 89, - 11, - 25, - 122, - 77, - 72, - 193 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "settleExpiredMarketPoolsToRevenuePool", - "discriminator": [ - 55, - 19, - 238, - 169, - 227, - 90, - 200, - 184 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [] - }, - { - "name": "settleFundingPayment", - "discriminator": [ - 222, - 90, - 202, - 94, - 28, - 45, - 115, - 183 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - } - ], - "args": [] - }, - { - "name": "settleMultiplePnls", - "discriminator": [ - 127, - 66, - 117, - 57, - 40, - 50, - 152, - 127 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - } - ], - "args": [ - { - "name": "marketIndexes", - "type": { - "vec": "u16" - } - }, - { - "name": "mode", - "type": { - "defined": { - "name": "settlePnlMode" - } - } - } - ] - }, - { - "name": "settlePerpToLpPool", - "discriminator": [ - 5, - 98, - 46, - 188, - 10, - 59, - 2, - 249 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "ammCache", - "writable": true - }, - { - "name": "quoteMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "constituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "constituentQuoteTokenAccount", - "writable": true - }, - { - "name": "quoteTokenVault", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - } - ], - "args": [] - }, - { - "name": "settlePnl", - "discriminator": [ - 43, - 61, - 234, - 45, - 15, - 95, - 152, - 153 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "settleRevenueToInsuranceFund", - "discriminator": [ - 200, - 120, - 93, - 136, - 69, - 38, - 199, - 159 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "sweepFuel", - "discriminator": [ - 175, - 107, - 19, - 56, - 165, - 241, - 43, - 69 - ], - "accounts": [ - { - "name": "fuelOverflow", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "relations": [ - "fuelOverflow", - "userStats" - ] - }, - { - "name": "signer", - "signer": true - } - ], - "args": [] - }, - { - "name": "transferDeposit", - "discriminator": [ - 20, - 20, - 147, - 223, - 41, - 63, - 204, - 111 - ], - "accounts": [ - { - "name": "fromUser", - "writable": true - }, - { - "name": "toUser", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "fromUser", - "toUser", - "userStats" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "transferPerpPosition", - "discriminator": [ - 23, - 172, - 188, - 168, - 134, - 210, - 3, - 108 - ], - "accounts": [ - { - "name": "fromUser", - "writable": true - }, - { - "name": "toUser", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": { - "option": "i64" - } - } - ] - }, - { - "name": "transferPools", - "discriminator": [ - 197, - 103, - 154, - 25, - 107, - 90, - 60, - 94 - ], - "accounts": [ - { - "name": "fromUser", - "writable": true - }, - { - "name": "toUser", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "fromUser", - "toUser", - "userStats" - ] - }, - { - "name": "state" - }, - { - "name": "depositFromSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "depositFromMarketIndex" - } - ] - } - }, - { - "name": "depositToSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "depositToMarketIndex" - } - ] - } - }, - { - "name": "borrowFromSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "borrowFromMarketIndex" - } - ] - } - }, - { - "name": "borrowToSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "borrowToMarketIndex" - } - ] - } - }, - { - "name": "driftSigner" - } - ], - "args": [ - { - "name": "depositFromMarketIndex", - "type": "u16" - }, - { - "name": "depositToMarketIndex", - "type": "u16" - }, - { - "name": "borrowFromMarketIndex", - "type": "u16" - }, - { - "name": "borrowToMarketIndex", - "type": "u16" - }, - { - "name": "depositAmount", - "type": { - "option": "u64" - } - }, - { - "name": "borrowAmount", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "transferProtocolIfSharesToRevenuePool", - "discriminator": [ - 236, - 136, - 147, - 153, - 146, - 205, - 104, - 29 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "ifRebalanceConfig", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "triggerOrder", - "discriminator": [ - 63, - 112, - 51, - 233, - 232, - 47, - 240, - 199 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "user", - "writable": true - } - ], - "args": [ - { - "name": "orderId", - "type": "u32" - } - ] - }, - { - "name": "updateAdmin", - "discriminator": [ - 161, - 176, - 40, - 213, - 60, - 184, - 179, - 228 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "admin", - "type": "pubkey" - } - ] - }, - { - "name": "updateAmmCache", - "discriminator": [ - 88, - 4, - 63, - 94, - 83, - 224, - 255, - 130 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "ammCache", - "writable": true - }, - { - "name": "quoteMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateAmmConstituentMappingData", - "discriminator": [ - 84, - 70, - 33, - 167, - 133, - 107, - 59, - 24 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool" - }, - { - "name": "ammConstituentMapping", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 65, - 77, - 77, - 95, - 77, - 65, - 80 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "ammConstituentMappingData", - "type": { - "vec": { - "defined": { - "name": "addAmmConstituentMappingDatum" - } - } - } - } - ] - }, - { - "name": "updateAmmJitIntensity", - "discriminator": [ - 181, - 191, - 53, - 109, - 166, - 249, - 55, - 142 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "ammJitIntensity", - "type": "u8" - } - ] - }, - { - "name": "updateAmms", - "discriminator": [ - 201, - 106, - 217, - 253, - 4, - 175, - 228, - 97 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "marketIndexes", - "type": { - "vec": "u16" - } - } - ] - }, - { - "name": "updateConstituentCorrelationData", - "discriminator": [ - 79, - 14, - 19, - 73, - 221, - 106, - 62, - 109 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool" - }, - { - "name": "constituentCorrelations", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "index1", - "type": "u16" - }, - { - "name": "index2", - "type": "u16" - }, - { - "name": "correlation", - "type": "i64" - } - ] - }, - { - "name": "updateConstituentOracleInfo", - "discriminator": [ - 198, - 117, - 231, - 250, - 147, - 33, - 127, - 161 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "constituent", - "writable": true - }, - { - "name": "spotMarket" - }, - { - "name": "oracle" - } - ], - "args": [] - }, - { - "name": "updateConstituentParams", - "discriminator": [ - 238, - 130, - 122, - 31, - 12, - 104, - 192, - 122 - ], - "accounts": [ - { - "name": "lpPool" - }, - { - "name": "constituentTargetBase", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "constituent", - "writable": true - } - ], - "args": [ - { - "name": "constituentParams", - "type": { - "defined": { - "name": "constituentParams" - } - } - } - ] - }, - { - "name": "updateConstituentPausedOperations", - "discriminator": [ - 185, - 122, - 153, - 191, - 131, - 177, - 132, - 208 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "constituent", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updateConstituentStatus", - "discriminator": [ - 76, - 159, - 211, - 239, - 182, - 214, - 6, - 15 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "constituent", - "writable": true - } - ], - "args": [ - { - "name": "newStatus", - "type": "u8" - } - ] - }, - { - "name": "updateDelegateUserGovTokenInsuranceStake", - "discriminator": [ - 241, - 29, - 215, - 228, - 142, - 116, - 22, - 160 - ], - "accounts": [ - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 15, - 0 - ] - } - ] - } - }, - { - "name": "insuranceFundStake" - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 15, - 0 - ] - } - ] - } - }, - { - "name": "state" - } - ], - "args": [] - }, - { - "name": "updateDiscountMint", - "discriminator": [ - 32, - 252, - 122, - 211, - 66, - 31, - 47, - 241 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "discountMint", - "type": "pubkey" - } - ] - }, - { - "name": "updateExchangeStatus", - "discriminator": [ - 83, - 160, - 252, - 250, - 129, - 116, - 49, - 223 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "exchangeStatus", - "type": "u8" - } - ] - }, - { - "name": "updateFeatureBitFlagsBuilderCodes", - "discriminator": [ - 1, - 128, - 177, - 51, - 173, - 45, - 11, - 102 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsMedianTriggerPrice", - "discriminator": [ - 64, - 185, - 221, - 45, - 87, - 147, - 12, - 19 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsMintRedeemLpPool", - "discriminator": [ - 26, - 11, - 142, - 122, - 206, - 159, - 9, - 45 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsMmOracle", - "discriminator": [ - 218, - 134, - 33, - 186, - 231, - 59, - 130, - 149 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsSettleLpPool", - "discriminator": [ - 186, - 28, - 78, - 230, - 155, - 83, - 242, - 26 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsSwapLpPool", - "discriminator": [ - 83, - 16, - 150, - 12, - 102, - 3, - 22, - 58 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFundingRate", - "discriminator": [ - 201, - 178, - 116, - 212, - 166, - 144, - 72, - 238 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "updateHighLeverageModeConfig", - "discriminator": [ - 64, - 122, - 212, - 93, - 141, - 217, - 202, - 55 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "highLeverageModeConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 104, - 105, - 103, - 104, - 95, - 108, - 101, - 118, - 101, - 114, - 97, - 103, - 101, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "bool" - }, - { - "name": "currentUsers", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "updateIfRebalanceConfig", - "discriminator": [ - 142, - 245, - 249, - 66, - 249, - 181, - 22, - 83 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "ifRebalanceConfig", - "writable": true - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ifRebalanceConfigParams" - } - } - } - ] - }, - { - "name": "updateInitialAmmCacheInfo", - "discriminator": [ - 157, - 210, - 109, - 67, - 212, - 170, - 12, - 107 - ], - "accounts": [ - { - "name": "state", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateInitialPctToLiquidate", - "discriminator": [ - 210, - 133, - 225, - 128, - 194, - 50, - 13, - 109 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "initialPctToLiquidate", - "type": "u16" - } - ] - }, - { - "name": "updateInsuranceFundUnstakingPeriod", - "discriminator": [ - 44, - 69, - 43, - 226, - 204, - 223, - 202, - 52 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "insuranceFundUnstakingPeriod", - "type": "i64" - } - ] - }, - { - "name": "updateK", - "discriminator": [ - 72, - 98, - 9, - 139, - 129, - 229, - 172, - 56 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "sqrtK", - "type": "u128" - } - ] - }, - { - "name": "updateLiquidationDuration", - "discriminator": [ - 28, - 154, - 20, - 249, - 102, - 192, - 73, - 71 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "liquidationDuration", - "type": "u8" - } - ] - }, - { - "name": "updateLiquidationMarginBufferRatio", - "discriminator": [ - 132, - 224, - 243, - 160, - 154, - 82, - 97, - 215 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "liquidationMarginBufferRatio", - "type": "u32" - } - ] - }, - { - "name": "updateLpConstituentTargetBase", - "discriminator": [ - 157, - 65, - 50, - 207, - 59, - 236, - 161, - 110 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "ammConstituentMapping" - }, - { - "name": "constituentTargetBase", - "writable": true - }, - { - "name": "ammCache" - }, - { - "name": "lpPool" - } - ], - "args": [] - }, - { - "name": "updateLpPoolAum", - "discriminator": [ - 88, - 113, - 137, - 206, - 246, - 247, - 171, - 142 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "constituentTargetBase", - "writable": true - }, - { - "name": "ammCache", - "writable": true - } - ], - "args": [] - }, - { - "name": "updateLpPoolParams", - "discriminator": [ - 217, - 92, - 2, - 255, - 27, - 167, - 178, - 81 - ], - "accounts": [ - { - "name": "lpPool", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "lpPoolParams", - "type": { - "defined": { - "name": "lpPoolParams" - } - } - } - ] - }, - { - "name": "updateOracleGuardRails", - "discriminator": [ - 131, - 112, - 10, - 59, - 32, - 54, - 40, - 164 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "oracleGuardRails", - "type": { - "defined": { - "name": "oracleGuardRails" - } - } - } - ] - }, - { - "name": "updatePerpAuctionDuration", - "discriminator": [ - 126, - 110, - 52, - 174, - 30, - 206, - 215, - 90 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "minPerpAuctionDuration", - "type": "u8" - } - ] - }, - { - "name": "updatePerpBidAskTwap", - "discriminator": [ - 247, - 23, - 255, - 65, - 212, - 90, - 221, - 194 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "keeperStats" - }, - { - "name": "authority", - "signer": true - } - ], - "args": [] - }, - { - "name": "updatePerpFeeStructure", - "discriminator": [ - 23, - 178, - 111, - 203, - 73, - 22, - 140, - 75 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "feeStructure", - "type": { - "defined": { - "name": "feeStructure" - } - } - } - ] - }, - { - "name": "updatePerpMarketAmmOracleTwap", - "discriminator": [ - 241, - 74, - 114, - 123, - 206, - 153, - 24, - 202 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [] - }, - { - "name": "updatePerpMarketAmmSpreadAdjustment", - "discriminator": [ - 155, - 195, - 149, - 43, - 220, - 82, - 173, - 205 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "ammSpreadAdjustment", - "type": "i8" - }, - { - "name": "ammInventorySpreadAdjustment", - "type": "i8" - }, - { - "name": "referencePriceOffset", - "type": "i32" - } - ] - }, - { - "name": "updatePerpMarketAmmSummaryStats", - "discriminator": [ - 122, - 101, - 249, - 238, - 209, - 9, - 241, - 245 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "spotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "account", - "path": "perpMarket" - } - ] - } - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updatePerpMarketSummaryStatsParams" - } - } - } - ] - }, - { - "name": "updatePerpMarketBaseSpread", - "discriminator": [ - 71, - 95, - 84, - 168, - 9, - 157, - 198, - 65 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "baseSpread", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketConcentrationCoef", - "discriminator": [ - 24, - 78, - 232, - 126, - 169, - 176, - 230, - 16 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "concentrationScale", - "type": "u128" - } - ] - }, - { - "name": "updatePerpMarketContractTier", - "discriminator": [ - 236, - 128, - 15, - 95, - 203, - 214, - 68, - 117 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "contractTier", - "type": { - "defined": { - "name": "contractTier" - } - } - } - ] - }, - { - "name": "updatePerpMarketCurveUpdateIntensity", - "discriminator": [ - 50, - 131, - 6, - 156, - 226, - 231, - 189, - 72 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "curveUpdateIntensity", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketExpiry", - "discriminator": [ - 44, - 221, - 227, - 151, - 131, - 140, - 22, - 110 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "expiryTs", - "type": "i64" - } - ] - }, - { - "name": "updatePerpMarketFeeAdjustment", - "discriminator": [ - 194, - 174, - 87, - 102, - 43, - 148, - 32, - 112 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "feeAdjustment", - "type": "i16" - } - ] - }, - { - "name": "updatePerpMarketFundingPeriod", - "discriminator": [ - 171, - 161, - 69, - 91, - 129, - 139, - 161, - 28 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "fundingPeriod", - "type": "i64" - } - ] - }, - { - "name": "updatePerpMarketHighLeverageMarginRatio", - "discriminator": [ - 88, - 112, - 86, - 49, - 24, - 116, - 74, - 157 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "marginRatioInitial", - "type": "u16" - }, - { - "name": "marginRatioMaintenance", - "type": "u16" - } - ] - }, - { - "name": "updatePerpMarketImfFactor", - "discriminator": [ - 207, - 194, - 56, - 132, - 35, - 67, - 71, - 244 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "imfFactor", - "type": "u32" - }, - { - "name": "unrealizedPnlImfFactor", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketLiquidationFee", - "discriminator": [ - 90, - 137, - 9, - 145, - 41, - 8, - 148, - 117 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "liquidatorFee", - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketLpPoolFeeTransferScalar", - "discriminator": [ - 94, - 228, - 237, - 109, - 100, - 185, - 4, - 81 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "optionalLpFeeTransferScalar", - "type": { - "option": "u8" - } - }, - { - "name": "optionalLpNetPnlTransferScalar", - "type": { - "option": "u8" - } - } - ] - }, - { - "name": "updatePerpMarketLpPoolId", - "discriminator": [ - 119, - 208, - 154, - 88, - 165, - 92, - 21, - 188 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "lpPoolId", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketLpPoolPausedOperations", - "discriminator": [ - 181, - 94, - 93, - 146, - 51, - 89, - 32, - 135 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "lpPausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketLpPoolStatus", - "discriminator": [ - 67, - 6, - 252, - 61, - 54, - 88, - 89, - 233 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [ - { - "name": "lpStatus", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketMarginRatio", - "discriminator": [ - 130, - 173, - 107, - 45, - 119, - 105, - 26, - 113 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "marginRatioInitial", - "type": "u32" - }, - { - "name": "marginRatioMaintenance", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketMaxFillReserveFraction", - "discriminator": [ - 19, - 172, - 114, - 154, - 42, - 135, - 161, - 133 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxFillReserveFraction", - "type": "u16" - } - ] - }, - { - "name": "updatePerpMarketMaxImbalances", - "discriminator": [ - 15, - 206, - 73, - 133, - 60, - 8, - 86, - 89 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "unrealizedMaxImbalance", - "type": "u64" - }, - { - "name": "maxRevenueWithdrawPerPeriod", - "type": "u64" - }, - { - "name": "quoteMaxInsurance", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketMaxOpenInterest", - "discriminator": [ - 194, - 79, - 149, - 224, - 246, - 102, - 186, - 140 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxOpenInterest", - "type": "u128" - } - ] - }, - { - "name": "updatePerpMarketMaxSlippageRatio", - "discriminator": [ - 235, - 37, - 40, - 196, - 70, - 146, - 54, - 201 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxSlippageRatio", - "type": "u16" - } - ] - }, - { - "name": "updatePerpMarketMaxSpread", - "discriminator": [ - 80, - 252, - 122, - 62, - 40, - 218, - 91, - 100 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxSpread", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketMinOrderSize", - "discriminator": [ - 226, - 74, - 5, - 89, - 108, - 223, - 46, - 141 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "orderSize", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketName", - "discriminator": [ - 211, - 31, - 21, - 210, - 64, - 108, - 66, - 201 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "updatePerpMarketNumberOfUsers", - "discriminator": [ - 35, - 62, - 144, - 177, - 180, - 62, - 215, - 196 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "numberOfUsers", - "type": { - "option": "u32" - } - }, - { - "name": "numberOfUsersWithBase", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "updatePerpMarketOracle", - "discriminator": [ - 182, - 113, - 111, - 160, - 67, - 174, - 89, - 191 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "oldOracle" - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [ - { - "name": "oracle", - "type": "pubkey" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "skipInvariantCheck", - "type": "bool" - } - ] - }, - { - "name": "updatePerpMarketOracleLowRiskSlotDelayOverride", - "discriminator": [ - 124, - 108, - 147, - 229, - 109, - 117, - 123, - 3 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "oracleLowRiskSlotDelayOverride", - "type": "i8" - } - ] - }, - { - "name": "updatePerpMarketOracleSlotDelayOverride", - "discriminator": [ - 165, - 91, - 239, - 227, - 63, - 172, - 227, - 8 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "oracleSlotDelayOverride", - "type": "i8" - } - ] - }, - { - "name": "updatePerpMarketPausedOperations", - "discriminator": [ - 53, - 16, - 136, - 132, - 30, - 220, - 121, - 85 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketPnlPool", - "discriminator": [ - 50, - 202, - 249, - 224, - 166, - 184, - 13, - 143 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketProtectedMakerParams", - "discriminator": [ - 249, - 213, - 115, - 34, - 253, - 239, - 75, - 173 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "protectedMakerLimitPriceDivisor", - "type": { - "option": "u8" - } - }, - { - "name": "protectedMakerDynamicDivisor", - "type": { - "option": "u8" - } - } - ] - }, - { - "name": "updatePerpMarketReferencePriceOffsetDeadbandPct", - "discriminator": [ - 214, - 73, - 166, - 11, - 218, - 76, - 110, - 163 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "referencePriceOffsetDeadbandPct", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketStatus", - "discriminator": [ - 71, - 201, - 175, - 122, - 255, - 207, - 196, - 207 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "marketStatus" - } - } - } - ] - }, - { - "name": "updatePerpMarketStepSizeAndTickSize", - "discriminator": [ - 231, - 255, - 97, - 25, - 146, - 139, - 174, - 4 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "stepSize", - "type": "u64" - }, - { - "name": "tickSize", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketUnrealizedAssetWeight", - "discriminator": [ - 135, - 132, - 205, - 165, - 109, - 150, - 166, - 106 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "unrealizedInitialAssetWeight", - "type": "u32" - }, - { - "name": "unrealizedMaintenanceAssetWeight", - "type": "u32" - } - ] - }, - { - "name": "updatePrelaunchOracle", - "discriminator": [ - 220, - 132, - 27, - 27, - 233, - 220, - 61, - 219 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket" - }, - { - "name": "oracle", - "writable": true - } - ], - "args": [] - }, - { - "name": "updatePrelaunchOracleParams", - "discriminator": [ - 98, - 205, - 147, - 243, - 18, - 75, - 83, - 207 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "prelaunchOracle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101 - ] - }, - { - "kind": "arg", - "path": "params.perp_market_index" - } - ] - } - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "prelaunchOracleParams" - } - } - } - ] - }, - { - "name": "updateProtectedMakerModeConfig", - "discriminator": [ - 86, - 166, - 235, - 253, - 67, - 202, - 223, - 17 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "protectedMakerModeConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 111, - 116, - 101, - 99, - 116, - 101, - 100, - 95, - 109, - 97, - 107, - 101, - 114, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "bool" - }, - { - "name": "currentUsers", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "updatePythPullOracle", - "discriminator": [ - 230, - 191, - 189, - 94, - 108, - 59, - 74, - 197 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "pythSolanaReceiver", - "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" - }, - { - "name": "encodedVaa" - }, - { - "name": "priceFeed", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 121, - 116, - 104, - 95, - 112, - 117, - 108, - 108 - ] - }, - { - "kind": "arg", - "path": "feedId" - } - ] - } - } - ], - "args": [ - { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "params", - "type": "bytes" - } - ] - }, - { - "name": "updateSerumFulfillmentConfigStatus", - "discriminator": [ - 171, - 109, - 240, - 251, - 95, - 1, - 149, - 89 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "serumFulfillmentConfig", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - } - ] - }, - { - "name": "updateSpotAuctionDuration", - "discriminator": [ - 182, - 178, - 203, - 72, - 187, - 143, - 157, - 107 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "defaultSpotAuctionDuration", - "type": "u8" - } - ] - }, - { - "name": "updateSpotFeeStructure", - "discriminator": [ - 97, - 216, - 105, - 131, - 113, - 246, - 142, - 141 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "feeStructure", - "type": { - "defined": { - "name": "feeStructure" - } - } - } - ] - }, - { - "name": "updateSpotMarketAssetTier", - "discriminator": [ - 253, - 209, - 231, - 14, - 242, - 208, - 243, - 130 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "assetTier", - "type": { - "defined": { - "name": "assetTier" - } - } - } - ] - }, - { - "name": "updateSpotMarketBorrowRate", - "discriminator": [ - 71, - 239, - 236, - 153, - 210, - 62, - 254, - 76 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "optimalUtilization", - "type": "u32" - }, - { - "name": "optimalBorrowRate", - "type": "u32" - }, - { - "name": "maxBorrowRate", - "type": "u32" - }, - { - "name": "minBorrowRate", - "type": { - "option": "u8" - } - } - ] - }, - { - "name": "updateSpotMarketCumulativeInterest", - "discriminator": [ - 39, - 166, - 139, - 243, - 158, - 165, - 155, - 225 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "spotMarket" - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateSpotMarketExpiry", - "discriminator": [ - 208, - 11, - 211, - 159, - 226, - 24, - 11, - 247 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "expiryTs", - "type": "i64" - } - ] - }, - { - "name": "updateSpotMarketFeeAdjustment", - "discriminator": [ - 148, - 182, - 3, - 126, - 157, - 114, - 220, - 99 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "feeAdjustment", - "type": "i16" - } - ] - }, - { - "name": "updateSpotMarketIfFactor", - "discriminator": [ - 147, - 30, - 224, - 34, - 18, - 230, - 105, - 4 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "userIfFactor", - "type": "u32" - }, - { - "name": "totalIfFactor", - "type": "u32" - } - ] - }, - { - "name": "updateSpotMarketIfPausedOperations", - "discriminator": [ - 101, - 215, - 79, - 74, - 59, - 41, - 79, - 12 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updateSpotMarketLiquidationFee", - "discriminator": [ - 11, - 13, - 255, - 53, - 56, - 136, - 104, - 177 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "liquidatorFee", - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "type": "u32" - } - ] - }, - { - "name": "updateSpotMarketMarginWeights", - "discriminator": [ - 109, - 33, - 87, - 195, - 255, - 36, - 6, - 81 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "initialAssetWeight", - "type": "u32" - }, - { - "name": "maintenanceAssetWeight", - "type": "u32" - }, - { - "name": "initialLiabilityWeight", - "type": "u32" - }, - { - "name": "maintenanceLiabilityWeight", - "type": "u32" - }, - { - "name": "imfFactor", - "type": "u32" - } - ] - }, - { - "name": "updateSpotMarketMaxTokenBorrows", - "discriminator": [ - 57, - 102, - 204, - 212, - 253, - 95, - 13, - 199 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxTokenBorrowsFraction", - "type": "u16" - } - ] - }, - { - "name": "updateSpotMarketMaxTokenDeposits", - "discriminator": [ - 56, - 191, - 79, - 18, - 26, - 121, - 80, - 208 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxTokenDeposits", - "type": "u64" - } - ] - }, - { - "name": "updateSpotMarketMinOrderSize", - "discriminator": [ - 93, - 128, - 11, - 119, - 26, - 20, - 181, - 50 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "orderSize", - "type": "u64" - } - ] - }, - { - "name": "updateSpotMarketName", - "discriminator": [ - 17, - 208, - 1, - 1, - 162, - 211, - 188, - 224 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "updateSpotMarketOracle", - "discriminator": [ - 114, - 184, - 102, - 37, - 246, - 186, - 180, - 99 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "oldOracle" - } - ], - "args": [ - { - "name": "oracle", - "type": "pubkey" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "skipInvariantCheck", - "type": "bool" - } - ] - }, - { - "name": "updateSpotMarketOrdersEnabled", - "discriminator": [ - 190, - 79, - 206, - 15, - 26, - 229, - 229, - 43 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "ordersEnabled", - "type": "bool" - } - ] - }, - { - "name": "updateSpotMarketPausedOperations", - "discriminator": [ - 100, - 61, - 153, - 81, - 180, - 12, - 6, - 248 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updateSpotMarketPoolId", - "discriminator": [ - 22, - 213, - 197, - 160, - 139, - 193, - 81, - 149 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "poolId", - "type": "u8" - } - ] - }, - { - "name": "updateSpotMarketRevenueSettlePeriod", - "discriminator": [ - 81, - 92, - 126, - 41, - 250, - 225, - 156, - 219 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "revenueSettlePeriod", - "type": "i64" - } - ] - }, - { - "name": "updateSpotMarketScaleInitialAssetWeightStart", - "discriminator": [ - 217, - 204, - 204, - 118, - 204, - 130, - 225, - 147 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "scaleInitialAssetWeightStart", - "type": "u64" - } - ] - }, - { - "name": "updateSpotMarketStatus", - "discriminator": [ - 78, - 94, - 16, - 188, - 193, - 110, - 231, - 31 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "marketStatus" - } - } - } - ] - }, - { - "name": "updateSpotMarketStepSizeAndTickSize", - "discriminator": [ - 238, - 153, - 137, - 80, - 206, - 59, - 250, - 61 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "stepSize", - "type": "u64" - }, - { - "name": "tickSize", - "type": "u64" - } - ] - }, - { - "name": "updateStateMaxInitializeUserFee", - "discriminator": [ - 237, - 225, - 25, - 237, - 193, - 45, - 77, - 97 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "maxInitializeUserFee", - "type": "u16" - } - ] - }, - { - "name": "updateStateMaxNumberOfSubAccounts", - "discriminator": [ - 155, - 123, - 214, - 2, - 221, - 166, - 204, - 85 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "maxNumberOfSubAccounts", - "type": "u16" - } - ] - }, - { - "name": "updateStateSettlementDuration", - "discriminator": [ - 97, - 68, - 199, - 235, - 131, - 80, - 61, - 173 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "settlementDuration", - "type": "u16" - } - ] - }, - { - "name": "updateUserCustomMarginRatio", - "discriminator": [ - 21, - 221, - 140, - 187, - 32, - 129, - 11, - 123 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "marginRatio", - "type": "u32" - } - ] - }, - { - "name": "updateUserDelegate", - "discriminator": [ - 139, - 205, - 141, - 141, - 113, - 36, - 94, - 187 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "delegate", - "type": "pubkey" - } - ] - }, - { - "name": "updateUserGovTokenInsuranceStake", - "discriminator": [ - 143, - 99, - 235, - 187, - 20, - 159, - 184, - 84 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 15, - 0 - ] - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "signer", - "signer": true - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 15, - 0 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateUserIdle", - "discriminator": [ - 253, - 133, - 67, - 22, - 103, - 161, - 20, - 100 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "user", - "writable": true - } - ], - "args": [] - }, - { - "name": "updateUserMarginTradingEnabled", - "discriminator": [ - 194, - 92, - 204, - 223, - 246, - 188, - 31, - 203 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "marginTradingEnabled", - "type": "bool" - } - ] - }, - { - "name": "updateUserName", - "discriminator": [ - 135, - 25, - 185, - 56, - 165, - 53, - 34, - 136 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "updateUserPerpPositionCustomMarginRatio", - "discriminator": [ - 121, - 137, - 157, - 155, - 89, - 186, - 145, - 113 - ], - "accounts": [ - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "marginRatio", - "type": "u16" - } - ] - }, - { - "name": "updateUserPoolId", - "discriminator": [ - 219, - 86, - 73, - 106, - 56, - 218, - 128, - 109 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "poolId", - "type": "u8" - } - ] - }, - { - "name": "updateUserProtectedMakerOrders", - "discriminator": [ - 114, - 39, - 123, - 198, - 187, - 25, - 90, - 219 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "protectedMakerModeConfig", - "writable": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "protectedMakerOrders", - "type": "bool" - } - ] - }, - { - "name": "updateUserQuoteAssetInsuranceStake", - "discriminator": [ - 251, - 101, - 156, - 7, - 2, - 63, - 30, - 23 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "signer", - "signer": true - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateUserReduceOnly", - "discriminator": [ - 199, - 71, - 42, - 67, - 144, - 19, - 86, - 109 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "reduceOnly", - "type": "bool" - } - ] - }, - { - "name": "updateUserStatsReferrerStatus", - "discriminator": [ - 174, - 154, - 72, - 42, - 191, - 148, - 145, - 205 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [] - }, - { - "name": "updateWithdrawGuardThreshold", - "discriminator": [ - 56, - 18, - 39, - 61, - 155, - 211, - 44, - 133 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "withdrawGuardThreshold", - "type": "u64" - } - ] - }, - { - "name": "viewLpPoolAddLiquidityFees", - "discriminator": [ - 80, - 66, - 226, - 161, - 70, - 142, - 119, - 84 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "inMarketMint" - }, - { - "name": "inConstituent", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "lpMint" - }, - { - "name": "constituentTargetBase" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u128" - } - ] - }, - { - "name": "viewLpPoolRemoveLiquidityFees", - "discriminator": [ - 47, - 12, - 9, - 102, - 12, - 226, - 197, - 89 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "outMarketMint" - }, - { - "name": "outConstituent", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "lpMint" - }, - { - "name": "constituentTargetBase" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" - } - ] - }, - { - "name": "viewLpPoolSwapFees", - "discriminator": [ - 126, - 189, - 109, - 189, - 170, - 156, - 3, - 46 - ], - "accounts": [ - { - "name": "driftSigner" - }, - { - "name": "state" - }, - { - "name": "lpPool" - }, - { - "name": "constituentTargetBase" - }, - { - "name": "constituentCorrelations" - }, - { - "name": "constituentInTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "writable": true - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "authority", - "signer": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" - }, - { - "name": "inTargetWeight", - "type": "i64" - }, - { - "name": "outTargetWeight", - "type": "i64" - } - ] - }, - { - "name": "withdraw", - "discriminator": [ - 183, - 18, - 70, - 156, - 148, - 109, - 161, - 34 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "user", - "userStats" - ] - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "reduceOnly", - "type": "bool" - } - ] - }, - { - "name": "withdrawFromProgramVault", - "discriminator": [ - 120, - 40, - 183, - 149, - 232, - 18, - 224, - 151 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "driftSigner" - }, - { - "name": "constituent", - "writable": true - }, - { - "name": "constituentTokenAccount", - "writable": true - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "mint" - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "zeroMmOracleFields", - "discriminator": [ - 192, - 226, - 39, - 204, - 207, - 120, - 148, - 250 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [] - } - ], - "accounts": [ - { - "name": "ammCache", - "discriminator": [ - 213, - 114, - 161, - 56, - 20, - 22, - 2, - 59 - ] - }, - { - "name": "ammConstituentMapping", - "discriminator": [ - 254, - 89, - 5, - 173, - 66, - 54, - 214, - 247 - ] - }, - { - "name": "constituent", - "discriminator": [ - 0, - 61, - 36, - 35, - 177, - 76, - 216, - 205 - ] - }, - { - "name": "constituentCorrelations", - "discriminator": [ - 124, - 203, - 115, - 33, - 18, - 162, - 67, - 216 - ] - }, - { - "name": "constituentTargetBase", - "discriminator": [ - 255, - 142, - 134, - 71, - 125, - 66, - 198, - 99 - ] - }, - { - "name": "fuelOverflow", - "discriminator": [ - 182, - 64, - 231, - 177, - 226, - 142, - 69, - 58 - ] - }, - { - "name": "highLeverageModeConfig", - "discriminator": [ - 3, - 196, - 90, - 189, - 193, - 64, - 228, - 234 - ] - }, - { - "name": "ifRebalanceConfig", - "discriminator": [ - 214, - 84, - 40, - 251, - 107, - 144, - 173, - 239 - ] - }, - { - "name": "insuranceFundStake", - "discriminator": [ - 110, - 202, - 14, - 42, - 95, - 73, - 90, - 95 - ] - }, - { - "name": "lpPool", - "discriminator": [ - 228, - 152, - 141, - 224, - 161, - 170, - 11, - 89 - ] - }, - { - "name": "openbookV2FulfillmentConfig", - "discriminator": [ - 3, - 43, - 58, - 106, - 131, - 132, - 199, - 171 - ] - }, - { - "name": "perpMarket", - "discriminator": [ - 10, - 223, - 12, - 44, - 107, - 245, - 55, - 247 - ] - }, - { - "name": "phoenixV1FulfillmentConfig", - "discriminator": [ - 233, - 45, - 62, - 40, - 35, - 129, - 48, - 72 - ] - }, - { - "name": "prelaunchOracle", - "discriminator": [ - 92, - 14, - 139, - 234, - 72, - 244, - 68, - 26 - ] - }, - { - "name": "protectedMakerModeConfig", - "discriminator": [ - 47, - 86, - 90, - 9, - 224, - 255, - 10, - 69 - ] - }, - { - "name": "pythLazerOracle", - "discriminator": [ - 159, - 7, - 161, - 249, - 34, - 81, - 121, - 133 - ] - }, - { - "name": "referrerName", - "discriminator": [ - 105, - 133, - 170, - 110, - 52, - 42, - 28, - 182 - ] - }, - { - "name": "revenueShare", - "discriminator": [ - 55, - 40, - 228, - 7, - 139, - 52, - 180, - 110 - ] - }, - { - "name": "revenueShareEscrow", - "discriminator": [ - 98, - 167, - 3, - 46, - 74, - 177, - 173, - 252 - ] - }, - { - "name": "serumV3FulfillmentConfig", - "discriminator": [ - 65, - 160, - 197, - 112, - 239, - 168, - 103, - 185 - ] - }, - { - "name": "signedMsgUserOrders", - "discriminator": [ - 70, - 6, - 50, - 248, - 222, - 1, - 143, - 49 - ] - }, - { - "name": "signedMsgWsDelegates", - "discriminator": [ - 190, - 115, - 111, - 44, - 216, - 252, - 108, - 85 - ] - }, - { - "name": "spotMarket", - "discriminator": [ - 100, - 177, - 8, - 107, - 168, - 65, - 65, - 39 - ] - }, - { - "name": "state", - "discriminator": [ - 216, - 146, - 107, - 94, - 104, - 75, - 182, - 177 - ] - }, - { - "name": "user", - "discriminator": [ - 159, - 117, - 95, - 227, - 239, - 151, - 58, - 236 - ] - }, - { - "name": "userStats", - "discriminator": [ - 176, - 223, - 136, - 27, - 122, - 79, - 32, - 227 - ] - } - ], - "events": [ - { - "name": "curveRecord", - "discriminator": [ - 101, - 238, - 40, - 228, - 70, - 46, - 61, - 117 - ] - }, - { - "name": "deleteUserRecord", - "discriminator": [ - 71, - 111, - 190, - 118, - 7, - 3, - 132, - 222 - ] - }, - { - "name": "depositRecord", - "discriminator": [ - 180, - 241, - 218, - 207, - 102, - 135, - 44, - 134 - ] - }, - { - "name": "fuelSeasonRecord", - "discriminator": [ - 19, - 137, - 119, - 33, - 224, - 249, - 6, - 87 - ] - }, - { - "name": "fuelSweepRecord", - "discriminator": [ - 41, - 84, - 37, - 246, - 132, - 240, - 131, - 8 - ] - }, - { - "name": "fundingPaymentRecord", - "discriminator": [ - 8, - 59, - 96, - 20, - 137, - 201, - 56, - 95 - ] - }, - { - "name": "fundingRateRecord", - "discriminator": [ - 68, - 3, - 255, - 26, - 133, - 91, - 147, - 254 - ] - }, - { - "name": "insuranceFundRecord", - "discriminator": [ - 56, - 222, - 215, - 235, - 78, - 197, - 99, - 146 - ] - }, - { - "name": "insuranceFundStakeRecord", - "discriminator": [ - 68, - 66, - 156, - 7, - 216, - 148, - 250, - 114 - ] - }, - { - "name": "insuranceFundSwapRecord", - "discriminator": [ - 85, - 190, - 99, - 203, - 237, - 33, - 227, - 100 - ] - }, - { - "name": "lpBorrowLendDepositRecord", - "discriminator": [ - 242, - 181, - 11, - 56, - 243, - 61, - 79, - 210 - ] - }, - { - "name": "lpMintRedeemRecord", - "discriminator": [ - 53, - 178, - 142, - 73, - 78, - 91, - 91, - 8 - ] - }, - { - "name": "lpRecord", - "discriminator": [ - 101, - 22, - 54, - 38, - 178, - 13, - 142, - 111 - ] - }, - { - "name": "lpSettleRecord", - "discriminator": [ - 208, - 191, - 131, - 110, - 173, - 48, - 7, - 2 - ] - }, - { - "name": "lpSwapRecord", - "discriminator": [ - 159, - 62, - 130, - 196, - 96, - 79, - 176, - 254 - ] - }, - { - "name": "liquidationRecord", - "discriminator": [ - 127, - 17, - 0, - 108, - 182, - 13, - 231, - 53 - ] - }, - { - "name": "newUserRecord", - "discriminator": [ - 236, - 186, - 113, - 219, - 42, - 51, - 149, - 249 - ] - }, - { - "name": "orderActionRecord", - "discriminator": [ - 224, - 52, - 67, - 71, - 194, - 237, - 109, - 1 - ] - }, - { - "name": "orderRecord", - "discriminator": [ - 104, - 19, - 64, - 56, - 89, - 21, - 2, - 90 - ] - }, - { - "name": "revenueShareSettleRecord", - "discriminator": [ - 61, - 162, - 89, - 10, - 24, - 20, - 59, - 45 - ] - }, - { - "name": "settlePnlRecord", - "discriminator": [ - 57, - 68, - 105, - 26, - 119, - 198, - 213, - 89 - ] - }, - { - "name": "signedMsgOrderRecord", - "discriminator": [ - 211, - 197, - 25, - 18, - 142, - 86, - 113, - 27 - ] - }, - { - "name": "spotInterestRecord", - "discriminator": [ - 183, - 186, - 203, - 186, - 225, - 187, - 95, - 130 - ] - }, - { - "name": "spotMarketVaultDepositRecord", - "discriminator": [ - 178, - 217, - 23, - 188, - 127, - 190, - 32, - 73 - ] - }, - { - "name": "swapRecord", - "discriminator": [ - 162, - 187, - 123, - 194, - 138, - 56, - 250, - 241 - ] - }, - { - "name": "transferProtocolIfSharesToRevenuePoolRecord", - "discriminator": [ - 209, - 118, - 142, - 167, - 130, - 46, - 164, - 151 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "invalidEd25519InstructionProgramId", - "msg": "invalid ed25519 instruction program" - }, - { - "code": 6001, - "name": "invalidEd25519InstructionDataLength", - "msg": "invalid ed25519 instruction data length" - }, - { - "code": 6002, - "name": "invalidSignatureIndex", - "msg": "invalid signature index" - }, - { - "code": 6003, - "name": "invalidSignatureOffset", - "msg": "invalid signature offset" - }, - { - "code": 6004, - "name": "invalidPublicKeyOffset", - "msg": "invalid public key offset" - }, - { - "code": 6005, - "name": "invalidMessageOffset", - "msg": "invalid message offset" - }, - { - "code": 6006, - "name": "invalidMessageDataSize", - "msg": "invalid message data size" - }, - { - "code": 6007, - "name": "invalidInstructionIndex", - "msg": "invalid instruction index" - }, - { - "code": 6008, - "name": "messageOffsetOverflow", - "msg": "message offset overflow" - }, - { - "code": 6009, - "name": "invalidMessageHex", - "msg": "invalid message hex" - }, - { - "code": 6010, - "name": "invalidMessageData", - "msg": "invalid message data" - }, - { - "code": 6011, - "name": "loadInstructionAtFailed", - "msg": "loading custom ix at index failed" - } - ], - "types": [ - { - "name": "amm", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "oracle", - "docs": [ - "oracle price data public key" - ], - "type": "pubkey" - }, - { - "name": "historicalOracleData", - "docs": [ - "stores historically witnessed oracle data" - ], - "type": { - "defined": { - "name": "historicalOracleData" - } - } - }, - { - "name": "baseAssetAmountPerLp", - "docs": [ - "accumulated base asset amount since inception per lp share", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteAssetAmountPerLp", - "docs": [ - "accumulated quote asset amount since inception per lp share", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "feePool", - "docs": [ - "partition of fees from perp market trading moved from pnl settlements" - ], - "type": { - "defined": { - "name": "poolBalance" - } - } - }, - { - "name": "baseAssetReserve", - "docs": [ - "`x` reserves for constant product mm formula (x * y = k)", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "quoteAssetReserve", - "docs": [ - "`y` reserves for constant product mm formula (x * y = k)", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "concentrationCoef", - "docs": [ - "determines how close the min/max base asset reserve sit vs base reserves", - "allow for decreasing slippage without increasing liquidity and v.v.", - "precision: PERCENTAGE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "minBaseAssetReserve", - "docs": [ - "minimum base_asset_reserve allowed before AMM is unavailable", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "maxBaseAssetReserve", - "docs": [ - "maximum base_asset_reserve allowed before AMM is unavailable", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "sqrtK", - "docs": [ - "`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "pegMultiplier", - "docs": [ - "normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced", - "precision: PEG_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "terminalQuoteAssetReserve", - "docs": [ - "y when market is balanced. stored to save computation", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "baseAssetAmountLong", - "docs": [ - "always non-negative. tracks number of total longs in market (regardless of counterparty)", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "baseAssetAmountShort", - "docs": [ - "always non-positive. tracks number of total shorts in market (regardless of counterparty)", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "baseAssetAmountWithAmm", - "docs": [ - "tracks net position (longs-shorts) in market with AMM as counterparty", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "baseAssetAmountWithUnsettledLp", - "docs": [ - "tracks net position (longs-shorts) in market with LPs as counterparty", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "maxOpenInterest", - "docs": [ - "max allowed open interest, blocks trades that breach this value", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "quoteAssetAmount", - "docs": [ - "sum of all user's perp quote_asset_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteEntryAmountLong", - "docs": [ - "sum of all long user's quote_entry_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteEntryAmountShort", - "docs": [ - "sum of all short user's quote_entry_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteBreakEvenAmountLong", - "docs": [ - "sum of all long user's quote_break_even_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteBreakEvenAmountShort", - "docs": [ - "sum of all short user's quote_break_even_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "userLpShares", - "docs": [ - "total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastFundingRate", - "docs": [ - "last funding rate in this perp market (unit is quote per base)", - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastFundingRateLong", - "docs": [ - "last funding rate for longs in this perp market (unit is quote per base)", - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastFundingRateShort", - "docs": [ - "last funding rate for shorts in this perp market (unit is quote per base)", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "last24hAvgFundingRate", - "docs": [ - "estimate of last 24h of funding rate perp market (unit is quote per base)", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "totalFee", - "docs": [ - "total fees collected by this perp market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "totalMmFee", - "docs": [ - "total fees collected by the vAMM's bid/ask spread", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "totalExchangeFee", - "docs": [ - "total fees collected by exchange fee schedule", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalFeeMinusDistributions", - "docs": [ - "total fees minus any recognized upnl and pool withdraws", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "totalFeeWithdrawn", - "docs": [ - "sum of all fees from fee pool withdrawn to revenue pool", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalLiquidationFee", - "docs": [ - "all fees collected by market for liquidations", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeFundingRateLong", - "docs": [ - "accumulated funding rate for longs since inception in market" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "cumulativeFundingRateShort", - "docs": [ - "accumulated funding rate for shorts since inception in market" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "totalSocialLoss", - "docs": [ - "accumulated social loss paid by users since inception in market" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "askBaseAssetReserve", - "docs": [ - "transformed base_asset_reserve for users going long", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "askQuoteAssetReserve", - "docs": [ - "transformed quote_asset_reserve for users going long", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "bidBaseAssetReserve", - "docs": [ - "transformed base_asset_reserve for users going short", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "bidQuoteAssetReserve", - "docs": [ - "transformed quote_asset_reserve for users going short", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastOracleNormalisedPrice", - "docs": [ - "the last seen oracle price partially shrunk toward the amm reserve price", - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastOracleReservePriceSpreadPct", - "docs": [ - "the gap between the oracle price and the reserve price = y * peg_multiplier / x" - ], - "type": "i64" - }, - { - "name": "lastBidPriceTwap", - "docs": [ - "average estimate of bid price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastAskPriceTwap", - "docs": [ - "average estimate of ask price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastMarkPriceTwap", - "docs": [ - "average estimate of (bid+ask)/2 price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastMarkPriceTwap5min", - "docs": [ - "average estimate of (bid+ask)/2 price over FIVE_MINUTES" - ], - "type": "u64" - }, - { - "name": "lastUpdateSlot", - "docs": [ - "the last blockchain slot the amm was updated" - ], - "type": "u64" - }, - { - "name": "lastOracleConfPct", - "docs": [ - "the pct size of the oracle confidence interval", - "precision: PERCENTAGE_PRECISION" - ], - "type": "u64" - }, - { - "name": "netRevenueSinceLastFunding", - "docs": [ - "the total_fee_minus_distribution change since the last funding update", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastFundingRateTs", - "docs": [ - "the last funding rate update unix_timestamp" - ], - "type": "i64" - }, - { - "name": "fundingPeriod", - "docs": [ - "the periodicity of the funding rate updates" - ], - "type": "i64" - }, - { - "name": "orderStepSize", - "docs": [ - "the base step size (increment) of orders", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "orderTickSize", - "docs": [ - "the price tick size of orders", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "minOrderSize", - "docs": [ - "the minimum base size of an order", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "mmOracleSlot", - "docs": [ - "the max base size a single user can have", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "volume24h", - "docs": [ - "estimated total of volume in market", - "QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "longIntensityVolume", - "docs": [ - "the volume intensity of long fills against AMM" - ], - "type": "u64" - }, - { - "name": "shortIntensityVolume", - "docs": [ - "the volume intensity of short fills against AMM" - ], - "type": "u64" - }, - { - "name": "lastTradeTs", - "docs": [ - "the blockchain unix timestamp at the time of the last trade" - ], - "type": "i64" - }, - { - "name": "markStd", - "docs": [ - "estimate of standard deviation of the fill (mark) prices", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "oracleStd", - "docs": [ - "estimate of standard deviation of the oracle price at each update", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastMarkPriceTwapTs", - "docs": [ - "the last unix_timestamp the mark twap was updated" - ], - "type": "i64" - }, - { - "name": "baseSpread", - "docs": [ - "the minimum spread the AMM can quote. also used as step size for some spread logic increases." - ], - "type": "u32" - }, - { - "name": "maxSpread", - "docs": [ - "the maximum spread the AMM can quote" - ], - "type": "u32" - }, - { - "name": "longSpread", - "docs": [ - "the spread for asks vs the reserve price" - ], - "type": "u32" - }, - { - "name": "shortSpread", - "docs": [ - "the spread for bids vs the reserve price" - ], - "type": "u32" - }, - { - "name": "mmOraclePrice", - "docs": [ - "MM oracle price" - ], - "type": "i64" - }, - { - "name": "maxFillReserveFraction", - "docs": [ - "the fraction of total available liquidity a single fill on the AMM can consume" - ], - "type": "u16" - }, - { - "name": "maxSlippageRatio", - "docs": [ - "the maximum slippage a single fill on the AMM can push" - ], - "type": "u16" - }, - { - "name": "curveUpdateIntensity", - "docs": [ - "the update intensity of AMM formulaic updates (adjusting k). 0-100" - ], - "type": "u8" - }, - { - "name": "ammJitIntensity", - "docs": [ - "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.", - "(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM." - ], - "type": "u8" - }, - { - "name": "oracleSource", - "docs": [ - "the oracle provider information. used to decode/scale the oracle public key" - ], - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "lastOracleValid", - "docs": [ - "tracks whether the oracle was considered valid at the last AMM update" - ], - "type": "bool" - }, - { - "name": "targetBaseAssetAmountPerLp", - "docs": [ - "the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split", - "precision: BASE_PRECISION" - ], - "type": "i32" - }, - { - "name": "perLpBase", - "docs": [ - "expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)" - ], - "type": "i8" - }, - { - "name": "oracleLowRiskSlotDelayOverride", - "docs": [ - "the override for the state.min_perp_auction_duration", - "0 is no override, -1 is disable speed bump, 1-100 is literal speed bump" - ], - "type": "i8" - }, - { - "name": "ammSpreadAdjustment", - "docs": [ - "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" - ], - "type": "i8" - }, - { - "name": "oracleSlotDelayOverride", - "type": "i8" - }, - { - "name": "mmOracleSequenceId", - "type": "u64" - }, - { - "name": "netUnsettledFundingPnl", - "type": "i64" - }, - { - "name": "quoteAssetAmountWithUnsettledLp", - "type": "i64" - }, - { - "name": "referencePriceOffset", - "type": "i32" - }, - { - "name": "ammInventorySpreadAdjustment", - "docs": [ - "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" - ], - "type": "i8" - }, - { - "name": "referencePriceOffsetDeadbandPct", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 2 - ] - } - }, - { - "name": "lastFundingOracleTwap", - "type": "i64" - } - ] - } - }, - { - "name": "addAmmConstituentMappingDatum", - "type": { - "kind": "struct", - "fields": [ - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "weight", - "type": "i64" - } - ] - } - }, - { - "name": "ammCache", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "cache", - "type": { - "vec": { - "defined": { - "name": "cacheInfo" - } - } - } - } - ] - } - }, - { - "name": "ammConstituentDatum", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "lastSlot", - "type": "u64" - }, - { - "name": "weight", - "docs": [ - "PERCENTAGE_PRECISION. The weight this constituent has on the perp market" - ], - "type": "i64" - } - ] - } - }, - { - "name": "ammConstituentMapping", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "lpPool", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "weights", - "type": { - "vec": { - "defined": { - "name": "ammConstituentDatum" - } - } - } - } - ] - } - }, - { - "name": "assetTier", - "type": { - "kind": "enum", - "variants": [ - { - "name": "collateral" - }, - { - "name": "protected" - }, - { - "name": "cross" - }, - { - "name": "isolated" - }, - { - "name": "unlisted" - } - ] - } - }, - { - "name": "builderInfo", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "maxFeeTenthBps", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 6 - ] - } - } - ] - } - }, - { - "name": "cacheInfo", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "oracle", - "type": "pubkey" - }, - { - "name": "lastFeePoolTokenAmount", - "type": "u128" - }, - { - "name": "lastNetPnlPoolTokenAmount", - "type": "i128" - }, - { - "name": "lastExchangeFees", - "type": "u128" - }, - { - "name": "lastSettleAmmExFees", - "type": "u128" - }, - { - "name": "lastSettleAmmPnl", - "type": "i128" - }, - { - "name": "position", - "docs": [ - "BASE PRECISION" - ], - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "lastSettleAmount", - "type": "u64" - }, - { - "name": "lastSettleSlot", - "type": "u64" - }, - { - "name": "lastSettleTs", - "type": "i64" - }, - { - "name": "quoteOwedFromLpPool", - "type": "i64" - }, - { - "name": "ammInventoryLimit", - "type": "i64" - }, - { - "name": "oraclePrice", - "type": "i64" - }, - { - "name": "oracleSlot", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "oracleSource", - "type": "u8" - }, - { - "name": "oracleValidity", - "type": "u8" - }, - { - "name": "lpStatusForPerpMarket", - "type": "u8" - }, - { - "name": "ammPositionScalar", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 34 - ] - } - } - ] - } - }, - { - "name": "constituent", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "address of the constituent" - ], - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "lpPool", - "type": "pubkey" - }, - { - "name": "vault", - "type": "pubkey" - }, - { - "name": "totalSwapFees", - "docs": [ - "total fees received by the constituent. Positive = fees received, Negative = fees paid" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "spotBalance", - "docs": [ - "spot borrow-lend balance for constituent" - ], - "type": { - "defined": { - "name": "constituentSpotBalance" - } - } - }, - { - "name": "lastSpotBalanceTokenAmount", - "type": "i64" - }, - { - "name": "cumulativeSpotInterestAccruedTokenAmount", - "type": "i64" - }, - { - "name": "maxWeightDeviation", - "docs": [ - "max deviation from target_weight allowed for the constituent", - "precision: PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "swapFeeMin", - "docs": [ - "min fee charged on swaps to/from this constituent", - "precision: PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "swapFeeMax", - "docs": [ - "max fee charged on swaps to/from this constituent", - "precision: PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "maxBorrowTokenAmount", - "docs": [ - "Max Borrow amount:", - "precision: token precision" - ], - "type": "u64" - }, - { - "name": "vaultTokenBalance", - "docs": [ - "ata token balance in token precision" - ], - "type": "u64" - }, - { - "name": "lastOraclePrice", - "type": "i64" - }, - { - "name": "lastOracleSlot", - "type": "u64" - }, - { - "name": "oracleStalenessThreshold", - "docs": [ - "Delay allowed for valid AUM calculation" - ], - "type": "u64" - }, - { - "name": "flashLoanInitialTokenAmount", - "type": "u64" - }, - { - "name": "nextSwapId", - "docs": [ - "Every swap to/from this constituent has a monotonically increasing id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "derivativeWeight", - "docs": [ - "percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight" - ], - "type": "u64" - }, - { - "name": "volatility", - "type": "u64" - }, - { - "name": "constituentDerivativeDepegThreshold", - "type": "u64" - }, - { - "name": "constituentDerivativeIndex", - "docs": [ - "The `constituent_index` of the parent constituent. -1 if it is a parent index", - "Example: if in a pool with SOL (parent) and dSOL (derivative),", - "SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,", - "dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1" - ], - "type": "i16" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "decimals", - "type": "u8" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "vaultBump", - "type": "u8" - }, - { - "name": "gammaInventory", - "type": "u8" - }, - { - "name": "gammaExecution", - "type": "u8" - }, - { - "name": "xi", - "type": "u8" - }, - { - "name": "status", - "type": "u8" - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 162 - ] - } - } - ] - } - }, - { - "name": "constituentCorrelations", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "lpPool", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "correlations", - "type": { - "vec": "i64" - } - } - ] - } - }, - { - "name": "constituentParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxWeightDeviation", - "type": { - "option": "i64" - } - }, - { - "name": "swapFeeMin", - "type": { - "option": "i64" - } - }, - { - "name": "swapFeeMax", - "type": { - "option": "i64" - } - }, - { - "name": "maxBorrowTokenAmount", - "type": { - "option": "u64" - } - }, - { - "name": "oracleStalenessThreshold", - "type": { - "option": "u64" - } - }, - { - "name": "costToTradeBps", - "type": { - "option": "i32" - } - }, - { - "name": "constituentDerivativeIndex", - "type": { - "option": "i16" - } - }, - { - "name": "derivativeWeight", - "type": { - "option": "u64" - } - }, - { - "name": "volatility", - "type": { - "option": "u64" - } - }, - { - "name": "gammaExecution", - "type": { - "option": "u8" - } - }, - { - "name": "gammaInventory", - "type": { - "option": "u8" - } - }, - { - "name": "xi", - "type": { - "option": "u8" - } - } - ] - } - }, - { - "name": "constituentSpotBalance", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "scaledBalance", - "docs": [ - "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", - "interest of corresponding market.", - "precision: token precision" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeDeposits", - "docs": [ - "The cumulative deposits/borrows a user has made into a market", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "marketIndex", - "docs": [ - "The market index of the corresponding spot market" - ], - "type": "u16" - }, - { - "name": "balanceType", - "docs": [ - "Whether the position is deposit or borrow" - ], - "type": { - "defined": { - "name": "spotBalanceType" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 5 - ] - } - } - ] - } - }, - { - "name": "constituentTargetBase", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "lpPool", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "targets", - "type": { - "vec": { - "defined": { - "name": "targetsDatum" - } - } - } - } - ] - } - }, - { - "name": "contractTier", - "type": { - "kind": "enum", - "variants": [ - { - "name": "a" - }, - { - "name": "b" - }, - { - "name": "c" - }, - { - "name": "speculative" - }, - { - "name": "highlySpeculative" - }, - { - "name": "isolated" - } - ] - } - }, - { - "name": "contractType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "perpetual" - }, - { - "name": "future" - }, - { - "name": "prediction" - } - ] - } - }, - { - "name": "curveRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "recordId", - "type": "u64" - }, - { - "name": "pegMultiplierBefore", - "type": "u128" - }, - { - "name": "baseAssetReserveBefore", - "type": "u128" - }, - { - "name": "quoteAssetReserveBefore", - "type": "u128" - }, - { - "name": "sqrtKBefore", - "type": "u128" - }, - { - "name": "pegMultiplierAfter", - "type": "u128" - }, - { - "name": "baseAssetReserveAfter", - "type": "u128" - }, - { - "name": "quoteAssetReserveAfter", - "type": "u128" - }, - { - "name": "sqrtKAfter", - "type": "u128" - }, - { - "name": "baseAssetAmountLong", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "u128" - }, - { - "name": "baseAssetAmountShort", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "u128" - }, - { - "name": "baseAssetAmountWithAmm", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i128" - }, - { - "name": "totalFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i128" - }, - { - "name": "totalFeeMinusDistributions", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i128" - }, - { - "name": "adjustmentCost", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i128" - }, - { - "name": "oraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "fillRecord", - "type": "u128" - }, - { - "name": "numberOfUsers", - "type": "u32" - }, - { - "name": "marketIndex", - "type": "u16" - } - ] - } - }, - { - "name": "deleteUserRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "docs": [ - "unix_timestamp of action" - ], - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "keeper", - "type": { - "option": "pubkey" - } - } - ] - } - }, - { - "name": "depositDirection", - "type": { - "kind": "enum", - "variants": [ - { - "name": "deposit" - }, - { - "name": "withdraw" - } - ] - } - }, - { - "name": "depositExplanation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "none" - }, - { - "name": "transfer" - }, - { - "name": "borrow" - }, - { - "name": "repayBorrow" - }, - { - "name": "reward" - } - ] - } - }, - { - "name": "depositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "docs": [ - "unix_timestamp of action" - ], - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "user", - "docs": [ - "user account public key" - ], - "type": "pubkey" - }, - { - "name": "direction", - "type": { - "defined": { - "name": "depositDirection" - } - } - }, - { - "name": "depositRecordId", - "type": "u64" - }, - { - "name": "amount", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "marketIndex", - "docs": [ - "spot market index" - ], - "type": "u16" - }, - { - "name": "oraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "marketDepositBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "marketWithdrawBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "marketCumulativeDepositInterest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "marketCumulativeBorrowInterest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "totalDepositsAfter", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalWithdrawsAfter", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "explanation", - "type": { - "defined": { - "name": "depositExplanation" - } - } - }, - { - "name": "transferUser", - "type": { - "option": "pubkey" - } - }, - { - "name": "signer", - "type": { - "option": "pubkey" - } - }, - { - "name": "userTokenAmountAfter", - "docs": [ - "precision: token mint precision" - ], - "type": "i128" - } - ] - } - }, - { - "name": "feeStructure", - "type": { - "kind": "struct", - "fields": [ - { - "name": "feeTiers", - "type": { - "array": [ - { - "defined": { - "name": "feeTier" - } - }, - 10 - ] - } - }, - { - "name": "fillerRewardStructure", - "type": { - "defined": { - "name": "orderFillerRewardStructure" - } - } - }, - { - "name": "referrerRewardEpochUpperBound", - "type": "u64" - }, - { - "name": "flatFillerFee", - "type": "u64" - } - ] - } - }, - { - "name": "feeTier", - "type": { - "kind": "struct", - "fields": [ - { - "name": "feeNumerator", - "type": "u32" - }, - { - "name": "feeDenominator", - "type": "u32" - }, - { - "name": "makerRebateNumerator", - "type": "u32" - }, - { - "name": "makerRebateDenominator", - "type": "u32" - }, - { - "name": "referrerRewardNumerator", - "type": "u32" - }, - { - "name": "referrerRewardDenominator", - "type": "u32" - }, - { - "name": "refereeFeeNumerator", - "type": "u32" - }, - { - "name": "refereeFeeDenominator", - "type": "u32" - } - ] - } - }, - { - "name": "fuelOverflow", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "The authority of this overflow account" - ], - "type": "pubkey" - }, - { - "name": "fuelInsurance", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelDeposits", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelBorrows", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelPositions", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelTaker", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelMaker", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastFuelSweepTs", - "type": "u32" - }, - { - "name": "lastResetTs", - "type": "u32" - }, - { - "name": "padding", - "type": { - "array": [ - "u128", - 6 - ] - } - } - ] - } - }, - { - "name": "fuelSeasonRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "fuelInsurance", - "type": "u128" - }, - { - "name": "fuelDeposits", - "type": "u128" - }, - { - "name": "fuelBorrows", - "type": "u128" - }, - { - "name": "fuelPositions", - "type": "u128" - }, - { - "name": "fuelTaker", - "type": "u128" - }, - { - "name": "fuelMaker", - "type": "u128" - }, - { - "name": "fuelTotal", - "type": "u128" - } - ] - } - }, - { - "name": "fuelSweepRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "userStatsFuelInsurance", - "type": "u32" - }, - { - "name": "userStatsFuelDeposits", - "type": "u32" - }, - { - "name": "userStatsFuelBorrows", - "type": "u32" - }, - { - "name": "userStatsFuelPositions", - "type": "u32" - }, - { - "name": "userStatsFuelTaker", - "type": "u32" - }, - { - "name": "userStatsFuelMaker", - "type": "u32" - }, - { - "name": "fuelOverflowFuelInsurance", - "type": "u128" - }, - { - "name": "fuelOverflowFuelDeposits", - "type": "u128" - }, - { - "name": "fuelOverflowFuelBorrows", - "type": "u128" - }, - { - "name": "fuelOverflowFuelPositions", - "type": "u128" - }, - { - "name": "fuelOverflowFuelTaker", - "type": "u128" - }, - { - "name": "fuelOverflowFuelMaker", - "type": "u128" - } - ] - } - }, - { - "name": "fundingPaymentRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fundingPayment", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "baseAssetAmount", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "userLastCumulativeFunding", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "ammCumulativeFundingLong", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "ammCumulativeFundingShort", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - } - ] - } - }, - { - "name": "fundingRateRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "recordId", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fundingRate", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "fundingRateLong", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "fundingRateShort", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "cumulativeFundingRateLong", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "cumulativeFundingRateShort", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "oraclePriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "markPriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "periodRevenue", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "baseAssetAmountWithAmm", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i128" - }, - { - "name": "baseAssetAmountWithUnsettledLp", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i128" - } - ] - } - }, - { - "name": "highLeverageModeConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "currentUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "u8" - }, - { - "name": "padding1", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "currentMaintenanceUsers", - "type": "u32" - }, - { - "name": "padding2", - "type": { - "array": [ - "u8", - 24 - ] - } - } - ] - } - }, - { - "name": "historicalIndexData", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastIndexBidPrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastIndexAskPrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastIndexPriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastIndexPriceTwap5min", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastIndexPriceTwapTs", - "docs": [ - "unix_timestamp of last snapshot" - ], - "type": "i64" - } - ] - } - }, - { - "name": "historicalOracleData", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastOracleConf", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastOracleDelay", - "docs": [ - "number of slots since last update" - ], - "type": "i64" - }, - { - "name": "lastOraclePriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastOraclePriceTwap5min", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastOraclePriceTwapTs", - "docs": [ - "unix_timestamp of last snapshot" - ], - "type": "i64" - } - ] - } - }, - { - "name": "ifRebalanceConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "totalInAmount", - "docs": [ - "total amount to be sold" - ], - "type": "u64" - }, - { - "name": "currentInAmount", - "docs": [ - "amount already sold" - ], - "type": "u64" - }, - { - "name": "currentOutAmount", - "docs": [ - "amount already bought" - ], - "type": "u64" - }, - { - "name": "currentOutAmountTransferred", - "docs": [ - "amount already transferred to revenue pool" - ], - "type": "u64" - }, - { - "name": "currentInAmountSinceLastTransfer", - "docs": [ - "amount already bought in epoch" - ], - "type": "u64" - }, - { - "name": "epochStartTs", - "docs": [ - "start time of epoch" - ], - "type": "i64" - }, - { - "name": "epochInAmount", - "docs": [ - "amount already bought in epoch" - ], - "type": "u64" - }, - { - "name": "epochMaxInAmount", - "docs": [ - "max amount to swap in epoch" - ], - "type": "u64" - }, - { - "name": "epochDuration", - "docs": [ - "duration of epoch" - ], - "type": "i64" - }, - { - "name": "outMarketIndex", - "docs": [ - "market index to sell" - ], - "type": "u16" - }, - { - "name": "inMarketIndex", - "docs": [ - "market index to buy" - ], - "type": "u16" - }, - { - "name": "maxSlippageBps", - "type": "u16" - }, - { - "name": "swapMode", - "type": "u8" - }, - { - "name": "status", - "type": "u8" - }, - { - "name": "padding2", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "ifRebalanceConfigParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "totalInAmount", - "type": "u64" - }, - { - "name": "epochMaxInAmount", - "type": "u64" - }, - { - "name": "epochDuration", - "type": "i64" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "maxSlippageBps", - "type": "u16" - }, - { - "name": "swapMode", - "type": "u8" - }, - { - "name": "status", - "type": "u8" - } - ] - } - }, - { - "name": "insuranceClaim", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "revenueWithdrawSinceLastSettle", - "docs": [ - "The amount of revenue last settled", - "Positive if funds left the perp market,", - "negative if funds were pulled into the perp market", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "maxRevenueWithdrawPerPeriod", - "docs": [ - "The max amount of revenue that can be withdrawn per period", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "quoteMaxInsurance", - "docs": [ - "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "quoteSettledInsurance", - "docs": [ - "The amount of insurance that has been used to resolve bankruptcy and pnl deficits", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastRevenueWithdrawTs", - "docs": [ - "The last time revenue was settled in/out of market" - ], - "type": "i64" - } - ] - } - }, - { - "name": "insuranceFund", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "vault", - "type": "pubkey" - }, - { - "name": "totalShares", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "userShares", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "sharesBase", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "unstakingPeriod", - "type": "i64" - }, - { - "name": "lastRevenueSettleTs", - "type": "i64" - }, - { - "name": "revenueSettlePeriod", - "type": "i64" - }, - { - "name": "totalFactor", - "type": "u32" - }, - { - "name": "userFactor", - "type": "u32" - } - ] - } - }, - { - "name": "insuranceFundRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "userIfFactor", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "totalIfFactor", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "vaultAmountBefore", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "insuranceVaultAmountBefore", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "totalIfSharesBefore", - "type": "u128" - }, - { - "name": "totalIfSharesAfter", - "type": "u128" - }, - { - "name": "amount", - "docs": [ - "precision: token mint precision" - ], - "type": "i64" - } - ] - } - }, - { - "name": "insuranceFundStake", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "ifShares", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastWithdrawRequestShares", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "ifBase", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastValidTs", - "type": "i64" - }, - { - "name": "lastWithdrawRequestValue", - "type": "u64" - }, - { - "name": "lastWithdrawRequestTs", - "type": "i64" - }, - { - "name": "costBasis", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 14 - ] - } - } - ] - } - }, - { - "name": "insuranceFundStakeRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "action", - "type": { - "defined": { - "name": "stakeAction" - } - } - }, - { - "name": "amount", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "insuranceVaultAmountBefore", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "ifSharesBefore", - "type": "u128" - }, - { - "name": "userIfSharesBefore", - "type": "u128" - }, - { - "name": "totalIfSharesBefore", - "type": "u128" - }, - { - "name": "ifSharesAfter", - "type": "u128" - }, - { - "name": "userIfSharesAfter", - "type": "u128" - }, - { - "name": "totalIfSharesAfter", - "type": "u128" - } - ] - } - }, - { - "name": "insuranceFundSwapRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rebalanceConfig", - "type": "pubkey" - }, - { - "name": "inIfTotalSharesBefore", - "type": "u128" - }, - { - "name": "outIfTotalSharesBefore", - "type": "u128" - }, - { - "name": "inIfUserSharesBefore", - "type": "u128" - }, - { - "name": "outIfUserSharesBefore", - "type": "u128" - }, - { - "name": "inIfTotalSharesAfter", - "type": "u128" - }, - { - "name": "outIfTotalSharesAfter", - "type": "u128" - }, - { - "name": "inIfUserSharesAfter", - "type": "u128" - }, - { - "name": "outIfUserSharesAfter", - "type": "u128" - }, - { - "name": "ts", - "type": "i64" - }, - { - "name": "inAmount", - "type": "u64" - }, - { - "name": "outAmount", - "type": "u64" - }, - { - "name": "outOraclePrice", - "type": "u64" - }, - { - "name": "outOraclePriceTwap", - "type": "i64" - }, - { - "name": "inVaultAmountBefore", - "type": "u64" - }, - { - "name": "outVaultAmountBefore", - "type": "u64" - }, - { - "name": "inFundVaultAmountAfter", - "type": "u64" - }, - { - "name": "outFundVaultAmountAfter", - "type": "u64" - }, - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - } - ] - } - }, - { - "name": "lpAction", - "type": { - "kind": "enum", - "variants": [ - { - "name": "addLiquidity" - }, - { - "name": "removeLiquidity" - }, - { - "name": "settleLiquidity" - }, - { - "name": "removeLiquidityDerisk" - } - ] - } - }, - { - "name": "lpBorrowLendDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "direction", - "type": { - "defined": { - "name": "depositDirection" - } - } - }, - { - "name": "tokenBalance", - "type": "i64" - }, - { - "name": "lastTokenBalance", - "type": "i64" - }, - { - "name": "interestAccruedTokenAmount", - "type": "i64" - }, - { - "name": "amountDepositWithdraw", - "type": "u64" - }, - { - "name": "lpPool", - "type": "pubkey" - } - ] - } - }, - { - "name": "lpMintRedeemRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "description", - "type": "u8" - }, - { - "name": "amount", - "docs": [ - "precision: continutent mint precision, gross fees" - ], - "type": "u128" - }, - { - "name": "fee", - "docs": [ - "precision: fee on amount, constituent market mint precision" - ], - "type": "i128" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "oraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "mint", - "docs": [ - "token mint" - ], - "type": "pubkey" - }, - { - "name": "lpAmount", - "docs": [ - "lp amount, lp mint precision" - ], - "type": "u64" - }, - { - "name": "lpFee", - "docs": [ - "lp fee, lp mint precision" - ], - "type": "i64" - }, - { - "name": "lpPrice", - "docs": [ - "the fair price of the lp token, PRICE_PRECISION" - ], - "type": "u128" - }, - { - "name": "mintRedeemId", - "type": "u64" - }, - { - "name": "lastAum", - "docs": [ - "LPPool last_aum" - ], - "type": "u128" - }, - { - "name": "lastAumSlot", - "type": "u64" - }, - { - "name": "inMarketCurrentWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inMarketTargetWeight", - "type": "i64" - }, - { - "name": "lpPool", - "type": "pubkey" - } - ] - } - }, - { - "name": "lpPool", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "address of the vault." - ], - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "whitelistMint", - "type": "pubkey" - }, - { - "name": "constituentTargetBase", - "type": "pubkey" - }, - { - "name": "constituentCorrelations", - "type": "pubkey" - }, - { - "name": "maxAum", - "docs": [ - "The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)", - "which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)", - "pub quote_constituent_index: u16,", - "QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastAum", - "docs": [ - "QUOTE_PRECISION: AUM of the vault in USD, updated lazily" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeQuoteSentToPerpMarkets", - "docs": [ - "QUOTE PRECISION: Cumulative quotes from settles" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeQuoteReceivedFromPerpMarkets", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalMintRedeemFeesPaid", - "docs": [ - "QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "lastAumSlot", - "docs": [ - "timestamp of last AUM slot" - ], - "type": "u64" - }, - { - "name": "maxSettleQuoteAmount", - "type": "u64" - }, - { - "name": "padding", - "docs": [ - "timestamp of last vAMM revenue rebalance" - ], - "type": "u64" - }, - { - "name": "mintRedeemId", - "docs": [ - "Every mint/redeem has a monotonically increasing id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "settleId", - "type": "u64" - }, - { - "name": "minMintFee", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "tokenSupply", - "type": "u64" - }, - { - "name": "volatility", - "type": "u64" - }, - { - "name": "constituents", - "type": "u16" - }, - { - "name": "quoteConsituentIndex", - "type": "u16" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "gammaExecution", - "type": "u8" - }, - { - "name": "xi", - "type": "u8" - }, - { - "name": "targetOracleDelayFeeBpsPer10Slots", - "type": "u8" - }, - { - "name": "targetPositionDelayFeeBpsPer10Slots", - "type": "u8" - }, - { - "name": "lpPoolId", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 174 - ] - } - } - ] - } - }, - { - "name": "lpRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "action", - "type": { - "defined": { - "name": "lpAction" - } - } - }, - { - "name": "nShares", - "docs": [ - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "deltaBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "deltaQuoteAssetAmount", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "pnl", - "docs": [ - "realized pnl of the position settlement", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - } - ] - } - }, - { - "name": "lpSettleRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "recordId", - "type": "u64" - }, - { - "name": "lastTs", - "type": "i64" - }, - { - "name": "lastSlot", - "type": "u64" - }, - { - "name": "ts", - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "settleToLpAmount", - "type": "i64" - }, - { - "name": "perpAmmPnlDelta", - "type": "i64" - }, - { - "name": "perpAmmExFeeDelta", - "type": "i64" - }, - { - "name": "lpAum", - "type": "u128" - }, - { - "name": "lpPrice", - "type": "u128" - }, - { - "name": "lpPool", - "type": "pubkey" - } - ] - } - }, - { - "name": "lpSwapRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "outAmount", - "docs": [ - "precision: out market mint precision, gross fees" - ], - "type": "u128" - }, - { - "name": "inAmount", - "docs": [ - "precision: in market mint precision, gross fees" - ], - "type": "u128" - }, - { - "name": "outFee", - "docs": [ - "precision: fee on amount_out, in market mint precision" - ], - "type": "i128" - }, - { - "name": "inFee", - "docs": [ - "precision: fee on amount_in, out market mint precision" - ], - "type": "i128" - }, - { - "name": "outSpotMarketIndex", - "type": "u16" - }, - { - "name": "inSpotMarketIndex", - "type": "u16" - }, - { - "name": "outConstituentIndex", - "type": "u16" - }, - { - "name": "inConstituentIndex", - "type": "u16" - }, - { - "name": "outOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastAum", - "docs": [ - "LPPool last_aum, QUOTE_PRECISION" - ], - "type": "u128" - }, - { - "name": "lastAumSlot", - "type": "u64" - }, - { - "name": "inMarketCurrentWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "outMarketCurrentWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inMarketTargetWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "outMarketTargetWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inSwapId", - "type": "u64" - }, - { - "name": "outSwapId", - "type": "u64" - }, - { - "name": "lpPool", - "type": "pubkey" - } - ] - } - }, - { - "name": "liquidateBorrowForPerpPnlRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "marketOraclePrice", - "type": "i64" - }, - { - "name": "pnlTransfer", - "type": "u128" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "liabilityPrice", - "type": "i64" - }, - { - "name": "liabilityTransfer", - "type": "u128" - } - ] - } - }, - { - "name": "liquidatePerpPnlForDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "marketOraclePrice", - "type": "i64" - }, - { - "name": "pnlTransfer", - "type": "u128" - }, - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "assetPrice", - "type": "i64" - }, - { - "name": "assetTransfer", - "type": "u128" - } - ] - } - }, - { - "name": "liquidatePerpRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "oraclePrice", - "type": "i64" - }, - { - "name": "baseAssetAmount", - "type": "i64" - }, - { - "name": "quoteAssetAmount", - "type": "i64" - }, - { - "name": "lpShares", - "docs": [ - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u64" - }, - { - "name": "fillRecordId", - "type": "u64" - }, - { - "name": "userOrderId", - "type": "u32" - }, - { - "name": "liquidatorOrderId", - "type": "u32" - }, - { - "name": "liquidatorFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "ifFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - } - ] - } - }, - { - "name": "liquidateSpotRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "assetPrice", - "type": "i64" - }, - { - "name": "assetTransfer", - "type": "u128" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "liabilityPrice", - "type": "i64" - }, - { - "name": "liabilityTransfer", - "docs": [ - "precision: token mint precision" - ], - "type": "u128" - }, - { - "name": "ifFee", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - } - ] - } - }, - { - "name": "liquidationRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "liquidationType", - "type": { - "defined": { - "name": "liquidationType" - } - } - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "liquidator", - "type": "pubkey" - }, - { - "name": "marginRequirement", - "type": "u128" - }, - { - "name": "totalCollateral", - "type": "i128" - }, - { - "name": "marginFreed", - "type": "u64" - }, - { - "name": "liquidationId", - "type": "u16" - }, - { - "name": "bankrupt", - "type": "bool" - }, - { - "name": "canceledOrderIds", - "type": { - "vec": "u32" - } - }, - { - "name": "liquidatePerp", - "type": { - "defined": { - "name": "liquidatePerpRecord" - } - } - }, - { - "name": "liquidateSpot", - "type": { - "defined": { - "name": "liquidateSpotRecord" - } - } - }, - { - "name": "liquidateBorrowForPerpPnl", - "type": { - "defined": { - "name": "liquidateBorrowForPerpPnlRecord" - } - } - }, - { - "name": "liquidatePerpPnlForDeposit", - "type": { - "defined": { - "name": "liquidatePerpPnlForDepositRecord" - } - } - }, - { - "name": "perpBankruptcy", - "type": { - "defined": { - "name": "perpBankruptcyRecord" - } - } - }, - { - "name": "spotBankruptcy", - "type": { - "defined": { - "name": "spotBankruptcyRecord" - } - } - } - ] - } - }, - { - "name": "liquidationType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "liquidatePerp" - }, - { - "name": "liquidateSpot" - }, - { - "name": "liquidateBorrowForPerpPnl" - }, - { - "name": "liquidatePerpPnlForDeposit" - }, - { - "name": "perpBankruptcy" - }, - { - "name": "spotBankruptcy" - } - ] - } - }, - { - "name": "lpPoolParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxSettleQuoteAmount", - "type": { - "option": "u64" - } - }, - { - "name": "volatility", - "type": { - "option": "u64" - } - }, - { - "name": "gammaExecution", - "type": { - "option": "u8" - } - }, - { - "name": "xi", - "type": { - "option": "u8" - } - }, - { - "name": "maxAum", - "type": { - "option": "u128" - } - }, - { - "name": "whitelistMint", - "type": { - "option": "pubkey" - } - } - ] - } - }, - { - "name": "marginMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "default" - }, - { - "name": "highLeverage" - }, - { - "name": "highLeverageMaintenance" - } - ] - } - }, - { - "name": "marketStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "initialized" - }, - { - "name": "active" - }, - { - "name": "fundingPaused" - }, - { - "name": "ammPaused" - }, - { - "name": "fillPaused" - }, - { - "name": "withdrawPaused" - }, - { - "name": "reduceOnly" - }, - { - "name": "settlement" - }, - { - "name": "delisted" - } - ] - } - }, - { - "name": "marketType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "spot" - }, - { - "name": "perp" - } - ] - } - }, - { - "name": "modifyOrderParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "direction", - "type": { - "option": { - "defined": { - "name": "positionDirection" - } - } - } - }, - { - "name": "baseAssetAmount", - "type": { - "option": "u64" - } - }, - { - "name": "price", - "type": { - "option": "u64" - } - }, - { - "name": "reduceOnly", - "type": { - "option": "bool" - } - }, - { - "name": "postOnly", - "type": { - "option": { - "defined": { - "name": "postOnlyParam" - } - } - } - }, - { - "name": "bitFlags", - "type": { - "option": "u8" - } - }, - { - "name": "maxTs", - "type": { - "option": "i64" - } - }, - { - "name": "triggerPrice", - "type": { - "option": "u64" - } - }, - { - "name": "triggerCondition", - "type": { - "option": { - "defined": { - "name": "orderTriggerCondition" - } - } - } - }, - { - "name": "oraclePriceOffset", - "type": { - "option": "i32" - } - }, - { - "name": "auctionDuration", - "type": { - "option": "u8" - } - }, - { - "name": "auctionStartPrice", - "type": { - "option": "i64" - } - }, - { - "name": "auctionEndPrice", - "type": { - "option": "i64" - } - }, - { - "name": "policy", - "type": { - "option": "u8" - } - } - ] - } - }, - { - "name": "newUserRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "docs": [ - "unix_timestamp of action" - ], - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "referrer", - "type": "pubkey" - } - ] - } - }, - { - "name": "openbookV2FulfillmentConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "openbookV2ProgramId", - "type": "pubkey" - }, - { - "name": "openbookV2Market", - "type": "pubkey" - }, - { - "name": "openbookV2MarketAuthority", - "type": "pubkey" - }, - { - "name": "openbookV2EventHeap", - "type": "pubkey" - }, - { - "name": "openbookV2Bids", - "type": "pubkey" - }, - { - "name": "openbookV2Asks", - "type": "pubkey" - }, - { - "name": "openbookV2BaseVault", - "type": "pubkey" - }, - { - "name": "openbookV2QuoteVault", - "type": "pubkey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": { - "name": "spotFulfillmentType" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "oracleGuardRails", - "type": { - "kind": "struct", - "fields": [ - { - "name": "priceDivergence", - "type": { - "defined": { - "name": "priceDivergenceGuardRails" - } - } - }, - { - "name": "validity", - "type": { - "defined": { - "name": "validityGuardRails" - } - } - } - ] - } - }, - { - "name": "oracleSource", - "type": { - "kind": "enum", - "variants": [ - { - "name": "pyth" - }, - { - "name": "switchboard" - }, - { - "name": "quoteAsset" - }, - { - "name": "pyth1K" - }, - { - "name": "pyth1M" - }, - { - "name": "pythStableCoin" - }, - { - "name": "prelaunch" - }, - { - "name": "pythPull" - }, - { - "name": "pyth1KPull" - }, - { - "name": "pyth1MPull" - }, - { - "name": "pythStableCoinPull" - }, - { - "name": "switchboardOnDemand" - }, - { - "name": "pythLazer" - }, - { - "name": "pythLazer1K" - }, - { - "name": "pythLazer1M" - }, - { - "name": "pythLazerStableCoin" - } - ] - } - }, - { - "name": "order", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "slot", - "docs": [ - "The slot the order was placed" - ], - "type": "u64" - }, - { - "name": "price", - "docs": [ - "The limit price for the order (can be 0 for market orders)", - "For orders with an auction, this price isn't used until the auction is complete", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "baseAssetAmount", - "docs": [ - "The size of the order", - "precision for perps: BASE_PRECISION", - "precision for spot: token mint precision" - ], - "type": "u64" - }, - { - "name": "baseAssetAmountFilled", - "docs": [ - "The amount of the order filled", - "precision for perps: BASE_PRECISION", - "precision for spot: token mint precision" - ], - "type": "u64" - }, - { - "name": "quoteAssetAmountFilled", - "docs": [ - "The amount of quote filled for the order", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "triggerPrice", - "docs": [ - "At what price the order will be triggered. Only relevant for trigger orders", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "auctionStartPrice", - "docs": [ - "The start price for the auction. Only relevant for market/oracle orders", - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "auctionEndPrice", - "docs": [ - "The end price for the auction. Only relevant for market/oracle orders", - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "maxTs", - "docs": [ - "The time when the order will expire" - ], - "type": "i64" - }, - { - "name": "oraclePriceOffset", - "docs": [ - "If set, the order limit price is the oracle price + this offset", - "precision: PRICE_PRECISION" - ], - "type": "i32" - }, - { - "name": "orderId", - "docs": [ - "The id for the order. Each users has their own order id space" - ], - "type": "u32" - }, - { - "name": "marketIndex", - "docs": [ - "The perp/spot market index" - ], - "type": "u16" - }, - { - "name": "status", - "docs": [ - "Whether the order is open or unused" - ], - "type": { - "defined": { - "name": "orderStatus" - } - } - }, - { - "name": "orderType", - "docs": [ - "The type of order" - ], - "type": { - "defined": { - "name": "orderType" - } - } - }, - { - "name": "marketType", - "docs": [ - "Whether market is spot or perp" - ], - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "userOrderId", - "docs": [ - "User generated order id. Can make it easier to place/cancel orders" - ], - "type": "u8" - }, - { - "name": "existingPositionDirection", - "docs": [ - "What the users position was when the order was placed" - ], - "type": { - "defined": { - "name": "positionDirection" - } - } - }, - { - "name": "direction", - "docs": [ - "Whether the user is going long or short. LONG = bid, SHORT = ask" - ], - "type": { - "defined": { - "name": "positionDirection" - } - } - }, - { - "name": "reduceOnly", - "docs": [ - "Whether the order is allowed to only reduce position size" - ], - "type": "bool" - }, - { - "name": "postOnly", - "docs": [ - "Whether the order must be a maker" - ], - "type": "bool" - }, - { - "name": "immediateOrCancel", - "docs": [ - "Whether the order must be canceled the same slot it is placed" - ], - "type": "bool" - }, - { - "name": "triggerCondition", - "docs": [ - "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders" - ], - "type": { - "defined": { - "name": "orderTriggerCondition" - } - } - }, - { - "name": "auctionDuration", - "docs": [ - "How many slots the auction lasts" - ], - "type": "u8" - }, - { - "name": "postedSlotTail", - "docs": [ - "Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)" - ], - "type": "u8" - }, - { - "name": "bitFlags", - "docs": [ - "Bitflags for further classification", - "0: is_signed_message" - ], - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 1 - ] - } - } - ] - } - }, - { - "name": "orderAction", - "type": { - "kind": "enum", - "variants": [ - { - "name": "place" - }, - { - "name": "cancel" - }, - { - "name": "fill" - }, - { - "name": "trigger" - }, - { - "name": "expire" - } - ] - } - }, - { - "name": "orderActionExplanation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "none" - }, - { - "name": "insufficientFreeCollateral" - }, - { - "name": "oraclePriceBreachedLimitPrice" - }, - { - "name": "marketOrderFilledToLimitPrice" - }, - { - "name": "orderExpired" - }, - { - "name": "liquidation" - }, - { - "name": "orderFilledWithAmm" - }, - { - "name": "orderFilledWithAmmJit" - }, - { - "name": "orderFilledWithMatch" - }, - { - "name": "orderFilledWithMatchJit" - }, - { - "name": "marketExpired" - }, - { - "name": "riskingIncreasingOrder" - }, - { - "name": "reduceOnlyOrderIncreasedPosition" - }, - { - "name": "orderFillWithSerum" - }, - { - "name": "noBorrowLiquidity" - }, - { - "name": "orderFillWithPhoenix" - }, - { - "name": "orderFilledWithAmmJitLpSplit" - }, - { - "name": "orderFilledWithLpJit" - }, - { - "name": "deriskLp" - }, - { - "name": "orderFilledWithOpenbookV2" - }, - { - "name": "transferPerpPosition" - } - ] - } - }, - { - "name": "orderActionRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "action", - "type": { - "defined": { - "name": "orderAction" - } - } - }, - { - "name": "actionExplanation", - "type": { - "defined": { - "name": "orderActionExplanation" - } - } - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "marketType", - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "filler", - "type": { - "option": "pubkey" - } - }, - { - "name": "fillerReward", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "fillRecordId", - "type": { - "option": "u64" - } - }, - { - "name": "baseAssetAmountFilled", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "quoteAssetAmountFilled", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "takerFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "i64" - } - }, - { - "name": "referrerReward", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u32" - } - }, - { - "name": "quoteAssetAmountSurplus", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "i64" - } - }, - { - "name": "spotFulfillmentMethodFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "taker", - "type": { - "option": "pubkey" - } - }, - { - "name": "takerOrderId", - "type": { - "option": "u32" - } - }, - { - "name": "takerOrderDirection", - "type": { - "option": { - "defined": { - "name": "positionDirection" - } - } - } - }, - { - "name": "takerOrderBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "takerOrderCumulativeBaseAssetAmountFilled", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "takerOrderCumulativeQuoteAssetAmountFilled", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "maker", - "type": { - "option": "pubkey" - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - }, - { - "name": "makerOrderDirection", - "type": { - "option": { - "defined": { - "name": "positionDirection" - } - } - } - }, - { - "name": "makerOrderBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerOrderCumulativeBaseAssetAmountFilled", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerOrderCumulativeQuoteAssetAmountFilled", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "oraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "bitFlags", - "docs": [ - "Bit flags:", - "0: is_signed_message" - ], - "type": "u8" - }, - { - "name": "takerExistingQuoteEntryAmount", - "docs": [ - "precision: QUOTE_PRECISION", - "Only Some if the taker reduced position" - ], - "type": { - "option": "u64" - } - }, - { - "name": "takerExistingBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION", - "Only Some if the taker flipped position direction" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerExistingQuoteEntryAmount", - "docs": [ - "precision: QUOTE_PRECISION", - "Only Some if the maker reduced position" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerExistingBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION", - "Only Some if the maker flipped position direction" - ], - "type": { - "option": "u64" - } - }, - { - "name": "triggerPrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "builderIdx", - "docs": [ - "the idx of the builder in the taker's [`RevenueShareEscrow`] account" - ], - "type": { - "option": "u8" - } - }, - { - "name": "builderFee", - "docs": [ - "precision: QUOTE_PRECISION builder fee paid by the taker" - ], - "type": { - "option": "u64" - } - } - ] - } - }, - { - "name": "orderFillerRewardStructure", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rewardNumerator", - "type": "u32" - }, - { - "name": "rewardDenominator", - "type": "u32" - }, - { - "name": "timeBasedRewardLowerBound", - "type": { - "defined": { - "name": "u128" - } - } - } - ] - } - }, - { - "name": "orderParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "orderType", - "type": { - "defined": { - "name": "orderType" - } - } - }, - { - "name": "marketType", - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "direction", - "type": { - "defined": { - "name": "positionDirection" - } - } - }, - { - "name": "userOrderId", - "type": "u8" - }, - { - "name": "baseAssetAmount", - "type": "u64" - }, - { - "name": "price", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "reduceOnly", - "type": "bool" - }, - { - "name": "postOnly", - "type": { - "defined": { - "name": "postOnlyParam" - } - } - }, - { - "name": "bitFlags", - "type": "u8" - }, - { - "name": "maxTs", - "type": { - "option": "i64" - } - }, - { - "name": "triggerPrice", - "type": { - "option": "u64" - } - }, - { - "name": "triggerCondition", - "type": { - "defined": { - "name": "orderTriggerCondition" - } - } - }, - { - "name": "oraclePriceOffset", - "type": { - "option": "i32" - } - }, - { - "name": "auctionDuration", - "type": { - "option": "u8" - } - }, - { - "name": "auctionStartPrice", - "type": { - "option": "i64" - } - }, - { - "name": "auctionEndPrice", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "orderRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "order", - "type": { - "defined": { - "name": "order" - } - } - } - ] - } - }, - { - "name": "orderStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "init" - }, - { - "name": "open" - }, - { - "name": "filled" - }, - { - "name": "canceled" - } - ] - } - }, - { - "name": "orderTriggerCondition", - "type": { - "kind": "enum", - "variants": [ - { - "name": "above" - }, - { - "name": "below" - }, - { - "name": "triggeredAbove" - }, - { - "name": "triggeredBelow" - } - ] - } - }, - { - "name": "orderType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "market" - }, - { - "name": "limit" - }, - { - "name": "triggerMarket" - }, - { - "name": "triggerLimit" - }, - { - "name": "oracle" - } - ] - } - }, - { - "name": "overrideAmmCacheParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quoteOwedFromLpPool", - "type": { - "option": "i64" - } - }, - { - "name": "lastSettleSlot", - "type": { - "option": "u64" - } - }, - { - "name": "lastFeePoolTokenAmount", - "type": { - "option": "u128" - } - }, - { - "name": "lastNetPnlPoolTokenAmount", - "type": { - "option": "i128" - } - }, - { - "name": "ammPositionScalar", - "type": { - "option": "u8" - } - }, - { - "name": "ammInventoryLimit", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "perpBankruptcyRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "pnl", - "type": "i128" - }, - { - "name": "ifPayment", - "type": "u128" - }, - { - "name": "clawbackUser", - "type": { - "option": "pubkey" - } - }, - { - "name": "clawbackUserPayment", - "type": { - "option": "u128" - } - }, - { - "name": "cumulativeFundingRateDelta", - "type": "i128" - } - ] - } - }, - { - "name": "perpMarket", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "The perp market's address. It is a pda of the market index" - ], - "type": "pubkey" - }, - { - "name": "amm", - "docs": [ - "The automated market maker" - ], - "type": { - "defined": { - "name": "amm" - } - } - }, - { - "name": "pnlPool", - "docs": [ - "The market's pnl pool. When users settle negative pnl, the balance increases.", - "When users settle positive pnl, the balance decreases. Can not go negative." - ], - "type": { - "defined": { - "name": "poolBalance" - } - } - }, - { - "name": "name", - "docs": [ - "Encoded display name for the perp market e.g. SOL-PERP" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "insuranceClaim", - "docs": [ - "The perp market's claim on the insurance fund" - ], - "type": { - "defined": { - "name": "insuranceClaim" - } - } - }, - { - "name": "unrealizedPnlMaxImbalance", - "docs": [ - "The max pnl imbalance before positive pnl asset weight is discounted", - "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", - "the amm has negative pnl and the initial asset weight for positive pnl is discounted", - "precision = QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "expiryTs", - "docs": [ - "The ts when the market will be expired. Only set if market is in reduce only mode" - ], - "type": "i64" - }, - { - "name": "expiryPrice", - "docs": [ - "The price at which positions will be settled. Only set if market is expired", - "precision = PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "nextFillRecordId", - "docs": [ - "Every trade has a fill record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "nextFundingRateRecordId", - "docs": [ - "Every funding rate update has a record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "nextCurveRecordId", - "docs": [ - "Every amm k updated has a record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "imfFactor", - "docs": [ - "The initial margin fraction factor. Used to increase margin ratio for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealizedPnlImfFactor", - "docs": [ - "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "liquidatorFee", - "docs": [ - "The fee the liquidator is paid for taking over perp position", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "marginRatioInitial", - "docs": [ - "The margin ratio which determines how much collateral is required to open a position", - "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "marginRatioMaintenance", - "docs": [ - "The margin ratio which determines when a user will be liquidated", - "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", - "else they will be liquidated", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealizedPnlInitialAssetWeight", - "docs": [ - "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealizedPnlMaintenanceAssetWeight", - "docs": [ - "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "numberOfUsersWithBase", - "docs": [ - "number of users in a position (base)" - ], - "type": "u32" - }, - { - "name": "numberOfUsers", - "docs": [ - "number of users in a position (pnl) or pnl (quote)" - ], - "type": "u32" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "status", - "docs": [ - "Whether a market is active, reduce only, expired, etc", - "Affects whether users can open/close positions" - ], - "type": { - "defined": { - "name": "marketStatus" - } - } - }, - { - "name": "contractType", - "docs": [ - "Currently only Perpetual markets are supported" - ], - "type": { - "defined": { - "name": "contractType" - } - } - }, - { - "name": "contractTier", - "docs": [ - "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", - "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" - ], - "type": { - "defined": { - "name": "contractTier" - } - } - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "quoteSpotMarketIndex", - "docs": [ - "The spot market that pnl is settled in" - ], - "type": "u16" - }, - { - "name": "feeAdjustment", - "docs": [ - "Between -100 and 100, represents what % to increase/decrease the fee by", - "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", - "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" - ], - "type": "i16" - }, - { - "name": "fuelBoostPosition", - "docs": [ - "fuel multiplier for perp funding", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostTaker", - "docs": [ - "fuel multiplier for perp taker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostMaker", - "docs": [ - "fuel multiplier for perp maker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "poolId", - "type": "u8" - }, - { - "name": "highLeverageMarginRatioInitial", - "type": "u16" - }, - { - "name": "highLeverageMarginRatioMaintenance", - "type": "u16" - }, - { - "name": "protectedMakerLimitPriceDivisor", - "type": "u8" - }, - { - "name": "protectedMakerDynamicDivisor", - "type": "u8" - }, - { - "name": "lpFeeTransferScalar", - "type": "u8" - }, - { - "name": "lpStatus", - "type": "u8" - }, - { - "name": "lpPausedOperations", - "type": "u8" - }, - { - "name": "lpExchangeFeeExcluscionScalar", - "type": "u8" - }, - { - "name": "lastFillPrice", - "type": "u64" - }, - { - "name": "lpPoolId", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 23 - ] - } - } - ] - } - }, - { - "name": "perpPosition", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastCumulativeFundingRate", - "docs": [ - "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "baseAssetAmount", - "docs": [ - "the size of the users perp position", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quoteAssetAmount", - "docs": [ - "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees", - "Updated when the user open/closes position or settles pnl. Includes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quoteBreakEvenAmount", - "docs": [ - "The amount of quote the user would need to exit their position at to break even", - "Updated when the user open/closes position or settles pnl. Includes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quoteEntryAmount", - "docs": [ - "The amount quote the user entered the position with. Equal to base asset amount * avg entry price", - "Updated when the user open/closes position. Excludes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "openBids", - "docs": [ - "The amount of non reduce only trigger orders the user has open", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "openAsks", - "docs": [ - "The amount of non reduce only trigger orders the user has open", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "settledPnl", - "docs": [ - "The amount of pnl settled in this market since opening the position", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lpShares", - "docs": [ - "The number of lp (liquidity provider) shares the user has in this perp market", - "LP shares allow users to provide liquidity via the AMM", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastBaseAssetAmountPerLp", - "docs": [ - "The last base asset amount per lp the amm had", - "Used to settle the users lp position", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastQuoteAssetAmountPerLp", - "docs": [ - "The last quote asset amount per lp the amm had", - "Used to settle the users lp position", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 2 - ] - } - }, - { - "name": "maxMarginRatio", - "type": "u16" - }, - { - "name": "marketIndex", - "docs": [ - "The market index for the perp market" - ], - "type": "u16" - }, - { - "name": "openOrders", - "docs": [ - "The number of open orders" - ], - "type": "u8" - }, - { - "name": "perLpBase", - "type": "i8" - } - ] - } - }, - { - "name": "phoenixV1FulfillmentConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "phoenixProgramId", - "type": "pubkey" - }, - { - "name": "phoenixLogAuthority", - "type": "pubkey" - }, - { - "name": "phoenixMarket", - "type": "pubkey" - }, - { - "name": "phoenixBaseVault", - "type": "pubkey" - }, - { - "name": "phoenixQuoteVault", - "type": "pubkey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": { - "name": "spotFulfillmentType" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "poolBalance", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "scaledBalance", - "docs": [ - "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", - "deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "marketIndex", - "docs": [ - "The spot market the pool is for" - ], - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 6 - ] - } - } - ] - } - }, - { - "name": "positionDirection", - "type": { - "kind": "enum", - "variants": [ - { - "name": "long" - }, - { - "name": "short" - } - ] - } - }, - { - "name": "postOnlyParam", - "type": { - "kind": "enum", - "variants": [ - { - "name": "none" - }, - { - "name": "mustPostOnly" - }, - { - "name": "tryPostOnly" - }, - { - "name": "slide" - } - ] - } - }, - { - "name": "prelaunchOracle", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "price", - "type": "i64" - }, - { - "name": "maxPrice", - "type": "i64" - }, - { - "name": "confidence", - "type": "u64" - }, - { - "name": "lastUpdateSlot", - "type": "u64" - }, - { - "name": "ammLastUpdateSlot", - "type": "u64" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 70 - ] - } - } - ] - } - }, - { - "name": "prelaunchOracleParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "price", - "type": { - "option": "i64" - } - }, - { - "name": "maxPrice", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "priceDivergenceGuardRails", - "type": { - "kind": "struct", - "fields": [ - { - "name": "markOraclePercentDivergence", - "type": "u64" - }, - { - "name": "oracleTwap5minPercentDivergence", - "type": "u64" - } - ] - } - }, - { - "name": "protectedMakerModeConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "currentUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 31 - ] - } - } - ] - } - }, - { - "name": "pythLazerOracle", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "price", - "type": "i64" - }, - { - "name": "publishTime", - "type": "u64" - }, - { - "name": "postedSlot", - "type": "u64" - }, - { - "name": "exponent", - "type": "i32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "conf", - "type": "u64" - } - ] - } - }, - { - "name": "referrerName", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "userStats", - "type": "pubkey" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "revenueShare", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "rust", - "packed": true - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "the owner of this account, a builder or referrer" - ], - "type": "pubkey" - }, - { - "name": "totalReferrerRewards", - "type": "u64" - }, - { - "name": "totalBuilderRewards", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 18 - ] - } - } - ] - } - }, - { - "name": "revenueShareEscrow", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "the owner of this account, a user" - ], - "type": "pubkey" - }, - { - "name": "referrer", - "type": "pubkey" - }, - { - "name": "referrerBoostExpireTs", - "type": "u32" - }, - { - "name": "referrerRewardOffset", - "type": "i8" - }, - { - "name": "refereeFeeNumeratorOffset", - "type": "i8" - }, - { - "name": "referrerBoostNumerator", - "type": "i8" - }, - { - "name": "reservedFixed", - "type": { - "array": [ - "u8", - 17 - ] - } - }, - { - "name": "padding0", - "type": "u32" - }, - { - "name": "orders", - "type": { - "vec": { - "defined": { - "name": "revenueShareOrder" - } - } - } - }, - { - "name": "padding1", - "type": "u32" - }, - { - "name": "approvedBuilders", - "type": { - "vec": { - "defined": { - "name": "builderInfo" - } - } - } - } - ] - } - }, - { - "name": "revenueShareOrder", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "feesAccrued", - "docs": [ - "fees accrued so far for this order slot. This is not exclusively fees from this order_id", - "and may include fees from other orders in the same market. This may be swept to the", - "builder's SpotPosition during settle_pnl." - ], - "type": "u64" - }, - { - "name": "orderId", - "docs": [ - "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open" - ], - "type": "u32" - }, - { - "name": "feeTenthBps", - "docs": [ - "the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%" - ], - "type": "u16" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "subAccountId", - "docs": [ - "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open" - ], - "type": "u16" - }, - { - "name": "builderIdx", - "docs": [ - "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", - "if bit_flag = Referral." - ], - "type": "u8" - }, - { - "name": "bitFlags", - "docs": [ - "bitflags that describe the state of the order.", - "[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.", - "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", - "[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.", - "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", - "[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.", - "If it is set, no other bitflag should be set." - ], - "type": "u8" - }, - { - "name": "userOrderIndex", - "docs": [ - "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches." - ], - "type": "u8" - }, - { - "name": "marketType", - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 10 - ] - } - } - ] - } - }, - { - "name": "revenueShareSettleRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "builder", - "type": { - "option": "pubkey" - } - }, - { - "name": "referrer", - "type": { - "option": "pubkey" - } - }, - { - "name": "feeSettled", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "marketType", - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "builderSubAccountId", - "type": "u16" - }, - { - "name": "builderTotalReferrerRewards", - "type": "u64" - }, - { - "name": "builderTotalBuilderRewards", - "type": "u64" - } - ] - } - }, - { - "name": "serumV3FulfillmentConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "serumProgramId", - "type": "pubkey" - }, - { - "name": "serumMarket", - "type": "pubkey" - }, - { - "name": "serumRequestQueue", - "type": "pubkey" - }, - { - "name": "serumEventQueue", - "type": "pubkey" - }, - { - "name": "serumBids", - "type": "pubkey" - }, - { - "name": "serumAsks", - "type": "pubkey" - }, - { - "name": "serumBaseVault", - "type": "pubkey" - }, - { - "name": "serumQuoteVault", - "type": "pubkey" - }, - { - "name": "serumOpenOrders", - "type": "pubkey" - }, - { - "name": "serumSignerNonce", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": { - "name": "spotFulfillmentType" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "settlePnlExplanation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "none" - }, - { - "name": "expiredPosition" - } - ] - } - }, - { - "name": "settlePnlMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "mustSettle" - }, - { - "name": "trySettle" - } - ] - } - }, - { - "name": "settlePnlRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "pnl", - "type": "i128" - }, - { - "name": "baseAssetAmount", - "type": "i64" - }, - { - "name": "quoteAssetAmountAfter", - "type": "i64" - }, - { - "name": "quoteEntryAmount", - "type": "i64" - }, - { - "name": "settlePrice", - "type": "i64" - }, - { - "name": "explanation", - "type": { - "defined": { - "name": "settlePnlExplanation" - } - } - } - ] - } - }, - { - "name": "signedMsgOrderId", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "uuid", - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "maxSlot", - "type": "u64" - }, - { - "name": "orderId", - "type": "u32" - }, - { - "name": "padding", - "type": "u32" - } - ] - } - }, - { - "name": "signedMsgOrderRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "hash", - "type": "string" - }, - { - "name": "matchingOrderParams", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "userOrderId", - "type": "u32" - }, - { - "name": "signedMsgOrderMaxSlot", - "type": "u64" - }, - { - "name": "signedMsgOrderUuid", - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "ts", - "type": "i64" - } - ] - } - }, - { - "name": "signedMsgUserOrders", - "docs": [ - "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" - ], - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authorityPubkey", - "type": "pubkey" - }, - { - "name": "padding", - "type": "u32" - }, - { - "name": "signedMsgOrderData", - "type": { - "vec": { - "defined": { - "name": "signedMsgOrderId" - } - } - } - } - ] - } - }, - { - "name": "signedMsgWsDelegates", - "docs": [ - "* Used to store authenticated delegates for swift-like ws connections" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "delegates", - "type": { - "vec": "pubkey" - } - } - ] - } - }, - { - "name": "spotBalanceType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "deposit" - }, - { - "name": "borrow" - } - ] - } - }, - { - "name": "spotBankruptcyRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "borrowAmount", - "type": "u128" - }, - { - "name": "ifPayment", - "type": "u128" - }, - { - "name": "cumulativeDepositInterestDelta", - "type": "u128" - } - ] - } - }, - { - "name": "spotFulfillmentConfigStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "enabled" - }, - { - "name": "disabled" - } - ] - } - }, - { - "name": "spotFulfillmentType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "serumV3" - }, - { - "name": "match" - }, - { - "name": "phoenixV1" - }, - { - "name": "openbookV2" - } - ] - } - }, - { - "name": "spotInterestRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "depositBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulativeDepositInterest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "borrowBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulativeBorrowInterest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "optimalUtilization", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimalBorrowRate", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "maxBorrowRate", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - } - ] - } - }, - { - "name": "spotMarket", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "The address of the spot market. It is a pda of the market index" - ], - "type": "pubkey" - }, - { - "name": "oracle", - "docs": [ - "The oracle used to price the markets deposits/borrows" - ], - "type": "pubkey" - }, - { - "name": "mint", - "docs": [ - "The token mint of the market" - ], - "type": "pubkey" - }, - { - "name": "vault", - "docs": [ - "The vault used to store the market's deposits", - "The amount in the vault should be equal to or greater than deposits - borrows" - ], - "type": "pubkey" - }, - { - "name": "name", - "docs": [ - "The encoded display name for the market e.g. SOL" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "historicalOracleData", - "type": { - "defined": { - "name": "historicalOracleData" - } - } - }, - { - "name": "historicalIndexData", - "type": { - "defined": { - "name": "historicalIndexData" - } - } - }, - { - "name": "revenuePool", - "docs": [ - "Revenue the protocol has collected in this markets token", - "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" - ], - "type": { - "defined": { - "name": "poolBalance" - } - } - }, - { - "name": "spotFeePool", - "docs": [ - "The fees collected from swaps between this market and the quote market", - "Is settled to the quote markets revenue pool" - ], - "type": { - "defined": { - "name": "poolBalance" - } - } - }, - { - "name": "insuranceFund", - "docs": [ - "Details on the insurance fund covering bankruptcies in this markets token", - "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" - ], - "type": { - "defined": { - "name": "insuranceFund" - } - } - }, - { - "name": "totalSpotFee", - "docs": [ - "The total spot fees collected for this market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "depositBalance", - "docs": [ - "The sum of the scaled balances for deposits across users and pool balances", - "To convert to the deposit token amount, multiply by the cumulative deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "borrowBalance", - "docs": [ - "The sum of the scaled balances for borrows across users and pool balances", - "To convert to the borrow token amount, multiply by the cumulative borrow interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeDepositInterest", - "docs": [ - "The cumulative interest earned by depositors", - "Used to calculate the deposit token amount from the deposit balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeBorrowInterest", - "docs": [ - "The cumulative interest earned by borrowers", - "Used to calculate the borrow token amount from the borrow balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalSocialLoss", - "docs": [ - "The total socialized loss from borrows, in the mint's token", - "precision: token mint precision" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalQuoteSocialLoss", - "docs": [ - "The total socialized loss from borrows, in the quote market's token", - "preicision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "withdrawGuardThreshold", - "docs": [ - "no withdraw limits/guards when deposits below this threshold", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "maxTokenDeposits", - "docs": [ - "The max amount of token deposits in this market", - "0 if there is no limit", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "depositTokenTwap", - "docs": [ - "24hr average of deposit token amount", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "borrowTokenTwap", - "docs": [ - "24hr average of borrow token amount", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "utilizationTwap", - "docs": [ - "24hr average of utilization", - "which is borrow amount over token amount", - "precision: SPOT_UTILIZATION_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastInterestTs", - "docs": [ - "Last time the cumulative deposit and borrow interest was updated" - ], - "type": "u64" - }, - { - "name": "lastTwapTs", - "docs": [ - "Last time the deposit/borrow/utilization averages were updated" - ], - "type": "u64" - }, - { - "name": "expiryTs", - "docs": [ - "The time the market is set to expire. Only set if market is in reduce only mode" - ], - "type": "i64" - }, - { - "name": "orderStepSize", - "docs": [ - "Spot orders must be a multiple of the step size", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "orderTickSize", - "docs": [ - "Spot orders must be a multiple of the tick size", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "minOrderSize", - "docs": [ - "The minimum order size", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "maxPositionSize", - "docs": [ - "The maximum spot position size", - "if the limit is 0, there is no limit", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "nextFillRecordId", - "docs": [ - "Every spot trade has a fill record id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "nextDepositRecordId", - "docs": [ - "Every deposit has a deposit record id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "initialAssetWeight", - "docs": [ - "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", - "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "maintenanceAssetWeight", - "docs": [ - "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", - "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "initialLiabilityWeight", - "docs": [ - "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", - "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "maintenanceLiabilityWeight", - "docs": [ - "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", - "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "imfFactor", - "docs": [ - "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "liquidatorFee", - "docs": [ - "The fee the liquidator is paid for taking over borrow/deposit", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimalUtilization", - "docs": [ - "The optimal utilization rate for this market.", - "Used to determine the markets borrow rate", - "precision: SPOT_UTILIZATION_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimalBorrowRate", - "docs": [ - "The borrow rate for this market when the market has optimal utilization", - "precision: SPOT_RATE_PRECISION" - ], - "type": "u32" - }, - { - "name": "maxBorrowRate", - "docs": [ - "The borrow rate for this market when the market has 1000 utilization", - "precision: SPOT_RATE_PRECISION" - ], - "type": "u32" - }, - { - "name": "decimals", - "docs": [ - "The market's token mint's decimals. To from decimals to a precision, 10^decimals" - ], - "type": "u32" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "ordersEnabled", - "docs": [ - "Whether or not spot trading is enabled" - ], - "type": "bool" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "marketStatus" - } - } - }, - { - "name": "assetTier", - "docs": [ - "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" - ], - "type": { - "defined": { - "name": "assetTier" - } - } - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "ifPausedOperations", - "type": "u8" - }, - { - "name": "feeAdjustment", - "type": "i16" - }, - { - "name": "maxTokenBorrowsFraction", - "docs": [ - "What fraction of max_token_deposits", - "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", - "precision: X/10000" - ], - "type": "u16" - }, - { - "name": "flashLoanAmount", - "docs": [ - "For swaps, the amount of token loaned out in the begin_swap ix", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "flashLoanInitialTokenAmount", - "docs": [ - "For swaps, the amount in the users token account in the begin_swap ix", - "Used to calculate how much of the token left the system in end_swap ix", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "totalSwapFee", - "docs": [ - "The total fees received from swaps", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "scaleInitialAssetWeightStart", - "docs": [ - "When to begin scaling down the initial asset weight", - "disabled when 0", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "minBorrowRate", - "docs": [ - "The min borrow rate for this market when the market regardless of utilization", - "1 => 1/200 => .5%", - "precision: X/200" - ], - "type": "u8" - }, - { - "name": "fuelBoostDeposits", - "docs": [ - "fuel multiplier for spot deposits", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostBorrows", - "docs": [ - "fuel multiplier for spot borrows", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostTaker", - "docs": [ - "fuel multiplier for spot taker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostMaker", - "docs": [ - "fuel multiplier for spot maker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostInsurance", - "docs": [ - "fuel multiplier for spot insurance stake", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "tokenProgramFlag", - "type": "u8" - }, - { - "name": "poolId", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 40 - ] - } - } - ] - } - }, - { - "name": "spotMarketVaultDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "depositBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulativeDepositInterestBefore", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulativeDepositInterestAfter", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "depositTokenAmountBefore", - "type": "u64" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "spotPosition", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "scaledBalance", - "docs": [ - "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", - "interest of corresponding market.", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u64" - }, - { - "name": "openBids", - "docs": [ - "How many spot non reduce only trigger orders the user has open", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "openAsks", - "docs": [ - "How many spot non reduce only trigger orders the user has open", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "cumulativeDeposits", - "docs": [ - "The cumulative deposits/borrows a user has made into a market", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "marketIndex", - "docs": [ - "The market index of the corresponding spot market" - ], - "type": "u16" - }, - { - "name": "balanceType", - "docs": [ - "Whether the position is deposit or borrow" - ], - "type": { - "defined": { - "name": "spotBalanceType" - } - } - }, - { - "name": "openOrders", - "docs": [ - "Number of open orders" - ], - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "stakeAction", - "type": { - "kind": "enum", - "variants": [ - { - "name": "stake" - }, - { - "name": "unstakeRequest" - }, - { - "name": "unstakeCancelRequest" - }, - { - "name": "unstake" - }, - { - "name": "unstakeTransfer" - }, - { - "name": "stakeTransfer" - }, - { - "name": "adminDeposit" - } - ] - } - }, - { - "name": "state", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "admin", - "type": "pubkey" - }, - { - "name": "whitelistMint", - "type": "pubkey" - }, - { - "name": "discountMint", - "type": "pubkey" - }, - { - "name": "signer", - "type": "pubkey" - }, - { - "name": "srmVault", - "type": "pubkey" - }, - { - "name": "perpFeeStructure", - "type": { - "defined": { - "name": "feeStructure" - } - } - }, - { - "name": "spotFeeStructure", - "type": { - "defined": { - "name": "feeStructure" - } - } - }, - { - "name": "oracleGuardRails", - "type": { - "defined": { - "name": "oracleGuardRails" - } - } - }, - { - "name": "numberOfAuthorities", - "type": "u64" - }, - { - "name": "numberOfSubAccounts", - "type": "u64" - }, - { - "name": "lpCooldownTime", - "type": "u64" - }, - { - "name": "liquidationMarginBufferRatio", - "type": "u32" - }, - { - "name": "settlementDuration", - "type": "u16" - }, - { - "name": "numberOfMarkets", - "type": "u16" - }, - { - "name": "numberOfSpotMarkets", - "type": "u16" - }, - { - "name": "signerNonce", - "type": "u8" - }, - { - "name": "minPerpAuctionDuration", - "type": "u8" - }, - { - "name": "defaultMarketOrderTimeInForce", - "type": "u8" - }, - { - "name": "defaultSpotAuctionDuration", - "type": "u8" - }, - { - "name": "exchangeStatus", - "type": "u8" - }, - { - "name": "liquidationDuration", - "type": "u8" - }, - { - "name": "initialPctToLiquidate", - "type": "u16" - }, - { - "name": "maxNumberOfSubAccounts", - "type": "u16" - }, - { - "name": "maxInitializeUserFee", - "type": "u16" - }, - { - "name": "featureBitFlags", - "type": "u8" - }, - { - "name": "lpPoolFeatureBitFlags", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - } - }, - { - "name": "swapRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "amountOut", - "docs": [ - "precision: out market mint precision" - ], - "type": "u64" - }, - { - "name": "amountIn", - "docs": [ - "precision: in market mint precision" - ], - "type": "u64" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "fee", - "type": "u64" - } - ] - } - }, - { - "name": "swapReduceOnly", - "type": { - "kind": "enum", - "variants": [ - { - "name": "in" - }, - { - "name": "out" - } - ] - } - }, - { - "name": "targetsDatum", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "costToTradeBps", - "type": "i32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "targetBase", - "type": "i64" - }, - { - "name": "lastOracleSlot", - "type": "u64" - }, - { - "name": "lastPositionSlot", - "type": "u64" - } - ] - } - }, - { - "name": "transferProtocolIfSharesToRevenuePoolRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "shares", - "type": "u128" - }, - { - "name": "ifVaultAmountBefore", - "type": "u64" - }, - { - "name": "protocolSharesBefore", - "type": "u128" - }, - { - "name": "transferAmount", - "type": "u64" - } - ] - } - }, - { - "name": "updatePerpMarketSummaryStatsParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quoteAssetAmountWithUnsettledLp", - "type": { - "option": "i64" - } - }, - { - "name": "netUnsettledFundingPnl", - "type": { - "option": "i64" - } - }, - { - "name": "updateAmmSummaryStats", - "type": { - "option": "bool" - } - }, - { - "name": "excludeTotalLiqFee", - "type": { - "option": "bool" - } - } - ] - } - }, - { - "name": "user", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "The owner/authority of the account" - ], - "type": "pubkey" - }, - { - "name": "delegate", - "docs": [ - "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw" - ], - "type": "pubkey" - }, - { - "name": "name", - "docs": [ - "Encoded display name e.g. \"toly\"" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "spotPositions", - "docs": [ - "The user's spot positions" - ], - "type": { - "array": [ - { - "defined": { - "name": "spotPosition" - } - }, - 8 - ] - } - }, - { - "name": "perpPositions", - "docs": [ - "The user's perp positions" - ], - "type": { - "array": [ - { - "defined": { - "name": "perpPosition" - } - }, - 8 - ] - } - }, - { - "name": "orders", - "docs": [ - "The user's orders" - ], - "type": { - "array": [ - { - "defined": { - "name": "order" - } - }, - 32 - ] - } - }, - { - "name": "lastAddPerpLpSharesTs", - "docs": [ - "The last time the user added perp lp positions" - ], - "type": "i64" - }, - { - "name": "totalDeposits", - "docs": [ - "The total values of deposits the user has made", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalWithdraws", - "docs": [ - "The total values of withdrawals the user has made", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalSocialLoss", - "docs": [ - "The total socialized loss the users has incurred upon the protocol", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "settledPerpPnl", - "docs": [ - "Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "cumulativeSpotFees", - "docs": [ - "Fees (taker fees, maker rebate, filler reward) for spot", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "cumulativePerpFunding", - "docs": [ - "Cumulative funding paid/received for perps", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "liquidationMarginFreed", - "docs": [ - "The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time", - "Defaults to zero when not being liquidated", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastActiveSlot", - "docs": [ - "The last slot a user was active. Used to determine if a user is idle" - ], - "type": "u64" - }, - { - "name": "nextOrderId", - "docs": [ - "Every user order has an order id. This is the next order id to be used" - ], - "type": "u32" - }, - { - "name": "maxMarginRatio", - "docs": [ - "Custom max initial margin ratio for the user" - ], - "type": "u32" - }, - { - "name": "nextLiquidationId", - "docs": [ - "The next liquidation id to be used for user" - ], - "type": "u16" - }, - { - "name": "subAccountId", - "docs": [ - "The sub account id for this user" - ], - "type": "u16" - }, - { - "name": "status", - "docs": [ - "Whether the user is active, being liquidated or bankrupt" - ], - "type": "u8" - }, - { - "name": "isMarginTradingEnabled", - "docs": [ - "Whether the user has enabled margin trading" - ], - "type": "bool" - }, - { - "name": "idle", - "docs": [ - "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", - "Off-chain keeper bots can ignore users that are idle" - ], - "type": "bool" - }, - { - "name": "openOrders", - "docs": [ - "number of open orders" - ], - "type": "u8" - }, - { - "name": "hasOpenOrder", - "docs": [ - "Whether or not user has open order" - ], - "type": "bool" - }, - { - "name": "openAuctions", - "docs": [ - "number of open orders with auction" - ], - "type": "u8" - }, - { - "name": "hasOpenAuction", - "docs": [ - "Whether or not user has open order with auction" - ], - "type": "bool" - }, - { - "name": "marginMode", - "type": { - "defined": { - "name": "marginMode" - } - } - }, - { - "name": "poolId", - "type": "u8" - }, - { - "name": "padding1", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "lastFuelBonusUpdateTs", - "type": "u32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 12 - ] - } - } - ] - } - }, - { - "name": "userFees", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "totalFeePaid", - "docs": [ - "Total taker fee paid", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalFeeRebate", - "docs": [ - "Total maker fee rebate", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalTokenDiscount", - "docs": [ - "Total discount from holding token", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalRefereeDiscount", - "docs": [ - "Total discount from being referred", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalReferrerReward", - "docs": [ - "Total reward to referrer", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "currentEpochReferrerReward", - "docs": [ - "Total reward to referrer this epoch", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - } - ] - } - }, - { - "name": "userStats", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "The authority for all of a users sub accounts" - ], - "type": "pubkey" - }, - { - "name": "referrer", - "docs": [ - "The address that referred this user" - ], - "type": "pubkey" - }, - { - "name": "fees", - "docs": [ - "Stats on the fees paid by the user" - ], - "type": { - "defined": { - "name": "userFees" - } - } - }, - { - "name": "nextEpochTs", - "docs": [ - "The timestamp of the next epoch", - "Epoch is used to limit referrer rewards earned in single epoch" - ], - "type": "i64" - }, - { - "name": "makerVolume30d", - "docs": [ - "Rolling 30day maker volume for user", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "takerVolume30d", - "docs": [ - "Rolling 30day taker volume for user", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "fillerVolume30d", - "docs": [ - "Rolling 30day filler volume for user", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastMakerVolume30dTs", - "docs": [ - "last time the maker volume was updated" - ], - "type": "i64" - }, - { - "name": "lastTakerVolume30dTs", - "docs": [ - "last time the taker volume was updated" - ], - "type": "i64" - }, - { - "name": "lastFillerVolume30dTs", - "docs": [ - "last time the filler volume was updated" - ], - "type": "i64" - }, - { - "name": "ifStakedQuoteAssetAmount", - "docs": [ - "The amount of tokens staked in the quote spot markets if" - ], - "type": "u64" - }, - { - "name": "numberOfSubAccounts", - "docs": [ - "The current number of sub accounts" - ], - "type": "u16" - }, - { - "name": "numberOfSubAccountsCreated", - "docs": [ - "The number of sub accounts created. Can be greater than the number of sub accounts if user", - "has deleted sub accounts" - ], - "type": "u16" - }, - { - "name": "referrerStatus", - "docs": [ - "Flags for referrer status:", - "First bit (LSB): 1 if user is a referrer, 0 otherwise", - "Second bit: 1 if user was referred, 0 otherwise" - ], - "type": "u8" - }, - { - "name": "disableUpdatePerpBidAskTwap", - "type": "u8" - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "fuelOverflowStatus", - "docs": [ - "whether the user has a FuelOverflow account" - ], - "type": "u8" - }, - { - "name": "fuelInsurance", - "docs": [ - "accumulated fuel for token amounts of insurance" - ], - "type": "u32" - }, - { - "name": "fuelDeposits", - "docs": [ - "accumulated fuel for notional of deposits" - ], - "type": "u32" - }, - { - "name": "fuelBorrows", - "docs": [ - "accumulate fuel bonus for notional of borrows" - ], - "type": "u32" - }, - { - "name": "fuelPositions", - "docs": [ - "accumulated fuel for perp open interest" - ], - "type": "u32" - }, - { - "name": "fuelTaker", - "docs": [ - "accumulate fuel bonus for taker volume" - ], - "type": "u32" - }, - { - "name": "fuelMaker", - "docs": [ - "accumulate fuel bonus for maker volume" - ], - "type": "u32" - }, - { - "name": "ifStakedGovTokenAmount", - "docs": [ - "The amount of tokens staked in the governance spot markets if" - ], - "type": "u64" - }, - { - "name": "lastFuelIfBonusUpdateTs", - "docs": [ - "last unix ts user stats data was used to update if fuel (u32 to save space)" - ], - "type": "u32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 12 - ] - } - } - ] - } - }, - { - "name": "validityGuardRails", - "type": { - "kind": "struct", - "fields": [ - { - "name": "slotsBeforeStaleForAmm", - "type": "i64" - }, - { - "name": "slotsBeforeStaleForMargin", - "type": "i64" - }, - { - "name": "confidenceIntervalMaxSize", - "type": "u64" - }, - { - "name": "tooVolatileRatio", - "type": "i64" - } - ] - } - }, - { - "name": "i128", - "docs": [ - "`i128` with legacy bit layout" - ], - "type": { - "kind": "struct", - "fields": [ - { - "array": [ - "u8", - 16 - ] - } - ] - } - }, - { - "name": "u128", - "docs": [ - "`u128` with legacy bit layout" - ], - "type": { - "kind": "struct", - "fields": [ - { - "array": [ - "u8", - 16 - ] - } - ] - } - } - ] + address: 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; + metadata: { + name: 'drift'; + version: '2.151.0'; + spec: '0.1.0'; + description: 'Created with Anchor'; + }; + instructions: [ + { + name: 'addAmmConstituentMappingData'; + discriminator: [164, 236, 130, 40, 118, 179, 46, 235]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'ammConstituentMappingData'; + type: { + vec: { + defined: { + name: 'addAmmConstituentMappingDatum'; + }; + }; + }; + }, + ]; + }, + { + name: 'addInsuranceFundStake'; + discriminator: [251, 144, 115, 11, 222, 47, 62, 236]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'addMarketToAmmCache'; + discriminator: [112, 149, 195, 222, 124, 7, 87, 237]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'adminDeposit'; + discriminator: [210, 66, 65, 182, 102, 214, 176, 30]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'adminTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'adminUpdateUserStatsPausedOperations'; + discriminator: [183, 104, 63, 150, 240, 199, 3, 10]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'beginInsuranceFundSwap'; + discriminator: [176, 69, 143, 205, 32, 132, 163, 0]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'outInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'beginLpSwap'; + discriminator: [64, 44, 24, 199, 48, 125, 67, 91]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'signerOutTokenAccount'; + docs: ['Signer token accounts']; + writable: true; + }, + { + name: 'signerInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + docs: ['Constituent token accounts']; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'outConstituent'; + docs: ['Constituents']; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpPool'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'beginSwap'; + discriminator: [174, 109, 228, 1, 242, 105, 232, 105]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'cancelOrder'; + discriminator: [95, 129, 237, 240, 8, 49, 223, 132]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'cancelOrderByUserId'; + discriminator: [107, 211, 250, 133, 18, 37, 57, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'userOrderId'; + type: 'u8'; + }, + ]; + }, + { + name: 'cancelOrders'; + discriminator: [238, 225, 95, 158, 227, 103, 8, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'marketType'; + type: { + option: { + defined: { + name: 'marketType'; + }; + }; + }; + }, + { + name: 'marketIndex'; + type: { + option: 'u16'; + }; + }, + { + name: 'direction'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + ]; + }, + { + name: 'cancelOrdersByIds'; + discriminator: [134, 19, 144, 165, 94, 240, 210, 94]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderIds'; + type: { + vec: 'u32'; + }; + }, + ]; + }, + { + name: 'cancelRequestRemoveInsuranceFundStake'; + discriminator: [97, 235, 78, 62, 212, 42, 241, 127]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'changeApprovedBuilder'; + discriminator: [179, 134, 211, 45, 195, 5, 189, 173]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + relations: ['escrow']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'builder'; + type: 'pubkey'; + }, + { + name: 'maxFeeBps'; + type: 'u16'; + }, + { + name: 'add'; + type: 'bool'; + }, + ]; + }, + { + name: 'changeSignedMsgWsDelegateStatus'; + discriminator: [252, 202, 252, 219, 179, 27, 84, 138]; + accounts: [ + { + name: 'signedMsgWsDelegates'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'delegate'; + type: 'pubkey'; + }, + { + name: 'add'; + type: 'bool'; + }, + ]; + }, + { + name: 'deleteAmmCache'; + discriminator: [216, 130, 215, 206, 233, 232, 191, 88]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'deleteInitializedPerpMarket'; + discriminator: [91, 154, 24, 87, 106, 59, 190, 66]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deleteInitializedSpotMarket'; + discriminator: [31, 140, 67, 191, 189, 20, 101, 221]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deletePrelaunchOracle'; + discriminator: [59, 169, 100, 49, 69, 17, 173, 253]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'perpMarketIndex'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deleteSignedMsgUserOrders'; + discriminator: [221, 247, 128, 253, 212, 254, 46, 153]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'deleteUser'; + discriminator: [186, 85, 17, 249, 219, 231, 98, 251]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + writable: true; + signer: true; + relations: ['user', 'userStats']; + }, + ]; + args: []; + }, + { + name: 'deposit'; + discriminator: [242, 35, 198, 137, 82, 225, 242, 182]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'depositIntoInsuranceFundStake'; + discriminator: [4, 22, 226, 201, 124, 44, 82, 230]; + accounts: [ + { + name: 'signer'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101, + ]; + }, + { + kind: 'account'; + path: 'userStats'; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoPerpMarketFeePool'; + discriminator: [34, 58, 57, 68, 97, 80, 244, 6]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'sourceVault'; + writable: true; + }, + { + name: 'driftSigner'; + }, + { + name: 'quoteSpotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoSpotMarketRevenuePool'; + discriminator: [92, 40, 151, 42, 122, 254, 139, 246]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoSpotMarketVault'; + discriminator: [48, 252, 119, 73, 255, 205, 174, 247]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'sourceVault'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositToProgramVault'; + discriminator: [235, 171, 121, 80, 57, 239, 147, 220]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'constituentTokenAccount'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'mint'; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'disableUserHighLeverageMode'; + discriminator: [183, 155, 45, 0, 226, 85, 213, 69]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'disableMaintenance'; + type: 'bool'; + }, + ]; + }, + { + name: 'enableUserHighLeverageMode'; + discriminator: [231, 24, 230, 112, 201, 173, 73, 184]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + ]; + }, + { + name: 'endInsuranceFundSwap'; + discriminator: [206, 230, 98, 8, 249, 158, 169, 167]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'outInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'endLpSwap'; + discriminator: [99, 125, 214, 165, 129, 175, 253, 135]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'signerOutTokenAccount'; + docs: ['Signer token accounts']; + writable: true; + }, + { + name: 'signerInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + docs: ['Constituent token accounts']; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'outConstituent'; + docs: ['Constituents']; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpPool'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'endSwap'; + discriminator: [177, 184, 27, 193, 34, 13, 210, 145]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'reduceOnly'; + type: { + option: { + defined: { + name: 'swapReduceOnly'; + }; + }; + }; + }, + ]; + }, + { + name: 'fillPerpOrder'; + discriminator: [13, 188, 248, 103, 134, 217, 106, 240]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'fillSpotOrder'; + discriminator: [212, 206, 130, 173, 21, 34, 199, 40]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'forceCancelOrders'; + discriminator: [64, 181, 196, 63, 222, 72, 64, 232]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'forceDeleteUser'; + discriminator: [2, 241, 195, 172, 227, 24, 254, 158]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + writable: true; + relations: ['user', 'userStats']; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'driftSigner'; + }, + ]; + args: []; + }, + { + name: 'initialize'; + discriminator: [175, 175, 109, 31, 13, 152, 155, 237]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [100, 114, 105, 102, 116, 95, 115, 116, 97, 116, 101]; + }, + ]; + }; + }, + { + name: 'quoteAssetMint'; + }, + { + name: 'driftSigner'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: []; + }, + { + name: 'initializeAmmCache'; + discriminator: [38, 60, 171, 158, 203, 58, 137, 8]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeConstituent'; + discriminator: [12, 196, 45, 218, 93, 89, 0, 33]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketMint'; + }, + { + name: 'constituentVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'decimals'; + type: 'u8'; + }, + { + name: 'maxWeightDeviation'; + type: 'i64'; + }, + { + name: 'swapFeeMin'; + type: 'i64'; + }, + { + name: 'swapFeeMax'; + type: 'i64'; + }, + { + name: 'maxBorrowTokenAmount'; + type: 'u64'; + }, + { + name: 'oracleStalenessThreshold'; + type: 'u64'; + }, + { + name: 'costToTrade'; + type: 'i32'; + }, + { + name: 'constituentDerivativeIndex'; + type: { + option: 'i16'; + }; + }, + { + name: 'constituentDerivativeDepegThreshold'; + type: 'u64'; + }, + { + name: 'derivativeWeight'; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'gammaInventory'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'newConstituentCorrelations'; + type: { + vec: 'i64'; + }; + }, + ]; + }, + { + name: 'initializeFuelOverflow'; + discriminator: [88, 223, 132, 161, 208, 88, 142, 42]; + accounts: [ + { + name: 'fuelOverflow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 102, + 117, + 101, + 108, + 95, + 111, + 118, + 101, + 114, + 102, + 108, + 111, + 119, + ]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeHighLeverageModeConfig'; + discriminator: [213, 167, 93, 246, 208, 130, 90, 248]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializeIfRebalanceConfig'; + discriminator: [8, 85, 184, 167, 176, 61, 173, 226]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 102, + 95, + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'arg'; + path: 'params.in_market_index'; + }, + { + kind: 'arg'; + path: 'params.out_market_index'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'ifRebalanceConfigParams'; + }; + }; + }, + ]; + }, + { + name: 'initializeInsuranceFundStake'; + discriminator: [187, 179, 243, 70, 248, 90, 92, 147]; + accounts: [ + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101, + ]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeLpPool'; + discriminator: [242, 64, 1, 222, 142, 46, 204, 227]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [108, 112, 95, 112, 111, 111, 108]; + }, + { + kind: 'arg'; + path: 'id'; + }, + ]; + }; + }, + { + name: 'mint'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'tokenProgram'; + address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'minMintFee'; + type: 'i64'; + }, + { + name: 'maxAum'; + type: 'u128'; + }, + { + name: 'maxSettleQuoteAmountPerMarket'; + type: 'u64'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'initializeOpenbookV2FulfillmentConfig'; + discriminator: [7, 221, 103, 153, 107, 57, 27, 197]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'openbookV2Program'; + }, + { + name: 'openbookV2Market'; + }, + { + name: 'driftSigner'; + }, + { + name: 'openbookV2FulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 111, + 112, + 101, + 110, + 98, + 111, + 111, + 107, + 95, + 118, + 50, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'openbookV2Market'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializePerpMarket'; + discriminator: [132, 9, 229, 118, 117, 118, 117, 62]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 101, 114, 112, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'state.number_of_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'ammBaseAssetReserve'; + type: 'u128'; + }, + { + name: 'ammQuoteAssetReserve'; + type: 'u128'; + }, + { + name: 'ammPeriodicity'; + type: 'i64'; + }, + { + name: 'ammPegMultiplier'; + type: 'u128'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'contractTier'; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + { + name: 'marginRatioInitial'; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'activeStatus'; + type: 'bool'; + }, + { + name: 'baseSpread'; + type: 'u32'; + }, + { + name: 'maxSpread'; + type: 'u32'; + }, + { + name: 'maxOpenInterest'; + type: 'u128'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + type: 'u64'; + }, + { + name: 'orderStepSize'; + type: 'u64'; + }, + { + name: 'orderTickSize'; + type: 'u64'; + }, + { + name: 'minOrderSize'; + type: 'u64'; + }, + { + name: 'concentrationCoefScale'; + type: 'u128'; + }, + { + name: 'curveUpdateIntensity'; + type: 'u8'; + }, + { + name: 'ammJitIntensity'; + type: 'u8'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'initializePhoenixFulfillmentConfig'; + discriminator: [135, 132, 110, 107, 185, 160, 169, 154]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'phoenixProgram'; + }, + { + name: 'phoenixMarket'; + }, + { + name: 'driftSigner'; + }, + { + name: 'phoenixFulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 104, + 111, + 101, + 110, + 105, + 120, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'phoenixMarket'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializePredictionMarket'; + discriminator: [248, 70, 198, 224, 224, 105, 125, 195]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'initializePrelaunchOracle'; + discriminator: [169, 178, 84, 25, 175, 62, 29, 247]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'params.perp_market_index'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'prelaunchOracleParams'; + }; + }; + }, + ]; + }, + { + name: 'initializeProtectedMakerModeConfig'; + discriminator: [67, 103, 220, 67, 88, 32, 252, 8]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializePythLazerOracle'; + discriminator: [140, 107, 33, 214, 235, 219, 103, 20]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lazerOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 108, 97, 122, 101, 114]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'feedId'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializePythPullOracle'; + discriminator: [249, 140, 253, 243, 248, 74, 240, 238]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeReferrerName'; + discriminator: [235, 126, 231, 10, 42, 164, 26, 61]; + accounts: [ + { + name: 'referrerName'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 114, + 101, + 102, + 101, + 114, + 114, + 101, + 114, + 95, + 110, + 97, + 109, + 101, + ]; + }, + { + kind: 'arg'; + path: 'name'; + }, + ]; + }; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeRevenueShare'; + discriminator: [57, 9, 123, 131, 82, 52, 50, 13]; + accounts: [ + { + name: 'revenueShare'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 83, 72, 65, 82, 69]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeRevenueShareEscrow'; + discriminator: [187, 18, 123, 88, 238, 104, 84, 154]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSerumFulfillmentConfig'; + discriminator: [193, 211, 132, 172, 70, 171, 7, 94]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'serumProgram'; + }, + { + name: 'serumMarket'; + }, + { + name: 'serumOpenOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 101, + 114, + 117, + 109, + 95, + 111, + 112, + 101, + 110, + 95, + 111, + 114, + 100, + 101, + 114, + 115, + ]; + }, + { + kind: 'account'; + path: 'serumMarket'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'serumFulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 101, + 114, + 117, + 109, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'serumMarket'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSignedMsgUserOrders'; + discriminator: [164, 99, 156, 126, 156, 57, 99, 180]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSignedMsgWsDelegates'; + discriminator: [40, 132, 96, 219, 184, 193, 80, 8]; + accounts: [ + { + name: 'signedMsgWsDelegates'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'delegates'; + type: { + vec: 'pubkey'; + }; + }, + ]; + }, + { + name: 'initializeSpotMarket'; + discriminator: [234, 196, 128, 44, 94, 15, 48, 201]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'spotMarketMint'; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'optimalUtilization'; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + type: 'u32'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'initialAssetWeight'; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + { + name: 'activeStatus'; + type: 'bool'; + }, + { + name: 'assetTier'; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + { + name: 'scaleInitialAssetWeightStart'; + type: 'u64'; + }, + { + name: 'withdrawGuardThreshold'; + type: 'u64'; + }, + { + name: 'orderTickSize'; + type: 'u64'; + }, + { + name: 'orderStepSize'; + type: 'u64'; + }, + { + name: 'ifTotalFactor'; + type: 'u32'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeUser'; + discriminator: [111, 17, 185, 250, 60, 122, 38, 254]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeUserStats'; + discriminator: [254, 243, 72, 98, 251, 130, 168, 213]; + accounts: [ + { + name: 'userStats'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114, 95, 115, 116, 97, 116, 115]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'liquidateBorrowForPerpPnl'; + discriminator: [169, 17, 32, 90, 207, 148, 209, 27]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxLiabilityTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerp'; + discriminator: [75, 35, 119, 247, 191, 18, 139, 2]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxBaseAssetAmount'; + type: 'u64'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerpPnlForDeposit'; + discriminator: [237, 75, 198, 235, 233, 186, 75, 35]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxPnlTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerpWithFill'; + discriminator: [95, 111, 124, 105, 86, 169, 187, 34]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'liquidateSpot'; + discriminator: [107, 0, 128, 41, 35, 229, 251, 18]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxLiabilityTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidateSpotWithSwapBegin'; + discriminator: [12, 43, 176, 83, 156, 251, 117, 13]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'liabilitySpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'liabilityMarketIndex'; + }, + ]; + }; + }, + { + name: 'assetSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'assetMarketIndex'; + }, + ]; + }; + }, + { + name: 'liabilityTokenAccount'; + writable: true; + }, + { + name: 'assetTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'swapAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'liquidateSpotWithSwapEnd'; + discriminator: [142, 88, 163, 160, 223, 75, 55, 225]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'liabilitySpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'liabilityMarketIndex'; + }, + ]; + }; + }, + { + name: 'assetSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'assetMarketIndex'; + }, + ]; + }; + }, + { + name: 'liabilityTokenAccount'; + writable: true; + }, + { + name: 'assetTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'logUserBalances'; + discriminator: [162, 21, 35, 251, 32, 57, 161, 210]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'lpPoolAddLiquidity'; + discriminator: [49, 135, 246, 103, 93, 146, 220, 141]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'inMarketMint'; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'userInTokenAccount'; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'userLpTokenAccount'; + writable: true; + }, + { + name: 'lpMint'; + writable: true; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u128'; + }, + { + name: 'minMintAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'lpPoolRemoveLiquidity'; + discriminator: [164, 36, 193, 252, 196, 157, 138, 43]; + accounts: [ + { + name: 'state'; + }, + { + name: 'driftSigner'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outMarketMint'; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'userOutTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'userLpTokenAccount'; + writable: true; + }, + { + name: 'spotMarketTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + writable: true; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + { + name: 'ammCache'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'minOutAmount'; + type: 'u128'; + }, + ]; + }, + { + name: 'lpPoolSwap'; + discriminator: [36, 161, 39, 49, 227, 1, 35, 226]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'constituentCorrelations'; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + }, + { + name: 'userInTokenAccount'; + writable: true; + }, + { + name: 'userOutTokenAccount'; + writable: true; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inMarketMint'; + }, + { + name: 'outMarketMint'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'minOutAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'modifyOrder'; + discriminator: [47, 124, 117, 255, 201, 197, 130, 94]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'modifyOrderParams'; + type: { + defined: { + name: 'modifyOrderParams'; + }; + }; + }, + ]; + }, + { + name: 'modifyOrderByUserId'; + discriminator: [158, 77, 4, 253, 252, 194, 161, 179]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'userOrderId'; + type: 'u8'; + }, + { + name: 'modifyOrderParams'; + type: { + defined: { + name: 'modifyOrderParams'; + }; + }; + }, + ]; + }, + { + name: 'moveAmmPrice'; + discriminator: [235, 109, 2, 82, 219, 118, 6, 159]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'baseAssetReserve'; + type: 'u128'; + }, + { + name: 'quoteAssetReserve'; + type: 'u128'; + }, + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'openbookV2FulfillmentConfigStatus'; + discriminator: [25, 173, 19, 189, 4, 211, 64, 238]; + accounts: [ + { + name: 'state'; + }, + { + name: 'openbookV2FulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'overrideAmmCacheInfo'; + discriminator: [189, 198, 128, 9, 49, 145, 201, 115]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'overrideParams'; + type: { + defined: { + name: 'overrideAmmCacheParams'; + }; + }; + }, + ]; + }, + { + name: 'pauseSpotMarketDepositWithdraw'; + discriminator: [183, 119, 59, 170, 137, 35, 242, 86]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + signer: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'phoenixFulfillmentConfigStatus'; + discriminator: [96, 31, 113, 32, 12, 203, 7, 154]; + accounts: [ + { + name: 'state'; + }, + { + name: 'phoenixFulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'placeAndMakePerpOrder'; + discriminator: [149, 117, 11, 237, 47, 95, 89, 237]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'takerOrderId'; + type: 'u32'; + }, + ]; + }, + { + name: 'placeAndMakeSignedMsgPerpOrder'; + discriminator: [16, 26, 123, 131, 94, 29, 175, 98]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'takerSignedMsgUserOrders'; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'taker'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'signedMsgOrderUuid'; + type: { + array: ['u8', 8]; + }; + }, + ]; + }, + { + name: 'placeAndMakeSpotOrder'; + discriminator: [149, 158, 85, 66, 239, 9, 243, 98]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'takerOrderId'; + type: 'u32'; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + ]; + }, + { + name: 'placeAndTakePerpOrder'; + discriminator: [213, 51, 1, 187, 108, 220, 230, 224]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'successCondition'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'placeAndTakeSpotOrder'; + discriminator: [191, 3, 138, 71, 114, 198, 202, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'placeOrders'; + discriminator: [60, 63, 50, 123, 12, 197, 60, 190]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + vec: { + defined: { + name: 'orderParams'; + }; + }; + }; + }, + ]; + }, + { + name: 'placePerpOrder'; + discriminator: [69, 161, 93, 202, 120, 126, 76, 185]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + ]; + }, + { + name: 'placeSignedMsgTakerOrder'; + discriminator: [32, 79, 101, 139, 25, 6, 98, 15]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'user'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'ixSysvar'; + docs: [ + 'the supplied Sysvar could be anything else.', + 'The Instruction Sysvar has not been implemented', + 'in the Anchor framework yet, so this is the safe approach.', + ]; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'signedMsgOrderParamsMessageBytes'; + type: 'bytes'; + }, + { + name: 'isDelegateSigner'; + type: 'bool'; + }, + ]; + }, + { + name: 'placeSpotOrder'; + discriminator: [45, 79, 81, 160, 248, 90, 91, 220]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + ]; + }, + { + name: 'postMultiPythPullOracleUpdatesAtomic'; + discriminator: [243, 79, 204, 228, 227, 208, 100, 244]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'guardianSet'; + }, + ]; + args: [ + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'postPythLazerOracleUpdate'; + discriminator: [218, 237, 170, 245, 39, 143, 166, 33]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythLazerStorage'; + address: '3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL'; + }, + { + name: 'ixSysvar'; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'pythMessage'; + type: 'bytes'; + }, + ]; + }, + { + name: 'postPythPullOracleUpdateAtomic'; + discriminator: [116, 122, 137, 158, 224, 195, 173, 119]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'guardianSet'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'recenterPerpMarketAmm'; + discriminator: [24, 87, 10, 115, 165, 190, 80, 139]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pegMultiplier'; + type: 'u128'; + }, + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'recenterPerpMarketAmmCrank'; + discriminator: [166, 19, 64, 10, 14, 51, 101, 122]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'perpMarket'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'depth'; + type: { + option: 'u128'; + }; + }, + ]; + }, + { + name: 'reclaimRent'; + discriminator: [218, 200, 19, 197, 227, 89, 192, 22]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + relations: ['user', 'userStats']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'removeAmmConstituentMappingData'; + discriminator: [20, 183, 211, 162, 16, 52, 229, 115]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'removeInsuranceFundStake'; + discriminator: [128, 166, 142, 9, 254, 187, 143, 174]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'repegAmmCurve'; + discriminator: [3, 36, 102, 89, 180, 128, 120, 213]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'newPegCandidate'; + type: 'u128'; + }, + ]; + }, + { + name: 'requestRemoveInsuranceFundStake'; + discriminator: [142, 70, 204, 92, 73, 106, 180, 52]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'resetFuelSeason'; + discriminator: [199, 122, 192, 255, 32, 99, 63, 200]; + accounts: [ + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'resetPerpMarketAmmOracleTwap'; + discriminator: [127, 10, 55, 164, 123, 226, 47, 24]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: []; + }, + { + name: 'resizeRevenueShareEscrowOrders'; + discriminator: [32, 124, 247, 225, 151, 213, 225, 38]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['escrow']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'resizeSignedMsgUserOrders'; + discriminator: [137, 10, 87, 150, 18, 115, 79, 168]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['user']; + }, + { + name: 'user'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolvePerpBankruptcy'; + discriminator: [224, 16, 176, 214, 162, 213, 183, 222]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'quoteSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolvePerpPnlDeficit'; + discriminator: [168, 204, 68, 150, 159, 126, 95, 148]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolveSpotBankruptcy'; + discriminator: [124, 194, 240, 254, 198, 213, 52, 122]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'revertFill'; + discriminator: [236, 238, 176, 69, 239, 10, 181, 193]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'setUserStatusToBeingLiquidated'; + discriminator: [106, 133, 160, 206, 193, 171, 192, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'settleExpiredMarket'; + discriminator: [120, 89, 11, 25, 122, 77, 72, 193]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'settleExpiredMarketPoolsToRevenuePool'; + discriminator: [55, 19, 238, 169, 227, 90, 200, 184]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'settleFundingPayment'; + discriminator: [222, 90, 202, 94, 28, 45, 115, 183]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'settleMultiplePnls'; + discriminator: [127, 66, 117, 57, 40, 50, 152, 127]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndexes'; + type: { + vec: 'u16'; + }; + }, + { + name: 'mode'; + type: { + defined: { + name: 'settlePnlMode'; + }; + }; + }, + ]; + }, + { + name: 'settlePerpToLpPool'; + discriminator: [5, 98, 46, 188, 10, 59, 2, 249]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + }, + { + name: 'quoteMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'constituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'constituentQuoteTokenAccount'; + writable: true; + }, + { + name: 'quoteTokenVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: []; + }, + { + name: 'settlePnl'; + discriminator: [43, 61, 234, 45, 15, 95, 152, 153]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'settleRevenueToInsuranceFund'; + discriminator: [200, 120, 93, 136, 69, 38, 199, 159]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'sweepFuel'; + discriminator: [175, 107, 19, 56, 165, 241, 43, 69]; + accounts: [ + { + name: 'fuelOverflow'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['fuelOverflow', 'userStats']; + }, + { + name: 'signer'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'transferDeposit'; + discriminator: [20, 20, 147, 223, 41, 63, 204, 111]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['fromUser', 'toUser', 'userStats']; + }, + { + name: 'state'; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'transferPerpPosition'; + discriminator: [23, 172, 188, 168, 134, 210, 3, 108]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: { + option: 'i64'; + }; + }, + ]; + }, + { + name: 'transferPools'; + discriminator: [197, 103, 154, 25, 107, 90, 60, 94]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['fromUser', 'toUser', 'userStats']; + }, + { + name: 'state'; + }, + { + name: 'depositFromSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'depositFromMarketIndex'; + }, + ]; + }; + }, + { + name: 'depositToSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'depositToMarketIndex'; + }, + ]; + }; + }, + { + name: 'borrowFromSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'borrowFromMarketIndex'; + }, + ]; + }; + }, + { + name: 'borrowToSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'borrowToMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'depositFromMarketIndex'; + type: 'u16'; + }, + { + name: 'depositToMarketIndex'; + type: 'u16'; + }, + { + name: 'borrowFromMarketIndex'; + type: 'u16'; + }, + { + name: 'borrowToMarketIndex'; + type: 'u16'; + }, + { + name: 'depositAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'borrowAmount'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'transferProtocolIfSharesToRevenuePool'; + discriminator: [236, 136, 147, 153, 146, 205, 104, 29]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'triggerOrder'; + discriminator: [63, 112, 51, 233, 232, 47, 240, 199]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateAdmin'; + discriminator: [161, 176, 40, 213, 60, 184, 179, 228]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'admin'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateAmmCache'; + discriminator: [88, 4, 63, 94, 83, 224, 255, 130]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + }, + { + name: 'quoteMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateAmmConstituentMappingData'; + discriminator: [84, 70, 33, 167, 133, 107, 59, 24]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'ammConstituentMappingData'; + type: { + vec: { + defined: { + name: 'addAmmConstituentMappingDatum'; + }; + }; + }; + }, + ]; + }, + { + name: 'updateAmmJitIntensity'; + discriminator: [181, 191, 53, 109, 166, 249, 55, 142]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ammJitIntensity'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateAmms'; + discriminator: [201, 106, 217, 253, 4, 175, 228, 97]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'marketIndexes'; + type: { + vec: 'u16'; + }; + }, + ]; + }, + { + name: 'updateConstituentCorrelationData'; + discriminator: [79, 14, 19, 73, 221, 106, 62, 109]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'index1'; + type: 'u16'; + }, + { + name: 'index2'; + type: 'u16'; + }, + { + name: 'correlation'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateConstituentOracleInfo'; + discriminator: [198, 117, 231, 250, 147, 33, 127, 161]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'spotMarket'; + }, + { + name: 'oracle'; + }, + ]; + args: []; + }, + { + name: 'updateConstituentParams'; + discriminator: [238, 130, 122, 31, 12, 104, 192, 122]; + accounts: [ + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'constituentParams'; + type: { + defined: { + name: 'constituentParams'; + }; + }; + }, + ]; + }, + { + name: 'updateConstituentPausedOperations'; + discriminator: [185, 122, 153, 191, 131, 177, 132, 208]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateConstituentStatus'; + discriminator: [76, 159, 211, 239, 182, 214, 6, 15]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'newStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateDelegateUserGovTokenInsuranceStake'; + discriminator: [241, 29, 215, 228, 142, 116, 22, 160]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: []; + }, + { + name: 'updateDiscountMint'; + discriminator: [32, 252, 122, 211, 66, 31, 47, 241]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'discountMint'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateExchangeStatus'; + discriminator: [83, 160, 252, 250, 129, 116, 49, 223]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'exchangeStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsBuilderCodes'; + discriminator: [1, 128, 177, 51, 173, 45, 11, 102]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMedianTriggerPrice'; + discriminator: [64, 185, 221, 45, 87, 147, 12, 19]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMintRedeemLpPool'; + discriminator: [26, 11, 142, 122, 206, 159, 9, 45]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMmOracle'; + discriminator: [218, 134, 33, 186, 231, 59, 130, 149]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsSettleLpPool'; + discriminator: [186, 28, 78, 230, 155, 83, 242, 26]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsSwapLpPool'; + discriminator: [83, 16, 150, 12, 102, 3, 22, 58]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFundingRate'; + discriminator: [201, 178, 116, 212, 166, 144, 72, 238]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateHighLeverageModeConfig'; + discriminator: [64, 122, 212, 93, 141, 217, 202, 55]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'currentUsers'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updateIfRebalanceConfig'; + discriminator: [142, 245, 249, 66, 249, 181, 22, 83]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'ifRebalanceConfigParams'; + }; + }; + }, + ]; + }, + { + name: 'updateInitialAmmCacheInfo'; + discriminator: [157, 210, 109, 67, 212, 170, 12, 107]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateInitialPctToLiquidate'; + discriminator: [210, 133, 225, 128, 194, 50, 13, 109]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'initialPctToLiquidate'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateInsuranceFundUnstakingPeriod'; + discriminator: [44, 69, 43, 226, 204, 223, 202, 52]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'insuranceFundUnstakingPeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateK'; + discriminator: [72, 98, 9, 139, 129, 229, 172, 56]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'updateLiquidationDuration'; + discriminator: [28, 154, 20, 249, 102, 192, 73, 71]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidationDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateLiquidationMarginBufferRatio'; + discriminator: [132, 224, 243, 160, 154, 82, 97, 215]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidationMarginBufferRatio'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateLpConstituentTargetBase'; + discriminator: [157, 65, 50, 207, 59, 236, 161, 110]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'ammConstituentMapping'; + }, + { + name: 'constituentTargetBase'; + writable: true; + }, + { + name: 'ammCache'; + }, + { + name: 'lpPool'; + }, + ]; + args: []; + }, + { + name: 'updateLpPoolAum'; + discriminator: [88, 113, 137, 206, 246, 247, 171, 142]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'constituentTargetBase'; + writable: true; + }, + { + name: 'ammCache'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateLpPoolParams'; + discriminator: [217, 92, 2, 255, 27, 167, 178, 81]; + accounts: [ + { + name: 'lpPool'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'lpPoolParams'; + type: { + defined: { + name: 'lpPoolParams'; + }; + }; + }, + ]; + }, + { + name: 'updateOracleGuardRails'; + discriminator: [131, 112, 10, 59, 32, 54, 40, 164]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleGuardRails'; + type: { + defined: { + name: 'oracleGuardRails'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpAuctionDuration'; + discriminator: [126, 110, 52, 174, 30, 206, 215, 90]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'minPerpAuctionDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpBidAskTwap'; + discriminator: [247, 23, 255, 65, 212, 90, 221, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'keeperStats'; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'updatePerpFeeStructure'; + discriminator: [23, 178, 111, 203, 73, 22, 140, 75]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'feeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketAmmOracleTwap'; + discriminator: [241, 74, 114, 123, 206, 153, 24, 202]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: []; + }, + { + name: 'updatePerpMarketAmmSpreadAdjustment'; + discriminator: [155, 195, 149, 43, 220, 82, 173, 205]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ammSpreadAdjustment'; + type: 'i8'; + }, + { + name: 'ammInventorySpreadAdjustment'; + type: 'i8'; + }, + { + name: 'referencePriceOffset'; + type: 'i32'; + }, + ]; + }, + { + name: 'updatePerpMarketAmmSummaryStats'; + discriminator: [122, 101, 249, 238, 209, 9, 241, 245]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'perpMarket'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'updatePerpMarketSummaryStatsParams'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketBaseSpread'; + discriminator: [71, 95, 84, 168, 9, 157, 198, 65]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'baseSpread'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketConcentrationCoef'; + discriminator: [24, 78, 232, 126, 169, 176, 230, 16]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'concentrationScale'; + type: 'u128'; + }, + ]; + }, + { + name: 'updatePerpMarketContractTier'; + discriminator: [236, 128, 15, 95, 203, 214, 68, 117]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'contractTier'; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketCurveUpdateIntensity'; + discriminator: [50, 131, 6, 156, 226, 231, 189, 72]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'curveUpdateIntensity'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketExpiry'; + discriminator: [44, 221, 227, 151, 131, 140, 22, 110]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'expiryTs'; + type: 'i64'; + }, + ]; + }, + { + name: 'updatePerpMarketFeeAdjustment'; + discriminator: [194, 174, 87, 102, 43, 148, 32, 112]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'feeAdjustment'; + type: 'i16'; + }, + ]; + }, + { + name: 'updatePerpMarketFundingPeriod'; + discriminator: [171, 161, 69, 91, 129, 139, 161, 28]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'fundingPeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updatePerpMarketHighLeverageMarginRatio'; + discriminator: [88, 112, 86, 49, 24, 116, 74, 157]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marginRatioInitial'; + type: 'u16'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketImfFactor'; + discriminator: [207, 194, 56, 132, 35, 67, 71, 244]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'unrealizedPnlImfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketLiquidationFee'; + discriminator: [90, 137, 9, 145, 41, 8, 148, 117]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolFeeTransferScalar'; + discriminator: [94, 228, 237, 109, 100, 185, 4, 81]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'optionalLpFeeTransferScalar'; + type: { + option: 'u8'; + }; + }, + { + name: 'optionalLpNetPnlTransferScalar'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolId'; + discriminator: [119, 208, 154, 88, 165, 92, 21, 188]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'lpPoolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolPausedOperations'; + discriminator: [181, 94, 93, 146, 51, 89, 32, 135]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'lpPausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolStatus'; + discriminator: [67, 6, 252, 61, 54, 88, 89, 233]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'lpStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketMarginRatio'; + discriminator: [130, 173, 107, 45, 119, 105, 26, 113]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marginRatioInitial'; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxFillReserveFraction'; + discriminator: [19, 172, 114, 154, 42, 135, 161, 133]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxFillReserveFraction'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxImbalances'; + discriminator: [15, 206, 73, 133, 60, 8, 86, 89]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'unrealizedMaxImbalance'; + type: 'u64'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxOpenInterest'; + discriminator: [194, 79, 149, 224, 246, 102, 186, 140]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxOpenInterest'; + type: 'u128'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxSlippageRatio'; + discriminator: [235, 37, 40, 196, 70, 146, 54, 201]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxSlippageRatio'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxSpread'; + discriminator: [80, 252, 122, 62, 40, 218, 91, 100]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxSpread'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketMinOrderSize'; + discriminator: [226, 74, 5, 89, 108, 223, 46, 141]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'orderSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketName'; + discriminator: [211, 31, 21, 210, 64, 108, 66, 201]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updatePerpMarketNumberOfUsers'; + discriminator: [35, 62, 144, 177, 180, 62, 215, 196]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'numberOfUsers'; + type: { + option: 'u32'; + }; + }, + { + name: 'numberOfUsersWithBase'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketOracle'; + discriminator: [182, 113, 111, 160, 67, 174, 89, 191]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'oldOracle'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'skipInvariantCheck'; + type: 'bool'; + }, + ]; + }, + { + name: 'updatePerpMarketOracleLowRiskSlotDelayOverride'; + discriminator: [124, 108, 147, 229, 109, 117, 123, 3]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleLowRiskSlotDelayOverride'; + type: 'i8'; + }, + ]; + }, + { + name: 'updatePerpMarketOracleSlotDelayOverride'; + discriminator: [165, 91, 239, 227, 63, 172, 227, 8]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleSlotDelayOverride'; + type: 'i8'; + }, + ]; + }, + { + name: 'updatePerpMarketPausedOperations'; + discriminator: [53, 16, 136, 132, 30, 220, 121, 85]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketPnlPool'; + discriminator: [50, 202, 249, 224, 166, 184, 13, 143]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketProtectedMakerParams'; + discriminator: [249, 213, 115, 34, 253, 239, 75, 173]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'protectedMakerLimitPriceDivisor'; + type: { + option: 'u8'; + }; + }, + { + name: 'protectedMakerDynamicDivisor'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketReferencePriceOffsetDeadbandPct'; + discriminator: [214, 73, 166, 11, 218, 76, 110, 163]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'referencePriceOffsetDeadbandPct'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketStatus'; + discriminator: [71, 201, 175, 122, 255, 207, 196, 207]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketStepSizeAndTickSize'; + discriminator: [231, 255, 97, 25, 146, 139, 174, 4]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'stepSize'; + type: 'u64'; + }, + { + name: 'tickSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketUnrealizedAssetWeight'; + discriminator: [135, 132, 205, 165, 109, 150, 166, 106]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'unrealizedInitialAssetWeight'; + type: 'u32'; + }, + { + name: 'unrealizedMaintenanceAssetWeight'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePrelaunchOracle'; + discriminator: [220, 132, 27, 27, 233, 220, 61, 219]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + }, + { + name: 'oracle'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updatePrelaunchOracleParams'; + discriminator: [98, 205, 147, 243, 18, 75, 83, 207]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'params.perp_market_index'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'prelaunchOracleParams'; + }; + }; + }, + ]; + }, + { + name: 'updateProtectedMakerModeConfig'; + discriminator: [86, 166, 235, 253, 67, 202, 223, 17]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'currentUsers'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updatePythPullOracle'; + discriminator: [230, 191, 189, 94, 108, 59, 74, 197]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'encodedVaa'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'updateSerumFulfillmentConfigStatus'; + discriminator: [171, 109, 240, 251, 95, 1, 149, 89]; + accounts: [ + { + name: 'state'; + }, + { + name: 'serumFulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotAuctionDuration'; + discriminator: [182, 178, 203, 72, 187, 143, 157, 107]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'defaultSpotAuctionDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotFeeStructure'; + discriminator: [97, 216, 105, 131, 113, 246, 142, 141]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'feeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketAssetTier'; + discriminator: [253, 209, 231, 14, 242, 208, 243, 130]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'assetTier'; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketBorrowRate'; + discriminator: [71, 239, 236, 153, 210, 62, 254, 76]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'optimalUtilization'; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + type: 'u32'; + }, + { + name: 'minBorrowRate'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updateSpotMarketCumulativeInterest'; + discriminator: [39, 166, 139, 243, 158, 165, 155, 225]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateSpotMarketExpiry'; + discriminator: [208, 11, 211, 159, 226, 24, 11, 247]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'expiryTs'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateSpotMarketFeeAdjustment'; + discriminator: [148, 182, 3, 126, 157, 114, 220, 99]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'feeAdjustment'; + type: 'i16'; + }, + ]; + }, + { + name: 'updateSpotMarketIfFactor'; + discriminator: [147, 30, 224, 34, 18, 230, 105, 4]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'userIfFactor'; + type: 'u32'; + }, + { + name: 'totalIfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketIfPausedOperations'; + discriminator: [101, 215, 79, 74, 59, 41, 79, 12]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketLiquidationFee'; + discriminator: [11, 13, 255, 53, 56, 136, 104, 177]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketMarginWeights'; + discriminator: [109, 33, 87, 195, 255, 36, 6, 81]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'initialAssetWeight'; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketMaxTokenBorrows'; + discriminator: [57, 102, 204, 212, 253, 95, 13, 199]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxTokenBorrowsFraction'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateSpotMarketMaxTokenDeposits'; + discriminator: [56, 191, 79, 18, 26, 121, 80, 208]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxTokenDeposits'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketMinOrderSize'; + discriminator: [93, 128, 11, 119, 26, 20, 181, 50]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'orderSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketName'; + discriminator: [17, 208, 1, 1, 162, 211, 188, 224]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updateSpotMarketOracle'; + discriminator: [114, 184, 102, 37, 246, 186, 180, 99]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'oldOracle'; + }, + ]; + args: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'skipInvariantCheck'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateSpotMarketOrdersEnabled'; + discriminator: [190, 79, 206, 15, 26, 229, 229, 43]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ordersEnabled'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateSpotMarketPausedOperations'; + discriminator: [100, 61, 153, 81, 180, 12, 6, 248]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketPoolId'; + discriminator: [22, 213, 197, 160, 139, 193, 81, 149]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'poolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketRevenueSettlePeriod'; + discriminator: [81, 92, 126, 41, 250, 225, 156, 219]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'revenueSettlePeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateSpotMarketScaleInitialAssetWeightStart'; + discriminator: [217, 204, 204, 118, 204, 130, 225, 147]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'scaleInitialAssetWeightStart'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketStatus'; + discriminator: [78, 94, 16, 188, 193, 110, 231, 31]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketStepSizeAndTickSize'; + discriminator: [238, 153, 137, 80, 206, 59, 250, 61]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'stepSize'; + type: 'u64'; + }, + { + name: 'tickSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateStateMaxInitializeUserFee'; + discriminator: [237, 225, 25, 237, 193, 45, 77, 97]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'maxInitializeUserFee'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateStateMaxNumberOfSubAccounts'; + discriminator: [155, 123, 214, 2, 221, 166, 204, 85]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'maxNumberOfSubAccounts'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateStateSettlementDuration'; + discriminator: [97, 68, 199, 235, 131, 80, 61, 173]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'settlementDuration'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateUserCustomMarginRatio'; + discriminator: [21, 221, 140, 187, 32, 129, 11, 123]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'marginRatio'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateUserDelegate'; + discriminator: [139, 205, 141, 141, 113, 36, 94, 187]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'delegate'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateUserGovTokenInsuranceStake'; + discriminator: [143, 99, 235, 187, 20, 159, 184, 84]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signer'; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateUserIdle'; + discriminator: [253, 133, 67, 22, 103, 161, 20, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateUserMarginTradingEnabled'; + discriminator: [194, 92, 204, 223, 246, 188, 31, 203]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'marginTradingEnabled'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserName'; + discriminator: [135, 25, 185, 56, 165, 53, 34, 136]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updateUserPerpPositionCustomMarginRatio'; + discriminator: [121, 137, 157, 155, 89, 186, 145, 113]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marginRatio'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateUserPoolId'; + discriminator: [219, 86, 73, 106, 56, 218, 128, 109]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateUserProtectedMakerOrders'; + discriminator: [114, 39, 123, 198, 187, 25, 90, 219]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'protectedMakerOrders'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserQuoteAssetInsuranceStake'; + discriminator: [251, 101, 156, 7, 2, 63, 30, 23]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signer'; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateUserReduceOnly'; + discriminator: [199, 71, 42, 67, 144, 19, 86, 109]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserStatsReferrerStatus'; + discriminator: [174, 154, 72, 42, 191, 148, 145, 205]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateWithdrawGuardThreshold'; + discriminator: [56, 18, 39, 61, 155, 211, 44, 133]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'withdrawGuardThreshold'; + type: 'u64'; + }, + ]; + }, + { + name: 'viewLpPoolAddLiquidityFees'; + discriminator: [80, 66, 226, 161, 70, 142, 119, 84]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'inMarketMint'; + }, + { + name: 'inConstituent'; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + }, + { + name: 'constituentTargetBase'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u128'; + }, + ]; + }, + { + name: 'viewLpPoolRemoveLiquidityFees'; + discriminator: [47, 12, 9, 102, 12, 226, 197, 89]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outMarketMint'; + }, + { + name: 'outConstituent'; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + }, + { + name: 'constituentTargetBase'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'viewLpPoolSwapFees'; + discriminator: [126, 189, 109, 189, 170, 156, 3, 46]; + accounts: [ + { + name: 'driftSigner'; + }, + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'constituentCorrelations'; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'inTargetWeight'; + type: 'i64'; + }, + { + name: 'outTargetWeight'; + type: 'i64'; + }, + ]; + }, + { + name: 'withdraw'; + discriminator: [183, 18, 70, 156, 148, 109, 161, 34]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['user', 'userStats']; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'withdrawFromProgramVault'; + discriminator: [120, 40, 183, 149, 232, 18, 224, 151]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'driftSigner'; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'constituentTokenAccount'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'mint'; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'zeroMmOracleFields'; + discriminator: [192, 226, 39, 204, 207, 120, 148, 250]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: 'ammCache'; + discriminator: [213, 114, 161, 56, 20, 22, 2, 59]; + }, + { + name: 'ammConstituentMapping'; + discriminator: [254, 89, 5, 173, 66, 54, 214, 247]; + }, + { + name: 'constituent'; + discriminator: [0, 61, 36, 35, 177, 76, 216, 205]; + }, + { + name: 'constituentCorrelations'; + discriminator: [124, 203, 115, 33, 18, 162, 67, 216]; + }, + { + name: 'constituentTargetBase'; + discriminator: [255, 142, 134, 71, 125, 66, 198, 99]; + }, + { + name: 'fuelOverflow'; + discriminator: [182, 64, 231, 177, 226, 142, 69, 58]; + }, + { + name: 'highLeverageModeConfig'; + discriminator: [3, 196, 90, 189, 193, 64, 228, 234]; + }, + { + name: 'ifRebalanceConfig'; + discriminator: [214, 84, 40, 251, 107, 144, 173, 239]; + }, + { + name: 'insuranceFundStake'; + discriminator: [110, 202, 14, 42, 95, 73, 90, 95]; + }, + { + name: 'lpPool'; + discriminator: [228, 152, 141, 224, 161, 170, 11, 89]; + }, + { + name: 'openbookV2FulfillmentConfig'; + discriminator: [3, 43, 58, 106, 131, 132, 199, 171]; + }, + { + name: 'perpMarket'; + discriminator: [10, 223, 12, 44, 107, 245, 55, 247]; + }, + { + name: 'phoenixV1FulfillmentConfig'; + discriminator: [233, 45, 62, 40, 35, 129, 48, 72]; + }, + { + name: 'prelaunchOracle'; + discriminator: [92, 14, 139, 234, 72, 244, 68, 26]; + }, + { + name: 'protectedMakerModeConfig'; + discriminator: [47, 86, 90, 9, 224, 255, 10, 69]; + }, + { + name: 'pythLazerOracle'; + discriminator: [159, 7, 161, 249, 34, 81, 121, 133]; + }, + { + name: 'referrerName'; + discriminator: [105, 133, 170, 110, 52, 42, 28, 182]; + }, + { + name: 'revenueShare'; + discriminator: [55, 40, 228, 7, 139, 52, 180, 110]; + }, + { + name: 'revenueShareEscrow'; + discriminator: [98, 167, 3, 46, 74, 177, 173, 252]; + }, + { + name: 'serumV3FulfillmentConfig'; + discriminator: [65, 160, 197, 112, 239, 168, 103, 185]; + }, + { + name: 'signedMsgUserOrders'; + discriminator: [70, 6, 50, 248, 222, 1, 143, 49]; + }, + { + name: 'signedMsgWsDelegates'; + discriminator: [190, 115, 111, 44, 216, 252, 108, 85]; + }, + { + name: 'spotMarket'; + discriminator: [100, 177, 8, 107, 168, 65, 65, 39]; + }, + { + name: 'state'; + discriminator: [216, 146, 107, 94, 104, 75, 182, 177]; + }, + { + name: 'user'; + discriminator: [159, 117, 95, 227, 239, 151, 58, 236]; + }, + { + name: 'userStats'; + discriminator: [176, 223, 136, 27, 122, 79, 32, 227]; + }, + ]; + events: [ + { + name: 'curveRecord'; + discriminator: [101, 238, 40, 228, 70, 46, 61, 117]; + }, + { + name: 'deleteUserRecord'; + discriminator: [71, 111, 190, 118, 7, 3, 132, 222]; + }, + { + name: 'depositRecord'; + discriminator: [180, 241, 218, 207, 102, 135, 44, 134]; + }, + { + name: 'fuelSeasonRecord'; + discriminator: [19, 137, 119, 33, 224, 249, 6, 87]; + }, + { + name: 'fuelSweepRecord'; + discriminator: [41, 84, 37, 246, 132, 240, 131, 8]; + }, + { + name: 'fundingPaymentRecord'; + discriminator: [8, 59, 96, 20, 137, 201, 56, 95]; + }, + { + name: 'fundingRateRecord'; + discriminator: [68, 3, 255, 26, 133, 91, 147, 254]; + }, + { + name: 'insuranceFundRecord'; + discriminator: [56, 222, 215, 235, 78, 197, 99, 146]; + }, + { + name: 'insuranceFundStakeRecord'; + discriminator: [68, 66, 156, 7, 216, 148, 250, 114]; + }, + { + name: 'insuranceFundSwapRecord'; + discriminator: [85, 190, 99, 203, 237, 33, 227, 100]; + }, + { + name: 'lpBorrowLendDepositRecord'; + discriminator: [242, 181, 11, 56, 243, 61, 79, 210]; + }, + { + name: 'lpMintRedeemRecord'; + discriminator: [53, 178, 142, 73, 78, 91, 91, 8]; + }, + { + name: 'lpRecord'; + discriminator: [101, 22, 54, 38, 178, 13, 142, 111]; + }, + { + name: 'lpSettleRecord'; + discriminator: [208, 191, 131, 110, 173, 48, 7, 2]; + }, + { + name: 'lpSwapRecord'; + discriminator: [159, 62, 130, 196, 96, 79, 176, 254]; + }, + { + name: 'liquidationRecord'; + discriminator: [127, 17, 0, 108, 182, 13, 231, 53]; + }, + { + name: 'newUserRecord'; + discriminator: [236, 186, 113, 219, 42, 51, 149, 249]; + }, + { + name: 'orderActionRecord'; + discriminator: [224, 52, 67, 71, 194, 237, 109, 1]; + }, + { + name: 'orderRecord'; + discriminator: [104, 19, 64, 56, 89, 21, 2, 90]; + }, + { + name: 'revenueShareSettleRecord'; + discriminator: [61, 162, 89, 10, 24, 20, 59, 45]; + }, + { + name: 'settlePnlRecord'; + discriminator: [57, 68, 105, 26, 119, 198, 213, 89]; + }, + { + name: 'signedMsgOrderRecord'; + discriminator: [211, 197, 25, 18, 142, 86, 113, 27]; + }, + { + name: 'spotInterestRecord'; + discriminator: [183, 186, 203, 186, 225, 187, 95, 130]; + }, + { + name: 'spotMarketVaultDepositRecord'; + discriminator: [178, 217, 23, 188, 127, 190, 32, 73]; + }, + { + name: 'swapRecord'; + discriminator: [162, 187, 123, 194, 138, 56, 250, 241]; + }, + { + name: 'transferProtocolIfSharesToRevenuePoolRecord'; + discriminator: [209, 118, 142, 167, 130, 46, 164, 151]; + }, + ]; + errors: [ + { + code: 6000; + name: 'invalidEd25519InstructionProgramId'; + msg: 'invalid ed25519 instruction program'; + }, + { + code: 6001; + name: 'invalidEd25519InstructionDataLength'; + msg: 'invalid ed25519 instruction data length'; + }, + { + code: 6002; + name: 'invalidSignatureIndex'; + msg: 'invalid signature index'; + }, + { + code: 6003; + name: 'invalidSignatureOffset'; + msg: 'invalid signature offset'; + }, + { + code: 6004; + name: 'invalidPublicKeyOffset'; + msg: 'invalid public key offset'; + }, + { + code: 6005; + name: 'invalidMessageOffset'; + msg: 'invalid message offset'; + }, + { + code: 6006; + name: 'invalidMessageDataSize'; + msg: 'invalid message data size'; + }, + { + code: 6007; + name: 'invalidInstructionIndex'; + msg: 'invalid instruction index'; + }, + { + code: 6008; + name: 'messageOffsetOverflow'; + msg: 'message offset overflow'; + }, + { + code: 6009; + name: 'invalidMessageHex'; + msg: 'invalid message hex'; + }, + { + code: 6010; + name: 'invalidMessageData'; + msg: 'invalid message data'; + }, + { + code: 6011; + name: 'loadInstructionAtFailed'; + msg: 'loading custom ix at index failed'; + }, + ]; + types: [ + { + name: 'amm'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'oracle'; + docs: ['oracle price data public key']; + type: 'pubkey'; + }, + { + name: 'historicalOracleData'; + docs: ['stores historically witnessed oracle data']; + type: { + defined: { + name: 'historicalOracleData'; + }; + }; + }, + { + name: 'baseAssetAmountPerLp'; + docs: [ + 'accumulated base asset amount since inception per lp share', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteAssetAmountPerLp'; + docs: [ + 'accumulated quote asset amount since inception per lp share', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'feePool'; + docs: [ + 'partition of fees from perp market trading moved from pnl settlements', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'baseAssetReserve'; + docs: [ + '`x` reserves for constant product mm formula (x * y = k)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'quoteAssetReserve'; + docs: [ + '`y` reserves for constant product mm formula (x * y = k)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'concentrationCoef'; + docs: [ + 'determines how close the min/max base asset reserve sit vs base reserves', + 'allow for decreasing slippage without increasing liquidity and v.v.', + 'precision: PERCENTAGE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'minBaseAssetReserve'; + docs: [ + 'minimum base_asset_reserve allowed before AMM is unavailable', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'maxBaseAssetReserve'; + docs: [ + 'maximum base_asset_reserve allowed before AMM is unavailable', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'sqrtK'; + docs: [ + '`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'pegMultiplier'; + docs: [ + 'normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced', + 'precision: PEG_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'terminalQuoteAssetReserve'; + docs: [ + 'y when market is balanced. stored to save computation', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'baseAssetAmountLong'; + docs: [ + 'always non-negative. tracks number of total longs in market (regardless of counterparty)', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountShort'; + docs: [ + 'always non-positive. tracks number of total shorts in market (regardless of counterparty)', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: [ + 'tracks net position (longs-shorts) in market with AMM as counterparty', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountWithUnsettledLp'; + docs: [ + 'tracks net position (longs-shorts) in market with LPs as counterparty', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'maxOpenInterest'; + docs: [ + 'max allowed open interest, blocks trades that breach this value', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'quoteAssetAmount'; + docs: [ + "sum of all user's perp quote_asset_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteEntryAmountLong'; + docs: [ + "sum of all long user's quote_entry_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteEntryAmountShort'; + docs: [ + "sum of all short user's quote_entry_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteBreakEvenAmountLong'; + docs: [ + "sum of all long user's quote_break_even_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteBreakEvenAmountShort'; + docs: [ + "sum of all short user's quote_break_even_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'userLpShares'; + docs: [ + 'total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastFundingRate'; + docs: [ + 'last funding rate in this perp market (unit is quote per base)', + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateLong'; + docs: [ + 'last funding rate for longs in this perp market (unit is quote per base)', + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateShort'; + docs: [ + 'last funding rate for shorts in this perp market (unit is quote per base)', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'last24hAvgFundingRate'; + docs: [ + 'estimate of last 24h of funding rate perp market (unit is quote per base)', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'totalFee'; + docs: [ + 'total fees collected by this perp market', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalMmFee'; + docs: [ + "total fees collected by the vAMM's bid/ask spread", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalExchangeFee'; + docs: [ + 'total fees collected by exchange fee schedule', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalFeeMinusDistributions'; + docs: [ + 'total fees minus any recognized upnl and pool withdraws', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalFeeWithdrawn'; + docs: [ + 'sum of all fees from fee pool withdrawn to revenue pool', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalLiquidationFee'; + docs: [ + 'all fees collected by market for liquidations', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeFundingRateLong'; + docs: [ + 'accumulated funding rate for longs since inception in market', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'cumulativeFundingRateShort'; + docs: [ + 'accumulated funding rate for shorts since inception in market', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalSocialLoss'; + docs: [ + 'accumulated social loss paid by users since inception in market', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'askBaseAssetReserve'; + docs: [ + 'transformed base_asset_reserve for users going long', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'askQuoteAssetReserve'; + docs: [ + 'transformed quote_asset_reserve for users going long', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'bidBaseAssetReserve'; + docs: [ + 'transformed base_asset_reserve for users going short', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'bidQuoteAssetReserve'; + docs: [ + 'transformed quote_asset_reserve for users going short', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastOracleNormalisedPrice'; + docs: [ + 'the last seen oracle price partially shrunk toward the amm reserve price', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastOracleReservePriceSpreadPct'; + docs: [ + 'the gap between the oracle price and the reserve price = y * peg_multiplier / x', + ]; + type: 'i64'; + }, + { + name: 'lastBidPriceTwap'; + docs: [ + 'average estimate of bid price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastAskPriceTwap'; + docs: [ + 'average estimate of ask price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwap'; + docs: [ + 'average estimate of (bid+ask)/2 price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwap5min'; + docs: ['average estimate of (bid+ask)/2 price over FIVE_MINUTES']; + type: 'u64'; + }, + { + name: 'lastUpdateSlot'; + docs: ['the last blockchain slot the amm was updated']; + type: 'u64'; + }, + { + name: 'lastOracleConfPct'; + docs: [ + 'the pct size of the oracle confidence interval', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'netRevenueSinceLastFunding'; + docs: [ + 'the total_fee_minus_distribution change since the last funding update', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateTs'; + docs: ['the last funding rate update unix_timestamp']; + type: 'i64'; + }, + { + name: 'fundingPeriod'; + docs: ['the periodicity of the funding rate updates']; + type: 'i64'; + }, + { + name: 'orderStepSize'; + docs: [ + 'the base step size (increment) of orders', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'orderTickSize'; + docs: [ + 'the price tick size of orders', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minOrderSize'; + docs: [ + 'the minimum base size of an order', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'mmOracleSlot'; + docs: [ + 'the max base size a single user can have', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'volume24h'; + docs: ['estimated total of volume in market', 'QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'longIntensityVolume'; + docs: ['the volume intensity of long fills against AMM']; + type: 'u64'; + }, + { + name: 'shortIntensityVolume'; + docs: ['the volume intensity of short fills against AMM']; + type: 'u64'; + }, + { + name: 'lastTradeTs'; + docs: [ + 'the blockchain unix timestamp at the time of the last trade', + ]; + type: 'i64'; + }, + { + name: 'markStd'; + docs: [ + 'estimate of standard deviation of the fill (mark) prices', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'oracleStd'; + docs: [ + 'estimate of standard deviation of the oracle price at each update', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwapTs'; + docs: ['the last unix_timestamp the mark twap was updated']; + type: 'i64'; + }, + { + name: 'baseSpread'; + docs: [ + 'the minimum spread the AMM can quote. also used as step size for some spread logic increases.', + ]; + type: 'u32'; + }, + { + name: 'maxSpread'; + docs: ['the maximum spread the AMM can quote']; + type: 'u32'; + }, + { + name: 'longSpread'; + docs: ['the spread for asks vs the reserve price']; + type: 'u32'; + }, + { + name: 'shortSpread'; + docs: ['the spread for bids vs the reserve price']; + type: 'u32'; + }, + { + name: 'mmOraclePrice'; + docs: ['MM oracle price']; + type: 'i64'; + }, + { + name: 'maxFillReserveFraction'; + docs: [ + 'the fraction of total available liquidity a single fill on the AMM can consume', + ]; + type: 'u16'; + }, + { + name: 'maxSlippageRatio'; + docs: ['the maximum slippage a single fill on the AMM can push']; + type: 'u16'; + }, + { + name: 'curveUpdateIntensity'; + docs: [ + 'the update intensity of AMM formulaic updates (adjusting k). 0-100', + ]; + type: 'u8'; + }, + { + name: 'ammJitIntensity'; + docs: [ + 'the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.', + '(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM.', + ]; + type: 'u8'; + }, + { + name: 'oracleSource'; + docs: [ + 'the oracle provider information. used to decode/scale the oracle public key', + ]; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'lastOracleValid'; + docs: [ + 'tracks whether the oracle was considered valid at the last AMM update', + ]; + type: 'bool'; + }, + { + name: 'targetBaseAssetAmountPerLp'; + docs: [ + 'the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split', + 'precision: BASE_PRECISION', + ]; + type: 'i32'; + }, + { + name: 'perLpBase'; + docs: [ + 'expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)', + ]; + type: 'i8'; + }, + { + name: 'oracleLowRiskSlotDelayOverride'; + docs: [ + 'the override for the state.min_perp_auction_duration', + '0 is no override, -1 is disable speed bump, 1-100 is literal speed bump', + ]; + type: 'i8'; + }, + { + name: 'ammSpreadAdjustment'; + docs: [ + 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', + ]; + type: 'i8'; + }, + { + name: 'oracleSlotDelayOverride'; + type: 'i8'; + }, + { + name: 'mmOracleSequenceId'; + type: 'u64'; + }, + { + name: 'netUnsettledFundingPnl'; + type: 'i64'; + }, + { + name: 'quoteAssetAmountWithUnsettledLp'; + type: 'i64'; + }, + { + name: 'referencePriceOffset'; + type: 'i32'; + }, + { + name: 'ammInventorySpreadAdjustment'; + docs: [ + 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', + ]; + type: 'i8'; + }, + { + name: 'referencePriceOffsetDeadbandPct'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 2]; + }; + }, + { + name: 'lastFundingOracleTwap'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'addAmmConstituentMappingDatum'; + type: { + kind: 'struct'; + fields: [ + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'weight'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ammCache'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'cache'; + type: { + vec: { + defined: { + name: 'cacheInfo'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'ammConstituentDatum'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'lastSlot'; + type: 'u64'; + }, + { + name: 'weight'; + docs: [ + 'PERCENTAGE_PRECISION. The weight this constituent has on the perp market', + ]; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ammConstituentMapping'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'weights'; + type: { + vec: { + defined: { + name: 'ammConstituentDatum'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'assetTier'; + type: { + kind: 'enum'; + variants: [ + { + name: 'collateral'; + }, + { + name: 'protected'; + }, + { + name: 'cross'; + }, + { + name: 'isolated'; + }, + { + name: 'unlisted'; + }, + ]; + }; + }, + { + name: 'builderInfo'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'maxFeeTenthBps'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 6]; + }; + }, + ]; + }; + }, + { + name: 'cacheInfo'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'lastFeePoolTokenAmount'; + type: 'u128'; + }, + { + name: 'lastNetPnlPoolTokenAmount'; + type: 'i128'; + }, + { + name: 'lastExchangeFees'; + type: 'u128'; + }, + { + name: 'lastSettleAmmExFees'; + type: 'u128'; + }, + { + name: 'lastSettleAmmPnl'; + type: 'i128'; + }, + { + name: 'position'; + docs: ['BASE PRECISION']; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'lastSettleAmount'; + type: 'u64'; + }, + { + name: 'lastSettleSlot'; + type: 'u64'; + }, + { + name: 'lastSettleTs'; + type: 'i64'; + }, + { + name: 'quoteOwedFromLpPool'; + type: 'i64'; + }, + { + name: 'ammInventoryLimit'; + type: 'i64'; + }, + { + name: 'oraclePrice'; + type: 'i64'; + }, + { + name: 'oracleSlot'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'oracleSource'; + type: 'u8'; + }, + { + name: 'oracleValidity'; + type: 'u8'; + }, + { + name: 'lpStatusForPerpMarket'; + type: 'u8'; + }, + { + name: 'ammPositionScalar'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 34]; + }; + }, + ]; + }; + }, + { + name: 'constituent'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: ['address of the constituent']; + type: 'pubkey'; + }, + { + name: 'mint'; + type: 'pubkey'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'vault'; + type: 'pubkey'; + }, + { + name: 'totalSwapFees'; + docs: [ + 'total fees received by the constituent. Positive = fees received, Negative = fees paid', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'spotBalance'; + docs: ['spot borrow-lend balance for constituent']; + type: { + defined: { + name: 'constituentSpotBalance'; + }; + }; + }, + { + name: 'lastSpotBalanceTokenAmount'; + type: 'i64'; + }, + { + name: 'cumulativeSpotInterestAccruedTokenAmount'; + type: 'i64'; + }, + { + name: 'maxWeightDeviation'; + docs: [ + 'max deviation from target_weight allowed for the constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'swapFeeMin'; + docs: [ + 'min fee charged on swaps to/from this constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'swapFeeMax'; + docs: [ + 'max fee charged on swaps to/from this constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxBorrowTokenAmount'; + docs: ['Max Borrow amount:', 'precision: token precision']; + type: 'u64'; + }, + { + name: 'vaultTokenBalance'; + docs: ['ata token balance in token precision']; + type: 'u64'; + }, + { + name: 'lastOraclePrice'; + type: 'i64'; + }, + { + name: 'lastOracleSlot'; + type: 'u64'; + }, + { + name: 'oracleStalenessThreshold'; + docs: ['Delay allowed for valid AUM calculation']; + type: 'u64'; + }, + { + name: 'flashLoanInitialTokenAmount'; + type: 'u64'; + }, + { + name: 'nextSwapId'; + docs: [ + 'Every swap to/from this constituent has a monotonically increasing id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'derivativeWeight'; + docs: [ + 'percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight', + ]; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'constituentDerivativeDepegThreshold'; + type: 'u64'; + }, + { + name: 'constituentDerivativeIndex'; + docs: [ + 'The `constituent_index` of the parent constituent. -1 if it is a parent index', + 'Example: if in a pool with SOL (parent) and dSOL (derivative),', + 'SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,', + 'dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1', + ]; + type: 'i16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'decimals'; + type: 'u8'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'vaultBump'; + type: 'u8'; + }, + { + name: 'gammaInventory'; + type: 'u8'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 162]; + }; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'correlations'; + type: { + vec: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'constituentParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxWeightDeviation'; + type: { + option: 'i64'; + }; + }, + { + name: 'swapFeeMin'; + type: { + option: 'i64'; + }; + }, + { + name: 'swapFeeMax'; + type: { + option: 'i64'; + }; + }, + { + name: 'maxBorrowTokenAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'oracleStalenessThreshold'; + type: { + option: 'u64'; + }; + }, + { + name: 'costToTradeBps'; + type: { + option: 'i32'; + }; + }, + { + name: 'constituentDerivativeIndex'; + type: { + option: 'i16'; + }; + }, + { + name: 'derivativeWeight'; + type: { + option: 'u64'; + }; + }, + { + name: 'volatility'; + type: { + option: 'u64'; + }; + }, + { + name: 'gammaExecution'; + type: { + option: 'u8'; + }; + }, + { + name: 'gammaInventory'; + type: { + option: 'u8'; + }; + }, + { + name: 'xi'; + type: { + option: 'u8'; + }; + }, + ]; + }; + }, + { + name: 'constituentSpotBalance'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', + 'interest of corresponding market.', + 'precision: token precision', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeDeposits'; + docs: [ + 'The cumulative deposits/borrows a user has made into a market', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'marketIndex'; + docs: ['The market index of the corresponding spot market']; + type: 'u16'; + }, + { + name: 'balanceType'; + docs: ['Whether the position is deposit or borrow']; + type: { + defined: { + name: 'spotBalanceType'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 5]; + }; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'targets'; + type: { + vec: { + defined: { + name: 'targetsDatum'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'contractTier'; + type: { + kind: 'enum'; + variants: [ + { + name: 'a'; + }, + { + name: 'b'; + }, + { + name: 'c'; + }, + { + name: 'speculative'; + }, + { + name: 'highlySpeculative'; + }, + { + name: 'isolated'; + }, + ]; + }; + }, + { + name: 'contractType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'perpetual'; + }, + { + name: 'future'; + }, + { + name: 'prediction'; + }, + ]; + }; + }, + { + name: 'curveRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'pegMultiplierBefore'; + type: 'u128'; + }, + { + name: 'baseAssetReserveBefore'; + type: 'u128'; + }, + { + name: 'quoteAssetReserveBefore'; + type: 'u128'; + }, + { + name: 'sqrtKBefore'; + type: 'u128'; + }, + { + name: 'pegMultiplierAfter'; + type: 'u128'; + }, + { + name: 'baseAssetReserveAfter'; + type: 'u128'; + }, + { + name: 'quoteAssetReserveAfter'; + type: 'u128'; + }, + { + name: 'sqrtKAfter'; + type: 'u128'; + }, + { + name: 'baseAssetAmountLong'; + docs: ['precision: BASE_PRECISION']; + type: 'u128'; + }, + { + name: 'baseAssetAmountShort'; + docs: ['precision: BASE_PRECISION']; + type: 'u128'; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + { + name: 'totalFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'totalFeeMinusDistributions'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'adjustmentCost'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'fillRecord'; + type: 'u128'; + }, + { + name: 'numberOfUsers'; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }; + }, + { + name: 'deleteUserRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'keeper'; + type: { + option: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'depositDirection'; + type: { + kind: 'enum'; + variants: [ + { + name: 'deposit'; + }, + { + name: 'withdraw'; + }, + ]; + }; + }, + { + name: 'depositExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'transfer'; + }, + { + name: 'borrow'; + }, + { + name: 'repayBorrow'; + }, + { + name: 'reward'; + }, + ]; + }; + }, + { + name: 'depositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + docs: ['user account public key']; + type: 'pubkey'; + }, + { + name: 'direction'; + type: { + defined: { + name: 'depositDirection'; + }; + }; + }, + { + name: 'depositRecordId'; + type: 'u64'; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'marketIndex'; + docs: ['spot market index']; + type: 'u16'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'marketDepositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'marketWithdrawBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'marketCumulativeDepositInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'marketCumulativeBorrowInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'totalDepositsAfter'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalWithdrawsAfter'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'explanation'; + type: { + defined: { + name: 'depositExplanation'; + }; + }; + }, + { + name: 'transferUser'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'signer'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'userTokenAmountAfter'; + docs: ['precision: token mint precision']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'feeStructure'; + type: { + kind: 'struct'; + fields: [ + { + name: 'feeTiers'; + type: { + array: [ + { + defined: { + name: 'feeTier'; + }; + }, + 10, + ]; + }; + }, + { + name: 'fillerRewardStructure'; + type: { + defined: { + name: 'orderFillerRewardStructure'; + }; + }; + }, + { + name: 'referrerRewardEpochUpperBound'; + type: 'u64'; + }, + { + name: 'flatFillerFee'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'feeTier'; + type: { + kind: 'struct'; + fields: [ + { + name: 'feeNumerator'; + type: 'u32'; + }, + { + name: 'feeDenominator'; + type: 'u32'; + }, + { + name: 'makerRebateNumerator'; + type: 'u32'; + }, + { + name: 'makerRebateDenominator'; + type: 'u32'; + }, + { + name: 'referrerRewardNumerator'; + type: 'u32'; + }, + { + name: 'referrerRewardDenominator'; + type: 'u32'; + }, + { + name: 'refereeFeeNumerator'; + type: 'u32'; + }, + { + name: 'refereeFeeDenominator'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'fuelOverflow'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The authority of this overflow account']; + type: 'pubkey'; + }, + { + name: 'fuelInsurance'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelDeposits'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelBorrows'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelPositions'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelTaker'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelMaker'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastFuelSweepTs'; + type: 'u32'; + }, + { + name: 'lastResetTs'; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u128', 6]; + }; + }, + ]; + }; + }, + { + name: 'fuelSeasonRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'fuelInsurance'; + type: 'u128'; + }, + { + name: 'fuelDeposits'; + type: 'u128'; + }, + { + name: 'fuelBorrows'; + type: 'u128'; + }, + { + name: 'fuelPositions'; + type: 'u128'; + }, + { + name: 'fuelTaker'; + type: 'u128'; + }, + { + name: 'fuelMaker'; + type: 'u128'; + }, + { + name: 'fuelTotal'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'fuelSweepRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'userStatsFuelInsurance'; + type: 'u32'; + }, + { + name: 'userStatsFuelDeposits'; + type: 'u32'; + }, + { + name: 'userStatsFuelBorrows'; + type: 'u32'; + }, + { + name: 'userStatsFuelPositions'; + type: 'u32'; + }, + { + name: 'userStatsFuelTaker'; + type: 'u32'; + }, + { + name: 'userStatsFuelMaker'; + type: 'u32'; + }, + { + name: 'fuelOverflowFuelInsurance'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelDeposits'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelBorrows'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelPositions'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelTaker'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelMaker'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'fundingPaymentRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fundingPayment'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + docs: ['precision: BASE_PRECISION']; + type: 'i64'; + }, + { + name: 'userLastCumulativeFunding'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i64'; + }, + { + name: 'ammCumulativeFundingLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'ammCumulativeFundingShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'fundingRateRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fundingRate'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i64'; + }, + { + name: 'fundingRateLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'fundingRateShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'cumulativeFundingRateLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'cumulativeFundingRateShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'oraclePriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'markPriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'periodRevenue'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + { + name: 'baseAssetAmountWithUnsettledLp'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'highLeverageModeConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'currentUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'u8'; + }, + { + name: 'padding1'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'currentMaintenanceUsers'; + type: 'u32'; + }, + { + name: 'padding2'; + type: { + array: ['u8', 24]; + }; + }, + ]; + }; + }, + { + name: 'historicalIndexData'; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastIndexBidPrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexAskPrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwap5min'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwapTs'; + docs: ['unix_timestamp of last snapshot']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'historicalOracleData'; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOracleConf'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastOracleDelay'; + docs: ['number of slots since last update']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwap5min'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwapTs'; + docs: ['unix_timestamp of last snapshot']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'totalInAmount'; + docs: ['total amount to be sold']; + type: 'u64'; + }, + { + name: 'currentInAmount'; + docs: ['amount already sold']; + type: 'u64'; + }, + { + name: 'currentOutAmount'; + docs: ['amount already bought']; + type: 'u64'; + }, + { + name: 'currentOutAmountTransferred'; + docs: ['amount already transferred to revenue pool']; + type: 'u64'; + }, + { + name: 'currentInAmountSinceLastTransfer'; + docs: ['amount already bought in epoch']; + type: 'u64'; + }, + { + name: 'epochStartTs'; + docs: ['start time of epoch']; + type: 'i64'; + }, + { + name: 'epochInAmount'; + docs: ['amount already bought in epoch']; + type: 'u64'; + }, + { + name: 'epochMaxInAmount'; + docs: ['max amount to swap in epoch']; + type: 'u64'; + }, + { + name: 'epochDuration'; + docs: ['duration of epoch']; + type: 'i64'; + }, + { + name: 'outMarketIndex'; + docs: ['market index to sell']; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + docs: ['market index to buy']; + type: 'u16'; + }, + { + name: 'maxSlippageBps'; + type: 'u16'; + }, + { + name: 'swapMode'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + { + name: 'padding2'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfigParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'totalInAmount'; + type: 'u64'; + }, + { + name: 'epochMaxInAmount'; + type: 'u64'; + }, + { + name: 'epochDuration'; + type: 'i64'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'maxSlippageBps'; + type: 'u16'; + }, + { + name: 'swapMode'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + ]; + }; + }, + { + name: 'insuranceClaim'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'revenueWithdrawSinceLastSettle'; + docs: [ + 'The amount of revenue last settled', + 'Positive if funds left the perp market,', + 'negative if funds were pulled into the perp market', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + docs: [ + 'The max amount of revenue that can be withdrawn per period', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + docs: [ + 'The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'quoteSettledInsurance'; + docs: [ + 'The amount of insurance that has been used to resolve bankruptcy and pnl deficits', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastRevenueWithdrawTs'; + docs: ['The last time revenue was settled in/out of market']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'insuranceFund'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'vault'; + type: 'pubkey'; + }, + { + name: 'totalShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'userShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'sharesBase'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'unstakingPeriod'; + type: 'i64'; + }, + { + name: 'lastRevenueSettleTs'; + type: 'i64'; + }, + { + name: 'revenueSettlePeriod'; + type: 'i64'; + }, + { + name: 'totalFactor'; + type: 'u32'; + }, + { + name: 'userFactor'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'insuranceFundRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'userIfFactor'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'totalIfFactor'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'vaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'insuranceVaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'totalIfSharesBefore'; + type: 'u128'; + }, + { + name: 'totalIfSharesAfter'; + type: 'u128'; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'ifShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastWithdrawRequestShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'ifBase'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastValidTs'; + type: 'i64'; + }, + { + name: 'lastWithdrawRequestValue'; + type: 'u64'; + }, + { + name: 'lastWithdrawRequestTs'; + type: 'i64'; + }, + { + name: 'costBasis'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 14]; + }; + }, + ]; + }; + }, + { + name: 'insuranceFundStakeRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'action'; + type: { + defined: { + name: 'stakeAction'; + }; + }; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'insuranceVaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'ifSharesBefore'; + type: 'u128'; + }, + { + name: 'userIfSharesBefore'; + type: 'u128'; + }, + { + name: 'totalIfSharesBefore'; + type: 'u128'; + }, + { + name: 'ifSharesAfter'; + type: 'u128'; + }, + { + name: 'userIfSharesAfter'; + type: 'u128'; + }, + { + name: 'totalIfSharesAfter'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'insuranceFundSwapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'rebalanceConfig'; + type: 'pubkey'; + }, + { + name: 'inIfTotalSharesBefore'; + type: 'u128'; + }, + { + name: 'outIfTotalSharesBefore'; + type: 'u128'; + }, + { + name: 'inIfUserSharesBefore'; + type: 'u128'; + }, + { + name: 'outIfUserSharesBefore'; + type: 'u128'; + }, + { + name: 'inIfTotalSharesAfter'; + type: 'u128'; + }, + { + name: 'outIfTotalSharesAfter'; + type: 'u128'; + }, + { + name: 'inIfUserSharesAfter'; + type: 'u128'; + }, + { + name: 'outIfUserSharesAfter'; + type: 'u128'; + }, + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'outAmount'; + type: 'u64'; + }, + { + name: 'outOraclePrice'; + type: 'u64'; + }, + { + name: 'outOraclePriceTwap'; + type: 'i64'; + }, + { + name: 'inVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'outVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'inFundVaultAmountAfter'; + type: 'u64'; + }, + { + name: 'outFundVaultAmountAfter'; + type: 'u64'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }; + }, + { + name: 'lpAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'addLiquidity'; + }, + { + name: 'removeLiquidity'; + }, + { + name: 'settleLiquidity'; + }, + { + name: 'removeLiquidityDerisk'; + }, + ]; + }; + }, + { + name: 'lpBorrowLendDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'direction'; + type: { + defined: { + name: 'depositDirection'; + }; + }; + }, + { + name: 'tokenBalance'; + type: 'i64'; + }, + { + name: 'lastTokenBalance'; + type: 'i64'; + }, + { + name: 'interestAccruedTokenAmount'; + type: 'i64'; + }, + { + name: 'amountDepositWithdraw'; + type: 'u64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpMintRedeemRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'description'; + type: 'u8'; + }, + { + name: 'amount'; + docs: ['precision: continutent mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'fee'; + docs: [ + 'precision: fee on amount, constituent market mint precision', + ]; + type: 'i128'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'mint'; + docs: ['token mint']; + type: 'pubkey'; + }, + { + name: 'lpAmount'; + docs: ['lp amount, lp mint precision']; + type: 'u64'; + }, + { + name: 'lpFee'; + docs: ['lp fee, lp mint precision']; + type: 'i64'; + }, + { + name: 'lpPrice'; + docs: ['the fair price of the lp token, PRICE_PRECISION']; + type: 'u128'; + }, + { + name: 'mintRedeemId'; + type: 'u64'; + }, + { + name: 'lastAum'; + docs: ['LPPool last_aum']; + type: 'u128'; + }, + { + name: 'lastAumSlot'; + type: 'u64'; + }, + { + name: 'inMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inMarketTargetWeight'; + type: 'i64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpPool'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: ['address of the vault.']; + type: 'pubkey'; + }, + { + name: 'mint'; + type: 'pubkey'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + { + name: 'constituentTargetBase'; + type: 'pubkey'; + }, + { + name: 'constituentCorrelations'; + type: 'pubkey'; + }, + { + name: 'maxAum'; + docs: [ + 'The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)', + 'which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)', + 'pub quote_constituent_index: u16,', + 'QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastAum'; + docs: ['QUOTE_PRECISION: AUM of the vault in USD, updated lazily']; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeQuoteSentToPerpMarkets'; + docs: ['QUOTE PRECISION: Cumulative quotes from settles']; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeQuoteReceivedFromPerpMarkets'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalMintRedeemFeesPaid'; + docs: [ + 'QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'lastAumSlot'; + docs: ['timestamp of last AUM slot']; + type: 'u64'; + }, + { + name: 'maxSettleQuoteAmount'; + type: 'u64'; + }, + { + name: 'padding'; + docs: ['timestamp of last vAMM revenue rebalance']; + type: 'u64'; + }, + { + name: 'mintRedeemId'; + docs: [ + 'Every mint/redeem has a monotonically increasing id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'settleId'; + type: 'u64'; + }, + { + name: 'minMintFee'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'tokenSupply'; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'constituents'; + type: 'u16'; + }, + { + name: 'quoteConsituentIndex'; + type: 'u16'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'targetOracleDelayFeeBpsPer10Slots'; + type: 'u8'; + }, + { + name: 'targetPositionDelayFeeBpsPer10Slots'; + type: 'u8'; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 174]; + }; + }, + ]; + }; + }, + { + name: 'lpRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'action'; + type: { + defined: { + name: 'lpAction'; + }; + }; + }, + { + name: 'nShares'; + docs: ['precision: AMM_RESERVE_PRECISION']; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'deltaBaseAssetAmount'; + docs: ['precision: BASE_PRECISION']; + type: 'i64'; + }, + { + name: 'deltaQuoteAssetAmount'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'pnl'; + docs: [ + 'realized pnl of the position settlement', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'lpSettleRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'lastTs'; + type: 'i64'; + }, + { + name: 'lastSlot'; + type: 'u64'; + }, + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'settleToLpAmount'; + type: 'i64'; + }, + { + name: 'perpAmmPnlDelta'; + type: 'i64'; + }, + { + name: 'perpAmmExFeeDelta'; + type: 'i64'; + }, + { + name: 'lpAum'; + type: 'u128'; + }, + { + name: 'lpPrice'; + type: 'u128'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpSwapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'outAmount'; + docs: ['precision: out market mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'inAmount'; + docs: ['precision: in market mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'outFee'; + docs: ['precision: fee on amount_out, in market mint precision']; + type: 'i128'; + }, + { + name: 'inFee'; + docs: ['precision: fee on amount_in, out market mint precision']; + type: 'i128'; + }, + { + name: 'outSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'inSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'outConstituentIndex'; + type: 'u16'; + }, + { + name: 'inConstituentIndex'; + type: 'u16'; + }, + { + name: 'outOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'inOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastAum'; + docs: ['LPPool last_aum, QUOTE_PRECISION']; + type: 'u128'; + }, + { + name: 'lastAumSlot'; + type: 'u64'; + }, + { + name: 'inMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'outMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inMarketTargetWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'outMarketTargetWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inSwapId'; + type: 'u64'; + }, + { + name: 'outSwapId'; + type: 'u64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'liquidateBorrowForPerpPnlRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marketOraclePrice'; + type: 'i64'; + }, + { + name: 'pnlTransfer'; + type: 'u128'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityPrice'; + type: 'i64'; + }, + { + name: 'liabilityTransfer'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'liquidatePerpPnlForDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marketOraclePrice'; + type: 'i64'; + }, + { + name: 'pnlTransfer'; + type: 'u128'; + }, + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'assetPrice'; + type: 'i64'; + }, + { + name: 'assetTransfer'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'liquidatePerpRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'oraclePrice'; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + type: 'i64'; + }, + { + name: 'quoteAssetAmount'; + type: 'i64'; + }, + { + name: 'lpShares'; + docs: ['precision: AMM_RESERVE_PRECISION']; + type: 'u64'; + }, + { + name: 'fillRecordId'; + type: 'u64'; + }, + { + name: 'userOrderId'; + type: 'u32'; + }, + { + name: 'liquidatorOrderId'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'ifFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'liquidateSpotRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'assetPrice'; + type: 'i64'; + }, + { + name: 'assetTransfer'; + type: 'u128'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityPrice'; + type: 'i64'; + }, + { + name: 'liabilityTransfer'; + docs: ['precision: token mint precision']; + type: 'u128'; + }, + { + name: 'ifFee'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'liquidationRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'liquidationType'; + type: { + defined: { + name: 'liquidationType'; + }; + }; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'liquidator'; + type: 'pubkey'; + }, + { + name: 'marginRequirement'; + type: 'u128'; + }, + { + name: 'totalCollateral'; + type: 'i128'; + }, + { + name: 'marginFreed'; + type: 'u64'; + }, + { + name: 'liquidationId'; + type: 'u16'; + }, + { + name: 'bankrupt'; + type: 'bool'; + }, + { + name: 'canceledOrderIds'; + type: { + vec: 'u32'; + }; + }, + { + name: 'liquidatePerp'; + type: { + defined: { + name: 'liquidatePerpRecord'; + }; + }; + }, + { + name: 'liquidateSpot'; + type: { + defined: { + name: 'liquidateSpotRecord'; + }; + }; + }, + { + name: 'liquidateBorrowForPerpPnl'; + type: { + defined: { + name: 'liquidateBorrowForPerpPnlRecord'; + }; + }; + }, + { + name: 'liquidatePerpPnlForDeposit'; + type: { + defined: { + name: 'liquidatePerpPnlForDepositRecord'; + }; + }; + }, + { + name: 'perpBankruptcy'; + type: { + defined: { + name: 'perpBankruptcyRecord'; + }; + }; + }, + { + name: 'spotBankruptcy'; + type: { + defined: { + name: 'spotBankruptcyRecord'; + }; + }; + }, + ]; + }; + }, + { + name: 'liquidationType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'liquidatePerp'; + }, + { + name: 'liquidateSpot'; + }, + { + name: 'liquidateBorrowForPerpPnl'; + }, + { + name: 'liquidatePerpPnlForDeposit'; + }, + { + name: 'perpBankruptcy'; + }, + { + name: 'spotBankruptcy'; + }, + ]; + }; + }, + { + name: 'lpPoolParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxSettleQuoteAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'volatility'; + type: { + option: 'u64'; + }; + }, + { + name: 'gammaExecution'; + type: { + option: 'u8'; + }; + }, + { + name: 'xi'; + type: { + option: 'u8'; + }; + }, + { + name: 'maxAum'; + type: { + option: 'u128'; + }; + }, + { + name: 'whitelistMint'; + type: { + option: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'marginMode'; + type: { + kind: 'enum'; + variants: [ + { + name: 'default'; + }, + { + name: 'highLeverage'; + }, + { + name: 'highLeverageMaintenance'; + }, + ]; + }; + }, + { + name: 'marketStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'initialized'; + }, + { + name: 'active'; + }, + { + name: 'fundingPaused'; + }, + { + name: 'ammPaused'; + }, + { + name: 'fillPaused'; + }, + { + name: 'withdrawPaused'; + }, + { + name: 'reduceOnly'; + }, + { + name: 'settlement'; + }, + { + name: 'delisted'; + }, + ]; + }; + }, + { + name: 'marketType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'spot'; + }, + { + name: 'perp'; + }, + ]; + }; + }, + { + name: 'modifyOrderParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'direction'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'baseAssetAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'price'; + type: { + option: 'u64'; + }; + }, + { + name: 'reduceOnly'; + type: { + option: 'bool'; + }; + }, + { + name: 'postOnly'; + type: { + option: { + defined: { + name: 'postOnlyParam'; + }; + }; + }; + }, + { + name: 'bitFlags'; + type: { + option: 'u8'; + }; + }, + { + name: 'maxTs'; + type: { + option: 'i64'; + }; + }, + { + name: 'triggerPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerCondition'; + type: { + option: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }; + }, + { + name: 'oraclePriceOffset'; + type: { + option: 'i32'; + }; + }, + { + name: 'auctionDuration'; + type: { + option: 'u8'; + }; + }, + { + name: 'auctionStartPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'auctionEndPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'policy'; + type: { + option: 'u8'; + }; + }, + ]; + }; + }, + { + name: 'newUserRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'referrer'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'openbookV2FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'openbookV2ProgramId'; + type: 'pubkey'; + }, + { + name: 'openbookV2Market'; + type: 'pubkey'; + }, + { + name: 'openbookV2MarketAuthority'; + type: 'pubkey'; + }, + { + name: 'openbookV2EventHeap'; + type: 'pubkey'; + }, + { + name: 'openbookV2Bids'; + type: 'pubkey'; + }, + { + name: 'openbookV2Asks'; + type: 'pubkey'; + }, + { + name: 'openbookV2BaseVault'; + type: 'pubkey'; + }, + { + name: 'openbookV2QuoteVault'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'oracleGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'priceDivergence'; + type: { + defined: { + name: 'priceDivergenceGuardRails'; + }; + }; + }, + { + name: 'validity'; + type: { + defined: { + name: 'validityGuardRails'; + }; + }; + }, + ]; + }; + }, + { + name: 'oracleSource'; + type: { + kind: 'enum'; + variants: [ + { + name: 'pyth'; + }, + { + name: 'switchboard'; + }, + { + name: 'quoteAsset'; + }, + { + name: 'pyth1K'; + }, + { + name: 'pyth1M'; + }, + { + name: 'pythStableCoin'; + }, + { + name: 'prelaunch'; + }, + { + name: 'pythPull'; + }, + { + name: 'pyth1KPull'; + }, + { + name: 'pyth1MPull'; + }, + { + name: 'pythStableCoinPull'; + }, + { + name: 'switchboardOnDemand'; + }, + { + name: 'pythLazer'; + }, + { + name: 'pythLazer1K'; + }, + { + name: 'pythLazer1M'; + }, + { + name: 'pythLazerStableCoin'; + }, + ]; + }; + }, + { + name: 'order'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'slot'; + docs: ['The slot the order was placed']; + type: 'u64'; + }, + { + name: 'price'; + docs: [ + 'The limit price for the order (can be 0 for market orders)', + "For orders with an auction, this price isn't used until the auction is complete", + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'baseAssetAmount'; + docs: [ + 'The size of the order', + 'precision for perps: BASE_PRECISION', + 'precision for spot: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'baseAssetAmountFilled'; + docs: [ + 'The amount of the order filled', + 'precision for perps: BASE_PRECISION', + 'precision for spot: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'quoteAssetAmountFilled'; + docs: [ + 'The amount of quote filled for the order', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'triggerPrice'; + docs: [ + 'At what price the order will be triggered. Only relevant for trigger orders', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'auctionStartPrice'; + docs: [ + 'The start price for the auction. Only relevant for market/oracle orders', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'auctionEndPrice'; + docs: [ + 'The end price for the auction. Only relevant for market/oracle orders', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxTs'; + docs: ['The time when the order will expire']; + type: 'i64'; + }, + { + name: 'oraclePriceOffset'; + docs: [ + 'If set, the order limit price is the oracle price + this offset', + 'precision: PRICE_PRECISION', + ]; + type: 'i32'; + }, + { + name: 'orderId'; + docs: [ + 'The id for the order. Each users has their own order id space', + ]; + type: 'u32'; + }, + { + name: 'marketIndex'; + docs: ['The perp/spot market index']; + type: 'u16'; + }, + { + name: 'status'; + docs: ['Whether the order is open or unused']; + type: { + defined: { + name: 'orderStatus'; + }; + }; + }, + { + name: 'orderType'; + docs: ['The type of order']; + type: { + defined: { + name: 'orderType'; + }; + }; + }, + { + name: 'marketType'; + docs: ['Whether market is spot or perp']; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'userOrderId'; + docs: [ + 'User generated order id. Can make it easier to place/cancel orders', + ]; + type: 'u8'; + }, + { + name: 'existingPositionDirection'; + docs: ['What the users position was when the order was placed']; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'direction'; + docs: [ + 'Whether the user is going long or short. LONG = bid, SHORT = ask', + ]; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'reduceOnly'; + docs: ['Whether the order is allowed to only reduce position size']; + type: 'bool'; + }, + { + name: 'postOnly'; + docs: ['Whether the order must be a maker']; + type: 'bool'; + }, + { + name: 'immediateOrCancel'; + docs: [ + 'Whether the order must be canceled the same slot it is placed', + ]; + type: 'bool'; + }, + { + name: 'triggerCondition'; + docs: [ + 'Whether the order is triggered above or below the trigger price. Only relevant for trigger orders', + ]; + type: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }, + { + name: 'auctionDuration'; + docs: ['How many slots the auction lasts']; + type: 'u8'; + }, + { + name: 'postedSlotTail'; + docs: [ + 'Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)', + ]; + type: 'u8'; + }, + { + name: 'bitFlags'; + docs: [ + 'Bitflags for further classification', + '0: is_signed_message', + ]; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 1]; + }; + }, + ]; + }; + }, + { + name: 'orderAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'place'; + }, + { + name: 'cancel'; + }, + { + name: 'fill'; + }, + { + name: 'trigger'; + }, + { + name: 'expire'; + }, + ]; + }; + }, + { + name: 'orderActionExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'insufficientFreeCollateral'; + }, + { + name: 'oraclePriceBreachedLimitPrice'; + }, + { + name: 'marketOrderFilledToLimitPrice'; + }, + { + name: 'orderExpired'; + }, + { + name: 'liquidation'; + }, + { + name: 'orderFilledWithAmm'; + }, + { + name: 'orderFilledWithAmmJit'; + }, + { + name: 'orderFilledWithMatch'; + }, + { + name: 'orderFilledWithMatchJit'; + }, + { + name: 'marketExpired'; + }, + { + name: 'riskingIncreasingOrder'; + }, + { + name: 'reduceOnlyOrderIncreasedPosition'; + }, + { + name: 'orderFillWithSerum'; + }, + { + name: 'noBorrowLiquidity'; + }, + { + name: 'orderFillWithPhoenix'; + }, + { + name: 'orderFilledWithAmmJitLpSplit'; + }, + { + name: 'orderFilledWithLpJit'; + }, + { + name: 'deriskLp'; + }, + { + name: 'orderFilledWithOpenbookV2'; + }, + { + name: 'transferPerpPosition'; + }, + ]; + }; + }, + { + name: 'orderActionRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'action'; + type: { + defined: { + name: 'orderAction'; + }; + }; + }, + { + name: 'actionExplanation'; + type: { + defined: { + name: 'orderActionExplanation'; + }; + }; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'filler'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'fillerReward'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'fillRecordId'; + type: { + option: 'u64'; + }; + }, + { + name: 'baseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'quoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'i64'; + }; + }, + { + name: 'referrerReward'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u32'; + }; + }, + { + name: 'quoteAssetAmountSurplus'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'i64'; + }; + }, + { + name: 'spotFulfillmentMethodFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'taker'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'takerOrderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'takerOrderDirection'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'takerOrderBaseAssetAmount'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerOrderCumulativeBaseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerOrderCumulativeQuoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'maker'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'makerOrderDirection'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'makerOrderBaseAssetAmount'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerOrderCumulativeBaseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerOrderCumulativeQuoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'bitFlags'; + docs: ['Bit flags:', '0: is_signed_message']; + type: 'u8'; + }, + { + name: 'takerExistingQuoteEntryAmount'; + docs: [ + 'precision: QUOTE_PRECISION', + 'Only Some if the taker reduced position', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'takerExistingBaseAssetAmount'; + docs: [ + 'precision: BASE_PRECISION', + 'Only Some if the taker flipped position direction', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'makerExistingQuoteEntryAmount'; + docs: [ + 'precision: QUOTE_PRECISION', + 'Only Some if the maker reduced position', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'makerExistingBaseAssetAmount'; + docs: [ + 'precision: BASE_PRECISION', + 'Only Some if the maker flipped position direction', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerPrice'; + docs: ['precision: PRICE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'builderIdx'; + docs: [ + "the idx of the builder in the taker's [`RevenueShareEscrow`] account", + ]; + type: { + option: 'u8'; + }; + }, + { + name: 'builderFee'; + docs: ['precision: QUOTE_PRECISION builder fee paid by the taker']; + type: { + option: 'u64'; + }; + }, + ]; + }; + }, + { + name: 'orderFillerRewardStructure'; + type: { + kind: 'struct'; + fields: [ + { + name: 'rewardNumerator'; + type: 'u32'; + }, + { + name: 'rewardDenominator'; + type: 'u32'; + }, + { + name: 'timeBasedRewardLowerBound'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + ]; + }; + }, + { + name: 'orderParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'orderType'; + type: { + defined: { + name: 'orderType'; + }; + }; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'direction'; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'userOrderId'; + type: 'u8'; + }, + { + name: 'baseAssetAmount'; + type: 'u64'; + }, + { + name: 'price'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'postOnly'; + type: { + defined: { + name: 'postOnlyParam'; + }; + }; + }, + { + name: 'bitFlags'; + type: 'u8'; + }, + { + name: 'maxTs'; + type: { + option: 'i64'; + }; + }, + { + name: 'triggerPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerCondition'; + type: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }, + { + name: 'oraclePriceOffset'; + type: { + option: 'i32'; + }; + }, + { + name: 'auctionDuration'; + type: { + option: 'u8'; + }; + }, + { + name: 'auctionStartPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'auctionEndPrice'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'orderRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'order'; + type: { + defined: { + name: 'order'; + }; + }; + }, + ]; + }; + }, + { + name: 'orderStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'init'; + }, + { + name: 'open'; + }, + { + name: 'filled'; + }, + { + name: 'canceled'; + }, + ]; + }; + }, + { + name: 'orderTriggerCondition'; + type: { + kind: 'enum'; + variants: [ + { + name: 'above'; + }, + { + name: 'below'; + }, + { + name: 'triggeredAbove'; + }, + { + name: 'triggeredBelow'; + }, + ]; + }; + }, + { + name: 'orderType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'market'; + }, + { + name: 'limit'; + }, + { + name: 'triggerMarket'; + }, + { + name: 'triggerLimit'; + }, + { + name: 'oracle'; + }, + ]; + }; + }, + { + name: 'overrideAmmCacheParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'quoteOwedFromLpPool'; + type: { + option: 'i64'; + }; + }, + { + name: 'lastSettleSlot'; + type: { + option: 'u64'; + }; + }, + { + name: 'lastFeePoolTokenAmount'; + type: { + option: 'u128'; + }; + }, + { + name: 'lastNetPnlPoolTokenAmount'; + type: { + option: 'i128'; + }; + }, + { + name: 'ammPositionScalar'; + type: { + option: 'u8'; + }; + }, + { + name: 'ammInventoryLimit'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'perpBankruptcyRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'pnl'; + type: 'i128'; + }, + { + name: 'ifPayment'; + type: 'u128'; + }, + { + name: 'clawbackUser'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'clawbackUserPayment'; + type: { + option: 'u128'; + }; + }, + { + name: 'cumulativeFundingRateDelta'; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: [ + "The perp market's address. It is a pda of the market index", + ]; + type: 'pubkey'; + }, + { + name: 'amm'; + docs: ['The automated market maker']; + type: { + defined: { + name: 'amm'; + }; + }; + }, + { + name: 'pnlPool'; + docs: [ + "The market's pnl pool. When users settle negative pnl, the balance increases.", + 'When users settle positive pnl, the balance decreases. Can not go negative.', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'name'; + docs: ['Encoded display name for the perp market e.g. SOL-PERP']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'insuranceClaim'; + docs: ["The perp market's claim on the insurance fund"]; + type: { + defined: { + name: 'insuranceClaim'; + }; + }; + }, + { + name: 'unrealizedPnlMaxImbalance'; + docs: [ + 'The max pnl imbalance before positive pnl asset weight is discounted', + "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", + 'the amm has negative pnl and the initial asset weight for positive pnl is discounted', + 'precision = QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'expiryTs'; + docs: [ + 'The ts when the market will be expired. Only set if market is in reduce only mode', + ]; + type: 'i64'; + }, + { + name: 'expiryPrice'; + docs: [ + 'The price at which positions will be settled. Only set if market is expired', + 'precision = PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'nextFillRecordId'; + docs: [ + 'Every trade has a fill record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'nextFundingRateRecordId'; + docs: [ + 'Every funding rate update has a record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'nextCurveRecordId'; + docs: [ + 'Every amm k updated has a record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'imfFactor'; + docs: [ + 'The initial margin fraction factor. Used to increase margin ratio for large positions', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlImfFactor'; + docs: [ + 'The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: [ + 'The fee the liquidator is paid for taking over perp position', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + docs: [ + 'The fee the insurance fund receives from liquidation', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'marginRatioInitial'; + docs: [ + 'The margin ratio which determines how much collateral is required to open a position', + 'e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + docs: [ + 'The margin ratio which determines when a user will be liquidated', + 'e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position', + 'else they will be liquidated', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlInitialAssetWeight'; + docs: [ + 'The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlMaintenanceAssetWeight'; + docs: [ + 'The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'numberOfUsersWithBase'; + docs: ['number of users in a position (base)']; + type: 'u32'; + }, + { + name: 'numberOfUsers'; + docs: ['number of users in a position (pnl) or pnl (quote)']; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'status'; + docs: [ + 'Whether a market is active, reduce only, expired, etc', + 'Affects whether users can open/close positions', + ]; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + { + name: 'contractType'; + docs: ['Currently only Perpetual markets are supported']; + type: { + defined: { + name: 'contractType'; + }; + }; + }, + { + name: 'contractTier'; + docs: [ + 'The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance', + 'It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first', + ]; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'quoteSpotMarketIndex'; + docs: ['The spot market that pnl is settled in']; + type: 'u16'; + }, + { + name: 'feeAdjustment'; + docs: [ + 'Between -100 and 100, represents what % to increase/decrease the fee by', + 'E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps', + 'if this is 50 and the fee is 5bps, the new fee will be 7.5bps', + ]; + type: 'i16'; + }, + { + name: 'fuelBoostPosition'; + docs: ['fuel multiplier for perp funding', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostTaker'; + docs: ['fuel multiplier for perp taker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostMaker'; + docs: ['fuel multiplier for perp maker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'highLeverageMarginRatioInitial'; + type: 'u16'; + }, + { + name: 'highLeverageMarginRatioMaintenance'; + type: 'u16'; + }, + { + name: 'protectedMakerLimitPriceDivisor'; + type: 'u8'; + }, + { + name: 'protectedMakerDynamicDivisor'; + type: 'u8'; + }, + { + name: 'lpFeeTransferScalar'; + type: 'u8'; + }, + { + name: 'lpStatus'; + type: 'u8'; + }, + { + name: 'lpPausedOperations'; + type: 'u8'; + }, + { + name: 'lpExchangeFeeExcluscionScalar'; + type: 'u8'; + }, + { + name: 'lastFillPrice'; + type: 'u64'; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 23]; + }; + }, + ]; + }; + }, + { + name: 'perpPosition'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastCumulativeFundingRate'; + docs: [ + "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + docs: [ + 'the size of the users perp position', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteAssetAmount'; + docs: [ + 'Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees', + 'Updated when the user open/closes position or settles pnl. Includes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteBreakEvenAmount'; + docs: [ + 'The amount of quote the user would need to exit their position at to break even', + 'Updated when the user open/closes position or settles pnl. Includes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteEntryAmount'; + docs: [ + 'The amount quote the user entered the position with. Equal to base asset amount * avg entry price', + 'Updated when the user open/closes position. Excludes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'openBids'; + docs: [ + 'The amount of non reduce only trigger orders the user has open', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'openAsks'; + docs: [ + 'The amount of non reduce only trigger orders the user has open', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'settledPnl'; + docs: [ + 'The amount of pnl settled in this market since opening the position', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lpShares'; + docs: [ + 'The number of lp (liquidity provider) shares the user has in this perp market', + 'LP shares allow users to provide liquidity via the AMM', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastBaseAssetAmountPerLp'; + docs: [ + 'The last base asset amount per lp the amm had', + 'Used to settle the users lp position', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastQuoteAssetAmountPerLp'; + docs: [ + 'The last quote asset amount per lp the amm had', + 'Used to settle the users lp position', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'padding'; + type: { + array: ['u8', 2]; + }; + }, + { + name: 'maxMarginRatio'; + type: 'u16'; + }, + { + name: 'marketIndex'; + docs: ['The market index for the perp market']; + type: 'u16'; + }, + { + name: 'openOrders'; + docs: ['The number of open orders']; + type: 'u8'; + }, + { + name: 'perLpBase'; + type: 'i8'; + }, + ]; + }; + }, + { + name: 'phoenixV1FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'phoenixProgramId'; + type: 'pubkey'; + }, + { + name: 'phoenixLogAuthority'; + type: 'pubkey'; + }, + { + name: 'phoenixMarket'; + type: 'pubkey'; + }, + { + name: 'phoenixBaseVault'; + type: 'pubkey'; + }, + { + name: 'phoenixQuoteVault'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'poolBalance'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", + 'deposit interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'marketIndex'; + docs: ['The spot market the pool is for']; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 6]; + }; + }, + ]; + }; + }, + { + name: 'positionDirection'; + type: { + kind: 'enum'; + variants: [ + { + name: 'long'; + }, + { + name: 'short'; + }, + ]; + }; + }, + { + name: 'postOnlyParam'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'mustPostOnly'; + }, + { + name: 'tryPostOnly'; + }, + { + name: 'slide'; + }, + ]; + }; + }, + { + name: 'prelaunchOracle'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'price'; + type: 'i64'; + }, + { + name: 'maxPrice'; + type: 'i64'; + }, + { + name: 'confidence'; + type: 'u64'; + }, + { + name: 'lastUpdateSlot'; + type: 'u64'; + }, + { + name: 'ammLastUpdateSlot'; + type: 'u64'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 70]; + }; + }, + ]; + }; + }, + { + name: 'prelaunchOracleParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'price'; + type: { + option: 'i64'; + }; + }, + { + name: 'maxPrice'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'priceDivergenceGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'markOraclePercentDivergence'; + type: 'u64'; + }, + { + name: 'oracleTwap5minPercentDivergence'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'protectedMakerModeConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'currentUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 31]; + }; + }, + ]; + }; + }, + { + name: 'pythLazerOracle'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'price'; + type: 'i64'; + }, + { + name: 'publishTime'; + type: 'u64'; + }, + { + name: 'postedSlot'; + type: 'u64'; + }, + { + name: 'exponent'; + type: 'i32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'conf'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'referrerName'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'userStats'; + type: 'pubkey'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }; + }, + { + name: 'revenueShare'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'rust'; + packed: true; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['the owner of this account, a builder or referrer']; + type: 'pubkey'; + }, + { + name: 'totalReferrerRewards'; + type: 'u64'; + }, + { + name: 'totalBuilderRewards'; + type: 'u64'; + }, + { + name: 'padding'; + type: { + array: ['u8', 18]; + }; + }, + ]; + }; + }, + { + name: 'revenueShareEscrow'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['the owner of this account, a user']; + type: 'pubkey'; + }, + { + name: 'referrer'; + type: 'pubkey'; + }, + { + name: 'referrerBoostExpireTs'; + type: 'u32'; + }, + { + name: 'referrerRewardOffset'; + type: 'i8'; + }, + { + name: 'refereeFeeNumeratorOffset'; + type: 'i8'; + }, + { + name: 'referrerBoostNumerator'; + type: 'i8'; + }, + { + name: 'reservedFixed'; + type: { + array: ['u8', 17]; + }; + }, + { + name: 'padding0'; + type: 'u32'; + }, + { + name: 'orders'; + type: { + vec: { + defined: { + name: 'revenueShareOrder'; + }; + }; + }; + }, + { + name: 'padding1'; + type: 'u32'; + }, + { + name: 'approvedBuilders'; + type: { + vec: { + defined: { + name: 'builderInfo'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'revenueShareOrder'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'feesAccrued'; + docs: [ + 'fees accrued so far for this order slot. This is not exclusively fees from this order_id', + 'and may include fees from other orders in the same market. This may be swept to the', + "builder's SpotPosition during settle_pnl.", + ]; + type: 'u64'; + }, + { + name: 'orderId'; + docs: [ + "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open", + ]; + type: 'u32'; + }, + { + name: 'feeTenthBps'; + docs: [ + 'the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%', + ]; + type: 'u16'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'subAccountId'; + docs: [ + "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open", + ]; + type: 'u16'; + }, + { + name: 'builderIdx'; + docs: [ + "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", + 'if bit_flag = Referral.', + ]; + type: 'u8'; + }, + { + name: 'bitFlags'; + docs: [ + 'bitflags that describe the state of the order.', + '[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.', + "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", + '[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.', + "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", + '[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.', + 'If it is set, no other bitflag should be set.', + ]; + type: 'u8'; + }, + { + name: 'userOrderIndex'; + docs: [ + "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches.", + ]; + type: 'u8'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 10]; + }; + }, + ]; + }; + }, + { + name: 'revenueShareSettleRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'builder'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'referrer'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'feeSettled'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'builderSubAccountId'; + type: 'u16'; + }, + { + name: 'builderTotalReferrerRewards'; + type: 'u64'; + }, + { + name: 'builderTotalBuilderRewards'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'serumV3FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'serumProgramId'; + type: 'pubkey'; + }, + { + name: 'serumMarket'; + type: 'pubkey'; + }, + { + name: 'serumRequestQueue'; + type: 'pubkey'; + }, + { + name: 'serumEventQueue'; + type: 'pubkey'; + }, + { + name: 'serumBids'; + type: 'pubkey'; + }, + { + name: 'serumAsks'; + type: 'pubkey'; + }, + { + name: 'serumBaseVault'; + type: 'pubkey'; + }, + { + name: 'serumQuoteVault'; + type: 'pubkey'; + }, + { + name: 'serumOpenOrders'; + type: 'pubkey'; + }, + { + name: 'serumSignerNonce'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'settlePnlExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'expiredPosition'; + }, + ]; + }; + }, + { + name: 'settlePnlMode'; + type: { + kind: 'enum'; + variants: [ + { + name: 'mustSettle'; + }, + { + name: 'trySettle'; + }, + ]; + }; + }, + { + name: 'settlePnlRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'pnl'; + type: 'i128'; + }, + { + name: 'baseAssetAmount'; + type: 'i64'; + }, + { + name: 'quoteAssetAmountAfter'; + type: 'i64'; + }, + { + name: 'quoteEntryAmount'; + type: 'i64'; + }, + { + name: 'settlePrice'; + type: 'i64'; + }, + { + name: 'explanation'; + type: { + defined: { + name: 'settlePnlExplanation'; + }; + }; + }, + ]; + }; + }, + { + name: 'signedMsgOrderId'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'uuid'; + type: { + array: ['u8', 8]; + }; + }, + { + name: 'maxSlot'; + type: 'u64'; + }, + { + name: 'orderId'; + type: 'u32'; + }, + { + name: 'padding'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'signedMsgOrderRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'hash'; + type: 'string'; + }, + { + name: 'matchingOrderParams'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'userOrderId'; + type: 'u32'; + }, + { + name: 'signedMsgOrderMaxSlot'; + type: 'u64'; + }, + { + name: 'signedMsgOrderUuid'; + type: { + array: ['u8', 8]; + }; + }, + { + name: 'ts'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'signedMsgUserOrders'; + docs: [ + '* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently', + ]; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authorityPubkey'; + type: 'pubkey'; + }, + { + name: 'padding'; + type: 'u32'; + }, + { + name: 'signedMsgOrderData'; + type: { + vec: { + defined: { + name: 'signedMsgOrderId'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'signedMsgWsDelegates'; + docs: [ + '* Used to store authenticated delegates for swift-like ws connections', + ]; + type: { + kind: 'struct'; + fields: [ + { + name: 'delegates'; + type: { + vec: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'spotBalanceType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'deposit'; + }, + { + name: 'borrow'; + }, + ]; + }; + }, + { + name: 'spotBankruptcyRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'borrowAmount'; + type: 'u128'; + }, + { + name: 'ifPayment'; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestDelta'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'spotFulfillmentConfigStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'enabled'; + }, + { + name: 'disabled'; + }, + ]; + }; + }, + { + name: 'spotFulfillmentType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'serumV3'; + }, + { + name: 'match'; + }, + { + name: 'phoenixV1'; + }, + { + name: 'openbookV2'; + }, + ]; + }; + }, + { + name: 'spotInterestRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'depositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'borrowBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeBorrowInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'optimalUtilization'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'spotMarket'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: [ + 'The address of the spot market. It is a pda of the market index', + ]; + type: 'pubkey'; + }, + { + name: 'oracle'; + docs: ['The oracle used to price the markets deposits/borrows']; + type: 'pubkey'; + }, + { + name: 'mint'; + docs: ['The token mint of the market']; + type: 'pubkey'; + }, + { + name: 'vault'; + docs: [ + "The vault used to store the market's deposits", + 'The amount in the vault should be equal to or greater than deposits - borrows', + ]; + type: 'pubkey'; + }, + { + name: 'name'; + docs: ['The encoded display name for the market e.g. SOL']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'historicalOracleData'; + type: { + defined: { + name: 'historicalOracleData'; + }; + }; + }, + { + name: 'historicalIndexData'; + type: { + defined: { + name: 'historicalIndexData'; + }; + }; + }, + { + name: 'revenuePool'; + docs: [ + 'Revenue the protocol has collected in this markets token', + 'e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'spotFeePool'; + docs: [ + 'The fees collected from swaps between this market and the quote market', + 'Is settled to the quote markets revenue pool', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'insuranceFund'; + docs: [ + 'Details on the insurance fund covering bankruptcies in this markets token', + 'Covers bankruptcies for borrows with this markets token and perps settling in this markets token', + ]; + type: { + defined: { + name: 'insuranceFund'; + }; + }; + }, + { + name: 'totalSpotFee'; + docs: [ + 'The total spot fees collected for this market', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'depositBalance'; + docs: [ + 'The sum of the scaled balances for deposits across users and pool balances', + 'To convert to the deposit token amount, multiply by the cumulative deposit interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'borrowBalance'; + docs: [ + 'The sum of the scaled balances for borrows across users and pool balances', + 'To convert to the borrow token amount, multiply by the cumulative borrow interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeDepositInterest'; + docs: [ + 'The cumulative interest earned by depositors', + 'Used to calculate the deposit token amount from the deposit balance', + 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeBorrowInterest'; + docs: [ + 'The cumulative interest earned by borrowers', + 'Used to calculate the borrow token amount from the borrow balance', + 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalSocialLoss'; + docs: [ + "The total socialized loss from borrows, in the mint's token", + 'precision: token mint precision', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalQuoteSocialLoss'; + docs: [ + "The total socialized loss from borrows, in the quote market's token", + 'preicision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'withdrawGuardThreshold'; + docs: [ + 'no withdraw limits/guards when deposits below this threshold', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'maxTokenDeposits'; + docs: [ + 'The max amount of token deposits in this market', + '0 if there is no limit', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'depositTokenTwap'; + docs: [ + '24hr average of deposit token amount', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'borrowTokenTwap'; + docs: [ + '24hr average of borrow token amount', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'utilizationTwap'; + docs: [ + '24hr average of utilization', + 'which is borrow amount over token amount', + 'precision: SPOT_UTILIZATION_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastInterestTs'; + docs: [ + 'Last time the cumulative deposit and borrow interest was updated', + ]; + type: 'u64'; + }, + { + name: 'lastTwapTs'; + docs: [ + 'Last time the deposit/borrow/utilization averages were updated', + ]; + type: 'u64'; + }, + { + name: 'expiryTs'; + docs: [ + 'The time the market is set to expire. Only set if market is in reduce only mode', + ]; + type: 'i64'; + }, + { + name: 'orderStepSize'; + docs: [ + 'Spot orders must be a multiple of the step size', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'orderTickSize'; + docs: [ + 'Spot orders must be a multiple of the tick size', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minOrderSize'; + docs: ['The minimum order size', 'precision: token mint precision']; + type: 'u64'; + }, + { + name: 'maxPositionSize'; + docs: [ + 'The maximum spot position size', + 'if the limit is 0, there is no limit', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'nextFillRecordId'; + docs: [ + 'Every spot trade has a fill record id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'nextDepositRecordId'; + docs: [ + 'Every deposit has a deposit record id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'initialAssetWeight'; + docs: [ + 'The initial asset weight used to calculate a deposits contribution to a users initial total collateral', + 'e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + docs: [ + 'The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral', + 'e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + docs: [ + 'The initial liability weight used to calculate a borrows contribution to a users initial margin requirement', + 'e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + docs: [ + 'The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement', + 'e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'imfFactor'; + docs: [ + 'The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: [ + 'The fee the liquidator is paid for taking over borrow/deposit', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + docs: [ + 'The fee the insurance fund receives from liquidation', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'optimalUtilization'; + docs: [ + 'The optimal utilization rate for this market.', + 'Used to determine the markets borrow rate', + 'precision: SPOT_UTILIZATION_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + docs: [ + 'The borrow rate for this market when the market has optimal utilization', + 'precision: SPOT_RATE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + docs: [ + 'The borrow rate for this market when the market has 1000 utilization', + 'precision: SPOT_RATE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'decimals'; + docs: [ + "The market's token mint's decimals. To from decimals to a precision, 10^decimals", + ]; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'ordersEnabled'; + docs: ['Whether or not spot trading is enabled']; + type: 'bool'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + { + name: 'assetTier'; + docs: [ + 'The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated', + ]; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'ifPausedOperations'; + type: 'u8'; + }, + { + name: 'feeAdjustment'; + type: 'i16'; + }, + { + name: 'maxTokenBorrowsFraction'; + docs: [ + 'What fraction of max_token_deposits', + 'disabled when 0, 1 => 1/10000 => .01% of max_token_deposits', + 'precision: X/10000', + ]; + type: 'u16'; + }, + { + name: 'flashLoanAmount'; + docs: [ + 'For swaps, the amount of token loaned out in the begin_swap ix', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'flashLoanInitialTokenAmount'; + docs: [ + 'For swaps, the amount in the users token account in the begin_swap ix', + 'Used to calculate how much of the token left the system in end_swap ix', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'totalSwapFee'; + docs: [ + 'The total fees received from swaps', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'scaleInitialAssetWeightStart'; + docs: [ + 'When to begin scaling down the initial asset weight', + 'disabled when 0', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minBorrowRate'; + docs: [ + 'The min borrow rate for this market when the market regardless of utilization', + '1 => 1/200 => .5%', + 'precision: X/200', + ]; + type: 'u8'; + }, + { + name: 'fuelBoostDeposits'; + docs: ['fuel multiplier for spot deposits', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostBorrows'; + docs: ['fuel multiplier for spot borrows', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostTaker'; + docs: ['fuel multiplier for spot taker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostMaker'; + docs: ['fuel multiplier for spot maker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostInsurance'; + docs: ['fuel multiplier for spot insurance stake', 'precision: 10']; + type: 'u8'; + }, + { + name: 'tokenProgramFlag'; + type: 'u8'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 40]; + }; + }, + ]; + }; + }, + { + name: 'spotMarketVaultDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'depositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestBefore'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestAfter'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'depositTokenAmountBefore'; + type: 'u64'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'spotPosition'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', + 'interest of corresponding market.', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'openBids'; + docs: [ + 'How many spot non reduce only trigger orders the user has open', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'openAsks'; + docs: [ + 'How many spot non reduce only trigger orders the user has open', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'cumulativeDeposits'; + docs: [ + 'The cumulative deposits/borrows a user has made into a market', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'marketIndex'; + docs: ['The market index of the corresponding spot market']; + type: 'u16'; + }, + { + name: 'balanceType'; + docs: ['Whether the position is deposit or borrow']; + type: { + defined: { + name: 'spotBalanceType'; + }; + }; + }, + { + name: 'openOrders'; + docs: ['Number of open orders']; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'stakeAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'stake'; + }, + { + name: 'unstakeRequest'; + }, + { + name: 'unstakeCancelRequest'; + }, + { + name: 'unstake'; + }, + { + name: 'unstakeTransfer'; + }, + { + name: 'stakeTransfer'; + }, + { + name: 'adminDeposit'; + }, + ]; + }; + }, + { + name: 'state'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'admin'; + type: 'pubkey'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + { + name: 'discountMint'; + type: 'pubkey'; + }, + { + name: 'signer'; + type: 'pubkey'; + }, + { + name: 'srmVault'; + type: 'pubkey'; + }, + { + name: 'perpFeeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + { + name: 'spotFeeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + { + name: 'oracleGuardRails'; + type: { + defined: { + name: 'oracleGuardRails'; + }; + }; + }, + { + name: 'numberOfAuthorities'; + type: 'u64'; + }, + { + name: 'numberOfSubAccounts'; + type: 'u64'; + }, + { + name: 'lpCooldownTime'; + type: 'u64'; + }, + { + name: 'liquidationMarginBufferRatio'; + type: 'u32'; + }, + { + name: 'settlementDuration'; + type: 'u16'; + }, + { + name: 'numberOfMarkets'; + type: 'u16'; + }, + { + name: 'numberOfSpotMarkets'; + type: 'u16'; + }, + { + name: 'signerNonce'; + type: 'u8'; + }, + { + name: 'minPerpAuctionDuration'; + type: 'u8'; + }, + { + name: 'defaultMarketOrderTimeInForce'; + type: 'u8'; + }, + { + name: 'defaultSpotAuctionDuration'; + type: 'u8'; + }, + { + name: 'exchangeStatus'; + type: 'u8'; + }, + { + name: 'liquidationDuration'; + type: 'u8'; + }, + { + name: 'initialPctToLiquidate'; + type: 'u16'; + }, + { + name: 'maxNumberOfSubAccounts'; + type: 'u16'; + }, + { + name: 'maxInitializeUserFee'; + type: 'u16'; + }, + { + name: 'featureBitFlags'; + type: 'u8'; + }, + { + name: 'lpPoolFeatureBitFlags'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 8]; + }; + }, + ]; + }; + }, + { + name: 'swapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'amountOut'; + docs: ['precision: out market mint precision']; + type: 'u64'; + }, + { + name: 'amountIn'; + docs: ['precision: in market mint precision']; + type: 'u64'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'inOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'fee'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'swapReduceOnly'; + type: { + kind: 'enum'; + variants: [ + { + name: 'in'; + }, + { + name: 'out'; + }, + ]; + }; + }, + { + name: 'targetsDatum'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'costToTradeBps'; + type: 'i32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'targetBase'; + type: 'i64'; + }, + { + name: 'lastOracleSlot'; + type: 'u64'; + }, + { + name: 'lastPositionSlot'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'transferProtocolIfSharesToRevenuePoolRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'shares'; + type: 'u128'; + }, + { + name: 'ifVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'protocolSharesBefore'; + type: 'u128'; + }, + { + name: 'transferAmount'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'updatePerpMarketSummaryStatsParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'quoteAssetAmountWithUnsettledLp'; + type: { + option: 'i64'; + }; + }, + { + name: 'netUnsettledFundingPnl'; + type: { + option: 'i64'; + }; + }, + { + name: 'updateAmmSummaryStats'; + type: { + option: 'bool'; + }; + }, + { + name: 'excludeTotalLiqFee'; + type: { + option: 'bool'; + }; + }, + ]; + }; + }, + { + name: 'user'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The owner/authority of the account']; + type: 'pubkey'; + }, + { + name: 'delegate'; + docs: [ + "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw", + ]; + type: 'pubkey'; + }, + { + name: 'name'; + docs: ['Encoded display name e.g. "toly"']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'spotPositions'; + docs: ["The user's spot positions"]; + type: { + array: [ + { + defined: { + name: 'spotPosition'; + }; + }, + 8, + ]; + }; + }, + { + name: 'perpPositions'; + docs: ["The user's perp positions"]; + type: { + array: [ + { + defined: { + name: 'perpPosition'; + }; + }, + 8, + ]; + }; + }, + { + name: 'orders'; + docs: ["The user's orders"]; + type: { + array: [ + { + defined: { + name: 'order'; + }; + }, + 32, + ]; + }; + }, + { + name: 'lastAddPerpLpSharesTs'; + docs: ['The last time the user added perp lp positions']; + type: 'i64'; + }, + { + name: 'totalDeposits'; + docs: [ + 'The total values of deposits the user has made', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalWithdraws'; + docs: [ + 'The total values of withdrawals the user has made', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalSocialLoss'; + docs: [ + 'The total socialized loss the users has incurred upon the protocol', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'settledPerpPnl'; + docs: [ + 'Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'cumulativeSpotFees'; + docs: [ + 'Fees (taker fees, maker rebate, filler reward) for spot', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'cumulativePerpFunding'; + docs: [ + 'Cumulative funding paid/received for perps', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'liquidationMarginFreed'; + docs: [ + 'The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time', + 'Defaults to zero when not being liquidated', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastActiveSlot'; + docs: [ + 'The last slot a user was active. Used to determine if a user is idle', + ]; + type: 'u64'; + }, + { + name: 'nextOrderId'; + docs: [ + 'Every user order has an order id. This is the next order id to be used', + ]; + type: 'u32'; + }, + { + name: 'maxMarginRatio'; + docs: ['Custom max initial margin ratio for the user']; + type: 'u32'; + }, + { + name: 'nextLiquidationId'; + docs: ['The next liquidation id to be used for user']; + type: 'u16'; + }, + { + name: 'subAccountId'; + docs: ['The sub account id for this user']; + type: 'u16'; + }, + { + name: 'status'; + docs: ['Whether the user is active, being liquidated or bankrupt']; + type: 'u8'; + }, + { + name: 'isMarginTradingEnabled'; + docs: ['Whether the user has enabled margin trading']; + type: 'bool'; + }, + { + name: 'idle'; + docs: [ + "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", + 'Off-chain keeper bots can ignore users that are idle', + ]; + type: 'bool'; + }, + { + name: 'openOrders'; + docs: ['number of open orders']; + type: 'u8'; + }, + { + name: 'hasOpenOrder'; + docs: ['Whether or not user has open order']; + type: 'bool'; + }, + { + name: 'openAuctions'; + docs: ['number of open orders with auction']; + type: 'u8'; + }, + { + name: 'hasOpenAuction'; + docs: ['Whether or not user has open order with auction']; + type: 'bool'; + }, + { + name: 'marginMode'; + type: { + defined: { + name: 'marginMode'; + }; + }; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'padding1'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'lastFuelBonusUpdateTs'; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 12]; + }; + }, + ]; + }; + }, + { + name: 'userFees'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'totalFeePaid'; + docs: ['Total taker fee paid', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalFeeRebate'; + docs: ['Total maker fee rebate', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalTokenDiscount'; + docs: [ + 'Total discount from holding token', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalRefereeDiscount'; + docs: [ + 'Total discount from being referred', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalReferrerReward'; + docs: ['Total reward to referrer', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'currentEpochReferrerReward'; + docs: [ + 'Total reward to referrer this epoch', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'userStats'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The authority for all of a users sub accounts']; + type: 'pubkey'; + }, + { + name: 'referrer'; + docs: ['The address that referred this user']; + type: 'pubkey'; + }, + { + name: 'fees'; + docs: ['Stats on the fees paid by the user']; + type: { + defined: { + name: 'userFees'; + }; + }; + }, + { + name: 'nextEpochTs'; + docs: [ + 'The timestamp of the next epoch', + 'Epoch is used to limit referrer rewards earned in single epoch', + ]; + type: 'i64'; + }, + { + name: 'makerVolume30d'; + docs: [ + 'Rolling 30day maker volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'takerVolume30d'; + docs: [ + 'Rolling 30day taker volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'fillerVolume30d'; + docs: [ + 'Rolling 30day filler volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMakerVolume30dTs'; + docs: ['last time the maker volume was updated']; + type: 'i64'; + }, + { + name: 'lastTakerVolume30dTs'; + docs: ['last time the taker volume was updated']; + type: 'i64'; + }, + { + name: 'lastFillerVolume30dTs'; + docs: ['last time the filler volume was updated']; + type: 'i64'; + }, + { + name: 'ifStakedQuoteAssetAmount'; + docs: ['The amount of tokens staked in the quote spot markets if']; + type: 'u64'; + }, + { + name: 'numberOfSubAccounts'; + docs: ['The current number of sub accounts']; + type: 'u16'; + }, + { + name: 'numberOfSubAccountsCreated'; + docs: [ + 'The number of sub accounts created. Can be greater than the number of sub accounts if user', + 'has deleted sub accounts', + ]; + type: 'u16'; + }, + { + name: 'referrerStatus'; + docs: [ + 'Flags for referrer status:', + 'First bit (LSB): 1 if user is a referrer, 0 otherwise', + 'Second bit: 1 if user was referred, 0 otherwise', + ]; + type: 'u8'; + }, + { + name: 'disableUpdatePerpBidAskTwap'; + type: 'u8'; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'fuelOverflowStatus'; + docs: ['whether the user has a FuelOverflow account']; + type: 'u8'; + }, + { + name: 'fuelInsurance'; + docs: ['accumulated fuel for token amounts of insurance']; + type: 'u32'; + }, + { + name: 'fuelDeposits'; + docs: ['accumulated fuel for notional of deposits']; + type: 'u32'; + }, + { + name: 'fuelBorrows'; + docs: ['accumulate fuel bonus for notional of borrows']; + type: 'u32'; + }, + { + name: 'fuelPositions'; + docs: ['accumulated fuel for perp open interest']; + type: 'u32'; + }, + { + name: 'fuelTaker'; + docs: ['accumulate fuel bonus for taker volume']; + type: 'u32'; + }, + { + name: 'fuelMaker'; + docs: ['accumulate fuel bonus for maker volume']; + type: 'u32'; + }, + { + name: 'ifStakedGovTokenAmount'; + docs: [ + 'The amount of tokens staked in the governance spot markets if', + ]; + type: 'u64'; + }, + { + name: 'lastFuelIfBonusUpdateTs'; + docs: [ + 'last unix ts user stats data was used to update if fuel (u32 to save space)', + ]; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 12]; + }; + }, + ]; + }; + }, + { + name: 'validityGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'slotsBeforeStaleForAmm'; + type: 'i64'; + }, + { + name: 'slotsBeforeStaleForMargin'; + type: 'i64'; + }, + { + name: 'confidenceIntervalMaxSize'; + type: 'u64'; + }, + { + name: 'tooVolatileRatio'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'i128'; + docs: ['`i128` with legacy bit layout']; + type: { + kind: 'struct'; + fields: [ + { + array: ['u8', 16]; + }, + ]; + }; + }, + { + name: 'u128'; + docs: ['`u128` with legacy bit layout']; + type: { + kind: 'struct'; + fields: [ + { + array: ['u8', 16]; + }, + ]; + }; + }, + ]; }; From 77ffba4cbc639e18e3c908d5e97e41e34a1d8fcb Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Tue, 9 Dec 2025 08:17:42 +0800 Subject: [PATCH 21/25] wip --- sdk/src/idl/drift.json | 1713 +- sdk/src/idl/drift.ts | 45516 ++++++++++++++++++++++----------------- 2 files changed, 27447 insertions(+), 19782 deletions(-) diff --git a/sdk/src/idl/drift.json b/sdk/src/idl/drift.json index 41ed94abba..1c01619e1a 100644 --- a/sdk/src/idl/drift.json +++ b/sdk/src/idl/drift.json @@ -15755,63 +15755,1728 @@ "errors": [ { "code": 6000, - "name": "InvalidEd25519InstructionProgramId", - "msg": "invalid ed25519 instruction program" + "name": "InvalidSpotMarketAuthority", + "msg": "Invalid Spot Market Authority" }, { "code": 6001, - "name": "InvalidEd25519InstructionDataLength", - "msg": "invalid ed25519 instruction data length" + "name": "InvalidInsuranceFundAuthority", + "msg": "Clearing house not insurance fund authority" }, { "code": 6002, - "name": "InvalidSignatureIndex", - "msg": "invalid signature index" + "name": "InsufficientDeposit", + "msg": "Insufficient deposit" }, { "code": 6003, - "name": "InvalidSignatureOffset", - "msg": "invalid signature offset" + "name": "InsufficientCollateral", + "msg": "Insufficient collateral" }, { "code": 6004, - "name": "InvalidPublicKeyOffset", - "msg": "invalid public key offset" + "name": "SufficientCollateral", + "msg": "Sufficient collateral" }, { "code": 6005, - "name": "InvalidMessageOffset", - "msg": "invalid message offset" + "name": "MaxNumberOfPositions", + "msg": "Max number of positions taken" }, { "code": 6006, - "name": "InvalidMessageDataSize", - "msg": "invalid message data size" + "name": "AdminControlsPricesDisabled", + "msg": "Admin Controls Prices Disabled" }, { "code": 6007, - "name": "InvalidInstructionIndex", - "msg": "invalid instruction index" + "name": "MarketDelisted", + "msg": "Market Delisted" }, { "code": 6008, - "name": "MessageOffsetOverflow", - "msg": "message offset overflow" + "name": "MarketIndexAlreadyInitialized", + "msg": "Market Index Already Initialized" }, { "code": 6009, - "name": "InvalidMessageHex", - "msg": "invalid message hex" + "name": "UserAccountAndUserPositionsAccountMismatch", + "msg": "User Account And User Positions Account Mismatch" }, { "code": 6010, - "name": "InvalidMessageData", - "msg": "invalid message data" + "name": "UserHasNoPositionInMarket", + "msg": "User Has No Position In Market" }, { "code": 6011, - "name": "LoadInstructionAtFailed", - "msg": "loading custom ix at index failed" + "name": "InvalidInitialPeg", + "msg": "Invalid Initial Peg" + }, + { + "code": 6012, + "name": "InvalidRepegRedundant", + "msg": "AMM repeg already configured with amt given" + }, + { + "code": 6013, + "name": "InvalidRepegDirection", + "msg": "AMM repeg incorrect repeg direction" + }, + { + "code": 6014, + "name": "InvalidRepegProfitability", + "msg": "AMM repeg out of bounds pnl" + }, + { + "code": 6015, + "name": "SlippageOutsideLimit", + "msg": "Slippage Outside Limit Price" + }, + { + "code": 6016, + "name": "OrderSizeTooSmall", + "msg": "Order Size Too Small" + }, + { + "code": 6017, + "name": "InvalidUpdateK", + "msg": "Price change too large when updating K" + }, + { + "code": 6018, + "name": "AdminWithdrawTooLarge", + "msg": "Admin tried to withdraw amount larger than fees collected" + }, + { + "code": 6019, + "name": "MathError", + "msg": "Math Error" + }, + { + "code": 6020, + "name": "BnConversionError", + "msg": "Conversion to u128/u64 failed with an overflow or underflow" + }, + { + "code": 6021, + "name": "ClockUnavailable", + "msg": "Clock unavailable" + }, + { + "code": 6022, + "name": "UnableToLoadOracle", + "msg": "Unable To Load Oracles" + }, + { + "code": 6023, + "name": "PriceBandsBreached", + "msg": "Price Bands Breached" + }, + { + "code": 6024, + "name": "ExchangePaused", + "msg": "Exchange is paused" + }, + { + "code": 6025, + "name": "InvalidWhitelistToken", + "msg": "Invalid whitelist token" + }, + { + "code": 6026, + "name": "WhitelistTokenNotFound", + "msg": "Whitelist token not found" + }, + { + "code": 6027, + "name": "InvalidDiscountToken", + "msg": "Invalid discount token" + }, + { + "code": 6028, + "name": "DiscountTokenNotFound", + "msg": "Discount token not found" + }, + { + "code": 6029, + "name": "ReferrerNotFound", + "msg": "Referrer not found" + }, + { + "code": 6030, + "name": "ReferrerStatsNotFound", + "msg": "ReferrerNotFound" + }, + { + "code": 6031, + "name": "ReferrerMustBeWritable", + "msg": "ReferrerMustBeWritable" + }, + { + "code": 6032, + "name": "ReferrerStatsMustBeWritable", + "msg": "ReferrerMustBeWritable" + }, + { + "code": 6033, + "name": "ReferrerAndReferrerStatsAuthorityUnequal", + "msg": "ReferrerAndReferrerStatsAuthorityUnequal" + }, + { + "code": 6034, + "name": "InvalidReferrer", + "msg": "InvalidReferrer" + }, + { + "code": 6035, + "name": "InvalidOracle", + "msg": "InvalidOracle" + }, + { + "code": 6036, + "name": "OracleNotFound", + "msg": "OracleNotFound" + }, + { + "code": 6037, + "name": "LiquidationsBlockedByOracle", + "msg": "Liquidations Blocked By Oracle" + }, + { + "code": 6038, + "name": "MaxDeposit", + "msg": "Can not deposit more than max deposit" + }, + { + "code": 6039, + "name": "CantDeleteUserWithCollateral", + "msg": "Can not delete user that still has collateral" + }, + { + "code": 6040, + "name": "InvalidFundingProfitability", + "msg": "AMM funding out of bounds pnl" + }, + { + "code": 6041, + "name": "CastingFailure", + "msg": "Casting Failure" + }, + { + "code": 6042, + "name": "InvalidOrder", + "msg": "InvalidOrder" + }, + { + "code": 6043, + "name": "InvalidOrderMaxTs", + "msg": "InvalidOrderMaxTs" + }, + { + "code": 6044, + "name": "InvalidOrderMarketType", + "msg": "InvalidOrderMarketType" + }, + { + "code": 6045, + "name": "InvalidOrderForInitialMarginReq", + "msg": "InvalidOrderForInitialMarginReq" + }, + { + "code": 6046, + "name": "InvalidOrderNotRiskReducing", + "msg": "InvalidOrderNotRiskReducing" + }, + { + "code": 6047, + "name": "InvalidOrderSizeTooSmall", + "msg": "InvalidOrderSizeTooSmall" + }, + { + "code": 6048, + "name": "InvalidOrderNotStepSizeMultiple", + "msg": "InvalidOrderNotStepSizeMultiple" + }, + { + "code": 6049, + "name": "InvalidOrderBaseQuoteAsset", + "msg": "InvalidOrderBaseQuoteAsset" + }, + { + "code": 6050, + "name": "InvalidOrderIOC", + "msg": "InvalidOrderIOC" + }, + { + "code": 6051, + "name": "InvalidOrderPostOnly", + "msg": "InvalidOrderPostOnly" + }, + { + "code": 6052, + "name": "InvalidOrderIOCPostOnly", + "msg": "InvalidOrderIOCPostOnly" + }, + { + "code": 6053, + "name": "InvalidOrderTrigger", + "msg": "InvalidOrderTrigger" + }, + { + "code": 6054, + "name": "InvalidOrderAuction", + "msg": "InvalidOrderAuction" + }, + { + "code": 6055, + "name": "InvalidOrderOracleOffset", + "msg": "InvalidOrderOracleOffset" + }, + { + "code": 6056, + "name": "InvalidOrderMinOrderSize", + "msg": "InvalidOrderMinOrderSize" + }, + { + "code": 6057, + "name": "PlacePostOnlyLimitFailure", + "msg": "Failed to Place Post-Only Limit Order" + }, + { + "code": 6058, + "name": "UserHasNoOrder", + "msg": "User has no order" + }, + { + "code": 6059, + "name": "OrderAmountTooSmall", + "msg": "Order Amount Too Small" + }, + { + "code": 6060, + "name": "MaxNumberOfOrders", + "msg": "Max number of orders taken" + }, + { + "code": 6061, + "name": "OrderDoesNotExist", + "msg": "Order does not exist" + }, + { + "code": 6062, + "name": "OrderNotOpen", + "msg": "Order not open" + }, + { + "code": 6063, + "name": "FillOrderDidNotUpdateState", + "msg": "FillOrderDidNotUpdateState" + }, + { + "code": 6064, + "name": "ReduceOnlyOrderIncreasedRisk", + "msg": "Reduce only order increased risk" + }, + { + "code": 6065, + "name": "UnableToLoadAccountLoader", + "msg": "Unable to load AccountLoader" + }, + { + "code": 6066, + "name": "TradeSizeTooLarge", + "msg": "Trade Size Too Large" + }, + { + "code": 6067, + "name": "UserCantReferThemselves", + "msg": "User cant refer themselves" + }, + { + "code": 6068, + "name": "DidNotReceiveExpectedReferrer", + "msg": "Did not receive expected referrer" + }, + { + "code": 6069, + "name": "CouldNotDeserializeReferrer", + "msg": "Could not deserialize referrer" + }, + { + "code": 6070, + "name": "CouldNotDeserializeReferrerStats", + "msg": "Could not deserialize referrer stats" + }, + { + "code": 6071, + "name": "UserOrderIdAlreadyInUse", + "msg": "User Order Id Already In Use" + }, + { + "code": 6072, + "name": "NoPositionsLiquidatable", + "msg": "No positions liquidatable" + }, + { + "code": 6073, + "name": "InvalidMarginRatio", + "msg": "Invalid Margin Ratio" + }, + { + "code": 6074, + "name": "CantCancelPostOnlyOrder", + "msg": "Cant Cancel Post Only Order" + }, + { + "code": 6075, + "name": "InvalidOracleOffset", + "msg": "InvalidOracleOffset" + }, + { + "code": 6076, + "name": "CantExpireOrders", + "msg": "CantExpireOrders" + }, + { + "code": 6077, + "name": "CouldNotLoadMarketData", + "msg": "CouldNotLoadMarketData" + }, + { + "code": 6078, + "name": "PerpMarketNotFound", + "msg": "PerpMarketNotFound" + }, + { + "code": 6079, + "name": "InvalidMarketAccount", + "msg": "InvalidMarketAccount" + }, + { + "code": 6080, + "name": "UnableToLoadPerpMarketAccount", + "msg": "UnableToLoadMarketAccount" + }, + { + "code": 6081, + "name": "MarketWrongMutability", + "msg": "MarketWrongMutability" + }, + { + "code": 6082, + "name": "UnableToCastUnixTime", + "msg": "UnableToCastUnixTime" + }, + { + "code": 6083, + "name": "CouldNotFindSpotPosition", + "msg": "CouldNotFindSpotPosition" + }, + { + "code": 6084, + "name": "NoSpotPositionAvailable", + "msg": "NoSpotPositionAvailable" + }, + { + "code": 6085, + "name": "InvalidSpotMarketInitialization", + "msg": "InvalidSpotMarketInitialization" + }, + { + "code": 6086, + "name": "CouldNotLoadSpotMarketData", + "msg": "CouldNotLoadSpotMarketData" + }, + { + "code": 6087, + "name": "SpotMarketNotFound", + "msg": "SpotMarketNotFound" + }, + { + "code": 6088, + "name": "InvalidSpotMarketAccount", + "msg": "InvalidSpotMarketAccount" + }, + { + "code": 6089, + "name": "UnableToLoadSpotMarketAccount", + "msg": "UnableToLoadSpotMarketAccount" + }, + { + "code": 6090, + "name": "SpotMarketWrongMutability", + "msg": "SpotMarketWrongMutability" + }, + { + "code": 6091, + "name": "SpotMarketInterestNotUpToDate", + "msg": "SpotInterestNotUpToDate" + }, + { + "code": 6092, + "name": "SpotMarketInsufficientDeposits", + "msg": "SpotMarketInsufficientDeposits" + }, + { + "code": 6093, + "name": "UserMustSettleTheirOwnPositiveUnsettledPNL", + "msg": "UserMustSettleTheirOwnPositiveUnsettledPNL" + }, + { + "code": 6094, + "name": "CantUpdatePoolBalanceType", + "msg": "CantUpdatePoolBalanceType" + }, + { + "code": 6095, + "name": "InsufficientCollateralForSettlingPNL", + "msg": "InsufficientCollateralForSettlingPNL" + }, + { + "code": 6096, + "name": "AMMNotUpdatedInSameSlot", + "msg": "AMMNotUpdatedInSameSlot" + }, + { + "code": 6097, + "name": "AuctionNotComplete", + "msg": "AuctionNotComplete" + }, + { + "code": 6098, + "name": "MakerNotFound", + "msg": "MakerNotFound" + }, + { + "code": 6099, + "name": "MakerStatsNotFound", + "msg": "MakerNotFound" + }, + { + "code": 6100, + "name": "MakerMustBeWritable", + "msg": "MakerMustBeWritable" + }, + { + "code": 6101, + "name": "MakerStatsMustBeWritable", + "msg": "MakerMustBeWritable" + }, + { + "code": 6102, + "name": "MakerOrderNotFound", + "msg": "MakerOrderNotFound" + }, + { + "code": 6103, + "name": "CouldNotDeserializeMaker", + "msg": "CouldNotDeserializeMaker" + }, + { + "code": 6104, + "name": "CouldNotDeserializeMakerStats", + "msg": "CouldNotDeserializeMaker" + }, + { + "code": 6105, + "name": "AuctionPriceDoesNotSatisfyMaker", + "msg": "AuctionPriceDoesNotSatisfyMaker" + }, + { + "code": 6106, + "name": "MakerCantFulfillOwnOrder", + "msg": "MakerCantFulfillOwnOrder" + }, + { + "code": 6107, + "name": "MakerOrderMustBePostOnly", + "msg": "MakerOrderMustBePostOnly" + }, + { + "code": 6108, + "name": "CantMatchTwoPostOnlys", + "msg": "CantMatchTwoPostOnlys" + }, + { + "code": 6109, + "name": "OrderBreachesOraclePriceLimits", + "msg": "OrderBreachesOraclePriceLimits" + }, + { + "code": 6110, + "name": "OrderMustBeTriggeredFirst", + "msg": "OrderMustBeTriggeredFirst" + }, + { + "code": 6111, + "name": "OrderNotTriggerable", + "msg": "OrderNotTriggerable" + }, + { + "code": 6112, + "name": "OrderDidNotSatisfyTriggerCondition", + "msg": "OrderDidNotSatisfyTriggerCondition" + }, + { + "code": 6113, + "name": "PositionAlreadyBeingLiquidated", + "msg": "PositionAlreadyBeingLiquidated" + }, + { + "code": 6114, + "name": "PositionDoesntHaveOpenPositionOrOrders", + "msg": "PositionDoesntHaveOpenPositionOrOrders" + }, + { + "code": 6115, + "name": "AllOrdersAreAlreadyLiquidations", + "msg": "AllOrdersAreAlreadyLiquidations" + }, + { + "code": 6116, + "name": "CantCancelLiquidationOrder", + "msg": "CantCancelLiquidationOrder" + }, + { + "code": 6117, + "name": "UserIsBeingLiquidated", + "msg": "UserIsBeingLiquidated" + }, + { + "code": 6118, + "name": "LiquidationsOngoing", + "msg": "LiquidationsOngoing" + }, + { + "code": 6119, + "name": "WrongSpotBalanceType", + "msg": "WrongSpotBalanceType" + }, + { + "code": 6120, + "name": "UserCantLiquidateThemself", + "msg": "UserCantLiquidateThemself" + }, + { + "code": 6121, + "name": "InvalidPerpPositionToLiquidate", + "msg": "InvalidPerpPositionToLiquidate" + }, + { + "code": 6122, + "name": "InvalidBaseAssetAmountForLiquidatePerp", + "msg": "InvalidBaseAssetAmountForLiquidatePerp" + }, + { + "code": 6123, + "name": "InvalidPositionLastFundingRate", + "msg": "InvalidPositionLastFundingRate" + }, + { + "code": 6124, + "name": "InvalidPositionDelta", + "msg": "InvalidPositionDelta" + }, + { + "code": 6125, + "name": "UserBankrupt", + "msg": "UserBankrupt" + }, + { + "code": 6126, + "name": "UserNotBankrupt", + "msg": "UserNotBankrupt" + }, + { + "code": 6127, + "name": "UserHasInvalidBorrow", + "msg": "UserHasInvalidBorrow" + }, + { + "code": 6128, + "name": "DailyWithdrawLimit", + "msg": "DailyWithdrawLimit" + }, + { + "code": 6129, + "name": "DefaultError", + "msg": "DefaultError" + }, + { + "code": 6130, + "name": "InsufficientLPTokens", + "msg": "Insufficient LP tokens" + }, + { + "code": 6131, + "name": "CantLPWithPerpPosition", + "msg": "Cant LP with a market position" + }, + { + "code": 6132, + "name": "UnableToBurnLPTokens", + "msg": "Unable to burn LP tokens" + }, + { + "code": 6133, + "name": "TryingToRemoveLiquidityTooFast", + "msg": "Trying to remove liqudity too fast after adding it" + }, + { + "code": 6134, + "name": "InvalidSpotMarketVault", + "msg": "Invalid Spot Market Vault" + }, + { + "code": 6135, + "name": "InvalidSpotMarketState", + "msg": "Invalid Spot Market State" + }, + { + "code": 6136, + "name": "InvalidSerumProgram", + "msg": "InvalidSerumProgram" + }, + { + "code": 6137, + "name": "InvalidSerumMarket", + "msg": "InvalidSerumMarket" + }, + { + "code": 6138, + "name": "InvalidSerumBids", + "msg": "InvalidSerumBids" + }, + { + "code": 6139, + "name": "InvalidSerumAsks", + "msg": "InvalidSerumAsks" + }, + { + "code": 6140, + "name": "InvalidSerumOpenOrders", + "msg": "InvalidSerumOpenOrders" + }, + { + "code": 6141, + "name": "FailedSerumCPI", + "msg": "FailedSerumCPI" + }, + { + "code": 6142, + "name": "FailedToFillOnExternalMarket", + "msg": "FailedToFillOnExternalMarket" + }, + { + "code": 6143, + "name": "InvalidFulfillmentConfig", + "msg": "InvalidFulfillmentConfig" + }, + { + "code": 6144, + "name": "InvalidFeeStructure", + "msg": "InvalidFeeStructure" + }, + { + "code": 6145, + "name": "InsufficientIFShares", + "msg": "Insufficient IF shares" + }, + { + "code": 6146, + "name": "MarketActionPaused", + "msg": "the Market has paused this action" + }, + { + "code": 6147, + "name": "MarketPlaceOrderPaused", + "msg": "the Market status doesnt allow placing orders" + }, + { + "code": 6148, + "name": "MarketFillOrderPaused", + "msg": "the Market status doesnt allow filling orders" + }, + { + "code": 6149, + "name": "MarketWithdrawPaused", + "msg": "the Market status doesnt allow withdraws" + }, + { + "code": 6150, + "name": "ProtectedAssetTierViolation", + "msg": "Action violates the Protected Asset Tier rules" + }, + { + "code": 6151, + "name": "IsolatedAssetTierViolation", + "msg": "Action violates the Isolated Asset Tier rules" + }, + { + "code": 6152, + "name": "UserCantBeDeleted", + "msg": "User Cant Be Deleted" + }, + { + "code": 6153, + "name": "ReduceOnlyWithdrawIncreasedRisk", + "msg": "Reduce Only Withdraw Increased Risk" + }, + { + "code": 6154, + "name": "MaxOpenInterest", + "msg": "Max Open Interest" + }, + { + "code": 6155, + "name": "CantResolvePerpBankruptcy", + "msg": "Cant Resolve Perp Bankruptcy" + }, + { + "code": 6156, + "name": "LiquidationDoesntSatisfyLimitPrice", + "msg": "Liquidation Doesnt Satisfy Limit Price" + }, + { + "code": 6157, + "name": "MarginTradingDisabled", + "msg": "Margin Trading Disabled" + }, + { + "code": 6158, + "name": "InvalidMarketStatusToSettlePnl", + "msg": "Invalid Market Status to Settle Perp Pnl" + }, + { + "code": 6159, + "name": "PerpMarketNotInSettlement", + "msg": "PerpMarketNotInSettlement" + }, + { + "code": 6160, + "name": "PerpMarketNotInReduceOnly", + "msg": "PerpMarketNotInReduceOnly" + }, + { + "code": 6161, + "name": "PerpMarketSettlementBufferNotReached", + "msg": "PerpMarketSettlementBufferNotReached" + }, + { + "code": 6162, + "name": "PerpMarketSettlementUserHasOpenOrders", + "msg": "PerpMarketSettlementUserHasOpenOrders" + }, + { + "code": 6163, + "name": "PerpMarketSettlementUserHasActiveLP", + "msg": "PerpMarketSettlementUserHasActiveLP" + }, + { + "code": 6164, + "name": "UnableToSettleExpiredUserPosition", + "msg": "UnableToSettleExpiredUserPosition" + }, + { + "code": 6165, + "name": "UnequalMarketIndexForSpotTransfer", + "msg": "UnequalMarketIndexForSpotTransfer" + }, + { + "code": 6166, + "name": "InvalidPerpPositionDetected", + "msg": "InvalidPerpPositionDetected" + }, + { + "code": 6167, + "name": "InvalidSpotPositionDetected", + "msg": "InvalidSpotPositionDetected" + }, + { + "code": 6168, + "name": "InvalidAmmDetected", + "msg": "InvalidAmmDetected" + }, + { + "code": 6169, + "name": "InvalidAmmForFillDetected", + "msg": "InvalidAmmForFillDetected" + }, + { + "code": 6170, + "name": "InvalidAmmLimitPriceOverride", + "msg": "InvalidAmmLimitPriceOverride" + }, + { + "code": 6171, + "name": "InvalidOrderFillPrice", + "msg": "InvalidOrderFillPrice" + }, + { + "code": 6172, + "name": "SpotMarketBalanceInvariantViolated", + "msg": "SpotMarketBalanceInvariantViolated" + }, + { + "code": 6173, + "name": "SpotMarketVaultInvariantViolated", + "msg": "SpotMarketVaultInvariantViolated" + }, + { + "code": 6174, + "name": "InvalidPDA", + "msg": "InvalidPDA" + }, + { + "code": 6175, + "name": "InvalidPDASigner", + "msg": "InvalidPDASigner" + }, + { + "code": 6176, + "name": "RevenueSettingsCannotSettleToIF", + "msg": "RevenueSettingsCannotSettleToIF" + }, + { + "code": 6177, + "name": "NoRevenueToSettleToIF", + "msg": "NoRevenueToSettleToIF" + }, + { + "code": 6178, + "name": "NoAmmPerpPnlDeficit", + "msg": "NoAmmPerpPnlDeficit" + }, + { + "code": 6179, + "name": "SufficientPerpPnlPool", + "msg": "SufficientPerpPnlPool" + }, + { + "code": 6180, + "name": "InsufficientPerpPnlPool", + "msg": "InsufficientPerpPnlPool" + }, + { + "code": 6181, + "name": "PerpPnlDeficitBelowThreshold", + "msg": "PerpPnlDeficitBelowThreshold" + }, + { + "code": 6182, + "name": "MaxRevenueWithdrawPerPeriodReached", + "msg": "MaxRevenueWithdrawPerPeriodReached" + }, + { + "code": 6183, + "name": "MaxIFWithdrawReached", + "msg": "InvalidSpotPositionDetected" + }, + { + "code": 6184, + "name": "NoIFWithdrawAvailable", + "msg": "NoIFWithdrawAvailable" + }, + { + "code": 6185, + "name": "InvalidIFUnstake", + "msg": "InvalidIFUnstake" + }, + { + "code": 6186, + "name": "InvalidIFUnstakeSize", + "msg": "InvalidIFUnstakeSize" + }, + { + "code": 6187, + "name": "InvalidIFUnstakeCancel", + "msg": "InvalidIFUnstakeCancel" + }, + { + "code": 6188, + "name": "InvalidIFForNewStakes", + "msg": "InvalidIFForNewStakes" + }, + { + "code": 6189, + "name": "InvalidIFRebase", + "msg": "InvalidIFRebase" + }, + { + "code": 6190, + "name": "InvalidInsuranceUnstakeSize", + "msg": "InvalidInsuranceUnstakeSize" + }, + { + "code": 6191, + "name": "InvalidOrderLimitPrice", + "msg": "InvalidOrderLimitPrice" + }, + { + "code": 6192, + "name": "InvalidIFDetected", + "msg": "InvalidIFDetected" + }, + { + "code": 6193, + "name": "InvalidAmmMaxSpreadDetected", + "msg": "InvalidAmmMaxSpreadDetected" + }, + { + "code": 6194, + "name": "InvalidConcentrationCoef", + "msg": "InvalidConcentrationCoef" + }, + { + "code": 6195, + "name": "InvalidSrmVault", + "msg": "InvalidSrmVault" + }, + { + "code": 6196, + "name": "InvalidVaultOwner", + "msg": "InvalidVaultOwner" + }, + { + "code": 6197, + "name": "InvalidMarketStatusForFills", + "msg": "InvalidMarketStatusForFills" + }, + { + "code": 6198, + "name": "IFWithdrawRequestInProgress", + "msg": "IFWithdrawRequestInProgress" + }, + { + "code": 6199, + "name": "NoIFWithdrawRequestInProgress", + "msg": "NoIFWithdrawRequestInProgress" + }, + { + "code": 6200, + "name": "IFWithdrawRequestTooSmall", + "msg": "IFWithdrawRequestTooSmall" + }, + { + "code": 6201, + "name": "IncorrectSpotMarketAccountPassed", + "msg": "IncorrectSpotMarketAccountPassed" + }, + { + "code": 6202, + "name": "BlockchainClockInconsistency", + "msg": "BlockchainClockInconsistency" + }, + { + "code": 6203, + "name": "InvalidIFSharesDetected", + "msg": "InvalidIFSharesDetected" + }, + { + "code": 6204, + "name": "NewLPSizeTooSmall", + "msg": "NewLPSizeTooSmall" + }, + { + "code": 6205, + "name": "MarketStatusInvalidForNewLP", + "msg": "MarketStatusInvalidForNewLP" + }, + { + "code": 6206, + "name": "InvalidMarkTwapUpdateDetected", + "msg": "InvalidMarkTwapUpdateDetected" + }, + { + "code": 6207, + "name": "MarketSettlementAttemptOnActiveMarket", + "msg": "MarketSettlementAttemptOnActiveMarket" + }, + { + "code": 6208, + "name": "MarketSettlementRequiresSettledLP", + "msg": "MarketSettlementRequiresSettledLP" + }, + { + "code": 6209, + "name": "MarketSettlementAttemptTooEarly", + "msg": "MarketSettlementAttemptTooEarly" + }, + { + "code": 6210, + "name": "MarketSettlementTargetPriceInvalid", + "msg": "MarketSettlementTargetPriceInvalid" + }, + { + "code": 6211, + "name": "UnsupportedSpotMarket", + "msg": "UnsupportedSpotMarket" + }, + { + "code": 6212, + "name": "SpotOrdersDisabled", + "msg": "SpotOrdersDisabled" + }, + { + "code": 6213, + "name": "MarketBeingInitialized", + "msg": "Market Being Initialized" + }, + { + "code": 6214, + "name": "InvalidUserSubAccountId", + "msg": "Invalid Sub Account Id" + }, + { + "code": 6215, + "name": "InvalidTriggerOrderCondition", + "msg": "Invalid Trigger Order Condition" + }, + { + "code": 6216, + "name": "InvalidSpotPosition", + "msg": "Invalid Spot Position" + }, + { + "code": 6217, + "name": "CantTransferBetweenSameUserAccount", + "msg": "Cant transfer between same user account" + }, + { + "code": 6218, + "name": "InvalidPerpPosition", + "msg": "Invalid Perp Position" + }, + { + "code": 6219, + "name": "UnableToGetLimitPrice", + "msg": "Unable To Get Limit Price" + }, + { + "code": 6220, + "name": "InvalidLiquidation", + "msg": "Invalid Liquidation" + }, + { + "code": 6221, + "name": "SpotFulfillmentConfigDisabled", + "msg": "Spot Fulfillment Config Disabled" + }, + { + "code": 6222, + "name": "InvalidMaker", + "msg": "Invalid Maker" + }, + { + "code": 6223, + "name": "FailedUnwrap", + "msg": "Failed Unwrap" + }, + { + "code": 6224, + "name": "MaxNumberOfUsers", + "msg": "Max Number Of Users" + }, + { + "code": 6225, + "name": "InvalidOracleForSettlePnl", + "msg": "InvalidOracleForSettlePnl" + }, + { + "code": 6226, + "name": "MarginOrdersOpen", + "msg": "MarginOrdersOpen" + }, + { + "code": 6227, + "name": "TierViolationLiquidatingPerpPnl", + "msg": "TierViolationLiquidatingPerpPnl" + }, + { + "code": 6228, + "name": "CouldNotLoadUserData", + "msg": "CouldNotLoadUserData" + }, + { + "code": 6229, + "name": "UserWrongMutability", + "msg": "UserWrongMutability" + }, + { + "code": 6230, + "name": "InvalidUserAccount", + "msg": "InvalidUserAccount" + }, + { + "code": 6231, + "name": "CouldNotLoadUserStatsData", + "msg": "CouldNotLoadUserData" + }, + { + "code": 6232, + "name": "UserStatsWrongMutability", + "msg": "UserWrongMutability" + }, + { + "code": 6233, + "name": "InvalidUserStatsAccount", + "msg": "InvalidUserAccount" + }, + { + "code": 6234, + "name": "UserNotFound", + "msg": "UserNotFound" + }, + { + "code": 6235, + "name": "UnableToLoadUserAccount", + "msg": "UnableToLoadUserAccount" + }, + { + "code": 6236, + "name": "UserStatsNotFound", + "msg": "UserStatsNotFound" + }, + { + "code": 6237, + "name": "UnableToLoadUserStatsAccount", + "msg": "UnableToLoadUserStatsAccount" + }, + { + "code": 6238, + "name": "UserNotInactive", + "msg": "User Not Inactive" + }, + { + "code": 6239, + "name": "RevertFill", + "msg": "RevertFill" + }, + { + "code": 6240, + "name": "InvalidMarketAccountforDeletion", + "msg": "Invalid MarketAccount for Deletion" + }, + { + "code": 6241, + "name": "InvalidSpotFulfillmentParams", + "msg": "Invalid Spot Fulfillment Params" + }, + { + "code": 6242, + "name": "FailedToGetMint", + "msg": "Failed to Get Mint" + }, + { + "code": 6243, + "name": "FailedPhoenixCPI", + "msg": "FailedPhoenixCPI" + }, + { + "code": 6244, + "name": "FailedToDeserializePhoenixMarket", + "msg": "FailedToDeserializePhoenixMarket" + }, + { + "code": 6245, + "name": "InvalidPricePrecision", + "msg": "InvalidPricePrecision" + }, + { + "code": 6246, + "name": "InvalidPhoenixProgram", + "msg": "InvalidPhoenixProgram" + }, + { + "code": 6247, + "name": "InvalidPhoenixMarket", + "msg": "InvalidPhoenixMarket" + }, + { + "code": 6248, + "name": "InvalidSwap", + "msg": "InvalidSwap" + }, + { + "code": 6249, + "name": "SwapLimitPriceBreached", + "msg": "SwapLimitPriceBreached" + }, + { + "code": 6250, + "name": "SpotMarketReduceOnly", + "msg": "SpotMarketReduceOnly" + }, + { + "code": 6251, + "name": "FundingWasNotUpdated", + "msg": "FundingWasNotUpdated" + }, + { + "code": 6252, + "name": "ImpossibleFill", + "msg": "ImpossibleFill" + }, + { + "code": 6253, + "name": "CantUpdatePerpBidAskTwap", + "msg": "CantUpdatePerpBidAskTwap" + }, + { + "code": 6254, + "name": "UserReduceOnly", + "msg": "UserReduceOnly" + }, + { + "code": 6255, + "name": "InvalidMarginCalculation", + "msg": "InvalidMarginCalculation" + }, + { + "code": 6256, + "name": "CantPayUserInitFee", + "msg": "CantPayUserInitFee" + }, + { + "code": 6257, + "name": "CantReclaimRent", + "msg": "CantReclaimRent" + }, + { + "code": 6258, + "name": "InsuranceFundOperationPaused", + "msg": "InsuranceFundOperationPaused" + }, + { + "code": 6259, + "name": "NoUnsettledPnl", + "msg": "NoUnsettledPnl" + }, + { + "code": 6260, + "name": "PnlPoolCantSettleUser", + "msg": "PnlPoolCantSettleUser" + }, + { + "code": 6261, + "name": "OracleNonPositive", + "msg": "OracleInvalid" + }, + { + "code": 6262, + "name": "OracleTooVolatile", + "msg": "OracleTooVolatile" + }, + { + "code": 6263, + "name": "OracleTooUncertain", + "msg": "OracleTooUncertain" + }, + { + "code": 6264, + "name": "OracleStaleForMargin", + "msg": "OracleStaleForMargin" + }, + { + "code": 6265, + "name": "OracleInsufficientDataPoints", + "msg": "OracleInsufficientDataPoints" + }, + { + "code": 6266, + "name": "OracleStaleForAMM", + "msg": "OracleStaleForAMM" + }, + { + "code": 6267, + "name": "UnableToParsePullOracleMessage", + "msg": "Unable to parse pull oracle message" + }, + { + "code": 6268, + "name": "MaxBorrows", + "msg": "Can not borow more than max borrows" + }, + { + "code": 6269, + "name": "OracleUpdatesNotMonotonic", + "msg": "Updates must be monotonically increasing" + }, + { + "code": 6270, + "name": "OraclePriceFeedMessageMismatch", + "msg": "Trying to update price feed with the wrong feed id" + }, + { + "code": 6271, + "name": "OracleUnsupportedMessageType", + "msg": "The message in the update must be a PriceFeedMessage" + }, + { + "code": 6272, + "name": "OracleDeserializeMessageFailed", + "msg": "Could not deserialize the message in the update" + }, + { + "code": 6273, + "name": "OracleWrongGuardianSetOwner", + "msg": "Wrong guardian set owner in update price atomic" + }, + { + "code": 6274, + "name": "OracleWrongWriteAuthority", + "msg": "Oracle post update atomic price feed account must be drift program" + }, + { + "code": 6275, + "name": "OracleWrongVaaOwner", + "msg": "Oracle vaa owner must be wormhole program" + }, + { + "code": 6276, + "name": "OracleTooManyPriceAccountUpdates", + "msg": "Multi updates must have 2 or fewer accounts passed in remaining accounts" + }, + { + "code": 6277, + "name": "OracleMismatchedVaaAndPriceUpdates", + "msg": "Don't have the same remaining accounts number and pyth updates left" + }, + { + "code": 6278, + "name": "OracleBadRemainingAccountPublicKey", + "msg": "Remaining account passed does not match oracle update derived pda" + }, + { + "code": 6279, + "name": "FailedOpenbookV2CPI", + "msg": "FailedOpenbookV2CPI" + }, + { + "code": 6280, + "name": "InvalidOpenbookV2Program", + "msg": "InvalidOpenbookV2Program" + }, + { + "code": 6281, + "name": "InvalidOpenbookV2Market", + "msg": "InvalidOpenbookV2Market" + }, + { + "code": 6282, + "name": "NonZeroTransferFee", + "msg": "Non zero transfer fee" + }, + { + "code": 6283, + "name": "LiquidationOrderFailedToFill", + "msg": "Liquidation order failed to fill" + }, + { + "code": 6284, + "name": "InvalidPredictionMarketOrder", + "msg": "Invalid prediction market order" + }, + { + "code": 6285, + "name": "InvalidVerificationIxIndex", + "msg": "Ed25519 Ix must be before place and make SignedMsg order ix" + }, + { + "code": 6286, + "name": "SigVerificationFailed", + "msg": "SignedMsg message verificaiton failed" + }, + { + "code": 6287, + "name": "MismatchedSignedMsgOrderParamsMarketIndex", + "msg": "Market index mismatched b/w taker and maker SignedMsg order params" + }, + { + "code": 6288, + "name": "InvalidSignedMsgOrderParam", + "msg": "Invalid SignedMsg order param" + }, + { + "code": 6289, + "name": "PlaceAndTakeOrderSuccessConditionFailed", + "msg": "Place and take order success condition failed" + }, + { + "code": 6290, + "name": "InvalidHighLeverageModeConfig", + "msg": "Invalid High Leverage Mode Config" + }, + { + "code": 6291, + "name": "InvalidRFQUserAccount", + "msg": "Invalid RFQ User Account" + }, + { + "code": 6292, + "name": "RFQUserAccountWrongMutability", + "msg": "RFQUserAccount should be mutable" + }, + { + "code": 6293, + "name": "RFQUserAccountFull", + "msg": "RFQUserAccount has too many active RFQs" + }, + { + "code": 6294, + "name": "RFQOrderNotFilled", + "msg": "RFQ order not filled as expected" + }, + { + "code": 6295, + "name": "InvalidRFQOrder", + "msg": "RFQ orders must be jit makers" + }, + { + "code": 6296, + "name": "InvalidRFQMatch", + "msg": "RFQ matches must be valid" + }, + { + "code": 6297, + "name": "InvalidSignedMsgUserAccount", + "msg": "Invalid SignedMsg user account" + }, + { + "code": 6298, + "name": "SignedMsgUserAccountWrongMutability", + "msg": "SignedMsg account wrong mutability" + }, + { + "code": 6299, + "name": "SignedMsgUserOrdersAccountFull", + "msg": "SignedMsgUserAccount has too many active orders" + }, + { + "code": 6300, + "name": "SignedMsgOrderDoesNotExist", + "msg": "Order with SignedMsg uuid does not exist" + }, + { + "code": 6301, + "name": "InvalidSignedMsgOrderId", + "msg": "SignedMsg order id cannot be 0s" + }, + { + "code": 6302, + "name": "InvalidPoolId", + "msg": "Invalid pool id" + }, + { + "code": 6303, + "name": "InvalidProtectedMakerModeConfig", + "msg": "Invalid Protected Maker Mode Config" + }, + { + "code": 6304, + "name": "InvalidPythLazerStorageOwner", + "msg": "Invalid pyth lazer storage owner" + }, + { + "code": 6305, + "name": "UnverifiedPythLazerMessage", + "msg": "Verification of pyth lazer message failed" + }, + { + "code": 6306, + "name": "InvalidPythLazerMessage", + "msg": "Invalid pyth lazer message" + }, + { + "code": 6307, + "name": "PythLazerMessagePriceFeedMismatch", + "msg": "Pyth lazer message does not correspond to correct fed id" + }, + { + "code": 6308, + "name": "InvalidLiquidateSpotWithSwap", + "msg": "InvalidLiquidateSpotWithSwap" + }, + { + "code": 6309, + "name": "SignedMsgUserContextUserMismatch", + "msg": "User in SignedMsg message does not match user in ix context" + }, + { + "code": 6310, + "name": "UserFuelOverflowThresholdNotMet", + "msg": "User fuel overflow threshold not met" + }, + { + "code": 6311, + "name": "FuelOverflowAccountNotFound", + "msg": "FuelOverflow account not found" + }, + { + "code": 6312, + "name": "InvalidTransferPerpPosition", + "msg": "Invalid Transfer Perp Position" + }, + { + "code": 6313, + "name": "InvalidSignedMsgUserOrdersResize", + "msg": "Invalid SignedMsgUserOrders resize" + }, + { + "code": 6314, + "name": "CouldNotDeserializeHighLeverageModeConfig", + "msg": "Could not deserialize high leverage mode config" + }, + { + "code": 6315, + "name": "InvalidIfRebalanceConfig", + "msg": "Invalid If Rebalance Config" + }, + { + "code": 6316, + "name": "InvalidIfRebalanceSwap", + "msg": "Invalid If Rebalance Swap" + }, + { + "code": 6317, + "name": "InvalidRevenueShareResize", + "msg": "Invalid RevenueShare resize" + }, + { + "code": 6318, + "name": "BuilderRevoked", + "msg": "Builder has been revoked" + }, + { + "code": 6319, + "name": "InvalidBuilderFee", + "msg": "Builder fee is greater than max fee bps" + }, + { + "code": 6320, + "name": "RevenueShareEscrowAuthorityMismatch", + "msg": "RevenueShareEscrow authority mismatch" + }, + { + "code": 6321, + "name": "RevenueShareEscrowOrdersAccountFull", + "msg": "RevenueShareEscrow has too many active orders" + }, + { + "code": 6322, + "name": "InvalidRevenueShareAccount", + "msg": "Invalid RevenueShareAccount" + }, + { + "code": 6323, + "name": "CannotRevokeBuilderWithOpenOrders", + "msg": "Cannot revoke builder with open orders" + }, + { + "code": 6324, + "name": "UnableToLoadRevenueShareAccount", + "msg": "Unable to load builder account" + }, + { + "code": 6325, + "name": "InvalidConstituent", + "msg": "Invalid Constituent" + }, + { + "code": 6326, + "name": "InvalidAmmConstituentMappingArgument", + "msg": "Invalid Amm Constituent Mapping argument" + }, + { + "code": 6327, + "name": "ConstituentNotFound", + "msg": "Constituent not found" + }, + { + "code": 6328, + "name": "ConstituentCouldNotLoad", + "msg": "Constituent could not load" + }, + { + "code": 6329, + "name": "ConstituentWrongMutability", + "msg": "Constituent wrong mutability" + }, + { + "code": 6330, + "name": "WrongNumberOfConstituents", + "msg": "Wrong number of constituents passed to instruction" + }, + { + "code": 6331, + "name": "InsufficientConstituentTokenBalance", + "msg": "Insufficient constituent token balance" + }, + { + "code": 6332, + "name": "AMMCacheStale", + "msg": "Amm Cache data too stale" + }, + { + "code": 6333, + "name": "LpPoolAumDelayed", + "msg": "LP Pool AUM not updated recently" + }, + { + "code": 6334, + "name": "ConstituentOracleStale", + "msg": "Constituent oracle is stale" + }, + { + "code": 6335, + "name": "LpInvariantFailed", + "msg": "LP Invariant failed" + }, + { + "code": 6336, + "name": "InvalidConstituentDerivativeWeights", + "msg": "Invalid constituent derivative weights" + }, + { + "code": 6337, + "name": "MaxDlpAumBreached", + "msg": "Max DLP AUM Breached" + }, + { + "code": 6338, + "name": "SettleLpPoolDisabled", + "msg": "Settle Lp Pool Disabled" + }, + { + "code": 6339, + "name": "MintRedeemLpPoolDisabled", + "msg": "Mint/Redeem Lp Pool Disabled" + }, + { + "code": 6340, + "name": "LpPoolSettleInvariantBreached", + "msg": "Settlement amount exceeded" + }, + { + "code": 6341, + "name": "InvalidConstituentOperation", + "msg": "Invalid constituent operation" + }, + { + "code": 6342, + "name": "Unauthorized", + "msg": "Unauthorized for operation" + }, + { + "code": 6343, + "name": "InvalidLpPoolId", + "msg": "Invalid Lp Pool Id for Operation" + }, + { + "code": 6344, + "name": "MarketIndexNotFoundAmmCache", + "msg": "MarketIndexNotFoundAmmCache" } ], "types": [ diff --git a/sdk/src/idl/drift.ts b/sdk/src/idl/drift.ts index 73f3277476..7e857b5c54 100644 --- a/sdk/src/idl/drift.ts +++ b/sdk/src/idl/drift.ts @@ -5,19762 +5,25762 @@ * IDL can be found at `target/idl/drift.json`. */ export type Drift = { - address: 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; - metadata: { - name: 'drift'; - version: '2.151.0'; - spec: '0.1.0'; - description: 'Created with Anchor'; - }; - instructions: [ - { - name: 'addAmmConstituentMappingData'; - discriminator: [164, 236, 130, 40, 118, 179, 46, 235]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - }, - { - name: 'ammConstituentMapping'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [65, 77, 77, 95, 77, 65, 80]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituentTargetBase'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'ammConstituentMappingData'; - type: { - vec: { - defined: { - name: 'addAmmConstituentMappingDatum'; - }; - }; - }; - }, - ]; - }, - { - name: 'addInsuranceFundStake'; - discriminator: [251, 144, 115, 11, 222, 47, 62, 236]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['insuranceFundStake', 'userStats']; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'addMarketToAmmCache'; - discriminator: [112, 149, 195, 222, 124, 7, 87, 237]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - { - name: 'perpMarket'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'adminDeposit'; - discriminator: [210, 66, 65, 182, 102, 214, 176, 30]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'adminTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'adminUpdateUserStatsPausedOperations'; - discriminator: [183, 104, 63, 150, 240, 199, 3, 10]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'beginInsuranceFundSwap'; - discriminator: [176, 69, 143, 205, 32, 132, 163, 0]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'outInsuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inInsuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outTokenAccount'; - writable: true; - }, - { - name: 'inTokenAccount'; - writable: true; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'amountIn'; - type: 'u64'; - }, - ]; - }, - { - name: 'beginLpSwap'; - discriminator: [64, 44, 24, 199, 48, 125, 67, 91]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'signerOutTokenAccount'; - docs: ['Signer token accounts']; - writable: true; - }, - { - name: 'signerInTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - docs: ['Constituent token accounts']; - writable: true; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - }, - { - name: 'outConstituent'; - docs: ['Constituents']; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpPool'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'amountIn'; - type: 'u64'; - }, - ]; - }, - { - name: 'beginSwap'; - discriminator: [174, 109, 228, 1, 242, 105, 232, 105]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'outSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outTokenAccount'; - writable: true; - }, - { - name: 'inTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'amountIn'; - type: 'u64'; - }, - ]; - }, - { - name: 'cancelOrder'; - discriminator: [95, 129, 237, 240, 8, 49, 223, 132]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'cancelOrderByUserId'; - discriminator: [107, 211, 250, 133, 18, 37, 57, 100]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'userOrderId'; - type: 'u8'; - }, - ]; - }, - { - name: 'cancelOrders'; - discriminator: [238, 225, 95, 158, 227, 103, 8, 194]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'marketType'; - type: { - option: { - defined: { - name: 'marketType'; - }; - }; - }; - }, - { - name: 'marketIndex'; - type: { - option: 'u16'; - }; - }, - { - name: 'direction'; - type: { - option: { - defined: { - name: 'positionDirection'; - }; - }; - }; - }, - ]; - }, - { - name: 'cancelOrdersByIds'; - discriminator: [134, 19, 144, 165, 94, 240, 210, 94]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'orderIds'; - type: { - vec: 'u32'; - }; - }, - ]; - }, - { - name: 'cancelRequestRemoveInsuranceFundStake'; - discriminator: [97, 235, 78, 62, 212, 42, 241, 127]; - accounts: [ - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['insuranceFundStake', 'userStats']; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'changeApprovedBuilder'; - discriminator: [179, 134, 211, 45, 195, 5, 189, 173]; - accounts: [ - { - name: 'escrow'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - relations: ['escrow']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'builder'; - type: 'pubkey'; - }, - { - name: 'maxFeeBps'; - type: 'u16'; - }, - { - name: 'add'; - type: 'bool'; - }, - ]; - }, - { - name: 'changeSignedMsgWsDelegateStatus'; - discriminator: [252, 202, 252, 219, 179, 27, 84, 138]; - accounts: [ - { - name: 'signedMsgWsDelegates'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'delegate'; - type: 'pubkey'; - }, - { - name: 'add'; - type: 'bool'; - }, - ]; - }, - { - name: 'deleteAmmCache'; - discriminator: [216, 130, 215, 206, 233, 232, 191, 88]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'deleteInitializedPerpMarket'; - discriminator: [91, 154, 24, 87, 106, 59, 190, 66]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'deleteInitializedSpotMarket'; - discriminator: [31, 140, 67, 191, 189, 20, 101, 221]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'deletePrelaunchOracle'; - discriminator: [59, 169, 100, 49, 69, 17, 173, 253]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'prelaunchOracle'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101, - ]; - }, - { - kind: 'arg'; - path: 'perpMarketIndex'; - }, - ]; - }; - }, - { - name: 'perpMarket'; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'deleteSignedMsgUserOrders'; - discriminator: [221, 247, 128, 253, 212, 254, 46, 153]; - accounts: [ - { - name: 'signedMsgUserOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'deleteUser'; - discriminator: [186, 85, 17, 249, 219, 231, 98, 251]; - accounts: [ - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - writable: true; - signer: true; - relations: ['user', 'userStats']; - }, - ]; - args: []; - }, - { - name: 'deposit'; - discriminator: [242, 35, 198, 137, 82, 225, 242, 182]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - ]; - }, - { - name: 'depositIntoInsuranceFundStake'; - discriminator: [4, 22, 226, 201, 124, 44, 82, 230]; - accounts: [ - { - name: 'signer'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101, - ]; - }, - { - kind: 'account'; - path: 'userStats'; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'depositIntoPerpMarketFeePool'; - discriminator: [34, 58, 57, 68, 97, 80, 244, 6]; - accounts: [ - { - name: 'state'; - writable: true; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'sourceVault'; - writable: true; - }, - { - name: 'driftSigner'; - }, - { - name: 'quoteSpotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'depositIntoSpotMarketRevenuePool'; - discriminator: [92, 40, 151, 42, 122, 254, 139, 246]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'spotMarket'; - }, - ]; - }; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'depositIntoSpotMarketVault'; - discriminator: [48, 252, 119, 73, 255, 205, 174, 247]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'admin'; - signer: true; - }, - { - name: 'sourceVault'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'depositToProgramVault'; - discriminator: [235, 171, 121, 80, 57, 239, 147, 220]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'constituent'; - writable: true; - }, - { - name: 'constituentTokenAccount'; - writable: true; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'mint'; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'disableUserHighLeverageMode'; - discriminator: [183, 155, 45, 0, 226, 85, 213, 69]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'highLeverageModeConfig'; - writable: true; - }, - ]; - args: [ - { - name: 'disableMaintenance'; - type: 'bool'; - }, - ]; - }, - { - name: 'enableUserHighLeverageMode'; - discriminator: [231, 24, 230, 112, 201, 173, 73, 184]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'highLeverageModeConfig'; - writable: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - ]; - }, - { - name: 'endInsuranceFundSwap'; - discriminator: [206, 230, 98, 8, 249, 158, 169, 167]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'outInsuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inInsuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outTokenAccount'; - writable: true; - }, - { - name: 'inTokenAccount'; - writable: true; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'endLpSwap'; - discriminator: [99, 125, 214, 165, 129, 175, 253, 135]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'signerOutTokenAccount'; - docs: ['Signer token accounts']; - writable: true; - }, - { - name: 'signerInTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - docs: ['Constituent token accounts']; - writable: true; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - }, - { - name: 'outConstituent'; - docs: ['Constituents']; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpPool'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'endSwap'; - discriminator: [177, 184, 27, 193, 34, 13, 210, 145]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'outSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outTokenAccount'; - writable: true; - }, - { - name: 'inTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - { - name: 'reduceOnly'; - type: { - option: { - defined: { - name: 'swapReduceOnly'; - }; - }; - }; - }, - ]; - }, - { - name: 'fillPerpOrder'; - discriminator: [13, 188, 248, 103, 134, 217, 106, 240]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'fillerStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'makerOrderId'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'fillSpotOrder'; - discriminator: [212, 206, 130, 173, 21, 34, 199, 40]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'fillerStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'fulfillmentType'; - type: { - option: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }; - }, - { - name: 'makerOrderId'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'forceCancelOrders'; - discriminator: [64, 181, 196, 63, 222, 72, 64, 232]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'forceDeleteUser'; - discriminator: [2, 241, 195, 172, 227, 24, 254, 158]; - accounts: [ - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - writable: true; - relations: ['user', 'userStats']; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'driftSigner'; - }, - ]; - args: []; - }, - { - name: 'initialize'; - discriminator: [175, 175, 109, 31, 13, 152, 155, 237]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [100, 114, 105, 102, 116, 95, 115, 116, 97, 116, 101]; - }, - ]; - }; - }, - { - name: 'quoteAssetMint'; - }, - { - name: 'driftSigner'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: []; - }, - { - name: 'initializeAmmCache'; - discriminator: [38, 60, 171, 158, 203, 58, 137, 8]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'initializeConstituent'; - discriminator: [12, 196, 45, 218, 93, 89, 0, 33]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'constituentTargetBase'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituentCorrelations'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'spotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'spotMarketMint'; - }, - { - name: 'constituentVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'decimals'; - type: 'u8'; - }, - { - name: 'maxWeightDeviation'; - type: 'i64'; - }, - { - name: 'swapFeeMin'; - type: 'i64'; - }, - { - name: 'swapFeeMax'; - type: 'i64'; - }, - { - name: 'maxBorrowTokenAmount'; - type: 'u64'; - }, - { - name: 'oracleStalenessThreshold'; - type: 'u64'; - }, - { - name: 'costToTrade'; - type: 'i32'; - }, - { - name: 'constituentDerivativeIndex'; - type: { - option: 'i16'; - }; - }, - { - name: 'constituentDerivativeDepegThreshold'; - type: 'u64'; - }, - { - name: 'derivativeWeight'; - type: 'u64'; - }, - { - name: 'volatility'; - type: 'u64'; - }, - { - name: 'gammaExecution'; - type: 'u8'; - }, - { - name: 'gammaInventory'; - type: 'u8'; - }, - { - name: 'xi'; - type: 'u8'; - }, - { - name: 'newConstituentCorrelations'; - type: { - vec: 'i64'; - }; - }, - ]; - }, - { - name: 'initializeFuelOverflow'; - discriminator: [88, 223, 132, 161, 208, 88, 142, 42]; - accounts: [ - { - name: 'fuelOverflow'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 102, - 117, - 101, - 108, - 95, - 111, - 118, - 101, - 114, - 102, - 108, - 111, - 119, - ]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - relations: ['userStats']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'initializeHighLeverageModeConfig'; - discriminator: [213, 167, 93, 246, 208, 130, 90, 248]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'highLeverageModeConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 104, - 105, - 103, - 104, - 95, - 108, - 101, - 118, - 101, - 114, - 97, - 103, - 101, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - ]; - }, - { - name: 'initializeIfRebalanceConfig'; - discriminator: [8, 85, 184, 167, 176, 61, 173, 226]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 102, - 95, - 114, - 101, - 98, - 97, - 108, - 97, - 110, - 99, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - { - kind: 'arg'; - path: 'params.in_market_index'; - }, - { - kind: 'arg'; - path: 'params.out_market_index'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'ifRebalanceConfigParams'; - }; - }; - }, - ]; - }, - { - name: 'initializeInsuranceFundStake'; - discriminator: [187, 179, 243, 70, 248, 90, 92, 147]; - accounts: [ - { - name: 'spotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101, - ]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - relations: ['userStats']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializeLpPool'; - discriminator: [242, 64, 1, 222, 142, 46, 204, 227]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [108, 112, 95, 112, 111, 111, 108]; - }, - { - kind: 'arg'; - path: 'id'; - }, - ]; - }; - }, - { - name: 'mint'; - }, - { - name: 'lpPoolTokenVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'ammConstituentMapping'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [65, 77, 77, 95, 77, 65, 80]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituentTargetBase'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'constituentCorrelations'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'tokenProgram'; - address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'lpPoolId'; - type: 'u8'; - }, - { - name: 'minMintFee'; - type: 'i64'; - }, - { - name: 'maxAum'; - type: 'u128'; - }, - { - name: 'maxSettleQuoteAmountPerMarket'; - type: 'u64'; - }, - { - name: 'whitelistMint'; - type: 'pubkey'; - }, - ]; - }, - { - name: 'initializeOpenbookV2FulfillmentConfig'; - discriminator: [7, 221, 103, 153, 107, 57, 27, 197]; - accounts: [ - { - name: 'baseSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'quoteSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'openbookV2Program'; - }, - { - name: 'openbookV2Market'; - }, - { - name: 'driftSigner'; - }, - { - name: 'openbookV2FulfillmentConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 111, - 112, - 101, - 110, - 98, - 111, - 111, - 107, - 95, - 118, - 50, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - { - kind: 'account'; - path: 'openbookV2Market'; - }, - ]; - }; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializePerpMarket'; - discriminator: [132, 9, 229, 118, 117, 118, 117, 62]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'perpMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 101, 114, 112, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'account'; - path: 'state.number_of_markets'; - account: 'state'; - }, - ]; - }; - }, - { - name: 'oracle'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'ammBaseAssetReserve'; - type: 'u128'; - }, - { - name: 'ammQuoteAssetReserve'; - type: 'u128'; - }, - { - name: 'ammPeriodicity'; - type: 'i64'; - }, - { - name: 'ammPegMultiplier'; - type: 'u128'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'contractTier'; - type: { - defined: { - name: 'contractTier'; - }; - }; - }, - { - name: 'marginRatioInitial'; - type: 'u32'; - }, - { - name: 'marginRatioMaintenance'; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - type: 'u32'; - }, - { - name: 'imfFactor'; - type: 'u32'; - }, - { - name: 'activeStatus'; - type: 'bool'; - }, - { - name: 'baseSpread'; - type: 'u32'; - }, - { - name: 'maxSpread'; - type: 'u32'; - }, - { - name: 'maxOpenInterest'; - type: 'u128'; - }, - { - name: 'maxRevenueWithdrawPerPeriod'; - type: 'u64'; - }, - { - name: 'quoteMaxInsurance'; - type: 'u64'; - }, - { - name: 'orderStepSize'; - type: 'u64'; - }, - { - name: 'orderTickSize'; - type: 'u64'; - }, - { - name: 'minOrderSize'; - type: 'u64'; - }, - { - name: 'concentrationCoefScale'; - type: 'u128'; - }, - { - name: 'curveUpdateIntensity'; - type: 'u8'; - }, - { - name: 'ammJitIntensity'; - type: 'u8'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'lpPoolId'; - type: 'u8'; - }, - ]; - }, - { - name: 'initializePhoenixFulfillmentConfig'; - discriminator: [135, 132, 110, 107, 185, 160, 169, 154]; - accounts: [ - { - name: 'baseSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'quoteSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'phoenixProgram'; - }, - { - name: 'phoenixMarket'; - }, - { - name: 'driftSigner'; - }, - { - name: 'phoenixFulfillmentConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 104, - 111, - 101, - 110, - 105, - 120, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - { - kind: 'account'; - path: 'phoenixMarket'; - }, - ]; - }; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializePredictionMarket'; - discriminator: [248, 70, 198, 224, 224, 105, 125, 195]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'initializePrelaunchOracle'; - discriminator: [169, 178, 84, 25, 175, 62, 29, 247]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'prelaunchOracle'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101, - ]; - }, - { - kind: 'arg'; - path: 'params.perp_market_index'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'prelaunchOracleParams'; - }; - }; - }, - ]; - }, - { - name: 'initializeProtectedMakerModeConfig'; - discriminator: [67, 103, 220, 67, 88, 32, 252, 8]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'protectedMakerModeConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 111, - 116, - 101, - 99, - 116, - 101, - 100, - 95, - 109, - 97, - 107, - 101, - 114, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - ]; - }, - { - name: 'initializePythLazerOracle'; - discriminator: [140, 107, 33, 214, 235, 219, 103, 20]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lazerOracle'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 121, 116, 104, 95, 108, 97, 122, 101, 114]; - }, - { - kind: 'arg'; - path: 'feedId'; - }, - ]; - }; - }, - { - name: 'state'; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'feedId'; - type: 'u32'; - }, - ]; - }, - { - name: 'initializePythPullOracle'; - discriminator: [249, 140, 253, 243, 248, 74, 240, 238]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'pythSolanaReceiver'; - address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; - }, - { - name: 'priceFeed'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; - }, - { - kind: 'arg'; - path: 'feedId'; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'feedId'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'initializeReferrerName'; - discriminator: [235, 126, 231, 10, 42, 164, 26, 61]; - accounts: [ - { - name: 'referrerName'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 114, - 101, - 102, - 101, - 114, - 114, - 101, - 114, - 95, - 110, - 97, - 109, - 101, - ]; - }, - { - kind: 'arg'; - path: 'name'; - }, - ]; - }; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'initializeRevenueShare'; - discriminator: [57, 9, 123, 131, 82, 52, 50, 13]; - accounts: [ - { - name: 'revenueShare'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [82, 69, 86, 95, 83, 72, 65, 82, 69]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'initializeRevenueShareEscrow'; - discriminator: [187, 18, 123, 88, 238, 104, 84, 154]; - accounts: [ - { - name: 'escrow'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - relations: ['userStats']; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'numOrders'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializeSerumFulfillmentConfig'; - discriminator: [193, 211, 132, 172, 70, 171, 7, 94]; - accounts: [ - { - name: 'baseSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'quoteSpotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'serumProgram'; - }, - { - name: 'serumMarket'; - }, - { - name: 'serumOpenOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 101, - 114, - 117, - 109, - 95, - 111, - 112, - 101, - 110, - 95, - 111, - 114, - 100, - 101, - 114, - 115, - ]; - }, - { - kind: 'account'; - path: 'serumMarket'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'serumFulfillmentConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 101, - 114, - 117, - 109, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - { - kind: 'account'; - path: 'serumMarket'; - }, - ]; - }; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializeSignedMsgUserOrders'; - discriminator: [164, 99, 156, 126, 156, 57, 99, 180]; - accounts: [ - { - name: 'signedMsgUserOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'numOrders'; - type: 'u16'; - }, - ]; - }, - { - name: 'initializeSignedMsgWsDelegates'; - discriminator: [40, 132, 96, 219, 184, 193, 80, 8]; - accounts: [ - { - name: 'signedMsgWsDelegates'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'delegates'; - type: { - vec: 'pubkey'; - }; - }, - ]; - }, - { - name: 'initializeSpotMarket'; - discriminator: [234, 196, 128, 44, 94, 15, 48, 201]; - accounts: [ - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'account'; - path: 'state.number_of_spot_markets'; - account: 'state'; - }, - ]; - }; - }, - { - name: 'spotMarketMint'; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'state.number_of_spot_markets'; - account: 'state'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'state.number_of_spot_markets'; - account: 'state'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'optimalUtilization'; - type: 'u32'; - }, - { - name: 'optimalBorrowRate'; - type: 'u32'; - }, - { - name: 'maxBorrowRate'; - type: 'u32'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'initialAssetWeight'; - type: 'u32'; - }, - { - name: 'maintenanceAssetWeight'; - type: 'u32'; - }, - { - name: 'initialLiabilityWeight'; - type: 'u32'; - }, - { - name: 'maintenanceLiabilityWeight'; - type: 'u32'; - }, - { - name: 'imfFactor'; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - type: 'u32'; - }, - { - name: 'activeStatus'; - type: 'bool'; - }, - { - name: 'assetTier'; - type: { - defined: { - name: 'assetTier'; - }; - }; - }, - { - name: 'scaleInitialAssetWeightStart'; - type: 'u64'; - }, - { - name: 'withdrawGuardThreshold'; - type: 'u64'; - }, - { - name: 'orderTickSize'; - type: 'u64'; - }, - { - name: 'orderStepSize'; - type: 'u64'; - }, - { - name: 'ifTotalFactor'; - type: 'u32'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'initializeUser'; - discriminator: [111, 17, 185, 250, 60, 122, 38, 254]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['userStats']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'initializeUserStats'; - discriminator: [254, 243, 72, 98, 251, 130, 168, 213]; - accounts: [ - { - name: 'userStats'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114, 95, 115, 116, 97, 116, 115]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'state'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'liquidateBorrowForPerpPnl'; - discriminator: [169, 17, 32, 90, 207, 148, 209, 27]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'liquidatorMaxLiabilityTransfer'; - type: 'u128'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'liquidatePerp'; - discriminator: [75, 35, 119, 247, 191, 18, 139, 2]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'liquidatorMaxBaseAssetAmount'; - type: 'u64'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'liquidatePerpPnlForDeposit'; - discriminator: [237, 75, 198, 235, 233, 186, 75, 35]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'liquidatorMaxPnlTransfer'; - type: 'u128'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'liquidatePerpWithFill'; - discriminator: [95, 111, 124, 105, 86, 169, 187, 34]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'liquidateSpot'; - discriminator: [107, 0, 128, 41, 35, 229, 251, 18]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: [ - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - { - name: 'liquidatorMaxLiabilityTransfer'; - type: 'u128'; - }, - { - name: 'limitPrice'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'liquidateSpotWithSwapBegin'; - discriminator: [12, 43, 176, 83, 156, 251, 117, 13]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'liabilitySpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'liabilityMarketIndex'; - }, - ]; - }; - }, - { - name: 'assetSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'assetMarketIndex'; - }, - ]; - }; - }, - { - name: 'liabilityTokenAccount'; - writable: true; - }, - { - name: 'assetTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - { - name: 'swapAmount'; - type: 'u64'; - }, - ]; - }, - { - name: 'liquidateSpotWithSwapEnd'; - discriminator: [142, 88, 163, 160, 223, 75, 55, 225]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'liabilitySpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'liabilityMarketIndex'; - }, - ]; - }; - }, - { - name: 'assetSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'assetMarketIndex'; - }, - ]; - }; - }, - { - name: 'liabilityTokenAccount'; - writable: true; - }, - { - name: 'assetTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - { - name: 'instructions'; - docs: ['Instructions Sysvar for instruction introspection']; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'logUserBalances'; - discriminator: [162, 21, 35, 251, 32, 57, 161, 210]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'lpPoolAddLiquidity'; - discriminator: [49, 135, 246, 103, 93, 146, 220, 141]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'inMarketMint'; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'userInTokenAccount'; - writable: true; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'userLpTokenAccount'; - writable: true; - }, - { - name: 'lpMint'; - writable: true; - }, - { - name: 'constituentTargetBase'; - }, - { - name: 'lpPoolTokenVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u128'; - }, - { - name: 'minMintAmount'; - type: 'u64'; - }, - ]; - }, - { - name: 'lpPoolRemoveLiquidity'; - discriminator: [164, 36, 193, 252, 196, 157, 138, 43]; - accounts: [ - { - name: 'state'; - }, - { - name: 'driftSigner'; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'outMarketMint'; - }, - { - name: 'outConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'userOutTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'userLpTokenAccount'; - writable: true; - }, - { - name: 'spotMarketTokenAccount'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpMint'; - writable: true; - }, - { - name: 'constituentTargetBase'; - }, - { - name: 'lpPoolTokenVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'tokenProgram'; - }, - { - name: 'ammCache'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - { - name: 'minOutAmount'; - type: 'u128'; - }, - ]; - }, - { - name: 'lpPoolSwap'; - discriminator: [36, 161, 39, 49, 227, 1, 35, 226]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - }, - { - name: 'constituentTargetBase'; - }, - { - name: 'constituentCorrelations'; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - writable: true; - }, - { - name: 'userInTokenAccount'; - writable: true; - }, - { - name: 'userOutTokenAccount'; - writable: true; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'inMarketMint'; - }, - { - name: 'outMarketMint'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - { - name: 'minOutAmount'; - type: 'u64'; - }, - ]; - }, - { - name: 'modifyOrder'; - discriminator: [47, 124, 117, 255, 201, 197, 130, 94]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'modifyOrderParams'; - type: { - defined: { - name: 'modifyOrderParams'; - }; - }; - }, - ]; - }, - { - name: 'modifyOrderByUserId'; - discriminator: [158, 77, 4, 253, 252, 194, 161, 179]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'userOrderId'; - type: 'u8'; - }, - { - name: 'modifyOrderParams'; - type: { - defined: { - name: 'modifyOrderParams'; - }; - }; - }, - ]; - }, - { - name: 'moveAmmPrice'; - discriminator: [235, 109, 2, 82, 219, 118, 6, 159]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'baseAssetReserve'; - type: 'u128'; - }, - { - name: 'quoteAssetReserve'; - type: 'u128'; - }, - { - name: 'sqrtK'; - type: 'u128'; - }, - ]; - }, - { - name: 'openbookV2FulfillmentConfigStatus'; - discriminator: [25, 173, 19, 189, 4, 211, 64, 238]; - accounts: [ - { - name: 'state'; - }, - { - name: 'openbookV2FulfillmentConfig'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - ]; - }, - { - name: 'overrideAmmCacheInfo'; - discriminator: [189, 198, 128, 9, 49, 145, 201, 115]; - accounts: [ - { - name: 'state'; - writable: true; - }, - { - name: 'admin'; - signer: true; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'overrideParams'; - type: { - defined: { - name: 'overrideAmmCacheParams'; - }; - }; - }, - ]; - }, - { - name: 'pauseSpotMarketDepositWithdraw'; - discriminator: [183, 119, 59, 170, 137, 35, 242, 86]; - accounts: [ - { - name: 'state'; - }, - { - name: 'keeper'; - signer: true; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'spotMarket'; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'phoenixFulfillmentConfigStatus'; - discriminator: [96, 31, 113, 32, 12, 203, 7, 154]; - accounts: [ - { - name: 'state'; - }, - { - name: 'phoenixFulfillmentConfig'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - ]; - }, - { - name: 'placeAndMakePerpOrder'; - discriminator: [149, 117, 11, 237, 47, 95, 89, 237]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'taker'; - writable: true; - }, - { - name: 'takerStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'takerOrderId'; - type: 'u32'; - }, - ]; - }, - { - name: 'placeAndMakeSignedMsgPerpOrder'; - discriminator: [16, 26, 123, 131, 94, 29, 175, 98]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'taker'; - writable: true; - }, - { - name: 'takerStats'; - writable: true; - }, - { - name: 'takerSignedMsgUserOrders'; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'taker'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'signedMsgOrderUuid'; - type: { - array: ['u8', 8]; - }; - }, - ]; - }, - { - name: 'placeAndMakeSpotOrder'; - discriminator: [149, 158, 85, 66, 239, 9, 243, 98]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'taker'; - writable: true; - }, - { - name: 'takerStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'takerOrderId'; - type: 'u32'; - }, - { - name: 'fulfillmentType'; - type: { - option: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }; - }, - ]; - }, - { - name: 'placeAndTakePerpOrder'; - discriminator: [213, 51, 1, 187, 108, 220, 230, 224]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'successCondition'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'placeAndTakeSpotOrder'; - discriminator: [191, 3, 138, 71, 114, 198, 202, 100]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'fulfillmentType'; - type: { - option: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }; - }, - { - name: 'makerOrderId'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'placeOrders'; - discriminator: [60, 63, 50, 123, 12, 197, 60, 190]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - vec: { - defined: { - name: 'orderParams'; - }; - }; - }; - }, - ]; - }, - { - name: 'placePerpOrder'; - discriminator: [69, 161, 93, 202, 120, 126, 76, 185]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - ]; - }, - { - name: 'placeSignedMsgTakerOrder'; - discriminator: [32, 79, 101, 139, 25, 6, 98, 15]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'signedMsgUserOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'user'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'ixSysvar'; - docs: [ - 'the supplied Sysvar could be anything else.', - 'The Instruction Sysvar has not been implemented', - 'in the Anchor framework yet, so this is the safe approach.', - ]; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'signedMsgOrderParamsMessageBytes'; - type: 'bytes'; - }, - { - name: 'isDelegateSigner'; - type: 'bool'; - }, - ]; - }, - { - name: 'placeSpotOrder'; - discriminator: [45, 79, 81, 160, 248, 90, 91, 220]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - ]; - }, - { - name: 'postMultiPythPullOracleUpdatesAtomic'; - discriminator: [243, 79, 204, 228, 227, 208, 100, 244]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'pythSolanaReceiver'; - address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; - }, - { - name: 'guardianSet'; - }, - ]; - args: [ - { - name: 'params'; - type: 'bytes'; - }, - ]; - }, - { - name: 'postPythLazerOracleUpdate'; - discriminator: [218, 237, 170, 245, 39, 143, 166, 33]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'pythLazerStorage'; - address: '3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL'; - }, - { - name: 'ixSysvar'; - address: 'Sysvar1nstructions1111111111111111111111111'; - }, - ]; - args: [ - { - name: 'pythMessage'; - type: 'bytes'; - }, - ]; - }, - { - name: 'postPythPullOracleUpdateAtomic'; - discriminator: [116, 122, 137, 158, 224, 195, 173, 119]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'pythSolanaReceiver'; - address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; - }, - { - name: 'guardianSet'; - }, - { - name: 'priceFeed'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; - }, - { - kind: 'arg'; - path: 'feedId'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'feedId'; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'params'; - type: 'bytes'; - }, - ]; - }, - { - name: 'recenterPerpMarketAmm'; - discriminator: [24, 87, 10, 115, 165, 190, 80, 139]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'pegMultiplier'; - type: 'u128'; - }, - { - name: 'sqrtK'; - type: 'u128'; - }, - ]; - }, - { - name: 'recenterPerpMarketAmmCrank'; - discriminator: [166, 19, 64, 10, 14, 51, 101, 122]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'spotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'account'; - path: 'perpMarket'; - }, - ]; - }; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'depth'; - type: { - option: 'u128'; - }; - }, - ]; - }, - { - name: 'reclaimRent'; - discriminator: [218, 200, 19, 197, 227, 89, 192, 22]; - accounts: [ - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - relations: ['user', 'userStats']; - }, - { - name: 'rent'; - address: 'SysvarRent111111111111111111111111111111111'; - }, - ]; - args: []; - }, - { - name: 'removeAmmConstituentMappingData'; - discriminator: [20, 183, 211, 162, 16, 52, 229, 115]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - }, - { - name: 'ammConstituentMapping'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [65, 77, 77, 95, 77, 65, 80]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'removeInsuranceFundStake'; - discriminator: [128, 166, 142, 9, 254, 187, 143, 174]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['insuranceFundStake', 'userStats']; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'repegAmmCurve'; - discriminator: [3, 36, 102, 89, 180, 128, 120, 213]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - ]; - args: [ - { - name: 'newPegCandidate'; - type: 'u128'; - }, - ]; - }, - { - name: 'requestRemoveInsuranceFundStake'; - discriminator: [142, 70, 204, 92, 73, 106, 180, 52]; - accounts: [ - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['insuranceFundStake', 'userStats']; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'resetFuelSeason'; - discriminator: [199, 122, 192, 255, 32, 99, 63, 200]; - accounts: [ - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - relations: ['userStats']; - }, - { - name: 'state'; - }, - { - name: 'admin'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'resetPerpMarketAmmOracleTwap'; - discriminator: [127, 10, 55, 164, 123, 226, 47, 24]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - ]; - args: []; - }, - { - name: 'resizeRevenueShareEscrowOrders'; - discriminator: [32, 124, 247, 225, 151, 213, 225, 38]; - accounts: [ - { - name: 'escrow'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - relations: ['escrow']; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'numOrders'; - type: 'u16'; - }, - ]; - }, - { - name: 'resizeSignedMsgUserOrders'; - discriminator: [137, 10, 87, 150, 18, 115, 79, 168]; - accounts: [ - { - name: 'signedMsgUserOrders'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; - }, - { - kind: 'account'; - path: 'authority'; - }, - ]; - }; - }, - { - name: 'authority'; - relations: ['user']; - }, - { - name: 'user'; - }, - { - name: 'payer'; - writable: true; - signer: true; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'numOrders'; - type: 'u16'; - }, - ]; - }, - { - name: 'resolvePerpBankruptcy'; - discriminator: [224, 16, 176, 214, 162, 213, 183, 222]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'quoteSpotMarketIndex'; - type: 'u16'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'resolvePerpPnlDeficit'; - discriminator: [168, 204, 68, 150, 159, 126, 95, 148]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'resolveSpotBankruptcy'; - discriminator: [124, 194, 240, 254, 198, 213, 52, 122]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'liquidator'; - writable: true; - }, - { - name: 'liquidatorStats'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'spotMarketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'revertFill'; - discriminator: [236, 238, 176, 69, 239, 10, 181, 193]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'fillerStats'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'setUserStatusToBeingLiquidated'; - discriminator: [106, 133, 160, 206, 193, 171, 192, 194]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'settleExpiredMarket'; - discriminator: [120, 89, 11, 25, 122, 77, 72, 193]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'settleExpiredMarketPoolsToRevenuePool'; - discriminator: [55, 19, 238, 169, 227, 90, 200, 184]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'settleFundingPayment'; - discriminator: [222, 90, 202, 94, 28, 45, 115, 183]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'settleMultiplePnls'; - discriminator: [127, 66, 117, 57, 40, 50, 152, 127]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndexes'; - type: { - vec: 'u16'; - }; - }, - { - name: 'mode'; - type: { - defined: { - name: 'settlePnlMode'; - }; - }; - }, - ]; - }, - { - name: 'settlePerpToLpPool'; - discriminator: [5, 98, 46, 188, 10, 59, 2, 249]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'ammCache'; - writable: true; - }, - { - name: 'quoteMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'constituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'constituentQuoteTokenAccount'; - writable: true; - }, - { - name: 'quoteTokenVault'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - ]; - args: []; - }, - { - name: 'settlePnl'; - discriminator: [43, 61, 234, 45, 15, 95, 152, 153]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'settleRevenueToInsuranceFund'; - discriminator: [200, 120, 93, 136, 69, 38, 199, 159]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'sweepFuel'; - discriminator: [175, 107, 19, 56, 165, 241, 43, 69]; - accounts: [ - { - name: 'fuelOverflow'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - relations: ['fuelOverflow', 'userStats']; - }, - { - name: 'signer'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'transferDeposit'; - discriminator: [20, 20, 147, 223, 41, 63, 204, 111]; - accounts: [ - { - name: 'fromUser'; - writable: true; - }, - { - name: 'toUser'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['fromUser', 'toUser', 'userStats']; - }, - { - name: 'state'; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'transferPerpPosition'; - discriminator: [23, 172, 188, 168, 134, 210, 3, 108]; - accounts: [ - { - name: 'fromUser'; - writable: true; - }, - { - name: 'toUser'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: { - option: 'i64'; - }; - }, - ]; - }, - { - name: 'transferPools'; - discriminator: [197, 103, 154, 25, 107, 90, 60, 94]; - accounts: [ - { - name: 'fromUser'; - writable: true; - }, - { - name: 'toUser'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['fromUser', 'toUser', 'userStats']; - }, - { - name: 'state'; - }, - { - name: 'depositFromSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'depositFromMarketIndex'; - }, - ]; - }; - }, - { - name: 'depositToSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'depositToMarketIndex'; - }, - ]; - }; - }, - { - name: 'borrowFromSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'borrowFromMarketIndex'; - }, - ]; - }; - }, - { - name: 'borrowToSpotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'borrowToMarketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - ]; - args: [ - { - name: 'depositFromMarketIndex'; - type: 'u16'; - }, - { - name: 'depositToMarketIndex'; - type: 'u16'; - }, - { - name: 'borrowFromMarketIndex'; - type: 'u16'; - }, - { - name: 'borrowToMarketIndex'; - type: 'u16'; - }, - { - name: 'depositAmount'; - type: { - option: 'u64'; - }; - }, - { - name: 'borrowAmount'; - type: { - option: 'u64'; - }; - }, - ]; - }, - { - name: 'transferProtocolIfSharesToRevenuePool'; - discriminator: [236, 136, 147, 153, 146, 205, 104, 29]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - writable: true; - signer: true; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'driftSigner'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'triggerOrder'; - discriminator: [63, 112, 51, 233, 232, 47, 240, 199]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: [ - { - name: 'orderId'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateAdmin'; - discriminator: [161, 176, 40, 213, 60, 184, 179, 228]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'admin'; - type: 'pubkey'; - }, - ]; - }, - { - name: 'updateAmmCache'; - discriminator: [88, 4, 63, 94, 83, 224, 255, 130]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'ammCache'; - writable: true; - }, - { - name: 'quoteMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateAmmConstituentMappingData'; - discriminator: [84, 70, 33, 167, 133, 107, 59, 24]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - }, - { - name: 'ammConstituentMapping'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [65, 77, 77, 95, 77, 65, 80]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'ammConstituentMappingData'; - type: { - vec: { - defined: { - name: 'addAmmConstituentMappingDatum'; - }; - }; - }; - }, - ]; - }, - { - name: 'updateAmmJitIntensity'; - discriminator: [181, 191, 53, 109, 166, 249, 55, 142]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'ammJitIntensity'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateAmms'; - discriminator: [201, 106, 217, 253, 4, 175, 228, 97]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'marketIndexes'; - type: { - vec: 'u16'; - }; - }, - ]; - }, - { - name: 'updateConstituentCorrelationData'; - discriminator: [79, 14, 19, 73, 221, 106, 62, 109]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - }, - { - name: 'constituentCorrelations'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'index1'; - type: 'u16'; - }, - { - name: 'index2'; - type: 'u16'; - }, - { - name: 'correlation'; - type: 'i64'; - }, - ]; - }, - { - name: 'updateConstituentOracleInfo'; - discriminator: [198, 117, 231, 250, 147, 33, 127, 161]; - accounts: [ - { - name: 'state'; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'constituent'; - writable: true; - }, - { - name: 'spotMarket'; - }, - { - name: 'oracle'; - }, - ]; - args: []; - }, - { - name: 'updateConstituentParams'; - discriminator: [238, 130, 122, 31, 12, 104, 192, 122]; - accounts: [ - { - name: 'lpPool'; - }, - { - name: 'constituentTargetBase'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - ]; - }; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'constituent'; - writable: true; - }, - ]; - args: [ - { - name: 'constituentParams'; - type: { - defined: { - name: 'constituentParams'; - }; - }; - }, - ]; - }, - { - name: 'updateConstituentPausedOperations'; - discriminator: [185, 122, 153, 191, 131, 177, 132, 208]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'constituent'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateConstituentStatus'; - discriminator: [76, 159, 211, 239, 182, 214, 6, 15]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'constituent'; - writable: true; - }, - ]; - args: [ - { - name: 'newStatus'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateDelegateUserGovTokenInsuranceStake'; - discriminator: [241, 29, 215, 228, 142, 116, 22, 160]; - accounts: [ - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [15, 0]; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [15, 0]; - }, - ]; - }; - }, - { - name: 'state'; - }, - ]; - args: []; - }, - { - name: 'updateDiscountMint'; - discriminator: [32, 252, 122, 211, 66, 31, 47, 241]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'discountMint'; - type: 'pubkey'; - }, - ]; - }, - { - name: 'updateExchangeStatus'; - discriminator: [83, 160, 252, 250, 129, 116, 49, 223]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'exchangeStatus'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsBuilderCodes'; - discriminator: [1, 128, 177, 51, 173, 45, 11, 102]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsMedianTriggerPrice'; - discriminator: [64, 185, 221, 45, 87, 147, 12, 19]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsMintRedeemLpPool'; - discriminator: [26, 11, 142, 122, 206, 159, 9, 45]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsMmOracle'; - discriminator: [218, 134, 33, 186, 231, 59, 130, 149]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsSettleLpPool'; - discriminator: [186, 28, 78, 230, 155, 83, 242, 26]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFeatureBitFlagsSwapLpPool'; - discriminator: [83, 16, 150, 12, 102, 3, 22, 58]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'enable'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateFundingRate'; - discriminator: [201, 178, 116, 212, 166, 144, 72, 238]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateHighLeverageModeConfig'; - discriminator: [64, 122, 212, 93, 141, 217, 202, 55]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'highLeverageModeConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 104, - 105, - 103, - 104, - 95, - 108, - 101, - 118, - 101, - 114, - 97, - 103, - 101, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - ]; - }; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - { - name: 'currentUsers'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'updateIfRebalanceConfig'; - discriminator: [142, 245, 249, 66, 249, 181, 22, 83]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'ifRebalanceConfig'; - writable: true; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'ifRebalanceConfigParams'; - }; - }; - }, - ]; - }, - { - name: 'updateInitialAmmCacheInfo'; - discriminator: [157, 210, 109, 67, 212, 170, 12, 107]; - accounts: [ - { - name: 'state'; - writable: true; - }, - { - name: 'admin'; - signer: true; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateInitialPctToLiquidate'; - discriminator: [210, 133, 225, 128, 194, 50, 13, 109]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'initialPctToLiquidate'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateInsuranceFundUnstakingPeriod'; - discriminator: [44, 69, 43, 226, 204, 223, 202, 52]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'insuranceFundUnstakingPeriod'; - type: 'i64'; - }, - ]; - }, - { - name: 'updateK'; - discriminator: [72, 98, 9, 139, 129, 229, 172, 56]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'sqrtK'; - type: 'u128'; - }, - ]; - }, - { - name: 'updateLiquidationDuration'; - discriminator: [28, 154, 20, 249, 102, 192, 73, 71]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'liquidationDuration'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateLiquidationMarginBufferRatio'; - discriminator: [132, 224, 243, 160, 154, 82, 97, 215]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'liquidationMarginBufferRatio'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateLpConstituentTargetBase'; - discriminator: [157, 65, 50, 207, 59, 236, 161, 110]; - accounts: [ - { - name: 'state'; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'ammConstituentMapping'; - }, - { - name: 'constituentTargetBase'; - writable: true; - }, - { - name: 'ammCache'; - }, - { - name: 'lpPool'; - }, - ]; - args: []; - }, - { - name: 'updateLpPoolAum'; - discriminator: [88, 113, 137, 206, 246, 247, 171, 142]; - accounts: [ - { - name: 'state'; - }, - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'lpPool'; - writable: true; - }, - { - name: 'constituentTargetBase'; - writable: true; - }, - { - name: 'ammCache'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'updateLpPoolParams'; - discriminator: [217, 92, 2, 255, 27, 167, 178, 81]; - accounts: [ - { - name: 'lpPool'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'lpPoolParams'; - type: { - defined: { - name: 'lpPoolParams'; - }; - }; - }, - ]; - }, - { - name: 'updateOracleGuardRails'; - discriminator: [131, 112, 10, 59, 32, 54, 40, 164]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'oracleGuardRails'; - type: { - defined: { - name: 'oracleGuardRails'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpAuctionDuration'; - discriminator: [126, 110, 52, 174, 30, 206, 215, 90]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'minPerpAuctionDuration'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpBidAskTwap'; - discriminator: [247, 23, 255, 65, 212, 90, 221, 194]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'keeperStats'; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: []; - }, - { - name: 'updatePerpFeeStructure'; - discriminator: [23, 178, 111, 203, 73, 22, 140, 75]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'feeStructure'; - type: { - defined: { - name: 'feeStructure'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpMarketAmmOracleTwap'; - discriminator: [241, 74, 114, 123, 206, 153, 24, 202]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - ]; - args: []; - }, - { - name: 'updatePerpMarketAmmSpreadAdjustment'; - discriminator: [155, 195, 149, 43, 220, 82, 173, 205]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'ammSpreadAdjustment'; - type: 'i8'; - }, - { - name: 'ammInventorySpreadAdjustment'; - type: 'i8'; - }, - { - name: 'referencePriceOffset'; - type: 'i32'; - }, - ]; - }, - { - name: 'updatePerpMarketAmmSummaryStats'; - discriminator: [122, 101, 249, 238, 209, 9, 241, 245]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'spotMarket'; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'account'; - path: 'perpMarket'; - }, - ]; - }; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'updatePerpMarketSummaryStatsParams'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpMarketBaseSpread'; - discriminator: [71, 95, 84, 168, 9, 157, 198, 65]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'baseSpread'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketConcentrationCoef'; - discriminator: [24, 78, 232, 126, 169, 176, 230, 16]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'concentrationScale'; - type: 'u128'; - }, - ]; - }, - { - name: 'updatePerpMarketContractTier'; - discriminator: [236, 128, 15, 95, 203, 214, 68, 117]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'contractTier'; - type: { - defined: { - name: 'contractTier'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpMarketCurveUpdateIntensity'; - discriminator: [50, 131, 6, 156, 226, 231, 189, 72]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'curveUpdateIntensity'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketExpiry'; - discriminator: [44, 221, 227, 151, 131, 140, 22, 110]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'expiryTs'; - type: 'i64'; - }, - ]; - }, - { - name: 'updatePerpMarketFeeAdjustment'; - discriminator: [194, 174, 87, 102, 43, 148, 32, 112]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'feeAdjustment'; - type: 'i16'; - }, - ]; - }, - { - name: 'updatePerpMarketFundingPeriod'; - discriminator: [171, 161, 69, 91, 129, 139, 161, 28]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'fundingPeriod'; - type: 'i64'; - }, - ]; - }, - { - name: 'updatePerpMarketHighLeverageMarginRatio'; - discriminator: [88, 112, 86, 49, 24, 116, 74, 157]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'marginRatioInitial'; - type: 'u16'; - }, - { - name: 'marginRatioMaintenance'; - type: 'u16'; - }, - ]; - }, - { - name: 'updatePerpMarketImfFactor'; - discriminator: [207, 194, 56, 132, 35, 67, 71, 244]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'imfFactor'; - type: 'u32'; - }, - { - name: 'unrealizedPnlImfFactor'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketLiquidationFee'; - discriminator: [90, 137, 9, 145, 41, 8, 148, 117]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'liquidatorFee'; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketLpPoolFeeTransferScalar'; - discriminator: [94, 228, 237, 109, 100, 185, 4, 81]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'optionalLpFeeTransferScalar'; - type: { - option: 'u8'; - }; - }, - { - name: 'optionalLpNetPnlTransferScalar'; - type: { - option: 'u8'; - }; - }, - ]; - }, - { - name: 'updatePerpMarketLpPoolId'; - discriminator: [119, 208, 154, 88, 165, 92, 21, 188]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'lpPoolId'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketLpPoolPausedOperations'; - discriminator: [181, 94, 93, 146, 51, 89, 32, 135]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'lpPausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketLpPoolStatus'; - discriminator: [67, 6, 252, 61, 54, 88, 89, 233]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'lpStatus'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketMarginRatio'; - discriminator: [130, 173, 107, 45, 119, 105, 26, 113]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'marginRatioInitial'; - type: 'u32'; - }, - { - name: 'marginRatioMaintenance'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxFillReserveFraction'; - discriminator: [19, 172, 114, 154, 42, 135, 161, 133]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxFillReserveFraction'; - type: 'u16'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxImbalances'; - discriminator: [15, 206, 73, 133, 60, 8, 86, 89]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'unrealizedMaxImbalance'; - type: 'u64'; - }, - { - name: 'maxRevenueWithdrawPerPeriod'; - type: 'u64'; - }, - { - name: 'quoteMaxInsurance'; - type: 'u64'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxOpenInterest'; - discriminator: [194, 79, 149, 224, 246, 102, 186, 140]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxOpenInterest'; - type: 'u128'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxSlippageRatio'; - discriminator: [235, 37, 40, 196, 70, 146, 54, 201]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxSlippageRatio'; - type: 'u16'; - }, - ]; - }, - { - name: 'updatePerpMarketMaxSpread'; - discriminator: [80, 252, 122, 62, 40, 218, 91, 100]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxSpread'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePerpMarketMinOrderSize'; - discriminator: [226, 74, 5, 89, 108, 223, 46, 141]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'orderSize'; - type: 'u64'; - }, - ]; - }, - { - name: 'updatePerpMarketName'; - discriminator: [211, 31, 21, 210, 64, 108, 66, 201]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'updatePerpMarketNumberOfUsers'; - discriminator: [35, 62, 144, 177, 180, 62, 215, 196]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'numberOfUsers'; - type: { - option: 'u32'; - }; - }, - { - name: 'numberOfUsersWithBase'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'updatePerpMarketOracle'; - discriminator: [182, 113, 111, 160, 67, 174, 89, 191]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'oldOracle'; - }, - { - name: 'ammCache'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100, - ]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'oracle'; - type: 'pubkey'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'skipInvariantCheck'; - type: 'bool'; - }, - ]; - }, - { - name: 'updatePerpMarketOracleLowRiskSlotDelayOverride'; - discriminator: [124, 108, 147, 229, 109, 117, 123, 3]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'oracleLowRiskSlotDelayOverride'; - type: 'i8'; - }, - ]; - }, - { - name: 'updatePerpMarketOracleSlotDelayOverride'; - discriminator: [165, 91, 239, 227, 63, 172, 227, 8]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'oracleSlotDelayOverride'; - type: 'i8'; - }, - ]; - }, - { - name: 'updatePerpMarketPausedOperations'; - discriminator: [53, 16, 136, 132, 30, 220, 121, 85]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketPnlPool'; - discriminator: [50, 202, 249, 224, 166, 184, 13, 143]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'updatePerpMarketProtectedMakerParams'; - discriminator: [249, 213, 115, 34, 253, 239, 75, 173]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'protectedMakerLimitPriceDivisor'; - type: { - option: 'u8'; - }; - }, - { - name: 'protectedMakerDynamicDivisor'; - type: { - option: 'u8'; - }; - }, - ]; - }, - { - name: 'updatePerpMarketReferencePriceOffsetDeadbandPct'; - discriminator: [214, 73, 166, 11, 218, 76, 110, 163]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'referencePriceOffsetDeadbandPct'; - type: 'u8'; - }, - ]; - }, - { - name: 'updatePerpMarketStatus'; - discriminator: [71, 201, 175, 122, 255, 207, 196, 207]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'marketStatus'; - }; - }; - }, - ]; - }, - { - name: 'updatePerpMarketStepSizeAndTickSize'; - discriminator: [231, 255, 97, 25, 146, 139, 174, 4]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'stepSize'; - type: 'u64'; - }, - { - name: 'tickSize'; - type: 'u64'; - }, - ]; - }, - { - name: 'updatePerpMarketUnrealizedAssetWeight'; - discriminator: [135, 132, 205, 165, 109, 150, 166, 106]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'unrealizedInitialAssetWeight'; - type: 'u32'; - }, - { - name: 'unrealizedMaintenanceAssetWeight'; - type: 'u32'; - }, - ]; - }, - { - name: 'updatePrelaunchOracle'; - discriminator: [220, 132, 27, 27, 233, 220, 61, 219]; - accounts: [ - { - name: 'state'; - }, - { - name: 'perpMarket'; - }, - { - name: 'oracle'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'updatePrelaunchOracleParams'; - discriminator: [98, 205, 147, 243, 18, 75, 83, 207]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'prelaunchOracle'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101, - ]; - }, - { - kind: 'arg'; - path: 'params.perp_market_index'; - }, - ]; - }; - }, - { - name: 'perpMarket'; - writable: true; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'params'; - type: { - defined: { - name: 'prelaunchOracleParams'; - }; - }; - }, - ]; - }, - { - name: 'updateProtectedMakerModeConfig'; - discriminator: [86, 166, 235, 253, 67, 202, 223, 17]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - { - name: 'protectedMakerModeConfig'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 112, - 114, - 111, - 116, - 101, - 99, - 116, - 101, - 100, - 95, - 109, - 97, - 107, - 101, - 114, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103, - ]; - }, - ]; - }; - }, - { - name: 'state'; - }, - ]; - args: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - { - name: 'currentUsers'; - type: { - option: 'u32'; - }; - }, - ]; - }, - { - name: 'updatePythPullOracle'; - discriminator: [230, 191, 189, 94, 108, 59, 74, 197]; - accounts: [ - { - name: 'keeper'; - writable: true; - signer: true; - }, - { - name: 'pythSolanaReceiver'; - address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; - }, - { - name: 'encodedVaa'; - }, - { - name: 'priceFeed'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; - }, - { - kind: 'arg'; - path: 'feedId'; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'feedId'; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'params'; - type: 'bytes'; - }, - ]; - }, - { - name: 'updateSerumFulfillmentConfigStatus'; - discriminator: [171, 109, 240, 251, 95, 1, 149, 89]; - accounts: [ - { - name: 'state'; - }, - { - name: 'serumFulfillmentConfig'; - writable: true; - }, - { - name: 'admin'; - writable: true; - signer: true; - relations: ['state']; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - ]; - }, - { - name: 'updateSpotAuctionDuration'; - discriminator: [182, 178, 203, 72, 187, 143, 157, 107]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'defaultSpotAuctionDuration'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateSpotFeeStructure'; - discriminator: [97, 216, 105, 131, 113, 246, 142, 141]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'feeStructure'; - type: { - defined: { - name: 'feeStructure'; - }; - }; - }, - ]; - }, - { - name: 'updateSpotMarketAssetTier'; - discriminator: [253, 209, 231, 14, 242, 208, 243, 130]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'assetTier'; - type: { - defined: { - name: 'assetTier'; - }; - }; - }, - ]; - }, - { - name: 'updateSpotMarketBorrowRate'; - discriminator: [71, 239, 236, 153, 210, 62, 254, 76]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'optimalUtilization'; - type: 'u32'; - }, - { - name: 'optimalBorrowRate'; - type: 'u32'; - }, - { - name: 'maxBorrowRate'; - type: 'u32'; - }, - { - name: 'minBorrowRate'; - type: { - option: 'u8'; - }; - }, - ]; - }, - { - name: 'updateSpotMarketCumulativeInterest'; - discriminator: [39, 166, 139, 243, 158, 165, 155, 225]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'spotMarketVault'; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'account'; - path: 'spotMarket'; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateSpotMarketExpiry'; - discriminator: [208, 11, 211, 159, 226, 24, 11, 247]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'expiryTs'; - type: 'i64'; - }, - ]; - }, - { - name: 'updateSpotMarketFeeAdjustment'; - discriminator: [148, 182, 3, 126, 157, 114, 220, 99]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'feeAdjustment'; - type: 'i16'; - }, - ]; - }, - { - name: 'updateSpotMarketIfFactor'; - discriminator: [147, 30, 224, 34, 18, 230, 105, 4]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'userIfFactor'; - type: 'u32'; - }, - { - name: 'totalIfFactor'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateSpotMarketIfPausedOperations'; - discriminator: [101, 215, 79, 74, 59, 41, 79, 12]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateSpotMarketLiquidationFee'; - discriminator: [11, 13, 255, 53, 56, 136, 104, 177]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'liquidatorFee'; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateSpotMarketMarginWeights'; - discriminator: [109, 33, 87, 195, 255, 36, 6, 81]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'initialAssetWeight'; - type: 'u32'; - }, - { - name: 'maintenanceAssetWeight'; - type: 'u32'; - }, - { - name: 'initialLiabilityWeight'; - type: 'u32'; - }, - { - name: 'maintenanceLiabilityWeight'; - type: 'u32'; - }, - { - name: 'imfFactor'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateSpotMarketMaxTokenBorrows'; - discriminator: [57, 102, 204, 212, 253, 95, 13, 199]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxTokenBorrowsFraction'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateSpotMarketMaxTokenDeposits'; - discriminator: [56, 191, 79, 18, 26, 121, 80, 208]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'maxTokenDeposits'; - type: 'u64'; - }, - ]; - }, - { - name: 'updateSpotMarketMinOrderSize'; - discriminator: [93, 128, 11, 119, 26, 20, 181, 50]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'orderSize'; - type: 'u64'; - }, - ]; - }, - { - name: 'updateSpotMarketName'; - discriminator: [17, 208, 1, 1, 162, 211, 188, 224]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'updateSpotMarketOracle'; - discriminator: [114, 184, 102, 37, 246, 186, 180, 99]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'oracle'; - }, - { - name: 'oldOracle'; - }, - ]; - args: [ - { - name: 'oracle'; - type: 'pubkey'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'skipInvariantCheck'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateSpotMarketOrdersEnabled'; - discriminator: [190, 79, 206, 15, 26, 229, 229, 43]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'ordersEnabled'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateSpotMarketPausedOperations'; - discriminator: [100, 61, 153, 81, 180, 12, 6, 248]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'pausedOperations'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateSpotMarketPoolId'; - discriminator: [22, 213, 197, 160, 139, 193, 81, 149]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'poolId'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateSpotMarketRevenueSettlePeriod'; - discriminator: [81, 92, 126, 41, 250, 225, 156, 219]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'revenueSettlePeriod'; - type: 'i64'; - }, - ]; - }, - { - name: 'updateSpotMarketScaleInitialAssetWeightStart'; - discriminator: [217, 204, 204, 118, 204, 130, 225, 147]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'scaleInitialAssetWeightStart'; - type: 'u64'; - }, - ]; - }, - { - name: 'updateSpotMarketStatus'; - discriminator: [78, 94, 16, 188, 193, 110, 231, 31]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'status'; - type: { - defined: { - name: 'marketStatus'; - }; - }; - }, - ]; - }, - { - name: 'updateSpotMarketStepSizeAndTickSize'; - discriminator: [238, 153, 137, 80, 206, 59, 250, 61]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'stepSize'; - type: 'u64'; - }, - { - name: 'tickSize'; - type: 'u64'; - }, - ]; - }, - { - name: 'updateStateMaxInitializeUserFee'; - discriminator: [237, 225, 25, 237, 193, 45, 77, 97]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'maxInitializeUserFee'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateStateMaxNumberOfSubAccounts'; - discriminator: [155, 123, 214, 2, 221, 166, 204, 85]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'maxNumberOfSubAccounts'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateStateSettlementDuration'; - discriminator: [97, 68, 199, 235, 131, 80, 61, 173]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - writable: true; - }, - ]; - args: [ - { - name: 'settlementDuration'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateUserCustomMarginRatio'; - discriminator: [21, 221, 140, 187, 32, 129, 11, 123]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'marginRatio'; - type: 'u32'; - }, - ]; - }, - { - name: 'updateUserDelegate'; - discriminator: [139, 205, 141, 141, 113, 36, 94, 187]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'delegate'; - type: 'pubkey'; - }, - ]; - }, - { - name: 'updateUserGovTokenInsuranceStake'; - discriminator: [143, 99, 235, 187, 20, 159, 184, 84]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [15, 0]; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'signer'; - signer: true; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [15, 0]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateUserIdle'; - discriminator: [253, 133, 67, 22, 103, 161, 20, 100]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'filler'; - writable: true; - }, - { - name: 'user'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'updateUserMarginTradingEnabled'; - discriminator: [194, 92, 204, 223, 246, 188, 31, 203]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'marginTradingEnabled'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateUserName'; - discriminator: [135, 25, 185, 56, 165, 53, 34, 136]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }, - { - name: 'updateUserPerpPositionCustomMarginRatio'; - discriminator: [121, 137, 157, 155, 89, 186, 145, 113]; - accounts: [ - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'marginRatio'; - type: 'u16'; - }, - ]; - }, - { - name: 'updateUserPoolId'; - discriminator: [219, 86, 73, 106, 56, 218, 128, 109]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'poolId'; - type: 'u8'; - }, - ]; - }, - { - name: 'updateUserProtectedMakerOrders'; - discriminator: [114, 39, 123, 198, 187, 25, 90, 219]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'protectedMakerModeConfig'; - writable: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'protectedMakerOrders'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateUserQuoteAssetInsuranceStake'; - discriminator: [251, 101, 156, 7, 2, 63, 30, 23]; - accounts: [ - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'signer'; - signer: true; - }, - { - name: 'insuranceFundVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'const'; - value: [0, 0]; - }, - ]; - }; - }, - ]; - args: []; - }, - { - name: 'updateUserReduceOnly'; - discriminator: [199, 71, 42, 67, 144, 19, 86, 109]; - accounts: [ - { - name: 'user'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [117, 115, 101, 114]; - }, - { - kind: 'account'; - path: 'authority'; - }, - { - kind: 'arg'; - path: 'subAccountId'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - ]; - args: [ - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - ]; - }, - { - name: 'updateUserStatsReferrerStatus'; - discriminator: [174, 154, 72, 42, 191, 148, 145, 205]; - accounts: [ - { - name: 'state'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'userStats'; - writable: true; - }, - ]; - args: []; - }, - { - name: 'updateWithdrawGuardThreshold'; - discriminator: [56, 18, 39, 61, 155, 211, 44, 133]; - accounts: [ - { - name: 'admin'; - signer: true; - relations: ['state']; - }, - { - name: 'state'; - }, - { - name: 'spotMarket'; - writable: true; - }, - ]; - args: [ - { - name: 'withdrawGuardThreshold'; - type: 'u64'; - }, - ]; - }, - { - name: 'viewLpPoolAddLiquidityFees'; - discriminator: [80, 66, 226, 161, 70, 142, 119, 84]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'inMarketMint'; - }, - { - name: 'inConstituent'; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpMint'; - }, - { - name: 'constituentTargetBase'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u128'; - }, - ]; - }, - { - name: 'viewLpPoolRemoveLiquidityFees'; - discriminator: [47, 12, 9, 102, 12, 226, 197, 89]; - accounts: [ - { - name: 'state'; - }, - { - name: 'lpPool'; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'outMarketMint'; - }, - { - name: 'outConstituent'; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'lpMint'; - }, - { - name: 'constituentTargetBase'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - ]; - }, - { - name: 'viewLpPoolSwapFees'; - discriminator: [126, 189, 109, 189, 170, 156, 3, 46]; - accounts: [ - { - name: 'driftSigner'; - }, - { - name: 'state'; - }, - { - name: 'lpPool'; - }, - { - name: 'constituentTargetBase'; - }, - { - name: 'constituentCorrelations'; - }, - { - name: 'constituentInTokenAccount'; - writable: true; - }, - { - name: 'constituentOutTokenAccount'; - writable: true; - }, - { - name: 'inConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'inMarketIndex'; - }, - ]; - }; - }, - { - name: 'outConstituent'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; - }, - { - kind: 'account'; - path: 'lpPool'; - }, - { - kind: 'arg'; - path: 'outMarketIndex'; - }, - ]; - }; - }, - { - name: 'authority'; - signer: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - { - name: 'inTargetWeight'; - type: 'i64'; - }, - { - name: 'outTargetWeight'; - type: 'i64'; - }, - ]; - }, - { - name: 'withdraw'; - discriminator: [183, 18, 70, 156, 148, 109, 161, 34]; - accounts: [ - { - name: 'state'; - }, - { - name: 'user'; - writable: true; - }, - { - name: 'userStats'; - writable: true; - }, - { - name: 'authority'; - signer: true; - relations: ['user', 'userStats']; - }, - { - name: 'spotMarketVault'; - writable: true; - pda: { - seeds: [ - { - kind: 'const'; - value: [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116, - ]; - }, - { - kind: 'arg'; - path: 'marketIndex'; - }, - ]; - }; - }, - { - name: 'driftSigner'; - }, - { - name: 'userTokenAccount'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - ]; - args: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - ]; - }, - { - name: 'withdrawFromProgramVault'; - discriminator: [120, 40, 183, 149, 232, 18, 224, 151]; - accounts: [ - { - name: 'state'; - }, - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'driftSigner'; - }, - { - name: 'constituent'; - writable: true; - }, - { - name: 'constituentTokenAccount'; - writable: true; - }, - { - name: 'spotMarket'; - writable: true; - }, - { - name: 'spotMarketVault'; - writable: true; - }, - { - name: 'tokenProgram'; - }, - { - name: 'mint'; - }, - { - name: 'oracle'; - }, - ]; - args: [ - { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - { - name: 'zeroMmOracleFields'; - discriminator: [192, 226, 39, 204, 207, 120, 148, 250]; - accounts: [ - { - name: 'admin'; - signer: true; - }, - { - name: 'state'; - }, - { - name: 'perpMarket'; - writable: true; - }, - ]; - args: []; - }, - ]; - accounts: [ - { - name: 'ammCache'; - discriminator: [213, 114, 161, 56, 20, 22, 2, 59]; - }, - { - name: 'ammConstituentMapping'; - discriminator: [254, 89, 5, 173, 66, 54, 214, 247]; - }, - { - name: 'constituent'; - discriminator: [0, 61, 36, 35, 177, 76, 216, 205]; - }, - { - name: 'constituentCorrelations'; - discriminator: [124, 203, 115, 33, 18, 162, 67, 216]; - }, - { - name: 'constituentTargetBase'; - discriminator: [255, 142, 134, 71, 125, 66, 198, 99]; - }, - { - name: 'fuelOverflow'; - discriminator: [182, 64, 231, 177, 226, 142, 69, 58]; - }, - { - name: 'highLeverageModeConfig'; - discriminator: [3, 196, 90, 189, 193, 64, 228, 234]; - }, - { - name: 'ifRebalanceConfig'; - discriminator: [214, 84, 40, 251, 107, 144, 173, 239]; - }, - { - name: 'insuranceFundStake'; - discriminator: [110, 202, 14, 42, 95, 73, 90, 95]; - }, - { - name: 'lpPool'; - discriminator: [228, 152, 141, 224, 161, 170, 11, 89]; - }, - { - name: 'openbookV2FulfillmentConfig'; - discriminator: [3, 43, 58, 106, 131, 132, 199, 171]; - }, - { - name: 'perpMarket'; - discriminator: [10, 223, 12, 44, 107, 245, 55, 247]; - }, - { - name: 'phoenixV1FulfillmentConfig'; - discriminator: [233, 45, 62, 40, 35, 129, 48, 72]; - }, - { - name: 'prelaunchOracle'; - discriminator: [92, 14, 139, 234, 72, 244, 68, 26]; - }, - { - name: 'protectedMakerModeConfig'; - discriminator: [47, 86, 90, 9, 224, 255, 10, 69]; - }, - { - name: 'pythLazerOracle'; - discriminator: [159, 7, 161, 249, 34, 81, 121, 133]; - }, - { - name: 'referrerName'; - discriminator: [105, 133, 170, 110, 52, 42, 28, 182]; - }, - { - name: 'revenueShare'; - discriminator: [55, 40, 228, 7, 139, 52, 180, 110]; - }, - { - name: 'revenueShareEscrow'; - discriminator: [98, 167, 3, 46, 74, 177, 173, 252]; - }, - { - name: 'serumV3FulfillmentConfig'; - discriminator: [65, 160, 197, 112, 239, 168, 103, 185]; - }, - { - name: 'signedMsgUserOrders'; - discriminator: [70, 6, 50, 248, 222, 1, 143, 49]; - }, - { - name: 'signedMsgWsDelegates'; - discriminator: [190, 115, 111, 44, 216, 252, 108, 85]; - }, - { - name: 'spotMarket'; - discriminator: [100, 177, 8, 107, 168, 65, 65, 39]; - }, - { - name: 'state'; - discriminator: [216, 146, 107, 94, 104, 75, 182, 177]; - }, - { - name: 'user'; - discriminator: [159, 117, 95, 227, 239, 151, 58, 236]; - }, - { - name: 'userStats'; - discriminator: [176, 223, 136, 27, 122, 79, 32, 227]; - }, - ]; - events: [ - { - name: 'curveRecord'; - discriminator: [101, 238, 40, 228, 70, 46, 61, 117]; - }, - { - name: 'deleteUserRecord'; - discriminator: [71, 111, 190, 118, 7, 3, 132, 222]; - }, - { - name: 'depositRecord'; - discriminator: [180, 241, 218, 207, 102, 135, 44, 134]; - }, - { - name: 'fuelSeasonRecord'; - discriminator: [19, 137, 119, 33, 224, 249, 6, 87]; - }, - { - name: 'fuelSweepRecord'; - discriminator: [41, 84, 37, 246, 132, 240, 131, 8]; - }, - { - name: 'fundingPaymentRecord'; - discriminator: [8, 59, 96, 20, 137, 201, 56, 95]; - }, - { - name: 'fundingRateRecord'; - discriminator: [68, 3, 255, 26, 133, 91, 147, 254]; - }, - { - name: 'insuranceFundRecord'; - discriminator: [56, 222, 215, 235, 78, 197, 99, 146]; - }, - { - name: 'insuranceFundStakeRecord'; - discriminator: [68, 66, 156, 7, 216, 148, 250, 114]; - }, - { - name: 'insuranceFundSwapRecord'; - discriminator: [85, 190, 99, 203, 237, 33, 227, 100]; - }, - { - name: 'lpBorrowLendDepositRecord'; - discriminator: [242, 181, 11, 56, 243, 61, 79, 210]; - }, - { - name: 'lpMintRedeemRecord'; - discriminator: [53, 178, 142, 73, 78, 91, 91, 8]; - }, - { - name: 'lpRecord'; - discriminator: [101, 22, 54, 38, 178, 13, 142, 111]; - }, - { - name: 'lpSettleRecord'; - discriminator: [208, 191, 131, 110, 173, 48, 7, 2]; - }, - { - name: 'lpSwapRecord'; - discriminator: [159, 62, 130, 196, 96, 79, 176, 254]; - }, - { - name: 'liquidationRecord'; - discriminator: [127, 17, 0, 108, 182, 13, 231, 53]; - }, - { - name: 'newUserRecord'; - discriminator: [236, 186, 113, 219, 42, 51, 149, 249]; - }, - { - name: 'orderActionRecord'; - discriminator: [224, 52, 67, 71, 194, 237, 109, 1]; - }, - { - name: 'orderRecord'; - discriminator: [104, 19, 64, 56, 89, 21, 2, 90]; - }, - { - name: 'revenueShareSettleRecord'; - discriminator: [61, 162, 89, 10, 24, 20, 59, 45]; - }, - { - name: 'settlePnlRecord'; - discriminator: [57, 68, 105, 26, 119, 198, 213, 89]; - }, - { - name: 'signedMsgOrderRecord'; - discriminator: [211, 197, 25, 18, 142, 86, 113, 27]; - }, - { - name: 'spotInterestRecord'; - discriminator: [183, 186, 203, 186, 225, 187, 95, 130]; - }, - { - name: 'spotMarketVaultDepositRecord'; - discriminator: [178, 217, 23, 188, 127, 190, 32, 73]; - }, - { - name: 'swapRecord'; - discriminator: [162, 187, 123, 194, 138, 56, 250, 241]; - }, - { - name: 'transferProtocolIfSharesToRevenuePoolRecord'; - discriminator: [209, 118, 142, 167, 130, 46, 164, 151]; - }, - ]; - errors: [ - { - code: 6000; - name: 'invalidEd25519InstructionProgramId'; - msg: 'invalid ed25519 instruction program'; - }, - { - code: 6001; - name: 'invalidEd25519InstructionDataLength'; - msg: 'invalid ed25519 instruction data length'; - }, - { - code: 6002; - name: 'invalidSignatureIndex'; - msg: 'invalid signature index'; - }, - { - code: 6003; - name: 'invalidSignatureOffset'; - msg: 'invalid signature offset'; - }, - { - code: 6004; - name: 'invalidPublicKeyOffset'; - msg: 'invalid public key offset'; - }, - { - code: 6005; - name: 'invalidMessageOffset'; - msg: 'invalid message offset'; - }, - { - code: 6006; - name: 'invalidMessageDataSize'; - msg: 'invalid message data size'; - }, - { - code: 6007; - name: 'invalidInstructionIndex'; - msg: 'invalid instruction index'; - }, - { - code: 6008; - name: 'messageOffsetOverflow'; - msg: 'message offset overflow'; - }, - { - code: 6009; - name: 'invalidMessageHex'; - msg: 'invalid message hex'; - }, - { - code: 6010; - name: 'invalidMessageData'; - msg: 'invalid message data'; - }, - { - code: 6011; - name: 'loadInstructionAtFailed'; - msg: 'loading custom ix at index failed'; - }, - ]; - types: [ - { - name: 'amm'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'oracle'; - docs: ['oracle price data public key']; - type: 'pubkey'; - }, - { - name: 'historicalOracleData'; - docs: ['stores historically witnessed oracle data']; - type: { - defined: { - name: 'historicalOracleData'; - }; - }; - }, - { - name: 'baseAssetAmountPerLp'; - docs: [ - 'accumulated base asset amount since inception per lp share', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteAssetAmountPerLp'; - docs: [ - 'accumulated quote asset amount since inception per lp share', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'feePool'; - docs: [ - 'partition of fees from perp market trading moved from pnl settlements', - ]; - type: { - defined: { - name: 'poolBalance'; - }; - }; - }, - { - name: 'baseAssetReserve'; - docs: [ - '`x` reserves for constant product mm formula (x * y = k)', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'quoteAssetReserve'; - docs: [ - '`y` reserves for constant product mm formula (x * y = k)', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'concentrationCoef'; - docs: [ - 'determines how close the min/max base asset reserve sit vs base reserves', - 'allow for decreasing slippage without increasing liquidity and v.v.', - 'precision: PERCENTAGE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'minBaseAssetReserve'; - docs: [ - 'minimum base_asset_reserve allowed before AMM is unavailable', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'maxBaseAssetReserve'; - docs: [ - 'maximum base_asset_reserve allowed before AMM is unavailable', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'sqrtK'; - docs: [ - '`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'pegMultiplier'; - docs: [ - 'normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced', - 'precision: PEG_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'terminalQuoteAssetReserve'; - docs: [ - 'y when market is balanced. stored to save computation', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'baseAssetAmountLong'; - docs: [ - 'always non-negative. tracks number of total longs in market (regardless of counterparty)', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'baseAssetAmountShort'; - docs: [ - 'always non-positive. tracks number of total shorts in market (regardless of counterparty)', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'baseAssetAmountWithAmm'; - docs: [ - 'tracks net position (longs-shorts) in market with AMM as counterparty', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'baseAssetAmountWithUnsettledLp'; - docs: [ - 'tracks net position (longs-shorts) in market with LPs as counterparty', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'maxOpenInterest'; - docs: [ - 'max allowed open interest, blocks trades that breach this value', - 'precision: BASE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'quoteAssetAmount'; - docs: [ - "sum of all user's perp quote_asset_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteEntryAmountLong'; - docs: [ - "sum of all long user's quote_entry_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteEntryAmountShort'; - docs: [ - "sum of all short user's quote_entry_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteBreakEvenAmountLong'; - docs: [ - "sum of all long user's quote_break_even_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'quoteBreakEvenAmountShort'; - docs: [ - "sum of all short user's quote_break_even_amount in market", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'userLpShares'; - docs: [ - 'total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastFundingRate'; - docs: [ - 'last funding rate in this perp market (unit is quote per base)', - 'precision: FUNDING_RATE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastFundingRateLong'; - docs: [ - 'last funding rate for longs in this perp market (unit is quote per base)', - 'precision: FUNDING_RATE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastFundingRateShort'; - docs: [ - 'last funding rate for shorts in this perp market (unit is quote per base)', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'last24hAvgFundingRate'; - docs: [ - 'estimate of last 24h of funding rate perp market (unit is quote per base)', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'totalFee'; - docs: [ - 'total fees collected by this perp market', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'totalMmFee'; - docs: [ - "total fees collected by the vAMM's bid/ask spread", - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'totalExchangeFee'; - docs: [ - 'total fees collected by exchange fee schedule', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalFeeMinusDistributions'; - docs: [ - 'total fees minus any recognized upnl and pool withdraws', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'totalFeeWithdrawn'; - docs: [ - 'sum of all fees from fee pool withdrawn to revenue pool', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalLiquidationFee'; - docs: [ - 'all fees collected by market for liquidations', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeFundingRateLong'; - docs: [ - 'accumulated funding rate for longs since inception in market', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'cumulativeFundingRateShort'; - docs: [ - 'accumulated funding rate for shorts since inception in market', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'totalSocialLoss'; - docs: [ - 'accumulated social loss paid by users since inception in market', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'askBaseAssetReserve'; - docs: [ - 'transformed base_asset_reserve for users going long', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'askQuoteAssetReserve'; - docs: [ - 'transformed quote_asset_reserve for users going long', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'bidBaseAssetReserve'; - docs: [ - 'transformed base_asset_reserve for users going short', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'bidQuoteAssetReserve'; - docs: [ - 'transformed quote_asset_reserve for users going short', - 'precision: AMM_RESERVE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastOracleNormalisedPrice'; - docs: [ - 'the last seen oracle price partially shrunk toward the amm reserve price', - 'precision: PRICE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastOracleReservePriceSpreadPct'; - docs: [ - 'the gap between the oracle price and the reserve price = y * peg_multiplier / x', - ]; - type: 'i64'; - }, - { - name: 'lastBidPriceTwap'; - docs: [ - 'average estimate of bid price over funding_period', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastAskPriceTwap'; - docs: [ - 'average estimate of ask price over funding_period', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastMarkPriceTwap'; - docs: [ - 'average estimate of (bid+ask)/2 price over funding_period', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastMarkPriceTwap5min'; - docs: ['average estimate of (bid+ask)/2 price over FIVE_MINUTES']; - type: 'u64'; - }, - { - name: 'lastUpdateSlot'; - docs: ['the last blockchain slot the amm was updated']; - type: 'u64'; - }, - { - name: 'lastOracleConfPct'; - docs: [ - 'the pct size of the oracle confidence interval', - 'precision: PERCENTAGE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'netRevenueSinceLastFunding'; - docs: [ - 'the total_fee_minus_distribution change since the last funding update', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastFundingRateTs'; - docs: ['the last funding rate update unix_timestamp']; - type: 'i64'; - }, - { - name: 'fundingPeriod'; - docs: ['the periodicity of the funding rate updates']; - type: 'i64'; - }, - { - name: 'orderStepSize'; - docs: [ - 'the base step size (increment) of orders', - 'precision: BASE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'orderTickSize'; - docs: [ - 'the price tick size of orders', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'minOrderSize'; - docs: [ - 'the minimum base size of an order', - 'precision: BASE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'mmOracleSlot'; - docs: [ - 'the max base size a single user can have', - 'precision: BASE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'volume24h'; - docs: ['estimated total of volume in market', 'QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'longIntensityVolume'; - docs: ['the volume intensity of long fills against AMM']; - type: 'u64'; - }, - { - name: 'shortIntensityVolume'; - docs: ['the volume intensity of short fills against AMM']; - type: 'u64'; - }, - { - name: 'lastTradeTs'; - docs: [ - 'the blockchain unix timestamp at the time of the last trade', - ]; - type: 'i64'; - }, - { - name: 'markStd'; - docs: [ - 'estimate of standard deviation of the fill (mark) prices', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'oracleStd'; - docs: [ - 'estimate of standard deviation of the oracle price at each update', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastMarkPriceTwapTs'; - docs: ['the last unix_timestamp the mark twap was updated']; - type: 'i64'; - }, - { - name: 'baseSpread'; - docs: [ - 'the minimum spread the AMM can quote. also used as step size for some spread logic increases.', - ]; - type: 'u32'; - }, - { - name: 'maxSpread'; - docs: ['the maximum spread the AMM can quote']; - type: 'u32'; - }, - { - name: 'longSpread'; - docs: ['the spread for asks vs the reserve price']; - type: 'u32'; - }, - { - name: 'shortSpread'; - docs: ['the spread for bids vs the reserve price']; - type: 'u32'; - }, - { - name: 'mmOraclePrice'; - docs: ['MM oracle price']; - type: 'i64'; - }, - { - name: 'maxFillReserveFraction'; - docs: [ - 'the fraction of total available liquidity a single fill on the AMM can consume', - ]; - type: 'u16'; - }, - { - name: 'maxSlippageRatio'; - docs: ['the maximum slippage a single fill on the AMM can push']; - type: 'u16'; - }, - { - name: 'curveUpdateIntensity'; - docs: [ - 'the update intensity of AMM formulaic updates (adjusting k). 0-100', - ]; - type: 'u8'; - }, - { - name: 'ammJitIntensity'; - docs: [ - 'the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.', - '(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM.', - ]; - type: 'u8'; - }, - { - name: 'oracleSource'; - docs: [ - 'the oracle provider information. used to decode/scale the oracle public key', - ]; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'lastOracleValid'; - docs: [ - 'tracks whether the oracle was considered valid at the last AMM update', - ]; - type: 'bool'; - }, - { - name: 'targetBaseAssetAmountPerLp'; - docs: [ - 'the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split', - 'precision: BASE_PRECISION', - ]; - type: 'i32'; - }, - { - name: 'perLpBase'; - docs: [ - 'expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)', - ]; - type: 'i8'; - }, - { - name: 'oracleLowRiskSlotDelayOverride'; - docs: [ - 'the override for the state.min_perp_auction_duration', - '0 is no override, -1 is disable speed bump, 1-100 is literal speed bump', - ]; - type: 'i8'; - }, - { - name: 'ammSpreadAdjustment'; - docs: [ - 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', - ]; - type: 'i8'; - }, - { - name: 'oracleSlotDelayOverride'; - type: 'i8'; - }, - { - name: 'mmOracleSequenceId'; - type: 'u64'; - }, - { - name: 'netUnsettledFundingPnl'; - type: 'i64'; - }, - { - name: 'quoteAssetAmountWithUnsettledLp'; - type: 'i64'; - }, - { - name: 'referencePriceOffset'; - type: 'i32'; - }, - { - name: 'ammInventorySpreadAdjustment'; - docs: [ - 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', - ]; - type: 'i8'; - }, - { - name: 'referencePriceOffsetDeadbandPct'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 2]; - }; - }, - { - name: 'lastFundingOracleTwap'; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'addAmmConstituentMappingDatum'; - type: { - kind: 'struct'; - fields: [ - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'weight'; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'ammCache'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'cache'; - type: { - vec: { - defined: { - name: 'cacheInfo'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'ammConstituentDatum'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - { - name: 'lastSlot'; - type: 'u64'; - }, - { - name: 'weight'; - docs: [ - 'PERCENTAGE_PRECISION. The weight this constituent has on the perp market', - ]; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'ammConstituentMapping'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'lpPool'; - type: 'pubkey'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'weights'; - type: { - vec: { - defined: { - name: 'ammConstituentDatum'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'assetTier'; - type: { - kind: 'enum'; - variants: [ - { - name: 'collateral'; - }, - { - name: 'protected'; - }, - { - name: 'cross'; - }, - { - name: 'isolated'; - }, - { - name: 'unlisted'; - }, - ]; - }; - }, - { - name: 'builderInfo'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'maxFeeTenthBps'; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 6]; - }; - }, - ]; - }; - }, - { - name: 'cacheInfo'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'oracle'; - type: 'pubkey'; - }, - { - name: 'lastFeePoolTokenAmount'; - type: 'u128'; - }, - { - name: 'lastNetPnlPoolTokenAmount'; - type: 'i128'; - }, - { - name: 'lastExchangeFees'; - type: 'u128'; - }, - { - name: 'lastSettleAmmExFees'; - type: 'u128'; - }, - { - name: 'lastSettleAmmPnl'; - type: 'i128'; - }, - { - name: 'position'; - docs: ['BASE PRECISION']; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'lastSettleAmount'; - type: 'u64'; - }, - { - name: 'lastSettleSlot'; - type: 'u64'; - }, - { - name: 'lastSettleTs'; - type: 'i64'; - }, - { - name: 'quoteOwedFromLpPool'; - type: 'i64'; - }, - { - name: 'ammInventoryLimit'; - type: 'i64'; - }, - { - name: 'oraclePrice'; - type: 'i64'; - }, - { - name: 'oracleSlot'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'oracleSource'; - type: 'u8'; - }, - { - name: 'oracleValidity'; - type: 'u8'; - }, - { - name: 'lpStatusForPerpMarket'; - type: 'u8'; - }, - { - name: 'ammPositionScalar'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 34]; - }; - }, - ]; - }; - }, - { - name: 'constituent'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - docs: ['address of the constituent']; - type: 'pubkey'; - }, - { - name: 'mint'; - type: 'pubkey'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - { - name: 'vault'; - type: 'pubkey'; - }, - { - name: 'totalSwapFees'; - docs: [ - 'total fees received by the constituent. Positive = fees received, Negative = fees paid', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'spotBalance'; - docs: ['spot borrow-lend balance for constituent']; - type: { - defined: { - name: 'constituentSpotBalance'; - }; - }; - }, - { - name: 'lastSpotBalanceTokenAmount'; - type: 'i64'; - }, - { - name: 'cumulativeSpotInterestAccruedTokenAmount'; - type: 'i64'; - }, - { - name: 'maxWeightDeviation'; - docs: [ - 'max deviation from target_weight allowed for the constituent', - 'precision: PERCENTAGE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'swapFeeMin'; - docs: [ - 'min fee charged on swaps to/from this constituent', - 'precision: PERCENTAGE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'swapFeeMax'; - docs: [ - 'max fee charged on swaps to/from this constituent', - 'precision: PERCENTAGE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'maxBorrowTokenAmount'; - docs: ['Max Borrow amount:', 'precision: token precision']; - type: 'u64'; - }, - { - name: 'vaultTokenBalance'; - docs: ['ata token balance in token precision']; - type: 'u64'; - }, - { - name: 'lastOraclePrice'; - type: 'i64'; - }, - { - name: 'lastOracleSlot'; - type: 'u64'; - }, - { - name: 'oracleStalenessThreshold'; - docs: ['Delay allowed for valid AUM calculation']; - type: 'u64'; - }, - { - name: 'flashLoanInitialTokenAmount'; - type: 'u64'; - }, - { - name: 'nextSwapId'; - docs: [ - 'Every swap to/from this constituent has a monotonically increasing id. This is the next id to use', - ]; - type: 'u64'; - }, - { - name: 'derivativeWeight'; - docs: [ - 'percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight', - ]; - type: 'u64'; - }, - { - name: 'volatility'; - type: 'u64'; - }, - { - name: 'constituentDerivativeDepegThreshold'; - type: 'u64'; - }, - { - name: 'constituentDerivativeIndex'; - docs: [ - 'The `constituent_index` of the parent constituent. -1 if it is a parent index', - 'Example: if in a pool with SOL (parent) and dSOL (derivative),', - 'SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,', - 'dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1', - ]; - type: 'i16'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'decimals'; - type: 'u8'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'vaultBump'; - type: 'u8'; - }, - { - name: 'gammaInventory'; - type: 'u8'; - }, - { - name: 'gammaExecution'; - type: 'u8'; - }, - { - name: 'xi'; - type: 'u8'; - }, - { - name: 'status'; - type: 'u8'; - }, - { - name: 'pausedOperations'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 162]; - }; - }, - ]; - }; - }, - { - name: 'constituentCorrelations'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'lpPool'; - type: 'pubkey'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'correlations'; - type: { - vec: 'i64'; - }; - }, - ]; - }; - }, - { - name: 'constituentParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'maxWeightDeviation'; - type: { - option: 'i64'; - }; - }, - { - name: 'swapFeeMin'; - type: { - option: 'i64'; - }; - }, - { - name: 'swapFeeMax'; - type: { - option: 'i64'; - }; - }, - { - name: 'maxBorrowTokenAmount'; - type: { - option: 'u64'; - }; - }, - { - name: 'oracleStalenessThreshold'; - type: { - option: 'u64'; - }; - }, - { - name: 'costToTradeBps'; - type: { - option: 'i32'; - }; - }, - { - name: 'constituentDerivativeIndex'; - type: { - option: 'i16'; - }; - }, - { - name: 'derivativeWeight'; - type: { - option: 'u64'; - }; - }, - { - name: 'volatility'; - type: { - option: 'u64'; - }; - }, - { - name: 'gammaExecution'; - type: { - option: 'u8'; - }; - }, - { - name: 'gammaInventory'; - type: { - option: 'u8'; - }; - }, - { - name: 'xi'; - type: { - option: 'u8'; - }; - }, - ]; - }; - }, - { - name: 'constituentSpotBalance'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'scaledBalance'; - docs: [ - 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', - 'interest of corresponding market.', - 'precision: token precision', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeDeposits'; - docs: [ - 'The cumulative deposits/borrows a user has made into a market', - 'precision: token mint precision', - ]; - type: 'i64'; - }, - { - name: 'marketIndex'; - docs: ['The market index of the corresponding spot market']; - type: 'u16'; - }, - { - name: 'balanceType'; - docs: ['Whether the position is deposit or borrow']; - type: { - defined: { - name: 'spotBalanceType'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 5]; - }; - }, - ]; - }; - }, - { - name: 'constituentTargetBase'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'lpPool'; - type: 'pubkey'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'targets'; - type: { - vec: { - defined: { - name: 'targetsDatum'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'contractTier'; - type: { - kind: 'enum'; - variants: [ - { - name: 'a'; - }, - { - name: 'b'; - }, - { - name: 'c'; - }, - { - name: 'speculative'; - }, - { - name: 'highlySpeculative'; - }, - { - name: 'isolated'; - }, - ]; - }; - }, - { - name: 'contractType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'perpetual'; - }, - { - name: 'future'; - }, - { - name: 'prediction'; - }, - ]; - }; - }, - { - name: 'curveRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'recordId'; - type: 'u64'; - }, - { - name: 'pegMultiplierBefore'; - type: 'u128'; - }, - { - name: 'baseAssetReserveBefore'; - type: 'u128'; - }, - { - name: 'quoteAssetReserveBefore'; - type: 'u128'; - }, - { - name: 'sqrtKBefore'; - type: 'u128'; - }, - { - name: 'pegMultiplierAfter'; - type: 'u128'; - }, - { - name: 'baseAssetReserveAfter'; - type: 'u128'; - }, - { - name: 'quoteAssetReserveAfter'; - type: 'u128'; - }, - { - name: 'sqrtKAfter'; - type: 'u128'; - }, - { - name: 'baseAssetAmountLong'; - docs: ['precision: BASE_PRECISION']; - type: 'u128'; - }, - { - name: 'baseAssetAmountShort'; - docs: ['precision: BASE_PRECISION']; - type: 'u128'; - }, - { - name: 'baseAssetAmountWithAmm'; - docs: ['precision: BASE_PRECISION']; - type: 'i128'; - }, - { - name: 'totalFee'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i128'; - }, - { - name: 'totalFeeMinusDistributions'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i128'; - }, - { - name: 'adjustmentCost'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i128'; - }, - { - name: 'oraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'fillRecord'; - type: 'u128'; - }, - { - name: 'numberOfUsers'; - type: 'u32'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - ]; - }; - }, - { - name: 'deleteUserRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - docs: ['unix_timestamp of action']; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'keeper'; - type: { - option: 'pubkey'; - }; - }, - ]; - }; - }, - { - name: 'depositDirection'; - type: { - kind: 'enum'; - variants: [ - { - name: 'deposit'; - }, - { - name: 'withdraw'; - }, - ]; - }; - }, - { - name: 'depositExplanation'; - type: { - kind: 'enum'; - variants: [ - { - name: 'none'; - }, - { - name: 'transfer'; - }, - { - name: 'borrow'; - }, - { - name: 'repayBorrow'; - }, - { - name: 'reward'; - }, - ]; - }; - }, - { - name: 'depositRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - docs: ['unix_timestamp of action']; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'user'; - docs: ['user account public key']; - type: 'pubkey'; - }, - { - name: 'direction'; - type: { - defined: { - name: 'depositDirection'; - }; - }; - }, - { - name: 'depositRecordId'; - type: 'u64'; - }, - { - name: 'amount'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'marketIndex'; - docs: ['spot market index']; - type: 'u16'; - }, - { - name: 'oraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'marketDepositBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'marketWithdrawBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'marketCumulativeDepositInterest'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'marketCumulativeBorrowInterest'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'totalDepositsAfter'; - docs: ['precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'totalWithdrawsAfter'; - docs: ['precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'explanation'; - type: { - defined: { - name: 'depositExplanation'; - }; - }; - }, - { - name: 'transferUser'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'signer'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'userTokenAmountAfter'; - docs: ['precision: token mint precision']; - type: 'i128'; - }, - ]; - }; - }, - { - name: 'feeStructure'; - type: { - kind: 'struct'; - fields: [ - { - name: 'feeTiers'; - type: { - array: [ - { - defined: { - name: 'feeTier'; - }; - }, - 10, - ]; - }; - }, - { - name: 'fillerRewardStructure'; - type: { - defined: { - name: 'orderFillerRewardStructure'; - }; - }; - }, - { - name: 'referrerRewardEpochUpperBound'; - type: 'u64'; - }, - { - name: 'flatFillerFee'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'feeTier'; - type: { - kind: 'struct'; - fields: [ - { - name: 'feeNumerator'; - type: 'u32'; - }, - { - name: 'feeDenominator'; - type: 'u32'; - }, - { - name: 'makerRebateNumerator'; - type: 'u32'; - }, - { - name: 'makerRebateDenominator'; - type: 'u32'; - }, - { - name: 'referrerRewardNumerator'; - type: 'u32'; - }, - { - name: 'referrerRewardDenominator'; - type: 'u32'; - }, - { - name: 'refereeFeeNumerator'; - type: 'u32'; - }, - { - name: 'refereeFeeDenominator'; - type: 'u32'; - }, - ]; - }; - }, - { - name: 'fuelOverflow'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['The authority of this overflow account']; - type: 'pubkey'; - }, - { - name: 'fuelInsurance'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelDeposits'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelBorrows'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelPositions'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelTaker'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'fuelMaker'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastFuelSweepTs'; - type: 'u32'; - }, - { - name: 'lastResetTs'; - type: 'u32'; - }, - { - name: 'padding'; - type: { - array: ['u128', 6]; - }; - }, - ]; - }; - }, - { - name: 'fuelSeasonRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'fuelInsurance'; - type: 'u128'; - }, - { - name: 'fuelDeposits'; - type: 'u128'; - }, - { - name: 'fuelBorrows'; - type: 'u128'; - }, - { - name: 'fuelPositions'; - type: 'u128'; - }, - { - name: 'fuelTaker'; - type: 'u128'; - }, - { - name: 'fuelMaker'; - type: 'u128'; - }, - { - name: 'fuelTotal'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'fuelSweepRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'userStatsFuelInsurance'; - type: 'u32'; - }, - { - name: 'userStatsFuelDeposits'; - type: 'u32'; - }, - { - name: 'userStatsFuelBorrows'; - type: 'u32'; - }, - { - name: 'userStatsFuelPositions'; - type: 'u32'; - }, - { - name: 'userStatsFuelTaker'; - type: 'u32'; - }, - { - name: 'userStatsFuelMaker'; - type: 'u32'; - }, - { - name: 'fuelOverflowFuelInsurance'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelDeposits'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelBorrows'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelPositions'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelTaker'; - type: 'u128'; - }, - { - name: 'fuelOverflowFuelMaker'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'fundingPaymentRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fundingPayment'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i64'; - }, - { - name: 'baseAssetAmount'; - docs: ['precision: BASE_PRECISION']; - type: 'i64'; - }, - { - name: 'userLastCumulativeFunding'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i64'; - }, - { - name: 'ammCumulativeFundingLong'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'ammCumulativeFundingShort'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - ]; - }; - }, - { - name: 'fundingRateRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'recordId'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fundingRate'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i64'; - }, - { - name: 'fundingRateLong'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'fundingRateShort'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'cumulativeFundingRateLong'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'cumulativeFundingRateShort'; - docs: ['precision: FUNDING_RATE_PRECISION']; - type: 'i128'; - }, - { - name: 'oraclePriceTwap'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'markPriceTwap'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'periodRevenue'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i64'; - }, - { - name: 'baseAssetAmountWithAmm'; - docs: ['precision: BASE_PRECISION']; - type: 'i128'; - }, - { - name: 'baseAssetAmountWithUnsettledLp'; - docs: ['precision: BASE_PRECISION']; - type: 'i128'; - }, - ]; - }; - }, - { - name: 'highLeverageModeConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - { - name: 'currentUsers'; - type: 'u32'; - }, - { - name: 'reduceOnly'; - type: 'u8'; - }, - { - name: 'padding1'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'currentMaintenanceUsers'; - type: 'u32'; - }, - { - name: 'padding2'; - type: { - array: ['u8', 24]; - }; - }, - ]; - }; - }, - { - name: 'historicalIndexData'; - type: { - kind: 'struct'; - fields: [ - { - name: 'lastIndexBidPrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastIndexAskPrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastIndexPriceTwap'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastIndexPriceTwap5min'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastIndexPriceTwapTs'; - docs: ['unix_timestamp of last snapshot']; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'historicalOracleData'; - type: { - kind: 'struct'; - fields: [ - { - name: 'lastOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'lastOracleConf'; - docs: ['precision: PRICE_PRECISION']; - type: 'u64'; - }, - { - name: 'lastOracleDelay'; - docs: ['number of slots since last update']; - type: 'i64'; - }, - { - name: 'lastOraclePriceTwap'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'lastOraclePriceTwap5min'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'lastOraclePriceTwapTs'; - docs: ['unix_timestamp of last snapshot']; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'ifRebalanceConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - type: 'pubkey'; - }, - { - name: 'totalInAmount'; - docs: ['total amount to be sold']; - type: 'u64'; - }, - { - name: 'currentInAmount'; - docs: ['amount already sold']; - type: 'u64'; - }, - { - name: 'currentOutAmount'; - docs: ['amount already bought']; - type: 'u64'; - }, - { - name: 'currentOutAmountTransferred'; - docs: ['amount already transferred to revenue pool']; - type: 'u64'; - }, - { - name: 'currentInAmountSinceLastTransfer'; - docs: ['amount already bought in epoch']; - type: 'u64'; - }, - { - name: 'epochStartTs'; - docs: ['start time of epoch']; - type: 'i64'; - }, - { - name: 'epochInAmount'; - docs: ['amount already bought in epoch']; - type: 'u64'; - }, - { - name: 'epochMaxInAmount'; - docs: ['max amount to swap in epoch']; - type: 'u64'; - }, - { - name: 'epochDuration'; - docs: ['duration of epoch']; - type: 'i64'; - }, - { - name: 'outMarketIndex'; - docs: ['market index to sell']; - type: 'u16'; - }, - { - name: 'inMarketIndex'; - docs: ['market index to buy']; - type: 'u16'; - }, - { - name: 'maxSlippageBps'; - type: 'u16'; - }, - { - name: 'swapMode'; - type: 'u8'; - }, - { - name: 'status'; - type: 'u8'; - }, - { - name: 'padding2'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }; - }, - { - name: 'ifRebalanceConfigParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'totalInAmount'; - type: 'u64'; - }, - { - name: 'epochMaxInAmount'; - type: 'u64'; - }, - { - name: 'epochDuration'; - type: 'i64'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'maxSlippageBps'; - type: 'u16'; - }, - { - name: 'swapMode'; - type: 'u8'; - }, - { - name: 'status'; - type: 'u8'; - }, - ]; - }; - }, - { - name: 'insuranceClaim'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'revenueWithdrawSinceLastSettle'; - docs: [ - 'The amount of revenue last settled', - 'Positive if funds left the perp market,', - 'negative if funds were pulled into the perp market', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'maxRevenueWithdrawPerPeriod'; - docs: [ - 'The max amount of revenue that can be withdrawn per period', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'quoteMaxInsurance'; - docs: [ - 'The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'quoteSettledInsurance'; - docs: [ - 'The amount of insurance that has been used to resolve bankruptcy and pnl deficits', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastRevenueWithdrawTs'; - docs: ['The last time revenue was settled in/out of market']; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'insuranceFund'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'vault'; - type: 'pubkey'; - }, - { - name: 'totalShares'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'userShares'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'sharesBase'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'unstakingPeriod'; - type: 'i64'; - }, - { - name: 'lastRevenueSettleTs'; - type: 'i64'; - }, - { - name: 'revenueSettlePeriod'; - type: 'i64'; - }, - { - name: 'totalFactor'; - type: 'u32'; - }, - { - name: 'userFactor'; - type: 'u32'; - }, - ]; - }; - }, - { - name: 'insuranceFundRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'userIfFactor'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - { - name: 'totalIfFactor'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - { - name: 'vaultAmountBefore'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'insuranceVaultAmountBefore'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'totalIfSharesBefore'; - type: 'u128'; - }, - { - name: 'totalIfSharesAfter'; - type: 'u128'; - }, - { - name: 'amount'; - docs: ['precision: token mint precision']; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'insuranceFundStake'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'ifShares'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastWithdrawRequestShares'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'ifBase'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastValidTs'; - type: 'i64'; - }, - { - name: 'lastWithdrawRequestValue'; - type: 'u64'; - }, - { - name: 'lastWithdrawRequestTs'; - type: 'i64'; - }, - { - name: 'costBasis'; - type: 'i64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 14]; - }; - }, - ]; - }; - }, - { - name: 'insuranceFundStakeRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'action'; - type: { - defined: { - name: 'stakeAction'; - }; - }; - }, - { - name: 'amount'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'insuranceVaultAmountBefore'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - { - name: 'ifSharesBefore'; - type: 'u128'; - }, - { - name: 'userIfSharesBefore'; - type: 'u128'; - }, - { - name: 'totalIfSharesBefore'; - type: 'u128'; - }, - { - name: 'ifSharesAfter'; - type: 'u128'; - }, - { - name: 'userIfSharesAfter'; - type: 'u128'; - }, - { - name: 'totalIfSharesAfter'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'insuranceFundSwapRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'rebalanceConfig'; - type: 'pubkey'; - }, - { - name: 'inIfTotalSharesBefore'; - type: 'u128'; - }, - { - name: 'outIfTotalSharesBefore'; - type: 'u128'; - }, - { - name: 'inIfUserSharesBefore'; - type: 'u128'; - }, - { - name: 'outIfUserSharesBefore'; - type: 'u128'; - }, - { - name: 'inIfTotalSharesAfter'; - type: 'u128'; - }, - { - name: 'outIfTotalSharesAfter'; - type: 'u128'; - }, - { - name: 'inIfUserSharesAfter'; - type: 'u128'; - }, - { - name: 'outIfUserSharesAfter'; - type: 'u128'; - }, - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'inAmount'; - type: 'u64'; - }, - { - name: 'outAmount'; - type: 'u64'; - }, - { - name: 'outOraclePrice'; - type: 'u64'; - }, - { - name: 'outOraclePriceTwap'; - type: 'i64'; - }, - { - name: 'inVaultAmountBefore'; - type: 'u64'; - }, - { - name: 'outVaultAmountBefore'; - type: 'u64'; - }, - { - name: 'inFundVaultAmountAfter'; - type: 'u64'; - }, - { - name: 'outFundVaultAmountAfter'; - type: 'u64'; - }, - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - ]; - }; - }, - { - name: 'lpAction'; - type: { - kind: 'enum'; - variants: [ - { - name: 'addLiquidity'; - }, - { - name: 'removeLiquidity'; - }, - { - name: 'settleLiquidity'; - }, - { - name: 'removeLiquidityDerisk'; - }, - ]; - }; - }, - { - name: 'lpBorrowLendDepositRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'direction'; - type: { - defined: { - name: 'depositDirection'; - }; - }; - }, - { - name: 'tokenBalance'; - type: 'i64'; - }, - { - name: 'lastTokenBalance'; - type: 'i64'; - }, - { - name: 'interestAccruedTokenAmount'; - type: 'i64'; - }, - { - name: 'amountDepositWithdraw'; - type: 'u64'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'lpMintRedeemRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'description'; - type: 'u8'; - }, - { - name: 'amount'; - docs: ['precision: continutent mint precision, gross fees']; - type: 'u128'; - }, - { - name: 'fee'; - docs: [ - 'precision: fee on amount, constituent market mint precision', - ]; - type: 'i128'; - }, - { - name: 'spotMarketIndex'; - type: 'u16'; - }, - { - name: 'constituentIndex'; - type: 'u16'; - }, - { - name: 'oraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'mint'; - docs: ['token mint']; - type: 'pubkey'; - }, - { - name: 'lpAmount'; - docs: ['lp amount, lp mint precision']; - type: 'u64'; - }, - { - name: 'lpFee'; - docs: ['lp fee, lp mint precision']; - type: 'i64'; - }, - { - name: 'lpPrice'; - docs: ['the fair price of the lp token, PRICE_PRECISION']; - type: 'u128'; - }, - { - name: 'mintRedeemId'; - type: 'u64'; - }, - { - name: 'lastAum'; - docs: ['LPPool last_aum']; - type: 'u128'; - }, - { - name: 'lastAumSlot'; - type: 'u64'; - }, - { - name: 'inMarketCurrentWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'inMarketTargetWeight'; - type: 'i64'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'lpPool'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - docs: ['address of the vault.']; - type: 'pubkey'; - }, - { - name: 'mint'; - type: 'pubkey'; - }, - { - name: 'whitelistMint'; - type: 'pubkey'; - }, - { - name: 'constituentTargetBase'; - type: 'pubkey'; - }, - { - name: 'constituentCorrelations'; - type: 'pubkey'; - }, - { - name: 'maxAum'; - docs: [ - 'The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)', - 'which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)', - 'pub quote_constituent_index: u16,', - 'QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'lastAum'; - docs: ['QUOTE_PRECISION: AUM of the vault in USD, updated lazily']; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeQuoteSentToPerpMarkets'; - docs: ['QUOTE PRECISION: Cumulative quotes from settles']; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeQuoteReceivedFromPerpMarkets'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalMintRedeemFeesPaid'; - docs: [ - 'QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens', - ]; - type: { - defined: { - name: 'i128'; - }; - }; - }, - { - name: 'lastAumSlot'; - docs: ['timestamp of last AUM slot']; - type: 'u64'; - }, - { - name: 'maxSettleQuoteAmount'; - type: 'u64'; - }, - { - name: 'padding'; - docs: ['timestamp of last vAMM revenue rebalance']; - type: 'u64'; - }, - { - name: 'mintRedeemId'; - docs: [ - 'Every mint/redeem has a monotonically increasing id. This is the next id to use', - ]; - type: 'u64'; - }, - { - name: 'settleId'; - type: 'u64'; - }, - { - name: 'minMintFee'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'tokenSupply'; - type: 'u64'; - }, - { - name: 'volatility'; - type: 'u64'; - }, - { - name: 'constituents'; - type: 'u16'; - }, - { - name: 'quoteConsituentIndex'; - type: 'u16'; - }, - { - name: 'bump'; - type: 'u8'; - }, - { - name: 'gammaExecution'; - type: 'u8'; - }, - { - name: 'xi'; - type: 'u8'; - }, - { - name: 'targetOracleDelayFeeBpsPer10Slots'; - type: 'u8'; - }, - { - name: 'targetPositionDelayFeeBpsPer10Slots'; - type: 'u8'; - }, - { - name: 'lpPoolId'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 174]; - }; - }, - ]; - }; - }, - { - name: 'lpRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'action'; - type: { - defined: { - name: 'lpAction'; - }; - }; - }, - { - name: 'nShares'; - docs: ['precision: AMM_RESERVE_PRECISION']; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'deltaBaseAssetAmount'; - docs: ['precision: BASE_PRECISION']; - type: 'i64'; - }, - { - name: 'deltaQuoteAssetAmount'; - docs: ['precision: QUOTE_PRECISION']; - type: 'i64'; - }, - { - name: 'pnl'; - docs: [ - 'realized pnl of the position settlement', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'lpSettleRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'recordId'; - type: 'u64'; - }, - { - name: 'lastTs'; - type: 'i64'; - }, - { - name: 'lastSlot'; - type: 'u64'; - }, - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'settleToLpAmount'; - type: 'i64'; - }, - { - name: 'perpAmmPnlDelta'; - type: 'i64'; - }, - { - name: 'perpAmmExFeeDelta'; - type: 'i64'; - }, - { - name: 'lpAum'; - type: 'u128'; - }, - { - name: 'lpPrice'; - type: 'u128'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'lpSwapRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'slot'; - type: 'u64'; - }, - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'outAmount'; - docs: ['precision: out market mint precision, gross fees']; - type: 'u128'; - }, - { - name: 'inAmount'; - docs: ['precision: in market mint precision, gross fees']; - type: 'u128'; - }, - { - name: 'outFee'; - docs: ['precision: fee on amount_out, in market mint precision']; - type: 'i128'; - }, - { - name: 'inFee'; - docs: ['precision: fee on amount_in, out market mint precision']; - type: 'i128'; - }, - { - name: 'outSpotMarketIndex'; - type: 'u16'; - }, - { - name: 'inSpotMarketIndex'; - type: 'u16'; - }, - { - name: 'outConstituentIndex'; - type: 'u16'; - }, - { - name: 'inConstituentIndex'; - type: 'u16'; - }, - { - name: 'outOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'inOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'lastAum'; - docs: ['LPPool last_aum, QUOTE_PRECISION']; - type: 'u128'; - }, - { - name: 'lastAumSlot'; - type: 'u64'; - }, - { - name: 'inMarketCurrentWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'outMarketCurrentWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'inMarketTargetWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'outMarketTargetWeight'; - docs: ['PERCENTAGE_PRECISION']; - type: 'i64'; - }, - { - name: 'inSwapId'; - type: 'u64'; - }, - { - name: 'outSwapId'; - type: 'u64'; - }, - { - name: 'lpPool'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'liquidateBorrowForPerpPnlRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'marketOraclePrice'; - type: 'i64'; - }, - { - name: 'pnlTransfer'; - type: 'u128'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityPrice'; - type: 'i64'; - }, - { - name: 'liabilityTransfer'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'liquidatePerpPnlForDepositRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'marketOraclePrice'; - type: 'i64'; - }, - { - name: 'pnlTransfer'; - type: 'u128'; - }, - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'assetPrice'; - type: 'i64'; - }, - { - name: 'assetTransfer'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'liquidatePerpRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'oraclePrice'; - type: 'i64'; - }, - { - name: 'baseAssetAmount'; - type: 'i64'; - }, - { - name: 'quoteAssetAmount'; - type: 'i64'; - }, - { - name: 'lpShares'; - docs: ['precision: AMM_RESERVE_PRECISION']; - type: 'u64'; - }, - { - name: 'fillRecordId'; - type: 'u64'; - }, - { - name: 'userOrderId'; - type: 'u32'; - }, - { - name: 'liquidatorOrderId'; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - docs: ['precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'ifFee'; - docs: ['precision: QUOTE_PRECISION']; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'liquidateSpotRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'assetMarketIndex'; - type: 'u16'; - }, - { - name: 'assetPrice'; - type: 'i64'; - }, - { - name: 'assetTransfer'; - type: 'u128'; - }, - { - name: 'liabilityMarketIndex'; - type: 'u16'; - }, - { - name: 'liabilityPrice'; - type: 'i64'; - }, - { - name: 'liabilityTransfer'; - docs: ['precision: token mint precision']; - type: 'u128'; - }, - { - name: 'ifFee'; - docs: ['precision: token mint precision']; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'liquidationRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'liquidationType'; - type: { - defined: { - name: 'liquidationType'; - }; - }; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'liquidator'; - type: 'pubkey'; - }, - { - name: 'marginRequirement'; - type: 'u128'; - }, - { - name: 'totalCollateral'; - type: 'i128'; - }, - { - name: 'marginFreed'; - type: 'u64'; - }, - { - name: 'liquidationId'; - type: 'u16'; - }, - { - name: 'bankrupt'; - type: 'bool'; - }, - { - name: 'canceledOrderIds'; - type: { - vec: 'u32'; - }; - }, - { - name: 'liquidatePerp'; - type: { - defined: { - name: 'liquidatePerpRecord'; - }; - }; - }, - { - name: 'liquidateSpot'; - type: { - defined: { - name: 'liquidateSpotRecord'; - }; - }; - }, - { - name: 'liquidateBorrowForPerpPnl'; - type: { - defined: { - name: 'liquidateBorrowForPerpPnlRecord'; - }; - }; - }, - { - name: 'liquidatePerpPnlForDeposit'; - type: { - defined: { - name: 'liquidatePerpPnlForDepositRecord'; - }; - }; - }, - { - name: 'perpBankruptcy'; - type: { - defined: { - name: 'perpBankruptcyRecord'; - }; - }; - }, - { - name: 'spotBankruptcy'; - type: { - defined: { - name: 'spotBankruptcyRecord'; - }; - }; - }, - ]; - }; - }, - { - name: 'liquidationType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'liquidatePerp'; - }, - { - name: 'liquidateSpot'; - }, - { - name: 'liquidateBorrowForPerpPnl'; - }, - { - name: 'liquidatePerpPnlForDeposit'; - }, - { - name: 'perpBankruptcy'; - }, - { - name: 'spotBankruptcy'; - }, - ]; - }; - }, - { - name: 'lpPoolParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'maxSettleQuoteAmount'; - type: { - option: 'u64'; - }; - }, - { - name: 'volatility'; - type: { - option: 'u64'; - }; - }, - { - name: 'gammaExecution'; - type: { - option: 'u8'; - }; - }, - { - name: 'xi'; - type: { - option: 'u8'; - }; - }, - { - name: 'maxAum'; - type: { - option: 'u128'; - }; - }, - { - name: 'whitelistMint'; - type: { - option: 'pubkey'; - }; - }, - ]; - }; - }, - { - name: 'marginMode'; - type: { - kind: 'enum'; - variants: [ - { - name: 'default'; - }, - { - name: 'highLeverage'; - }, - { - name: 'highLeverageMaintenance'; - }, - ]; - }; - }, - { - name: 'marketStatus'; - type: { - kind: 'enum'; - variants: [ - { - name: 'initialized'; - }, - { - name: 'active'; - }, - { - name: 'fundingPaused'; - }, - { - name: 'ammPaused'; - }, - { - name: 'fillPaused'; - }, - { - name: 'withdrawPaused'; - }, - { - name: 'reduceOnly'; - }, - { - name: 'settlement'; - }, - { - name: 'delisted'; - }, - ]; - }; - }, - { - name: 'marketType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'spot'; - }, - { - name: 'perp'; - }, - ]; - }; - }, - { - name: 'modifyOrderParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'direction'; - type: { - option: { - defined: { - name: 'positionDirection'; - }; - }; - }; - }, - { - name: 'baseAssetAmount'; - type: { - option: 'u64'; - }; - }, - { - name: 'price'; - type: { - option: 'u64'; - }; - }, - { - name: 'reduceOnly'; - type: { - option: 'bool'; - }; - }, - { - name: 'postOnly'; - type: { - option: { - defined: { - name: 'postOnlyParam'; - }; - }; - }; - }, - { - name: 'bitFlags'; - type: { - option: 'u8'; - }; - }, - { - name: 'maxTs'; - type: { - option: 'i64'; - }; - }, - { - name: 'triggerPrice'; - type: { - option: 'u64'; - }; - }, - { - name: 'triggerCondition'; - type: { - option: { - defined: { - name: 'orderTriggerCondition'; - }; - }; - }; - }, - { - name: 'oraclePriceOffset'; - type: { - option: 'i32'; - }; - }, - { - name: 'auctionDuration'; - type: { - option: 'u8'; - }; - }, - { - name: 'auctionStartPrice'; - type: { - option: 'i64'; - }; - }, - { - name: 'auctionEndPrice'; - type: { - option: 'i64'; - }; - }, - { - name: 'policy'; - type: { - option: 'u8'; - }; - }, - ]; - }; - }, - { - name: 'newUserRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - docs: ['unix_timestamp of action']; - type: 'i64'; - }, - { - name: 'userAuthority'; - type: 'pubkey'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'subAccountId'; - type: 'u16'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'referrer'; - type: 'pubkey'; - }, - ]; - }; - }, - { - name: 'openbookV2FulfillmentConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - type: 'pubkey'; - }, - { - name: 'openbookV2ProgramId'; - type: 'pubkey'; - }, - { - name: 'openbookV2Market'; - type: 'pubkey'; - }, - { - name: 'openbookV2MarketAuthority'; - type: 'pubkey'; - }, - { - name: 'openbookV2EventHeap'; - type: 'pubkey'; - }, - { - name: 'openbookV2Bids'; - type: 'pubkey'; - }, - { - name: 'openbookV2Asks'; - type: 'pubkey'; - }, - { - name: 'openbookV2BaseVault'; - type: 'pubkey'; - }, - { - name: 'openbookV2QuoteVault'; - type: 'pubkey'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fulfillmentType'; - type: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }, - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - ]; - }; - }, - { - name: 'oracleGuardRails'; - type: { - kind: 'struct'; - fields: [ - { - name: 'priceDivergence'; - type: { - defined: { - name: 'priceDivergenceGuardRails'; - }; - }; - }, - { - name: 'validity'; - type: { - defined: { - name: 'validityGuardRails'; - }; - }; - }, - ]; - }; - }, - { - name: 'oracleSource'; - type: { - kind: 'enum'; - variants: [ - { - name: 'pyth'; - }, - { - name: 'switchboard'; - }, - { - name: 'quoteAsset'; - }, - { - name: 'pyth1K'; - }, - { - name: 'pyth1M'; - }, - { - name: 'pythStableCoin'; - }, - { - name: 'prelaunch'; - }, - { - name: 'pythPull'; - }, - { - name: 'pyth1KPull'; - }, - { - name: 'pyth1MPull'; - }, - { - name: 'pythStableCoinPull'; - }, - { - name: 'switchboardOnDemand'; - }, - { - name: 'pythLazer'; - }, - { - name: 'pythLazer1K'; - }, - { - name: 'pythLazer1M'; - }, - { - name: 'pythLazerStableCoin'; - }, - ]; - }; - }, - { - name: 'order'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'slot'; - docs: ['The slot the order was placed']; - type: 'u64'; - }, - { - name: 'price'; - docs: [ - 'The limit price for the order (can be 0 for market orders)', - "For orders with an auction, this price isn't used until the auction is complete", - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'baseAssetAmount'; - docs: [ - 'The size of the order', - 'precision for perps: BASE_PRECISION', - 'precision for spot: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'baseAssetAmountFilled'; - docs: [ - 'The amount of the order filled', - 'precision for perps: BASE_PRECISION', - 'precision for spot: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'quoteAssetAmountFilled'; - docs: [ - 'The amount of quote filled for the order', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'triggerPrice'; - docs: [ - 'At what price the order will be triggered. Only relevant for trigger orders', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'auctionStartPrice'; - docs: [ - 'The start price for the auction. Only relevant for market/oracle orders', - 'precision: PRICE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'auctionEndPrice'; - docs: [ - 'The end price for the auction. Only relevant for market/oracle orders', - 'precision: PRICE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'maxTs'; - docs: ['The time when the order will expire']; - type: 'i64'; - }, - { - name: 'oraclePriceOffset'; - docs: [ - 'If set, the order limit price is the oracle price + this offset', - 'precision: PRICE_PRECISION', - ]; - type: 'i32'; - }, - { - name: 'orderId'; - docs: [ - 'The id for the order. Each users has their own order id space', - ]; - type: 'u32'; - }, - { - name: 'marketIndex'; - docs: ['The perp/spot market index']; - type: 'u16'; - }, - { - name: 'status'; - docs: ['Whether the order is open or unused']; - type: { - defined: { - name: 'orderStatus'; - }; - }; - }, - { - name: 'orderType'; - docs: ['The type of order']; - type: { - defined: { - name: 'orderType'; - }; - }; - }, - { - name: 'marketType'; - docs: ['Whether market is spot or perp']; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'userOrderId'; - docs: [ - 'User generated order id. Can make it easier to place/cancel orders', - ]; - type: 'u8'; - }, - { - name: 'existingPositionDirection'; - docs: ['What the users position was when the order was placed']; - type: { - defined: { - name: 'positionDirection'; - }; - }; - }, - { - name: 'direction'; - docs: [ - 'Whether the user is going long or short. LONG = bid, SHORT = ask', - ]; - type: { - defined: { - name: 'positionDirection'; - }; - }; - }, - { - name: 'reduceOnly'; - docs: ['Whether the order is allowed to only reduce position size']; - type: 'bool'; - }, - { - name: 'postOnly'; - docs: ['Whether the order must be a maker']; - type: 'bool'; - }, - { - name: 'immediateOrCancel'; - docs: [ - 'Whether the order must be canceled the same slot it is placed', - ]; - type: 'bool'; - }, - { - name: 'triggerCondition'; - docs: [ - 'Whether the order is triggered above or below the trigger price. Only relevant for trigger orders', - ]; - type: { - defined: { - name: 'orderTriggerCondition'; - }; - }; - }, - { - name: 'auctionDuration'; - docs: ['How many slots the auction lasts']; - type: 'u8'; - }, - { - name: 'postedSlotTail'; - docs: [ - 'Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)', - ]; - type: 'u8'; - }, - { - name: 'bitFlags'; - docs: [ - 'Bitflags for further classification', - '0: is_signed_message', - ]; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 1]; - }; - }, - ]; - }; - }, - { - name: 'orderAction'; - type: { - kind: 'enum'; - variants: [ - { - name: 'place'; - }, - { - name: 'cancel'; - }, - { - name: 'fill'; - }, - { - name: 'trigger'; - }, - { - name: 'expire'; - }, - ]; - }; - }, - { - name: 'orderActionExplanation'; - type: { - kind: 'enum'; - variants: [ - { - name: 'none'; - }, - { - name: 'insufficientFreeCollateral'; - }, - { - name: 'oraclePriceBreachedLimitPrice'; - }, - { - name: 'marketOrderFilledToLimitPrice'; - }, - { - name: 'orderExpired'; - }, - { - name: 'liquidation'; - }, - { - name: 'orderFilledWithAmm'; - }, - { - name: 'orderFilledWithAmmJit'; - }, - { - name: 'orderFilledWithMatch'; - }, - { - name: 'orderFilledWithMatchJit'; - }, - { - name: 'marketExpired'; - }, - { - name: 'riskingIncreasingOrder'; - }, - { - name: 'reduceOnlyOrderIncreasedPosition'; - }, - { - name: 'orderFillWithSerum'; - }, - { - name: 'noBorrowLiquidity'; - }, - { - name: 'orderFillWithPhoenix'; - }, - { - name: 'orderFilledWithAmmJitLpSplit'; - }, - { - name: 'orderFilledWithLpJit'; - }, - { - name: 'deriskLp'; - }, - { - name: 'orderFilledWithOpenbookV2'; - }, - { - name: 'transferPerpPosition'; - }, - ]; - }; - }, - { - name: 'orderActionRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'action'; - type: { - defined: { - name: 'orderAction'; - }; - }; - }, - { - name: 'actionExplanation'; - type: { - defined: { - name: 'orderActionExplanation'; - }; - }; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'marketType'; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'filler'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'fillerReward'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'fillRecordId'; - type: { - option: 'u64'; - }; - }, - { - name: 'baseAssetAmountFilled'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'quoteAssetAmountFilled'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'takerFee'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'makerFee'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'i64'; - }; - }, - { - name: 'referrerReward'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u32'; - }; - }, - { - name: 'quoteAssetAmountSurplus'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'i64'; - }; - }, - { - name: 'spotFulfillmentMethodFee'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'taker'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'takerOrderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'takerOrderDirection'; - type: { - option: { - defined: { - name: 'positionDirection'; - }; - }; - }; - }, - { - name: 'takerOrderBaseAssetAmount'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'takerOrderCumulativeBaseAssetAmountFilled'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'takerOrderCumulativeQuoteAssetAmountFilled'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'maker'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'makerOrderId'; - type: { - option: 'u32'; - }; - }, - { - name: 'makerOrderDirection'; - type: { - option: { - defined: { - name: 'positionDirection'; - }; - }; - }; - }, - { - name: 'makerOrderBaseAssetAmount'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'makerOrderCumulativeBaseAssetAmountFilled'; - docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; - type: { - option: 'u64'; - }; - }, - { - name: 'makerOrderCumulativeQuoteAssetAmountFilled'; - docs: ['precision: QUOTE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'oraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'bitFlags'; - docs: ['Bit flags:', '0: is_signed_message']; - type: 'u8'; - }, - { - name: 'takerExistingQuoteEntryAmount'; - docs: [ - 'precision: QUOTE_PRECISION', - 'Only Some if the taker reduced position', - ]; - type: { - option: 'u64'; - }; - }, - { - name: 'takerExistingBaseAssetAmount'; - docs: [ - 'precision: BASE_PRECISION', - 'Only Some if the taker flipped position direction', - ]; - type: { - option: 'u64'; - }; - }, - { - name: 'makerExistingQuoteEntryAmount'; - docs: [ - 'precision: QUOTE_PRECISION', - 'Only Some if the maker reduced position', - ]; - type: { - option: 'u64'; - }; - }, - { - name: 'makerExistingBaseAssetAmount'; - docs: [ - 'precision: BASE_PRECISION', - 'Only Some if the maker flipped position direction', - ]; - type: { - option: 'u64'; - }; - }, - { - name: 'triggerPrice'; - docs: ['precision: PRICE_PRECISION']; - type: { - option: 'u64'; - }; - }, - { - name: 'builderIdx'; - docs: [ - "the idx of the builder in the taker's [`RevenueShareEscrow`] account", - ]; - type: { - option: 'u8'; - }; - }, - { - name: 'builderFee'; - docs: ['precision: QUOTE_PRECISION builder fee paid by the taker']; - type: { - option: 'u64'; - }; - }, - ]; - }; - }, - { - name: 'orderFillerRewardStructure'; - type: { - kind: 'struct'; - fields: [ - { - name: 'rewardNumerator'; - type: 'u32'; - }, - { - name: 'rewardDenominator'; - type: 'u32'; - }, - { - name: 'timeBasedRewardLowerBound'; - type: { - defined: { - name: 'u128'; - }; - }; - }, - ]; - }; - }, - { - name: 'orderParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'orderType'; - type: { - defined: { - name: 'orderType'; - }; - }; - }, - { - name: 'marketType'; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'direction'; - type: { - defined: { - name: 'positionDirection'; - }; - }; - }, - { - name: 'userOrderId'; - type: 'u8'; - }, - { - name: 'baseAssetAmount'; - type: 'u64'; - }, - { - name: 'price'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'reduceOnly'; - type: 'bool'; - }, - { - name: 'postOnly'; - type: { - defined: { - name: 'postOnlyParam'; - }; - }; - }, - { - name: 'bitFlags'; - type: 'u8'; - }, - { - name: 'maxTs'; - type: { - option: 'i64'; - }; - }, - { - name: 'triggerPrice'; - type: { - option: 'u64'; - }; - }, - { - name: 'triggerCondition'; - type: { - defined: { - name: 'orderTriggerCondition'; - }; - }; - }, - { - name: 'oraclePriceOffset'; - type: { - option: 'i32'; - }; - }, - { - name: 'auctionDuration'; - type: { - option: 'u8'; - }; - }, - { - name: 'auctionStartPrice'; - type: { - option: 'i64'; - }; - }, - { - name: 'auctionEndPrice'; - type: { - option: 'i64'; - }; - }, - ]; - }; - }, - { - name: 'orderRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'order'; - type: { - defined: { - name: 'order'; - }; - }; - }, - ]; - }; - }, - { - name: 'orderStatus'; - type: { - kind: 'enum'; - variants: [ - { - name: 'init'; - }, - { - name: 'open'; - }, - { - name: 'filled'; - }, - { - name: 'canceled'; - }, - ]; - }; - }, - { - name: 'orderTriggerCondition'; - type: { - kind: 'enum'; - variants: [ - { - name: 'above'; - }, - { - name: 'below'; - }, - { - name: 'triggeredAbove'; - }, - { - name: 'triggeredBelow'; - }, - ]; - }; - }, - { - name: 'orderType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'market'; - }, - { - name: 'limit'; - }, - { - name: 'triggerMarket'; - }, - { - name: 'triggerLimit'; - }, - { - name: 'oracle'; - }, - ]; - }; - }, - { - name: 'overrideAmmCacheParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'quoteOwedFromLpPool'; - type: { - option: 'i64'; - }; - }, - { - name: 'lastSettleSlot'; - type: { - option: 'u64'; - }; - }, - { - name: 'lastFeePoolTokenAmount'; - type: { - option: 'u128'; - }; - }, - { - name: 'lastNetPnlPoolTokenAmount'; - type: { - option: 'i128'; - }; - }, - { - name: 'ammPositionScalar'; - type: { - option: 'u8'; - }; - }, - { - name: 'ammInventoryLimit'; - type: { - option: 'i64'; - }; - }, - ]; - }; - }, - { - name: 'perpBankruptcyRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'pnl'; - type: 'i128'; - }, - { - name: 'ifPayment'; - type: 'u128'; - }, - { - name: 'clawbackUser'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'clawbackUserPayment'; - type: { - option: 'u128'; - }; - }, - { - name: 'cumulativeFundingRateDelta'; - type: 'i128'; - }, - ]; - }; - }, - { - name: 'perpMarket'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - docs: [ - "The perp market's address. It is a pda of the market index", - ]; - type: 'pubkey'; - }, - { - name: 'amm'; - docs: ['The automated market maker']; - type: { - defined: { - name: 'amm'; - }; - }; - }, - { - name: 'pnlPool'; - docs: [ - "The market's pnl pool. When users settle negative pnl, the balance increases.", - 'When users settle positive pnl, the balance decreases. Can not go negative.', - ]; - type: { - defined: { - name: 'poolBalance'; - }; - }; - }, - { - name: 'name'; - docs: ['Encoded display name for the perp market e.g. SOL-PERP']; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'insuranceClaim'; - docs: ["The perp market's claim on the insurance fund"]; - type: { - defined: { - name: 'insuranceClaim'; - }; - }; - }, - { - name: 'unrealizedPnlMaxImbalance'; - docs: [ - 'The max pnl imbalance before positive pnl asset weight is discounted', - "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", - 'the amm has negative pnl and the initial asset weight for positive pnl is discounted', - 'precision = QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'expiryTs'; - docs: [ - 'The ts when the market will be expired. Only set if market is in reduce only mode', - ]; - type: 'i64'; - }, - { - name: 'expiryPrice'; - docs: [ - 'The price at which positions will be settled. Only set if market is expired', - 'precision = PRICE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'nextFillRecordId'; - docs: [ - 'Every trade has a fill record id. This is the next id to be used', - ]; - type: 'u64'; - }, - { - name: 'nextFundingRateRecordId'; - docs: [ - 'Every funding rate update has a record id. This is the next id to be used', - ]; - type: 'u64'; - }, - { - name: 'nextCurveRecordId'; - docs: [ - 'Every amm k updated has a record id. This is the next id to be used', - ]; - type: 'u64'; - }, - { - name: 'imfFactor'; - docs: [ - 'The initial margin fraction factor. Used to increase margin ratio for large positions', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'unrealizedPnlImfFactor'; - docs: [ - 'The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - docs: [ - 'The fee the liquidator is paid for taking over perp position', - 'precision: LIQUIDATOR_FEE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - docs: [ - 'The fee the insurance fund receives from liquidation', - 'precision: LIQUIDATOR_FEE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'marginRatioInitial'; - docs: [ - 'The margin ratio which determines how much collateral is required to open a position', - 'e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'marginRatioMaintenance'; - docs: [ - 'The margin ratio which determines when a user will be liquidated', - 'e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position', - 'else they will be liquidated', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'unrealizedPnlInitialAssetWeight'; - docs: [ - 'The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'unrealizedPnlMaintenanceAssetWeight'; - docs: [ - 'The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'numberOfUsersWithBase'; - docs: ['number of users in a position (base)']; - type: 'u32'; - }, - { - name: 'numberOfUsers'; - docs: ['number of users in a position (pnl) or pnl (quote)']; - type: 'u32'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'status'; - docs: [ - 'Whether a market is active, reduce only, expired, etc', - 'Affects whether users can open/close positions', - ]; - type: { - defined: { - name: 'marketStatus'; - }; - }; - }, - { - name: 'contractType'; - docs: ['Currently only Perpetual markets are supported']; - type: { - defined: { - name: 'contractType'; - }; - }; - }, - { - name: 'contractTier'; - docs: [ - 'The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance', - 'It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first', - ]; - type: { - defined: { - name: 'contractTier'; - }; - }; - }, - { - name: 'pausedOperations'; - type: 'u8'; - }, - { - name: 'quoteSpotMarketIndex'; - docs: ['The spot market that pnl is settled in']; - type: 'u16'; - }, - { - name: 'feeAdjustment'; - docs: [ - 'Between -100 and 100, represents what % to increase/decrease the fee by', - 'E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps', - 'if this is 50 and the fee is 5bps, the new fee will be 7.5bps', - ]; - type: 'i16'; - }, - { - name: 'fuelBoostPosition'; - docs: ['fuel multiplier for perp funding', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostTaker'; - docs: ['fuel multiplier for perp taker', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostMaker'; - docs: ['fuel multiplier for perp maker', 'precision: 10']; - type: 'u8'; - }, - { - name: 'poolId'; - type: 'u8'; - }, - { - name: 'highLeverageMarginRatioInitial'; - type: 'u16'; - }, - { - name: 'highLeverageMarginRatioMaintenance'; - type: 'u16'; - }, - { - name: 'protectedMakerLimitPriceDivisor'; - type: 'u8'; - }, - { - name: 'protectedMakerDynamicDivisor'; - type: 'u8'; - }, - { - name: 'lpFeeTransferScalar'; - type: 'u8'; - }, - { - name: 'lpStatus'; - type: 'u8'; - }, - { - name: 'lpPausedOperations'; - type: 'u8'; - }, - { - name: 'lpExchangeFeeExcluscionScalar'; - type: 'u8'; - }, - { - name: 'lastFillPrice'; - type: 'u64'; - }, - { - name: 'lpPoolId'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 23]; - }; - }, - ]; - }; - }, - { - name: 'perpPosition'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'lastCumulativeFundingRate'; - docs: [ - "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", - 'precision: FUNDING_RATE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'baseAssetAmount'; - docs: [ - 'the size of the users perp position', - 'precision: BASE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'quoteAssetAmount'; - docs: [ - 'Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees', - 'Updated when the user open/closes position or settles pnl. Includes fees/funding', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'quoteBreakEvenAmount'; - docs: [ - 'The amount of quote the user would need to exit their position at to break even', - 'Updated when the user open/closes position or settles pnl. Includes fees/funding', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'quoteEntryAmount'; - docs: [ - 'The amount quote the user entered the position with. Equal to base asset amount * avg entry price', - 'Updated when the user open/closes position. Excludes fees/funding', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'openBids'; - docs: [ - 'The amount of non reduce only trigger orders the user has open', - 'precision: BASE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'openAsks'; - docs: [ - 'The amount of non reduce only trigger orders the user has open', - 'precision: BASE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'settledPnl'; - docs: [ - 'The amount of pnl settled in this market since opening the position', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lpShares'; - docs: [ - 'The number of lp (liquidity provider) shares the user has in this perp market', - 'LP shares allow users to provide liquidity via the AMM', - 'precision: BASE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastBaseAssetAmountPerLp'; - docs: [ - 'The last base asset amount per lp the amm had', - 'Used to settle the users lp position', - 'precision: BASE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'lastQuoteAssetAmountPerLp'; - docs: [ - 'The last quote asset amount per lp the amm had', - 'Used to settle the users lp position', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'padding'; - type: { - array: ['u8', 2]; - }; - }, - { - name: 'maxMarginRatio'; - type: 'u16'; - }, - { - name: 'marketIndex'; - docs: ['The market index for the perp market']; - type: 'u16'; - }, - { - name: 'openOrders'; - docs: ['The number of open orders']; - type: 'u8'; - }, - { - name: 'perLpBase'; - type: 'i8'; - }, - ]; - }; - }, - { - name: 'phoenixV1FulfillmentConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - type: 'pubkey'; - }, - { - name: 'phoenixProgramId'; - type: 'pubkey'; - }, - { - name: 'phoenixLogAuthority'; - type: 'pubkey'; - }, - { - name: 'phoenixMarket'; - type: 'pubkey'; - }, - { - name: 'phoenixBaseVault'; - type: 'pubkey'; - }, - { - name: 'phoenixQuoteVault'; - type: 'pubkey'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fulfillmentType'; - type: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }, - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - ]; - }; - }, - { - name: 'poolBalance'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'scaledBalance'; - docs: [ - "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", - 'deposit interest', - 'precision: SPOT_BALANCE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'marketIndex'; - docs: ['The spot market the pool is for']; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 6]; - }; - }, - ]; - }; - }, - { - name: 'positionDirection'; - type: { - kind: 'enum'; - variants: [ - { - name: 'long'; - }, - { - name: 'short'; - }, - ]; - }; - }, - { - name: 'postOnlyParam'; - type: { - kind: 'enum'; - variants: [ - { - name: 'none'; - }, - { - name: 'mustPostOnly'; - }, - { - name: 'tryPostOnly'; - }, - { - name: 'slide'; - }, - ]; - }; - }, - { - name: 'prelaunchOracle'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'price'; - type: 'i64'; - }, - { - name: 'maxPrice'; - type: 'i64'; - }, - { - name: 'confidence'; - type: 'u64'; - }, - { - name: 'lastUpdateSlot'; - type: 'u64'; - }, - { - name: 'ammLastUpdateSlot'; - type: 'u64'; - }, - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'padding'; - type: { - array: ['u8', 70]; - }; - }, - ]; - }; - }, - { - name: 'prelaunchOracleParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'perpMarketIndex'; - type: 'u16'; - }, - { - name: 'price'; - type: { - option: 'i64'; - }; - }, - { - name: 'maxPrice'; - type: { - option: 'i64'; - }; - }, - ]; - }; - }, - { - name: 'priceDivergenceGuardRails'; - type: { - kind: 'struct'; - fields: [ - { - name: 'markOraclePercentDivergence'; - type: 'u64'; - }, - { - name: 'oracleTwap5minPercentDivergence'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'protectedMakerModeConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'maxUsers'; - type: 'u32'; - }, - { - name: 'currentUsers'; - type: 'u32'; - }, - { - name: 'reduceOnly'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 31]; - }; - }, - ]; - }; - }, - { - name: 'pythLazerOracle'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'price'; - type: 'i64'; - }, - { - name: 'publishTime'; - type: 'u64'; - }, - { - name: 'postedSlot'; - type: 'u64'; - }, - { - name: 'exponent'; - type: 'i32'; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - { - name: 'conf'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'referrerName'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - type: 'pubkey'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'userStats'; - type: 'pubkey'; - }, - { - name: 'name'; - type: { - array: ['u8', 32]; - }; - }, - ]; - }; - }, - { - name: 'revenueShare'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'rust'; - packed: true; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['the owner of this account, a builder or referrer']; - type: 'pubkey'; - }, - { - name: 'totalReferrerRewards'; - type: 'u64'; - }, - { - name: 'totalBuilderRewards'; - type: 'u64'; - }, - { - name: 'padding'; - type: { - array: ['u8', 18]; - }; - }, - ]; - }; - }, - { - name: 'revenueShareEscrow'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['the owner of this account, a user']; - type: 'pubkey'; - }, - { - name: 'referrer'; - type: 'pubkey'; - }, - { - name: 'referrerBoostExpireTs'; - type: 'u32'; - }, - { - name: 'referrerRewardOffset'; - type: 'i8'; - }, - { - name: 'refereeFeeNumeratorOffset'; - type: 'i8'; - }, - { - name: 'referrerBoostNumerator'; - type: 'i8'; - }, - { - name: 'reservedFixed'; - type: { - array: ['u8', 17]; - }; - }, - { - name: 'padding0'; - type: 'u32'; - }, - { - name: 'orders'; - type: { - vec: { - defined: { - name: 'revenueShareOrder'; - }; - }; - }; - }, - { - name: 'padding1'; - type: 'u32'; - }, - { - name: 'approvedBuilders'; - type: { - vec: { - defined: { - name: 'builderInfo'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'revenueShareOrder'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'feesAccrued'; - docs: [ - 'fees accrued so far for this order slot. This is not exclusively fees from this order_id', - 'and may include fees from other orders in the same market. This may be swept to the', - "builder's SpotPosition during settle_pnl.", - ]; - type: 'u64'; - }, - { - name: 'orderId'; - docs: [ - "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open", - ]; - type: 'u32'; - }, - { - name: 'feeTenthBps'; - docs: [ - 'the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%', - ]; - type: 'u16'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'subAccountId'; - docs: [ - "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open", - ]; - type: 'u16'; - }, - { - name: 'builderIdx'; - docs: [ - "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", - 'if bit_flag = Referral.', - ]; - type: 'u8'; - }, - { - name: 'bitFlags'; - docs: [ - 'bitflags that describe the state of the order.', - '[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.', - "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", - '[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.', - "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", - '[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.', - 'If it is set, no other bitflag should be set.', - ]; - type: 'u8'; - }, - { - name: 'userOrderIndex'; - docs: [ - "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches.", - ]; - type: 'u8'; - }, - { - name: 'marketType'; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 10]; - }; - }, - ]; - }; - }, - { - name: 'revenueShareSettleRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'builder'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'referrer'; - type: { - option: 'pubkey'; - }; - }, - { - name: 'feeSettled'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'marketType'; - type: { - defined: { - name: 'marketType'; - }; - }; - }, - { - name: 'builderSubAccountId'; - type: 'u16'; - }, - { - name: 'builderTotalReferrerRewards'; - type: 'u64'; - }, - { - name: 'builderTotalBuilderRewards'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'serumV3FulfillmentConfig'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - type: 'pubkey'; - }, - { - name: 'serumProgramId'; - type: 'pubkey'; - }, - { - name: 'serumMarket'; - type: 'pubkey'; - }, - { - name: 'serumRequestQueue'; - type: 'pubkey'; - }, - { - name: 'serumEventQueue'; - type: 'pubkey'; - }, - { - name: 'serumBids'; - type: 'pubkey'; - }, - { - name: 'serumAsks'; - type: 'pubkey'; - }, - { - name: 'serumBaseVault'; - type: 'pubkey'; - }, - { - name: 'serumQuoteVault'; - type: 'pubkey'; - }, - { - name: 'serumOpenOrders'; - type: 'pubkey'; - }, - { - name: 'serumSignerNonce'; - type: 'u64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'fulfillmentType'; - type: { - defined: { - name: 'spotFulfillmentType'; - }; - }; - }, - { - name: 'status'; - type: { - defined: { - name: 'spotFulfillmentConfigStatus'; - }; - }; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - ]; - }; - }, - { - name: 'settlePnlExplanation'; - type: { - kind: 'enum'; - variants: [ - { - name: 'none'; - }, - { - name: 'expiredPosition'; - }, - ]; - }; - }, - { - name: 'settlePnlMode'; - type: { - kind: 'enum'; - variants: [ - { - name: 'mustSettle'; - }, - { - name: 'trySettle'; - }, - ]; - }; - }, - { - name: 'settlePnlRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'pnl'; - type: 'i128'; - }, - { - name: 'baseAssetAmount'; - type: 'i64'; - }, - { - name: 'quoteAssetAmountAfter'; - type: 'i64'; - }, - { - name: 'quoteEntryAmount'; - type: 'i64'; - }, - { - name: 'settlePrice'; - type: 'i64'; - }, - { - name: 'explanation'; - type: { - defined: { - name: 'settlePnlExplanation'; - }; - }; - }, - ]; - }; - }, - { - name: 'signedMsgOrderId'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'uuid'; - type: { - array: ['u8', 8]; - }; - }, - { - name: 'maxSlot'; - type: 'u64'; - }, - { - name: 'orderId'; - type: 'u32'; - }, - { - name: 'padding'; - type: 'u32'; - }, - ]; - }; - }, - { - name: 'signedMsgOrderRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'hash'; - type: 'string'; - }, - { - name: 'matchingOrderParams'; - type: { - defined: { - name: 'orderParams'; - }; - }; - }, - { - name: 'userOrderId'; - type: 'u32'; - }, - { - name: 'signedMsgOrderMaxSlot'; - type: 'u64'; - }, - { - name: 'signedMsgOrderUuid'; - type: { - array: ['u8', 8]; - }; - }, - { - name: 'ts'; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'signedMsgUserOrders'; - docs: [ - '* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently', - ]; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authorityPubkey'; - type: 'pubkey'; - }, - { - name: 'padding'; - type: 'u32'; - }, - { - name: 'signedMsgOrderData'; - type: { - vec: { - defined: { - name: 'signedMsgOrderId'; - }; - }; - }; - }, - ]; - }; - }, - { - name: 'signedMsgWsDelegates'; - docs: [ - '* Used to store authenticated delegates for swift-like ws connections', - ]; - type: { - kind: 'struct'; - fields: [ - { - name: 'delegates'; - type: { - vec: 'pubkey'; - }; - }, - ]; - }; - }, - { - name: 'spotBalanceType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'deposit'; - }, - { - name: 'borrow'; - }, - ]; - }; - }, - { - name: 'spotBankruptcyRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'borrowAmount'; - type: 'u128'; - }, - { - name: 'ifPayment'; - type: 'u128'; - }, - { - name: 'cumulativeDepositInterestDelta'; - type: 'u128'; - }, - ]; - }; - }, - { - name: 'spotFulfillmentConfigStatus'; - type: { - kind: 'enum'; - variants: [ - { - name: 'enabled'; - }, - { - name: 'disabled'; - }, - ]; - }; - }, - { - name: 'spotFulfillmentType'; - type: { - kind: 'enum'; - variants: [ - { - name: 'serumV3'; - }, - { - name: 'match'; - }, - { - name: 'phoenixV1'; - }, - { - name: 'openbookV2'; - }, - ]; - }; - }, - { - name: 'spotInterestRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'depositBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'cumulativeDepositInterest'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'borrowBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'cumulativeBorrowInterest'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'optimalUtilization'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - { - name: 'optimalBorrowRate'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - { - name: 'maxBorrowRate'; - docs: ['precision: PERCENTAGE_PRECISION']; - type: 'u32'; - }, - ]; - }; - }, - { - name: 'spotMarket'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'pubkey'; - docs: [ - 'The address of the spot market. It is a pda of the market index', - ]; - type: 'pubkey'; - }, - { - name: 'oracle'; - docs: ['The oracle used to price the markets deposits/borrows']; - type: 'pubkey'; - }, - { - name: 'mint'; - docs: ['The token mint of the market']; - type: 'pubkey'; - }, - { - name: 'vault'; - docs: [ - "The vault used to store the market's deposits", - 'The amount in the vault should be equal to or greater than deposits - borrows', - ]; - type: 'pubkey'; - }, - { - name: 'name'; - docs: ['The encoded display name for the market e.g. SOL']; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'historicalOracleData'; - type: { - defined: { - name: 'historicalOracleData'; - }; - }; - }, - { - name: 'historicalIndexData'; - type: { - defined: { - name: 'historicalIndexData'; - }; - }; - }, - { - name: 'revenuePool'; - docs: [ - 'Revenue the protocol has collected in this markets token', - 'e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool', - ]; - type: { - defined: { - name: 'poolBalance'; - }; - }; - }, - { - name: 'spotFeePool'; - docs: [ - 'The fees collected from swaps between this market and the quote market', - 'Is settled to the quote markets revenue pool', - ]; - type: { - defined: { - name: 'poolBalance'; - }; - }; - }, - { - name: 'insuranceFund'; - docs: [ - 'Details on the insurance fund covering bankruptcies in this markets token', - 'Covers bankruptcies for borrows with this markets token and perps settling in this markets token', - ]; - type: { - defined: { - name: 'insuranceFund'; - }; - }; - }, - { - name: 'totalSpotFee'; - docs: [ - 'The total spot fees collected for this market', - 'precision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'depositBalance'; - docs: [ - 'The sum of the scaled balances for deposits across users and pool balances', - 'To convert to the deposit token amount, multiply by the cumulative deposit interest', - 'precision: SPOT_BALANCE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'borrowBalance'; - docs: [ - 'The sum of the scaled balances for borrows across users and pool balances', - 'To convert to the borrow token amount, multiply by the cumulative borrow interest', - 'precision: SPOT_BALANCE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeDepositInterest'; - docs: [ - 'The cumulative interest earned by depositors', - 'Used to calculate the deposit token amount from the deposit balance', - 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'cumulativeBorrowInterest'; - docs: [ - 'The cumulative interest earned by borrowers', - 'Used to calculate the borrow token amount from the borrow balance', - 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalSocialLoss'; - docs: [ - "The total socialized loss from borrows, in the mint's token", - 'precision: token mint precision', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'totalQuoteSocialLoss'; - docs: [ - "The total socialized loss from borrows, in the quote market's token", - 'preicision: QUOTE_PRECISION', - ]; - type: { - defined: { - name: 'u128'; - }; - }; - }, - { - name: 'withdrawGuardThreshold'; - docs: [ - 'no withdraw limits/guards when deposits below this threshold', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'maxTokenDeposits'; - docs: [ - 'The max amount of token deposits in this market', - '0 if there is no limit', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'depositTokenTwap'; - docs: [ - '24hr average of deposit token amount', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'borrowTokenTwap'; - docs: [ - '24hr average of borrow token amount', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'utilizationTwap'; - docs: [ - '24hr average of utilization', - 'which is borrow amount over token amount', - 'precision: SPOT_UTILIZATION_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastInterestTs'; - docs: [ - 'Last time the cumulative deposit and borrow interest was updated', - ]; - type: 'u64'; - }, - { - name: 'lastTwapTs'; - docs: [ - 'Last time the deposit/borrow/utilization averages were updated', - ]; - type: 'u64'; - }, - { - name: 'expiryTs'; - docs: [ - 'The time the market is set to expire. Only set if market is in reduce only mode', - ]; - type: 'i64'; - }, - { - name: 'orderStepSize'; - docs: [ - 'Spot orders must be a multiple of the step size', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'orderTickSize'; - docs: [ - 'Spot orders must be a multiple of the tick size', - 'precision: PRICE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'minOrderSize'; - docs: ['The minimum order size', 'precision: token mint precision']; - type: 'u64'; - }, - { - name: 'maxPositionSize'; - docs: [ - 'The maximum spot position size', - 'if the limit is 0, there is no limit', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'nextFillRecordId'; - docs: [ - 'Every spot trade has a fill record id. This is the next id to use', - ]; - type: 'u64'; - }, - { - name: 'nextDepositRecordId'; - docs: [ - 'Every deposit has a deposit record id. This is the next id to use', - ]; - type: 'u64'; - }, - { - name: 'initialAssetWeight'; - docs: [ - 'The initial asset weight used to calculate a deposits contribution to a users initial total collateral', - 'e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'maintenanceAssetWeight'; - docs: [ - 'The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral', - 'e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'initialLiabilityWeight'; - docs: [ - 'The initial liability weight used to calculate a borrows contribution to a users initial margin requirement', - 'e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'maintenanceLiabilityWeight'; - docs: [ - 'The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement', - 'e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement', - 'precision: SPOT_WEIGHT_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'imfFactor'; - docs: [ - 'The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions', - 'precision: MARGIN_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'liquidatorFee'; - docs: [ - 'The fee the liquidator is paid for taking over borrow/deposit', - 'precision: LIQUIDATOR_FEE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'ifLiquidationFee'; - docs: [ - 'The fee the insurance fund receives from liquidation', - 'precision: LIQUIDATOR_FEE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'optimalUtilization'; - docs: [ - 'The optimal utilization rate for this market.', - 'Used to determine the markets borrow rate', - 'precision: SPOT_UTILIZATION_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'optimalBorrowRate'; - docs: [ - 'The borrow rate for this market when the market has optimal utilization', - 'precision: SPOT_RATE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'maxBorrowRate'; - docs: [ - 'The borrow rate for this market when the market has 1000 utilization', - 'precision: SPOT_RATE_PRECISION', - ]; - type: 'u32'; - }, - { - name: 'decimals'; - docs: [ - "The market's token mint's decimals. To from decimals to a precision, 10^decimals", - ]; - type: 'u32'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'ordersEnabled'; - docs: ['Whether or not spot trading is enabled']; - type: 'bool'; - }, - { - name: 'oracleSource'; - type: { - defined: { - name: 'oracleSource'; - }; - }; - }, - { - name: 'status'; - type: { - defined: { - name: 'marketStatus'; - }; - }; - }, - { - name: 'assetTier'; - docs: [ - 'The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated', - ]; - type: { - defined: { - name: 'assetTier'; - }; - }; - }, - { - name: 'pausedOperations'; - type: 'u8'; - }, - { - name: 'ifPausedOperations'; - type: 'u8'; - }, - { - name: 'feeAdjustment'; - type: 'i16'; - }, - { - name: 'maxTokenBorrowsFraction'; - docs: [ - 'What fraction of max_token_deposits', - 'disabled when 0, 1 => 1/10000 => .01% of max_token_deposits', - 'precision: X/10000', - ]; - type: 'u16'; - }, - { - name: 'flashLoanAmount'; - docs: [ - 'For swaps, the amount of token loaned out in the begin_swap ix', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'flashLoanInitialTokenAmount'; - docs: [ - 'For swaps, the amount in the users token account in the begin_swap ix', - 'Used to calculate how much of the token left the system in end_swap ix', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'totalSwapFee'; - docs: [ - 'The total fees received from swaps', - 'precision: token mint precision', - ]; - type: 'u64'; - }, - { - name: 'scaleInitialAssetWeightStart'; - docs: [ - 'When to begin scaling down the initial asset weight', - 'disabled when 0', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'minBorrowRate'; - docs: [ - 'The min borrow rate for this market when the market regardless of utilization', - '1 => 1/200 => .5%', - 'precision: X/200', - ]; - type: 'u8'; - }, - { - name: 'fuelBoostDeposits'; - docs: ['fuel multiplier for spot deposits', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostBorrows'; - docs: ['fuel multiplier for spot borrows', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostTaker'; - docs: ['fuel multiplier for spot taker', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostMaker'; - docs: ['fuel multiplier for spot maker', 'precision: 10']; - type: 'u8'; - }, - { - name: 'fuelBoostInsurance'; - docs: ['fuel multiplier for spot insurance stake', 'precision: 10']; - type: 'u8'; - }, - { - name: 'tokenProgramFlag'; - type: 'u8'; - }, - { - name: 'poolId'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 40]; - }; - }, - ]; - }; - }, - { - name: 'spotMarketVaultDepositRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'depositBalance'; - docs: ['precision: SPOT_BALANCE_PRECISION']; - type: 'u128'; - }, - { - name: 'cumulativeDepositInterestBefore'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'cumulativeDepositInterestAfter'; - docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; - type: 'u128'; - }, - { - name: 'depositTokenAmountBefore'; - type: 'u64'; - }, - { - name: 'amount'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'spotPosition'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'scaledBalance'; - docs: [ - 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', - 'interest of corresponding market.', - 'precision: SPOT_BALANCE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'openBids'; - docs: [ - 'How many spot non reduce only trigger orders the user has open', - 'precision: token mint precision', - ]; - type: 'i64'; - }, - { - name: 'openAsks'; - docs: [ - 'How many spot non reduce only trigger orders the user has open', - 'precision: token mint precision', - ]; - type: 'i64'; - }, - { - name: 'cumulativeDeposits'; - docs: [ - 'The cumulative deposits/borrows a user has made into a market', - 'precision: token mint precision', - ]; - type: 'i64'; - }, - { - name: 'marketIndex'; - docs: ['The market index of the corresponding spot market']; - type: 'u16'; - }, - { - name: 'balanceType'; - docs: ['Whether the position is deposit or borrow']; - type: { - defined: { - name: 'spotBalanceType'; - }; - }; - }, - { - name: 'openOrders'; - docs: ['Number of open orders']; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - ]; - }; - }, - { - name: 'stakeAction'; - type: { - kind: 'enum'; - variants: [ - { - name: 'stake'; - }, - { - name: 'unstakeRequest'; - }, - { - name: 'unstakeCancelRequest'; - }, - { - name: 'unstake'; - }, - { - name: 'unstakeTransfer'; - }, - { - name: 'stakeTransfer'; - }, - { - name: 'adminDeposit'; - }, - ]; - }; - }, - { - name: 'state'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'admin'; - type: 'pubkey'; - }, - { - name: 'whitelistMint'; - type: 'pubkey'; - }, - { - name: 'discountMint'; - type: 'pubkey'; - }, - { - name: 'signer'; - type: 'pubkey'; - }, - { - name: 'srmVault'; - type: 'pubkey'; - }, - { - name: 'perpFeeStructure'; - type: { - defined: { - name: 'feeStructure'; - }; - }; - }, - { - name: 'spotFeeStructure'; - type: { - defined: { - name: 'feeStructure'; - }; - }; - }, - { - name: 'oracleGuardRails'; - type: { - defined: { - name: 'oracleGuardRails'; - }; - }; - }, - { - name: 'numberOfAuthorities'; - type: 'u64'; - }, - { - name: 'numberOfSubAccounts'; - type: 'u64'; - }, - { - name: 'lpCooldownTime'; - type: 'u64'; - }, - { - name: 'liquidationMarginBufferRatio'; - type: 'u32'; - }, - { - name: 'settlementDuration'; - type: 'u16'; - }, - { - name: 'numberOfMarkets'; - type: 'u16'; - }, - { - name: 'numberOfSpotMarkets'; - type: 'u16'; - }, - { - name: 'signerNonce'; - type: 'u8'; - }, - { - name: 'minPerpAuctionDuration'; - type: 'u8'; - }, - { - name: 'defaultMarketOrderTimeInForce'; - type: 'u8'; - }, - { - name: 'defaultSpotAuctionDuration'; - type: 'u8'; - }, - { - name: 'exchangeStatus'; - type: 'u8'; - }, - { - name: 'liquidationDuration'; - type: 'u8'; - }, - { - name: 'initialPctToLiquidate'; - type: 'u16'; - }, - { - name: 'maxNumberOfSubAccounts'; - type: 'u16'; - }, - { - name: 'maxInitializeUserFee'; - type: 'u16'; - }, - { - name: 'featureBitFlags'; - type: 'u8'; - }, - { - name: 'lpPoolFeatureBitFlags'; - type: 'u8'; - }, - { - name: 'padding'; - type: { - array: ['u8', 8]; - }; - }, - ]; - }; - }, - { - name: 'swapRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'user'; - type: 'pubkey'; - }, - { - name: 'amountOut'; - docs: ['precision: out market mint precision']; - type: 'u64'; - }, - { - name: 'amountIn'; - docs: ['precision: in market mint precision']; - type: 'u64'; - }, - { - name: 'outMarketIndex'; - type: 'u16'; - }, - { - name: 'inMarketIndex'; - type: 'u16'; - }, - { - name: 'outOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'inOraclePrice'; - docs: ['precision: PRICE_PRECISION']; - type: 'i64'; - }, - { - name: 'fee'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'swapReduceOnly'; - type: { - kind: 'enum'; - variants: [ - { - name: 'in'; - }, - { - name: 'out'; - }, - ]; - }; - }, - { - name: 'targetsDatum'; - serialization: 'bytemuck'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'costToTradeBps'; - type: 'i32'; - }, - { - name: 'padding'; - type: { - array: ['u8', 4]; - }; - }, - { - name: 'targetBase'; - type: 'i64'; - }, - { - name: 'lastOracleSlot'; - type: 'u64'; - }, - { - name: 'lastPositionSlot'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'transferProtocolIfSharesToRevenuePoolRecord'; - type: { - kind: 'struct'; - fields: [ - { - name: 'ts'; - type: 'i64'; - }, - { - name: 'marketIndex'; - type: 'u16'; - }, - { - name: 'amount'; - type: 'u64'; - }, - { - name: 'shares'; - type: 'u128'; - }, - { - name: 'ifVaultAmountBefore'; - type: 'u64'; - }, - { - name: 'protocolSharesBefore'; - type: 'u128'; - }, - { - name: 'transferAmount'; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'updatePerpMarketSummaryStatsParams'; - type: { - kind: 'struct'; - fields: [ - { - name: 'quoteAssetAmountWithUnsettledLp'; - type: { - option: 'i64'; - }; - }, - { - name: 'netUnsettledFundingPnl'; - type: { - option: 'i64'; - }; - }, - { - name: 'updateAmmSummaryStats'; - type: { - option: 'bool'; - }; - }, - { - name: 'excludeTotalLiqFee'; - type: { - option: 'bool'; - }; - }, - ]; - }; - }, - { - name: 'user'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['The owner/authority of the account']; - type: 'pubkey'; - }, - { - name: 'delegate'; - docs: [ - "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw", - ]; - type: 'pubkey'; - }, - { - name: 'name'; - docs: ['Encoded display name e.g. "toly"']; - type: { - array: ['u8', 32]; - }; - }, - { - name: 'spotPositions'; - docs: ["The user's spot positions"]; - type: { - array: [ - { - defined: { - name: 'spotPosition'; - }; - }, - 8, - ]; - }; - }, - { - name: 'perpPositions'; - docs: ["The user's perp positions"]; - type: { - array: [ - { - defined: { - name: 'perpPosition'; - }; - }, - 8, - ]; - }; - }, - { - name: 'orders'; - docs: ["The user's orders"]; - type: { - array: [ - { - defined: { - name: 'order'; - }; - }, - 32, - ]; - }; - }, - { - name: 'lastAddPerpLpSharesTs'; - docs: ['The last time the user added perp lp positions']; - type: 'i64'; - }, - { - name: 'totalDeposits'; - docs: [ - 'The total values of deposits the user has made', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'totalWithdraws'; - docs: [ - 'The total values of withdrawals the user has made', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'totalSocialLoss'; - docs: [ - 'The total socialized loss the users has incurred upon the protocol', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'settledPerpPnl'; - docs: [ - 'Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'cumulativeSpotFees'; - docs: [ - 'Fees (taker fees, maker rebate, filler reward) for spot', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'cumulativePerpFunding'; - docs: [ - 'Cumulative funding paid/received for perps', - 'precision: QUOTE_PRECISION', - ]; - type: 'i64'; - }, - { - name: 'liquidationMarginFreed'; - docs: [ - 'The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time', - 'Defaults to zero when not being liquidated', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastActiveSlot'; - docs: [ - 'The last slot a user was active. Used to determine if a user is idle', - ]; - type: 'u64'; - }, - { - name: 'nextOrderId'; - docs: [ - 'Every user order has an order id. This is the next order id to be used', - ]; - type: 'u32'; - }, - { - name: 'maxMarginRatio'; - docs: ['Custom max initial margin ratio for the user']; - type: 'u32'; - }, - { - name: 'nextLiquidationId'; - docs: ['The next liquidation id to be used for user']; - type: 'u16'; - }, - { - name: 'subAccountId'; - docs: ['The sub account id for this user']; - type: 'u16'; - }, - { - name: 'status'; - docs: ['Whether the user is active, being liquidated or bankrupt']; - type: 'u8'; - }, - { - name: 'isMarginTradingEnabled'; - docs: ['Whether the user has enabled margin trading']; - type: 'bool'; - }, - { - name: 'idle'; - docs: [ - "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", - 'Off-chain keeper bots can ignore users that are idle', - ]; - type: 'bool'; - }, - { - name: 'openOrders'; - docs: ['number of open orders']; - type: 'u8'; - }, - { - name: 'hasOpenOrder'; - docs: ['Whether or not user has open order']; - type: 'bool'; - }, - { - name: 'openAuctions'; - docs: ['number of open orders with auction']; - type: 'u8'; - }, - { - name: 'hasOpenAuction'; - docs: ['Whether or not user has open order with auction']; - type: 'bool'; - }, - { - name: 'marginMode'; - type: { - defined: { - name: 'marginMode'; - }; - }; - }, - { - name: 'poolId'; - type: 'u8'; - }, - { - name: 'padding1'; - type: { - array: ['u8', 3]; - }; - }, - { - name: 'lastFuelBonusUpdateTs'; - type: 'u32'; - }, - { - name: 'padding'; - type: { - array: ['u8', 12]; - }; - }, - ]; - }; - }, - { - name: 'userFees'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'totalFeePaid'; - docs: ['Total taker fee paid', 'precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'totalFeeRebate'; - docs: ['Total maker fee rebate', 'precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'totalTokenDiscount'; - docs: [ - 'Total discount from holding token', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'totalRefereeDiscount'; - docs: [ - 'Total discount from being referred', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'totalReferrerReward'; - docs: ['Total reward to referrer', 'precision: QUOTE_PRECISION']; - type: 'u64'; - }, - { - name: 'currentEpochReferrerReward'; - docs: [ - 'Total reward to referrer this epoch', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - ]; - }; - }, - { - name: 'userStats'; - serialization: 'bytemuckunsafe'; - repr: { - kind: 'c'; - }; - type: { - kind: 'struct'; - fields: [ - { - name: 'authority'; - docs: ['The authority for all of a users sub accounts']; - type: 'pubkey'; - }, - { - name: 'referrer'; - docs: ['The address that referred this user']; - type: 'pubkey'; - }, - { - name: 'fees'; - docs: ['Stats on the fees paid by the user']; - type: { - defined: { - name: 'userFees'; - }; - }; - }, - { - name: 'nextEpochTs'; - docs: [ - 'The timestamp of the next epoch', - 'Epoch is used to limit referrer rewards earned in single epoch', - ]; - type: 'i64'; - }, - { - name: 'makerVolume30d'; - docs: [ - 'Rolling 30day maker volume for user', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'takerVolume30d'; - docs: [ - 'Rolling 30day taker volume for user', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'fillerVolume30d'; - docs: [ - 'Rolling 30day filler volume for user', - 'precision: QUOTE_PRECISION', - ]; - type: 'u64'; - }, - { - name: 'lastMakerVolume30dTs'; - docs: ['last time the maker volume was updated']; - type: 'i64'; - }, - { - name: 'lastTakerVolume30dTs'; - docs: ['last time the taker volume was updated']; - type: 'i64'; - }, - { - name: 'lastFillerVolume30dTs'; - docs: ['last time the filler volume was updated']; - type: 'i64'; - }, - { - name: 'ifStakedQuoteAssetAmount'; - docs: ['The amount of tokens staked in the quote spot markets if']; - type: 'u64'; - }, - { - name: 'numberOfSubAccounts'; - docs: ['The current number of sub accounts']; - type: 'u16'; - }, - { - name: 'numberOfSubAccountsCreated'; - docs: [ - 'The number of sub accounts created. Can be greater than the number of sub accounts if user', - 'has deleted sub accounts', - ]; - type: 'u16'; - }, - { - name: 'referrerStatus'; - docs: [ - 'Flags for referrer status:', - 'First bit (LSB): 1 if user is a referrer, 0 otherwise', - 'Second bit: 1 if user was referred, 0 otherwise', - ]; - type: 'u8'; - }, - { - name: 'disableUpdatePerpBidAskTwap'; - type: 'u8'; - }, - { - name: 'pausedOperations'; - type: 'u8'; - }, - { - name: 'fuelOverflowStatus'; - docs: ['whether the user has a FuelOverflow account']; - type: 'u8'; - }, - { - name: 'fuelInsurance'; - docs: ['accumulated fuel for token amounts of insurance']; - type: 'u32'; - }, - { - name: 'fuelDeposits'; - docs: ['accumulated fuel for notional of deposits']; - type: 'u32'; - }, - { - name: 'fuelBorrows'; - docs: ['accumulate fuel bonus for notional of borrows']; - type: 'u32'; - }, - { - name: 'fuelPositions'; - docs: ['accumulated fuel for perp open interest']; - type: 'u32'; - }, - { - name: 'fuelTaker'; - docs: ['accumulate fuel bonus for taker volume']; - type: 'u32'; - }, - { - name: 'fuelMaker'; - docs: ['accumulate fuel bonus for maker volume']; - type: 'u32'; - }, - { - name: 'ifStakedGovTokenAmount'; - docs: [ - 'The amount of tokens staked in the governance spot markets if', - ]; - type: 'u64'; - }, - { - name: 'lastFuelIfBonusUpdateTs'; - docs: [ - 'last unix ts user stats data was used to update if fuel (u32 to save space)', - ]; - type: 'u32'; - }, - { - name: 'padding'; - type: { - array: ['u8', 12]; - }; - }, - ]; - }; - }, - { - name: 'validityGuardRails'; - type: { - kind: 'struct'; - fields: [ - { - name: 'slotsBeforeStaleForAmm'; - type: 'i64'; - }, - { - name: 'slotsBeforeStaleForMargin'; - type: 'i64'; - }, - { - name: 'confidenceIntervalMaxSize'; - type: 'u64'; - }, - { - name: 'tooVolatileRatio'; - type: 'i64'; - }, - ]; - }; - }, - { - name: 'i128'; - docs: ['`i128` with legacy bit layout']; - type: { - kind: 'struct'; - fields: [ - { - array: ['u8', 16]; - }, - ]; - }; - }, - { - name: 'u128'; - docs: ['`u128` with legacy bit layout']; - type: { - kind: 'struct'; - fields: [ - { - array: ['u8', 16]; - }, - ]; - }; - }, - ]; + "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH", + "metadata": { + "name": "drift", + "version": "2.151.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "addAmmConstituentMappingData", + "discriminator": [ + 164, + 236, + 130, + 40, + 118, + 179, + 46, + 235 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool" + }, + { + "name": "ammConstituentMapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituentTargetBase", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "ammConstituentMappingData", + "type": { + "vec": { + "defined": { + "name": "addAmmConstituentMappingDatum" + } + } + } + } + ] + }, + { + "name": "addInsuranceFundStake", + "discriminator": [ + 251, + 144, + 115, + 11, + 222, + 47, + 62, + 236 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insuranceFundStake", + "userStats" + ] + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "addMarketToAmmCache", + "discriminator": [ + 112, + 149, + 195, + 222, + 124, + 7, + 87, + 237 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + }, + { + "name": "perpMarket" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "adminDeposit", + "discriminator": [ + 210, + 66, + 65, + 182, + 102, + 214, + 176, + 30 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "adminTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "adminUpdateUserStatsPausedOperations", + "discriminator": [ + 183, + 104, + 63, + 150, + 240, + 199, + 3, + 10 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "beginInsuranceFundSwap", + "discriminator": [ + 176, + 69, + 143, + 205, + 32, + 132, + 163, + 0 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "outInsuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inInsuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outTokenAccount", + "writable": true + }, + { + "name": "inTokenAccount", + "writable": true + }, + { + "name": "ifRebalanceConfig", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "amountIn", + "type": "u64" + } + ] + }, + { + "name": "beginLpSwap", + "discriminator": [ + 64, + 44, + 24, + 199, + 48, + 125, + 67, + 91 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "signerOutTokenAccount", + "docs": [ + "Signer token accounts" + ], + "writable": true + }, + { + "name": "signerInTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "docs": [ + "Constituent token accounts" + ], + "writable": true + }, + { + "name": "constituentInTokenAccount", + "writable": true + }, + { + "name": "outConstituent", + "docs": [ + "Constituents" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "lpPool" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "amountIn", + "type": "u64" + } + ] + }, + { + "name": "beginSwap", + "discriminator": [ + 174, + 109, + 228, + 1, + 242, + 105, + 232, + 105 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "outSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outTokenAccount", + "writable": true + }, + { + "name": "inTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "amountIn", + "type": "u64" + } + ] + }, + { + "name": "cancelOrder", + "discriminator": [ + 95, + 129, + 237, + 240, + 8, + 49, + 223, + 132 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "orderId", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "cancelOrderByUserId", + "discriminator": [ + 107, + 211, + 250, + 133, + 18, + 37, + 57, + 100 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "userOrderId", + "type": "u8" + } + ] + }, + { + "name": "cancelOrders", + "discriminator": [ + 238, + 225, + 95, + 158, + 227, + 103, + 8, + 194 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "marketType", + "type": { + "option": { + "defined": { + "name": "marketType" + } + } + } + }, + { + "name": "marketIndex", + "type": { + "option": "u16" + } + }, + { + "name": "direction", + "type": { + "option": { + "defined": { + "name": "positionDirection" + } + } + } + } + ] + }, + { + "name": "cancelOrdersByIds", + "discriminator": [ + 134, + 19, + 144, + 165, + 94, + 240, + 210, + 94 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "orderIds", + "type": { + "vec": "u32" + } + } + ] + }, + { + "name": "cancelRequestRemoveInsuranceFundStake", + "discriminator": [ + 97, + 235, + 78, + 62, + 212, + 42, + 241, + 127 + ], + "accounts": [ + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insuranceFundStake", + "userStats" + ] + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "changeApprovedBuilder", + "discriminator": [ + 179, + 134, + 211, + 45, + 195, + 5, + 189, + 173 + ], + "accounts": [ + { + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "signer": true, + "relations": [ + "escrow" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "builder", + "type": "pubkey" + }, + { + "name": "maxFeeBps", + "type": "u16" + }, + { + "name": "add", + "type": "bool" + } + ] + }, + { + "name": "changeSignedMsgWsDelegateStatus", + "discriminator": [ + 252, + 202, + 252, + 219, + 179, + 27, + 84, + 138 + ], + "accounts": [ + { + "name": "signedMsgWsDelegates", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71, + 95, + 87, + 83 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "delegate", + "type": "pubkey" + }, + { + "name": "add", + "type": "bool" + } + ] + }, + { + "name": "deleteAmmCache", + "discriminator": [ + 216, + 130, + 215, + 206, + 233, + 232, + 191, + 88 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "deleteInitializedPerpMarket", + "discriminator": [ + 91, + 154, + 24, + 87, + 106, + 59, + 190, + 66 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "deleteInitializedSpotMarket", + "discriminator": [ + 31, + 140, + 67, + 191, + 189, + 20, + 101, + 221 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "deletePrelaunchOracle", + "discriminator": [ + 59, + 169, + 100, + 49, + 69, + 17, + 173, + 253 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "prelaunchOracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "perpMarketIndex" + } + ] + } + }, + { + "name": "perpMarket" + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "perpMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "deleteSignedMsgUserOrders", + "discriminator": [ + 221, + 247, + 128, + 253, + 212, + 254, + 46, + 153 + ], + "accounts": [ + { + "name": "signedMsgUserOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [] + }, + { + "name": "deleteUser", + "discriminator": [ + 186, + 85, + 17, + 249, + 219, + 231, + 98, + 251 + ], + "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "writable": true, + "signer": true, + "relations": [ + "user", + "userStats" + ] + } + ], + "args": [] + }, + { + "name": "deposit", + "discriminator": [ + 242, + 35, + 198, + 137, + 82, + 225, + 242, + 182 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "reduceOnly", + "type": "bool" + } + ] + }, + { + "name": "depositIntoInsuranceFundStake", + "discriminator": [ + 4, + 22, + 226, + 201, + 124, + 44, + 82, + 230 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101 + ] + }, + { + "kind": "account", + "path": "userStats" + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "depositIntoPerpMarketFeePool", + "discriminator": [ + 34, + 58, + 57, + 68, + 97, + 80, + 244, + 6 + ], + "accounts": [ + { + "name": "state", + "writable": true + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "sourceVault", + "writable": true + }, + { + "name": "driftSigner" + }, + { + "name": "quoteSpotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "depositIntoSpotMarketRevenuePool", + "discriminator": [ + 92, + 40, + 151, + 42, + 122, + 254, + 139, + 246 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spotMarket" + } + ] + } + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "depositIntoSpotMarketVault", + "discriminator": [ + 48, + 252, + 119, + 73, + 255, + 205, + 174, + 247 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "admin", + "signer": true + }, + { + "name": "sourceVault", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "depositToProgramVault", + "discriminator": [ + 235, + 171, + 121, + 80, + 57, + 239, + 147, + 220 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "constituent", + "writable": true + }, + { + "name": "constituentTokenAccount", + "writable": true + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "mint" + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "disableUserHighLeverageMode", + "discriminator": [ + 183, + 155, + 45, + 0, + 226, + 85, + 213, + 69 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "highLeverageModeConfig", + "writable": true + } + ], + "args": [ + { + "name": "disableMaintenance", + "type": "bool" + } + ] + }, + { + "name": "enableUserHighLeverageMode", + "discriminator": [ + 231, + 24, + 230, + 112, + 201, + 173, + 73, + 184 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "highLeverageModeConfig", + "writable": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + } + ] + }, + { + "name": "endInsuranceFundSwap", + "discriminator": [ + 206, + 230, + 98, + 8, + 249, + 158, + 169, + 167 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "outInsuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inInsuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outTokenAccount", + "writable": true + }, + { + "name": "inTokenAccount", + "writable": true + }, + { + "name": "ifRebalanceConfig", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "endLpSwap", + "discriminator": [ + 99, + 125, + 214, + 165, + 129, + 175, + 253, + 135 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "signerOutTokenAccount", + "docs": [ + "Signer token accounts" + ], + "writable": true + }, + { + "name": "signerInTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "docs": [ + "Constituent token accounts" + ], + "writable": true + }, + { + "name": "constituentInTokenAccount", + "writable": true + }, + { + "name": "outConstituent", + "docs": [ + "Constituents" + ], + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "lpPool" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "endSwap", + "discriminator": [ + 177, + 184, + 27, + 193, + 34, + 13, + 210, + 145 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "outSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outTokenAccount", + "writable": true + }, + { + "name": "inTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + }, + { + "name": "reduceOnly", + "type": { + "option": { + "defined": { + "name": "swapReduceOnly" + } + } + } + } + ] + }, + { + "name": "fillPerpOrder", + "discriminator": [ + 13, + 188, + 248, + 103, + 134, + 217, + 106, + 240 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "fillerStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "orderId", + "type": { + "option": "u32" + } + }, + { + "name": "makerOrderId", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "fillSpotOrder", + "discriminator": [ + 212, + 206, + 130, + 173, + 21, + 34, + 199, + 40 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "fillerStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "orderId", + "type": { + "option": "u32" + } + }, + { + "name": "fulfillmentType", + "type": { + "option": { + "defined": { + "name": "spotFulfillmentType" + } + } + } + }, + { + "name": "makerOrderId", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "forceCancelOrders", + "discriminator": [ + 64, + 181, + 196, + 63, + 222, + 72, + 64, + 232 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "forceDeleteUser", + "discriminator": [ + 2, + 241, + 195, + 172, + 227, + 24, + 254, + 158 + ], + "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "writable": true, + "relations": [ + "user", + "userStats" + ] + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "driftSigner" + } + ], + "args": [] + }, + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 114, + 105, + 102, + 116, + 95, + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "quoteAssetMint" + }, + { + "name": "driftSigner" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [] + }, + { + "name": "initializeAmmCache", + "discriminator": [ + 38, + 60, + 171, + 158, + 203, + 58, + 137, + 8 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initializeConstituent", + "discriminator": [ + 12, + 196, + 45, + 218, + 93, + 89, + 0, + 33 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "constituentTargetBase", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituentCorrelations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "spotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "spotMarketMint" + }, + { + "name": "constituentVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "decimals", + "type": "u8" + }, + { + "name": "maxWeightDeviation", + "type": "i64" + }, + { + "name": "swapFeeMin", + "type": "i64" + }, + { + "name": "swapFeeMax", + "type": "i64" + }, + { + "name": "maxBorrowTokenAmount", + "type": "u64" + }, + { + "name": "oracleStalenessThreshold", + "type": "u64" + }, + { + "name": "costToTrade", + "type": "i32" + }, + { + "name": "constituentDerivativeIndex", + "type": { + "option": "i16" + } + }, + { + "name": "constituentDerivativeDepegThreshold", + "type": "u64" + }, + { + "name": "derivativeWeight", + "type": "u64" + }, + { + "name": "volatility", + "type": "u64" + }, + { + "name": "gammaExecution", + "type": "u8" + }, + { + "name": "gammaInventory", + "type": "u8" + }, + { + "name": "xi", + "type": "u8" + }, + { + "name": "newConstituentCorrelations", + "type": { + "vec": "i64" + } + } + ] + }, + { + "name": "initializeFuelOverflow", + "discriminator": [ + 88, + 223, + 132, + 161, + 208, + 88, + 142, + 42 + ], + "accounts": [ + { + "name": "fuelOverflow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 117, + 101, + 108, + 95, + 111, + 118, + 101, + 114, + 102, + 108, + 111, + 119 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "relations": [ + "userStats" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initializeHighLeverageModeConfig", + "discriminator": [ + 213, + 167, + 93, + 246, + 208, + 130, + 90, + 248 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "highLeverageModeConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + } + ] + }, + { + "name": "initializeIfRebalanceConfig", + "discriminator": [ + 8, + 85, + 184, + 167, + 176, + 61, + 173, + 226 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "ifRebalanceConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 102, + 95, + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "arg", + "path": "params.in_market_index" + }, + { + "kind": "arg", + "path": "params.out_market_index" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ifRebalanceConfigParams" + } + } + } + ] + }, + { + "name": "initializeInsuranceFundStake", + "discriminator": [ + 187, + 179, + 243, + 70, + 248, + 90, + 92, + 147 + ], + "accounts": [ + { + "name": "spotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state" + }, + { + "name": "authority", + "signer": true, + "relations": [ + "userStats" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "initializeLpPool", + "discriminator": [ + 242, + 64, + 1, + 222, + 142, + 46, + 204, + 227 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 112, + 95, + 112, + 111, + 111, + 108 + ] + }, + { + "kind": "arg", + "path": "id" + } + ] + } + }, + { + "name": "mint" + }, + { + "name": "lpPoolTokenVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "ammConstituentMapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituentTargetBase", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "constituentCorrelations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "lpPoolId", + "type": "u8" + }, + { + "name": "minMintFee", + "type": "i64" + }, + { + "name": "maxAum", + "type": "u128" + }, + { + "name": "maxSettleQuoteAmountPerMarket", + "type": "u64" + }, + { + "name": "whitelistMint", + "type": "pubkey" + } + ] + }, + { + "name": "initializeOpenbookV2FulfillmentConfig", + "discriminator": [ + 7, + 221, + 103, + 153, + 107, + 57, + 27, + 197 + ], + "accounts": [ + { + "name": "baseSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "quoteSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "openbookV2Program" + }, + { + "name": "openbookV2Market" + }, + { + "name": "driftSigner" + }, + { + "name": "openbookV2FulfillmentConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 111, + 112, + 101, + 110, + 98, + 111, + 111, + 107, + 95, + 118, + 50, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "openbookV2Market" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "initializePerpMarket", + "discriminator": [ + 132, + 9, + 229, + 118, + 117, + 118, + 117, + 62 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "perpMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 101, + 114, + 112, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_markets", + "account": "state" + } + ] + } + }, + { + "name": "oracle" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "ammBaseAssetReserve", + "type": "u128" + }, + { + "name": "ammQuoteAssetReserve", + "type": "u128" + }, + { + "name": "ammPeriodicity", + "type": "i64" + }, + { + "name": "ammPegMultiplier", + "type": "u128" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "contractTier", + "type": { + "defined": { + "name": "contractTier" + } + } + }, + { + "name": "marginRatioInitial", + "type": "u32" + }, + { + "name": "marginRatioMaintenance", + "type": "u32" + }, + { + "name": "liquidatorFee", + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "type": "u32" + }, + { + "name": "imfFactor", + "type": "u32" + }, + { + "name": "activeStatus", + "type": "bool" + }, + { + "name": "baseSpread", + "type": "u32" + }, + { + "name": "maxSpread", + "type": "u32" + }, + { + "name": "maxOpenInterest", + "type": "u128" + }, + { + "name": "maxRevenueWithdrawPerPeriod", + "type": "u64" + }, + { + "name": "quoteMaxInsurance", + "type": "u64" + }, + { + "name": "orderStepSize", + "type": "u64" + }, + { + "name": "orderTickSize", + "type": "u64" + }, + { + "name": "minOrderSize", + "type": "u64" + }, + { + "name": "concentrationCoefScale", + "type": "u128" + }, + { + "name": "curveUpdateIntensity", + "type": "u8" + }, + { + "name": "ammJitIntensity", + "type": "u8" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "lpPoolId", + "type": "u8" + } + ] + }, + { + "name": "initializePhoenixFulfillmentConfig", + "discriminator": [ + 135, + 132, + 110, + 107, + 185, + 160, + 169, + 154 + ], + "accounts": [ + { + "name": "baseSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "quoteSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "phoenixProgram" + }, + { + "name": "phoenixMarket" + }, + { + "name": "driftSigner" + }, + { + "name": "phoenixFulfillmentConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 104, + 111, + 101, + 110, + 105, + 120, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "phoenixMarket" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "initializePredictionMarket", + "discriminator": [ + 248, + 70, + 198, + 224, + 224, + 105, + 125, + 195 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [] + }, + { + "name": "initializePrelaunchOracle", + "discriminator": [ + 169, + 178, + 84, + 25, + 175, + 62, + 29, + 247 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "prelaunchOracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "params.perp_market_index" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "prelaunchOracleParams" + } + } + } + ] + }, + { + "name": "initializeProtectedMakerModeConfig", + "discriminator": [ + 67, + 103, + 220, + 67, + 88, + 32, + 252, + 8 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "protectedMakerModeConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + } + ] + }, + { + "name": "initializePythLazerOracle", + "discriminator": [ + 140, + 107, + 33, + 214, + 235, + 219, + 103, + 20 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lazerOracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 108, + 97, + 122, + 101, + 114 + ] + }, + { + "kind": "arg", + "path": "feedId" + } + ] + } + }, + { + "name": "state" + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "feedId", + "type": "u32" + } + ] + }, + { + "name": "initializePythPullOracle", + "discriminator": [ + 249, + 140, + 253, + 243, + 248, + 74, + 240, + 238 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "pythSolanaReceiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "priceFeed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feedId" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "feedId", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "initializeReferrerName", + "discriminator": [ + 235, + 126, + 231, + 10, + 42, + 164, + 26, + 61 + ], + "accounts": [ + { + "name": "referrerName", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 102, + 101, + 114, + 114, + 101, + 114, + 95, + 110, + 97, + 109, + 101 + ] + }, + { + "kind": "arg", + "path": "name" + } + ] + } + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "initializeRevenueShare", + "discriminator": [ + 57, + 9, + 123, + 131, + 82, + 52, + 50, + 13 + ], + "accounts": [ + { + "name": "revenueShare", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 83, + 72, + 65, + 82, + 69 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority" + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initializeRevenueShareEscrow", + "discriminator": [ + 187, + 18, + 123, + 88, + 238, + 104, + 84, + 154 + ], + "accounts": [ + { + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "relations": [ + "userStats" + ] + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state" + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "numOrders", + "type": "u16" + } + ] + }, + { + "name": "initializeSerumFulfillmentConfig", + "discriminator": [ + 193, + 211, + 132, + 172, + 70, + 171, + 7, + 94 + ], + "accounts": [ + { + "name": "baseSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "quoteSpotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "serumProgram" + }, + { + "name": "serumMarket" + }, + { + "name": "serumOpenOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 114, + 117, + 109, + 95, + 111, + 112, + 101, + 110, + 95, + 111, + 114, + 100, + 101, + 114, + 115 + ] + }, + { + "kind": "account", + "path": "serumMarket" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "serumFulfillmentConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 114, + 117, + 109, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + }, + { + "kind": "account", + "path": "serumMarket" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "initializeSignedMsgUserOrders", + "discriminator": [ + 164, + 99, + 156, + 126, + 156, + 57, + 99, + 180 + ], + "accounts": [ + { + "name": "signedMsgUserOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority" + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "numOrders", + "type": "u16" + } + ] + }, + { + "name": "initializeSignedMsgWsDelegates", + "discriminator": [ + 40, + 132, + 96, + 219, + 184, + 193, + 80, + 8 + ], + "accounts": [ + { + "name": "signedMsgWsDelegates", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71, + 95, + 87, + 83 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "delegates", + "type": { + "vec": "pubkey" + } + } + ] + }, + { + "name": "initializeSpotMarket", + "discriminator": [ + 234, + 196, + 128, + 44, + 94, + 15, + 48, + 201 + ], + "accounts": [ + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "state" + } + ] + } + }, + { + "name": "spotMarketMint" + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "state" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "state.number_of_spot_markets", + "account": "state" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "state", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "optimalUtilization", + "type": "u32" + }, + { + "name": "optimalBorrowRate", + "type": "u32" + }, + { + "name": "maxBorrowRate", + "type": "u32" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "initialAssetWeight", + "type": "u32" + }, + { + "name": "maintenanceAssetWeight", + "type": "u32" + }, + { + "name": "initialLiabilityWeight", + "type": "u32" + }, + { + "name": "maintenanceLiabilityWeight", + "type": "u32" + }, + { + "name": "imfFactor", + "type": "u32" + }, + { + "name": "liquidatorFee", + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "type": "u32" + }, + { + "name": "activeStatus", + "type": "bool" + }, + { + "name": "assetTier", + "type": { + "defined": { + "name": "assetTier" + } + } + }, + { + "name": "scaleInitialAssetWeightStart", + "type": "u64" + }, + { + "name": "withdrawGuardThreshold", + "type": "u64" + }, + { + "name": "orderTickSize", + "type": "u64" + }, + { + "name": "orderStepSize", + "type": "u64" + }, + { + "name": "ifTotalFactor", + "type": "u32" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "initializeUser", + "discriminator": [ + 111, + 17, + 185, + 250, + 60, + 122, + 38, + 254 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "userStats" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "initializeUserStats", + "discriminator": [ + 254, + 243, + 72, + 98, + 251, + 130, + 168, + 213 + ], + "accounts": [ + { + "name": "userStats", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114, + 95, + 115, + 116, + 97, + 116, + 115 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "state", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "liquidateBorrowForPerpPnl", + "discriminator": [ + 169, + 17, + 32, + 90, + 207, + 148, + 209, + 27 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "liquidatorMaxLiabilityTransfer", + "type": "u128" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "liquidatePerp", + "discriminator": [ + 75, + 35, + 119, + 247, + 191, + 18, + 139, + 2 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "liquidatorMaxBaseAssetAmount", + "type": "u64" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "liquidatePerpPnlForDeposit", + "discriminator": [ + 237, + 75, + 198, + 235, + 233, + 186, + 75, + 35 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "liquidatorMaxPnlTransfer", + "type": "u128" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "liquidatePerpWithFill", + "discriminator": [ + 95, + 111, + 124, + 105, + 86, + 169, + 187, + 34 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "liquidateSpot", + "discriminator": [ + 107, + 0, + 128, + 41, + 35, + 229, + 251, + 18 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [ + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + }, + { + "name": "liquidatorMaxLiabilityTransfer", + "type": "u128" + }, + { + "name": "limitPrice", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "liquidateSpotWithSwapBegin", + "discriminator": [ + 12, + 43, + 176, + 83, + 156, + 251, + 117, + 13 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "liabilitySpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "liabilityMarketIndex" + } + ] + } + }, + { + "name": "assetSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "assetMarketIndex" + } + ] + } + }, + { + "name": "liabilityTokenAccount", + "writable": true + }, + { + "name": "assetTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + }, + { + "name": "swapAmount", + "type": "u64" + } + ] + }, + { + "name": "liquidateSpotWithSwapEnd", + "discriminator": [ + 142, + 88, + 163, + 160, + 223, + 75, + 55, + 225 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "liabilitySpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "liabilityMarketIndex" + } + ] + } + }, + { + "name": "assetSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "assetMarketIndex" + } + ] + } + }, + { + "name": "liabilityTokenAccount", + "writable": true + }, + { + "name": "assetTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + }, + { + "name": "instructions", + "docs": [ + "Instructions Sysvar for instruction introspection" + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "logUserBalances", + "discriminator": [ + 162, + 21, + 35, + 251, + 32, + 57, + 161, + 210 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "lpPoolAddLiquidity", + "discriminator": [ + 49, + 135, + 246, + 103, + 93, + 146, + 220, + 141 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "inMarketMint" + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "userInTokenAccount", + "writable": true + }, + { + "name": "constituentInTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "userLpTokenAccount", + "writable": true + }, + { + "name": "lpMint", + "writable": true + }, + { + "name": "constituentTargetBase" + }, + { + "name": "lpPoolTokenVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u128" + }, + { + "name": "minMintAmount", + "type": "u64" + } + ] + }, + { + "name": "lpPoolRemoveLiquidity", + "discriminator": [ + 164, + 36, + 193, + 252, + 196, + 157, + 138, + 43 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "driftSigner" + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "outMarketMint" + }, + { + "name": "outConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "userOutTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "userLpTokenAccount", + "writable": true + }, + { + "name": "spotMarketTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "lpMint", + "writable": true + }, + { + "name": "constituentTargetBase" + }, + { + "name": "lpPoolTokenVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "tokenProgram" + }, + { + "name": "ammCache", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u64" + }, + { + "name": "minOutAmount", + "type": "u128" + } + ] + }, + { + "name": "lpPoolSwap", + "discriminator": [ + 36, + 161, + 39, + 49, + 227, + 1, + 35, + 226 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool" + }, + { + "name": "constituentTargetBase" + }, + { + "name": "constituentCorrelations" + }, + { + "name": "constituentInTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "writable": true + }, + { + "name": "userInTokenAccount", + "writable": true + }, + { + "name": "userOutTokenAccount", + "writable": true + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "inMarketMint" + }, + { + "name": "outMarketMint" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u64" + }, + { + "name": "minOutAmount", + "type": "u64" + } + ] + }, + { + "name": "modifyOrder", + "discriminator": [ + 47, + 124, + 117, + 255, + 201, + 197, + 130, + 94 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "orderId", + "type": { + "option": "u32" + } + }, + { + "name": "modifyOrderParams", + "type": { + "defined": { + "name": "modifyOrderParams" + } + } + } + ] + }, + { + "name": "modifyOrderByUserId", + "discriminator": [ + 158, + 77, + 4, + 253, + 252, + 194, + 161, + 179 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "userOrderId", + "type": "u8" + }, + { + "name": "modifyOrderParams", + "type": { + "defined": { + "name": "modifyOrderParams" + } + } + } + ] + }, + { + "name": "moveAmmPrice", + "discriminator": [ + 235, + 109, + 2, + 82, + 219, + 118, + 6, + 159 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "baseAssetReserve", + "type": "u128" + }, + { + "name": "quoteAssetReserve", + "type": "u128" + }, + { + "name": "sqrtK", + "type": "u128" + } + ] + }, + { + "name": "openbookV2FulfillmentConfigStatus", + "discriminator": [ + 25, + 173, + 19, + 189, + 4, + 211, + 64, + 238 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "openbookV2FulfillmentConfig", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + } + ] + }, + { + "name": "overrideAmmCacheInfo", + "discriminator": [ + 189, + 198, + 128, + 9, + 49, + 145, + 201, + 115 + ], + "accounts": [ + { + "name": "state", + "writable": true + }, + { + "name": "admin", + "signer": true + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "overrideParams", + "type": { + "defined": { + "name": "overrideAmmCacheParams" + } + } + } + ] + }, + { + "name": "pauseSpotMarketDepositWithdraw", + "discriminator": [ + 183, + 119, + 59, + 170, + 137, + 35, + 242, + 86 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "keeper", + "signer": true + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spotMarket" + } + ] + } + } + ], + "args": [] + }, + { + "name": "phoenixFulfillmentConfigStatus", + "discriminator": [ + 96, + 31, + 113, + 32, + 12, + 203, + 7, + 154 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "phoenixFulfillmentConfig", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + } + ] + }, + { + "name": "placeAndMakePerpOrder", + "discriminator": [ + 149, + 117, + 11, + 237, + 47, + 95, + 89, + 237 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "taker", + "writable": true + }, + { + "name": "takerStats", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "takerOrderId", + "type": "u32" + } + ] + }, + { + "name": "placeAndMakeSignedMsgPerpOrder", + "discriminator": [ + 16, + 26, + 123, + 131, + 94, + 29, + 175, + 98 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "taker", + "writable": true + }, + { + "name": "takerStats", + "writable": true + }, + { + "name": "takerSignedMsgUserOrders", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "taker" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "signedMsgOrderUuid", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + }, + { + "name": "placeAndMakeSpotOrder", + "discriminator": [ + 149, + 158, + 85, + 66, + 239, + 9, + 243, + 98 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "taker", + "writable": true + }, + { + "name": "takerStats", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "takerOrderId", + "type": "u32" + }, + { + "name": "fulfillmentType", + "type": { + "option": { + "defined": { + "name": "spotFulfillmentType" + } + } + } + } + ] + }, + { + "name": "placeAndTakePerpOrder", + "discriminator": [ + 213, + 51, + 1, + 187, + 108, + 220, + 230, + 224 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "successCondition", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "placeAndTakeSpotOrder", + "discriminator": [ + 191, + 3, + 138, + 71, + 114, + 198, + 202, + 100 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "fulfillmentType", + "type": { + "option": { + "defined": { + "name": "spotFulfillmentType" + } + } + } + }, + { + "name": "makerOrderId", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "placeOrders", + "discriminator": [ + 60, + 63, + 50, + 123, + 12, + 197, + 60, + 190 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "vec": { + "defined": { + "name": "orderParams" + } + } + } + } + ] + }, + { + "name": "placePerpOrder", + "discriminator": [ + 69, + 161, + 93, + 202, + 120, + 126, + 76, + 185 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + } + ] + }, + { + "name": "placeSignedMsgTakerOrder", + "discriminator": [ + 32, + 79, + 101, + 139, + 25, + 6, + 98, + 15 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "signedMsgUserOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "user" + } + ] + } + }, + { + "name": "authority", + "signer": true + }, + { + "name": "ixSysvar", + "docs": [ + "the supplied Sysvar could be anything else.", + "The Instruction Sysvar has not been implemented", + "in the Anchor framework yet, so this is the safe approach." + ], + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "signedMsgOrderParamsMessageBytes", + "type": "bytes" + }, + { + "name": "isDelegateSigner", + "type": "bool" + } + ] + }, + { + "name": "placeSpotOrder", + "discriminator": [ + 45, + 79, + 81, + 160, + 248, + 90, + 91, + 220 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "orderParams" + } + } + } + ] + }, + { + "name": "postMultiPythPullOracleUpdatesAtomic", + "discriminator": [ + 243, + 79, + 204, + 228, + 227, + 208, + 100, + 244 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "pythSolanaReceiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "guardianSet" + } + ], + "args": [ + { + "name": "params", + "type": "bytes" + } + ] + }, + { + "name": "postPythLazerOracleUpdate", + "discriminator": [ + 218, + 237, + 170, + 245, + 39, + 143, + 166, + 33 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "pythLazerStorage", + "address": "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL" + }, + { + "name": "ixSysvar", + "address": "Sysvar1nstructions1111111111111111111111111" + } + ], + "args": [ + { + "name": "pythMessage", + "type": "bytes" + } + ] + }, + { + "name": "postPythPullOracleUpdateAtomic", + "discriminator": [ + 116, + 122, + 137, + 158, + 224, + 195, + 173, + 119 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "pythSolanaReceiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "guardianSet" + }, + { + "name": "priceFeed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feedId" + } + ] + } + } + ], + "args": [ + { + "name": "feedId", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "params", + "type": "bytes" + } + ] + }, + { + "name": "recenterPerpMarketAmm", + "discriminator": [ + 24, + 87, + 10, + 115, + 165, + 190, + 80, + 139 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "pegMultiplier", + "type": "u128" + }, + { + "name": "sqrtK", + "type": "u128" + } + ] + }, + { + "name": "recenterPerpMarketAmmCrank", + "discriminator": [ + 166, + 19, + 64, + 10, + 14, + 51, + 101, + 122 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "spotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "perpMarket" + } + ] + } + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "depth", + "type": { + "option": "u128" + } + } + ] + }, + { + "name": "reclaimRent", + "discriminator": [ + 218, + 200, + 19, + 197, + 227, + 89, + 192, + 22 + ], + "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "state" + }, + { + "name": "authority", + "signer": true, + "relations": [ + "user", + "userStats" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "removeAmmConstituentMappingData", + "discriminator": [ + 20, + 183, + 211, + 162, + 16, + 52, + 229, + 115 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool" + }, + { + "name": "ammConstituentMapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + } + ] + }, + { + "name": "removeInsuranceFundStake", + "discriminator": [ + 128, + 166, + 142, + 9, + 254, + 187, + 143, + 174 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insuranceFundStake", + "userStats" + ] + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "repegAmmCurve", + "discriminator": [ + 3, + 36, + 102, + 89, + 180, + 128, + 120, + 213 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ + { + "name": "newPegCandidate", + "type": "u128" + } + ] + }, + { + "name": "requestRemoveInsuranceFundStake", + "discriminator": [ + 142, + 70, + 204, + 92, + 73, + 106, + 180, + 52 + ], + "accounts": [ + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "insuranceFundStake", + "userStats" + ] + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "resetFuelSeason", + "discriminator": [ + 199, + 122, + 192, + 255, + 32, + 99, + 63, + 200 + ], + "accounts": [ + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "relations": [ + "userStats" + ] + }, + { + "name": "state" + }, + { + "name": "admin", + "signer": true + } + ], + "args": [] + }, + { + "name": "resetPerpMarketAmmOracleTwap", + "discriminator": [ + 127, + 10, + 55, + 164, + 123, + 226, + 47, + 24 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [] + }, + { + "name": "resizeRevenueShareEscrowOrders", + "discriminator": [ + 32, + 124, + 247, + 225, + 151, + 213, + 225, + 38 + ], + "accounts": [ + { + "name": "escrow", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 82, + 69, + 86, + 95, + 69, + 83, + 67, + 82, + 79, + 87 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "relations": [ + "escrow" + ] + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "numOrders", + "type": "u16" + } + ] + }, + { + "name": "resizeSignedMsgUserOrders", + "discriminator": [ + 137, + 10, + 87, + 150, + 18, + 115, + 79, + 168 + ], + "accounts": [ + { + "name": "signedMsgUserOrders", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 83, + 73, + 71, + 78, + 69, + 68, + 95, + 77, + 83, + 71 + ] + }, + { + "kind": "account", + "path": "authority" + } + ] + } + }, + { + "name": "authority", + "relations": [ + "user" + ] + }, + { + "name": "user" + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "numOrders", + "type": "u16" + } + ] + }, + { + "name": "resolvePerpBankruptcy", + "discriminator": [ + 224, + 16, + 176, + 214, + 162, + 213, + 183, + 222 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "quoteSpotMarketIndex", + "type": "u16" + }, + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "resolvePerpPnlDeficit", + "discriminator": [ + 168, + 204, + 68, + 150, + 159, + 126, + 95, + 148 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "perpMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "resolveSpotBankruptcy", + "discriminator": [ + 124, + 194, + 240, + 254, + 198, + 213, + 52, + 122 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "liquidator", + "writable": true + }, + { + "name": "liquidatorStats", + "writable": true + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "spotMarketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "revertFill", + "discriminator": [ + 236, + 238, + 176, + 69, + 239, + 10, + 181, + 193 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "fillerStats", + "writable": true + } + ], + "args": [] + }, + { + "name": "setUserStatusToBeingLiquidated", + "discriminator": [ + 106, + 133, + 160, + 206, + 193, + 171, + 192, + 194 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [] + }, + { + "name": "settleExpiredMarket", + "discriminator": [ + 120, + 89, + 11, + 25, + 122, + 77, + 72, + 193 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "settleExpiredMarketPoolsToRevenuePool", + "discriminator": [ + 55, + 19, + 238, + 169, + 227, + 90, + 200, + 184 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [] + }, + { + "name": "settleFundingPayment", + "discriminator": [ + 222, + 90, + 202, + 94, + 28, + 45, + 115, + 183 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "settleMultiplePnls", + "discriminator": [ + 127, + 66, + 117, + 57, + 40, + 50, + 152, + 127 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [ + { + "name": "marketIndexes", + "type": { + "vec": "u16" + } + }, + { + "name": "mode", + "type": { + "defined": { + "name": "settlePnlMode" + } + } + } + ] + }, + { + "name": "settlePerpToLpPool", + "discriminator": [ + 5, + 98, + 46, + 188, + 10, + 59, + 2, + 249 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "ammCache", + "writable": true + }, + { + "name": "quoteMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "constituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "constituentQuoteTokenAccount", + "writable": true + }, + { + "name": "quoteTokenVault", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + } + ], + "args": [] + }, + { + "name": "settlePnl", + "discriminator": [ + 43, + 61, + 234, + 45, + 15, + 95, + 152, + 153 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "settleRevenueToInsuranceFund", + "discriminator": [ + 200, + 120, + 93, + 136, + 69, + 38, + 199, + 159 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "spotMarketIndex", + "type": "u16" + } + ] + }, + { + "name": "sweepFuel", + "discriminator": [ + 175, + 107, + 19, + 56, + 165, + 241, + 43, + 69 + ], + "accounts": [ + { + "name": "fuelOverflow", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "relations": [ + "fuelOverflow", + "userStats" + ] + }, + { + "name": "signer", + "signer": true + } + ], + "args": [] + }, + { + "name": "transferDeposit", + "discriminator": [ + 20, + 20, + 147, + 223, + 41, + 63, + 204, + 111 + ], + "accounts": [ + { + "name": "fromUser", + "writable": true + }, + { + "name": "toUser", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "fromUser", + "toUser", + "userStats" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "transferPerpPosition", + "discriminator": [ + 23, + 172, + 188, + 168, + 134, + 210, + 3, + 108 + ], + "accounts": [ + { + "name": "fromUser", + "writable": true + }, + { + "name": "toUser", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": { + "option": "i64" + } + } + ] + }, + { + "name": "transferPools", + "discriminator": [ + 197, + 103, + 154, + 25, + 107, + 90, + 60, + 94 + ], + "accounts": [ + { + "name": "fromUser", + "writable": true + }, + { + "name": "toUser", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "fromUser", + "toUser", + "userStats" + ] + }, + { + "name": "state" + }, + { + "name": "depositFromSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "depositFromMarketIndex" + } + ] + } + }, + { + "name": "depositToSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "depositToMarketIndex" + } + ] + } + }, + { + "name": "borrowFromSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "borrowFromMarketIndex" + } + ] + } + }, + { + "name": "borrowToSpotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "borrowToMarketIndex" + } + ] + } + }, + { + "name": "driftSigner" + } + ], + "args": [ + { + "name": "depositFromMarketIndex", + "type": "u16" + }, + { + "name": "depositToMarketIndex", + "type": "u16" + }, + { + "name": "borrowFromMarketIndex", + "type": "u16" + }, + { + "name": "borrowToMarketIndex", + "type": "u16" + }, + { + "name": "depositAmount", + "type": { + "option": "u64" + } + }, + { + "name": "borrowAmount", + "type": { + "option": "u64" + } + } + ] + }, + { + "name": "transferProtocolIfSharesToRevenuePool", + "discriminator": [ + 236, + 136, + 147, + 153, + 146, + 205, + 104, + 29 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "writable": true, + "signer": true + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "ifRebalanceConfig", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "driftSigner" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "triggerOrder", + "discriminator": [ + 63, + 112, + 51, + 233, + 232, + 47, + 240, + 199 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "user", + "writable": true + } + ], + "args": [ + { + "name": "orderId", + "type": "u32" + } + ] + }, + { + "name": "updateAdmin", + "discriminator": [ + 161, + 176, + 40, + 213, + 60, + 184, + 179, + 228 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "admin", + "type": "pubkey" + } + ] + }, + { + "name": "updateAmmCache", + "discriminator": [ + 88, + 4, + 63, + 94, + 83, + 224, + 255, + 130 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "ammCache", + "writable": true + }, + { + "name": "quoteMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateAmmConstituentMappingData", + "discriminator": [ + 84, + 70, + 33, + 167, + 133, + 107, + 59, + 24 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool" + }, + { + "name": "ammConstituentMapping", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 65, + 77, + 77, + 95, + 77, + 65, + 80 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "ammConstituentMappingData", + "type": { + "vec": { + "defined": { + "name": "addAmmConstituentMappingDatum" + } + } + } + } + ] + }, + { + "name": "updateAmmJitIntensity", + "discriminator": [ + 181, + 191, + 53, + 109, + 166, + 249, + 55, + 142 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "ammJitIntensity", + "type": "u8" + } + ] + }, + { + "name": "updateAmms", + "discriminator": [ + 201, + 106, + 217, + 253, + 4, + 175, + 228, + 97 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "marketIndexes", + "type": { + "vec": "u16" + } + } + ] + }, + { + "name": "updateConstituentCorrelationData", + "discriminator": [ + 79, + 14, + 19, + 73, + 221, + 106, + 62, + 109 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "lpPool" + }, + { + "name": "constituentCorrelations", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "index1", + "type": "u16" + }, + { + "name": "index2", + "type": "u16" + }, + { + "name": "correlation", + "type": "i64" + } + ] + }, + { + "name": "updateConstituentOracleInfo", + "discriminator": [ + 198, + 117, + 231, + 250, + 147, + 33, + 127, + 161 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "constituent", + "writable": true + }, + { + "name": "spotMarket" + }, + { + "name": "oracle" + } + ], + "args": [] + }, + { + "name": "updateConstituentParams", + "discriminator": [ + 238, + 130, + 122, + 31, + 12, + 104, + 192, + 122 + ], + "accounts": [ + { + "name": "lpPool" + }, + { + "name": "constituentTargetBase", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100 + ] + }, + { + "kind": "account", + "path": "lpPool" + } + ] + } + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "constituent", + "writable": true + } + ], + "args": [ + { + "name": "constituentParams", + "type": { + "defined": { + "name": "constituentParams" + } + } + } + ] + }, + { + "name": "updateConstituentPausedOperations", + "discriminator": [ + 185, + 122, + 153, + 191, + 131, + 177, + 132, + 208 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "constituent", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updateConstituentStatus", + "discriminator": [ + 76, + 159, + 211, + 239, + 182, + 214, + 6, + 15 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + }, + { + "name": "constituent", + "writable": true + } + ], + "args": [ + { + "name": "newStatus", + "type": "u8" + } + ] + }, + { + "name": "updateDelegateUserGovTokenInsuranceStake", + "discriminator": [ + 241, + 29, + 215, + 228, + 142, + 116, + 22, + 160 + ], + "accounts": [ + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } + }, + { + "name": "insuranceFundStake" + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } + }, + { + "name": "state" + } + ], + "args": [] + }, + { + "name": "updateDiscountMint", + "discriminator": [ + 32, + 252, + 122, + 211, + 66, + 31, + 47, + 241 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "discountMint", + "type": "pubkey" + } + ] + }, + { + "name": "updateExchangeStatus", + "discriminator": [ + 83, + 160, + 252, + 250, + 129, + 116, + 49, + 223 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "exchangeStatus", + "type": "u8" + } + ] + }, + { + "name": "updateFeatureBitFlagsBuilderCodes", + "discriminator": [ + 1, + 128, + 177, + 51, + 173, + 45, + 11, + 102 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsMedianTriggerPrice", + "discriminator": [ + 64, + 185, + 221, + 45, + 87, + 147, + 12, + 19 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsMintRedeemLpPool", + "discriminator": [ + 26, + 11, + 142, + 122, + 206, + 159, + 9, + 45 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsMmOracle", + "discriminator": [ + 218, + 134, + 33, + 186, + 231, + 59, + 130, + 149 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsSettleLpPool", + "discriminator": [ + 186, + 28, + 78, + 230, + 155, + 83, + 242, + 26 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFeatureBitFlagsSwapLpPool", + "discriminator": [ + 83, + 16, + 150, + 12, + 102, + 3, + 22, + 58 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "enable", + "type": "bool" + } + ] + }, + { + "name": "updateFundingRate", + "discriminator": [ + 201, + 178, + 116, + 212, + 166, + 144, + 72, + 238 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + } + ] + }, + { + "name": "updateHighLeverageModeConfig", + "discriminator": [ + 64, + 122, + 212, + 93, + 141, + 217, + 202, + 55 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "highLeverageModeConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "bool" + }, + { + "name": "currentUsers", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "updateIfRebalanceConfig", + "discriminator": [ + 142, + 245, + 249, + 66, + 249, + 181, + 22, + 83 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "ifRebalanceConfig", + "writable": true + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ifRebalanceConfigParams" + } + } + } + ] + }, + { + "name": "updateInitialAmmCacheInfo", + "discriminator": [ + 157, + 210, + 109, + 67, + 212, + 170, + 12, + 107 + ], + "accounts": [ + { + "name": "state", + "writable": true + }, + { + "name": "admin", + "signer": true + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateInitialPctToLiquidate", + "discriminator": [ + 210, + 133, + 225, + 128, + 194, + 50, + 13, + 109 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "initialPctToLiquidate", + "type": "u16" + } + ] + }, + { + "name": "updateInsuranceFundUnstakingPeriod", + "discriminator": [ + 44, + 69, + 43, + 226, + 204, + 223, + 202, + 52 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "insuranceFundUnstakingPeriod", + "type": "i64" + } + ] + }, + { + "name": "updateK", + "discriminator": [ + 72, + 98, + 9, + 139, + 129, + 229, + 172, + 56 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "sqrtK", + "type": "u128" + } + ] + }, + { + "name": "updateLiquidationDuration", + "discriminator": [ + 28, + 154, + 20, + 249, + 102, + 192, + 73, + 71 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "liquidationDuration", + "type": "u8" + } + ] + }, + { + "name": "updateLiquidationMarginBufferRatio", + "discriminator": [ + 132, + 224, + 243, + 160, + 154, + 82, + 97, + 215 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "liquidationMarginBufferRatio", + "type": "u32" + } + ] + }, + { + "name": "updateLpConstituentTargetBase", + "discriminator": [ + 157, + 65, + 50, + 207, + 59, + 236, + 161, + 110 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "ammConstituentMapping" + }, + { + "name": "constituentTargetBase", + "writable": true + }, + { + "name": "ammCache" + }, + { + "name": "lpPool" + } + ], + "args": [] + }, + { + "name": "updateLpPoolAum", + "discriminator": [ + 88, + 113, + 137, + 206, + 246, + 247, + 171, + 142 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "lpPool", + "writable": true + }, + { + "name": "constituentTargetBase", + "writable": true + }, + { + "name": "ammCache", + "writable": true + } + ], + "args": [] + }, + { + "name": "updateLpPoolParams", + "discriminator": [ + 217, + 92, + 2, + 255, + 27, + 167, + 178, + 81 + ], + "accounts": [ + { + "name": "lpPool", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "lpPoolParams", + "type": { + "defined": { + "name": "lpPoolParams" + } + } + } + ] + }, + { + "name": "updateOracleGuardRails", + "discriminator": [ + 131, + 112, + 10, + 59, + 32, + 54, + 40, + 164 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "oracleGuardRails", + "type": { + "defined": { + "name": "oracleGuardRails" + } + } + } + ] + }, + { + "name": "updatePerpAuctionDuration", + "discriminator": [ + 126, + 110, + 52, + 174, + 30, + 206, + 215, + 90 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "minPerpAuctionDuration", + "type": "u8" + } + ] + }, + { + "name": "updatePerpBidAskTwap", + "discriminator": [ + 247, + 23, + 255, + 65, + 212, + 90, + 221, + 194 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "keeperStats" + }, + { + "name": "authority", + "signer": true + } + ], + "args": [] + }, + { + "name": "updatePerpFeeStructure", + "discriminator": [ + 23, + 178, + 111, + 203, + 73, + 22, + 140, + 75 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "feeStructure", + "type": { + "defined": { + "name": "feeStructure" + } + } + } + ] + }, + { + "name": "updatePerpMarketAmmOracleTwap", + "discriminator": [ + 241, + 74, + 114, + 123, + 206, + 153, + 24, + 202 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [] + }, + { + "name": "updatePerpMarketAmmSpreadAdjustment", + "discriminator": [ + 155, + 195, + 149, + 43, + 220, + 82, + 173, + 205 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "ammSpreadAdjustment", + "type": "i8" + }, + { + "name": "ammInventorySpreadAdjustment", + "type": "i8" + }, + { + "name": "referencePriceOffset", + "type": "i32" + } + ] + }, + { + "name": "updatePerpMarketAmmSummaryStats", + "discriminator": [ + 122, + 101, + 249, + 238, + 209, + 9, + 241, + 245 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "spotMarket", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "account", + "path": "perpMarket" + } + ] + } + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updatePerpMarketSummaryStatsParams" + } + } + } + ] + }, + { + "name": "updatePerpMarketBaseSpread", + "discriminator": [ + 71, + 95, + 84, + 168, + 9, + 157, + 198, + 65 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "baseSpread", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketConcentrationCoef", + "discriminator": [ + 24, + 78, + 232, + 126, + 169, + 176, + 230, + 16 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "concentrationScale", + "type": "u128" + } + ] + }, + { + "name": "updatePerpMarketContractTier", + "discriminator": [ + 236, + 128, + 15, + 95, + 203, + 214, + 68, + 117 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "contractTier", + "type": { + "defined": { + "name": "contractTier" + } + } + } + ] + }, + { + "name": "updatePerpMarketCurveUpdateIntensity", + "discriminator": [ + 50, + 131, + 6, + 156, + 226, + 231, + 189, + 72 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "curveUpdateIntensity", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketExpiry", + "discriminator": [ + 44, + 221, + 227, + 151, + 131, + 140, + 22, + 110 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "expiryTs", + "type": "i64" + } + ] + }, + { + "name": "updatePerpMarketFeeAdjustment", + "discriminator": [ + 194, + 174, + 87, + 102, + 43, + 148, + 32, + 112 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "feeAdjustment", + "type": "i16" + } + ] + }, + { + "name": "updatePerpMarketFundingPeriod", + "discriminator": [ + 171, + 161, + 69, + 91, + 129, + 139, + 161, + 28 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "fundingPeriod", + "type": "i64" + } + ] + }, + { + "name": "updatePerpMarketHighLeverageMarginRatio", + "discriminator": [ + 88, + 112, + 86, + 49, + 24, + 116, + 74, + 157 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "marginRatioInitial", + "type": "u16" + }, + { + "name": "marginRatioMaintenance", + "type": "u16" + } + ] + }, + { + "name": "updatePerpMarketImfFactor", + "discriminator": [ + 207, + 194, + 56, + 132, + 35, + 67, + 71, + 244 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "imfFactor", + "type": "u32" + }, + { + "name": "unrealizedPnlImfFactor", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketLiquidationFee", + "discriminator": [ + 90, + 137, + 9, + 145, + 41, + 8, + 148, + 117 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "liquidatorFee", + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketLpPoolFeeTransferScalar", + "discriminator": [ + 94, + 228, + 237, + 109, + 100, + 185, + 4, + 81 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "optionalLpFeeTransferScalar", + "type": { + "option": "u8" + } + }, + { + "name": "optionalLpNetPnlTransferScalar", + "type": { + "option": "u8" + } + } + ] + }, + { + "name": "updatePerpMarketLpPoolId", + "discriminator": [ + 119, + 208, + 154, + 88, + 165, + 92, + 21, + 188 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "lpPoolId", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketLpPoolPausedOperations", + "discriminator": [ + 181, + 94, + 93, + 146, + 51, + 89, + 32, + 135 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "lpPausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketLpPoolStatus", + "discriminator": [ + 67, + 6, + 252, + 61, + 54, + 88, + 89, + 233 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ + { + "name": "lpStatus", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketMarginRatio", + "discriminator": [ + 130, + 173, + 107, + 45, + 119, + 105, + 26, + 113 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "marginRatioInitial", + "type": "u32" + }, + { + "name": "marginRatioMaintenance", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketMaxFillReserveFraction", + "discriminator": [ + 19, + 172, + 114, + 154, + 42, + 135, + 161, + 133 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxFillReserveFraction", + "type": "u16" + } + ] + }, + { + "name": "updatePerpMarketMaxImbalances", + "discriminator": [ + 15, + 206, + 73, + 133, + 60, + 8, + 86, + 89 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "unrealizedMaxImbalance", + "type": "u64" + }, + { + "name": "maxRevenueWithdrawPerPeriod", + "type": "u64" + }, + { + "name": "quoteMaxInsurance", + "type": "u64" + } + ] + }, + { + "name": "updatePerpMarketMaxOpenInterest", + "discriminator": [ + 194, + 79, + 149, + 224, + 246, + 102, + 186, + 140 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxOpenInterest", + "type": "u128" + } + ] + }, + { + "name": "updatePerpMarketMaxSlippageRatio", + "discriminator": [ + 235, + 37, + 40, + 196, + 70, + 146, + 54, + 201 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxSlippageRatio", + "type": "u16" + } + ] + }, + { + "name": "updatePerpMarketMaxSpread", + "discriminator": [ + 80, + 252, + 122, + 62, + 40, + 218, + 91, + 100 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxSpread", + "type": "u32" + } + ] + }, + { + "name": "updatePerpMarketMinOrderSize", + "discriminator": [ + 226, + 74, + 5, + 89, + 108, + 223, + 46, + 141 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "orderSize", + "type": "u64" + } + ] + }, + { + "name": "updatePerpMarketName", + "discriminator": [ + 211, + 31, + 21, + 210, + 64, + 108, + 66, + 201 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "updatePerpMarketNumberOfUsers", + "discriminator": [ + 35, + 62, + 144, + 177, + 180, + 62, + 215, + 196 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "numberOfUsers", + "type": { + "option": "u32" + } + }, + { + "name": "numberOfUsersWithBase", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "updatePerpMarketOracle", + "discriminator": [ + 182, + 113, + 111, + 160, + 67, + 174, + 89, + 191 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "oldOracle" + }, + { + "name": "ammCache", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100 + ] + } + ] + } + } + ], + "args": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "skipInvariantCheck", + "type": "bool" + } + ] + }, + { + "name": "updatePerpMarketOracleLowRiskSlotDelayOverride", + "discriminator": [ + 124, + 108, + 147, + 229, + 109, + 117, + 123, + 3 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "oracleLowRiskSlotDelayOverride", + "type": "i8" + } + ] + }, + { + "name": "updatePerpMarketOracleSlotDelayOverride", + "discriminator": [ + 165, + 91, + 239, + 227, + 63, + 172, + 227, + 8 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "oracleSlotDelayOverride", + "type": "i8" + } + ] + }, + { + "name": "updatePerpMarketPausedOperations", + "discriminator": [ + 53, + 16, + 136, + 132, + 30, + 220, + 121, + 85 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketPnlPool", + "discriminator": [ + 50, + 202, + 249, + 224, + 166, + 184, + 13, + 143 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "updatePerpMarketProtectedMakerParams", + "discriminator": [ + 249, + 213, + 115, + 34, + 253, + 239, + 75, + 173 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "protectedMakerLimitPriceDivisor", + "type": { + "option": "u8" + } + }, + { + "name": "protectedMakerDynamicDivisor", + "type": { + "option": "u8" + } + } + ] + }, + { + "name": "updatePerpMarketReferencePriceOffsetDeadbandPct", + "discriminator": [ + 214, + 73, + 166, + 11, + 218, + 76, + 110, + 163 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "referencePriceOffsetDeadbandPct", + "type": "u8" + } + ] + }, + { + "name": "updatePerpMarketStatus", + "discriminator": [ + 71, + 201, + 175, + 122, + 255, + 207, + 196, + 207 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "marketStatus" + } + } + } + ] + }, + { + "name": "updatePerpMarketStepSizeAndTickSize", + "discriminator": [ + 231, + 255, + 97, + 25, + 146, + 139, + 174, + 4 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "stepSize", + "type": "u64" + }, + { + "name": "tickSize", + "type": "u64" + } + ] + }, + { + "name": "updatePerpMarketUnrealizedAssetWeight", + "discriminator": [ + 135, + 132, + 205, + 165, + 109, + 150, + 166, + 106 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [ + { + "name": "unrealizedInitialAssetWeight", + "type": "u32" + }, + { + "name": "unrealizedMaintenanceAssetWeight", + "type": "u32" + } + ] + }, + { + "name": "updatePrelaunchOracle", + "discriminator": [ + 220, + 132, + 27, + 27, + 233, + 220, + 61, + 219 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "perpMarket" + }, + { + "name": "oracle", + "writable": true + } + ], + "args": [] + }, + { + "name": "updatePrelaunchOracleParams", + "discriminator": [ + 98, + 205, + 147, + 243, + 18, + 75, + 83, + 207 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "prelaunchOracle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101 + ] + }, + { + "kind": "arg", + "path": "params.perp_market_index" + } + ] + } + }, + { + "name": "perpMarket", + "writable": true + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "prelaunchOracleParams" + } + } + } + ] + }, + { + "name": "updateProtectedMakerModeConfig", + "discriminator": [ + 86, + 166, + 235, + 253, + 67, + 202, + 223, + 17 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "protectedMakerModeConfig", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "state" + } + ], + "args": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "bool" + }, + { + "name": "currentUsers", + "type": { + "option": "u32" + } + } + ] + }, + { + "name": "updatePythPullOracle", + "discriminator": [ + 230, + 191, + 189, + 94, + 108, + 59, + 74, + 197 + ], + "accounts": [ + { + "name": "keeper", + "writable": true, + "signer": true + }, + { + "name": "pythSolanaReceiver", + "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" + }, + { + "name": "encodedVaa" + }, + { + "name": "priceFeed", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 121, + 116, + 104, + 95, + 112, + 117, + 108, + 108 + ] + }, + { + "kind": "arg", + "path": "feedId" + } + ] + } + } + ], + "args": [ + { + "name": "feedId", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "params", + "type": "bytes" + } + ] + }, + { + "name": "updateSerumFulfillmentConfigStatus", + "discriminator": [ + 171, + 109, + 240, + 251, + 95, + 1, + 149, + 89 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "serumFulfillmentConfig", + "writable": true + }, + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "state" + ] + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + } + ] + }, + { + "name": "updateSpotAuctionDuration", + "discriminator": [ + 182, + 178, + 203, + 72, + 187, + 143, + 157, + 107 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "defaultSpotAuctionDuration", + "type": "u8" + } + ] + }, + { + "name": "updateSpotFeeStructure", + "discriminator": [ + 97, + 216, + 105, + 131, + 113, + 246, + 142, + 141 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "feeStructure", + "type": { + "defined": { + "name": "feeStructure" + } + } + } + ] + }, + { + "name": "updateSpotMarketAssetTier", + "discriminator": [ + 253, + 209, + 231, + 14, + 242, + 208, + 243, + 130 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "assetTier", + "type": { + "defined": { + "name": "assetTier" + } + } + } + ] + }, + { + "name": "updateSpotMarketBorrowRate", + "discriminator": [ + 71, + 239, + 236, + 153, + 210, + 62, + 254, + 76 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "optimalUtilization", + "type": "u32" + }, + { + "name": "optimalBorrowRate", + "type": "u32" + }, + { + "name": "maxBorrowRate", + "type": "u32" + }, + { + "name": "minBorrowRate", + "type": { + "option": "u8" + } + } + ] + }, + { + "name": "updateSpotMarketCumulativeInterest", + "discriminator": [ + 39, + 166, + 139, + 243, + 158, + 165, + 155, + 225 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "spotMarketVault", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "spotMarket" + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateSpotMarketExpiry", + "discriminator": [ + 208, + 11, + 211, + 159, + 226, + 24, + 11, + 247 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "expiryTs", + "type": "i64" + } + ] + }, + { + "name": "updateSpotMarketFeeAdjustment", + "discriminator": [ + 148, + 182, + 3, + 126, + 157, + 114, + 220, + 99 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "feeAdjustment", + "type": "i16" + } + ] + }, + { + "name": "updateSpotMarketIfFactor", + "discriminator": [ + 147, + 30, + 224, + 34, + 18, + 230, + 105, + 4 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "userIfFactor", + "type": "u32" + }, + { + "name": "totalIfFactor", + "type": "u32" + } + ] + }, + { + "name": "updateSpotMarketIfPausedOperations", + "discriminator": [ + 101, + 215, + 79, + 74, + 59, + 41, + 79, + 12 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updateSpotMarketLiquidationFee", + "discriminator": [ + 11, + 13, + 255, + 53, + 56, + 136, + 104, + 177 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "liquidatorFee", + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "type": "u32" + } + ] + }, + { + "name": "updateSpotMarketMarginWeights", + "discriminator": [ + 109, + 33, + 87, + 195, + 255, + 36, + 6, + 81 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "initialAssetWeight", + "type": "u32" + }, + { + "name": "maintenanceAssetWeight", + "type": "u32" + }, + { + "name": "initialLiabilityWeight", + "type": "u32" + }, + { + "name": "maintenanceLiabilityWeight", + "type": "u32" + }, + { + "name": "imfFactor", + "type": "u32" + } + ] + }, + { + "name": "updateSpotMarketMaxTokenBorrows", + "discriminator": [ + 57, + 102, + 204, + 212, + 253, + 95, + 13, + 199 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxTokenBorrowsFraction", + "type": "u16" + } + ] + }, + { + "name": "updateSpotMarketMaxTokenDeposits", + "discriminator": [ + 56, + 191, + 79, + 18, + 26, + 121, + 80, + 208 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "maxTokenDeposits", + "type": "u64" + } + ] + }, + { + "name": "updateSpotMarketMinOrderSize", + "discriminator": [ + 93, + 128, + 11, + 119, + 26, + 20, + 181, + 50 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "orderSize", + "type": "u64" + } + ] + }, + { + "name": "updateSpotMarketName", + "discriminator": [ + 17, + 208, + 1, + 1, + 162, + 211, + 188, + 224 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "updateSpotMarketOracle", + "discriminator": [ + 114, + 184, + 102, + 37, + 246, + 186, + 180, + 99 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "oracle" + }, + { + "name": "oldOracle" + } + ], + "args": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "skipInvariantCheck", + "type": "bool" + } + ] + }, + { + "name": "updateSpotMarketOrdersEnabled", + "discriminator": [ + 190, + 79, + 206, + 15, + 26, + 229, + 229, + 43 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "ordersEnabled", + "type": "bool" + } + ] + }, + { + "name": "updateSpotMarketPausedOperations", + "discriminator": [ + 100, + 61, + 153, + 81, + 180, + 12, + 6, + 248 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "pausedOperations", + "type": "u8" + } + ] + }, + { + "name": "updateSpotMarketPoolId", + "discriminator": [ + 22, + 213, + 197, + 160, + 139, + 193, + 81, + 149 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "poolId", + "type": "u8" + } + ] + }, + { + "name": "updateSpotMarketRevenueSettlePeriod", + "discriminator": [ + 81, + 92, + 126, + 41, + 250, + 225, + 156, + 219 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "revenueSettlePeriod", + "type": "i64" + } + ] + }, + { + "name": "updateSpotMarketScaleInitialAssetWeightStart", + "discriminator": [ + 217, + 204, + 204, + 118, + 204, + 130, + 225, + 147 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "scaleInitialAssetWeightStart", + "type": "u64" + } + ] + }, + { + "name": "updateSpotMarketStatus", + "discriminator": [ + 78, + 94, + 16, + 188, + 193, + 110, + 231, + 31 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "status", + "type": { + "defined": { + "name": "marketStatus" + } + } + } + ] + }, + { + "name": "updateSpotMarketStepSizeAndTickSize", + "discriminator": [ + 238, + 153, + 137, + 80, + 206, + 59, + 250, + 61 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "stepSize", + "type": "u64" + }, + { + "name": "tickSize", + "type": "u64" + } + ] + }, + { + "name": "updateStateMaxInitializeUserFee", + "discriminator": [ + 237, + 225, + 25, + 237, + 193, + 45, + 77, + 97 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "maxInitializeUserFee", + "type": "u16" + } + ] + }, + { + "name": "updateStateMaxNumberOfSubAccounts", + "discriminator": [ + 155, + 123, + 214, + 2, + 221, + 166, + 204, + 85 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "maxNumberOfSubAccounts", + "type": "u16" + } + ] + }, + { + "name": "updateStateSettlementDuration", + "discriminator": [ + 97, + 68, + 199, + 235, + 131, + 80, + 61, + 173 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state", + "writable": true + } + ], + "args": [ + { + "name": "settlementDuration", + "type": "u16" + } + ] + }, + { + "name": "updateUserCustomMarginRatio", + "discriminator": [ + 21, + 221, + 140, + 187, + 32, + 129, + 11, + 123 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "marginRatio", + "type": "u32" + } + ] + }, + { + "name": "updateUserDelegate", + "discriminator": [ + 139, + 205, + 141, + 141, + 113, + 36, + 94, + 187 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "delegate", + "type": "pubkey" + } + ] + }, + { + "name": "updateUserGovTokenInsuranceStake", + "discriminator": [ + 143, + 99, + 235, + 187, + 20, + 159, + 184, + 84 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "signer", + "signer": true + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 15, + 0 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateUserIdle", + "discriminator": [ + 253, + 133, + 67, + 22, + 103, + 161, + 20, + 100 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "filler", + "writable": true + }, + { + "name": "user", + "writable": true + } + ], + "args": [] + }, + { + "name": "updateUserMarginTradingEnabled", + "discriminator": [ + 194, + 92, + 204, + 223, + 246, + 188, + 31, + 203 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "marginTradingEnabled", + "type": "bool" + } + ] + }, + { + "name": "updateUserName", + "discriminator": [ + 135, + 25, + 185, + 56, + 165, + 53, + 34, + 136 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "updateUserPerpPositionCustomMarginRatio", + "discriminator": [ + 121, + 137, + 157, + 155, + 89, + 186, + 145, + 113 + ], + "accounts": [ + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "marginRatio", + "type": "u16" + } + ] + }, + { + "name": "updateUserPoolId", + "discriminator": [ + 219, + 86, + 73, + 106, + 56, + 218, + 128, + 109 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "poolId", + "type": "u8" + } + ] + }, + { + "name": "updateUserProtectedMakerOrders", + "discriminator": [ + 114, + 39, + 123, + 198, + 187, + 25, + 90, + 219 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "authority", + "signer": true + }, + { + "name": "protectedMakerModeConfig", + "writable": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "protectedMakerOrders", + "type": "bool" + } + ] + }, + { + "name": "updateUserQuoteAssetInsuranceStake", + "discriminator": [ + 251, + 101, + 156, + 7, + 2, + 63, + 30, + 23 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + }, + { + "name": "insuranceFundStake", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "signer", + "signer": true + }, + { + "name": "insuranceFundVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "updateUserReduceOnly", + "discriminator": [ + 199, + 71, + 42, + 67, + 144, + 19, + 86, + 109 + ], + "accounts": [ + { + "name": "user", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "authority" + }, + { + "kind": "arg", + "path": "subAccountId" + } + ] + } + }, + { + "name": "authority", + "signer": true + } + ], + "args": [ + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "reduceOnly", + "type": "bool" + } + ] + }, + { + "name": "updateUserStatsReferrerStatus", + "discriminator": [ + 174, + 154, + 72, + 42, + 191, + 148, + 145, + 205 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "userStats", + "writable": true + } + ], + "args": [] + }, + { + "name": "updateWithdrawGuardThreshold", + "discriminator": [ + 56, + 18, + 39, + 61, + 155, + 211, + 44, + 133 + ], + "accounts": [ + { + "name": "admin", + "signer": true, + "relations": [ + "state" + ] + }, + { + "name": "state" + }, + { + "name": "spotMarket", + "writable": true + } + ], + "args": [ + { + "name": "withdrawGuardThreshold", + "type": "u64" + } + ] + }, + { + "name": "viewLpPoolAddLiquidityFees", + "discriminator": [ + 80, + 66, + 226, + 161, + 70, + 142, + 119, + 84 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "inMarketMint" + }, + { + "name": "inConstituent", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "lpMint" + }, + { + "name": "constituentTargetBase" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u128" + } + ] + }, + { + "name": "viewLpPoolRemoveLiquidityFees", + "discriminator": [ + 47, + 12, + 9, + 102, + 12, + 226, + 197, + 89 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "lpPool" + }, + { + "name": "authority", + "signer": true + }, + { + "name": "outMarketMint" + }, + { + "name": "outConstituent", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "lpMint" + }, + { + "name": "constituentTargetBase" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u64" + } + ] + }, + { + "name": "viewLpPoolSwapFees", + "discriminator": [ + 126, + 189, + 109, + 189, + 170, + 156, + 3, + 46 + ], + "accounts": [ + { + "name": "driftSigner" + }, + { + "name": "state" + }, + { + "name": "lpPool" + }, + { + "name": "constituentTargetBase" + }, + { + "name": "constituentCorrelations" + }, + { + "name": "constituentInTokenAccount", + "writable": true + }, + { + "name": "constituentOutTokenAccount", + "writable": true + }, + { + "name": "inConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "inMarketIndex" + } + ] + } + }, + { + "name": "outConstituent", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84 + ] + }, + { + "kind": "account", + "path": "lpPool" + }, + { + "kind": "arg", + "path": "outMarketIndex" + } + ] + } + }, + { + "name": "authority", + "signer": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "inAmount", + "type": "u64" + }, + { + "name": "inTargetWeight", + "type": "i64" + }, + { + "name": "outTargetWeight", + "type": "i64" + } + ] + }, + { + "name": "withdraw", + "discriminator": [ + 183, + 18, + 70, + 156, + 148, + 109, + 161, + 34 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "user", + "writable": true + }, + { + "name": "userStats", + "writable": true + }, + { + "name": "authority", + "signer": true, + "relations": [ + "user", + "userStats" + ] + }, + { + "name": "spotMarketVault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "arg", + "path": "marketIndex" + } + ] + } + }, + { + "name": "driftSigner" + }, + { + "name": "userTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + } + ], + "args": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "reduceOnly", + "type": "bool" + } + ] + }, + { + "name": "withdrawFromProgramVault", + "discriminator": [ + 120, + 40, + 183, + 149, + 232, + 18, + 224, + 151 + ], + "accounts": [ + { + "name": "state" + }, + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "driftSigner" + }, + { + "name": "constituent", + "writable": true + }, + { + "name": "constituentTokenAccount", + "writable": true + }, + { + "name": "spotMarket", + "writable": true + }, + { + "name": "spotMarketVault", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "mint" + }, + { + "name": "oracle" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "zeroMmOracleFields", + "discriminator": [ + 192, + 226, + 39, + 204, + 207, + 120, + 148, + 250 + ], + "accounts": [ + { + "name": "admin", + "signer": true + }, + { + "name": "state" + }, + { + "name": "perpMarket", + "writable": true + } + ], + "args": [] + } + ], + "accounts": [ + { + "name": "ammCache", + "discriminator": [ + 213, + 114, + 161, + 56, + 20, + 22, + 2, + 59 + ] + }, + { + "name": "ammConstituentMapping", + "discriminator": [ + 254, + 89, + 5, + 173, + 66, + 54, + 214, + 247 + ] + }, + { + "name": "constituent", + "discriminator": [ + 0, + 61, + 36, + 35, + 177, + 76, + 216, + 205 + ] + }, + { + "name": "constituentCorrelations", + "discriminator": [ + 124, + 203, + 115, + 33, + 18, + 162, + 67, + 216 + ] + }, + { + "name": "constituentTargetBase", + "discriminator": [ + 255, + 142, + 134, + 71, + 125, + 66, + 198, + 99 + ] + }, + { + "name": "fuelOverflow", + "discriminator": [ + 182, + 64, + 231, + 177, + 226, + 142, + 69, + 58 + ] + }, + { + "name": "highLeverageModeConfig", + "discriminator": [ + 3, + 196, + 90, + 189, + 193, + 64, + 228, + 234 + ] + }, + { + "name": "ifRebalanceConfig", + "discriminator": [ + 214, + 84, + 40, + 251, + 107, + 144, + 173, + 239 + ] + }, + { + "name": "insuranceFundStake", + "discriminator": [ + 110, + 202, + 14, + 42, + 95, + 73, + 90, + 95 + ] + }, + { + "name": "lpPool", + "discriminator": [ + 228, + 152, + 141, + 224, + 161, + 170, + 11, + 89 + ] + }, + { + "name": "openbookV2FulfillmentConfig", + "discriminator": [ + 3, + 43, + 58, + 106, + 131, + 132, + 199, + 171 + ] + }, + { + "name": "perpMarket", + "discriminator": [ + 10, + 223, + 12, + 44, + 107, + 245, + 55, + 247 + ] + }, + { + "name": "phoenixV1FulfillmentConfig", + "discriminator": [ + 233, + 45, + 62, + 40, + 35, + 129, + 48, + 72 + ] + }, + { + "name": "prelaunchOracle", + "discriminator": [ + 92, + 14, + 139, + 234, + 72, + 244, + 68, + 26 + ] + }, + { + "name": "protectedMakerModeConfig", + "discriminator": [ + 47, + 86, + 90, + 9, + 224, + 255, + 10, + 69 + ] + }, + { + "name": "pythLazerOracle", + "discriminator": [ + 159, + 7, + 161, + 249, + 34, + 81, + 121, + 133 + ] + }, + { + "name": "referrerName", + "discriminator": [ + 105, + 133, + 170, + 110, + 52, + 42, + 28, + 182 + ] + }, + { + "name": "revenueShare", + "discriminator": [ + 55, + 40, + 228, + 7, + 139, + 52, + 180, + 110 + ] + }, + { + "name": "revenueShareEscrow", + "discriminator": [ + 98, + 167, + 3, + 46, + 74, + 177, + 173, + 252 + ] + }, + { + "name": "serumV3FulfillmentConfig", + "discriminator": [ + 65, + 160, + 197, + 112, + 239, + 168, + 103, + 185 + ] + }, + { + "name": "signedMsgUserOrders", + "discriminator": [ + 70, + 6, + 50, + 248, + 222, + 1, + 143, + 49 + ] + }, + { + "name": "signedMsgWsDelegates", + "discriminator": [ + 190, + 115, + 111, + 44, + 216, + 252, + 108, + 85 + ] + }, + { + "name": "spotMarket", + "discriminator": [ + 100, + 177, + 8, + 107, + 168, + 65, + 65, + 39 + ] + }, + { + "name": "state", + "discriminator": [ + 216, + 146, + 107, + 94, + 104, + 75, + 182, + 177 + ] + }, + { + "name": "user", + "discriminator": [ + 159, + 117, + 95, + 227, + 239, + 151, + 58, + 236 + ] + }, + { + "name": "userStats", + "discriminator": [ + 176, + 223, + 136, + 27, + 122, + 79, + 32, + 227 + ] + } + ], + "events": [ + { + "name": "curveRecord", + "discriminator": [ + 101, + 238, + 40, + 228, + 70, + 46, + 61, + 117 + ] + }, + { + "name": "deleteUserRecord", + "discriminator": [ + 71, + 111, + 190, + 118, + 7, + 3, + 132, + 222 + ] + }, + { + "name": "depositRecord", + "discriminator": [ + 180, + 241, + 218, + 207, + 102, + 135, + 44, + 134 + ] + }, + { + "name": "fuelSeasonRecord", + "discriminator": [ + 19, + 137, + 119, + 33, + 224, + 249, + 6, + 87 + ] + }, + { + "name": "fuelSweepRecord", + "discriminator": [ + 41, + 84, + 37, + 246, + 132, + 240, + 131, + 8 + ] + }, + { + "name": "fundingPaymentRecord", + "discriminator": [ + 8, + 59, + 96, + 20, + 137, + 201, + 56, + 95 + ] + }, + { + "name": "fundingRateRecord", + "discriminator": [ + 68, + 3, + 255, + 26, + 133, + 91, + 147, + 254 + ] + }, + { + "name": "insuranceFundRecord", + "discriminator": [ + 56, + 222, + 215, + 235, + 78, + 197, + 99, + 146 + ] + }, + { + "name": "insuranceFundStakeRecord", + "discriminator": [ + 68, + 66, + 156, + 7, + 216, + 148, + 250, + 114 + ] + }, + { + "name": "insuranceFundSwapRecord", + "discriminator": [ + 85, + 190, + 99, + 203, + 237, + 33, + 227, + 100 + ] + }, + { + "name": "lpBorrowLendDepositRecord", + "discriminator": [ + 242, + 181, + 11, + 56, + 243, + 61, + 79, + 210 + ] + }, + { + "name": "lpMintRedeemRecord", + "discriminator": [ + 53, + 178, + 142, + 73, + 78, + 91, + 91, + 8 + ] + }, + { + "name": "lpRecord", + "discriminator": [ + 101, + 22, + 54, + 38, + 178, + 13, + 142, + 111 + ] + }, + { + "name": "lpSettleRecord", + "discriminator": [ + 208, + 191, + 131, + 110, + 173, + 48, + 7, + 2 + ] + }, + { + "name": "lpSwapRecord", + "discriminator": [ + 159, + 62, + 130, + 196, + 96, + 79, + 176, + 254 + ] + }, + { + "name": "liquidationRecord", + "discriminator": [ + 127, + 17, + 0, + 108, + 182, + 13, + 231, + 53 + ] + }, + { + "name": "newUserRecord", + "discriminator": [ + 236, + 186, + 113, + 219, + 42, + 51, + 149, + 249 + ] + }, + { + "name": "orderActionRecord", + "discriminator": [ + 224, + 52, + 67, + 71, + 194, + 237, + 109, + 1 + ] + }, + { + "name": "orderRecord", + "discriminator": [ + 104, + 19, + 64, + 56, + 89, + 21, + 2, + 90 + ] + }, + { + "name": "revenueShareSettleRecord", + "discriminator": [ + 61, + 162, + 89, + 10, + 24, + 20, + 59, + 45 + ] + }, + { + "name": "settlePnlRecord", + "discriminator": [ + 57, + 68, + 105, + 26, + 119, + 198, + 213, + 89 + ] + }, + { + "name": "signedMsgOrderRecord", + "discriminator": [ + 211, + 197, + 25, + 18, + 142, + 86, + 113, + 27 + ] + }, + { + "name": "spotInterestRecord", + "discriminator": [ + 183, + 186, + 203, + 186, + 225, + 187, + 95, + 130 + ] + }, + { + "name": "spotMarketVaultDepositRecord", + "discriminator": [ + 178, + 217, + 23, + 188, + 127, + 190, + 32, + 73 + ] + }, + { + "name": "swapRecord", + "discriminator": [ + 162, + 187, + 123, + 194, + 138, + 56, + 250, + 241 + ] + }, + { + "name": "transferProtocolIfSharesToRevenuePoolRecord", + "discriminator": [ + 209, + 118, + 142, + 167, + 130, + 46, + 164, + 151 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "invalidSpotMarketAuthority", + "msg": "Invalid Spot Market Authority" + }, + { + "code": 6001, + "name": "invalidInsuranceFundAuthority", + "msg": "Clearing house not insurance fund authority" + }, + { + "code": 6002, + "name": "insufficientDeposit", + "msg": "Insufficient deposit" + }, + { + "code": 6003, + "name": "insufficientCollateral", + "msg": "Insufficient collateral" + }, + { + "code": 6004, + "name": "sufficientCollateral", + "msg": "Sufficient collateral" + }, + { + "code": 6005, + "name": "maxNumberOfPositions", + "msg": "Max number of positions taken" + }, + { + "code": 6006, + "name": "adminControlsPricesDisabled", + "msg": "Admin Controls Prices Disabled" + }, + { + "code": 6007, + "name": "marketDelisted", + "msg": "Market Delisted" + }, + { + "code": 6008, + "name": "marketIndexAlreadyInitialized", + "msg": "Market Index Already Initialized" + }, + { + "code": 6009, + "name": "userAccountAndUserPositionsAccountMismatch", + "msg": "User Account And User Positions Account Mismatch" + }, + { + "code": 6010, + "name": "userHasNoPositionInMarket", + "msg": "User Has No Position In Market" + }, + { + "code": 6011, + "name": "invalidInitialPeg", + "msg": "Invalid Initial Peg" + }, + { + "code": 6012, + "name": "invalidRepegRedundant", + "msg": "AMM repeg already configured with amt given" + }, + { + "code": 6013, + "name": "invalidRepegDirection", + "msg": "AMM repeg incorrect repeg direction" + }, + { + "code": 6014, + "name": "invalidRepegProfitability", + "msg": "AMM repeg out of bounds pnl" + }, + { + "code": 6015, + "name": "slippageOutsideLimit", + "msg": "Slippage Outside Limit Price" + }, + { + "code": 6016, + "name": "orderSizeTooSmall", + "msg": "Order Size Too Small" + }, + { + "code": 6017, + "name": "invalidUpdateK", + "msg": "Price change too large when updating K" + }, + { + "code": 6018, + "name": "adminWithdrawTooLarge", + "msg": "Admin tried to withdraw amount larger than fees collected" + }, + { + "code": 6019, + "name": "mathError", + "msg": "Math Error" + }, + { + "code": 6020, + "name": "bnConversionError", + "msg": "Conversion to u128/u64 failed with an overflow or underflow" + }, + { + "code": 6021, + "name": "clockUnavailable", + "msg": "Clock unavailable" + }, + { + "code": 6022, + "name": "unableToLoadOracle", + "msg": "Unable To Load Oracles" + }, + { + "code": 6023, + "name": "priceBandsBreached", + "msg": "Price Bands Breached" + }, + { + "code": 6024, + "name": "exchangePaused", + "msg": "Exchange is paused" + }, + { + "code": 6025, + "name": "invalidWhitelistToken", + "msg": "Invalid whitelist token" + }, + { + "code": 6026, + "name": "whitelistTokenNotFound", + "msg": "Whitelist token not found" + }, + { + "code": 6027, + "name": "invalidDiscountToken", + "msg": "Invalid discount token" + }, + { + "code": 6028, + "name": "discountTokenNotFound", + "msg": "Discount token not found" + }, + { + "code": 6029, + "name": "referrerNotFound", + "msg": "Referrer not found" + }, + { + "code": 6030, + "name": "referrerStatsNotFound", + "msg": "referrerNotFound" + }, + { + "code": 6031, + "name": "referrerMustBeWritable", + "msg": "referrerMustBeWritable" + }, + { + "code": 6032, + "name": "referrerStatsMustBeWritable", + "msg": "referrerMustBeWritable" + }, + { + "code": 6033, + "name": "referrerAndReferrerStatsAuthorityUnequal", + "msg": "referrerAndReferrerStatsAuthorityUnequal" + }, + { + "code": 6034, + "name": "invalidReferrer", + "msg": "invalidReferrer" + }, + { + "code": 6035, + "name": "invalidOracle", + "msg": "invalidOracle" + }, + { + "code": 6036, + "name": "oracleNotFound", + "msg": "oracleNotFound" + }, + { + "code": 6037, + "name": "liquidationsBlockedByOracle", + "msg": "Liquidations Blocked By Oracle" + }, + { + "code": 6038, + "name": "maxDeposit", + "msg": "Can not deposit more than max deposit" + }, + { + "code": 6039, + "name": "cantDeleteUserWithCollateral", + "msg": "Can not delete user that still has collateral" + }, + { + "code": 6040, + "name": "invalidFundingProfitability", + "msg": "AMM funding out of bounds pnl" + }, + { + "code": 6041, + "name": "castingFailure", + "msg": "Casting Failure" + }, + { + "code": 6042, + "name": "invalidOrder", + "msg": "invalidOrder" + }, + { + "code": 6043, + "name": "invalidOrderMaxTs", + "msg": "invalidOrderMaxTs" + }, + { + "code": 6044, + "name": "invalidOrderMarketType", + "msg": "invalidOrderMarketType" + }, + { + "code": 6045, + "name": "invalidOrderForInitialMarginReq", + "msg": "invalidOrderForInitialMarginReq" + }, + { + "code": 6046, + "name": "invalidOrderNotRiskReducing", + "msg": "invalidOrderNotRiskReducing" + }, + { + "code": 6047, + "name": "invalidOrderSizeTooSmall", + "msg": "invalidOrderSizeTooSmall" + }, + { + "code": 6048, + "name": "invalidOrderNotStepSizeMultiple", + "msg": "invalidOrderNotStepSizeMultiple" + }, + { + "code": 6049, + "name": "invalidOrderBaseQuoteAsset", + "msg": "invalidOrderBaseQuoteAsset" + }, + { + "code": 6050, + "name": "invalidOrderIoc", + "msg": "invalidOrderIoc" + }, + { + "code": 6051, + "name": "invalidOrderPostOnly", + "msg": "invalidOrderPostOnly" + }, + { + "code": 6052, + "name": "invalidOrderIocPostOnly", + "msg": "invalidOrderIocPostOnly" + }, + { + "code": 6053, + "name": "invalidOrderTrigger", + "msg": "invalidOrderTrigger" + }, + { + "code": 6054, + "name": "invalidOrderAuction", + "msg": "invalidOrderAuction" + }, + { + "code": 6055, + "name": "invalidOrderOracleOffset", + "msg": "invalidOrderOracleOffset" + }, + { + "code": 6056, + "name": "invalidOrderMinOrderSize", + "msg": "invalidOrderMinOrderSize" + }, + { + "code": 6057, + "name": "placePostOnlyLimitFailure", + "msg": "Failed to Place Post-Only Limit Order" + }, + { + "code": 6058, + "name": "userHasNoOrder", + "msg": "User has no order" + }, + { + "code": 6059, + "name": "orderAmountTooSmall", + "msg": "Order Amount Too Small" + }, + { + "code": 6060, + "name": "maxNumberOfOrders", + "msg": "Max number of orders taken" + }, + { + "code": 6061, + "name": "orderDoesNotExist", + "msg": "Order does not exist" + }, + { + "code": 6062, + "name": "orderNotOpen", + "msg": "Order not open" + }, + { + "code": 6063, + "name": "fillOrderDidNotUpdateState", + "msg": "fillOrderDidNotUpdateState" + }, + { + "code": 6064, + "name": "reduceOnlyOrderIncreasedRisk", + "msg": "Reduce only order increased risk" + }, + { + "code": 6065, + "name": "unableToLoadAccountLoader", + "msg": "Unable to load AccountLoader" + }, + { + "code": 6066, + "name": "tradeSizeTooLarge", + "msg": "Trade Size Too Large" + }, + { + "code": 6067, + "name": "userCantReferThemselves", + "msg": "User cant refer themselves" + }, + { + "code": 6068, + "name": "didNotReceiveExpectedReferrer", + "msg": "Did not receive expected referrer" + }, + { + "code": 6069, + "name": "couldNotDeserializeReferrer", + "msg": "Could not deserialize referrer" + }, + { + "code": 6070, + "name": "couldNotDeserializeReferrerStats", + "msg": "Could not deserialize referrer stats" + }, + { + "code": 6071, + "name": "userOrderIdAlreadyInUse", + "msg": "User Order Id Already In Use" + }, + { + "code": 6072, + "name": "noPositionsLiquidatable", + "msg": "No positions liquidatable" + }, + { + "code": 6073, + "name": "invalidMarginRatio", + "msg": "Invalid Margin Ratio" + }, + { + "code": 6074, + "name": "cantCancelPostOnlyOrder", + "msg": "Cant Cancel Post Only Order" + }, + { + "code": 6075, + "name": "invalidOracleOffset", + "msg": "invalidOracleOffset" + }, + { + "code": 6076, + "name": "cantExpireOrders", + "msg": "cantExpireOrders" + }, + { + "code": 6077, + "name": "couldNotLoadMarketData", + "msg": "couldNotLoadMarketData" + }, + { + "code": 6078, + "name": "perpMarketNotFound", + "msg": "perpMarketNotFound" + }, + { + "code": 6079, + "name": "invalidMarketAccount", + "msg": "invalidMarketAccount" + }, + { + "code": 6080, + "name": "unableToLoadPerpMarketAccount", + "msg": "unableToLoadMarketAccount" + }, + { + "code": 6081, + "name": "marketWrongMutability", + "msg": "marketWrongMutability" + }, + { + "code": 6082, + "name": "unableToCastUnixTime", + "msg": "unableToCastUnixTime" + }, + { + "code": 6083, + "name": "couldNotFindSpotPosition", + "msg": "couldNotFindSpotPosition" + }, + { + "code": 6084, + "name": "noSpotPositionAvailable", + "msg": "noSpotPositionAvailable" + }, + { + "code": 6085, + "name": "invalidSpotMarketInitialization", + "msg": "invalidSpotMarketInitialization" + }, + { + "code": 6086, + "name": "couldNotLoadSpotMarketData", + "msg": "couldNotLoadSpotMarketData" + }, + { + "code": 6087, + "name": "spotMarketNotFound", + "msg": "spotMarketNotFound" + }, + { + "code": 6088, + "name": "invalidSpotMarketAccount", + "msg": "invalidSpotMarketAccount" + }, + { + "code": 6089, + "name": "unableToLoadSpotMarketAccount", + "msg": "unableToLoadSpotMarketAccount" + }, + { + "code": 6090, + "name": "spotMarketWrongMutability", + "msg": "spotMarketWrongMutability" + }, + { + "code": 6091, + "name": "spotMarketInterestNotUpToDate", + "msg": "spotInterestNotUpToDate" + }, + { + "code": 6092, + "name": "spotMarketInsufficientDeposits", + "msg": "spotMarketInsufficientDeposits" + }, + { + "code": 6093, + "name": "userMustSettleTheirOwnPositiveUnsettledPnl", + "msg": "userMustSettleTheirOwnPositiveUnsettledPnl" + }, + { + "code": 6094, + "name": "cantUpdatePoolBalanceType", + "msg": "cantUpdatePoolBalanceType" + }, + { + "code": 6095, + "name": "insufficientCollateralForSettlingPnl", + "msg": "insufficientCollateralForSettlingPnl" + }, + { + "code": 6096, + "name": "ammNotUpdatedInSameSlot", + "msg": "ammNotUpdatedInSameSlot" + }, + { + "code": 6097, + "name": "auctionNotComplete", + "msg": "auctionNotComplete" + }, + { + "code": 6098, + "name": "makerNotFound", + "msg": "makerNotFound" + }, + { + "code": 6099, + "name": "makerStatsNotFound", + "msg": "makerNotFound" + }, + { + "code": 6100, + "name": "makerMustBeWritable", + "msg": "makerMustBeWritable" + }, + { + "code": 6101, + "name": "makerStatsMustBeWritable", + "msg": "makerMustBeWritable" + }, + { + "code": 6102, + "name": "makerOrderNotFound", + "msg": "makerOrderNotFound" + }, + { + "code": 6103, + "name": "couldNotDeserializeMaker", + "msg": "couldNotDeserializeMaker" + }, + { + "code": 6104, + "name": "couldNotDeserializeMakerStats", + "msg": "couldNotDeserializeMaker" + }, + { + "code": 6105, + "name": "auctionPriceDoesNotSatisfyMaker", + "msg": "auctionPriceDoesNotSatisfyMaker" + }, + { + "code": 6106, + "name": "makerCantFulfillOwnOrder", + "msg": "makerCantFulfillOwnOrder" + }, + { + "code": 6107, + "name": "makerOrderMustBePostOnly", + "msg": "makerOrderMustBePostOnly" + }, + { + "code": 6108, + "name": "cantMatchTwoPostOnlys", + "msg": "cantMatchTwoPostOnlys" + }, + { + "code": 6109, + "name": "orderBreachesOraclePriceLimits", + "msg": "orderBreachesOraclePriceLimits" + }, + { + "code": 6110, + "name": "orderMustBeTriggeredFirst", + "msg": "orderMustBeTriggeredFirst" + }, + { + "code": 6111, + "name": "orderNotTriggerable", + "msg": "orderNotTriggerable" + }, + { + "code": 6112, + "name": "orderDidNotSatisfyTriggerCondition", + "msg": "orderDidNotSatisfyTriggerCondition" + }, + { + "code": 6113, + "name": "positionAlreadyBeingLiquidated", + "msg": "positionAlreadyBeingLiquidated" + }, + { + "code": 6114, + "name": "positionDoesntHaveOpenPositionOrOrders", + "msg": "positionDoesntHaveOpenPositionOrOrders" + }, + { + "code": 6115, + "name": "allOrdersAreAlreadyLiquidations", + "msg": "allOrdersAreAlreadyLiquidations" + }, + { + "code": 6116, + "name": "cantCancelLiquidationOrder", + "msg": "cantCancelLiquidationOrder" + }, + { + "code": 6117, + "name": "userIsBeingLiquidated", + "msg": "userIsBeingLiquidated" + }, + { + "code": 6118, + "name": "liquidationsOngoing", + "msg": "liquidationsOngoing" + }, + { + "code": 6119, + "name": "wrongSpotBalanceType", + "msg": "wrongSpotBalanceType" + }, + { + "code": 6120, + "name": "userCantLiquidateThemself", + "msg": "userCantLiquidateThemself" + }, + { + "code": 6121, + "name": "invalidPerpPositionToLiquidate", + "msg": "invalidPerpPositionToLiquidate" + }, + { + "code": 6122, + "name": "invalidBaseAssetAmountForLiquidatePerp", + "msg": "invalidBaseAssetAmountForLiquidatePerp" + }, + { + "code": 6123, + "name": "invalidPositionLastFundingRate", + "msg": "invalidPositionLastFundingRate" + }, + { + "code": 6124, + "name": "invalidPositionDelta", + "msg": "invalidPositionDelta" + }, + { + "code": 6125, + "name": "userBankrupt", + "msg": "userBankrupt" + }, + { + "code": 6126, + "name": "userNotBankrupt", + "msg": "userNotBankrupt" + }, + { + "code": 6127, + "name": "userHasInvalidBorrow", + "msg": "userHasInvalidBorrow" + }, + { + "code": 6128, + "name": "dailyWithdrawLimit", + "msg": "dailyWithdrawLimit" + }, + { + "code": 6129, + "name": "defaultError", + "msg": "defaultError" + }, + { + "code": 6130, + "name": "insufficientLpTokens", + "msg": "Insufficient LP tokens" + }, + { + "code": 6131, + "name": "cantLpWithPerpPosition", + "msg": "Cant LP with a market position" + }, + { + "code": 6132, + "name": "unableToBurnLpTokens", + "msg": "Unable to burn LP tokens" + }, + { + "code": 6133, + "name": "tryingToRemoveLiquidityTooFast", + "msg": "Trying to remove liqudity too fast after adding it" + }, + { + "code": 6134, + "name": "invalidSpotMarketVault", + "msg": "Invalid Spot Market Vault" + }, + { + "code": 6135, + "name": "invalidSpotMarketState", + "msg": "Invalid Spot Market State" + }, + { + "code": 6136, + "name": "invalidSerumProgram", + "msg": "invalidSerumProgram" + }, + { + "code": 6137, + "name": "invalidSerumMarket", + "msg": "invalidSerumMarket" + }, + { + "code": 6138, + "name": "invalidSerumBids", + "msg": "invalidSerumBids" + }, + { + "code": 6139, + "name": "invalidSerumAsks", + "msg": "invalidSerumAsks" + }, + { + "code": 6140, + "name": "invalidSerumOpenOrders", + "msg": "invalidSerumOpenOrders" + }, + { + "code": 6141, + "name": "failedSerumCpi", + "msg": "failedSerumCpi" + }, + { + "code": 6142, + "name": "failedToFillOnExternalMarket", + "msg": "failedToFillOnExternalMarket" + }, + { + "code": 6143, + "name": "invalidFulfillmentConfig", + "msg": "invalidFulfillmentConfig" + }, + { + "code": 6144, + "name": "invalidFeeStructure", + "msg": "invalidFeeStructure" + }, + { + "code": 6145, + "name": "insufficientIfShares", + "msg": "Insufficient IF shares" + }, + { + "code": 6146, + "name": "marketActionPaused", + "msg": "the Market has paused this action" + }, + { + "code": 6147, + "name": "marketPlaceOrderPaused", + "msg": "the Market status doesnt allow placing orders" + }, + { + "code": 6148, + "name": "marketFillOrderPaused", + "msg": "the Market status doesnt allow filling orders" + }, + { + "code": 6149, + "name": "marketWithdrawPaused", + "msg": "the Market status doesnt allow withdraws" + }, + { + "code": 6150, + "name": "protectedAssetTierViolation", + "msg": "Action violates the Protected Asset Tier rules" + }, + { + "code": 6151, + "name": "isolatedAssetTierViolation", + "msg": "Action violates the Isolated Asset Tier rules" + }, + { + "code": 6152, + "name": "userCantBeDeleted", + "msg": "User Cant Be Deleted" + }, + { + "code": 6153, + "name": "reduceOnlyWithdrawIncreasedRisk", + "msg": "Reduce Only Withdraw Increased Risk" + }, + { + "code": 6154, + "name": "maxOpenInterest", + "msg": "Max Open Interest" + }, + { + "code": 6155, + "name": "cantResolvePerpBankruptcy", + "msg": "Cant Resolve Perp Bankruptcy" + }, + { + "code": 6156, + "name": "liquidationDoesntSatisfyLimitPrice", + "msg": "Liquidation Doesnt Satisfy Limit Price" + }, + { + "code": 6157, + "name": "marginTradingDisabled", + "msg": "Margin Trading Disabled" + }, + { + "code": 6158, + "name": "invalidMarketStatusToSettlePnl", + "msg": "Invalid Market Status to Settle Perp Pnl" + }, + { + "code": 6159, + "name": "perpMarketNotInSettlement", + "msg": "perpMarketNotInSettlement" + }, + { + "code": 6160, + "name": "perpMarketNotInReduceOnly", + "msg": "perpMarketNotInReduceOnly" + }, + { + "code": 6161, + "name": "perpMarketSettlementBufferNotReached", + "msg": "perpMarketSettlementBufferNotReached" + }, + { + "code": 6162, + "name": "perpMarketSettlementUserHasOpenOrders", + "msg": "perpMarketSettlementUserHasOpenOrders" + }, + { + "code": 6163, + "name": "perpMarketSettlementUserHasActiveLp", + "msg": "perpMarketSettlementUserHasActiveLp" + }, + { + "code": 6164, + "name": "unableToSettleExpiredUserPosition", + "msg": "unableToSettleExpiredUserPosition" + }, + { + "code": 6165, + "name": "unequalMarketIndexForSpotTransfer", + "msg": "unequalMarketIndexForSpotTransfer" + }, + { + "code": 6166, + "name": "invalidPerpPositionDetected", + "msg": "invalidPerpPositionDetected" + }, + { + "code": 6167, + "name": "invalidSpotPositionDetected", + "msg": "invalidSpotPositionDetected" + }, + { + "code": 6168, + "name": "invalidAmmDetected", + "msg": "invalidAmmDetected" + }, + { + "code": 6169, + "name": "invalidAmmForFillDetected", + "msg": "invalidAmmForFillDetected" + }, + { + "code": 6170, + "name": "invalidAmmLimitPriceOverride", + "msg": "invalidAmmLimitPriceOverride" + }, + { + "code": 6171, + "name": "invalidOrderFillPrice", + "msg": "invalidOrderFillPrice" + }, + { + "code": 6172, + "name": "spotMarketBalanceInvariantViolated", + "msg": "spotMarketBalanceInvariantViolated" + }, + { + "code": 6173, + "name": "spotMarketVaultInvariantViolated", + "msg": "spotMarketVaultInvariantViolated" + }, + { + "code": 6174, + "name": "invalidPda", + "msg": "invalidPda" + }, + { + "code": 6175, + "name": "invalidPdaSigner", + "msg": "invalidPdaSigner" + }, + { + "code": 6176, + "name": "revenueSettingsCannotSettleToIf", + "msg": "revenueSettingsCannotSettleToIf" + }, + { + "code": 6177, + "name": "noRevenueToSettleToIf", + "msg": "noRevenueToSettleToIf" + }, + { + "code": 6178, + "name": "noAmmPerpPnlDeficit", + "msg": "noAmmPerpPnlDeficit" + }, + { + "code": 6179, + "name": "sufficientPerpPnlPool", + "msg": "sufficientPerpPnlPool" + }, + { + "code": 6180, + "name": "insufficientPerpPnlPool", + "msg": "insufficientPerpPnlPool" + }, + { + "code": 6181, + "name": "perpPnlDeficitBelowThreshold", + "msg": "perpPnlDeficitBelowThreshold" + }, + { + "code": 6182, + "name": "maxRevenueWithdrawPerPeriodReached", + "msg": "maxRevenueWithdrawPerPeriodReached" + }, + { + "code": 6183, + "name": "maxIfWithdrawReached", + "msg": "invalidSpotPositionDetected" + }, + { + "code": 6184, + "name": "noIfWithdrawAvailable", + "msg": "noIfWithdrawAvailable" + }, + { + "code": 6185, + "name": "invalidIfUnstake", + "msg": "invalidIfUnstake" + }, + { + "code": 6186, + "name": "invalidIfUnstakeSize", + "msg": "invalidIfUnstakeSize" + }, + { + "code": 6187, + "name": "invalidIfUnstakeCancel", + "msg": "invalidIfUnstakeCancel" + }, + { + "code": 6188, + "name": "invalidIfForNewStakes", + "msg": "invalidIfForNewStakes" + }, + { + "code": 6189, + "name": "invalidIfRebase", + "msg": "invalidIfRebase" + }, + { + "code": 6190, + "name": "invalidInsuranceUnstakeSize", + "msg": "invalidInsuranceUnstakeSize" + }, + { + "code": 6191, + "name": "invalidOrderLimitPrice", + "msg": "invalidOrderLimitPrice" + }, + { + "code": 6192, + "name": "invalidIfDetected", + "msg": "invalidIfDetected" + }, + { + "code": 6193, + "name": "invalidAmmMaxSpreadDetected", + "msg": "invalidAmmMaxSpreadDetected" + }, + { + "code": 6194, + "name": "invalidConcentrationCoef", + "msg": "invalidConcentrationCoef" + }, + { + "code": 6195, + "name": "invalidSrmVault", + "msg": "invalidSrmVault" + }, + { + "code": 6196, + "name": "invalidVaultOwner", + "msg": "invalidVaultOwner" + }, + { + "code": 6197, + "name": "invalidMarketStatusForFills", + "msg": "invalidMarketStatusForFills" + }, + { + "code": 6198, + "name": "ifWithdrawRequestInProgress", + "msg": "ifWithdrawRequestInProgress" + }, + { + "code": 6199, + "name": "noIfWithdrawRequestInProgress", + "msg": "noIfWithdrawRequestInProgress" + }, + { + "code": 6200, + "name": "ifWithdrawRequestTooSmall", + "msg": "ifWithdrawRequestTooSmall" + }, + { + "code": 6201, + "name": "incorrectSpotMarketAccountPassed", + "msg": "incorrectSpotMarketAccountPassed" + }, + { + "code": 6202, + "name": "blockchainClockInconsistency", + "msg": "blockchainClockInconsistency" + }, + { + "code": 6203, + "name": "invalidIfSharesDetected", + "msg": "invalidIfSharesDetected" + }, + { + "code": 6204, + "name": "newLpSizeTooSmall", + "msg": "newLpSizeTooSmall" + }, + { + "code": 6205, + "name": "marketStatusInvalidForNewLp", + "msg": "marketStatusInvalidForNewLp" + }, + { + "code": 6206, + "name": "invalidMarkTwapUpdateDetected", + "msg": "invalidMarkTwapUpdateDetected" + }, + { + "code": 6207, + "name": "marketSettlementAttemptOnActiveMarket", + "msg": "marketSettlementAttemptOnActiveMarket" + }, + { + "code": 6208, + "name": "marketSettlementRequiresSettledLp", + "msg": "marketSettlementRequiresSettledLp" + }, + { + "code": 6209, + "name": "marketSettlementAttemptTooEarly", + "msg": "marketSettlementAttemptTooEarly" + }, + { + "code": 6210, + "name": "marketSettlementTargetPriceInvalid", + "msg": "marketSettlementTargetPriceInvalid" + }, + { + "code": 6211, + "name": "unsupportedSpotMarket", + "msg": "unsupportedSpotMarket" + }, + { + "code": 6212, + "name": "spotOrdersDisabled", + "msg": "spotOrdersDisabled" + }, + { + "code": 6213, + "name": "marketBeingInitialized", + "msg": "Market Being Initialized" + }, + { + "code": 6214, + "name": "invalidUserSubAccountId", + "msg": "Invalid Sub Account Id" + }, + { + "code": 6215, + "name": "invalidTriggerOrderCondition", + "msg": "Invalid Trigger Order Condition" + }, + { + "code": 6216, + "name": "invalidSpotPosition", + "msg": "Invalid Spot Position" + }, + { + "code": 6217, + "name": "cantTransferBetweenSameUserAccount", + "msg": "Cant transfer between same user account" + }, + { + "code": 6218, + "name": "invalidPerpPosition", + "msg": "Invalid Perp Position" + }, + { + "code": 6219, + "name": "unableToGetLimitPrice", + "msg": "Unable To Get Limit Price" + }, + { + "code": 6220, + "name": "invalidLiquidation", + "msg": "Invalid Liquidation" + }, + { + "code": 6221, + "name": "spotFulfillmentConfigDisabled", + "msg": "Spot Fulfillment Config Disabled" + }, + { + "code": 6222, + "name": "invalidMaker", + "msg": "Invalid Maker" + }, + { + "code": 6223, + "name": "failedUnwrap", + "msg": "Failed Unwrap" + }, + { + "code": 6224, + "name": "maxNumberOfUsers", + "msg": "Max Number Of Users" + }, + { + "code": 6225, + "name": "invalidOracleForSettlePnl", + "msg": "invalidOracleForSettlePnl" + }, + { + "code": 6226, + "name": "marginOrdersOpen", + "msg": "marginOrdersOpen" + }, + { + "code": 6227, + "name": "tierViolationLiquidatingPerpPnl", + "msg": "tierViolationLiquidatingPerpPnl" + }, + { + "code": 6228, + "name": "couldNotLoadUserData", + "msg": "couldNotLoadUserData" + }, + { + "code": 6229, + "name": "userWrongMutability", + "msg": "userWrongMutability" + }, + { + "code": 6230, + "name": "invalidUserAccount", + "msg": "invalidUserAccount" + }, + { + "code": 6231, + "name": "couldNotLoadUserStatsData", + "msg": "couldNotLoadUserData" + }, + { + "code": 6232, + "name": "userStatsWrongMutability", + "msg": "userWrongMutability" + }, + { + "code": 6233, + "name": "invalidUserStatsAccount", + "msg": "invalidUserAccount" + }, + { + "code": 6234, + "name": "userNotFound", + "msg": "userNotFound" + }, + { + "code": 6235, + "name": "unableToLoadUserAccount", + "msg": "unableToLoadUserAccount" + }, + { + "code": 6236, + "name": "userStatsNotFound", + "msg": "userStatsNotFound" + }, + { + "code": 6237, + "name": "unableToLoadUserStatsAccount", + "msg": "unableToLoadUserStatsAccount" + }, + { + "code": 6238, + "name": "userNotInactive", + "msg": "User Not Inactive" + }, + { + "code": 6239, + "name": "revertFill", + "msg": "revertFill" + }, + { + "code": 6240, + "name": "invalidMarketAccountforDeletion", + "msg": "Invalid MarketAccount for Deletion" + }, + { + "code": 6241, + "name": "invalidSpotFulfillmentParams", + "msg": "Invalid Spot Fulfillment Params" + }, + { + "code": 6242, + "name": "failedToGetMint", + "msg": "Failed to Get Mint" + }, + { + "code": 6243, + "name": "failedPhoenixCpi", + "msg": "failedPhoenixCpi" + }, + { + "code": 6244, + "name": "failedToDeserializePhoenixMarket", + "msg": "failedToDeserializePhoenixMarket" + }, + { + "code": 6245, + "name": "invalidPricePrecision", + "msg": "invalidPricePrecision" + }, + { + "code": 6246, + "name": "invalidPhoenixProgram", + "msg": "invalidPhoenixProgram" + }, + { + "code": 6247, + "name": "invalidPhoenixMarket", + "msg": "invalidPhoenixMarket" + }, + { + "code": 6248, + "name": "invalidSwap", + "msg": "invalidSwap" + }, + { + "code": 6249, + "name": "swapLimitPriceBreached", + "msg": "swapLimitPriceBreached" + }, + { + "code": 6250, + "name": "spotMarketReduceOnly", + "msg": "spotMarketReduceOnly" + }, + { + "code": 6251, + "name": "fundingWasNotUpdated", + "msg": "fundingWasNotUpdated" + }, + { + "code": 6252, + "name": "impossibleFill", + "msg": "impossibleFill" + }, + { + "code": 6253, + "name": "cantUpdatePerpBidAskTwap", + "msg": "cantUpdatePerpBidAskTwap" + }, + { + "code": 6254, + "name": "userReduceOnly", + "msg": "userReduceOnly" + }, + { + "code": 6255, + "name": "invalidMarginCalculation", + "msg": "invalidMarginCalculation" + }, + { + "code": 6256, + "name": "cantPayUserInitFee", + "msg": "cantPayUserInitFee" + }, + { + "code": 6257, + "name": "cantReclaimRent", + "msg": "cantReclaimRent" + }, + { + "code": 6258, + "name": "insuranceFundOperationPaused", + "msg": "insuranceFundOperationPaused" + }, + { + "code": 6259, + "name": "noUnsettledPnl", + "msg": "noUnsettledPnl" + }, + { + "code": 6260, + "name": "pnlPoolCantSettleUser", + "msg": "pnlPoolCantSettleUser" + }, + { + "code": 6261, + "name": "oracleNonPositive", + "msg": "oracleInvalid" + }, + { + "code": 6262, + "name": "oracleTooVolatile", + "msg": "oracleTooVolatile" + }, + { + "code": 6263, + "name": "oracleTooUncertain", + "msg": "oracleTooUncertain" + }, + { + "code": 6264, + "name": "oracleStaleForMargin", + "msg": "oracleStaleForMargin" + }, + { + "code": 6265, + "name": "oracleInsufficientDataPoints", + "msg": "oracleInsufficientDataPoints" + }, + { + "code": 6266, + "name": "oracleStaleForAmm", + "msg": "oracleStaleForAmm" + }, + { + "code": 6267, + "name": "unableToParsePullOracleMessage", + "msg": "Unable to parse pull oracle message" + }, + { + "code": 6268, + "name": "maxBorrows", + "msg": "Can not borow more than max borrows" + }, + { + "code": 6269, + "name": "oracleUpdatesNotMonotonic", + "msg": "Updates must be monotonically increasing" + }, + { + "code": 6270, + "name": "oraclePriceFeedMessageMismatch", + "msg": "Trying to update price feed with the wrong feed id" + }, + { + "code": 6271, + "name": "oracleUnsupportedMessageType", + "msg": "The message in the update must be a PriceFeedMessage" + }, + { + "code": 6272, + "name": "oracleDeserializeMessageFailed", + "msg": "Could not deserialize the message in the update" + }, + { + "code": 6273, + "name": "oracleWrongGuardianSetOwner", + "msg": "Wrong guardian set owner in update price atomic" + }, + { + "code": 6274, + "name": "oracleWrongWriteAuthority", + "msg": "Oracle post update atomic price feed account must be drift program" + }, + { + "code": 6275, + "name": "oracleWrongVaaOwner", + "msg": "Oracle vaa owner must be wormhole program" + }, + { + "code": 6276, + "name": "oracleTooManyPriceAccountUpdates", + "msg": "Multi updates must have 2 or fewer accounts passed in remaining accounts" + }, + { + "code": 6277, + "name": "oracleMismatchedVaaAndPriceUpdates", + "msg": "Don't have the same remaining accounts number and pyth updates left" + }, + { + "code": 6278, + "name": "oracleBadRemainingAccountPublicKey", + "msg": "Remaining account passed does not match oracle update derived pda" + }, + { + "code": 6279, + "name": "failedOpenbookV2cpi", + "msg": "failedOpenbookV2cpi" + }, + { + "code": 6280, + "name": "invalidOpenbookV2Program", + "msg": "invalidOpenbookV2Program" + }, + { + "code": 6281, + "name": "invalidOpenbookV2Market", + "msg": "invalidOpenbookV2Market" + }, + { + "code": 6282, + "name": "nonZeroTransferFee", + "msg": "Non zero transfer fee" + }, + { + "code": 6283, + "name": "liquidationOrderFailedToFill", + "msg": "Liquidation order failed to fill" + }, + { + "code": 6284, + "name": "invalidPredictionMarketOrder", + "msg": "Invalid prediction market order" + }, + { + "code": 6285, + "name": "invalidVerificationIxIndex", + "msg": "Ed25519 Ix must be before place and make SignedMsg order ix" + }, + { + "code": 6286, + "name": "sigVerificationFailed", + "msg": "SignedMsg message verificaiton failed" + }, + { + "code": 6287, + "name": "mismatchedSignedMsgOrderParamsMarketIndex", + "msg": "Market index mismatched b/w taker and maker SignedMsg order params" + }, + { + "code": 6288, + "name": "invalidSignedMsgOrderParam", + "msg": "Invalid SignedMsg order param" + }, + { + "code": 6289, + "name": "placeAndTakeOrderSuccessConditionFailed", + "msg": "Place and take order success condition failed" + }, + { + "code": 6290, + "name": "invalidHighLeverageModeConfig", + "msg": "Invalid High Leverage Mode Config" + }, + { + "code": 6291, + "name": "invalidRfqUserAccount", + "msg": "Invalid RFQ User Account" + }, + { + "code": 6292, + "name": "rfqUserAccountWrongMutability", + "msg": "RFQUserAccount should be mutable" + }, + { + "code": 6293, + "name": "rfqUserAccountFull", + "msg": "RFQUserAccount has too many active RFQs" + }, + { + "code": 6294, + "name": "rfqOrderNotFilled", + "msg": "RFQ order not filled as expected" + }, + { + "code": 6295, + "name": "invalidRfqOrder", + "msg": "RFQ orders must be jit makers" + }, + { + "code": 6296, + "name": "invalidRfqMatch", + "msg": "RFQ matches must be valid" + }, + { + "code": 6297, + "name": "invalidSignedMsgUserAccount", + "msg": "Invalid SignedMsg user account" + }, + { + "code": 6298, + "name": "signedMsgUserAccountWrongMutability", + "msg": "SignedMsg account wrong mutability" + }, + { + "code": 6299, + "name": "signedMsgUserOrdersAccountFull", + "msg": "SignedMsgUserAccount has too many active orders" + }, + { + "code": 6300, + "name": "signedMsgOrderDoesNotExist", + "msg": "Order with SignedMsg uuid does not exist" + }, + { + "code": 6301, + "name": "invalidSignedMsgOrderId", + "msg": "SignedMsg order id cannot be 0s" + }, + { + "code": 6302, + "name": "invalidPoolId", + "msg": "Invalid pool id" + }, + { + "code": 6303, + "name": "invalidProtectedMakerModeConfig", + "msg": "Invalid Protected Maker Mode Config" + }, + { + "code": 6304, + "name": "invalidPythLazerStorageOwner", + "msg": "Invalid pyth lazer storage owner" + }, + { + "code": 6305, + "name": "unverifiedPythLazerMessage", + "msg": "Verification of pyth lazer message failed" + }, + { + "code": 6306, + "name": "invalidPythLazerMessage", + "msg": "Invalid pyth lazer message" + }, + { + "code": 6307, + "name": "pythLazerMessagePriceFeedMismatch", + "msg": "Pyth lazer message does not correspond to correct fed id" + }, + { + "code": 6308, + "name": "invalidLiquidateSpotWithSwap", + "msg": "invalidLiquidateSpotWithSwap" + }, + { + "code": 6309, + "name": "signedMsgUserContextUserMismatch", + "msg": "User in SignedMsg message does not match user in ix context" + }, + { + "code": 6310, + "name": "userFuelOverflowThresholdNotMet", + "msg": "User fuel overflow threshold not met" + }, + { + "code": 6311, + "name": "fuelOverflowAccountNotFound", + "msg": "FuelOverflow account not found" + }, + { + "code": 6312, + "name": "invalidTransferPerpPosition", + "msg": "Invalid Transfer Perp Position" + }, + { + "code": 6313, + "name": "invalidSignedMsgUserOrdersResize", + "msg": "Invalid SignedMsgUserOrders resize" + }, + { + "code": 6314, + "name": "couldNotDeserializeHighLeverageModeConfig", + "msg": "Could not deserialize high leverage mode config" + }, + { + "code": 6315, + "name": "invalidIfRebalanceConfig", + "msg": "Invalid If Rebalance Config" + }, + { + "code": 6316, + "name": "invalidIfRebalanceSwap", + "msg": "Invalid If Rebalance Swap" + }, + { + "code": 6317, + "name": "invalidRevenueShareResize", + "msg": "Invalid RevenueShare resize" + }, + { + "code": 6318, + "name": "builderRevoked", + "msg": "Builder has been revoked" + }, + { + "code": 6319, + "name": "invalidBuilderFee", + "msg": "Builder fee is greater than max fee bps" + }, + { + "code": 6320, + "name": "revenueShareEscrowAuthorityMismatch", + "msg": "RevenueShareEscrow authority mismatch" + }, + { + "code": 6321, + "name": "revenueShareEscrowOrdersAccountFull", + "msg": "RevenueShareEscrow has too many active orders" + }, + { + "code": 6322, + "name": "invalidRevenueShareAccount", + "msg": "Invalid RevenueShareAccount" + }, + { + "code": 6323, + "name": "cannotRevokeBuilderWithOpenOrders", + "msg": "Cannot revoke builder with open orders" + }, + { + "code": 6324, + "name": "unableToLoadRevenueShareAccount", + "msg": "Unable to load builder account" + }, + { + "code": 6325, + "name": "invalidConstituent", + "msg": "Invalid Constituent" + }, + { + "code": 6326, + "name": "invalidAmmConstituentMappingArgument", + "msg": "Invalid Amm Constituent Mapping argument" + }, + { + "code": 6327, + "name": "constituentNotFound", + "msg": "Constituent not found" + }, + { + "code": 6328, + "name": "constituentCouldNotLoad", + "msg": "Constituent could not load" + }, + { + "code": 6329, + "name": "constituentWrongMutability", + "msg": "Constituent wrong mutability" + }, + { + "code": 6330, + "name": "wrongNumberOfConstituents", + "msg": "Wrong number of constituents passed to instruction" + }, + { + "code": 6331, + "name": "insufficientConstituentTokenBalance", + "msg": "Insufficient constituent token balance" + }, + { + "code": 6332, + "name": "ammCacheStale", + "msg": "Amm Cache data too stale" + }, + { + "code": 6333, + "name": "lpPoolAumDelayed", + "msg": "LP Pool AUM not updated recently" + }, + { + "code": 6334, + "name": "constituentOracleStale", + "msg": "Constituent oracle is stale" + }, + { + "code": 6335, + "name": "lpInvariantFailed", + "msg": "LP Invariant failed" + }, + { + "code": 6336, + "name": "invalidConstituentDerivativeWeights", + "msg": "Invalid constituent derivative weights" + }, + { + "code": 6337, + "name": "maxDlpAumBreached", + "msg": "Max DLP AUM Breached" + }, + { + "code": 6338, + "name": "settleLpPoolDisabled", + "msg": "Settle Lp Pool Disabled" + }, + { + "code": 6339, + "name": "mintRedeemLpPoolDisabled", + "msg": "Mint/Redeem Lp Pool Disabled" + }, + { + "code": 6340, + "name": "lpPoolSettleInvariantBreached", + "msg": "Settlement amount exceeded" + }, + { + "code": 6341, + "name": "invalidConstituentOperation", + "msg": "Invalid constituent operation" + }, + { + "code": 6342, + "name": "unauthorized", + "msg": "Unauthorized for operation" + }, + { + "code": 6343, + "name": "invalidLpPoolId", + "msg": "Invalid Lp Pool Id for Operation" + }, + { + "code": 6344, + "name": "marketIndexNotFoundAmmCache", + "msg": "marketIndexNotFoundAmmCache" + } + ], + "types": [ + { + "name": "amm", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "docs": [ + "oracle price data public key" + ], + "type": "pubkey" + }, + { + "name": "historicalOracleData", + "docs": [ + "stores historically witnessed oracle data" + ], + "type": { + "defined": { + "name": "historicalOracleData" + } + } + }, + { + "name": "baseAssetAmountPerLp", + "docs": [ + "accumulated base asset amount since inception per lp share", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteAssetAmountPerLp", + "docs": [ + "accumulated quote asset amount since inception per lp share", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "feePool", + "docs": [ + "partition of fees from perp market trading moved from pnl settlements" + ], + "type": { + "defined": { + "name": "poolBalance" + } + } + }, + { + "name": "baseAssetReserve", + "docs": [ + "`x` reserves for constant product mm formula (x * y = k)", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "quoteAssetReserve", + "docs": [ + "`y` reserves for constant product mm formula (x * y = k)", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "concentrationCoef", + "docs": [ + "determines how close the min/max base asset reserve sit vs base reserves", + "allow for decreasing slippage without increasing liquidity and v.v.", + "precision: PERCENTAGE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "minBaseAssetReserve", + "docs": [ + "minimum base_asset_reserve allowed before AMM is unavailable", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "maxBaseAssetReserve", + "docs": [ + "maximum base_asset_reserve allowed before AMM is unavailable", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "sqrtK", + "docs": [ + "`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "pegMultiplier", + "docs": [ + "normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced", + "precision: PEG_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "terminalQuoteAssetReserve", + "docs": [ + "y when market is balanced. stored to save computation", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "baseAssetAmountLong", + "docs": [ + "always non-negative. tracks number of total longs in market (regardless of counterparty)", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "baseAssetAmountShort", + "docs": [ + "always non-positive. tracks number of total shorts in market (regardless of counterparty)", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "baseAssetAmountWithAmm", + "docs": [ + "tracks net position (longs-shorts) in market with AMM as counterparty", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "baseAssetAmountWithUnsettledLp", + "docs": [ + "tracks net position (longs-shorts) in market with LPs as counterparty", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "maxOpenInterest", + "docs": [ + "max allowed open interest, blocks trades that breach this value", + "precision: BASE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "quoteAssetAmount", + "docs": [ + "sum of all user's perp quote_asset_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteEntryAmountLong", + "docs": [ + "sum of all long user's quote_entry_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteEntryAmountShort", + "docs": [ + "sum of all short user's quote_entry_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteBreakEvenAmountLong", + "docs": [ + "sum of all long user's quote_break_even_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "quoteBreakEvenAmountShort", + "docs": [ + "sum of all short user's quote_break_even_amount in market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "userLpShares", + "docs": [ + "total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastFundingRate", + "docs": [ + "last funding rate in this perp market (unit is quote per base)", + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastFundingRateLong", + "docs": [ + "last funding rate for longs in this perp market (unit is quote per base)", + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastFundingRateShort", + "docs": [ + "last funding rate for shorts in this perp market (unit is quote per base)", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "last24hAvgFundingRate", + "docs": [ + "estimate of last 24h of funding rate perp market (unit is quote per base)", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "totalFee", + "docs": [ + "total fees collected by this perp market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "totalMmFee", + "docs": [ + "total fees collected by the vAMM's bid/ask spread", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "totalExchangeFee", + "docs": [ + "total fees collected by exchange fee schedule", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalFeeMinusDistributions", + "docs": [ + "total fees minus any recognized upnl and pool withdraws", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "totalFeeWithdrawn", + "docs": [ + "sum of all fees from fee pool withdrawn to revenue pool", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalLiquidationFee", + "docs": [ + "all fees collected by market for liquidations", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeFundingRateLong", + "docs": [ + "accumulated funding rate for longs since inception in market" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "cumulativeFundingRateShort", + "docs": [ + "accumulated funding rate for shorts since inception in market" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "totalSocialLoss", + "docs": [ + "accumulated social loss paid by users since inception in market" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "askBaseAssetReserve", + "docs": [ + "transformed base_asset_reserve for users going long", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "askQuoteAssetReserve", + "docs": [ + "transformed quote_asset_reserve for users going long", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "bidBaseAssetReserve", + "docs": [ + "transformed base_asset_reserve for users going short", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "bidQuoteAssetReserve", + "docs": [ + "transformed quote_asset_reserve for users going short", + "precision: AMM_RESERVE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastOracleNormalisedPrice", + "docs": [ + "the last seen oracle price partially shrunk toward the amm reserve price", + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastOracleReservePriceSpreadPct", + "docs": [ + "the gap between the oracle price and the reserve price = y * peg_multiplier / x" + ], + "type": "i64" + }, + { + "name": "lastBidPriceTwap", + "docs": [ + "average estimate of bid price over funding_period", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastAskPriceTwap", + "docs": [ + "average estimate of ask price over funding_period", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastMarkPriceTwap", + "docs": [ + "average estimate of (bid+ask)/2 price over funding_period", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastMarkPriceTwap5min", + "docs": [ + "average estimate of (bid+ask)/2 price over FIVE_MINUTES" + ], + "type": "u64" + }, + { + "name": "lastUpdateSlot", + "docs": [ + "the last blockchain slot the amm was updated" + ], + "type": "u64" + }, + { + "name": "lastOracleConfPct", + "docs": [ + "the pct size of the oracle confidence interval", + "precision: PERCENTAGE_PRECISION" + ], + "type": "u64" + }, + { + "name": "netRevenueSinceLastFunding", + "docs": [ + "the total_fee_minus_distribution change since the last funding update", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastFundingRateTs", + "docs": [ + "the last funding rate update unix_timestamp" + ], + "type": "i64" + }, + { + "name": "fundingPeriod", + "docs": [ + "the periodicity of the funding rate updates" + ], + "type": "i64" + }, + { + "name": "orderStepSize", + "docs": [ + "the base step size (increment) of orders", + "precision: BASE_PRECISION" + ], + "type": "u64" + }, + { + "name": "orderTickSize", + "docs": [ + "the price tick size of orders", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "minOrderSize", + "docs": [ + "the minimum base size of an order", + "precision: BASE_PRECISION" + ], + "type": "u64" + }, + { + "name": "mmOracleSlot", + "docs": [ + "the max base size a single user can have", + "precision: BASE_PRECISION" + ], + "type": "u64" + }, + { + "name": "volume24h", + "docs": [ + "estimated total of volume in market", + "QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "longIntensityVolume", + "docs": [ + "the volume intensity of long fills against AMM" + ], + "type": "u64" + }, + { + "name": "shortIntensityVolume", + "docs": [ + "the volume intensity of short fills against AMM" + ], + "type": "u64" + }, + { + "name": "lastTradeTs", + "docs": [ + "the blockchain unix timestamp at the time of the last trade" + ], + "type": "i64" + }, + { + "name": "markStd", + "docs": [ + "estimate of standard deviation of the fill (mark) prices", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "oracleStd", + "docs": [ + "estimate of standard deviation of the oracle price at each update", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastMarkPriceTwapTs", + "docs": [ + "the last unix_timestamp the mark twap was updated" + ], + "type": "i64" + }, + { + "name": "baseSpread", + "docs": [ + "the minimum spread the AMM can quote. also used as step size for some spread logic increases." + ], + "type": "u32" + }, + { + "name": "maxSpread", + "docs": [ + "the maximum spread the AMM can quote" + ], + "type": "u32" + }, + { + "name": "longSpread", + "docs": [ + "the spread for asks vs the reserve price" + ], + "type": "u32" + }, + { + "name": "shortSpread", + "docs": [ + "the spread for bids vs the reserve price" + ], + "type": "u32" + }, + { + "name": "mmOraclePrice", + "docs": [ + "MM oracle price" + ], + "type": "i64" + }, + { + "name": "maxFillReserveFraction", + "docs": [ + "the fraction of total available liquidity a single fill on the AMM can consume" + ], + "type": "u16" + }, + { + "name": "maxSlippageRatio", + "docs": [ + "the maximum slippage a single fill on the AMM can push" + ], + "type": "u16" + }, + { + "name": "curveUpdateIntensity", + "docs": [ + "the update intensity of AMM formulaic updates (adjusting k). 0-100" + ], + "type": "u8" + }, + { + "name": "ammJitIntensity", + "docs": [ + "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.", + "(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM." + ], + "type": "u8" + }, + { + "name": "oracleSource", + "docs": [ + "the oracle provider information. used to decode/scale the oracle public key" + ], + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "lastOracleValid", + "docs": [ + "tracks whether the oracle was considered valid at the last AMM update" + ], + "type": "bool" + }, + { + "name": "targetBaseAssetAmountPerLp", + "docs": [ + "the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split", + "precision: BASE_PRECISION" + ], + "type": "i32" + }, + { + "name": "perLpBase", + "docs": [ + "expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)" + ], + "type": "i8" + }, + { + "name": "oracleLowRiskSlotDelayOverride", + "docs": [ + "the override for the state.min_perp_auction_duration", + "0 is no override, -1 is disable speed bump, 1-100 is literal speed bump" + ], + "type": "i8" + }, + { + "name": "ammSpreadAdjustment", + "docs": [ + "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" + ], + "type": "i8" + }, + { + "name": "oracleSlotDelayOverride", + "type": "i8" + }, + { + "name": "mmOracleSequenceId", + "type": "u64" + }, + { + "name": "netUnsettledFundingPnl", + "type": "i64" + }, + { + "name": "quoteAssetAmountWithUnsettledLp", + "type": "i64" + }, + { + "name": "referencePriceOffset", + "type": "i32" + }, + { + "name": "ammInventorySpreadAdjustment", + "docs": [ + "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" + ], + "type": "i8" + }, + { + "name": "referencePriceOffsetDeadbandPct", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "lastFundingOracleTwap", + "type": "i64" + } + ] + } + }, + { + "name": "addAmmConstituentMappingDatum", + "type": { + "kind": "struct", + "fields": [ + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "weight", + "type": "i64" + } + ] + } + }, + { + "name": "ammCache", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "cache", + "type": { + "vec": { + "defined": { + "name": "cacheInfo" + } + } + } + } + ] + } + }, + { + "name": "ammConstituentDatum", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "lastSlot", + "type": "u64" + }, + { + "name": "weight", + "docs": [ + "PERCENTAGE_PRECISION. The weight this constituent has on the perp market" + ], + "type": "i64" + } + ] + } + }, + { + "name": "ammConstituentMapping", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lpPool", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "weights", + "type": { + "vec": { + "defined": { + "name": "ammConstituentDatum" + } + } + } + } + ] + } + }, + { + "name": "assetTier", + "type": { + "kind": "enum", + "variants": [ + { + "name": "collateral" + }, + { + "name": "protected" + }, + { + "name": "cross" + }, + { + "name": "isolated" + }, + { + "name": "unlisted" + } + ] + } + }, + { + "name": "builderInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "maxFeeTenthBps", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 6 + ] + } + } + ] + } + }, + { + "name": "cacheInfo", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "oracle", + "type": "pubkey" + }, + { + "name": "lastFeePoolTokenAmount", + "type": "u128" + }, + { + "name": "lastNetPnlPoolTokenAmount", + "type": "i128" + }, + { + "name": "lastExchangeFees", + "type": "u128" + }, + { + "name": "lastSettleAmmExFees", + "type": "u128" + }, + { + "name": "lastSettleAmmPnl", + "type": "i128" + }, + { + "name": "position", + "docs": [ + "BASE PRECISION" + ], + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "lastSettleAmount", + "type": "u64" + }, + { + "name": "lastSettleSlot", + "type": "u64" + }, + { + "name": "lastSettleTs", + "type": "i64" + }, + { + "name": "quoteOwedFromLpPool", + "type": "i64" + }, + { + "name": "ammInventoryLimit", + "type": "i64" + }, + { + "name": "oraclePrice", + "type": "i64" + }, + { + "name": "oracleSlot", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "oracleSource", + "type": "u8" + }, + { + "name": "oracleValidity", + "type": "u8" + }, + { + "name": "lpStatusForPerpMarket", + "type": "u8" + }, + { + "name": "ammPositionScalar", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 34 + ] + } + } + ] + } + }, + { + "name": "constituent", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "address of the constituent" + ], + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "lpPool", + "type": "pubkey" + }, + { + "name": "vault", + "type": "pubkey" + }, + { + "name": "totalSwapFees", + "docs": [ + "total fees received by the constituent. Positive = fees received, Negative = fees paid" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "spotBalance", + "docs": [ + "spot borrow-lend balance for constituent" + ], + "type": { + "defined": { + "name": "constituentSpotBalance" + } + } + }, + { + "name": "lastSpotBalanceTokenAmount", + "type": "i64" + }, + { + "name": "cumulativeSpotInterestAccruedTokenAmount", + "type": "i64" + }, + { + "name": "maxWeightDeviation", + "docs": [ + "max deviation from target_weight allowed for the constituent", + "precision: PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "swapFeeMin", + "docs": [ + "min fee charged on swaps to/from this constituent", + "precision: PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "swapFeeMax", + "docs": [ + "max fee charged on swaps to/from this constituent", + "precision: PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "maxBorrowTokenAmount", + "docs": [ + "Max Borrow amount:", + "precision: token precision" + ], + "type": "u64" + }, + { + "name": "vaultTokenBalance", + "docs": [ + "ata token balance in token precision" + ], + "type": "u64" + }, + { + "name": "lastOraclePrice", + "type": "i64" + }, + { + "name": "lastOracleSlot", + "type": "u64" + }, + { + "name": "oracleStalenessThreshold", + "docs": [ + "Delay allowed for valid AUM calculation" + ], + "type": "u64" + }, + { + "name": "flashLoanInitialTokenAmount", + "type": "u64" + }, + { + "name": "nextSwapId", + "docs": [ + "Every swap to/from this constituent has a monotonically increasing id. This is the next id to use" + ], + "type": "u64" + }, + { + "name": "derivativeWeight", + "docs": [ + "percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight" + ], + "type": "u64" + }, + { + "name": "volatility", + "type": "u64" + }, + { + "name": "constituentDerivativeDepegThreshold", + "type": "u64" + }, + { + "name": "constituentDerivativeIndex", + "docs": [ + "The `constituent_index` of the parent constituent. -1 if it is a parent index", + "Example: if in a pool with SOL (parent) and dSOL (derivative),", + "SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,", + "dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1" + ], + "type": "i16" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "decimals", + "type": "u8" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "vaultBump", + "type": "u8" + }, + { + "name": "gammaInventory", + "type": "u8" + }, + { + "name": "gammaExecution", + "type": "u8" + }, + { + "name": "xi", + "type": "u8" + }, + { + "name": "status", + "type": "u8" + }, + { + "name": "pausedOperations", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 162 + ] + } + } + ] + } + }, + { + "name": "constituentCorrelations", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lpPool", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "correlations", + "type": { + "vec": "i64" + } + } + ] + } + }, + { + "name": "constituentParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxWeightDeviation", + "type": { + "option": "i64" + } + }, + { + "name": "swapFeeMin", + "type": { + "option": "i64" + } + }, + { + "name": "swapFeeMax", + "type": { + "option": "i64" + } + }, + { + "name": "maxBorrowTokenAmount", + "type": { + "option": "u64" + } + }, + { + "name": "oracleStalenessThreshold", + "type": { + "option": "u64" + } + }, + { + "name": "costToTradeBps", + "type": { + "option": "i32" + } + }, + { + "name": "constituentDerivativeIndex", + "type": { + "option": "i16" + } + }, + { + "name": "derivativeWeight", + "type": { + "option": "u64" + } + }, + { + "name": "volatility", + "type": { + "option": "u64" + } + }, + { + "name": "gammaExecution", + "type": { + "option": "u8" + } + }, + { + "name": "gammaInventory", + "type": { + "option": "u8" + } + }, + { + "name": "xi", + "type": { + "option": "u8" + } + } + ] + } + }, + { + "name": "constituentSpotBalance", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "scaledBalance", + "docs": [ + "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", + "interest of corresponding market.", + "precision: token precision" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeDeposits", + "docs": [ + "The cumulative deposits/borrows a user has made into a market", + "precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "marketIndex", + "docs": [ + "The market index of the corresponding spot market" + ], + "type": "u16" + }, + { + "name": "balanceType", + "docs": [ + "Whether the position is deposit or borrow" + ], + "type": { + "defined": { + "name": "spotBalanceType" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 5 + ] + } + } + ] + } + }, + { + "name": "constituentTargetBase", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lpPool", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "targets", + "type": { + "vec": { + "defined": { + "name": "targetsDatum" + } + } + } + } + ] + } + }, + { + "name": "contractTier", + "type": { + "kind": "enum", + "variants": [ + { + "name": "a" + }, + { + "name": "b" + }, + { + "name": "c" + }, + { + "name": "speculative" + }, + { + "name": "highlySpeculative" + }, + { + "name": "isolated" + } + ] + } + }, + { + "name": "contractType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "perpetual" + }, + { + "name": "future" + }, + { + "name": "prediction" + } + ] + } + }, + { + "name": "curveRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "recordId", + "type": "u64" + }, + { + "name": "pegMultiplierBefore", + "type": "u128" + }, + { + "name": "baseAssetReserveBefore", + "type": "u128" + }, + { + "name": "quoteAssetReserveBefore", + "type": "u128" + }, + { + "name": "sqrtKBefore", + "type": "u128" + }, + { + "name": "pegMultiplierAfter", + "type": "u128" + }, + { + "name": "baseAssetReserveAfter", + "type": "u128" + }, + { + "name": "quoteAssetReserveAfter", + "type": "u128" + }, + { + "name": "sqrtKAfter", + "type": "u128" + }, + { + "name": "baseAssetAmountLong", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "u128" + }, + { + "name": "baseAssetAmountShort", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "u128" + }, + { + "name": "baseAssetAmountWithAmm", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i128" + }, + { + "name": "totalFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" + }, + { + "name": "totalFeeMinusDistributions", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" + }, + { + "name": "adjustmentCost", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i128" + }, + { + "name": "oraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "fillRecord", + "type": "u128" + }, + { + "name": "numberOfUsers", + "type": "u32" + }, + { + "name": "marketIndex", + "type": "u16" + } + ] + } + }, + { + "name": "deleteUserRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "docs": [ + "unix_timestamp of action" + ], + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "keeper", + "type": { + "option": "pubkey" + } + } + ] + } + }, + { + "name": "depositDirection", + "type": { + "kind": "enum", + "variants": [ + { + "name": "deposit" + }, + { + "name": "withdraw" + } + ] + } + }, + { + "name": "depositExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "none" + }, + { + "name": "transfer" + }, + { + "name": "borrow" + }, + { + "name": "repayBorrow" + }, + { + "name": "reward" + } + ] + } + }, + { + "name": "depositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "docs": [ + "unix_timestamp of action" + ], + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "user", + "docs": [ + "user account public key" + ], + "type": "pubkey" + }, + { + "name": "direction", + "type": { + "defined": { + "name": "depositDirection" + } + } + }, + { + "name": "depositRecordId", + "type": "u64" + }, + { + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "marketIndex", + "docs": [ + "spot market index" + ], + "type": "u16" + }, + { + "name": "oraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "marketDepositBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "marketWithdrawBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "marketCumulativeDepositInterest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "marketCumulativeBorrowInterest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "totalDepositsAfter", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalWithdrawsAfter", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "explanation", + "type": { + "defined": { + "name": "depositExplanation" + } + } + }, + { + "name": "transferUser", + "type": { + "option": "pubkey" + } + }, + { + "name": "signer", + "type": { + "option": "pubkey" + } + }, + { + "name": "userTokenAmountAfter", + "docs": [ + "precision: token mint precision" + ], + "type": "i128" + } + ] + } + }, + { + "name": "feeStructure", + "type": { + "kind": "struct", + "fields": [ + { + "name": "feeTiers", + "type": { + "array": [ + { + "defined": { + "name": "feeTier" + } + }, + 10 + ] + } + }, + { + "name": "fillerRewardStructure", + "type": { + "defined": { + "name": "orderFillerRewardStructure" + } + } + }, + { + "name": "referrerRewardEpochUpperBound", + "type": "u64" + }, + { + "name": "flatFillerFee", + "type": "u64" + } + ] + } + }, + { + "name": "feeTier", + "type": { + "kind": "struct", + "fields": [ + { + "name": "feeNumerator", + "type": "u32" + }, + { + "name": "feeDenominator", + "type": "u32" + }, + { + "name": "makerRebateNumerator", + "type": "u32" + }, + { + "name": "makerRebateDenominator", + "type": "u32" + }, + { + "name": "referrerRewardNumerator", + "type": "u32" + }, + { + "name": "referrerRewardDenominator", + "type": "u32" + }, + { + "name": "refereeFeeNumerator", + "type": "u32" + }, + { + "name": "refereeFeeDenominator", + "type": "u32" + } + ] + } + }, + { + "name": "fuelOverflow", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The authority of this overflow account" + ], + "type": "pubkey" + }, + { + "name": "fuelInsurance", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelDeposits", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelBorrows", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelPositions", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelTaker", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "fuelMaker", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastFuelSweepTs", + "type": "u32" + }, + { + "name": "lastResetTs", + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u128", + 6 + ] + } + } + ] + } + }, + { + "name": "fuelSeasonRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "fuelInsurance", + "type": "u128" + }, + { + "name": "fuelDeposits", + "type": "u128" + }, + { + "name": "fuelBorrows", + "type": "u128" + }, + { + "name": "fuelPositions", + "type": "u128" + }, + { + "name": "fuelTaker", + "type": "u128" + }, + { + "name": "fuelMaker", + "type": "u128" + }, + { + "name": "fuelTotal", + "type": "u128" + } + ] + } + }, + { + "name": "fuelSweepRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "userStatsFuelInsurance", + "type": "u32" + }, + { + "name": "userStatsFuelDeposits", + "type": "u32" + }, + { + "name": "userStatsFuelBorrows", + "type": "u32" + }, + { + "name": "userStatsFuelPositions", + "type": "u32" + }, + { + "name": "userStatsFuelTaker", + "type": "u32" + }, + { + "name": "userStatsFuelMaker", + "type": "u32" + }, + { + "name": "fuelOverflowFuelInsurance", + "type": "u128" + }, + { + "name": "fuelOverflowFuelDeposits", + "type": "u128" + }, + { + "name": "fuelOverflowFuelBorrows", + "type": "u128" + }, + { + "name": "fuelOverflowFuelPositions", + "type": "u128" + }, + { + "name": "fuelOverflowFuelTaker", + "type": "u128" + }, + { + "name": "fuelOverflowFuelMaker", + "type": "u128" + } + ] + } + }, + { + "name": "fundingPaymentRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fundingPayment", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "baseAssetAmount", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "userLastCumulativeFunding", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "ammCumulativeFundingLong", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "ammCumulativeFundingShort", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + } + ] + } + }, + { + "name": "fundingRateRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "recordId", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fundingRate", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "fundingRateLong", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "fundingRateShort", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "cumulativeFundingRateLong", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "cumulativeFundingRateShort", + "docs": [ + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i128" + }, + { + "name": "oraclePriceTwap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "markPriceTwap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "periodRevenue", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "baseAssetAmountWithAmm", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i128" + }, + { + "name": "baseAssetAmountWithUnsettledLp", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i128" + } + ] + } + }, + { + "name": "highLeverageModeConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "currentUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "u8" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "currentMaintenanceUsers", + "type": "u32" + }, + { + "name": "padding2", + "type": { + "array": [ + "u8", + 24 + ] + } + } + ] + } + }, + { + "name": "historicalIndexData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lastIndexBidPrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastIndexAskPrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastIndexPriceTwap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastIndexPriceTwap5min", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastIndexPriceTwapTs", + "docs": [ + "unix_timestamp of last snapshot" + ], + "type": "i64" + } + ] + } + }, + { + "name": "historicalOracleData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "lastOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastOracleConf", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastOracleDelay", + "docs": [ + "number of slots since last update" + ], + "type": "i64" + }, + { + "name": "lastOraclePriceTwap", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastOraclePriceTwap5min", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastOraclePriceTwapTs", + "docs": [ + "unix_timestamp of last snapshot" + ], + "type": "i64" + } + ] + } + }, + { + "name": "ifRebalanceConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" + }, + { + "name": "totalInAmount", + "docs": [ + "total amount to be sold" + ], + "type": "u64" + }, + { + "name": "currentInAmount", + "docs": [ + "amount already sold" + ], + "type": "u64" + }, + { + "name": "currentOutAmount", + "docs": [ + "amount already bought" + ], + "type": "u64" + }, + { + "name": "currentOutAmountTransferred", + "docs": [ + "amount already transferred to revenue pool" + ], + "type": "u64" + }, + { + "name": "currentInAmountSinceLastTransfer", + "docs": [ + "amount already bought in epoch" + ], + "type": "u64" + }, + { + "name": "epochStartTs", + "docs": [ + "start time of epoch" + ], + "type": "i64" + }, + { + "name": "epochInAmount", + "docs": [ + "amount already bought in epoch" + ], + "type": "u64" + }, + { + "name": "epochMaxInAmount", + "docs": [ + "max amount to swap in epoch" + ], + "type": "u64" + }, + { + "name": "epochDuration", + "docs": [ + "duration of epoch" + ], + "type": "i64" + }, + { + "name": "outMarketIndex", + "docs": [ + "market index to sell" + ], + "type": "u16" + }, + { + "name": "inMarketIndex", + "docs": [ + "market index to buy" + ], + "type": "u16" + }, + { + "name": "maxSlippageBps", + "type": "u16" + }, + { + "name": "swapMode", + "type": "u8" + }, + { + "name": "status", + "type": "u8" + }, + { + "name": "padding2", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "ifRebalanceConfigParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "totalInAmount", + "type": "u64" + }, + { + "name": "epochMaxInAmount", + "type": "u64" + }, + { + "name": "epochDuration", + "type": "i64" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "maxSlippageBps", + "type": "u16" + }, + { + "name": "swapMode", + "type": "u8" + }, + { + "name": "status", + "type": "u8" + } + ] + } + }, + { + "name": "insuranceClaim", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "revenueWithdrawSinceLastSettle", + "docs": [ + "The amount of revenue last settled", + "Positive if funds left the perp market,", + "negative if funds were pulled into the perp market", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "maxRevenueWithdrawPerPeriod", + "docs": [ + "The max amount of revenue that can be withdrawn per period", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "quoteMaxInsurance", + "docs": [ + "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "quoteSettledInsurance", + "docs": [ + "The amount of insurance that has been used to resolve bankruptcy and pnl deficits", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastRevenueWithdrawTs", + "docs": [ + "The last time revenue was settled in/out of market" + ], + "type": "i64" + } + ] + } + }, + { + "name": "insuranceFund", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "vault", + "type": "pubkey" + }, + { + "name": "totalShares", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "userShares", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "sharesBase", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "unstakingPeriod", + "type": "i64" + }, + { + "name": "lastRevenueSettleTs", + "type": "i64" + }, + { + "name": "revenueSettlePeriod", + "type": "i64" + }, + { + "name": "totalFactor", + "type": "u32" + }, + { + "name": "userFactor", + "type": "u32" + } + ] + } + }, + { + "name": "insuranceFundRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "userIfFactor", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + }, + { + "name": "totalIfFactor", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + }, + { + "name": "vaultAmountBefore", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "insuranceVaultAmountBefore", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "totalIfSharesBefore", + "type": "u128" + }, + { + "name": "totalIfSharesAfter", + "type": "u128" + }, + { + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "i64" + } + ] + } + }, + { + "name": "insuranceFundStake", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "ifShares", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastWithdrawRequestShares", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "ifBase", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastValidTs", + "type": "i64" + }, + { + "name": "lastWithdrawRequestValue", + "type": "u64" + }, + { + "name": "lastWithdrawRequestTs", + "type": "i64" + }, + { + "name": "costBasis", + "type": "i64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 14 + ] + } + } + ] + } + }, + { + "name": "insuranceFundStakeRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "action", + "type": { + "defined": { + "name": "stakeAction" + } + } + }, + { + "name": "amount", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "insuranceVaultAmountBefore", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "ifSharesBefore", + "type": "u128" + }, + { + "name": "userIfSharesBefore", + "type": "u128" + }, + { + "name": "totalIfSharesBefore", + "type": "u128" + }, + { + "name": "ifSharesAfter", + "type": "u128" + }, + { + "name": "userIfSharesAfter", + "type": "u128" + }, + { + "name": "totalIfSharesAfter", + "type": "u128" + } + ] + } + }, + { + "name": "insuranceFundSwapRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rebalanceConfig", + "type": "pubkey" + }, + { + "name": "inIfTotalSharesBefore", + "type": "u128" + }, + { + "name": "outIfTotalSharesBefore", + "type": "u128" + }, + { + "name": "inIfUserSharesBefore", + "type": "u128" + }, + { + "name": "outIfUserSharesBefore", + "type": "u128" + }, + { + "name": "inIfTotalSharesAfter", + "type": "u128" + }, + { + "name": "outIfTotalSharesAfter", + "type": "u128" + }, + { + "name": "inIfUserSharesAfter", + "type": "u128" + }, + { + "name": "outIfUserSharesAfter", + "type": "u128" + }, + { + "name": "ts", + "type": "i64" + }, + { + "name": "inAmount", + "type": "u64" + }, + { + "name": "outAmount", + "type": "u64" + }, + { + "name": "outOraclePrice", + "type": "u64" + }, + { + "name": "outOraclePriceTwap", + "type": "i64" + }, + { + "name": "inVaultAmountBefore", + "type": "u64" + }, + { + "name": "outVaultAmountBefore", + "type": "u64" + }, + { + "name": "inFundVaultAmountAfter", + "type": "u64" + }, + { + "name": "outFundVaultAmountAfter", + "type": "u64" + }, + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outMarketIndex", + "type": "u16" + } + ] + } + }, + { + "name": "lpAction", + "type": { + "kind": "enum", + "variants": [ + { + "name": "addLiquidity" + }, + { + "name": "removeLiquidity" + }, + { + "name": "settleLiquidity" + }, + { + "name": "removeLiquidityDerisk" + } + ] + } + }, + { + "name": "lpBorrowLendDepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "direction", + "type": { + "defined": { + "name": "depositDirection" + } + } + }, + { + "name": "tokenBalance", + "type": "i64" + }, + { + "name": "lastTokenBalance", + "type": "i64" + }, + { + "name": "interestAccruedTokenAmount", + "type": "i64" + }, + { + "name": "amountDepositWithdraw", + "type": "u64" + }, + { + "name": "lpPool", + "type": "pubkey" + } + ] + } + }, + { + "name": "lpMintRedeemRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "description", + "type": "u8" + }, + { + "name": "amount", + "docs": [ + "precision: continutent mint precision, gross fees" + ], + "type": "u128" + }, + { + "name": "fee", + "docs": [ + "precision: fee on amount, constituent market mint precision" + ], + "type": "i128" + }, + { + "name": "spotMarketIndex", + "type": "u16" + }, + { + "name": "constituentIndex", + "type": "u16" + }, + { + "name": "oraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "mint", + "docs": [ + "token mint" + ], + "type": "pubkey" + }, + { + "name": "lpAmount", + "docs": [ + "lp amount, lp mint precision" + ], + "type": "u64" + }, + { + "name": "lpFee", + "docs": [ + "lp fee, lp mint precision" + ], + "type": "i64" + }, + { + "name": "lpPrice", + "docs": [ + "the fair price of the lp token, PRICE_PRECISION" + ], + "type": "u128" + }, + { + "name": "mintRedeemId", + "type": "u64" + }, + { + "name": "lastAum", + "docs": [ + "LPPool last_aum" + ], + "type": "u128" + }, + { + "name": "lastAumSlot", + "type": "u64" + }, + { + "name": "inMarketCurrentWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inMarketTargetWeight", + "type": "i64" + }, + { + "name": "lpPool", + "type": "pubkey" + } + ] + } + }, + { + "name": "lpPool", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "address of the vault." + ], + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "whitelistMint", + "type": "pubkey" + }, + { + "name": "constituentTargetBase", + "type": "pubkey" + }, + { + "name": "constituentCorrelations", + "type": "pubkey" + }, + { + "name": "maxAum", + "docs": [ + "The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)", + "which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)", + "pub quote_constituent_index: u16,", + "QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "lastAum", + "docs": [ + "QUOTE_PRECISION: AUM of the vault in USD, updated lazily" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeQuoteSentToPerpMarkets", + "docs": [ + "QUOTE PRECISION: Cumulative quotes from settles" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeQuoteReceivedFromPerpMarkets", + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalMintRedeemFeesPaid", + "docs": [ + "QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens" + ], + "type": { + "defined": { + "name": "i128" + } + } + }, + { + "name": "lastAumSlot", + "docs": [ + "timestamp of last AUM slot" + ], + "type": "u64" + }, + { + "name": "maxSettleQuoteAmount", + "type": "u64" + }, + { + "name": "padding", + "docs": [ + "timestamp of last vAMM revenue rebalance" + ], + "type": "u64" + }, + { + "name": "mintRedeemId", + "docs": [ + "Every mint/redeem has a monotonically increasing id. This is the next id to use" + ], + "type": "u64" + }, + { + "name": "settleId", + "type": "u64" + }, + { + "name": "minMintFee", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "tokenSupply", + "type": "u64" + }, + { + "name": "volatility", + "type": "u64" + }, + { + "name": "constituents", + "type": "u16" + }, + { + "name": "quoteConsituentIndex", + "type": "u16" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "gammaExecution", + "type": "u8" + }, + { + "name": "xi", + "type": "u8" + }, + { + "name": "targetOracleDelayFeeBpsPer10Slots", + "type": "u8" + }, + { + "name": "targetPositionDelayFeeBpsPer10Slots", + "type": "u8" + }, + { + "name": "lpPoolId", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 174 + ] + } + } + ] + } + }, + { + "name": "lpRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "action", + "type": { + "defined": { + "name": "lpAction" + } + } + }, + { + "name": "nShares", + "docs": [ + "precision: AMM_RESERVE_PRECISION" + ], + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "deltaBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "deltaQuoteAssetAmount", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "pnl", + "docs": [ + "realized pnl of the position settlement", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + } + ] + } + }, + { + "name": "lpSettleRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "recordId", + "type": "u64" + }, + { + "name": "lastTs", + "type": "i64" + }, + { + "name": "lastSlot", + "type": "u64" + }, + { + "name": "ts", + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "settleToLpAmount", + "type": "i64" + }, + { + "name": "perpAmmPnlDelta", + "type": "i64" + }, + { + "name": "perpAmmExFeeDelta", + "type": "i64" + }, + { + "name": "lpAum", + "type": "u128" + }, + { + "name": "lpPrice", + "type": "u128" + }, + { + "name": "lpPool", + "type": "pubkey" + } + ] + } + }, + { + "name": "lpSwapRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "outAmount", + "docs": [ + "precision: out market mint precision, gross fees" + ], + "type": "u128" + }, + { + "name": "inAmount", + "docs": [ + "precision: in market mint precision, gross fees" + ], + "type": "u128" + }, + { + "name": "outFee", + "docs": [ + "precision: fee on amount_out, in market mint precision" + ], + "type": "i128" + }, + { + "name": "inFee", + "docs": [ + "precision: fee on amount_in, out market mint precision" + ], + "type": "i128" + }, + { + "name": "outSpotMarketIndex", + "type": "u16" + }, + { + "name": "inSpotMarketIndex", + "type": "u16" + }, + { + "name": "outConstituentIndex", + "type": "u16" + }, + { + "name": "inConstituentIndex", + "type": "u16" + }, + { + "name": "outOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastAum", + "docs": [ + "LPPool last_aum, QUOTE_PRECISION" + ], + "type": "u128" + }, + { + "name": "lastAumSlot", + "type": "u64" + }, + { + "name": "inMarketCurrentWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "outMarketCurrentWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inMarketTargetWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "outMarketTargetWeight", + "docs": [ + "PERCENTAGE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inSwapId", + "type": "u64" + }, + { + "name": "outSwapId", + "type": "u64" + }, + { + "name": "lpPool", + "type": "pubkey" + } + ] + } + }, + { + "name": "liquidateBorrowForPerpPnlRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "marketOraclePrice", + "type": "i64" + }, + { + "name": "pnlTransfer", + "type": "u128" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + }, + { + "name": "liabilityPrice", + "type": "i64" + }, + { + "name": "liabilityTransfer", + "type": "u128" + } + ] + } + }, + { + "name": "liquidatePerpPnlForDepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "marketOraclePrice", + "type": "i64" + }, + { + "name": "pnlTransfer", + "type": "u128" + }, + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "assetPrice", + "type": "i64" + }, + { + "name": "assetTransfer", + "type": "u128" + } + ] + } + }, + { + "name": "liquidatePerpRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "oraclePrice", + "type": "i64" + }, + { + "name": "baseAssetAmount", + "type": "i64" + }, + { + "name": "quoteAssetAmount", + "type": "i64" + }, + { + "name": "lpShares", + "docs": [ + "precision: AMM_RESERVE_PRECISION" + ], + "type": "u64" + }, + { + "name": "fillRecordId", + "type": "u64" + }, + { + "name": "userOrderId", + "type": "u32" + }, + { + "name": "liquidatorOrderId", + "type": "u32" + }, + { + "name": "liquidatorFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "ifFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": "u64" + } + ] + } + }, + { + "name": "liquidateSpotRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "assetMarketIndex", + "type": "u16" + }, + { + "name": "assetPrice", + "type": "i64" + }, + { + "name": "assetTransfer", + "type": "u128" + }, + { + "name": "liabilityMarketIndex", + "type": "u16" + }, + { + "name": "liabilityPrice", + "type": "i64" + }, + { + "name": "liabilityTransfer", + "docs": [ + "precision: token mint precision" + ], + "type": "u128" + }, + { + "name": "ifFee", + "docs": [ + "precision: token mint precision" + ], + "type": "u64" + } + ] + } + }, + { + "name": "liquidationRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "liquidationType", + "type": { + "defined": { + "name": "liquidationType" + } + } + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "liquidator", + "type": "pubkey" + }, + { + "name": "marginRequirement", + "type": "u128" + }, + { + "name": "totalCollateral", + "type": "i128" + }, + { + "name": "marginFreed", + "type": "u64" + }, + { + "name": "liquidationId", + "type": "u16" + }, + { + "name": "bankrupt", + "type": "bool" + }, + { + "name": "canceledOrderIds", + "type": { + "vec": "u32" + } + }, + { + "name": "liquidatePerp", + "type": { + "defined": { + "name": "liquidatePerpRecord" + } + } + }, + { + "name": "liquidateSpot", + "type": { + "defined": { + "name": "liquidateSpotRecord" + } + } + }, + { + "name": "liquidateBorrowForPerpPnl", + "type": { + "defined": { + "name": "liquidateBorrowForPerpPnlRecord" + } + } + }, + { + "name": "liquidatePerpPnlForDeposit", + "type": { + "defined": { + "name": "liquidatePerpPnlForDepositRecord" + } + } + }, + { + "name": "perpBankruptcy", + "type": { + "defined": { + "name": "perpBankruptcyRecord" + } + } + }, + { + "name": "spotBankruptcy", + "type": { + "defined": { + "name": "spotBankruptcyRecord" + } + } + } + ] + } + }, + { + "name": "liquidationType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "liquidatePerp" + }, + { + "name": "liquidateSpot" + }, + { + "name": "liquidateBorrowForPerpPnl" + }, + { + "name": "liquidatePerpPnlForDeposit" + }, + { + "name": "perpBankruptcy" + }, + { + "name": "spotBankruptcy" + } + ] + } + }, + { + "name": "lpPoolParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxSettleQuoteAmount", + "type": { + "option": "u64" + } + }, + { + "name": "volatility", + "type": { + "option": "u64" + } + }, + { + "name": "gammaExecution", + "type": { + "option": "u8" + } + }, + { + "name": "xi", + "type": { + "option": "u8" + } + }, + { + "name": "maxAum", + "type": { + "option": "u128" + } + }, + { + "name": "whitelistMint", + "type": { + "option": "pubkey" + } + } + ] + } + }, + { + "name": "marginMode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "default" + }, + { + "name": "highLeverage" + }, + { + "name": "highLeverageMaintenance" + } + ] + } + }, + { + "name": "marketStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "initialized" + }, + { + "name": "active" + }, + { + "name": "fundingPaused" + }, + { + "name": "ammPaused" + }, + { + "name": "fillPaused" + }, + { + "name": "withdrawPaused" + }, + { + "name": "reduceOnly" + }, + { + "name": "settlement" + }, + { + "name": "delisted" + } + ] + } + }, + { + "name": "marketType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "spot" + }, + { + "name": "perp" + } + ] + } + }, + { + "name": "modifyOrderParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "direction", + "type": { + "option": { + "defined": { + "name": "positionDirection" + } + } + } + }, + { + "name": "baseAssetAmount", + "type": { + "option": "u64" + } + }, + { + "name": "price", + "type": { + "option": "u64" + } + }, + { + "name": "reduceOnly", + "type": { + "option": "bool" + } + }, + { + "name": "postOnly", + "type": { + "option": { + "defined": { + "name": "postOnlyParam" + } + } + } + }, + { + "name": "bitFlags", + "type": { + "option": "u8" + } + }, + { + "name": "maxTs", + "type": { + "option": "i64" + } + }, + { + "name": "triggerPrice", + "type": { + "option": "u64" + } + }, + { + "name": "triggerCondition", + "type": { + "option": { + "defined": { + "name": "orderTriggerCondition" + } + } + } + }, + { + "name": "oraclePriceOffset", + "type": { + "option": "i32" + } + }, + { + "name": "auctionDuration", + "type": { + "option": "u8" + } + }, + { + "name": "auctionStartPrice", + "type": { + "option": "i64" + } + }, + { + "name": "auctionEndPrice", + "type": { + "option": "i64" + } + }, + { + "name": "policy", + "type": { + "option": "u8" + } + } + ] + } + }, + { + "name": "newUserRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "docs": [ + "unix_timestamp of action" + ], + "type": "i64" + }, + { + "name": "userAuthority", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "subAccountId", + "type": "u16" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "referrer", + "type": "pubkey" + } + ] + } + }, + { + "name": "openbookV2FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" + }, + { + "name": "openbookV2ProgramId", + "type": "pubkey" + }, + { + "name": "openbookV2Market", + "type": "pubkey" + }, + { + "name": "openbookV2MarketAuthority", + "type": "pubkey" + }, + { + "name": "openbookV2EventHeap", + "type": "pubkey" + }, + { + "name": "openbookV2Bids", + "type": "pubkey" + }, + { + "name": "openbookV2Asks", + "type": "pubkey" + }, + { + "name": "openbookV2BaseVault", + "type": "pubkey" + }, + { + "name": "openbookV2QuoteVault", + "type": "pubkey" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fulfillmentType", + "type": { + "defined": { + "name": "spotFulfillmentType" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "oracleGuardRails", + "type": { + "kind": "struct", + "fields": [ + { + "name": "priceDivergence", + "type": { + "defined": { + "name": "priceDivergenceGuardRails" + } + } + }, + { + "name": "validity", + "type": { + "defined": { + "name": "validityGuardRails" + } + } + } + ] + } + }, + { + "name": "oracleSource", + "type": { + "kind": "enum", + "variants": [ + { + "name": "pyth" + }, + { + "name": "switchboard" + }, + { + "name": "quoteAsset" + }, + { + "name": "pyth1K" + }, + { + "name": "pyth1M" + }, + { + "name": "pythStableCoin" + }, + { + "name": "prelaunch" + }, + { + "name": "pythPull" + }, + { + "name": "pyth1KPull" + }, + { + "name": "pyth1MPull" + }, + { + "name": "pythStableCoinPull" + }, + { + "name": "switchboardOnDemand" + }, + { + "name": "pythLazer" + }, + { + "name": "pythLazer1K" + }, + { + "name": "pythLazer1M" + }, + { + "name": "pythLazerStableCoin" + } + ] + } + }, + { + "name": "order", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "slot", + "docs": [ + "The slot the order was placed" + ], + "type": "u64" + }, + { + "name": "price", + "docs": [ + "The limit price for the order (can be 0 for market orders)", + "For orders with an auction, this price isn't used until the auction is complete", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "baseAssetAmount", + "docs": [ + "The size of the order", + "precision for perps: BASE_PRECISION", + "precision for spot: token mint precision" + ], + "type": "u64" + }, + { + "name": "baseAssetAmountFilled", + "docs": [ + "The amount of the order filled", + "precision for perps: BASE_PRECISION", + "precision for spot: token mint precision" + ], + "type": "u64" + }, + { + "name": "quoteAssetAmountFilled", + "docs": [ + "The amount of quote filled for the order", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "triggerPrice", + "docs": [ + "At what price the order will be triggered. Only relevant for trigger orders", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "auctionStartPrice", + "docs": [ + "The start price for the auction. Only relevant for market/oracle orders", + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "auctionEndPrice", + "docs": [ + "The end price for the auction. Only relevant for market/oracle orders", + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "maxTs", + "docs": [ + "The time when the order will expire" + ], + "type": "i64" + }, + { + "name": "oraclePriceOffset", + "docs": [ + "If set, the order limit price is the oracle price + this offset", + "precision: PRICE_PRECISION" + ], + "type": "i32" + }, + { + "name": "orderId", + "docs": [ + "The id for the order. Each users has their own order id space" + ], + "type": "u32" + }, + { + "name": "marketIndex", + "docs": [ + "The perp/spot market index" + ], + "type": "u16" + }, + { + "name": "status", + "docs": [ + "Whether the order is open or unused" + ], + "type": { + "defined": { + "name": "orderStatus" + } + } + }, + { + "name": "orderType", + "docs": [ + "The type of order" + ], + "type": { + "defined": { + "name": "orderType" + } + } + }, + { + "name": "marketType", + "docs": [ + "Whether market is spot or perp" + ], + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "userOrderId", + "docs": [ + "User generated order id. Can make it easier to place/cancel orders" + ], + "type": "u8" + }, + { + "name": "existingPositionDirection", + "docs": [ + "What the users position was when the order was placed" + ], + "type": { + "defined": { + "name": "positionDirection" + } + } + }, + { + "name": "direction", + "docs": [ + "Whether the user is going long or short. LONG = bid, SHORT = ask" + ], + "type": { + "defined": { + "name": "positionDirection" + } + } + }, + { + "name": "reduceOnly", + "docs": [ + "Whether the order is allowed to only reduce position size" + ], + "type": "bool" + }, + { + "name": "postOnly", + "docs": [ + "Whether the order must be a maker" + ], + "type": "bool" + }, + { + "name": "immediateOrCancel", + "docs": [ + "Whether the order must be canceled the same slot it is placed" + ], + "type": "bool" + }, + { + "name": "triggerCondition", + "docs": [ + "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders" + ], + "type": { + "defined": { + "name": "orderTriggerCondition" + } + } + }, + { + "name": "auctionDuration", + "docs": [ + "How many slots the auction lasts" + ], + "type": "u8" + }, + { + "name": "postedSlotTail", + "docs": [ + "Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)" + ], + "type": "u8" + }, + { + "name": "bitFlags", + "docs": [ + "Bitflags for further classification", + "0: is_signed_message" + ], + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 1 + ] + } + } + ] + } + }, + { + "name": "orderAction", + "type": { + "kind": "enum", + "variants": [ + { + "name": "place" + }, + { + "name": "cancel" + }, + { + "name": "fill" + }, + { + "name": "trigger" + }, + { + "name": "expire" + } + ] + } + }, + { + "name": "orderActionExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "none" + }, + { + "name": "insufficientFreeCollateral" + }, + { + "name": "oraclePriceBreachedLimitPrice" + }, + { + "name": "marketOrderFilledToLimitPrice" + }, + { + "name": "orderExpired" + }, + { + "name": "liquidation" + }, + { + "name": "orderFilledWithAmm" + }, + { + "name": "orderFilledWithAmmJit" + }, + { + "name": "orderFilledWithMatch" + }, + { + "name": "orderFilledWithMatchJit" + }, + { + "name": "marketExpired" + }, + { + "name": "riskingIncreasingOrder" + }, + { + "name": "reduceOnlyOrderIncreasedPosition" + }, + { + "name": "orderFillWithSerum" + }, + { + "name": "noBorrowLiquidity" + }, + { + "name": "orderFillWithPhoenix" + }, + { + "name": "orderFilledWithAmmJitLpSplit" + }, + { + "name": "orderFilledWithLpJit" + }, + { + "name": "deriskLp" + }, + { + "name": "orderFilledWithOpenbookV2" + }, + { + "name": "transferPerpPosition" + } + ] + } + }, + { + "name": "orderActionRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "action", + "type": { + "defined": { + "name": "orderAction" + } + } + }, + { + "name": "actionExplanation", + "type": { + "defined": { + "name": "orderActionExplanation" + } + } + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "marketType", + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "filler", + "type": { + "option": "pubkey" + } + }, + { + "name": "fillerReward", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "fillRecordId", + "type": { + "option": "u64" + } + }, + { + "name": "baseAssetAmountFilled", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "quoteAssetAmountFilled", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "takerFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "i64" + } + }, + { + "name": "referrerReward", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u32" + } + }, + { + "name": "quoteAssetAmountSurplus", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "i64" + } + }, + { + "name": "spotFulfillmentMethodFee", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "taker", + "type": { + "option": "pubkey" + } + }, + { + "name": "takerOrderId", + "type": { + "option": "u32" + } + }, + { + "name": "takerOrderDirection", + "type": { + "option": { + "defined": { + "name": "positionDirection" + } + } + } + }, + { + "name": "takerOrderBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "takerOrderCumulativeBaseAssetAmountFilled", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "takerOrderCumulativeQuoteAssetAmountFilled", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "maker", + "type": { + "option": "pubkey" + } + }, + { + "name": "makerOrderId", + "type": { + "option": "u32" + } + }, + { + "name": "makerOrderDirection", + "type": { + "option": { + "defined": { + "name": "positionDirection" + } + } + } + }, + { + "name": "makerOrderBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerOrderCumulativeBaseAssetAmountFilled", + "docs": [ + "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerOrderCumulativeQuoteAssetAmountFilled", + "docs": [ + "precision: QUOTE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "oraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "bitFlags", + "docs": [ + "Bit flags:", + "0: is_signed_message" + ], + "type": "u8" + }, + { + "name": "takerExistingQuoteEntryAmount", + "docs": [ + "precision: QUOTE_PRECISION", + "Only Some if the taker reduced position" + ], + "type": { + "option": "u64" + } + }, + { + "name": "takerExistingBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION", + "Only Some if the taker flipped position direction" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerExistingQuoteEntryAmount", + "docs": [ + "precision: QUOTE_PRECISION", + "Only Some if the maker reduced position" + ], + "type": { + "option": "u64" + } + }, + { + "name": "makerExistingBaseAssetAmount", + "docs": [ + "precision: BASE_PRECISION", + "Only Some if the maker flipped position direction" + ], + "type": { + "option": "u64" + } + }, + { + "name": "triggerPrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": { + "option": "u64" + } + }, + { + "name": "builderIdx", + "docs": [ + "the idx of the builder in the taker's [`RevenueShareEscrow`] account" + ], + "type": { + "option": "u8" + } + }, + { + "name": "builderFee", + "docs": [ + "precision: QUOTE_PRECISION builder fee paid by the taker" + ], + "type": { + "option": "u64" + } + } + ] + } + }, + { + "name": "orderFillerRewardStructure", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rewardNumerator", + "type": "u32" + }, + { + "name": "rewardDenominator", + "type": "u32" + }, + { + "name": "timeBasedRewardLowerBound", + "type": { + "defined": { + "name": "u128" + } + } + } + ] + } + }, + { + "name": "orderParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "orderType", + "type": { + "defined": { + "name": "orderType" + } + } + }, + { + "name": "marketType", + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "direction", + "type": { + "defined": { + "name": "positionDirection" + } + } + }, + { + "name": "userOrderId", + "type": "u8" + }, + { + "name": "baseAssetAmount", + "type": "u64" + }, + { + "name": "price", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "reduceOnly", + "type": "bool" + }, + { + "name": "postOnly", + "type": { + "defined": { + "name": "postOnlyParam" + } + } + }, + { + "name": "bitFlags", + "type": "u8" + }, + { + "name": "maxTs", + "type": { + "option": "i64" + } + }, + { + "name": "triggerPrice", + "type": { + "option": "u64" + } + }, + { + "name": "triggerCondition", + "type": { + "defined": { + "name": "orderTriggerCondition" + } + } + }, + { + "name": "oraclePriceOffset", + "type": { + "option": "i32" + } + }, + { + "name": "auctionDuration", + "type": { + "option": "u8" + } + }, + { + "name": "auctionStartPrice", + "type": { + "option": "i64" + } + }, + { + "name": "auctionEndPrice", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "orderRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "order", + "type": { + "defined": { + "name": "order" + } + } + } + ] + } + }, + { + "name": "orderStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "init" + }, + { + "name": "open" + }, + { + "name": "filled" + }, + { + "name": "canceled" + } + ] + } + }, + { + "name": "orderTriggerCondition", + "type": { + "kind": "enum", + "variants": [ + { + "name": "above" + }, + { + "name": "below" + }, + { + "name": "triggeredAbove" + }, + { + "name": "triggeredBelow" + } + ] + } + }, + { + "name": "orderType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "market" + }, + { + "name": "limit" + }, + { + "name": "triggerMarket" + }, + { + "name": "triggerLimit" + }, + { + "name": "oracle" + } + ] + } + }, + { + "name": "overrideAmmCacheParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quoteOwedFromLpPool", + "type": { + "option": "i64" + } + }, + { + "name": "lastSettleSlot", + "type": { + "option": "u64" + } + }, + { + "name": "lastFeePoolTokenAmount", + "type": { + "option": "u128" + } + }, + { + "name": "lastNetPnlPoolTokenAmount", + "type": { + "option": "i128" + } + }, + { + "name": "ammPositionScalar", + "type": { + "option": "u8" + } + }, + { + "name": "ammInventoryLimit", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "perpBankruptcyRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "pnl", + "type": "i128" + }, + { + "name": "ifPayment", + "type": "u128" + }, + { + "name": "clawbackUser", + "type": { + "option": "pubkey" + } + }, + { + "name": "clawbackUserPayment", + "type": { + "option": "u128" + } + }, + { + "name": "cumulativeFundingRateDelta", + "type": "i128" + } + ] + } + }, + { + "name": "perpMarket", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "The perp market's address. It is a pda of the market index" + ], + "type": "pubkey" + }, + { + "name": "amm", + "docs": [ + "The automated market maker" + ], + "type": { + "defined": { + "name": "amm" + } + } + }, + { + "name": "pnlPool", + "docs": [ + "The market's pnl pool. When users settle negative pnl, the balance increases.", + "When users settle positive pnl, the balance decreases. Can not go negative." + ], + "type": { + "defined": { + "name": "poolBalance" + } + } + }, + { + "name": "name", + "docs": [ + "Encoded display name for the perp market e.g. SOL-PERP" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "insuranceClaim", + "docs": [ + "The perp market's claim on the insurance fund" + ], + "type": { + "defined": { + "name": "insuranceClaim" + } + } + }, + { + "name": "unrealizedPnlMaxImbalance", + "docs": [ + "The max pnl imbalance before positive pnl asset weight is discounted", + "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", + "the amm has negative pnl and the initial asset weight for positive pnl is discounted", + "precision = QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "expiryTs", + "docs": [ + "The ts when the market will be expired. Only set if market is in reduce only mode" + ], + "type": "i64" + }, + { + "name": "expiryPrice", + "docs": [ + "The price at which positions will be settled. Only set if market is expired", + "precision = PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "nextFillRecordId", + "docs": [ + "Every trade has a fill record id. This is the next id to be used" + ], + "type": "u64" + }, + { + "name": "nextFundingRateRecordId", + "docs": [ + "Every funding rate update has a record id. This is the next id to be used" + ], + "type": "u64" + }, + { + "name": "nextCurveRecordId", + "docs": [ + "Every amm k updated has a record id. This is the next id to be used" + ], + "type": "u64" + }, + { + "name": "imfFactor", + "docs": [ + "The initial margin fraction factor. Used to increase margin ratio for large positions", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "unrealizedPnlImfFactor", + "docs": [ + "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "liquidatorFee", + "docs": [ + "The fee the liquidator is paid for taking over perp position", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "docs": [ + "The fee the insurance fund receives from liquidation", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" + }, + { + "name": "marginRatioInitial", + "docs": [ + "The margin ratio which determines how much collateral is required to open a position", + "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "marginRatioMaintenance", + "docs": [ + "The margin ratio which determines when a user will be liquidated", + "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", + "else they will be liquidated", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "unrealizedPnlInitialAssetWeight", + "docs": [ + "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "unrealizedPnlMaintenanceAssetWeight", + "docs": [ + "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "numberOfUsersWithBase", + "docs": [ + "number of users in a position (base)" + ], + "type": "u32" + }, + { + "name": "numberOfUsers", + "docs": [ + "number of users in a position (pnl) or pnl (quote)" + ], + "type": "u32" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "status", + "docs": [ + "Whether a market is active, reduce only, expired, etc", + "Affects whether users can open/close positions" + ], + "type": { + "defined": { + "name": "marketStatus" + } + } + }, + { + "name": "contractType", + "docs": [ + "Currently only Perpetual markets are supported" + ], + "type": { + "defined": { + "name": "contractType" + } + } + }, + { + "name": "contractTier", + "docs": [ + "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", + "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" + ], + "type": { + "defined": { + "name": "contractTier" + } + } + }, + { + "name": "pausedOperations", + "type": "u8" + }, + { + "name": "quoteSpotMarketIndex", + "docs": [ + "The spot market that pnl is settled in" + ], + "type": "u16" + }, + { + "name": "feeAdjustment", + "docs": [ + "Between -100 and 100, represents what % to increase/decrease the fee by", + "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", + "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" + ], + "type": "i16" + }, + { + "name": "fuelBoostPosition", + "docs": [ + "fuel multiplier for perp funding", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostTaker", + "docs": [ + "fuel multiplier for perp taker", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostMaker", + "docs": [ + "fuel multiplier for perp maker", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "poolId", + "type": "u8" + }, + { + "name": "highLeverageMarginRatioInitial", + "type": "u16" + }, + { + "name": "highLeverageMarginRatioMaintenance", + "type": "u16" + }, + { + "name": "protectedMakerLimitPriceDivisor", + "type": "u8" + }, + { + "name": "protectedMakerDynamicDivisor", + "type": "u8" + }, + { + "name": "lpFeeTransferScalar", + "type": "u8" + }, + { + "name": "lpStatus", + "type": "u8" + }, + { + "name": "lpPausedOperations", + "type": "u8" + }, + { + "name": "lpExchangeFeeExcluscionScalar", + "type": "u8" + }, + { + "name": "lastFillPrice", + "type": "u64" + }, + { + "name": "lpPoolId", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 23 + ] + } + } + ] + } + }, + { + "name": "perpPosition", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "lastCumulativeFundingRate", + "docs": [ + "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", + "precision: FUNDING_RATE_PRECISION" + ], + "type": "i64" + }, + { + "name": "baseAssetAmount", + "docs": [ + "the size of the users perp position", + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "quoteAssetAmount", + "docs": [ + "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees", + "Updated when the user open/closes position or settles pnl. Includes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "quoteBreakEvenAmount", + "docs": [ + "The amount of quote the user would need to exit their position at to break even", + "Updated when the user open/closes position or settles pnl. Includes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "quoteEntryAmount", + "docs": [ + "The amount quote the user entered the position with. Equal to base asset amount * avg entry price", + "Updated when the user open/closes position. Excludes fees/funding", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "openBids", + "docs": [ + "The amount of non reduce only trigger orders the user has open", + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "openAsks", + "docs": [ + "The amount of non reduce only trigger orders the user has open", + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "settledPnl", + "docs": [ + "The amount of pnl settled in this market since opening the position", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lpShares", + "docs": [ + "The number of lp (liquidity provider) shares the user has in this perp market", + "LP shares allow users to provide liquidity via the AMM", + "precision: BASE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastBaseAssetAmountPerLp", + "docs": [ + "The last base asset amount per lp the amm had", + "Used to settle the users lp position", + "precision: BASE_PRECISION" + ], + "type": "i64" + }, + { + "name": "lastQuoteAssetAmountPerLp", + "docs": [ + "The last quote asset amount per lp the amm had", + "Used to settle the users lp position", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 2 + ] + } + }, + { + "name": "maxMarginRatio", + "type": "u16" + }, + { + "name": "marketIndex", + "docs": [ + "The market index for the perp market" + ], + "type": "u16" + }, + { + "name": "openOrders", + "docs": [ + "The number of open orders" + ], + "type": "u8" + }, + { + "name": "perLpBase", + "type": "i8" + } + ] + } + }, + { + "name": "phoenixV1FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" + }, + { + "name": "phoenixProgramId", + "type": "pubkey" + }, + { + "name": "phoenixLogAuthority", + "type": "pubkey" + }, + { + "name": "phoenixMarket", + "type": "pubkey" + }, + { + "name": "phoenixBaseVault", + "type": "pubkey" + }, + { + "name": "phoenixQuoteVault", + "type": "pubkey" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fulfillmentType", + "type": { + "defined": { + "name": "spotFulfillmentType" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "poolBalance", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "scaledBalance", + "docs": [ + "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", + "deposit interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "marketIndex", + "docs": [ + "The spot market the pool is for" + ], + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 6 + ] + } + } + ] + } + }, + { + "name": "positionDirection", + "type": { + "kind": "enum", + "variants": [ + { + "name": "long" + }, + { + "name": "short" + } + ] + } + }, + { + "name": "postOnlyParam", + "type": { + "kind": "enum", + "variants": [ + { + "name": "none" + }, + { + "name": "mustPostOnly" + }, + { + "name": "tryPostOnly" + }, + { + "name": "slide" + } + ] + } + }, + { + "name": "prelaunchOracle", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "i64" + }, + { + "name": "maxPrice", + "type": "i64" + }, + { + "name": "confidence", + "type": "u64" + }, + { + "name": "lastUpdateSlot", + "type": "u64" + }, + { + "name": "ammLastUpdateSlot", + "type": "u64" + }, + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 70 + ] + } + } + ] + } + }, + { + "name": "prelaunchOracleParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "perpMarketIndex", + "type": "u16" + }, + { + "name": "price", + "type": { + "option": "i64" + } + }, + { + "name": "maxPrice", + "type": { + "option": "i64" + } + } + ] + } + }, + { + "name": "priceDivergenceGuardRails", + "type": { + "kind": "struct", + "fields": [ + { + "name": "markOraclePercentDivergence", + "type": "u64" + }, + { + "name": "oracleTwap5minPercentDivergence", + "type": "u64" + } + ] + } + }, + { + "name": "protectedMakerModeConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "maxUsers", + "type": "u32" + }, + { + "name": "currentUsers", + "type": "u32" + }, + { + "name": "reduceOnly", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 31 + ] + } + } + ] + } + }, + { + "name": "pythLazerOracle", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "price", + "type": "i64" + }, + { + "name": "publishTime", + "type": "u64" + }, + { + "name": "postedSlot", + "type": "u64" + }, + { + "name": "exponent", + "type": "i32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "conf", + "type": "u64" + } + ] + } + }, + { + "name": "referrerName", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "userStats", + "type": "pubkey" + }, + { + "name": "name", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "revenueShare", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "rust", + "packed": true + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "the owner of this account, a builder or referrer" + ], + "type": "pubkey" + }, + { + "name": "totalReferrerRewards", + "type": "u64" + }, + { + "name": "totalBuilderRewards", + "type": "u64" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 18 + ] + } + } + ] + } + }, + { + "name": "revenueShareEscrow", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "the owner of this account, a user" + ], + "type": "pubkey" + }, + { + "name": "referrer", + "type": "pubkey" + }, + { + "name": "referrerBoostExpireTs", + "type": "u32" + }, + { + "name": "referrerRewardOffset", + "type": "i8" + }, + { + "name": "refereeFeeNumeratorOffset", + "type": "i8" + }, + { + "name": "referrerBoostNumerator", + "type": "i8" + }, + { + "name": "reservedFixed", + "type": { + "array": [ + "u8", + 17 + ] + } + }, + { + "name": "padding0", + "type": "u32" + }, + { + "name": "orders", + "type": { + "vec": { + "defined": { + "name": "revenueShareOrder" + } + } + } + }, + { + "name": "padding1", + "type": "u32" + }, + { + "name": "approvedBuilders", + "type": { + "vec": { + "defined": { + "name": "builderInfo" + } + } + } + } + ] + } + }, + { + "name": "revenueShareOrder", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "feesAccrued", + "docs": [ + "fees accrued so far for this order slot. This is not exclusively fees from this order_id", + "and may include fees from other orders in the same market. This may be swept to the", + "builder's SpotPosition during settle_pnl." + ], + "type": "u64" + }, + { + "name": "orderId", + "docs": [ + "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open" + ], + "type": "u32" + }, + { + "name": "feeTenthBps", + "docs": [ + "the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%" + ], + "type": "u16" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "subAccountId", + "docs": [ + "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open" + ], + "type": "u16" + }, + { + "name": "builderIdx", + "docs": [ + "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", + "if bit_flag = Referral." + ], + "type": "u8" + }, + { + "name": "bitFlags", + "docs": [ + "bitflags that describe the state of the order.", + "[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.", + "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", + "[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.", + "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", + "[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.", + "If it is set, no other bitflag should be set." + ], + "type": "u8" + }, + { + "name": "userOrderIndex", + "docs": [ + "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches." + ], + "type": "u8" + }, + { + "name": "marketType", + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 10 + ] + } + } + ] + } + }, + { + "name": "revenueShareSettleRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "builder", + "type": { + "option": "pubkey" + } + }, + { + "name": "referrer", + "type": { + "option": "pubkey" + } + }, + { + "name": "feeSettled", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "marketType", + "type": { + "defined": { + "name": "marketType" + } + } + }, + { + "name": "builderSubAccountId", + "type": "u16" + }, + { + "name": "builderTotalReferrerRewards", + "type": "u64" + }, + { + "name": "builderTotalBuilderRewards", + "type": "u64" + } + ] + } + }, + { + "name": "serumV3FulfillmentConfig", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "type": "pubkey" + }, + { + "name": "serumProgramId", + "type": "pubkey" + }, + { + "name": "serumMarket", + "type": "pubkey" + }, + { + "name": "serumRequestQueue", + "type": "pubkey" + }, + { + "name": "serumEventQueue", + "type": "pubkey" + }, + { + "name": "serumBids", + "type": "pubkey" + }, + { + "name": "serumAsks", + "type": "pubkey" + }, + { + "name": "serumBaseVault", + "type": "pubkey" + }, + { + "name": "serumQuoteVault", + "type": "pubkey" + }, + { + "name": "serumOpenOrders", + "type": "pubkey" + }, + { + "name": "serumSignerNonce", + "type": "u64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "fulfillmentType", + "type": { + "defined": { + "name": "spotFulfillmentType" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "spotFulfillmentConfigStatus" + } + } + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "settlePnlExplanation", + "type": { + "kind": "enum", + "variants": [ + { + "name": "none" + }, + { + "name": "expiredPosition" + } + ] + } + }, + { + "name": "settlePnlMode", + "type": { + "kind": "enum", + "variants": [ + { + "name": "mustSettle" + }, + { + "name": "trySettle" + } + ] + } + }, + { + "name": "settlePnlRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "pnl", + "type": "i128" + }, + { + "name": "baseAssetAmount", + "type": "i64" + }, + { + "name": "quoteAssetAmountAfter", + "type": "i64" + }, + { + "name": "quoteEntryAmount", + "type": "i64" + }, + { + "name": "settlePrice", + "type": "i64" + }, + { + "name": "explanation", + "type": { + "defined": { + "name": "settlePnlExplanation" + } + } + } + ] + } + }, + { + "name": "signedMsgOrderId", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "uuid", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "maxSlot", + "type": "u64" + }, + { + "name": "orderId", + "type": "u32" + }, + { + "name": "padding", + "type": "u32" + } + ] + } + }, + { + "name": "signedMsgOrderRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "hash", + "type": "string" + }, + { + "name": "matchingOrderParams", + "type": { + "defined": { + "name": "orderParams" + } + } + }, + { + "name": "userOrderId", + "type": "u32" + }, + { + "name": "signedMsgOrderMaxSlot", + "type": "u64" + }, + { + "name": "signedMsgOrderUuid", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "ts", + "type": "i64" + } + ] + } + }, + { + "name": "signedMsgUserOrders", + "docs": [ + "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" + ], + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authorityPubkey", + "type": "pubkey" + }, + { + "name": "padding", + "type": "u32" + }, + { + "name": "signedMsgOrderData", + "type": { + "vec": { + "defined": { + "name": "signedMsgOrderId" + } + } + } + } + ] + } + }, + { + "name": "signedMsgWsDelegates", + "docs": [ + "* Used to store authenticated delegates for swift-like ws connections" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "delegates", + "type": { + "vec": "pubkey" + } + } + ] + } + }, + { + "name": "spotBalanceType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "deposit" + }, + { + "name": "borrow" + } + ] + } + }, + { + "name": "spotBankruptcyRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "borrowAmount", + "type": "u128" + }, + { + "name": "ifPayment", + "type": "u128" + }, + { + "name": "cumulativeDepositInterestDelta", + "type": "u128" + } + ] + } + }, + { + "name": "spotFulfillmentConfigStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "enabled" + }, + { + "name": "disabled" + } + ] + } + }, + { + "name": "spotFulfillmentType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "serumV3" + }, + { + "name": "match" + }, + { + "name": "phoenixV1" + }, + { + "name": "openbookV2" + } + ] + } + }, + { + "name": "spotInterestRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "depositBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulativeDepositInterest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "borrowBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulativeBorrowInterest", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "optimalUtilization", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + }, + { + "name": "optimalBorrowRate", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + }, + { + "name": "maxBorrowRate", + "docs": [ + "precision: PERCENTAGE_PRECISION" + ], + "type": "u32" + } + ] + } + }, + { + "name": "spotMarket", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "pubkey", + "docs": [ + "The address of the spot market. It is a pda of the market index" + ], + "type": "pubkey" + }, + { + "name": "oracle", + "docs": [ + "The oracle used to price the markets deposits/borrows" + ], + "type": "pubkey" + }, + { + "name": "mint", + "docs": [ + "The token mint of the market" + ], + "type": "pubkey" + }, + { + "name": "vault", + "docs": [ + "The vault used to store the market's deposits", + "The amount in the vault should be equal to or greater than deposits - borrows" + ], + "type": "pubkey" + }, + { + "name": "name", + "docs": [ + "The encoded display name for the market e.g. SOL" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "historicalOracleData", + "type": { + "defined": { + "name": "historicalOracleData" + } + } + }, + { + "name": "historicalIndexData", + "type": { + "defined": { + "name": "historicalIndexData" + } + } + }, + { + "name": "revenuePool", + "docs": [ + "Revenue the protocol has collected in this markets token", + "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" + ], + "type": { + "defined": { + "name": "poolBalance" + } + } + }, + { + "name": "spotFeePool", + "docs": [ + "The fees collected from swaps between this market and the quote market", + "Is settled to the quote markets revenue pool" + ], + "type": { + "defined": { + "name": "poolBalance" + } + } + }, + { + "name": "insuranceFund", + "docs": [ + "Details on the insurance fund covering bankruptcies in this markets token", + "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" + ], + "type": { + "defined": { + "name": "insuranceFund" + } + } + }, + { + "name": "totalSpotFee", + "docs": [ + "The total spot fees collected for this market", + "precision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "depositBalance", + "docs": [ + "The sum of the scaled balances for deposits across users and pool balances", + "To convert to the deposit token amount, multiply by the cumulative deposit interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "borrowBalance", + "docs": [ + "The sum of the scaled balances for borrows across users and pool balances", + "To convert to the borrow token amount, multiply by the cumulative borrow interest", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeDepositInterest", + "docs": [ + "The cumulative interest earned by depositors", + "Used to calculate the deposit token amount from the deposit balance", + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "cumulativeBorrowInterest", + "docs": [ + "The cumulative interest earned by borrowers", + "Used to calculate the borrow token amount from the borrow balance", + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalSocialLoss", + "docs": [ + "The total socialized loss from borrows, in the mint's token", + "precision: token mint precision" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "totalQuoteSocialLoss", + "docs": [ + "The total socialized loss from borrows, in the quote market's token", + "preicision: QUOTE_PRECISION" + ], + "type": { + "defined": { + "name": "u128" + } + } + }, + { + "name": "withdrawGuardThreshold", + "docs": [ + "no withdraw limits/guards when deposits below this threshold", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "maxTokenDeposits", + "docs": [ + "The max amount of token deposits in this market", + "0 if there is no limit", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "depositTokenTwap", + "docs": [ + "24hr average of deposit token amount", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "borrowTokenTwap", + "docs": [ + "24hr average of borrow token amount", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "utilizationTwap", + "docs": [ + "24hr average of utilization", + "which is borrow amount over token amount", + "precision: SPOT_UTILIZATION_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastInterestTs", + "docs": [ + "Last time the cumulative deposit and borrow interest was updated" + ], + "type": "u64" + }, + { + "name": "lastTwapTs", + "docs": [ + "Last time the deposit/borrow/utilization averages were updated" + ], + "type": "u64" + }, + { + "name": "expiryTs", + "docs": [ + "The time the market is set to expire. Only set if market is in reduce only mode" + ], + "type": "i64" + }, + { + "name": "orderStepSize", + "docs": [ + "Spot orders must be a multiple of the step size", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "orderTickSize", + "docs": [ + "Spot orders must be a multiple of the tick size", + "precision: PRICE_PRECISION" + ], + "type": "u64" + }, + { + "name": "minOrderSize", + "docs": [ + "The minimum order size", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "maxPositionSize", + "docs": [ + "The maximum spot position size", + "if the limit is 0, there is no limit", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "nextFillRecordId", + "docs": [ + "Every spot trade has a fill record id. This is the next id to use" + ], + "type": "u64" + }, + { + "name": "nextDepositRecordId", + "docs": [ + "Every deposit has a deposit record id. This is the next id to use" + ], + "type": "u64" + }, + { + "name": "initialAssetWeight", + "docs": [ + "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", + "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "maintenanceAssetWeight", + "docs": [ + "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", + "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "initialLiabilityWeight", + "docs": [ + "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", + "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "maintenanceLiabilityWeight", + "docs": [ + "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", + "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", + "precision: SPOT_WEIGHT_PRECISION" + ], + "type": "u32" + }, + { + "name": "imfFactor", + "docs": [ + "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", + "precision: MARGIN_PRECISION" + ], + "type": "u32" + }, + { + "name": "liquidatorFee", + "docs": [ + "The fee the liquidator is paid for taking over borrow/deposit", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" + }, + { + "name": "ifLiquidationFee", + "docs": [ + "The fee the insurance fund receives from liquidation", + "precision: LIQUIDATOR_FEE_PRECISION" + ], + "type": "u32" + }, + { + "name": "optimalUtilization", + "docs": [ + "The optimal utilization rate for this market.", + "Used to determine the markets borrow rate", + "precision: SPOT_UTILIZATION_PRECISION" + ], + "type": "u32" + }, + { + "name": "optimalBorrowRate", + "docs": [ + "The borrow rate for this market when the market has optimal utilization", + "precision: SPOT_RATE_PRECISION" + ], + "type": "u32" + }, + { + "name": "maxBorrowRate", + "docs": [ + "The borrow rate for this market when the market has 1000 utilization", + "precision: SPOT_RATE_PRECISION" + ], + "type": "u32" + }, + { + "name": "decimals", + "docs": [ + "The market's token mint's decimals. To from decimals to a precision, 10^decimals" + ], + "type": "u32" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "ordersEnabled", + "docs": [ + "Whether or not spot trading is enabled" + ], + "type": "bool" + }, + { + "name": "oracleSource", + "type": { + "defined": { + "name": "oracleSource" + } + } + }, + { + "name": "status", + "type": { + "defined": { + "name": "marketStatus" + } + } + }, + { + "name": "assetTier", + "docs": [ + "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" + ], + "type": { + "defined": { + "name": "assetTier" + } + } + }, + { + "name": "pausedOperations", + "type": "u8" + }, + { + "name": "ifPausedOperations", + "type": "u8" + }, + { + "name": "feeAdjustment", + "type": "i16" + }, + { + "name": "maxTokenBorrowsFraction", + "docs": [ + "What fraction of max_token_deposits", + "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", + "precision: X/10000" + ], + "type": "u16" + }, + { + "name": "flashLoanAmount", + "docs": [ + "For swaps, the amount of token loaned out in the begin_swap ix", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "flashLoanInitialTokenAmount", + "docs": [ + "For swaps, the amount in the users token account in the begin_swap ix", + "Used to calculate how much of the token left the system in end_swap ix", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "totalSwapFee", + "docs": [ + "The total fees received from swaps", + "precision: token mint precision" + ], + "type": "u64" + }, + { + "name": "scaleInitialAssetWeightStart", + "docs": [ + "When to begin scaling down the initial asset weight", + "disabled when 0", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "minBorrowRate", + "docs": [ + "The min borrow rate for this market when the market regardless of utilization", + "1 => 1/200 => .5%", + "precision: X/200" + ], + "type": "u8" + }, + { + "name": "fuelBoostDeposits", + "docs": [ + "fuel multiplier for spot deposits", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostBorrows", + "docs": [ + "fuel multiplier for spot borrows", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostTaker", + "docs": [ + "fuel multiplier for spot taker", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostMaker", + "docs": [ + "fuel multiplier for spot maker", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "fuelBoostInsurance", + "docs": [ + "fuel multiplier for spot insurance stake", + "precision: 10" + ], + "type": "u8" + }, + { + "name": "tokenProgramFlag", + "type": "u8" + }, + { + "name": "poolId", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 40 + ] + } + } + ] + } + }, + { + "name": "spotMarketVaultDepositRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "depositBalance", + "docs": [ + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulativeDepositInterestBefore", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "cumulativeDepositInterestAfter", + "docs": [ + "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" + ], + "type": "u128" + }, + { + "name": "depositTokenAmountBefore", + "type": "u64" + }, + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "spotPosition", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "scaledBalance", + "docs": [ + "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", + "interest of corresponding market.", + "precision: SPOT_BALANCE_PRECISION" + ], + "type": "u64" + }, + { + "name": "openBids", + "docs": [ + "How many spot non reduce only trigger orders the user has open", + "precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "openAsks", + "docs": [ + "How many spot non reduce only trigger orders the user has open", + "precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "cumulativeDeposits", + "docs": [ + "The cumulative deposits/borrows a user has made into a market", + "precision: token mint precision" + ], + "type": "i64" + }, + { + "name": "marketIndex", + "docs": [ + "The market index of the corresponding spot market" + ], + "type": "u16" + }, + { + "name": "balanceType", + "docs": [ + "Whether the position is deposit or borrow" + ], + "type": { + "defined": { + "name": "spotBalanceType" + } + } + }, + { + "name": "openOrders", + "docs": [ + "Number of open orders" + ], + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + } + ] + } + }, + { + "name": "stakeAction", + "type": { + "kind": "enum", + "variants": [ + { + "name": "stake" + }, + { + "name": "unstakeRequest" + }, + { + "name": "unstakeCancelRequest" + }, + { + "name": "unstake" + }, + { + "name": "unstakeTransfer" + }, + { + "name": "stakeTransfer" + }, + { + "name": "adminDeposit" + } + ] + } + }, + { + "name": "state", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "admin", + "type": "pubkey" + }, + { + "name": "whitelistMint", + "type": "pubkey" + }, + { + "name": "discountMint", + "type": "pubkey" + }, + { + "name": "signer", + "type": "pubkey" + }, + { + "name": "srmVault", + "type": "pubkey" + }, + { + "name": "perpFeeStructure", + "type": { + "defined": { + "name": "feeStructure" + } + } + }, + { + "name": "spotFeeStructure", + "type": { + "defined": { + "name": "feeStructure" + } + } + }, + { + "name": "oracleGuardRails", + "type": { + "defined": { + "name": "oracleGuardRails" + } + } + }, + { + "name": "numberOfAuthorities", + "type": "u64" + }, + { + "name": "numberOfSubAccounts", + "type": "u64" + }, + { + "name": "lpCooldownTime", + "type": "u64" + }, + { + "name": "liquidationMarginBufferRatio", + "type": "u32" + }, + { + "name": "settlementDuration", + "type": "u16" + }, + { + "name": "numberOfMarkets", + "type": "u16" + }, + { + "name": "numberOfSpotMarkets", + "type": "u16" + }, + { + "name": "signerNonce", + "type": "u8" + }, + { + "name": "minPerpAuctionDuration", + "type": "u8" + }, + { + "name": "defaultMarketOrderTimeInForce", + "type": "u8" + }, + { + "name": "defaultSpotAuctionDuration", + "type": "u8" + }, + { + "name": "exchangeStatus", + "type": "u8" + }, + { + "name": "liquidationDuration", + "type": "u8" + }, + { + "name": "initialPctToLiquidate", + "type": "u16" + }, + { + "name": "maxNumberOfSubAccounts", + "type": "u16" + }, + { + "name": "maxInitializeUserFee", + "type": "u16" + }, + { + "name": "featureBitFlags", + "type": "u8" + }, + { + "name": "lpPoolFeatureBitFlags", + "type": "u8" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "swapRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "amountOut", + "docs": [ + "precision: out market mint precision" + ], + "type": "u64" + }, + { + "name": "amountIn", + "docs": [ + "precision: in market mint precision" + ], + "type": "u64" + }, + { + "name": "outMarketIndex", + "type": "u16" + }, + { + "name": "inMarketIndex", + "type": "u16" + }, + { + "name": "outOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "inOraclePrice", + "docs": [ + "precision: PRICE_PRECISION" + ], + "type": "i64" + }, + { + "name": "fee", + "type": "u64" + } + ] + } + }, + { + "name": "swapReduceOnly", + "type": { + "kind": "enum", + "variants": [ + { + "name": "in" + }, + { + "name": "out" + } + ] + } + }, + { + "name": "targetsDatum", + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "costToTradeBps", + "type": "i32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "targetBase", + "type": "i64" + }, + { + "name": "lastOracleSlot", + "type": "u64" + }, + { + "name": "lastPositionSlot", + "type": "u64" + } + ] + } + }, + { + "name": "transferProtocolIfSharesToRevenuePoolRecord", + "type": { + "kind": "struct", + "fields": [ + { + "name": "ts", + "type": "i64" + }, + { + "name": "marketIndex", + "type": "u16" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "shares", + "type": "u128" + }, + { + "name": "ifVaultAmountBefore", + "type": "u64" + }, + { + "name": "protocolSharesBefore", + "type": "u128" + }, + { + "name": "transferAmount", + "type": "u64" + } + ] + } + }, + { + "name": "updatePerpMarketSummaryStatsParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quoteAssetAmountWithUnsettledLp", + "type": { + "option": "i64" + } + }, + { + "name": "netUnsettledFundingPnl", + "type": { + "option": "i64" + } + }, + { + "name": "updateAmmSummaryStats", + "type": { + "option": "bool" + } + }, + { + "name": "excludeTotalLiqFee", + "type": { + "option": "bool" + } + } + ] + } + }, + { + "name": "user", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The owner/authority of the account" + ], + "type": "pubkey" + }, + { + "name": "delegate", + "docs": [ + "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw" + ], + "type": "pubkey" + }, + { + "name": "name", + "docs": [ + "Encoded display name e.g. \"toly\"" + ], + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "spotPositions", + "docs": [ + "The user's spot positions" + ], + "type": { + "array": [ + { + "defined": { + "name": "spotPosition" + } + }, + 8 + ] + } + }, + { + "name": "perpPositions", + "docs": [ + "The user's perp positions" + ], + "type": { + "array": [ + { + "defined": { + "name": "perpPosition" + } + }, + 8 + ] + } + }, + { + "name": "orders", + "docs": [ + "The user's orders" + ], + "type": { + "array": [ + { + "defined": { + "name": "order" + } + }, + 32 + ] + } + }, + { + "name": "lastAddPerpLpSharesTs", + "docs": [ + "The last time the user added perp lp positions" + ], + "type": "i64" + }, + { + "name": "totalDeposits", + "docs": [ + "The total values of deposits the user has made", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalWithdraws", + "docs": [ + "The total values of withdrawals the user has made", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalSocialLoss", + "docs": [ + "The total socialized loss the users has incurred upon the protocol", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "settledPerpPnl", + "docs": [ + "Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "cumulativeSpotFees", + "docs": [ + "Fees (taker fees, maker rebate, filler reward) for spot", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "cumulativePerpFunding", + "docs": [ + "Cumulative funding paid/received for perps", + "precision: QUOTE_PRECISION" + ], + "type": "i64" + }, + { + "name": "liquidationMarginFreed", + "docs": [ + "The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time", + "Defaults to zero when not being liquidated", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastActiveSlot", + "docs": [ + "The last slot a user was active. Used to determine if a user is idle" + ], + "type": "u64" + }, + { + "name": "nextOrderId", + "docs": [ + "Every user order has an order id. This is the next order id to be used" + ], + "type": "u32" + }, + { + "name": "maxMarginRatio", + "docs": [ + "Custom max initial margin ratio for the user" + ], + "type": "u32" + }, + { + "name": "nextLiquidationId", + "docs": [ + "The next liquidation id to be used for user" + ], + "type": "u16" + }, + { + "name": "subAccountId", + "docs": [ + "The sub account id for this user" + ], + "type": "u16" + }, + { + "name": "status", + "docs": [ + "Whether the user is active, being liquidated or bankrupt" + ], + "type": "u8" + }, + { + "name": "isMarginTradingEnabled", + "docs": [ + "Whether the user has enabled margin trading" + ], + "type": "bool" + }, + { + "name": "idle", + "docs": [ + "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", + "Off-chain keeper bots can ignore users that are idle" + ], + "type": "bool" + }, + { + "name": "openOrders", + "docs": [ + "number of open orders" + ], + "type": "u8" + }, + { + "name": "hasOpenOrder", + "docs": [ + "Whether or not user has open order" + ], + "type": "bool" + }, + { + "name": "openAuctions", + "docs": [ + "number of open orders with auction" + ], + "type": "u8" + }, + { + "name": "hasOpenAuction", + "docs": [ + "Whether or not user has open order with auction" + ], + "type": "bool" + }, + { + "name": "marginMode", + "type": { + "defined": { + "name": "marginMode" + } + } + }, + { + "name": "poolId", + "type": "u8" + }, + { + "name": "padding1", + "type": { + "array": [ + "u8", + 3 + ] + } + }, + { + "name": "lastFuelBonusUpdateTs", + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 12 + ] + } + } + ] + } + }, + { + "name": "userFees", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "totalFeePaid", + "docs": [ + "Total taker fee paid", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalFeeRebate", + "docs": [ + "Total maker fee rebate", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalTokenDiscount", + "docs": [ + "Total discount from holding token", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalRefereeDiscount", + "docs": [ + "Total discount from being referred", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "totalReferrerReward", + "docs": [ + "Total reward to referrer", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "currentEpochReferrerReward", + "docs": [ + "Total reward to referrer this epoch", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + } + ] + } + }, + { + "name": "userStats", + "serialization": "bytemuckunsafe", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "authority", + "docs": [ + "The authority for all of a users sub accounts" + ], + "type": "pubkey" + }, + { + "name": "referrer", + "docs": [ + "The address that referred this user" + ], + "type": "pubkey" + }, + { + "name": "fees", + "docs": [ + "Stats on the fees paid by the user" + ], + "type": { + "defined": { + "name": "userFees" + } + } + }, + { + "name": "nextEpochTs", + "docs": [ + "The timestamp of the next epoch", + "Epoch is used to limit referrer rewards earned in single epoch" + ], + "type": "i64" + }, + { + "name": "makerVolume30d", + "docs": [ + "Rolling 30day maker volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "takerVolume30d", + "docs": [ + "Rolling 30day taker volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "fillerVolume30d", + "docs": [ + "Rolling 30day filler volume for user", + "precision: QUOTE_PRECISION" + ], + "type": "u64" + }, + { + "name": "lastMakerVolume30dTs", + "docs": [ + "last time the maker volume was updated" + ], + "type": "i64" + }, + { + "name": "lastTakerVolume30dTs", + "docs": [ + "last time the taker volume was updated" + ], + "type": "i64" + }, + { + "name": "lastFillerVolume30dTs", + "docs": [ + "last time the filler volume was updated" + ], + "type": "i64" + }, + { + "name": "ifStakedQuoteAssetAmount", + "docs": [ + "The amount of tokens staked in the quote spot markets if" + ], + "type": "u64" + }, + { + "name": "numberOfSubAccounts", + "docs": [ + "The current number of sub accounts" + ], + "type": "u16" + }, + { + "name": "numberOfSubAccountsCreated", + "docs": [ + "The number of sub accounts created. Can be greater than the number of sub accounts if user", + "has deleted sub accounts" + ], + "type": "u16" + }, + { + "name": "referrerStatus", + "docs": [ + "Flags for referrer status:", + "First bit (LSB): 1 if user is a referrer, 0 otherwise", + "Second bit: 1 if user was referred, 0 otherwise" + ], + "type": "u8" + }, + { + "name": "disableUpdatePerpBidAskTwap", + "type": "u8" + }, + { + "name": "pausedOperations", + "type": "u8" + }, + { + "name": "fuelOverflowStatus", + "docs": [ + "whether the user has a FuelOverflow account" + ], + "type": "u8" + }, + { + "name": "fuelInsurance", + "docs": [ + "accumulated fuel for token amounts of insurance" + ], + "type": "u32" + }, + { + "name": "fuelDeposits", + "docs": [ + "accumulated fuel for notional of deposits" + ], + "type": "u32" + }, + { + "name": "fuelBorrows", + "docs": [ + "accumulate fuel bonus for notional of borrows" + ], + "type": "u32" + }, + { + "name": "fuelPositions", + "docs": [ + "accumulated fuel for perp open interest" + ], + "type": "u32" + }, + { + "name": "fuelTaker", + "docs": [ + "accumulate fuel bonus for taker volume" + ], + "type": "u32" + }, + { + "name": "fuelMaker", + "docs": [ + "accumulate fuel bonus for maker volume" + ], + "type": "u32" + }, + { + "name": "ifStakedGovTokenAmount", + "docs": [ + "The amount of tokens staked in the governance spot markets if" + ], + "type": "u64" + }, + { + "name": "lastFuelIfBonusUpdateTs", + "docs": [ + "last unix ts user stats data was used to update if fuel (u32 to save space)" + ], + "type": "u32" + }, + { + "name": "padding", + "type": { + "array": [ + "u8", + 12 + ] + } + } + ] + } + }, + { + "name": "validityGuardRails", + "type": { + "kind": "struct", + "fields": [ + { + "name": "slotsBeforeStaleForAmm", + "type": "i64" + }, + { + "name": "slotsBeforeStaleForMargin", + "type": "i64" + }, + { + "name": "confidenceIntervalMaxSize", + "type": "u64" + }, + { + "name": "tooVolatileRatio", + "type": "i64" + } + ] + } + }, + { + "name": "i128", + "docs": [ + "`i128` with legacy bit layout" + ], + "type": { + "kind": "struct", + "fields": [ + { + "array": [ + "u8", + 16 + ] + } + ] + } + }, + { + "name": "u128", + "docs": [ + "`u128` with legacy bit layout" + ], + "type": { + "kind": "struct", + "fields": [ + { + "array": [ + "u8", + 16 + ] + } + ] + } + } + ] }; From a6d218e094c224a1da0c3ac497149a7a9debcc79 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Thu, 18 Dec 2025 11:02:15 +0800 Subject: [PATCH 22/25] test passing?? --- bun.lock | 25 +- package.json | 10 +- programs/drift/src/state/events.rs | 16 +- sdk/bun.lock | 58 +- sdk/package.json | 12 +- sdk/src/accounts/bulkAccountLoader.ts | 4 +- sdk/src/accounts/fetch.ts | 8 +- .../grpcDriftClientAccountSubscriberV2.ts | 14 +- .../accounts/grpcMultiAccountSubscriber.ts | 13 +- .../pollingDriftClientAccountSubscriber.ts | 20 +- ...HighLeverageModeConfigAccountSubscriber.ts | 2 +- ...lingInsuranceFundStakeAccountSubscriber.ts | 18 +- .../accounts/pollingUserAccountSubscriber.ts | 4 +- .../pollingUserStatsAccountSubscriber.ts | 2 +- .../accounts/webSocketAccountSubscriber.ts | 4 +- .../accounts/webSocketAccountSubscriberV2.ts | 3 +- .../webSocketDriftClientAccountSubscriber.ts | 15 +- ...webSocketDriftClientAccountSubscriberV2.ts | 24 +- sdk/src/config.ts | 11 +- sdk/src/driftClient.ts | 14 +- sdk/src/idl/drift.json | 210 + sdk/src/idl/drift.ts | 47181 +++++++--------- sdk/src/orderSubscriber/OrderSubscriber.ts | 2 +- sdk/src/types.ts | 159 +- sdk/src/user.ts | 5 +- sdk/src/userMap/revenueShareEscrowMap.ts | 8 +- sdk/src/userMap/userMap.ts | 3 +- sdk/tests/amm/test.ts | 4 +- sdk/tests/decode/test.ts | 6 +- sdk/tests/dlob/helpers.ts | 7 +- sdk/yarn.lock | 286 +- tests/builderCodes.ts | 41 +- tests/testHelpers.ts | 30 +- yarn.lock | 122 +- 34 files changed, 22236 insertions(+), 26105 deletions(-) diff --git a/bun.lock b/bun.lock index a2652fec3a..0182f7376d 100644 --- a/bun.lock +++ b/bun.lock @@ -7,14 +7,15 @@ "@pythnetwork/pyth-solana-receiver": "0.8.0", "@switchboard-xyz/common": "5.5.0", "@switchboard-xyz/on-demand": "3.7.3", - "anchor-bankrun": "0.3.0", + "@types/bs58": "^5.0.0", + "anchor-bankrun": "0.5.0", "chai-bn": "0.2.2", "csvtojson": "2.0.10", "dotenv": "16.4.5", "json2csv": "5.0.7", "nanoid": "3.3.4", "rpc-websockets": "7.5.1", - "solana-bankrun": "0.3.0", + "solana-bankrun": "0.4.0", "zod": "4.0.17", "zstddec": "0.1.0", }, @@ -185,6 +186,8 @@ "@types/bn.js": ["@types/bn.js@5.1.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-Xh8vSwUeMKeYYrj3cX4lGQgFSF/N03r+tv4AiLl1SucqV+uTQpxRcnM8AkXKHwYP9ZPXOYXRr2KPXpVlIvqh9w=="], + "@types/bs58": ["@types/bs58@5.0.0", "", { "dependencies": { "bs58": "*" } }, "sha512-cAw/jKBzo98m6Xz1X5ETqymWfIMbXbu6nK15W4LQYjeHJkVqSmM5PO8Bd9KVHQJ/F4rHcSso9LcjtgCW6TGu2w=="], + "@types/chai": ["@types/chai@5.0.0", "", {}, "sha512-+DwhEHAaFPPdJ2ral3kNHFQXnTfscEEFsUxzD+d7nlcLrFK23JtNjH71RGasTcHb88b4vVi4mTyfpf8u2L8bdA=="], "@types/connect": ["@types/connect@3.4.38", "", { "dependencies": { "@types/node": "*" } }, "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug=="], @@ -229,7 +232,7 @@ "ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="], - "anchor-bankrun": ["anchor-bankrun@0.3.0", "", { "peerDependencies": { "@coral-xyz/anchor": "^0.28.0", "@solana/web3.js": "^1.78.4", "solana-bankrun": "^0.2.0" } }, "sha512-PYBW5fWX+iGicIS5MIM/omhk1tQPUc0ELAnI/IkLKQJ6d75De/CQRh8MF2bU/TgGyFi6zEel80wUe3uRol9RrQ=="], + "anchor-bankrun": ["anchor-bankrun@0.5.0", "", { "peerDependencies": { "@coral-xyz/anchor": "^0.30.0", "@solana/web3.js": ">1.92.0", "solana-bankrun": ">=0.2.0 <0.5.0" } }, "sha512-cNTRv7pN9dy+kiyJ3UlNVTg9hAXhY2HtNVNXJbP/2BkS9nOdLV0qKWhgW8UR9Go0gYuEOLKuPzrGL4HFAZPsVw=="], "ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="], @@ -663,17 +666,17 @@ "snake-case": ["snake-case@3.0.4", "", { "dependencies": { "dot-case": "^3.0.4", "tslib": "^2.0.3" } }, "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg=="], - "solana-bankrun": ["solana-bankrun@0.3.0", "", { "dependencies": { "@solana/web3.js": "^1.68.0", "bs58": "^4.0.1" }, "optionalDependencies": { "solana-bankrun-darwin-arm64": "0.3.0", "solana-bankrun-darwin-universal": "0.3.0", "solana-bankrun-darwin-x64": "0.3.0", "solana-bankrun-linux-x64-gnu": "0.3.0", "solana-bankrun-linux-x64-musl": "0.3.0" } }, "sha512-YkH7sa8TB/AoRPzG17CXJtYsRIQHEkEqGLz1Vwc13taXhDBkjO7z6NI5JYw7n0ybRymDHwMYTc7sd+5J40TyVQ=="], + "solana-bankrun": ["solana-bankrun@0.4.0", "", { "dependencies": { "@solana/web3.js": "^1.68.0", "bs58": "^4.0.1" }, "optionalDependencies": { "solana-bankrun-darwin-arm64": "0.4.0", "solana-bankrun-darwin-universal": "0.4.0", "solana-bankrun-darwin-x64": "0.4.0", "solana-bankrun-linux-x64-gnu": "0.4.0", "solana-bankrun-linux-x64-musl": "0.4.0" } }, "sha512-NMmXUipPBkt8NgnyNO3SCnPERP6xT/AMNMBooljGA3+rG6NN8lmXJsKeLqQTiFsDeWD74U++QM/DgcueSWvrIg=="], - "solana-bankrun-darwin-arm64": ["solana-bankrun-darwin-arm64@0.3.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-+NbDncf0U6l3knuacRBiqpjZ2DSp+5lZaAU518gH7/x6qubbui/d000STaIBK+uNTPBS/AL/bCN+7PkXqmA3lA=="], + "solana-bankrun-darwin-arm64": ["solana-bankrun-darwin-arm64@0.4.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-6dz78Teoz7ez/3lpRLDjktYLJb79FcmJk2me4/YaB8WiO6W43OdExU4h+d2FyuAryO2DgBPXaBoBNY/8J1HJmw=="], - "solana-bankrun-darwin-universal": ["solana-bankrun-darwin-universal@0.3.0", "", { "os": "darwin" }, "sha512-1/F0xdMa4qvc5o6z16FCCbZ5jbdvKvxpx5kyPcMWRiRPwyvi+zltMxciPAYMlg3wslQqGz88uFhrBEzq2eTumQ=="], + "solana-bankrun-darwin-universal": ["solana-bankrun-darwin-universal@0.4.0", "", { "os": "darwin" }, "sha512-zSSw/Jx3KNU42pPMmrEWABd0nOwGJfsj7nm9chVZ3ae7WQg3Uty0hHAkn5NSDCj3OOiN0py9Dr1l9vmRJpOOxg=="], - "solana-bankrun-darwin-x64": ["solana-bankrun-darwin-x64@0.3.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-U6CANjkmMl+lgNA7UH0GKs5V7LtVIUDzJBZefGGqLfqUNv3EjA/PrrToM0hAOWJgkxSwdz6zW+p5sw5FmnbXtg=="], + "solana-bankrun-darwin-x64": ["solana-bankrun-darwin-x64@0.4.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-LWjs5fsgHFtyr7YdJR6r0Ho5zrtzI6CY4wvwPXr8H2m3b4pZe6RLIZjQtabCav4cguc14G0K8yQB2PTMuGub8w=="], - "solana-bankrun-linux-x64-gnu": ["solana-bankrun-linux-x64-gnu@0.3.0", "", { "os": "linux", "cpu": "x64" }, "sha512-qJSkCFs0k2n4XtTnyxGMiZsuqO2TiqTYgWjQ+3mZhGNUAMys/Vq8bd7/SyBm6RR7EfVuRXRxZvh+F8oKZ77V4w=="], + "solana-bankrun-linux-x64-gnu": ["solana-bankrun-linux-x64-gnu@0.4.0", "", { "os": "linux", "cpu": "x64" }, "sha512-SrlVrb82UIxt21Zr/XZFHVV/h9zd2/nP25PMpLJVLD7Pgl2yhkhfi82xj3OjxoQqWe+zkBJ+uszA0EEKr67yNw=="], - "solana-bankrun-linux-x64-musl": ["solana-bankrun-linux-x64-musl@0.3.0", "", { "os": "linux", "cpu": "x64" }, "sha512-xsS2CS2xb1Sw4ivNXM0gPz/qpW9BX0neSvt/pnok5L330Nu9xlTnKAY8FhzzqOP9P9sJlGRM787Y6d0yYwt6xQ=="], + "solana-bankrun-linux-x64-musl": ["solana-bankrun-linux-x64-musl@0.4.0", "", { "os": "linux", "cpu": "x64" }, "sha512-Nv328ZanmURdYfcLL+jwB1oMzX4ZzK57NwIcuJjGlf0XSNLq96EoaO5buEiUTo4Ls7MqqMyLbClHcrPE7/aKyA=="], "spok": ["spok@1.5.5", "", { "dependencies": { "ansicolors": "~0.3.2", "find-process": "^1.4.7" } }, "sha512-IrJIXY54sCNFASyHPOY+jEirkiJ26JDqsGiI0Dvhwcnkl0PEWi1PSsrkYql0rzDw8LFVTcA7rdUCAJdE2HE+2Q=="], @@ -859,6 +862,8 @@ "@switchboard-xyz/on-demand/isomorphic-ws": ["isomorphic-ws@5.0.0", "", { "peerDependencies": { "ws": "*" } }, "sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw=="], + "@types/bs58/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="], + "@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.3", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg=="], "fast-glob/glob-parent": ["glob-parent@5.1.2", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="], @@ -989,6 +994,8 @@ "@switchboard-xyz/on-demand/bs58/base-x": ["base-x@5.0.1", "", {}, "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg=="], + "@types/bs58/bs58/base-x": ["base-x@5.0.1", "", {}, "sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg=="], + "@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.2", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ=="], "jayson/@types/ws/@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="], diff --git a/package.json b/package.json index 146e55ada6..30eb1ddf94 100644 --- a/package.json +++ b/package.json @@ -32,14 +32,15 @@ "@pythnetwork/pyth-solana-receiver": "0.8.0", "@switchboard-xyz/common": "5.5.0", "@switchboard-xyz/on-demand": "3.7.3", - "anchor-bankrun": "0.3.0", + "@types/bs58": "^5.0.0", + "anchor-bankrun": "0.5.0", "chai-bn": "0.2.2", "csvtojson": "2.0.10", "dotenv": "16.4.5", "json2csv": "5.0.7", "nanoid": "3.3.4", "rpc-websockets": "7.5.1", - "solana-bankrun": "0.3.0", + "solana-bankrun": "0.4.0", "zod": "4.0.17", "zstddec": "0.1.0" }, @@ -73,7 +74,10 @@ "backslash": "<0.2.1", "chalk-template": "<1.1.1", "supports-hyperlinks": "<4.1.1", - "has-ansi": "<6.0.1" + "has-ansi": "<6.0.1", + "@coral-xyz/anchor/@solana/web3.js": "1.98.0", + "base-x": "^3.0.11", + "bs58": "^4.0.1" }, "overrides": { "chalk": "4.1.2", diff --git a/programs/drift/src/state/events.rs b/programs/drift/src/state/events.rs index 1a52e7013a..ceb589461e 100644 --- a/programs/drift/src/state/events.rs +++ b/programs/drift/src/state/events.rs @@ -4,7 +4,9 @@ use crate::controller::position::PositionDirection; use crate::error::{DriftResult, ErrorCode::InvalidOrder}; use crate::math::casting::Cast; use crate::math::safe_unwrap::SafeUnwrap; -use crate::state::order_params::OrderParams; +use crate::state::order_params::{ + OrderParams, SignedMsgOrderParamsDelegateMessage, SignedMsgOrderParamsMessage, +}; use crate::state::traits::Size; use crate::state::user::{MarketType, Order}; use anchor_lang::Discriminator; @@ -900,3 +902,15 @@ pub struct LPBorrowLendDepositRecord { impl Size for LPBorrowLendDepositRecord { const SIZE: usize = 104; } + +/// unusued placeholder event to force include signed msg types into drift IDL +#[event] +#[derive(Default)] +struct _SignedMsgOrderParamsExport { + _a: SignedMsgOrderParamsMessage, + _b: SignedMsgOrderParamsDelegateMessage, +} + +impl Size for _SignedMsgOrderParamsExport { + const SIZE: usize = 0; +} diff --git a/sdk/bun.lock b/sdk/bun.lock index 1c160496ec..d39c81e539 100644 --- a/sdk/bun.lock +++ b/sdk/bun.lock @@ -19,13 +19,13 @@ "@switchboard-xyz/common": "5.5.0", "@switchboard-xyz/on-demand": "3.7.3", "@triton-one/yellowstone-grpc": "1.4.1", - "anchor-bankrun": "0.3.0", + "anchor-bankrun": "0.5.0", "gill": "^0.10.3", "helius-laserstream": "0.1.8", "nanoid": "3.3.4", "node-cache": "5.1.2", "rpc-websockets": "7.5.1", - "solana-bankrun": "0.3.1", + "solana-bankrun": "0.4.0", "strict-event-emitter-types": "2.0.0", "tweetnacl": "1.0.3", "tweetnacl-util": "0.15.1", @@ -60,6 +60,7 @@ }, }, "overrides": { + "bs58": "^4.0.1", "debug": "<4.4.2", "supports-color": "7.2.0", "ansi-regex": "5.0.1", @@ -68,6 +69,7 @@ "wrap-ansi": "7.0.0", "chalk": "4.1.2", "strip-ansi": "6.0.1", + "base-x": "^3.0.11", "color-name": "<2.0.1", }, "packages": { @@ -399,7 +401,7 @@ "ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="], - "anchor-bankrun": ["anchor-bankrun@0.3.0", "", { "peerDependencies": { "@coral-xyz/anchor": "^0.28.0", "@solana/web3.js": "^1.78.4", "solana-bankrun": "^0.2.0" } }, "sha512-PYBW5fWX+iGicIS5MIM/omhk1tQPUc0ELAnI/IkLKQJ6d75De/CQRh8MF2bU/TgGyFi6zEel80wUe3uRol9RrQ=="], + "anchor-bankrun": ["anchor-bankrun@0.5.0", "", { "peerDependencies": { "@coral-xyz/anchor": "^0.30.0", "@solana/web3.js": ">1.92.0", "solana-bankrun": ">=0.2.0 <0.5.0" } }, "sha512-cNTRv7pN9dy+kiyJ3UlNVTg9hAXhY2HtNVNXJbP/2BkS9nOdLV0qKWhgW8UR9Go0gYuEOLKuPzrGL4HFAZPsVw=="], "ansi-colors": ["ansi-colors@4.1.3", "", {}, "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw=="], @@ -435,7 +437,7 @@ "balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="], - "base-x": ["base-x@3.0.10", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ=="], + "base-x": ["base-x@3.0.11", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA=="], "base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="], @@ -1037,17 +1039,17 @@ "snake-case": ["snake-case@3.0.4", "", { "dependencies": { "dot-case": "^3.0.4", "tslib": "^2.0.3" } }, "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg=="], - "solana-bankrun": ["solana-bankrun@0.3.1", "", { "dependencies": { "@solana/web3.js": "^1.68.0", "bs58": "^4.0.1" }, "optionalDependencies": { "solana-bankrun-darwin-arm64": "0.3.1", "solana-bankrun-darwin-universal": "0.3.1", "solana-bankrun-darwin-x64": "0.3.1", "solana-bankrun-linux-x64-gnu": "0.3.1", "solana-bankrun-linux-x64-musl": "0.3.1" } }, "sha512-inRwON7fBU5lPC36HdEqPeDg15FXJYcf77+o0iz9amvkUMJepcwnRwEfTNyMVpVYdgjTOBW5vg+596/3fi1kGA=="], + "solana-bankrun": ["solana-bankrun@0.4.0", "", { "dependencies": { "@solana/web3.js": "^1.68.0", "bs58": "^4.0.1" }, "optionalDependencies": { "solana-bankrun-darwin-arm64": "0.4.0", "solana-bankrun-darwin-universal": "0.4.0", "solana-bankrun-darwin-x64": "0.4.0", "solana-bankrun-linux-x64-gnu": "0.4.0", "solana-bankrun-linux-x64-musl": "0.4.0" } }, "sha512-NMmXUipPBkt8NgnyNO3SCnPERP6xT/AMNMBooljGA3+rG6NN8lmXJsKeLqQTiFsDeWD74U++QM/DgcueSWvrIg=="], - "solana-bankrun-darwin-arm64": ["solana-bankrun-darwin-arm64@0.3.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-9LWtH/3/WR9fs8Ve/srdo41mpSqVHmRqDoo69Dv1Cupi+o1zMU6HiEPUHEvH2Tn/6TDbPEDf18MYNfReLUqE6A=="], + "solana-bankrun-darwin-arm64": ["solana-bankrun-darwin-arm64@0.4.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-6dz78Teoz7ez/3lpRLDjktYLJb79FcmJk2me4/YaB8WiO6W43OdExU4h+d2FyuAryO2DgBPXaBoBNY/8J1HJmw=="], - "solana-bankrun-darwin-universal": ["solana-bankrun-darwin-universal@0.3.1", "", { "os": "darwin" }, "sha512-muGHpVYWT7xCd8ZxEjs/bmsbMp8XBqroYGbE4lQPMDUuLvsJEIrjGqs3MbxEFr71sa58VpyvgywWd5ifI7sGIg=="], + "solana-bankrun-darwin-universal": ["solana-bankrun-darwin-universal@0.4.0", "", { "os": "darwin" }, "sha512-zSSw/Jx3KNU42pPMmrEWABd0nOwGJfsj7nm9chVZ3ae7WQg3Uty0hHAkn5NSDCj3OOiN0py9Dr1l9vmRJpOOxg=="], - "solana-bankrun-darwin-x64": ["solana-bankrun-darwin-x64@0.3.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-oCaxfHyt7RC3ZMldrh5AbKfy4EH3YRMl8h6fSlMZpxvjQx7nK7PxlRwMeflMnVdkKKp7U8WIDak1lilIPd3/lg=="], + "solana-bankrun-darwin-x64": ["solana-bankrun-darwin-x64@0.4.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-LWjs5fsgHFtyr7YdJR6r0Ho5zrtzI6CY4wvwPXr8H2m3b4pZe6RLIZjQtabCav4cguc14G0K8yQB2PTMuGub8w=="], - "solana-bankrun-linux-x64-gnu": ["solana-bankrun-linux-x64-gnu@0.3.1", "", { "os": "linux", "cpu": "x64" }, "sha512-PfRFhr7igGFNt2Ecfdzh3li9eFPB3Xhmk0Eib17EFIB62YgNUg3ItRnQQFaf0spazFjjJLnglY1TRKTuYlgSVA=="], + "solana-bankrun-linux-x64-gnu": ["solana-bankrun-linux-x64-gnu@0.4.0", "", { "os": "linux", "cpu": "x64" }, "sha512-SrlVrb82UIxt21Zr/XZFHVV/h9zd2/nP25PMpLJVLD7Pgl2yhkhfi82xj3OjxoQqWe+zkBJ+uszA0EEKr67yNw=="], - "solana-bankrun-linux-x64-musl": ["solana-bankrun-linux-x64-musl@0.3.1", "", { "os": "linux", "cpu": "x64" }, "sha512-6r8i0NuXg3CGURql8ISMIUqhE7Hx/O7MlIworK4oN08jYrP0CXdLeB/hywNn7Z8d1NXrox/NpYUgvRm2yIzAsQ=="], + "solana-bankrun-linux-x64-musl": ["solana-bankrun-linux-x64-musl@0.4.0", "", { "os": "linux", "cpu": "x64" }, "sha512-Nv328ZanmURdYfcLL+jwB1oMzX4ZzK57NwIcuJjGlf0XSNLq96EoaO5buEiUTo4Ls7MqqMyLbClHcrPE7/aKyA=="], "source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="], @@ -1179,10 +1181,6 @@ "@ellipsis-labs/phoenix-sdk/@types/node": ["@types/node@18.19.78", "", { "dependencies": { "undici-types": "~5.26.4" } }, "sha512-m1ilZCTwKLkk9rruBJXFeYN0Bc5SbjirwYX/Td3MqPfioYbgun3IvK/m8dQxMCnrPGZPg1kvXjp3SIekCN/ynw=="], - "@ellipsis-labs/phoenix-sdk/bs58": ["bs58@5.0.0", "", { "dependencies": { "base-x": "^4.0.0" } }, "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ=="], - - "@metaplex-foundation/beet-solana/bs58": ["bs58@5.0.0", "", { "dependencies": { "base-x": "^4.0.0" } }, "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ=="], - "@metaplex-foundation/solita/@metaplex-foundation/beet": ["@metaplex-foundation/beet@0.4.0", "", { "dependencies": { "ansicolors": "^0.3.2", "bn.js": "^5.2.0", "debug": "^4.3.3" } }, "sha512-2OAKJnLatCc3mBXNL0QmWVQKAWK2C7XDfepgL0p/9+8oSx4bmRAFHFqptl1A/C0U5O3dxGwKfmKluW161OVGcA=="], "@metaplex-foundation/solita/js-sha256": ["js-sha256@0.9.0", "", {}, "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA=="], @@ -1203,8 +1201,6 @@ "@pythnetwork/solana-utils/@coral-xyz/anchor": ["@coral-xyz/anchor@0.29.0", "", { "dependencies": { "@coral-xyz/borsh": "^0.29.0", "@noble/hashes": "^1.3.1", "@solana/web3.js": "^1.68.0", "bn.js": "^5.1.2", "bs58": "^4.0.1", "buffer-layout": "^1.2.2", "camelcase": "^6.3.0", "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "pako": "^2.0.3", "snake-case": "^3.0.4", "superstruct": "^0.15.4", "toml": "^3.0.0" } }, "sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA=="], - "@pythnetwork/solana-utils/bs58": ["bs58@5.0.0", "", { "dependencies": { "base-x": "^4.0.0" } }, "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ=="], - "@sinonjs/commons/type-detect": ["type-detect@4.0.8", "", {}, "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g=="], "@solana/errors/commander": ["commander@14.0.0", "", {}, "sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA=="], @@ -1221,14 +1217,10 @@ "@switchboard-xyz/common/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], - "@switchboard-xyz/common/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="], - "@switchboard-xyz/on-demand/@solana/spl-token": ["@solana/spl-token@0.4.14", "", { "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", "@solana/spl-token-group": "^0.0.7", "@solana/spl-token-metadata": "^0.1.6", "buffer": "^6.0.3" }, "peerDependencies": { "@solana/web3.js": "^1.95.5" } }, "sha512-u09zr96UBpX4U685MnvQsNzlvw9TiY005hk1vJmJr7gMJldoPG1eYU5/wNEyOA5lkMLiR/gOi9SFD4MefOYEsA=="], "@switchboard-xyz/on-demand/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], - "@switchboard-xyz/on-demand/bs58": ["bs58@6.0.0", "", { "dependencies": { "base-x": "^5.0.0" } }, "sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw=="], - "@typescript-eslint/project-service/@typescript-eslint/types": ["@typescript-eslint/types@8.38.0", "", {}, "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw=="], "@typescript-eslint/typescript-estree/minimatch": ["minimatch@9.0.3", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg=="], @@ -1293,6 +1285,8 @@ "sass-lookup/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], + "solana-bankrun/@solana/web3.js": ["@solana/web3.js@1.98.4", "", { "dependencies": { "@babel/runtime": "^7.25.0", "@noble/curves": "^1.4.2", "@noble/hashes": "^1.4.0", "@solana/buffer-layout": "^4.0.1", "@solana/codecs-numbers": "^2.1.0", "agentkeepalive": "^4.5.0", "bn.js": "^5.2.1", "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.3", "fast-stable-stringify": "^1.0.0", "jayson": "^4.1.1", "node-fetch": "^2.7.0", "rpc-websockets": "^9.0.2", "superstruct": "^2.0.2" } }, "sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw=="], + "stack-utils/escape-string-regexp": ["escape-string-regexp@2.0.0", "", {}, "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w=="], "stylus-lookup/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], @@ -1303,20 +1297,12 @@ "@ellipsis-labs/phoenix-sdk/@types/node/undici-types": ["undici-types@5.26.5", "", {}, "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="], - "@ellipsis-labs/phoenix-sdk/bs58/base-x": ["base-x@4.0.0", "", {}, "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw=="], - - "@metaplex-foundation/beet-solana/bs58/base-x": ["base-x@4.0.0", "", {}, "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw=="], - "@openbook-dex/openbook-v2/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], "@pythnetwork/pyth-solana-receiver/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], "@pythnetwork/solana-utils/@coral-xyz/anchor/@coral-xyz/borsh": ["@coral-xyz/borsh@0.29.0", "", { "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" }, "peerDependencies": { "@solana/web3.js": "^1.68.0" } }, "sha512-s7VFVa3a0oqpkuRloWVPdCK7hMbAMY270geZOGfCnaqexrP5dTIpbEHL33req6IYPPJ0hYa71cdvJ1h6V55/oQ=="], - "@pythnetwork/solana-utils/@coral-xyz/anchor/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], - - "@pythnetwork/solana-utils/bs58/base-x": ["base-x@4.0.0", "", {}, "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw=="], - "@solana/spl-token-group/@solana/codecs/@solana/codecs-core": ["@solana/codecs-core@2.0.0-rc.1", "", { "dependencies": { "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ=="], "@solana/spl-token-group/@solana/codecs/@solana/codecs-data-structures": ["@solana/codecs-data-structures@2.0.0-rc.1", "", { "dependencies": { "@solana/codecs-core": "2.0.0-rc.1", "@solana/codecs-numbers": "2.0.0-rc.1", "@solana/errors": "2.0.0-rc.1" }, "peerDependencies": { "typescript": ">=5" } }, "sha512-rinCv0RrAVJ9rE/rmaibWJQxMwC5lSaORSZuwjopSUE6T0nb/MVg6Z1siNCXhh/HFTOg0l8bNvZHgBcN/yvXog=="], @@ -1341,22 +1327,14 @@ "@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], - "@switchboard-xyz/common/@solana/web3.js/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], - "@switchboard-xyz/common/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.1", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-1IXGM/TfPT6nfYMIXkJdzn+L4JEsmb0FL1O2OBjaH03V3yuUDdKFulGLMFG6ErV+8pZ5HVC0limve01RyO+saA=="], "@switchboard-xyz/common/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], - "@switchboard-xyz/common/bs58/base-x": ["base-x@5.0.0", "", {}, "sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ=="], - - "@switchboard-xyz/on-demand/@solana/web3.js/bs58": ["bs58@4.0.1", "", { "dependencies": { "base-x": "^3.0.2" } }, "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw=="], - "@switchboard-xyz/on-demand/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.1", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-1IXGM/TfPT6nfYMIXkJdzn+L4JEsmb0FL1O2OBjaH03V3yuUDdKFulGLMFG6ErV+8pZ5HVC0limve01RyO+saA=="], "@switchboard-xyz/on-demand/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], - "@switchboard-xyz/on-demand/bs58/base-x": ["base-x@5.0.0", "", {}, "sha512-sMW3VGSX1QWVFA6l8U62MLKz29rRfpTlYdCqLdpLo1/Yd4zZwSbnUaDfciIAowAqvq7YFnWq9hrhdg1KYgc1lQ=="], - "@typescript-eslint/typescript-estree/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="], "detective-typescript/@typescript-eslint/typescript-estree/@typescript-eslint/types": ["@typescript-eslint/types@8.38.0", "", {}, "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw=="], @@ -1377,6 +1355,10 @@ "mocha/yargs/cliui": ["cliui@7.0.4", "", { "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", "wrap-ansi": "^7.0.0" } }, "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ=="], + "solana-bankrun/@solana/web3.js/rpc-websockets": ["rpc-websockets@9.1.1", "", { "dependencies": { "@swc/helpers": "^0.5.11", "@types/uuid": "^8.3.4", "@types/ws": "^8.2.2", "buffer": "^6.0.3", "eventemitter3": "^5.0.1", "uuid": "^8.3.2", "ws": "^8.5.0" }, "optionalDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" } }, "sha512-1IXGM/TfPT6nfYMIXkJdzn+L4JEsmb0FL1O2OBjaH03V3yuUDdKFulGLMFG6ErV+8pZ5HVC0limve01RyO+saA=="], + + "solana-bankrun/@solana/web3.js/superstruct": ["superstruct@2.0.2", "", {}, "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A=="], + "@solana/spl-token-group/@solana/codecs/@solana/codecs-core/@solana/errors": ["@solana/errors@2.0.0-rc.1", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ=="], "@solana/spl-token-group/@solana/codecs/@solana/codecs-data-structures/@solana/errors": ["@solana/errors@2.0.0-rc.1", "", { "dependencies": { "chalk": "^5.3.0", "commander": "^12.1.0" }, "peerDependencies": { "typescript": ">=5" }, "bin": { "errors": "bin/cli.mjs" } }, "sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ=="], @@ -1411,6 +1393,10 @@ "jito-ts/@grpc/grpc-js/@grpc/proto-loader/protobufjs": ["protobufjs@7.4.0", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.4", "@protobufjs/eventemitter": "^1.1.0", "@protobufjs/fetch": "^1.1.0", "@protobufjs/float": "^1.0.2", "@protobufjs/inquire": "^1.1.0", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.0", "@types/node": ">=13.7.0", "long": "^5.0.0" } }, "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw=="], + "solana-bankrun/@solana/web3.js/rpc-websockets/@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="], + + "solana-bankrun/@solana/web3.js/rpc-websockets/eventemitter3": ["eventemitter3@5.0.1", "", {}, "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="], + "@solana/spl-token-group/@solana/codecs/@solana/codecs-core/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], "@solana/spl-token-group/@solana/codecs/@solana/codecs-data-structures/@solana/errors/commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="], diff --git a/sdk/package.json b/sdk/package.json index f4113fa955..adef23c1fd 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -56,13 +56,13 @@ "@switchboard-xyz/common": "5.5.0", "@switchboard-xyz/on-demand": "3.7.3", "@triton-one/yellowstone-grpc": "1.4.1", - "anchor-bankrun": "0.3.0", + "anchor-bankrun": "0.5.0", "gill": "^0.10.3", "helius-laserstream": "0.1.8", "nanoid": "3.3.4", "node-cache": "5.1.2", "rpc-websockets": "7.5.1", - "solana-bankrun": "0.3.1", + "solana-bankrun": "0.4.0", "strict-event-emitter-types": "2.0.0", "tweetnacl": "1.0.3", "tweetnacl-util": "0.15.1", @@ -119,7 +119,9 @@ "backslash": "<0.2.1", "chalk-template": "<0.4.0", "supports-hyperlinks": "<4.1.1", - "has-ansi": "<6.0.1" + "has-ansi": "<6.0.1", + "base-x": "^3.0.11", + "bs58": "^4.0.1" }, "overrides": { "chalk": "4.1.2", @@ -139,7 +141,9 @@ "backslash": "<0.2.1", "chalk-template": "<1.1.1", "supports-hyperlinks": "<4.1.1", - "has-ansi": "<6.0.1" + "has-ansi": "<6.0.1", + "base-x": "^3.0.11", + "bs58": "^4.0.1" }, "browser": { "helius-laserstream": false, diff --git a/sdk/src/accounts/bulkAccountLoader.ts b/sdk/src/accounts/bulkAccountLoader.ts index c76d91b1cd..74cc6a799d 100644 --- a/sdk/src/accounts/bulkAccountLoader.ts +++ b/sdk/src/accounts/bulkAccountLoader.ts @@ -242,10 +242,10 @@ export class BulkAccountLoader { callback(buffer, slot); } catch (e) { console.log('Bulk account load: error in account callback'); - console.log('accounto to load', accountToLoad.publicKey.toString()); + console.log('account to load', accountToLoad.publicKey.toString()); console.log('buffer', buffer.toString('base64')); for (const callback of accountToLoad.callbacks.values()) { - console.log('account to load cb', callback); + console.log('account to load cb', callback.toString()); } throw e; } diff --git a/sdk/src/accounts/fetch.ts b/sdk/src/accounts/fetch.ts index 53d5f9ff5e..539a380e7f 100644 --- a/sdk/src/accounts/fetch.ts +++ b/sdk/src/accounts/fetch.ts @@ -45,7 +45,7 @@ export async function fetchUserAccountsUsingKeys( return undefined; } return program.account.user.coder.accounts.decodeUnchecked( - 'User', + 'user', accountInfo.data ) as UserAccount; }); @@ -67,7 +67,7 @@ export async function fetchUserStatsAccount( return accountInfo ? (program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', + 'userStats', accountInfo.data ) as UserStatsAccount) : undefined; @@ -87,7 +87,7 @@ export async function fetchRevenueShareAccount( ); if (!accountInfo) return null; return program.account.revenueShare.coder.accounts.decode( - 'RevenueShare', + 'revenueShare', accountInfo.data ) as RevenueShareAccount; } @@ -108,7 +108,7 @@ export async function fetchRevenueShareEscrowAccount( const escrowAccount = program.account.revenueShareEscrow.coder.accounts.decode( - 'RevenueShareEscrow', + 'revenueShareEscrow', escrow.data ) as RevenueShareEscrowAccount; diff --git a/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts b/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts index 5ff0a15dd1..b2fa631f82 100644 --- a/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts +++ b/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts @@ -23,7 +23,12 @@ import { } from './types'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; import { grpcMultiAccountSubscriber } from './grpcMultiAccountSubscriber'; -import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types'; +import { + PerpMarketAccount, + SpotMarketAccount, + StateAccount, + parseSpotMarketAccount, +} from '../types'; import { getOracleId, getPublicKeyAndSourceFromOracleId, @@ -135,7 +140,7 @@ export class grpcDriftClientAccountSubscriberV2 .filter((accountInfo) => !!accountInfo) .map((accountInfo) => { const perpMarket = this.program.coder.accounts.decode( - 'PerpMarket', + 'perpMarket', accountInfo.data ); return [perpMarket.marketIndex, perpMarket]; @@ -162,10 +167,11 @@ export class grpcDriftClientAccountSubscriberV2 spotMarketAccountInfos .filter((accountInfo) => !!accountInfo) .map((accountInfo) => { - const spotMarket = this.program.coder.accounts.decode( - 'SpotMarket', + const decoded = this.program.coder.accounts.decode( + 'spotMarket', accountInfo.data ); + const spotMarket = parseSpotMarketAccount(decoded); return [spotMarket.marketIndex, spotMarket]; }) ); diff --git a/sdk/src/accounts/grpcMultiAccountSubscriber.ts b/sdk/src/accounts/grpcMultiAccountSubscriber.ts index 3bf465c8fb..34cbcbd25d 100644 --- a/sdk/src/accounts/grpcMultiAccountSubscriber.ts +++ b/sdk/src/accounts/grpcMultiAccountSubscriber.ts @@ -13,6 +13,7 @@ import { } from '../isomorphic/grpc'; import { BufferAndSlot, DataAndSlot, GrpcConfigs, ResubOpts } from './types'; import { Drift } from '../idl/drift'; +import { parseAccount } from '../types'; interface AccountInfoLike { owner: PublicKey; @@ -180,10 +181,12 @@ export class grpcMultiAccountSubscriber { slot: currentSlot, }); - const accountDecoded = this.program.coder.accounts.decode( - this.capitalize(this.accountName), + const decoded = this.program.coder.accounts.decode( + this.accountName, newBuffer ); + const accountDecoded = parseAccount(this.accountName, decoded); + this.setAccountData(accountId, accountDecoded, currentSlot); } } @@ -303,12 +306,14 @@ export class grpcMultiAccountSubscriber { buffer: Buffer, accountProps: U ) => { - const data = this.decodeBufferFn + const decoded = this.decodeBufferFn ? this.decodeBufferFn(buffer, accountPubkey, accountProps) : this.program.account[this.accountName].coder.accounts.decode( - this.capitalize(this.accountName), + this.accountName, buffer ); + const data = parseAccount(this.accountName, decoded); + const handler = this.onChangeMap.get(accountPubkey); if (handler) { handler(data, context, buffer, accountProps); diff --git a/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts b/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts index d386ded475..b9e372abab 100644 --- a/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts +++ b/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts @@ -16,6 +16,7 @@ import { StateAccount, UserAccount, OracleSource, + parseAccount, } from '../types'; import { getDriftStateAccountPublicKey, @@ -23,7 +24,7 @@ import { getSpotMarketPublicKey, } from '../addresses/pda'; import { BulkAccountLoader } from './bulkAccountLoader'; -import { capitalize, findDelistedPerpMarketsAndOracles } from './utils'; +import { findDelistedPerpMarketsAndOracles } from './utils'; import { PublicKey } from '@solana/web3.js'; import { OracleInfo, OraclePriceData } from '../oracles/types'; import { OracleClientCache } from '../oracles/oracleClientCache'; @@ -257,9 +258,11 @@ export class PollingDriftClientAccountSubscriber (buffer: Buffer, slot: number) => { if (!buffer) return; - const account = this.program.account[ - accountToPoll.key - ].coder.accounts.decodeUnchecked(capitalize(accountToPoll.key), buffer); + const decoded = this.program.coder.accounts.decodeUnchecked( + accountToPoll.key, + buffer + ); + const account = parseAccount(accountToPoll.key, decoded); const dataAndSlot = { data: account, slot, @@ -329,9 +332,12 @@ export class PollingDriftClientAccountSubscriber const { buffer, slot } = bufferAndSlot; if (buffer) { - const account = this.program.account[ - accountToPoll.key - ].coder.accounts.decodeUnchecked(capitalize(accountToPoll.key), buffer); + const decoded = this.program.coder.accounts.decodeUnchecked( + accountToPoll.key, + buffer + ); + const account = parseAccount(accountToPoll.key, decoded); + if (accountToPoll.mapKey != undefined) { this[accountToPoll.key].set(accountToPoll.mapKey, { data: account, diff --git a/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts b/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts index c06955dced..84296cbe56 100644 --- a/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +++ b/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts @@ -87,7 +87,7 @@ export class PollingHighLeverageModeConfigAccountSubscriber } const account = this.program.account.user.coder.accounts.decode( - 'HighLeverageModeConfig', + 'highLeverageModeConfig', buffer ); this.highLeverageModeConfigAccountAndSlot = { data: account, slot }; diff --git a/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts b/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts index 0134b1cfc1..b608aebd42 100644 --- a/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +++ b/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts @@ -4,7 +4,7 @@ import { InsuranceFundStakeAccountEvents, InsuranceFundStakeAccountSubscriber, } from './types'; -import { Program } from '@coral-xyz/anchor'; +import { BN, Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { PublicKey } from '@solana/web3.js'; @@ -83,7 +83,7 @@ export class PollingInsuranceFundStakeAccountSubscriber } const account = this.program.account.user.coder.accounts.decode( - 'InsuranceFundStake', + 'insuranceFundStake', buffer ); this.insuranceFundStakeAccountAndSlot = { data: account, slot }; @@ -115,7 +115,19 @@ export class PollingInsuranceFundStakeAccountSubscriber (this.insuranceFundStakeAccountAndSlot?.slot ?? 0) ) { this.insuranceFundStakeAccountAndSlot = { - data: dataAndContext.data as InsuranceFundStake, + data: { + costBasis: dataAndContext.data.costBasis, + marketIndex: dataAndContext.data.marketIndex, + authority: dataAndContext.data.authority, + ifShares: new BN(dataAndContext.data.ifShares[0]), + ifBase: new BN(dataAndContext.data.ifBase[0]), + lastWithdrawRequestShares: new BN( + dataAndContext.data.lastWithdrawRequestShares[0] + ), + lastWithdrawRequestValue: + dataAndContext.data.lastWithdrawRequestValue, + lastWithdrawRequestTs: dataAndContext.data.lastWithdrawRequestTs, + } as InsuranceFundStake, slot: dataAndContext.context.slot, }; } diff --git a/sdk/src/accounts/pollingUserAccountSubscriber.ts b/sdk/src/accounts/pollingUserAccountSubscriber.ts index d5d7bffeaa..77cdac9be8 100644 --- a/sdk/src/accounts/pollingUserAccountSubscriber.ts +++ b/sdk/src/accounts/pollingUserAccountSubscriber.ts @@ -75,7 +75,7 @@ export class PollingUserAccountSubscriber implements UserAccountSubscriber { return; } - const account = this.decode('User', buffer); + const account = this.decode('user', buffer); this.user = { data: account, slot }; this.eventEmitter.emit('userAccountUpdate', account); this.eventEmitter.emit('update'); @@ -101,7 +101,7 @@ export class PollingUserAccountSubscriber implements UserAccountSubscriber { ); if (dataAndContext.context.slot > (this.user?.slot ?? 0)) { this.user = { - data: this.decode('User', dataAndContext.value.data), + data: this.decode('user', dataAndContext.value.data), slot: dataAndContext.context.slot, }; } diff --git a/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts b/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts index faa2971fa1..a808f09369 100644 --- a/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts +++ b/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts @@ -77,7 +77,7 @@ export class PollingUserStatsAccountSubscriber const account = this.program.account.userStats.coder.accounts.decodeUnchecked( - 'UserStats', + 'userStats', buffer ); this.userStats = { data: account, slot }; diff --git a/sdk/src/accounts/webSocketAccountSubscriber.ts b/sdk/src/accounts/webSocketAccountSubscriber.ts index a994c37d7c..4db1eac61f 100644 --- a/sdk/src/accounts/webSocketAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketAccountSubscriber.ts @@ -6,8 +6,6 @@ import { } from './types'; import { AnchorProvider, Program } from '@coral-xyz/anchor'; import { AccountInfo, Commitment, Context, PublicKey } from '@solana/web3.js'; -import { capitalize } from './utils'; -import * as Buffer from 'buffer'; import { Drift } from '../idl/drift'; export class WebSocketAccountSubscriber implements AccountSubscriber { @@ -200,7 +198,7 @@ export class WebSocketAccountSubscriber implements AccountSubscriber { return this.decodeBufferFn(buffer); } else { return this.program.account[this.accountName].coder.accounts.decode( - capitalize(this.accountName), + this.accountName, buffer ); } diff --git a/sdk/src/accounts/webSocketAccountSubscriberV2.ts b/sdk/src/accounts/webSocketAccountSubscriberV2.ts index d12c3064e5..9c4f26fc29 100644 --- a/sdk/src/accounts/webSocketAccountSubscriberV2.ts +++ b/sdk/src/accounts/webSocketAccountSubscriberV2.ts @@ -5,7 +5,6 @@ import { BufferAndSlot, } from './types'; import { AnchorProvider, Program } from '@coral-xyz/anchor'; -import { capitalize } from './utils'; import { AccountInfoBase, AccountInfoWithBase64EncodedData, @@ -481,7 +480,7 @@ export class WebSocketAccountSubscriberV2 implements AccountSubscriber { return this.decodeBufferFn(buffer); } else { return this.program.account[this.accountName].coder.accounts.decode( - capitalize(this.accountName), + this.accountName, buffer ); } diff --git a/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts b/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts index fd91da4484..6d5edc9005 100644 --- a/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts @@ -7,7 +7,12 @@ import { NotSubscribedError, ResubOpts, } from './types'; -import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types'; +import { + PerpMarketAccount, + SpotMarketAccount, + StateAccount, + parseSpotMarketAccount, +} from '../types'; import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; @@ -22,7 +27,6 @@ import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { Commitment, PublicKey } from '@solana/web3.js'; import { OracleInfo, OraclePriceData } from '../oracles/types'; import { OracleClientCache } from '../oracles/oracleClientCache'; -import * as Buffer from 'buffer'; import { QUOTE_ORACLE_PRICE_DATA } from '../oracles/quoteAssetOracleClient'; import { findAllMarketAndOracles } from '../config'; import { findDelistedPerpMarketsAndOracles } from './utils'; @@ -239,7 +243,7 @@ export class WebSocketDriftClientAccountSubscriber .filter((accountInfo) => !!accountInfo) .map((accountInfo) => { const perpMarket = this.program.coder.accounts.decode( - 'PerpMarket', + 'perpMarket', accountInfo.data ); return [perpMarket.marketIndex, perpMarket]; @@ -263,10 +267,11 @@ export class WebSocketDriftClientAccountSubscriber spotMarketAccountInfos .filter((accountInfo) => !!accountInfo) .map((accountInfo) => { - const spotMarket = this.program.coder.accounts.decode( - 'SpotMarket', + const decoded = this.program.coder.accounts.decode( + 'spotMarket', accountInfo.data ); + const spotMarket = parseSpotMarketAccount(decoded); return [spotMarket.marketIndex, spotMarket]; }) ); diff --git a/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts b/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts index 502dd0ce6c..36bf85474f 100644 --- a/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts +++ b/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts @@ -12,6 +12,8 @@ import { PerpMarketAccount, SpotMarketAccount, StateAccount, + parseSpotMarketAccount, + parsePerpMarketAccount, } from '../types'; import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; @@ -206,9 +208,14 @@ export class WebSocketDriftClientAccountSubscriberV2 'PerpMarketAccountsSubscriber', 'PerpMarket', this.program, - this.program.account.perpMarket.coder.accounts.decodeUnchecked.bind( - this.program.account.perpMarket.coder.accounts - ), + (_accountName: string, buffer: Buffer) => { + const decoded = + this.program.account.perpMarket.coder.accounts.decodeUnchecked( + 'perpMarket', + buffer + ); + return parsePerpMarketAccount(decoded); + }, { filters: [getPerpMarketAccountsFilter()], commitment: this.commitment, @@ -222,9 +229,14 @@ export class WebSocketDriftClientAccountSubscriberV2 'SpotMarketAccountsSubscriber', 'SpotMarket', this.program, - this.program.account.spotMarket.coder.accounts.decodeUnchecked.bind( - this.program.account.spotMarket.coder.accounts - ), + (_accountName: string, buffer: Buffer) => { + const decoded = + this.program.account.spotMarket.coder.accounts.decodeUnchecked( + 'spotMarket', + buffer + ); + return parseSpotMarketAccount(decoded); + }, { filters: [getSpotMarketAccountsFilter()], commitment: this.commitment, diff --git a/sdk/src/config.ts b/sdk/src/config.ts index 4c257d15e2..5deada1669 100644 --- a/sdk/src/config.ts +++ b/sdk/src/config.ts @@ -186,10 +186,13 @@ export async function findAllMarketAndOracles( const spotMarketIndexes = []; const oracleInfos = new Map(); - //@ts-ignore TS2589 - const perpMarketProgramAccountsRaw = await program.account.perpMarket.all(); - //@ts-ignore TS2589 - const spotMarketProgramAccountsRaw = await program.account.spotMarket.all(); + const [perpMarketProgramAccountsRaw, spotMarketProgramAccountsRaw] = + await Promise.all([ + // @ts-ignore TS2589 + program.account.perpMarket.all(), + // @ts-ignore TS2589 + program.account.spotMarket.all(), + ]); const perpMarketProgramAccounts: ProgramAccount[] = perpMarketProgramAccountsRaw.map((account) => ({ diff --git a/sdk/src/driftClient.ts b/sdk/src/driftClient.ts index 9223cb77b2..7e901d2b42 100644 --- a/sdk/src/driftClient.ts +++ b/sdk/src/driftClient.ts @@ -6972,11 +6972,11 @@ export class DriftClient { prefix, delegateSigner ? this.program.coder.types.encode( - 'SignedMsgOrderParamsDelegateMessage', + 'signedMsgOrderParamsDelegateMessage', withBuilderDefaults as SignedMsgOrderParamsDelegateMessage ) : this.program.coder.types.encode( - 'SignedMsgOrderParamsMessage', + 'signedMsgOrderParamsMessage', withBuilderDefaults as SignedMsgOrderParamsMessage ), ]); @@ -6994,8 +6994,8 @@ export class DriftClient { delegateSigner?: boolean ): SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage { const decodeStr = delegateSigner - ? 'SignedMsgOrderParamsDelegateMessage' - : 'SignedMsgOrderParamsMessage'; + ? 'signedMsgOrderParamsDelegateMessage' + : 'signedMsgOrderParamsMessage'; return this.program.coder.types.decode( decodeStr, Buffer.concat([ @@ -10259,7 +10259,7 @@ export class DriftClient { const postIxs: TransactionInstruction[] = []; if (accumulatorUpdateData.updates.length > 1) { const encodedParams = this.getReceiverProgram().coder.types.encode( - 'PostMultiUpdatesAtomicParams', + 'postMultiUpdatesAtomicParams', { vaa: trimmedVaa, merklePriceUpdates: accumulatorUpdateData.updates, @@ -10326,7 +10326,7 @@ export class DriftClient { const receiverProgram = this.getReceiverProgram(); const encodedParams = receiverProgram.coder.types.encode( - 'PostUpdateAtomicParams', + 'postUpdateAtomicParams', params ); @@ -10402,7 +10402,7 @@ export class DriftClient { const receiverProgram = this.getReceiverProgram(); const encodedParams = receiverProgram.coder.types.encode( - 'PostUpdateParams', + 'postUpdateParams', params ); diff --git a/sdk/src/idl/drift.json b/sdk/src/idl/drift.json index 1c01619e1a..7b834ba91f 100644 --- a/sdk/src/idl/drift.json +++ b/sdk/src/idl/drift.json @@ -15750,6 +15750,19 @@ 164, 151 ] + }, + { + "name": "_SignedMsgOrderParamsExport", + "discriminator": [ + 141, + 81, + 104, + 63, + 186, + 109, + 87, + 251 + ] } ], "errors": [ @@ -23919,6 +23932,160 @@ ] } }, + { + "name": "SignedMsgOrderParamsDelegateMessage", + "type": { + "kind": "struct", + "fields": [ + { + "name": "signed_msg_order_params", + "type": { + "defined": { + "name": "OrderParams" + } + } + }, + { + "name": "taker_pubkey", + "type": "pubkey" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "uuid", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "take_profit_order_params", + "type": { + "option": { + "defined": { + "name": "SignedMsgTriggerOrderParams" + } + } + } + }, + { + "name": "stop_loss_order_params", + "type": { + "option": { + "defined": { + "name": "SignedMsgTriggerOrderParams" + } + } + } + }, + { + "name": "max_margin_ratio", + "type": { + "option": "u16" + } + }, + { + "name": "builder_idx", + "type": { + "option": "u8" + } + }, + { + "name": "builder_fee_tenth_bps", + "type": { + "option": "u16" + } + }, + { + "name": "isolated_position_deposit", + "type": { + "option": "u64" + } + } + ] + } + }, + { + "name": "SignedMsgOrderParamsMessage", + "type": { + "kind": "struct", + "fields": [ + { + "name": "signed_msg_order_params", + "type": { + "defined": { + "name": "OrderParams" + } + } + }, + { + "name": "sub_account_id", + "type": "u16" + }, + { + "name": "slot", + "type": "u64" + }, + { + "name": "uuid", + "type": { + "array": [ + "u8", + 8 + ] + } + }, + { + "name": "take_profit_order_params", + "type": { + "option": { + "defined": { + "name": "SignedMsgTriggerOrderParams" + } + } + } + }, + { + "name": "stop_loss_order_params", + "type": { + "option": { + "defined": { + "name": "SignedMsgTriggerOrderParams" + } + } + } + }, + { + "name": "max_margin_ratio", + "type": { + "option": "u16" + } + }, + { + "name": "builder_idx", + "type": { + "option": "u8" + } + }, + { + "name": "builder_fee_tenth_bps", + "type": { + "option": "u16" + } + }, + { + "name": "isolated_position_deposit", + "type": { + "option": "u64" + } + } + ] + } + }, { "name": "SignedMsgOrderRecord", "type": { @@ -23964,6 +24131,22 @@ ] } }, + { + "name": "SignedMsgTriggerOrderParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "trigger_price", + "type": "u64" + }, + { + "name": "base_asset_amount", + "type": "u64" + } + ] + } + }, { "name": "SignedMsgUserOrders", "docs": [ @@ -25722,6 +25905,33 @@ ] } }, + { + "name": "_SignedMsgOrderParamsExport", + "docs": [ + "unusued placeholder event to force include signed msg types into drift IDL" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "_a", + "type": { + "defined": { + "name": "SignedMsgOrderParamsMessage" + } + } + }, + { + "name": "_b", + "type": { + "defined": { + "name": "SignedMsgOrderParamsDelegateMessage" + } + } + } + ] + } + }, { "name": "i128", "docs": [ diff --git a/sdk/src/idl/drift.ts b/sdk/src/idl/drift.ts index 7e857b5c54..e0a0e44abb 100644 --- a/sdk/src/idl/drift.ts +++ b/sdk/src/idl/drift.ts @@ -5,25762 +5,21427 @@ * IDL can be found at `target/idl/drift.json`. */ export type Drift = { - "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH", - "metadata": { - "name": "drift", - "version": "2.151.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "addAmmConstituentMappingData", - "discriminator": [ - 164, - 236, - 130, - 40, - 118, - 179, - 46, - 235 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool" - }, - { - "name": "ammConstituentMapping", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 65, - 77, - 77, - 95, - 77, - 65, - 80 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituentTargetBase", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "ammConstituentMappingData", - "type": { - "vec": { - "defined": { - "name": "addAmmConstituentMappingDatum" - } - } - } - } - ] - }, - { - "name": "addInsuranceFundStake", - "discriminator": [ - 251, - 144, - 115, - 11, - 222, - 47, - 62, - 236 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insuranceFundStake", - "userStats" - ] - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "addMarketToAmmCache", - "discriminator": [ - 112, - 149, - 195, - 222, - 124, - 7, - 87, - 237 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "perpMarket" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "adminDeposit", - "discriminator": [ - 210, - 66, - 65, - 182, - 102, - 214, - 176, - 30 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "adminTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "adminUpdateUserStatsPausedOperations", - "discriminator": [ - 183, - 104, - 63, - 150, - 240, - 199, - 3, - 10 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "beginInsuranceFundSwap", - "discriminator": [ - 176, - 69, - 143, - 205, - 32, - 132, - 163, - 0 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "outInsuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inInsuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outTokenAccount", - "writable": true - }, - { - "name": "inTokenAccount", - "writable": true - }, - { - "name": "ifRebalanceConfig", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "amountIn", - "type": "u64" - } - ] - }, - { - "name": "beginLpSwap", - "discriminator": [ - 64, - 44, - 24, - 199, - 48, - 125, - 67, - 91 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "signerOutTokenAccount", - "docs": [ - "Signer token accounts" - ], - "writable": true - }, - { - "name": "signerInTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "docs": [ - "Constituent token accounts" - ], - "writable": true - }, - { - "name": "constituentInTokenAccount", - "writable": true - }, - { - "name": "outConstituent", - "docs": [ - "Constituents" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "lpPool" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "amountIn", - "type": "u64" - } - ] - }, - { - "name": "beginSwap", - "discriminator": [ - 174, - 109, - 228, - 1, - 242, - 105, - 232, - 105 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "outSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outTokenAccount", - "writable": true - }, - { - "name": "inTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "amountIn", - "type": "u64" - } - ] - }, - { - "name": "cancelOrder", - "discriminator": [ - 95, - 129, - 237, - 240, - 8, - 49, - 223, - 132 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "cancelOrderByUserId", - "discriminator": [ - 107, - 211, - 250, - 133, - 18, - 37, - 57, - 100 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "userOrderId", - "type": "u8" - } - ] - }, - { - "name": "cancelOrders", - "discriminator": [ - 238, - 225, - 95, - 158, - 227, - 103, - 8, - 194 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "marketType", - "type": { - "option": { - "defined": { - "name": "marketType" - } - } - } - }, - { - "name": "marketIndex", - "type": { - "option": "u16" - } - }, - { - "name": "direction", - "type": { - "option": { - "defined": { - "name": "positionDirection" - } - } - } - } - ] - }, - { - "name": "cancelOrdersByIds", - "discriminator": [ - 134, - 19, - 144, - 165, - 94, - 240, - 210, - 94 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "orderIds", - "type": { - "vec": "u32" - } - } - ] - }, - { - "name": "cancelRequestRemoveInsuranceFundStake", - "discriminator": [ - 97, - 235, - 78, - 62, - 212, - 42, - 241, - 127 - ], - "accounts": [ - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insuranceFundStake", - "userStats" - ] - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "changeApprovedBuilder", - "discriminator": [ - 179, - 134, - 211, - 45, - 195, - 5, - 189, - 173 - ], - "accounts": [ - { - "name": "escrow", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 82, - 69, - 86, - 95, - 69, - 83, - 67, - 82, - 79, - 87 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "signer": true, - "relations": [ - "escrow" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "builder", - "type": "pubkey" - }, - { - "name": "maxFeeBps", - "type": "u16" - }, - { - "name": "add", - "type": "bool" - } - ] - }, - { - "name": "changeSignedMsgWsDelegateStatus", - "discriminator": [ - 252, - 202, - 252, - 219, - 179, - 27, - 84, - 138 - ], - "accounts": [ - { - "name": "signedMsgWsDelegates", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71, - 95, - 87, - 83 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "delegate", - "type": "pubkey" - }, - { - "name": "add", - "type": "bool" - } - ] - }, - { - "name": "deleteAmmCache", - "discriminator": [ - 216, - 130, - 215, - 206, - 233, - 232, - 191, - 88 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "deleteInitializedPerpMarket", - "discriminator": [ - 91, - 154, - 24, - 87, - 106, - 59, - 190, - 66 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "deleteInitializedSpotMarket", - "discriminator": [ - 31, - 140, - 67, - 191, - 189, - 20, - 101, - 221 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "deletePrelaunchOracle", - "discriminator": [ - 59, - 169, - 100, - 49, - 69, - 17, - 173, - 253 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "prelaunchOracle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101 - ] - }, - { - "kind": "arg", - "path": "perpMarketIndex" - } - ] - } - }, - { - "name": "perpMarket" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "perpMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "deleteSignedMsgUserOrders", - "discriminator": [ - 221, - 247, - 128, - 253, - 212, - 254, - 46, - 153 - ], - "accounts": [ - { - "name": "signedMsgUserOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [] - }, - { - "name": "deleteUser", - "discriminator": [ - 186, - 85, - 17, - 249, - 219, - 231, - 98, - 251 - ], - "accounts": [ - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "writable": true, - "signer": true, - "relations": [ - "user", - "userStats" - ] - } - ], - "args": [] - }, - { - "name": "deposit", - "discriminator": [ - 242, - 35, - 198, - 137, - 82, - 225, - 242, - 182 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "reduceOnly", - "type": "bool" - } - ] - }, - { - "name": "depositIntoInsuranceFundStake", - "discriminator": [ - 4, - 22, - 226, - 201, - 124, - 44, - 82, - 230 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101 - ] - }, - { - "kind": "account", - "path": "userStats" - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "depositIntoPerpMarketFeePool", - "discriminator": [ - 34, - 58, - 57, - 68, - 97, - 80, - 244, - 6 - ], - "accounts": [ - { - "name": "state", - "writable": true - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "sourceVault", - "writable": true - }, - { - "name": "driftSigner" - }, - { - "name": "quoteSpotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "depositIntoSpotMarketRevenuePool", - "discriminator": [ - 92, - 40, - 151, - 42, - 122, - 254, - 139, - 246 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "spotMarket" - } - ] - } - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "depositIntoSpotMarketVault", - "discriminator": [ - 48, - 252, - 119, - 73, - 255, - 205, - 174, - 247 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "sourceVault", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "depositToProgramVault", - "discriminator": [ - 235, - 171, - 121, - 80, - 57, - 239, - 147, - 220 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "constituent", - "writable": true - }, - { - "name": "constituentTokenAccount", - "writable": true - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "mint" - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "disableUserHighLeverageMode", - "discriminator": [ - 183, - 155, - 45, - 0, - 226, - 85, - 213, - 69 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "highLeverageModeConfig", - "writable": true - } - ], - "args": [ - { - "name": "disableMaintenance", - "type": "bool" - } - ] - }, - { - "name": "enableUserHighLeverageMode", - "discriminator": [ - 231, - 24, - 230, - 112, - 201, - 173, - 73, - 184 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "highLeverageModeConfig", - "writable": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - } - ] - }, - { - "name": "endInsuranceFundSwap", - "discriminator": [ - 206, - 230, - 98, - 8, - 249, - 158, - 169, - 167 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "outInsuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inInsuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outTokenAccount", - "writable": true - }, - { - "name": "inTokenAccount", - "writable": true - }, - { - "name": "ifRebalanceConfig", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "endLpSwap", - "discriminator": [ - 99, - 125, - 214, - 165, - 129, - 175, - 253, - 135 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "signerOutTokenAccount", - "docs": [ - "Signer token accounts" - ], - "writable": true - }, - { - "name": "signerInTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "docs": [ - "Constituent token accounts" - ], - "writable": true - }, - { - "name": "constituentInTokenAccount", - "writable": true - }, - { - "name": "outConstituent", - "docs": [ - "Constituents" - ], - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "lpPool" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "endSwap", - "discriminator": [ - 177, - 184, - 27, - 193, - 34, - 13, - 210, - 145 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "outSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outTokenAccount", - "writable": true - }, - { - "name": "inTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - }, - { - "name": "reduceOnly", - "type": { - "option": { - "defined": { - "name": "swapReduceOnly" - } - } - } - } - ] - }, - { - "name": "fillPerpOrder", - "discriminator": [ - 13, - 188, - 248, - 103, - 134, - 217, - 106, - 240 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "fillerStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "fillSpotOrder", - "discriminator": [ - 212, - 206, - 130, - 173, - 21, - 34, - 199, - 40 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "fillerStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": { - "name": "spotFulfillmentType" - } - } - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "forceCancelOrders", - "discriminator": [ - 64, - 181, - 196, - 63, - 222, - 72, - 64, - 232 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "user", - "writable": true - } - ], - "args": [] - }, - { - "name": "forceDeleteUser", - "discriminator": [ - 2, - 241, - 195, - 172, - 227, - 24, - 254, - 158 - ], - "accounts": [ - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "writable": true, - "relations": [ - "user", - "userStats" - ] - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "driftSigner" - } - ], - "args": [] - }, - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 114, - 105, - 102, - 116, - 95, - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "quoteAssetMint" - }, - { - "name": "driftSigner" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [] - }, - { - "name": "initializeAmmCache", - "discriminator": [ - 38, - 60, - 171, - 158, - 203, - 58, - 137, - 8 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initializeConstituent", - "discriminator": [ - 12, - 196, - 45, - 218, - 93, - 89, - 0, - 33 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "constituentTargetBase", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituentCorrelations", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "spotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "spotMarketMint" - }, - { - "name": "constituentVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "decimals", - "type": "u8" - }, - { - "name": "maxWeightDeviation", - "type": "i64" - }, - { - "name": "swapFeeMin", - "type": "i64" - }, - { - "name": "swapFeeMax", - "type": "i64" - }, - { - "name": "maxBorrowTokenAmount", - "type": "u64" - }, - { - "name": "oracleStalenessThreshold", - "type": "u64" - }, - { - "name": "costToTrade", - "type": "i32" - }, - { - "name": "constituentDerivativeIndex", - "type": { - "option": "i16" - } - }, - { - "name": "constituentDerivativeDepegThreshold", - "type": "u64" - }, - { - "name": "derivativeWeight", - "type": "u64" - }, - { - "name": "volatility", - "type": "u64" - }, - { - "name": "gammaExecution", - "type": "u8" - }, - { - "name": "gammaInventory", - "type": "u8" - }, - { - "name": "xi", - "type": "u8" - }, - { - "name": "newConstituentCorrelations", - "type": { - "vec": "i64" - } - } - ] - }, - { - "name": "initializeFuelOverflow", - "discriminator": [ - 88, - 223, - 132, - 161, - 208, - 88, - 142, - 42 - ], - "accounts": [ - { - "name": "fuelOverflow", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 102, - 117, - 101, - 108, - 95, - 111, - 118, - 101, - 114, - 102, - 108, - 111, - 119 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "relations": [ - "userStats" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initializeHighLeverageModeConfig", - "discriminator": [ - 213, - 167, - 93, - 246, - 208, - 130, - 90, - 248 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "highLeverageModeConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 104, - 105, - 103, - 104, - 95, - 108, - 101, - 118, - 101, - 114, - 97, - 103, - 101, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "maxUsers", - "type": "u32" - } - ] - }, - { - "name": "initializeIfRebalanceConfig", - "discriminator": [ - 8, - 85, - 184, - 167, - 176, - 61, - 173, - 226 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "ifRebalanceConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 102, - 95, - 114, - 101, - 98, - 97, - 108, - 97, - 110, - 99, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "arg", - "path": "params.in_market_index" - }, - { - "kind": "arg", - "path": "params.out_market_index" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ifRebalanceConfigParams" - } - } - } - ] - }, - { - "name": "initializeInsuranceFundStake", - "discriminator": [ - 187, - 179, - 243, - 70, - 248, - 90, - 92, - 147 - ], - "accounts": [ - { - "name": "spotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 115, - 116, - 97, - 107, - 101 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state" - }, - { - "name": "authority", - "signer": true, - "relations": [ - "userStats" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "initializeLpPool", - "discriminator": [ - 242, - 64, - 1, - 222, - 142, - 46, - 204, - 227 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 112, - 95, - 112, - 111, - 111, - 108 - ] - }, - { - "kind": "arg", - "path": "id" - } - ] - } - }, - { - "name": "mint" - }, - { - "name": "lpPoolTokenVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "ammConstituentMapping", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 65, - 77, - 77, - 95, - 77, - 65, - 80 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituentTargetBase", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "constituentCorrelations", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "lpPoolId", - "type": "u8" - }, - { - "name": "minMintFee", - "type": "i64" - }, - { - "name": "maxAum", - "type": "u128" - }, - { - "name": "maxSettleQuoteAmountPerMarket", - "type": "u64" - }, - { - "name": "whitelistMint", - "type": "pubkey" - } - ] - }, - { - "name": "initializeOpenbookV2FulfillmentConfig", - "discriminator": [ - 7, - 221, - 103, - 153, - 107, - 57, - 27, - 197 - ], - "accounts": [ - { - "name": "baseSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "quoteSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "openbookV2Program" - }, - { - "name": "openbookV2Market" - }, - { - "name": "driftSigner" - }, - { - "name": "openbookV2FulfillmentConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 111, - 112, - 101, - 110, - 98, - 111, - 111, - 107, - 95, - 118, - 50, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "openbookV2Market" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "initializePerpMarket", - "discriminator": [ - 132, - 9, - 229, - 118, - 117, - 118, - 117, - 62 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "perpMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 101, - 114, - 112, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "account", - "path": "state.number_of_markets", - "account": "state" - } - ] - } - }, - { - "name": "oracle" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "ammBaseAssetReserve", - "type": "u128" - }, - { - "name": "ammQuoteAssetReserve", - "type": "u128" - }, - { - "name": "ammPeriodicity", - "type": "i64" - }, - { - "name": "ammPegMultiplier", - "type": "u128" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "contractTier", - "type": { - "defined": { - "name": "contractTier" - } - } - }, - { - "name": "marginRatioInitial", - "type": "u32" - }, - { - "name": "marginRatioMaintenance", - "type": "u32" - }, - { - "name": "liquidatorFee", - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "type": "u32" - }, - { - "name": "imfFactor", - "type": "u32" - }, - { - "name": "activeStatus", - "type": "bool" - }, - { - "name": "baseSpread", - "type": "u32" - }, - { - "name": "maxSpread", - "type": "u32" - }, - { - "name": "maxOpenInterest", - "type": "u128" - }, - { - "name": "maxRevenueWithdrawPerPeriod", - "type": "u64" - }, - { - "name": "quoteMaxInsurance", - "type": "u64" - }, - { - "name": "orderStepSize", - "type": "u64" - }, - { - "name": "orderTickSize", - "type": "u64" - }, - { - "name": "minOrderSize", - "type": "u64" - }, - { - "name": "concentrationCoefScale", - "type": "u128" - }, - { - "name": "curveUpdateIntensity", - "type": "u8" - }, - { - "name": "ammJitIntensity", - "type": "u8" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "lpPoolId", - "type": "u8" - } - ] - }, - { - "name": "initializePhoenixFulfillmentConfig", - "discriminator": [ - 135, - 132, - 110, - 107, - 185, - 160, - 169, - 154 - ], - "accounts": [ - { - "name": "baseSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "quoteSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "phoenixProgram" - }, - { - "name": "phoenixMarket" - }, - { - "name": "driftSigner" - }, - { - "name": "phoenixFulfillmentConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 104, - 111, - 101, - 110, - 105, - 120, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "phoenixMarket" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "initializePredictionMarket", - "discriminator": [ - 248, - 70, - 198, - 224, - 224, - 105, - 125, - 195 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [] - }, - { - "name": "initializePrelaunchOracle", - "discriminator": [ - 169, - 178, - 84, - 25, - 175, - 62, - 29, - 247 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "prelaunchOracle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101 - ] - }, - { - "kind": "arg", - "path": "params.perp_market_index" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "prelaunchOracleParams" - } - } - } - ] - }, - { - "name": "initializeProtectedMakerModeConfig", - "discriminator": [ - 67, - 103, - 220, - 67, - 88, - 32, - 252, - 8 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "protectedMakerModeConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 111, - 116, - 101, - 99, - 116, - 101, - 100, - 95, - 109, - 97, - 107, - 101, - 114, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "maxUsers", - "type": "u32" - } - ] - }, - { - "name": "initializePythLazerOracle", - "discriminator": [ - 140, - 107, - 33, - 214, - 235, - 219, - 103, - 20 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lazerOracle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 121, - 116, - 104, - 95, - 108, - 97, - 122, - 101, - 114 - ] - }, - { - "kind": "arg", - "path": "feedId" - } - ] - } - }, - { - "name": "state" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "feedId", - "type": "u32" - } - ] - }, - { - "name": "initializePythPullOracle", - "discriminator": [ - 249, - 140, - 253, - 243, - 248, - 74, - 240, - 238 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "pythSolanaReceiver", - "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" - }, - { - "name": "priceFeed", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 121, - 116, - 104, - 95, - 112, - 117, - 108, - 108 - ] - }, - { - "kind": "arg", - "path": "feedId" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "initializeReferrerName", - "discriminator": [ - 235, - 126, - 231, - 10, - 42, - 164, - 26, - 61 - ], - "accounts": [ - { - "name": "referrerName", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 102, - 101, - 114, - 114, - 101, - 114, - 95, - 110, - 97, - 109, - 101 - ] - }, - { - "kind": "arg", - "path": "name" - } - ] - } - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "initializeRevenueShare", - "discriminator": [ - 57, - 9, - 123, - 131, - 82, - 52, - 50, - 13 - ], - "accounts": [ - { - "name": "revenueShare", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 82, - 69, - 86, - 95, - 83, - 72, - 65, - 82, - 69 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority" - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initializeRevenueShareEscrow", - "discriminator": [ - 187, - 18, - 123, - 88, - 238, - 104, - 84, - 154 - ], - "accounts": [ - { - "name": "escrow", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 82, - 69, - 86, - 95, - 69, - 83, - 67, - 82, - 79, - 87 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "relations": [ - "userStats" - ] - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state" - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "numOrders", - "type": "u16" - } - ] - }, - { - "name": "initializeSerumFulfillmentConfig", - "discriminator": [ - 193, - 211, - 132, - 172, - 70, - 171, - 7, - 94 - ], - "accounts": [ - { - "name": "baseSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "quoteSpotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "serumProgram" - }, - { - "name": "serumMarket" - }, - { - "name": "serumOpenOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 114, - 117, - 109, - 95, - 111, - 112, - 101, - 110, - 95, - 111, - 114, - 100, - 101, - 114, - 115 - ] - }, - { - "kind": "account", - "path": "serumMarket" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "serumFulfillmentConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 114, - 117, - 109, - 95, - 102, - 117, - 108, - 102, - 105, - 108, - 108, - 109, - 101, - 110, - 116, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - }, - { - "kind": "account", - "path": "serumMarket" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "initializeSignedMsgUserOrders", - "discriminator": [ - 164, - 99, - 156, - 126, - 156, - 57, - 99, - 180 - ], - "accounts": [ - { - "name": "signedMsgUserOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority" - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "numOrders", - "type": "u16" - } - ] - }, - { - "name": "initializeSignedMsgWsDelegates", - "discriminator": [ - 40, - 132, - 96, - 219, - 184, - 193, - 80, - 8 - ], - "accounts": [ - { - "name": "signedMsgWsDelegates", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71, - 95, - 87, - 83 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "delegates", - "type": { - "vec": "pubkey" - } - } - ] - }, - { - "name": "initializeSpotMarket", - "discriminator": [ - 234, - 196, - 128, - 44, - 94, - 15, - 48, - 201 - ], - "accounts": [ - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "account", - "path": "state.number_of_spot_markets", - "account": "state" - } - ] - } - }, - { - "name": "spotMarketMint" - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "state.number_of_spot_markets", - "account": "state" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "state.number_of_spot_markets", - "account": "state" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "state", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "optimalUtilization", - "type": "u32" - }, - { - "name": "optimalBorrowRate", - "type": "u32" - }, - { - "name": "maxBorrowRate", - "type": "u32" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "initialAssetWeight", - "type": "u32" - }, - { - "name": "maintenanceAssetWeight", - "type": "u32" - }, - { - "name": "initialLiabilityWeight", - "type": "u32" - }, - { - "name": "maintenanceLiabilityWeight", - "type": "u32" - }, - { - "name": "imfFactor", - "type": "u32" - }, - { - "name": "liquidatorFee", - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "type": "u32" - }, - { - "name": "activeStatus", - "type": "bool" - }, - { - "name": "assetTier", - "type": { - "defined": { - "name": "assetTier" - } - } - }, - { - "name": "scaleInitialAssetWeightStart", - "type": "u64" - }, - { - "name": "withdrawGuardThreshold", - "type": "u64" - }, - { - "name": "orderTickSize", - "type": "u64" - }, - { - "name": "orderStepSize", - "type": "u64" - }, - { - "name": "ifTotalFactor", - "type": "u32" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "initializeUser", - "discriminator": [ - 111, - 17, - 185, - 250, - 60, - 122, - 38, - 254 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "userStats" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "initializeUserStats", - "discriminator": [ - 254, - 243, - 72, - 98, - 251, - 130, - 168, - 213 - ], - "accounts": [ - { - "name": "userStats", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114, - 95, - 115, - 116, - 97, - 116, - 115 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "state", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "liquidateBorrowForPerpPnl", - "discriminator": [ - 169, - 17, - 32, - 90, - 207, - 148, - 209, - 27 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxLiabilityTransfer", - "type": "u128" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "liquidatePerp", - "discriminator": [ - 75, - 35, - 119, - 247, - 191, - 18, - 139, - 2 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxBaseAssetAmount", - "type": "u64" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "liquidatePerpPnlForDeposit", - "discriminator": [ - 237, - 75, - 198, - 235, - 233, - 186, - 75, - 35 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxPnlTransfer", - "type": "u128" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "liquidatePerpWithFill", - "discriminator": [ - 95, - 111, - 124, - 105, - 86, - 169, - 187, - 34 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "liquidateSpot", - "discriminator": [ - 107, - 0, - 128, - 41, - 35, - 229, - 251, - 18 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [ - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "liquidatorMaxLiabilityTransfer", - "type": "u128" - }, - { - "name": "limitPrice", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "liquidateSpotWithSwapBegin", - "discriminator": [ - 12, - 43, - 176, - 83, - 156, - 251, - 117, - 13 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "liabilitySpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "liabilityMarketIndex" - } - ] - } - }, - { - "name": "assetSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "assetMarketIndex" - } - ] - } - }, - { - "name": "liabilityTokenAccount", - "writable": true - }, - { - "name": "assetTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "swapAmount", - "type": "u64" - } - ] - }, - { - "name": "liquidateSpotWithSwapEnd", - "discriminator": [ - 142, - 88, - 163, - 160, - 223, - 75, - 55, - 225 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "liabilitySpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "liabilityMarketIndex" - } - ] - } - }, - { - "name": "assetSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "assetMarketIndex" - } - ] - } - }, - { - "name": "liabilityTokenAccount", - "writable": true - }, - { - "name": "assetTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - }, - { - "name": "instructions", - "docs": [ - "Instructions Sysvar for instruction introspection" - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "logUserBalances", - "discriminator": [ - 162, - 21, - 35, - 251, - 32, - 57, - 161, - 210 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "user", - "writable": true - } - ], - "args": [] - }, - { - "name": "lpPoolAddLiquidity", - "discriminator": [ - 49, - 135, - 246, - 103, - 93, - 146, - 220, - 141 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "inMarketMint" - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "userInTokenAccount", - "writable": true - }, - { - "name": "constituentInTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "userLpTokenAccount", - "writable": true - }, - { - "name": "lpMint", - "writable": true - }, - { - "name": "constituentTargetBase" - }, - { - "name": "lpPoolTokenVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u128" - }, - { - "name": "minMintAmount", - "type": "u64" - } - ] - }, - { - "name": "lpPoolRemoveLiquidity", - "discriminator": [ - 164, - 36, - 193, - 252, - 196, - 157, - 138, - 43 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "driftSigner" - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "outMarketMint" - }, - { - "name": "outConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "userOutTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "userLpTokenAccount", - "writable": true - }, - { - "name": "spotMarketTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "lpMint", - "writable": true - }, - { - "name": "constituentTargetBase" - }, - { - "name": "lpPoolTokenVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 76, - 80, - 95, - 80, - 79, - 79, - 76, - 95, - 84, - 79, - 75, - 69, - 78, - 95, - 86, - 65, - 85, - 76, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "tokenProgram" - }, - { - "name": "ammCache", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" - }, - { - "name": "minOutAmount", - "type": "u128" - } - ] - }, - { - "name": "lpPoolSwap", - "discriminator": [ - 36, - 161, - 39, - 49, - 227, - 1, - 35, - 226 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool" - }, - { - "name": "constituentTargetBase" - }, - { - "name": "constituentCorrelations" - }, - { - "name": "constituentInTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "writable": true - }, - { - "name": "userInTokenAccount", - "writable": true - }, - { - "name": "userOutTokenAccount", - "writable": true - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "inMarketMint" - }, - { - "name": "outMarketMint" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" - }, - { - "name": "minOutAmount", - "type": "u64" - } - ] - }, - { - "name": "modifyOrder", - "discriminator": [ - 47, - 124, - 117, - 255, - 201, - 197, - 130, - 94 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "orderId", - "type": { - "option": "u32" - } - }, - { - "name": "modifyOrderParams", - "type": { - "defined": { - "name": "modifyOrderParams" - } - } - } - ] - }, - { - "name": "modifyOrderByUserId", - "discriminator": [ - 158, - 77, - 4, - 253, - 252, - 194, - 161, - 179 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "userOrderId", - "type": "u8" - }, - { - "name": "modifyOrderParams", - "type": { - "defined": { - "name": "modifyOrderParams" - } - } - } - ] - }, - { - "name": "moveAmmPrice", - "discriminator": [ - 235, - 109, - 2, - 82, - 219, - 118, - 6, - 159 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "baseAssetReserve", - "type": "u128" - }, - { - "name": "quoteAssetReserve", - "type": "u128" - }, - { - "name": "sqrtK", - "type": "u128" - } - ] - }, - { - "name": "openbookV2FulfillmentConfigStatus", - "discriminator": [ - 25, - 173, - 19, - 189, - 4, - 211, - 64, - 238 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "openbookV2FulfillmentConfig", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - } - ] - }, - { - "name": "overrideAmmCacheInfo", - "discriminator": [ - 189, - 198, - 128, - 9, - 49, - 145, - 201, - 115 - ], - "accounts": [ - { - "name": "state", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "overrideParams", - "type": { - "defined": { - "name": "overrideAmmCacheParams" - } - } - } - ] - }, - { - "name": "pauseSpotMarketDepositWithdraw", - "discriminator": [ - 183, - 119, - 59, - 170, - 137, - 35, - 242, - 86 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "keeper", - "signer": true - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "spotMarket" - } - ] - } - } - ], - "args": [] - }, - { - "name": "phoenixFulfillmentConfigStatus", - "discriminator": [ - 96, - 31, - 113, - 32, - 12, - 203, - 7, - 154 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "phoenixFulfillmentConfig", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - } - ] - }, - { - "name": "placeAndMakePerpOrder", - "discriminator": [ - 149, - 117, - 11, - 237, - 47, - 95, - 89, - 237 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "taker", - "writable": true - }, - { - "name": "takerStats", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "takerOrderId", - "type": "u32" - } - ] - }, - { - "name": "placeAndMakeSignedMsgPerpOrder", - "discriminator": [ - 16, - 26, - 123, - 131, - 94, - 29, - 175, - 98 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "taker", - "writable": true - }, - { - "name": "takerStats", - "writable": true - }, - { - "name": "takerSignedMsgUserOrders", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "taker" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "signedMsgOrderUuid", - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - }, - { - "name": "placeAndMakeSpotOrder", - "discriminator": [ - 149, - 158, - 85, - 66, - 239, - 9, - 243, - 98 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "taker", - "writable": true - }, - { - "name": "takerStats", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "takerOrderId", - "type": "u32" - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": { - "name": "spotFulfillmentType" - } - } - } - } - ] - }, - { - "name": "placeAndTakePerpOrder", - "discriminator": [ - 213, - 51, - 1, - 187, - 108, - 220, - 230, - 224 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "successCondition", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "placeAndTakeSpotOrder", - "discriminator": [ - 191, - 3, - 138, - 71, - 114, - 198, - 202, - 100 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "fulfillmentType", - "type": { - "option": { - "defined": { - "name": "spotFulfillmentType" - } - } - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "placeOrders", - "discriminator": [ - 60, - 63, - 50, - 123, - 12, - 197, - 60, - 190 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "vec": { - "defined": { - "name": "orderParams" - } - } - } - } - ] - }, - { - "name": "placePerpOrder", - "discriminator": [ - 69, - 161, - 93, - 202, - 120, - 126, - 76, - 185 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - } - ] - }, - { - "name": "placeSignedMsgTakerOrder", - "discriminator": [ - 32, - 79, - 101, - 139, - 25, - 6, - 98, - 15 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "signedMsgUserOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "user" - } - ] - } - }, - { - "name": "authority", - "signer": true - }, - { - "name": "ixSysvar", - "docs": [ - "the supplied Sysvar could be anything else.", - "The Instruction Sysvar has not been implemented", - "in the Anchor framework yet, so this is the safe approach." - ], - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "signedMsgOrderParamsMessageBytes", - "type": "bytes" - }, - { - "name": "isDelegateSigner", - "type": "bool" - } - ] - }, - { - "name": "placeSpotOrder", - "discriminator": [ - 45, - 79, - 81, - 160, - 248, - 90, - 91, - 220 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "orderParams" - } - } - } - ] - }, - { - "name": "postMultiPythPullOracleUpdatesAtomic", - "discriminator": [ - 243, - 79, - 204, - 228, - 227, - 208, - 100, - 244 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "pythSolanaReceiver", - "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" - }, - { - "name": "guardianSet" - } - ], - "args": [ - { - "name": "params", - "type": "bytes" - } - ] - }, - { - "name": "postPythLazerOracleUpdate", - "discriminator": [ - 218, - 237, - 170, - 245, - 39, - 143, - 166, - 33 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "pythLazerStorage", - "address": "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL" - }, - { - "name": "ixSysvar", - "address": "Sysvar1nstructions1111111111111111111111111" - } - ], - "args": [ - { - "name": "pythMessage", - "type": "bytes" - } - ] - }, - { - "name": "postPythPullOracleUpdateAtomic", - "discriminator": [ - 116, - 122, - 137, - 158, - 224, - 195, - 173, - 119 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "pythSolanaReceiver", - "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" - }, - { - "name": "guardianSet" - }, - { - "name": "priceFeed", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 121, - 116, - 104, - 95, - 112, - 117, - 108, - 108 - ] - }, - { - "kind": "arg", - "path": "feedId" - } - ] - } - } - ], - "args": [ - { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "params", - "type": "bytes" - } - ] - }, - { - "name": "recenterPerpMarketAmm", - "discriminator": [ - 24, - 87, - 10, - 115, - 165, - 190, - 80, - 139 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "pegMultiplier", - "type": "u128" - }, - { - "name": "sqrtK", - "type": "u128" - } - ] - }, - { - "name": "recenterPerpMarketAmmCrank", - "discriminator": [ - 166, - 19, - 64, - 10, - 14, - 51, - 101, - 122 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "spotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "account", - "path": "perpMarket" - } - ] - } - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "depth", - "type": { - "option": "u128" - } - } - ] - }, - { - "name": "reclaimRent", - "discriminator": [ - 218, - 200, - 19, - 197, - 227, - 89, - 192, - 22 - ], - "accounts": [ - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "state" - }, - { - "name": "authority", - "signer": true, - "relations": [ - "user", - "userStats" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "removeAmmConstituentMappingData", - "discriminator": [ - 20, - 183, - 211, - 162, - 16, - 52, - 229, - 115 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool" - }, - { - "name": "ammConstituentMapping", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 65, - 77, - 77, - 95, - 77, - 65, - 80 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - } - ] - }, - { - "name": "removeInsuranceFundStake", - "discriminator": [ - 128, - 166, - 142, - 9, - 254, - 187, - 143, - 174 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insuranceFundStake", - "userStats" - ] - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "repegAmmCurve", - "discriminator": [ - 3, - 36, - 102, - 89, - 180, - 128, - 120, - 213 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [ - { - "name": "newPegCandidate", - "type": "u128" - } - ] - }, - { - "name": "requestRemoveInsuranceFundStake", - "discriminator": [ - 142, - 70, - 204, - 92, - 73, - 106, - 180, - 52 - ], - "accounts": [ - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "insuranceFundStake", - "userStats" - ] - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "resetFuelSeason", - "discriminator": [ - 199, - 122, - 192, - 255, - 32, - 99, - 63, - 200 - ], - "accounts": [ - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "relations": [ - "userStats" - ] - }, - { - "name": "state" - }, - { - "name": "admin", - "signer": true - } - ], - "args": [] - }, - { - "name": "resetPerpMarketAmmOracleTwap", - "discriminator": [ - 127, - 10, - 55, - 164, - 123, - 226, - 47, - 24 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [] - }, - { - "name": "resizeRevenueShareEscrowOrders", - "discriminator": [ - 32, - 124, - 247, - 225, - 151, - 213, - 225, - 38 - ], - "accounts": [ - { - "name": "escrow", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 82, - 69, - 86, - 95, - 69, - 83, - 67, - 82, - 79, - 87 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "relations": [ - "escrow" - ] - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "numOrders", - "type": "u16" - } - ] - }, - { - "name": "resizeSignedMsgUserOrders", - "discriminator": [ - 137, - 10, - 87, - 150, - 18, - 115, - 79, - 168 - ], - "accounts": [ - { - "name": "signedMsgUserOrders", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 83, - 73, - 71, - 78, - 69, - 68, - 95, - 77, - 83, - 71 - ] - }, - { - "kind": "account", - "path": "authority" - } - ] - } - }, - { - "name": "authority", - "relations": [ - "user" - ] - }, - { - "name": "user" - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "numOrders", - "type": "u16" - } - ] - }, - { - "name": "resolvePerpBankruptcy", - "discriminator": [ - 224, - 16, - 176, - 214, - 162, - 213, - 183, - 222 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "quoteSpotMarketIndex", - "type": "u16" - }, - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "resolvePerpPnlDeficit", - "discriminator": [ - 168, - 204, - 68, - 150, - 159, - 126, - 95, - 148 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "resolveSpotBankruptcy", - "discriminator": [ - 124, - 194, - 240, - 254, - 198, - 213, - 52, - 122 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "liquidator", - "writable": true - }, - { - "name": "liquidatorStats", - "writable": true - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "spotMarketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "revertFill", - "discriminator": [ - 236, - 238, - 176, - 69, - 239, - 10, - 181, - 193 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "fillerStats", - "writable": true - } - ], - "args": [] - }, - { - "name": "setUserStatusToBeingLiquidated", - "discriminator": [ - 106, - 133, - 160, - 206, - 193, - 171, - 192, - 194 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [] - }, - { - "name": "settleExpiredMarket", - "discriminator": [ - 120, - 89, - 11, - 25, - 122, - 77, - 72, - 193 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "settleExpiredMarketPoolsToRevenuePool", - "discriminator": [ - 55, - 19, - 238, - 169, - 227, - 90, - 200, - 184 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [] - }, - { - "name": "settleFundingPayment", - "discriminator": [ - 222, - 90, - 202, - 94, - 28, - 45, - 115, - 183 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - } - ], - "args": [] - }, - { - "name": "settleMultiplePnls", - "discriminator": [ - 127, - 66, - 117, - 57, - 40, - 50, - 152, - 127 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - } - ], - "args": [ - { - "name": "marketIndexes", - "type": { - "vec": "u16" - } - }, - { - "name": "mode", - "type": { - "defined": { - "name": "settlePnlMode" - } - } - } - ] - }, - { - "name": "settlePerpToLpPool", - "discriminator": [ - 5, - 98, - 46, - 188, - 10, - 59, - 2, - 249 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "ammCache", - "writable": true - }, - { - "name": "quoteMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "constituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "constituentQuoteTokenAccount", - "writable": true - }, - { - "name": "quoteTokenVault", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - } - ], - "args": [] - }, - { - "name": "settlePnl", - "discriminator": [ - 43, - 61, - 234, - 45, - 15, - 95, - 152, - 153 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "settleRevenueToInsuranceFund", - "discriminator": [ - 200, - 120, - 93, - 136, - 69, - 38, - 199, - 159 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - } - ] - }, - { - "name": "sweepFuel", - "discriminator": [ - 175, - 107, - 19, - 56, - 165, - 241, - 43, - 69 - ], - "accounts": [ - { - "name": "fuelOverflow", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "relations": [ - "fuelOverflow", - "userStats" - ] - }, - { - "name": "signer", - "signer": true - } - ], - "args": [] - }, - { - "name": "transferDeposit", - "discriminator": [ - 20, - 20, - 147, - 223, - 41, - 63, - 204, - 111 - ], - "accounts": [ - { - "name": "fromUser", - "writable": true - }, - { - "name": "toUser", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "fromUser", - "toUser", - "userStats" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "transferPerpPosition", - "discriminator": [ - 23, - 172, - 188, - 168, - 134, - 210, - 3, - 108 - ], - "accounts": [ - { - "name": "fromUser", - "writable": true - }, - { - "name": "toUser", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": { - "option": "i64" - } - } - ] - }, - { - "name": "transferPools", - "discriminator": [ - 197, - 103, - 154, - 25, - 107, - 90, - 60, - 94 - ], - "accounts": [ - { - "name": "fromUser", - "writable": true - }, - { - "name": "toUser", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "fromUser", - "toUser", - "userStats" - ] - }, - { - "name": "state" - }, - { - "name": "depositFromSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "depositFromMarketIndex" - } - ] - } - }, - { - "name": "depositToSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "depositToMarketIndex" - } - ] - } - }, - { - "name": "borrowFromSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "borrowFromMarketIndex" - } - ] - } - }, - { - "name": "borrowToSpotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "borrowToMarketIndex" - } - ] - } - }, - { - "name": "driftSigner" - } - ], - "args": [ - { - "name": "depositFromMarketIndex", - "type": "u16" - }, - { - "name": "depositToMarketIndex", - "type": "u16" - }, - { - "name": "borrowFromMarketIndex", - "type": "u16" - }, - { - "name": "borrowToMarketIndex", - "type": "u16" - }, - { - "name": "depositAmount", - "type": { - "option": "u64" - } - }, - { - "name": "borrowAmount", - "type": { - "option": "u64" - } - } - ] - }, - { - "name": "transferProtocolIfSharesToRevenuePool", - "discriminator": [ - 236, - 136, - 147, - 153, - 146, - 205, - 104, - 29 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "writable": true, - "signer": true - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "ifRebalanceConfig", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "driftSigner" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "triggerOrder", - "discriminator": [ - 63, - 112, - 51, - 233, - 232, - 47, - 240, - 199 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "user", - "writable": true - } - ], - "args": [ - { - "name": "orderId", - "type": "u32" - } - ] - }, - { - "name": "updateAdmin", - "discriminator": [ - 161, - 176, - 40, - 213, - 60, - 184, - 179, - 228 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "admin", - "type": "pubkey" - } - ] - }, - { - "name": "updateAmmCache", - "discriminator": [ - 88, - 4, - 63, - 94, - 83, - 224, - 255, - 130 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "ammCache", - "writable": true - }, - { - "name": "quoteMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateAmmConstituentMappingData", - "discriminator": [ - 84, - 70, - 33, - 167, - 133, - 107, - 59, - 24 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool" - }, - { - "name": "ammConstituentMapping", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 65, - 77, - 77, - 95, - 77, - 65, - 80 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "ammConstituentMappingData", - "type": { - "vec": { - "defined": { - "name": "addAmmConstituentMappingDatum" - } - } - } - } - ] - }, - { - "name": "updateAmmJitIntensity", - "discriminator": [ - 181, - 191, - 53, - 109, - 166, - 249, - 55, - 142 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "ammJitIntensity", - "type": "u8" - } - ] - }, - { - "name": "updateAmms", - "discriminator": [ - 201, - 106, - 217, - 253, - 4, - 175, - 228, - 97 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "marketIndexes", - "type": { - "vec": "u16" - } - } - ] - }, - { - "name": "updateConstituentCorrelationData", - "discriminator": [ - 79, - 14, - 19, - 73, - 221, - 106, - 62, - 109 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "lpPool" - }, - { - "name": "constituentCorrelations", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 99, - 111, - 114, - 114, - 101, - 108, - 97, - 116, - 105, - 111, - 110, - 115 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "index1", - "type": "u16" - }, - { - "name": "index2", - "type": "u16" - }, - { - "name": "correlation", - "type": "i64" - } - ] - }, - { - "name": "updateConstituentOracleInfo", - "discriminator": [ - 198, - 117, - 231, - 250, - 147, - 33, - 127, - 161 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "constituent", - "writable": true - }, - { - "name": "spotMarket" - }, - { - "name": "oracle" - } - ], - "args": [] - }, - { - "name": "updateConstituentParams", - "discriminator": [ - 238, - 130, - 122, - 31, - 12, - 104, - 192, - 122 - ], - "accounts": [ - { - "name": "lpPool" - }, - { - "name": "constituentTargetBase", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 115, - 116, - 105, - 116, - 117, - 101, - 110, - 116, - 95, - 116, - 97, - 114, - 103, - 101, - 116, - 95, - 98, - 97, - 115, - 101, - 95, - 115, - 101, - 101, - 100 - ] - }, - { - "kind": "account", - "path": "lpPool" - } - ] - } - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "constituent", - "writable": true - } - ], - "args": [ - { - "name": "constituentParams", - "type": { - "defined": { - "name": "constituentParams" - } - } - } - ] - }, - { - "name": "updateConstituentPausedOperations", - "discriminator": [ - 185, - 122, - 153, - 191, - 131, - 177, - 132, - 208 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "constituent", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updateConstituentStatus", - "discriminator": [ - 76, - 159, - 211, - 239, - 182, - 214, - 6, - 15 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - }, - { - "name": "constituent", - "writable": true - } - ], - "args": [ - { - "name": "newStatus", - "type": "u8" - } - ] - }, - { - "name": "updateDelegateUserGovTokenInsuranceStake", - "discriminator": [ - 241, - 29, - 215, - 228, - 142, - 116, - 22, - 160 - ], - "accounts": [ - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 15, - 0 - ] - } - ] - } - }, - { - "name": "insuranceFundStake" - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 15, - 0 - ] - } - ] - } - }, - { - "name": "state" - } - ], - "args": [] - }, - { - "name": "updateDiscountMint", - "discriminator": [ - 32, - 252, - 122, - 211, - 66, - 31, - 47, - 241 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "discountMint", - "type": "pubkey" - } - ] - }, - { - "name": "updateExchangeStatus", - "discriminator": [ - 83, - 160, - 252, - 250, - 129, - 116, - 49, - 223 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "exchangeStatus", - "type": "u8" - } - ] - }, - { - "name": "updateFeatureBitFlagsBuilderCodes", - "discriminator": [ - 1, - 128, - 177, - 51, - 173, - 45, - 11, - 102 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsMedianTriggerPrice", - "discriminator": [ - 64, - 185, - 221, - 45, - 87, - 147, - 12, - 19 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsMintRedeemLpPool", - "discriminator": [ - 26, - 11, - 142, - 122, - 206, - 159, - 9, - 45 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsMmOracle", - "discriminator": [ - 218, - 134, - 33, - 186, - 231, - 59, - 130, - 149 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsSettleLpPool", - "discriminator": [ - 186, - 28, - 78, - 230, - 155, - 83, - 242, - 26 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFeatureBitFlagsSwapLpPool", - "discriminator": [ - 83, - 16, - 150, - 12, - 102, - 3, - 22, - 58 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "enable", - "type": "bool" - } - ] - }, - { - "name": "updateFundingRate", - "discriminator": [ - 201, - 178, - 116, - 212, - 166, - 144, - 72, - 238 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - } - ] - }, - { - "name": "updateHighLeverageModeConfig", - "discriminator": [ - 64, - 122, - 212, - 93, - 141, - 217, - 202, - 55 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "highLeverageModeConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 104, - 105, - 103, - 104, - 95, - 108, - 101, - 118, - 101, - 114, - 97, - 103, - 101, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "bool" - }, - { - "name": "currentUsers", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "updateIfRebalanceConfig", - "discriminator": [ - 142, - 245, - 249, - 66, - 249, - 181, - 22, - 83 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "ifRebalanceConfig", - "writable": true - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ifRebalanceConfigParams" - } - } - } - ] - }, - { - "name": "updateInitialAmmCacheInfo", - "discriminator": [ - 157, - 210, - 109, - 67, - 212, - 170, - 12, - 107 - ], - "accounts": [ - { - "name": "state", - "writable": true - }, - { - "name": "admin", - "signer": true - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateInitialPctToLiquidate", - "discriminator": [ - 210, - 133, - 225, - 128, - 194, - 50, - 13, - 109 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "initialPctToLiquidate", - "type": "u16" - } - ] - }, - { - "name": "updateInsuranceFundUnstakingPeriod", - "discriminator": [ - 44, - 69, - 43, - 226, - 204, - 223, - 202, - 52 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "insuranceFundUnstakingPeriod", - "type": "i64" - } - ] - }, - { - "name": "updateK", - "discriminator": [ - 72, - 98, - 9, - 139, - 129, - 229, - 172, - 56 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "sqrtK", - "type": "u128" - } - ] - }, - { - "name": "updateLiquidationDuration", - "discriminator": [ - 28, - 154, - 20, - 249, - 102, - 192, - 73, - 71 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "liquidationDuration", - "type": "u8" - } - ] - }, - { - "name": "updateLiquidationMarginBufferRatio", - "discriminator": [ - 132, - 224, - 243, - 160, - 154, - 82, - 97, - 215 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "liquidationMarginBufferRatio", - "type": "u32" - } - ] - }, - { - "name": "updateLpConstituentTargetBase", - "discriminator": [ - 157, - 65, - 50, - 207, - 59, - 236, - 161, - 110 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "ammConstituentMapping" - }, - { - "name": "constituentTargetBase", - "writable": true - }, - { - "name": "ammCache" - }, - { - "name": "lpPool" - } - ], - "args": [] - }, - { - "name": "updateLpPoolAum", - "discriminator": [ - 88, - 113, - 137, - 206, - 246, - 247, - 171, - 142 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "lpPool", - "writable": true - }, - { - "name": "constituentTargetBase", - "writable": true - }, - { - "name": "ammCache", - "writable": true - } - ], - "args": [] - }, - { - "name": "updateLpPoolParams", - "discriminator": [ - 217, - 92, - 2, - 255, - 27, - 167, - 178, - 81 - ], - "accounts": [ - { - "name": "lpPool", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "lpPoolParams", - "type": { - "defined": { - "name": "lpPoolParams" - } - } - } - ] - }, - { - "name": "updateOracleGuardRails", - "discriminator": [ - 131, - 112, - 10, - 59, - 32, - 54, - 40, - 164 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "oracleGuardRails", - "type": { - "defined": { - "name": "oracleGuardRails" - } - } - } - ] - }, - { - "name": "updatePerpAuctionDuration", - "discriminator": [ - 126, - 110, - 52, - 174, - 30, - 206, - 215, - 90 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "minPerpAuctionDuration", - "type": "u8" - } - ] - }, - { - "name": "updatePerpBidAskTwap", - "discriminator": [ - 247, - 23, - 255, - 65, - 212, - 90, - 221, - 194 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "keeperStats" - }, - { - "name": "authority", - "signer": true - } - ], - "args": [] - }, - { - "name": "updatePerpFeeStructure", - "discriminator": [ - 23, - 178, - 111, - 203, - 73, - 22, - 140, - 75 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "feeStructure", - "type": { - "defined": { - "name": "feeStructure" - } - } - } - ] - }, - { - "name": "updatePerpMarketAmmOracleTwap", - "discriminator": [ - 241, - 74, - 114, - 123, - 206, - 153, - 24, - 202 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [] - }, - { - "name": "updatePerpMarketAmmSpreadAdjustment", - "discriminator": [ - 155, - 195, - 149, - 43, - 220, - 82, - 173, - 205 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "ammSpreadAdjustment", - "type": "i8" - }, - { - "name": "ammInventorySpreadAdjustment", - "type": "i8" - }, - { - "name": "referencePriceOffset", - "type": "i32" - } - ] - }, - { - "name": "updatePerpMarketAmmSummaryStats", - "discriminator": [ - 122, - 101, - 249, - 238, - 209, - 9, - 241, - 245 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "spotMarket", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "account", - "path": "perpMarket" - } - ] - } - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updatePerpMarketSummaryStatsParams" - } - } - } - ] - }, - { - "name": "updatePerpMarketBaseSpread", - "discriminator": [ - 71, - 95, - 84, - 168, - 9, - 157, - 198, - 65 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "baseSpread", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketConcentrationCoef", - "discriminator": [ - 24, - 78, - 232, - 126, - 169, - 176, - 230, - 16 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "concentrationScale", - "type": "u128" - } - ] - }, - { - "name": "updatePerpMarketContractTier", - "discriminator": [ - 236, - 128, - 15, - 95, - 203, - 214, - 68, - 117 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "contractTier", - "type": { - "defined": { - "name": "contractTier" - } - } - } - ] - }, - { - "name": "updatePerpMarketCurveUpdateIntensity", - "discriminator": [ - 50, - 131, - 6, - 156, - 226, - 231, - 189, - 72 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "curveUpdateIntensity", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketExpiry", - "discriminator": [ - 44, - 221, - 227, - 151, - 131, - 140, - 22, - 110 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "expiryTs", - "type": "i64" - } - ] - }, - { - "name": "updatePerpMarketFeeAdjustment", - "discriminator": [ - 194, - 174, - 87, - 102, - 43, - 148, - 32, - 112 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "feeAdjustment", - "type": "i16" - } - ] - }, - { - "name": "updatePerpMarketFundingPeriod", - "discriminator": [ - 171, - 161, - 69, - 91, - 129, - 139, - 161, - 28 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "fundingPeriod", - "type": "i64" - } - ] - }, - { - "name": "updatePerpMarketHighLeverageMarginRatio", - "discriminator": [ - 88, - 112, - 86, - 49, - 24, - 116, - 74, - 157 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "marginRatioInitial", - "type": "u16" - }, - { - "name": "marginRatioMaintenance", - "type": "u16" - } - ] - }, - { - "name": "updatePerpMarketImfFactor", - "discriminator": [ - 207, - 194, - 56, - 132, - 35, - 67, - 71, - 244 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "imfFactor", - "type": "u32" - }, - { - "name": "unrealizedPnlImfFactor", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketLiquidationFee", - "discriminator": [ - 90, - 137, - 9, - 145, - 41, - 8, - 148, - 117 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "liquidatorFee", - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketLpPoolFeeTransferScalar", - "discriminator": [ - 94, - 228, - 237, - 109, - 100, - 185, - 4, - 81 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "optionalLpFeeTransferScalar", - "type": { - "option": "u8" - } - }, - { - "name": "optionalLpNetPnlTransferScalar", - "type": { - "option": "u8" - } - } - ] - }, - { - "name": "updatePerpMarketLpPoolId", - "discriminator": [ - 119, - 208, - 154, - 88, - 165, - 92, - 21, - 188 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "lpPoolId", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketLpPoolPausedOperations", - "discriminator": [ - 181, - 94, - 93, - 146, - 51, - 89, - 32, - 135 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "lpPausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketLpPoolStatus", - "discriminator": [ - 67, - 6, - 252, - 61, - 54, - 88, - 89, - 233 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [ - { - "name": "lpStatus", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketMarginRatio", - "discriminator": [ - 130, - 173, - 107, - 45, - 119, - 105, - 26, - 113 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "marginRatioInitial", - "type": "u32" - }, - { - "name": "marginRatioMaintenance", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketMaxFillReserveFraction", - "discriminator": [ - 19, - 172, - 114, - 154, - 42, - 135, - 161, - 133 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxFillReserveFraction", - "type": "u16" - } - ] - }, - { - "name": "updatePerpMarketMaxImbalances", - "discriminator": [ - 15, - 206, - 73, - 133, - 60, - 8, - 86, - 89 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "unrealizedMaxImbalance", - "type": "u64" - }, - { - "name": "maxRevenueWithdrawPerPeriod", - "type": "u64" - }, - { - "name": "quoteMaxInsurance", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketMaxOpenInterest", - "discriminator": [ - 194, - 79, - 149, - 224, - 246, - 102, - 186, - 140 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxOpenInterest", - "type": "u128" - } - ] - }, - { - "name": "updatePerpMarketMaxSlippageRatio", - "discriminator": [ - 235, - 37, - 40, - 196, - 70, - 146, - 54, - 201 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxSlippageRatio", - "type": "u16" - } - ] - }, - { - "name": "updatePerpMarketMaxSpread", - "discriminator": [ - 80, - 252, - 122, - 62, - 40, - 218, - 91, - 100 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxSpread", - "type": "u32" - } - ] - }, - { - "name": "updatePerpMarketMinOrderSize", - "discriminator": [ - 226, - 74, - 5, - 89, - 108, - 223, - 46, - 141 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "orderSize", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketName", - "discriminator": [ - 211, - 31, - 21, - 210, - 64, - 108, - 66, - 201 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "updatePerpMarketNumberOfUsers", - "discriminator": [ - 35, - 62, - 144, - 177, - 180, - 62, - 215, - 196 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "numberOfUsers", - "type": { - "option": "u32" - } - }, - { - "name": "numberOfUsersWithBase", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "updatePerpMarketOracle", - "discriminator": [ - 182, - 113, - 111, - 160, - 67, - 174, - 89, - 191 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "oldOracle" - }, - { - "name": "ammCache", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 109, - 109, - 95, - 99, - 97, - 99, - 104, - 101, - 95, - 115, - 101, - 101, - 100 - ] - } - ] - } - } - ], - "args": [ - { - "name": "oracle", - "type": "pubkey" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "skipInvariantCheck", - "type": "bool" - } - ] - }, - { - "name": "updatePerpMarketOracleLowRiskSlotDelayOverride", - "discriminator": [ - 124, - 108, - 147, - 229, - 109, - 117, - 123, - 3 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "oracleLowRiskSlotDelayOverride", - "type": "i8" - } - ] - }, - { - "name": "updatePerpMarketOracleSlotDelayOverride", - "discriminator": [ - 165, - 91, - 239, - 227, - 63, - 172, - 227, - 8 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "oracleSlotDelayOverride", - "type": "i8" - } - ] - }, - { - "name": "updatePerpMarketPausedOperations", - "discriminator": [ - 53, - 16, - 136, - 132, - 30, - 220, - 121, - 85 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketPnlPool", - "discriminator": [ - 50, - 202, - 249, - 224, - 166, - 184, - 13, - 143 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketProtectedMakerParams", - "discriminator": [ - 249, - 213, - 115, - 34, - 253, - 239, - 75, - 173 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "protectedMakerLimitPriceDivisor", - "type": { - "option": "u8" - } - }, - { - "name": "protectedMakerDynamicDivisor", - "type": { - "option": "u8" - } - } - ] - }, - { - "name": "updatePerpMarketReferencePriceOffsetDeadbandPct", - "discriminator": [ - 214, - 73, - 166, - 11, - 218, - 76, - 110, - 163 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "referencePriceOffsetDeadbandPct", - "type": "u8" - } - ] - }, - { - "name": "updatePerpMarketStatus", - "discriminator": [ - 71, - 201, - 175, - 122, - 255, - 207, - 196, - 207 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "marketStatus" - } - } - } - ] - }, - { - "name": "updatePerpMarketStepSizeAndTickSize", - "discriminator": [ - 231, - 255, - 97, - 25, - 146, - 139, - 174, - 4 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "stepSize", - "type": "u64" - }, - { - "name": "tickSize", - "type": "u64" - } - ] - }, - { - "name": "updatePerpMarketUnrealizedAssetWeight", - "discriminator": [ - 135, - 132, - 205, - 165, - 109, - 150, - 166, - 106 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [ - { - "name": "unrealizedInitialAssetWeight", - "type": "u32" - }, - { - "name": "unrealizedMaintenanceAssetWeight", - "type": "u32" - } - ] - }, - { - "name": "updatePrelaunchOracle", - "discriminator": [ - 220, - 132, - 27, - 27, - 233, - 220, - 61, - 219 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "perpMarket" - }, - { - "name": "oracle", - "writable": true - } - ], - "args": [] - }, - { - "name": "updatePrelaunchOracleParams", - "discriminator": [ - 98, - 205, - 147, - 243, - 18, - 75, - 83, - 207 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "prelaunchOracle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 101, - 108, - 97, - 117, - 110, - 99, - 104, - 95, - 111, - 114, - 97, - 99, - 108, - 101 - ] - }, - { - "kind": "arg", - "path": "params.perp_market_index" - } - ] - } - }, - { - "name": "perpMarket", - "writable": true - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "prelaunchOracleParams" - } - } - } - ] - }, - { - "name": "updateProtectedMakerModeConfig", - "discriminator": [ - 86, - 166, - 235, - 253, - 67, - 202, - 223, - 17 - ], - "accounts": [ - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "protectedMakerModeConfig", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 114, - 111, - 116, - 101, - 99, - 116, - 101, - 100, - 95, - 109, - 97, - 107, - 101, - 114, - 95, - 109, - 111, - 100, - 101, - 95, - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "state" - } - ], - "args": [ - { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "bool" - }, - { - "name": "currentUsers", - "type": { - "option": "u32" - } - } - ] - }, - { - "name": "updatePythPullOracle", - "discriminator": [ - 230, - 191, - 189, - 94, - 108, - 59, - 74, - 197 - ], - "accounts": [ - { - "name": "keeper", - "writable": true, - "signer": true - }, - { - "name": "pythSolanaReceiver", - "address": "G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha" - }, - { - "name": "encodedVaa" - }, - { - "name": "priceFeed", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 112, - 121, - 116, - 104, - 95, - 112, - 117, - 108, - 108 - ] - }, - { - "kind": "arg", - "path": "feedId" - } - ] - } - } - ], - "args": [ - { - "name": "feedId", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "params", - "type": "bytes" - } - ] - }, - { - "name": "updateSerumFulfillmentConfigStatus", - "discriminator": [ - 171, - 109, - 240, - 251, - 95, - 1, - 149, - 89 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "serumFulfillmentConfig", - "writable": true - }, - { - "name": "admin", - "writable": true, - "signer": true, - "relations": [ - "state" - ] - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - } - ] - }, - { - "name": "updateSpotAuctionDuration", - "discriminator": [ - 182, - 178, - 203, - 72, - 187, - 143, - 157, - 107 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "defaultSpotAuctionDuration", - "type": "u8" - } - ] - }, - { - "name": "updateSpotFeeStructure", - "discriminator": [ - 97, - 216, - 105, - 131, - 113, - 246, - 142, - 141 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "feeStructure", - "type": { - "defined": { - "name": "feeStructure" - } - } - } - ] - }, - { - "name": "updateSpotMarketAssetTier", - "discriminator": [ - 253, - 209, - 231, - 14, - 242, - 208, - 243, - 130 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "assetTier", - "type": { - "defined": { - "name": "assetTier" - } - } - } - ] - }, - { - "name": "updateSpotMarketBorrowRate", - "discriminator": [ - 71, - 239, - 236, - 153, - 210, - 62, - 254, - 76 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "optimalUtilization", - "type": "u32" - }, - { - "name": "optimalBorrowRate", - "type": "u32" - }, - { - "name": "maxBorrowRate", - "type": "u32" - }, - { - "name": "minBorrowRate", - "type": { - "option": "u8" - } - } - ] - }, - { - "name": "updateSpotMarketCumulativeInterest", - "discriminator": [ - 39, - 166, - 139, - 243, - 158, - 165, - 155, - 225 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "spotMarketVault", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "account", - "path": "spotMarket" - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateSpotMarketExpiry", - "discriminator": [ - 208, - 11, - 211, - 159, - 226, - 24, - 11, - 247 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "expiryTs", - "type": "i64" - } - ] - }, - { - "name": "updateSpotMarketFeeAdjustment", - "discriminator": [ - 148, - 182, - 3, - 126, - 157, - 114, - 220, - 99 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "feeAdjustment", - "type": "i16" - } - ] - }, - { - "name": "updateSpotMarketIfFactor", - "discriminator": [ - 147, - 30, - 224, - 34, - 18, - 230, - 105, - 4 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "userIfFactor", - "type": "u32" - }, - { - "name": "totalIfFactor", - "type": "u32" - } - ] - }, - { - "name": "updateSpotMarketIfPausedOperations", - "discriminator": [ - 101, - 215, - 79, - 74, - 59, - 41, - 79, - 12 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updateSpotMarketLiquidationFee", - "discriminator": [ - 11, - 13, - 255, - 53, - 56, - 136, - 104, - 177 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "liquidatorFee", - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "type": "u32" - } - ] - }, - { - "name": "updateSpotMarketMarginWeights", - "discriminator": [ - 109, - 33, - 87, - 195, - 255, - 36, - 6, - 81 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "initialAssetWeight", - "type": "u32" - }, - { - "name": "maintenanceAssetWeight", - "type": "u32" - }, - { - "name": "initialLiabilityWeight", - "type": "u32" - }, - { - "name": "maintenanceLiabilityWeight", - "type": "u32" - }, - { - "name": "imfFactor", - "type": "u32" - } - ] - }, - { - "name": "updateSpotMarketMaxTokenBorrows", - "discriminator": [ - 57, - 102, - 204, - 212, - 253, - 95, - 13, - 199 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxTokenBorrowsFraction", - "type": "u16" - } - ] - }, - { - "name": "updateSpotMarketMaxTokenDeposits", - "discriminator": [ - 56, - 191, - 79, - 18, - 26, - 121, - 80, - 208 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "maxTokenDeposits", - "type": "u64" - } - ] - }, - { - "name": "updateSpotMarketMinOrderSize", - "discriminator": [ - 93, - 128, - 11, - 119, - 26, - 20, - 181, - 50 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "orderSize", - "type": "u64" - } - ] - }, - { - "name": "updateSpotMarketName", - "discriminator": [ - 17, - 208, - 1, - 1, - 162, - 211, - 188, - 224 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "updateSpotMarketOracle", - "discriminator": [ - 114, - 184, - 102, - 37, - 246, - 186, - 180, - 99 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "oracle" - }, - { - "name": "oldOracle" - } - ], - "args": [ - { - "name": "oracle", - "type": "pubkey" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "skipInvariantCheck", - "type": "bool" - } - ] - }, - { - "name": "updateSpotMarketOrdersEnabled", - "discriminator": [ - 190, - 79, - 206, - 15, - 26, - 229, - 229, - 43 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "ordersEnabled", - "type": "bool" - } - ] - }, - { - "name": "updateSpotMarketPausedOperations", - "discriminator": [ - 100, - 61, - 153, - 81, - 180, - 12, - 6, - 248 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "pausedOperations", - "type": "u8" - } - ] - }, - { - "name": "updateSpotMarketPoolId", - "discriminator": [ - 22, - 213, - 197, - 160, - 139, - 193, - 81, - 149 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "poolId", - "type": "u8" - } - ] - }, - { - "name": "updateSpotMarketRevenueSettlePeriod", - "discriminator": [ - 81, - 92, - 126, - 41, - 250, - 225, - 156, - 219 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "revenueSettlePeriod", - "type": "i64" - } - ] - }, - { - "name": "updateSpotMarketScaleInitialAssetWeightStart", - "discriminator": [ - 217, - 204, - 204, - 118, - 204, - 130, - 225, - 147 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "scaleInitialAssetWeightStart", - "type": "u64" - } - ] - }, - { - "name": "updateSpotMarketStatus", - "discriminator": [ - 78, - 94, - 16, - 188, - 193, - 110, - 231, - 31 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "status", - "type": { - "defined": { - "name": "marketStatus" - } - } - } - ] - }, - { - "name": "updateSpotMarketStepSizeAndTickSize", - "discriminator": [ - 238, - 153, - 137, - 80, - 206, - 59, - 250, - 61 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "stepSize", - "type": "u64" - }, - { - "name": "tickSize", - "type": "u64" - } - ] - }, - { - "name": "updateStateMaxInitializeUserFee", - "discriminator": [ - 237, - 225, - 25, - 237, - 193, - 45, - 77, - 97 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "maxInitializeUserFee", - "type": "u16" - } - ] - }, - { - "name": "updateStateMaxNumberOfSubAccounts", - "discriminator": [ - 155, - 123, - 214, - 2, - 221, - 166, - 204, - 85 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "maxNumberOfSubAccounts", - "type": "u16" - } - ] - }, - { - "name": "updateStateSettlementDuration", - "discriminator": [ - 97, - 68, - 199, - 235, - 131, - 80, - 61, - 173 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state", - "writable": true - } - ], - "args": [ - { - "name": "settlementDuration", - "type": "u16" - } - ] - }, - { - "name": "updateUserCustomMarginRatio", - "discriminator": [ - 21, - 221, - 140, - 187, - 32, - 129, - 11, - 123 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "marginRatio", - "type": "u32" - } - ] - }, - { - "name": "updateUserDelegate", - "discriminator": [ - 139, - 205, - 141, - 141, - 113, - 36, - 94, - 187 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "delegate", - "type": "pubkey" - } - ] - }, - { - "name": "updateUserGovTokenInsuranceStake", - "discriminator": [ - 143, - 99, - 235, - 187, - 20, - 159, - 184, - 84 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 15, - 0 - ] - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "signer", - "signer": true - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 15, - 0 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateUserIdle", - "discriminator": [ - 253, - 133, - 67, - 22, - 103, - 161, - 20, - 100 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "filler", - "writable": true - }, - { - "name": "user", - "writable": true - } - ], - "args": [] - }, - { - "name": "updateUserMarginTradingEnabled", - "discriminator": [ - 194, - 92, - 204, - 223, - 246, - 188, - 31, - 203 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "marginTradingEnabled", - "type": "bool" - } - ] - }, - { - "name": "updateUserName", - "discriminator": [ - 135, - 25, - 185, - 56, - 165, - 53, - 34, - 136 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "updateUserPerpPositionCustomMarginRatio", - "discriminator": [ - 121, - 137, - 157, - 155, - 89, - 186, - 145, - 113 - ], - "accounts": [ - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "marginRatio", - "type": "u16" - } - ] - }, - { - "name": "updateUserPoolId", - "discriminator": [ - 219, - 86, - 73, - 106, - 56, - 218, - 128, - 109 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "poolId", - "type": "u8" - } - ] - }, - { - "name": "updateUserProtectedMakerOrders", - "discriminator": [ - 114, - 39, - 123, - 198, - 187, - 25, - 90, - 219 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "authority", - "signer": true - }, - { - "name": "protectedMakerModeConfig", - "writable": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "protectedMakerOrders", - "type": "bool" - } - ] - }, - { - "name": "updateUserQuoteAssetInsuranceStake", - "discriminator": [ - 251, - 101, - 156, - 7, - 2, - 63, - 30, - 23 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - }, - { - "name": "insuranceFundStake", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "signer", - "signer": true - }, - { - "name": "insuranceFundVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 117, - 114, - 97, - 110, - 99, - 101, - 95, - 102, - 117, - 110, - 100, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "const", - "value": [ - 0, - 0 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "updateUserReduceOnly", - "discriminator": [ - 199, - 71, - 42, - 67, - 144, - 19, - 86, - 109 - ], - "accounts": [ - { - "name": "user", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "authority" - }, - { - "kind": "arg", - "path": "subAccountId" - } - ] - } - }, - { - "name": "authority", - "signer": true - } - ], - "args": [ - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "reduceOnly", - "type": "bool" - } - ] - }, - { - "name": "updateUserStatsReferrerStatus", - "discriminator": [ - 174, - 154, - 72, - 42, - 191, - 148, - 145, - 205 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "userStats", - "writable": true - } - ], - "args": [] - }, - { - "name": "updateWithdrawGuardThreshold", - "discriminator": [ - 56, - 18, - 39, - 61, - 155, - 211, - 44, - 133 - ], - "accounts": [ - { - "name": "admin", - "signer": true, - "relations": [ - "state" - ] - }, - { - "name": "state" - }, - { - "name": "spotMarket", - "writable": true - } - ], - "args": [ - { - "name": "withdrawGuardThreshold", - "type": "u64" - } - ] - }, - { - "name": "viewLpPoolAddLiquidityFees", - "discriminator": [ - 80, - 66, - 226, - 161, - 70, - 142, - 119, - 84 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "inMarketMint" - }, - { - "name": "inConstituent", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "lpMint" - }, - { - "name": "constituentTargetBase" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u128" - } - ] - }, - { - "name": "viewLpPoolRemoveLiquidityFees", - "discriminator": [ - 47, - 12, - 9, - 102, - 12, - 226, - 197, - 89 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "lpPool" - }, - { - "name": "authority", - "signer": true - }, - { - "name": "outMarketMint" - }, - { - "name": "outConstituent", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "lpMint" - }, - { - "name": "constituentTargetBase" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" - } - ] - }, - { - "name": "viewLpPoolSwapFees", - "discriminator": [ - 126, - 189, - 109, - 189, - 170, - 156, - 3, - 46 - ], - "accounts": [ - { - "name": "driftSigner" - }, - { - "name": "state" - }, - { - "name": "lpPool" - }, - { - "name": "constituentTargetBase" - }, - { - "name": "constituentCorrelations" - }, - { - "name": "constituentInTokenAccount", - "writable": true - }, - { - "name": "constituentOutTokenAccount", - "writable": true - }, - { - "name": "inConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "inMarketIndex" - } - ] - } - }, - { - "name": "outConstituent", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 67, - 79, - 78, - 83, - 84, - 73, - 84, - 85, - 69, - 78, - 84 - ] - }, - { - "kind": "account", - "path": "lpPool" - }, - { - "kind": "arg", - "path": "outMarketIndex" - } - ] - } - }, - { - "name": "authority", - "signer": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inAmount", - "type": "u64" - }, - { - "name": "inTargetWeight", - "type": "i64" - }, - { - "name": "outTargetWeight", - "type": "i64" - } - ] - }, - { - "name": "withdraw", - "discriminator": [ - 183, - 18, - 70, - 156, - 148, - 109, - 161, - 34 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "user", - "writable": true - }, - { - "name": "userStats", - "writable": true - }, - { - "name": "authority", - "signer": true, - "relations": [ - "user", - "userStats" - ] - }, - { - "name": "spotMarketVault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 111, - 116, - 95, - 109, - 97, - 114, - 107, - 101, - 116, - 95, - 118, - 97, - 117, - 108, - 116 - ] - }, - { - "kind": "arg", - "path": "marketIndex" - } - ] - } - }, - { - "name": "driftSigner" - }, - { - "name": "userTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - } - ], - "args": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "reduceOnly", - "type": "bool" - } - ] - }, - { - "name": "withdrawFromProgramVault", - "discriminator": [ - 120, - 40, - 183, - 149, - 232, - 18, - 224, - 151 - ], - "accounts": [ - { - "name": "state" - }, - { - "name": "admin", - "writable": true, - "signer": true - }, - { - "name": "driftSigner" - }, - { - "name": "constituent", - "writable": true - }, - { - "name": "constituentTokenAccount", - "writable": true - }, - { - "name": "spotMarket", - "writable": true - }, - { - "name": "spotMarketVault", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "mint" - }, - { - "name": "oracle" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "zeroMmOracleFields", - "discriminator": [ - 192, - 226, - 39, - 204, - 207, - 120, - 148, - 250 - ], - "accounts": [ - { - "name": "admin", - "signer": true - }, - { - "name": "state" - }, - { - "name": "perpMarket", - "writable": true - } - ], - "args": [] - } - ], - "accounts": [ - { - "name": "ammCache", - "discriminator": [ - 213, - 114, - 161, - 56, - 20, - 22, - 2, - 59 - ] - }, - { - "name": "ammConstituentMapping", - "discriminator": [ - 254, - 89, - 5, - 173, - 66, - 54, - 214, - 247 - ] - }, - { - "name": "constituent", - "discriminator": [ - 0, - 61, - 36, - 35, - 177, - 76, - 216, - 205 - ] - }, - { - "name": "constituentCorrelations", - "discriminator": [ - 124, - 203, - 115, - 33, - 18, - 162, - 67, - 216 - ] - }, - { - "name": "constituentTargetBase", - "discriminator": [ - 255, - 142, - 134, - 71, - 125, - 66, - 198, - 99 - ] - }, - { - "name": "fuelOverflow", - "discriminator": [ - 182, - 64, - 231, - 177, - 226, - 142, - 69, - 58 - ] - }, - { - "name": "highLeverageModeConfig", - "discriminator": [ - 3, - 196, - 90, - 189, - 193, - 64, - 228, - 234 - ] - }, - { - "name": "ifRebalanceConfig", - "discriminator": [ - 214, - 84, - 40, - 251, - 107, - 144, - 173, - 239 - ] - }, - { - "name": "insuranceFundStake", - "discriminator": [ - 110, - 202, - 14, - 42, - 95, - 73, - 90, - 95 - ] - }, - { - "name": "lpPool", - "discriminator": [ - 228, - 152, - 141, - 224, - 161, - 170, - 11, - 89 - ] - }, - { - "name": "openbookV2FulfillmentConfig", - "discriminator": [ - 3, - 43, - 58, - 106, - 131, - 132, - 199, - 171 - ] - }, - { - "name": "perpMarket", - "discriminator": [ - 10, - 223, - 12, - 44, - 107, - 245, - 55, - 247 - ] - }, - { - "name": "phoenixV1FulfillmentConfig", - "discriminator": [ - 233, - 45, - 62, - 40, - 35, - 129, - 48, - 72 - ] - }, - { - "name": "prelaunchOracle", - "discriminator": [ - 92, - 14, - 139, - 234, - 72, - 244, - 68, - 26 - ] - }, - { - "name": "protectedMakerModeConfig", - "discriminator": [ - 47, - 86, - 90, - 9, - 224, - 255, - 10, - 69 - ] - }, - { - "name": "pythLazerOracle", - "discriminator": [ - 159, - 7, - 161, - 249, - 34, - 81, - 121, - 133 - ] - }, - { - "name": "referrerName", - "discriminator": [ - 105, - 133, - 170, - 110, - 52, - 42, - 28, - 182 - ] - }, - { - "name": "revenueShare", - "discriminator": [ - 55, - 40, - 228, - 7, - 139, - 52, - 180, - 110 - ] - }, - { - "name": "revenueShareEscrow", - "discriminator": [ - 98, - 167, - 3, - 46, - 74, - 177, - 173, - 252 - ] - }, - { - "name": "serumV3FulfillmentConfig", - "discriminator": [ - 65, - 160, - 197, - 112, - 239, - 168, - 103, - 185 - ] - }, - { - "name": "signedMsgUserOrders", - "discriminator": [ - 70, - 6, - 50, - 248, - 222, - 1, - 143, - 49 - ] - }, - { - "name": "signedMsgWsDelegates", - "discriminator": [ - 190, - 115, - 111, - 44, - 216, - 252, - 108, - 85 - ] - }, - { - "name": "spotMarket", - "discriminator": [ - 100, - 177, - 8, - 107, - 168, - 65, - 65, - 39 - ] - }, - { - "name": "state", - "discriminator": [ - 216, - 146, - 107, - 94, - 104, - 75, - 182, - 177 - ] - }, - { - "name": "user", - "discriminator": [ - 159, - 117, - 95, - 227, - 239, - 151, - 58, - 236 - ] - }, - { - "name": "userStats", - "discriminator": [ - 176, - 223, - 136, - 27, - 122, - 79, - 32, - 227 - ] - } - ], - "events": [ - { - "name": "curveRecord", - "discriminator": [ - 101, - 238, - 40, - 228, - 70, - 46, - 61, - 117 - ] - }, - { - "name": "deleteUserRecord", - "discriminator": [ - 71, - 111, - 190, - 118, - 7, - 3, - 132, - 222 - ] - }, - { - "name": "depositRecord", - "discriminator": [ - 180, - 241, - 218, - 207, - 102, - 135, - 44, - 134 - ] - }, - { - "name": "fuelSeasonRecord", - "discriminator": [ - 19, - 137, - 119, - 33, - 224, - 249, - 6, - 87 - ] - }, - { - "name": "fuelSweepRecord", - "discriminator": [ - 41, - 84, - 37, - 246, - 132, - 240, - 131, - 8 - ] - }, - { - "name": "fundingPaymentRecord", - "discriminator": [ - 8, - 59, - 96, - 20, - 137, - 201, - 56, - 95 - ] - }, - { - "name": "fundingRateRecord", - "discriminator": [ - 68, - 3, - 255, - 26, - 133, - 91, - 147, - 254 - ] - }, - { - "name": "insuranceFundRecord", - "discriminator": [ - 56, - 222, - 215, - 235, - 78, - 197, - 99, - 146 - ] - }, - { - "name": "insuranceFundStakeRecord", - "discriminator": [ - 68, - 66, - 156, - 7, - 216, - 148, - 250, - 114 - ] - }, - { - "name": "insuranceFundSwapRecord", - "discriminator": [ - 85, - 190, - 99, - 203, - 237, - 33, - 227, - 100 - ] - }, - { - "name": "lpBorrowLendDepositRecord", - "discriminator": [ - 242, - 181, - 11, - 56, - 243, - 61, - 79, - 210 - ] - }, - { - "name": "lpMintRedeemRecord", - "discriminator": [ - 53, - 178, - 142, - 73, - 78, - 91, - 91, - 8 - ] - }, - { - "name": "lpRecord", - "discriminator": [ - 101, - 22, - 54, - 38, - 178, - 13, - 142, - 111 - ] - }, - { - "name": "lpSettleRecord", - "discriminator": [ - 208, - 191, - 131, - 110, - 173, - 48, - 7, - 2 - ] - }, - { - "name": "lpSwapRecord", - "discriminator": [ - 159, - 62, - 130, - 196, - 96, - 79, - 176, - 254 - ] - }, - { - "name": "liquidationRecord", - "discriminator": [ - 127, - 17, - 0, - 108, - 182, - 13, - 231, - 53 - ] - }, - { - "name": "newUserRecord", - "discriminator": [ - 236, - 186, - 113, - 219, - 42, - 51, - 149, - 249 - ] - }, - { - "name": "orderActionRecord", - "discriminator": [ - 224, - 52, - 67, - 71, - 194, - 237, - 109, - 1 - ] - }, - { - "name": "orderRecord", - "discriminator": [ - 104, - 19, - 64, - 56, - 89, - 21, - 2, - 90 - ] - }, - { - "name": "revenueShareSettleRecord", - "discriminator": [ - 61, - 162, - 89, - 10, - 24, - 20, - 59, - 45 - ] - }, - { - "name": "settlePnlRecord", - "discriminator": [ - 57, - 68, - 105, - 26, - 119, - 198, - 213, - 89 - ] - }, - { - "name": "signedMsgOrderRecord", - "discriminator": [ - 211, - 197, - 25, - 18, - 142, - 86, - 113, - 27 - ] - }, - { - "name": "spotInterestRecord", - "discriminator": [ - 183, - 186, - 203, - 186, - 225, - 187, - 95, - 130 - ] - }, - { - "name": "spotMarketVaultDepositRecord", - "discriminator": [ - 178, - 217, - 23, - 188, - 127, - 190, - 32, - 73 - ] - }, - { - "name": "swapRecord", - "discriminator": [ - 162, - 187, - 123, - 194, - 138, - 56, - 250, - 241 - ] - }, - { - "name": "transferProtocolIfSharesToRevenuePoolRecord", - "discriminator": [ - 209, - 118, - 142, - 167, - 130, - 46, - 164, - 151 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "invalidSpotMarketAuthority", - "msg": "Invalid Spot Market Authority" - }, - { - "code": 6001, - "name": "invalidInsuranceFundAuthority", - "msg": "Clearing house not insurance fund authority" - }, - { - "code": 6002, - "name": "insufficientDeposit", - "msg": "Insufficient deposit" - }, - { - "code": 6003, - "name": "insufficientCollateral", - "msg": "Insufficient collateral" - }, - { - "code": 6004, - "name": "sufficientCollateral", - "msg": "Sufficient collateral" - }, - { - "code": 6005, - "name": "maxNumberOfPositions", - "msg": "Max number of positions taken" - }, - { - "code": 6006, - "name": "adminControlsPricesDisabled", - "msg": "Admin Controls Prices Disabled" - }, - { - "code": 6007, - "name": "marketDelisted", - "msg": "Market Delisted" - }, - { - "code": 6008, - "name": "marketIndexAlreadyInitialized", - "msg": "Market Index Already Initialized" - }, - { - "code": 6009, - "name": "userAccountAndUserPositionsAccountMismatch", - "msg": "User Account And User Positions Account Mismatch" - }, - { - "code": 6010, - "name": "userHasNoPositionInMarket", - "msg": "User Has No Position In Market" - }, - { - "code": 6011, - "name": "invalidInitialPeg", - "msg": "Invalid Initial Peg" - }, - { - "code": 6012, - "name": "invalidRepegRedundant", - "msg": "AMM repeg already configured with amt given" - }, - { - "code": 6013, - "name": "invalidRepegDirection", - "msg": "AMM repeg incorrect repeg direction" - }, - { - "code": 6014, - "name": "invalidRepegProfitability", - "msg": "AMM repeg out of bounds pnl" - }, - { - "code": 6015, - "name": "slippageOutsideLimit", - "msg": "Slippage Outside Limit Price" - }, - { - "code": 6016, - "name": "orderSizeTooSmall", - "msg": "Order Size Too Small" - }, - { - "code": 6017, - "name": "invalidUpdateK", - "msg": "Price change too large when updating K" - }, - { - "code": 6018, - "name": "adminWithdrawTooLarge", - "msg": "Admin tried to withdraw amount larger than fees collected" - }, - { - "code": 6019, - "name": "mathError", - "msg": "Math Error" - }, - { - "code": 6020, - "name": "bnConversionError", - "msg": "Conversion to u128/u64 failed with an overflow or underflow" - }, - { - "code": 6021, - "name": "clockUnavailable", - "msg": "Clock unavailable" - }, - { - "code": 6022, - "name": "unableToLoadOracle", - "msg": "Unable To Load Oracles" - }, - { - "code": 6023, - "name": "priceBandsBreached", - "msg": "Price Bands Breached" - }, - { - "code": 6024, - "name": "exchangePaused", - "msg": "Exchange is paused" - }, - { - "code": 6025, - "name": "invalidWhitelistToken", - "msg": "Invalid whitelist token" - }, - { - "code": 6026, - "name": "whitelistTokenNotFound", - "msg": "Whitelist token not found" - }, - { - "code": 6027, - "name": "invalidDiscountToken", - "msg": "Invalid discount token" - }, - { - "code": 6028, - "name": "discountTokenNotFound", - "msg": "Discount token not found" - }, - { - "code": 6029, - "name": "referrerNotFound", - "msg": "Referrer not found" - }, - { - "code": 6030, - "name": "referrerStatsNotFound", - "msg": "referrerNotFound" - }, - { - "code": 6031, - "name": "referrerMustBeWritable", - "msg": "referrerMustBeWritable" - }, - { - "code": 6032, - "name": "referrerStatsMustBeWritable", - "msg": "referrerMustBeWritable" - }, - { - "code": 6033, - "name": "referrerAndReferrerStatsAuthorityUnequal", - "msg": "referrerAndReferrerStatsAuthorityUnequal" - }, - { - "code": 6034, - "name": "invalidReferrer", - "msg": "invalidReferrer" - }, - { - "code": 6035, - "name": "invalidOracle", - "msg": "invalidOracle" - }, - { - "code": 6036, - "name": "oracleNotFound", - "msg": "oracleNotFound" - }, - { - "code": 6037, - "name": "liquidationsBlockedByOracle", - "msg": "Liquidations Blocked By Oracle" - }, - { - "code": 6038, - "name": "maxDeposit", - "msg": "Can not deposit more than max deposit" - }, - { - "code": 6039, - "name": "cantDeleteUserWithCollateral", - "msg": "Can not delete user that still has collateral" - }, - { - "code": 6040, - "name": "invalidFundingProfitability", - "msg": "AMM funding out of bounds pnl" - }, - { - "code": 6041, - "name": "castingFailure", - "msg": "Casting Failure" - }, - { - "code": 6042, - "name": "invalidOrder", - "msg": "invalidOrder" - }, - { - "code": 6043, - "name": "invalidOrderMaxTs", - "msg": "invalidOrderMaxTs" - }, - { - "code": 6044, - "name": "invalidOrderMarketType", - "msg": "invalidOrderMarketType" - }, - { - "code": 6045, - "name": "invalidOrderForInitialMarginReq", - "msg": "invalidOrderForInitialMarginReq" - }, - { - "code": 6046, - "name": "invalidOrderNotRiskReducing", - "msg": "invalidOrderNotRiskReducing" - }, - { - "code": 6047, - "name": "invalidOrderSizeTooSmall", - "msg": "invalidOrderSizeTooSmall" - }, - { - "code": 6048, - "name": "invalidOrderNotStepSizeMultiple", - "msg": "invalidOrderNotStepSizeMultiple" - }, - { - "code": 6049, - "name": "invalidOrderBaseQuoteAsset", - "msg": "invalidOrderBaseQuoteAsset" - }, - { - "code": 6050, - "name": "invalidOrderIoc", - "msg": "invalidOrderIoc" - }, - { - "code": 6051, - "name": "invalidOrderPostOnly", - "msg": "invalidOrderPostOnly" - }, - { - "code": 6052, - "name": "invalidOrderIocPostOnly", - "msg": "invalidOrderIocPostOnly" - }, - { - "code": 6053, - "name": "invalidOrderTrigger", - "msg": "invalidOrderTrigger" - }, - { - "code": 6054, - "name": "invalidOrderAuction", - "msg": "invalidOrderAuction" - }, - { - "code": 6055, - "name": "invalidOrderOracleOffset", - "msg": "invalidOrderOracleOffset" - }, - { - "code": 6056, - "name": "invalidOrderMinOrderSize", - "msg": "invalidOrderMinOrderSize" - }, - { - "code": 6057, - "name": "placePostOnlyLimitFailure", - "msg": "Failed to Place Post-Only Limit Order" - }, - { - "code": 6058, - "name": "userHasNoOrder", - "msg": "User has no order" - }, - { - "code": 6059, - "name": "orderAmountTooSmall", - "msg": "Order Amount Too Small" - }, - { - "code": 6060, - "name": "maxNumberOfOrders", - "msg": "Max number of orders taken" - }, - { - "code": 6061, - "name": "orderDoesNotExist", - "msg": "Order does not exist" - }, - { - "code": 6062, - "name": "orderNotOpen", - "msg": "Order not open" - }, - { - "code": 6063, - "name": "fillOrderDidNotUpdateState", - "msg": "fillOrderDidNotUpdateState" - }, - { - "code": 6064, - "name": "reduceOnlyOrderIncreasedRisk", - "msg": "Reduce only order increased risk" - }, - { - "code": 6065, - "name": "unableToLoadAccountLoader", - "msg": "Unable to load AccountLoader" - }, - { - "code": 6066, - "name": "tradeSizeTooLarge", - "msg": "Trade Size Too Large" - }, - { - "code": 6067, - "name": "userCantReferThemselves", - "msg": "User cant refer themselves" - }, - { - "code": 6068, - "name": "didNotReceiveExpectedReferrer", - "msg": "Did not receive expected referrer" - }, - { - "code": 6069, - "name": "couldNotDeserializeReferrer", - "msg": "Could not deserialize referrer" - }, - { - "code": 6070, - "name": "couldNotDeserializeReferrerStats", - "msg": "Could not deserialize referrer stats" - }, - { - "code": 6071, - "name": "userOrderIdAlreadyInUse", - "msg": "User Order Id Already In Use" - }, - { - "code": 6072, - "name": "noPositionsLiquidatable", - "msg": "No positions liquidatable" - }, - { - "code": 6073, - "name": "invalidMarginRatio", - "msg": "Invalid Margin Ratio" - }, - { - "code": 6074, - "name": "cantCancelPostOnlyOrder", - "msg": "Cant Cancel Post Only Order" - }, - { - "code": 6075, - "name": "invalidOracleOffset", - "msg": "invalidOracleOffset" - }, - { - "code": 6076, - "name": "cantExpireOrders", - "msg": "cantExpireOrders" - }, - { - "code": 6077, - "name": "couldNotLoadMarketData", - "msg": "couldNotLoadMarketData" - }, - { - "code": 6078, - "name": "perpMarketNotFound", - "msg": "perpMarketNotFound" - }, - { - "code": 6079, - "name": "invalidMarketAccount", - "msg": "invalidMarketAccount" - }, - { - "code": 6080, - "name": "unableToLoadPerpMarketAccount", - "msg": "unableToLoadMarketAccount" - }, - { - "code": 6081, - "name": "marketWrongMutability", - "msg": "marketWrongMutability" - }, - { - "code": 6082, - "name": "unableToCastUnixTime", - "msg": "unableToCastUnixTime" - }, - { - "code": 6083, - "name": "couldNotFindSpotPosition", - "msg": "couldNotFindSpotPosition" - }, - { - "code": 6084, - "name": "noSpotPositionAvailable", - "msg": "noSpotPositionAvailable" - }, - { - "code": 6085, - "name": "invalidSpotMarketInitialization", - "msg": "invalidSpotMarketInitialization" - }, - { - "code": 6086, - "name": "couldNotLoadSpotMarketData", - "msg": "couldNotLoadSpotMarketData" - }, - { - "code": 6087, - "name": "spotMarketNotFound", - "msg": "spotMarketNotFound" - }, - { - "code": 6088, - "name": "invalidSpotMarketAccount", - "msg": "invalidSpotMarketAccount" - }, - { - "code": 6089, - "name": "unableToLoadSpotMarketAccount", - "msg": "unableToLoadSpotMarketAccount" - }, - { - "code": 6090, - "name": "spotMarketWrongMutability", - "msg": "spotMarketWrongMutability" - }, - { - "code": 6091, - "name": "spotMarketInterestNotUpToDate", - "msg": "spotInterestNotUpToDate" - }, - { - "code": 6092, - "name": "spotMarketInsufficientDeposits", - "msg": "spotMarketInsufficientDeposits" - }, - { - "code": 6093, - "name": "userMustSettleTheirOwnPositiveUnsettledPnl", - "msg": "userMustSettleTheirOwnPositiveUnsettledPnl" - }, - { - "code": 6094, - "name": "cantUpdatePoolBalanceType", - "msg": "cantUpdatePoolBalanceType" - }, - { - "code": 6095, - "name": "insufficientCollateralForSettlingPnl", - "msg": "insufficientCollateralForSettlingPnl" - }, - { - "code": 6096, - "name": "ammNotUpdatedInSameSlot", - "msg": "ammNotUpdatedInSameSlot" - }, - { - "code": 6097, - "name": "auctionNotComplete", - "msg": "auctionNotComplete" - }, - { - "code": 6098, - "name": "makerNotFound", - "msg": "makerNotFound" - }, - { - "code": 6099, - "name": "makerStatsNotFound", - "msg": "makerNotFound" - }, - { - "code": 6100, - "name": "makerMustBeWritable", - "msg": "makerMustBeWritable" - }, - { - "code": 6101, - "name": "makerStatsMustBeWritable", - "msg": "makerMustBeWritable" - }, - { - "code": 6102, - "name": "makerOrderNotFound", - "msg": "makerOrderNotFound" - }, - { - "code": 6103, - "name": "couldNotDeserializeMaker", - "msg": "couldNotDeserializeMaker" - }, - { - "code": 6104, - "name": "couldNotDeserializeMakerStats", - "msg": "couldNotDeserializeMaker" - }, - { - "code": 6105, - "name": "auctionPriceDoesNotSatisfyMaker", - "msg": "auctionPriceDoesNotSatisfyMaker" - }, - { - "code": 6106, - "name": "makerCantFulfillOwnOrder", - "msg": "makerCantFulfillOwnOrder" - }, - { - "code": 6107, - "name": "makerOrderMustBePostOnly", - "msg": "makerOrderMustBePostOnly" - }, - { - "code": 6108, - "name": "cantMatchTwoPostOnlys", - "msg": "cantMatchTwoPostOnlys" - }, - { - "code": 6109, - "name": "orderBreachesOraclePriceLimits", - "msg": "orderBreachesOraclePriceLimits" - }, - { - "code": 6110, - "name": "orderMustBeTriggeredFirst", - "msg": "orderMustBeTriggeredFirst" - }, - { - "code": 6111, - "name": "orderNotTriggerable", - "msg": "orderNotTriggerable" - }, - { - "code": 6112, - "name": "orderDidNotSatisfyTriggerCondition", - "msg": "orderDidNotSatisfyTriggerCondition" - }, - { - "code": 6113, - "name": "positionAlreadyBeingLiquidated", - "msg": "positionAlreadyBeingLiquidated" - }, - { - "code": 6114, - "name": "positionDoesntHaveOpenPositionOrOrders", - "msg": "positionDoesntHaveOpenPositionOrOrders" - }, - { - "code": 6115, - "name": "allOrdersAreAlreadyLiquidations", - "msg": "allOrdersAreAlreadyLiquidations" - }, - { - "code": 6116, - "name": "cantCancelLiquidationOrder", - "msg": "cantCancelLiquidationOrder" - }, - { - "code": 6117, - "name": "userIsBeingLiquidated", - "msg": "userIsBeingLiquidated" - }, - { - "code": 6118, - "name": "liquidationsOngoing", - "msg": "liquidationsOngoing" - }, - { - "code": 6119, - "name": "wrongSpotBalanceType", - "msg": "wrongSpotBalanceType" - }, - { - "code": 6120, - "name": "userCantLiquidateThemself", - "msg": "userCantLiquidateThemself" - }, - { - "code": 6121, - "name": "invalidPerpPositionToLiquidate", - "msg": "invalidPerpPositionToLiquidate" - }, - { - "code": 6122, - "name": "invalidBaseAssetAmountForLiquidatePerp", - "msg": "invalidBaseAssetAmountForLiquidatePerp" - }, - { - "code": 6123, - "name": "invalidPositionLastFundingRate", - "msg": "invalidPositionLastFundingRate" - }, - { - "code": 6124, - "name": "invalidPositionDelta", - "msg": "invalidPositionDelta" - }, - { - "code": 6125, - "name": "userBankrupt", - "msg": "userBankrupt" - }, - { - "code": 6126, - "name": "userNotBankrupt", - "msg": "userNotBankrupt" - }, - { - "code": 6127, - "name": "userHasInvalidBorrow", - "msg": "userHasInvalidBorrow" - }, - { - "code": 6128, - "name": "dailyWithdrawLimit", - "msg": "dailyWithdrawLimit" - }, - { - "code": 6129, - "name": "defaultError", - "msg": "defaultError" - }, - { - "code": 6130, - "name": "insufficientLpTokens", - "msg": "Insufficient LP tokens" - }, - { - "code": 6131, - "name": "cantLpWithPerpPosition", - "msg": "Cant LP with a market position" - }, - { - "code": 6132, - "name": "unableToBurnLpTokens", - "msg": "Unable to burn LP tokens" - }, - { - "code": 6133, - "name": "tryingToRemoveLiquidityTooFast", - "msg": "Trying to remove liqudity too fast after adding it" - }, - { - "code": 6134, - "name": "invalidSpotMarketVault", - "msg": "Invalid Spot Market Vault" - }, - { - "code": 6135, - "name": "invalidSpotMarketState", - "msg": "Invalid Spot Market State" - }, - { - "code": 6136, - "name": "invalidSerumProgram", - "msg": "invalidSerumProgram" - }, - { - "code": 6137, - "name": "invalidSerumMarket", - "msg": "invalidSerumMarket" - }, - { - "code": 6138, - "name": "invalidSerumBids", - "msg": "invalidSerumBids" - }, - { - "code": 6139, - "name": "invalidSerumAsks", - "msg": "invalidSerumAsks" - }, - { - "code": 6140, - "name": "invalidSerumOpenOrders", - "msg": "invalidSerumOpenOrders" - }, - { - "code": 6141, - "name": "failedSerumCpi", - "msg": "failedSerumCpi" - }, - { - "code": 6142, - "name": "failedToFillOnExternalMarket", - "msg": "failedToFillOnExternalMarket" - }, - { - "code": 6143, - "name": "invalidFulfillmentConfig", - "msg": "invalidFulfillmentConfig" - }, - { - "code": 6144, - "name": "invalidFeeStructure", - "msg": "invalidFeeStructure" - }, - { - "code": 6145, - "name": "insufficientIfShares", - "msg": "Insufficient IF shares" - }, - { - "code": 6146, - "name": "marketActionPaused", - "msg": "the Market has paused this action" - }, - { - "code": 6147, - "name": "marketPlaceOrderPaused", - "msg": "the Market status doesnt allow placing orders" - }, - { - "code": 6148, - "name": "marketFillOrderPaused", - "msg": "the Market status doesnt allow filling orders" - }, - { - "code": 6149, - "name": "marketWithdrawPaused", - "msg": "the Market status doesnt allow withdraws" - }, - { - "code": 6150, - "name": "protectedAssetTierViolation", - "msg": "Action violates the Protected Asset Tier rules" - }, - { - "code": 6151, - "name": "isolatedAssetTierViolation", - "msg": "Action violates the Isolated Asset Tier rules" - }, - { - "code": 6152, - "name": "userCantBeDeleted", - "msg": "User Cant Be Deleted" - }, - { - "code": 6153, - "name": "reduceOnlyWithdrawIncreasedRisk", - "msg": "Reduce Only Withdraw Increased Risk" - }, - { - "code": 6154, - "name": "maxOpenInterest", - "msg": "Max Open Interest" - }, - { - "code": 6155, - "name": "cantResolvePerpBankruptcy", - "msg": "Cant Resolve Perp Bankruptcy" - }, - { - "code": 6156, - "name": "liquidationDoesntSatisfyLimitPrice", - "msg": "Liquidation Doesnt Satisfy Limit Price" - }, - { - "code": 6157, - "name": "marginTradingDisabled", - "msg": "Margin Trading Disabled" - }, - { - "code": 6158, - "name": "invalidMarketStatusToSettlePnl", - "msg": "Invalid Market Status to Settle Perp Pnl" - }, - { - "code": 6159, - "name": "perpMarketNotInSettlement", - "msg": "perpMarketNotInSettlement" - }, - { - "code": 6160, - "name": "perpMarketNotInReduceOnly", - "msg": "perpMarketNotInReduceOnly" - }, - { - "code": 6161, - "name": "perpMarketSettlementBufferNotReached", - "msg": "perpMarketSettlementBufferNotReached" - }, - { - "code": 6162, - "name": "perpMarketSettlementUserHasOpenOrders", - "msg": "perpMarketSettlementUserHasOpenOrders" - }, - { - "code": 6163, - "name": "perpMarketSettlementUserHasActiveLp", - "msg": "perpMarketSettlementUserHasActiveLp" - }, - { - "code": 6164, - "name": "unableToSettleExpiredUserPosition", - "msg": "unableToSettleExpiredUserPosition" - }, - { - "code": 6165, - "name": "unequalMarketIndexForSpotTransfer", - "msg": "unequalMarketIndexForSpotTransfer" - }, - { - "code": 6166, - "name": "invalidPerpPositionDetected", - "msg": "invalidPerpPositionDetected" - }, - { - "code": 6167, - "name": "invalidSpotPositionDetected", - "msg": "invalidSpotPositionDetected" - }, - { - "code": 6168, - "name": "invalidAmmDetected", - "msg": "invalidAmmDetected" - }, - { - "code": 6169, - "name": "invalidAmmForFillDetected", - "msg": "invalidAmmForFillDetected" - }, - { - "code": 6170, - "name": "invalidAmmLimitPriceOverride", - "msg": "invalidAmmLimitPriceOverride" - }, - { - "code": 6171, - "name": "invalidOrderFillPrice", - "msg": "invalidOrderFillPrice" - }, - { - "code": 6172, - "name": "spotMarketBalanceInvariantViolated", - "msg": "spotMarketBalanceInvariantViolated" - }, - { - "code": 6173, - "name": "spotMarketVaultInvariantViolated", - "msg": "spotMarketVaultInvariantViolated" - }, - { - "code": 6174, - "name": "invalidPda", - "msg": "invalidPda" - }, - { - "code": 6175, - "name": "invalidPdaSigner", - "msg": "invalidPdaSigner" - }, - { - "code": 6176, - "name": "revenueSettingsCannotSettleToIf", - "msg": "revenueSettingsCannotSettleToIf" - }, - { - "code": 6177, - "name": "noRevenueToSettleToIf", - "msg": "noRevenueToSettleToIf" - }, - { - "code": 6178, - "name": "noAmmPerpPnlDeficit", - "msg": "noAmmPerpPnlDeficit" - }, - { - "code": 6179, - "name": "sufficientPerpPnlPool", - "msg": "sufficientPerpPnlPool" - }, - { - "code": 6180, - "name": "insufficientPerpPnlPool", - "msg": "insufficientPerpPnlPool" - }, - { - "code": 6181, - "name": "perpPnlDeficitBelowThreshold", - "msg": "perpPnlDeficitBelowThreshold" - }, - { - "code": 6182, - "name": "maxRevenueWithdrawPerPeriodReached", - "msg": "maxRevenueWithdrawPerPeriodReached" - }, - { - "code": 6183, - "name": "maxIfWithdrawReached", - "msg": "invalidSpotPositionDetected" - }, - { - "code": 6184, - "name": "noIfWithdrawAvailable", - "msg": "noIfWithdrawAvailable" - }, - { - "code": 6185, - "name": "invalidIfUnstake", - "msg": "invalidIfUnstake" - }, - { - "code": 6186, - "name": "invalidIfUnstakeSize", - "msg": "invalidIfUnstakeSize" - }, - { - "code": 6187, - "name": "invalidIfUnstakeCancel", - "msg": "invalidIfUnstakeCancel" - }, - { - "code": 6188, - "name": "invalidIfForNewStakes", - "msg": "invalidIfForNewStakes" - }, - { - "code": 6189, - "name": "invalidIfRebase", - "msg": "invalidIfRebase" - }, - { - "code": 6190, - "name": "invalidInsuranceUnstakeSize", - "msg": "invalidInsuranceUnstakeSize" - }, - { - "code": 6191, - "name": "invalidOrderLimitPrice", - "msg": "invalidOrderLimitPrice" - }, - { - "code": 6192, - "name": "invalidIfDetected", - "msg": "invalidIfDetected" - }, - { - "code": 6193, - "name": "invalidAmmMaxSpreadDetected", - "msg": "invalidAmmMaxSpreadDetected" - }, - { - "code": 6194, - "name": "invalidConcentrationCoef", - "msg": "invalidConcentrationCoef" - }, - { - "code": 6195, - "name": "invalidSrmVault", - "msg": "invalidSrmVault" - }, - { - "code": 6196, - "name": "invalidVaultOwner", - "msg": "invalidVaultOwner" - }, - { - "code": 6197, - "name": "invalidMarketStatusForFills", - "msg": "invalidMarketStatusForFills" - }, - { - "code": 6198, - "name": "ifWithdrawRequestInProgress", - "msg": "ifWithdrawRequestInProgress" - }, - { - "code": 6199, - "name": "noIfWithdrawRequestInProgress", - "msg": "noIfWithdrawRequestInProgress" - }, - { - "code": 6200, - "name": "ifWithdrawRequestTooSmall", - "msg": "ifWithdrawRequestTooSmall" - }, - { - "code": 6201, - "name": "incorrectSpotMarketAccountPassed", - "msg": "incorrectSpotMarketAccountPassed" - }, - { - "code": 6202, - "name": "blockchainClockInconsistency", - "msg": "blockchainClockInconsistency" - }, - { - "code": 6203, - "name": "invalidIfSharesDetected", - "msg": "invalidIfSharesDetected" - }, - { - "code": 6204, - "name": "newLpSizeTooSmall", - "msg": "newLpSizeTooSmall" - }, - { - "code": 6205, - "name": "marketStatusInvalidForNewLp", - "msg": "marketStatusInvalidForNewLp" - }, - { - "code": 6206, - "name": "invalidMarkTwapUpdateDetected", - "msg": "invalidMarkTwapUpdateDetected" - }, - { - "code": 6207, - "name": "marketSettlementAttemptOnActiveMarket", - "msg": "marketSettlementAttemptOnActiveMarket" - }, - { - "code": 6208, - "name": "marketSettlementRequiresSettledLp", - "msg": "marketSettlementRequiresSettledLp" - }, - { - "code": 6209, - "name": "marketSettlementAttemptTooEarly", - "msg": "marketSettlementAttemptTooEarly" - }, - { - "code": 6210, - "name": "marketSettlementTargetPriceInvalid", - "msg": "marketSettlementTargetPriceInvalid" - }, - { - "code": 6211, - "name": "unsupportedSpotMarket", - "msg": "unsupportedSpotMarket" - }, - { - "code": 6212, - "name": "spotOrdersDisabled", - "msg": "spotOrdersDisabled" - }, - { - "code": 6213, - "name": "marketBeingInitialized", - "msg": "Market Being Initialized" - }, - { - "code": 6214, - "name": "invalidUserSubAccountId", - "msg": "Invalid Sub Account Id" - }, - { - "code": 6215, - "name": "invalidTriggerOrderCondition", - "msg": "Invalid Trigger Order Condition" - }, - { - "code": 6216, - "name": "invalidSpotPosition", - "msg": "Invalid Spot Position" - }, - { - "code": 6217, - "name": "cantTransferBetweenSameUserAccount", - "msg": "Cant transfer between same user account" - }, - { - "code": 6218, - "name": "invalidPerpPosition", - "msg": "Invalid Perp Position" - }, - { - "code": 6219, - "name": "unableToGetLimitPrice", - "msg": "Unable To Get Limit Price" - }, - { - "code": 6220, - "name": "invalidLiquidation", - "msg": "Invalid Liquidation" - }, - { - "code": 6221, - "name": "spotFulfillmentConfigDisabled", - "msg": "Spot Fulfillment Config Disabled" - }, - { - "code": 6222, - "name": "invalidMaker", - "msg": "Invalid Maker" - }, - { - "code": 6223, - "name": "failedUnwrap", - "msg": "Failed Unwrap" - }, - { - "code": 6224, - "name": "maxNumberOfUsers", - "msg": "Max Number Of Users" - }, - { - "code": 6225, - "name": "invalidOracleForSettlePnl", - "msg": "invalidOracleForSettlePnl" - }, - { - "code": 6226, - "name": "marginOrdersOpen", - "msg": "marginOrdersOpen" - }, - { - "code": 6227, - "name": "tierViolationLiquidatingPerpPnl", - "msg": "tierViolationLiquidatingPerpPnl" - }, - { - "code": 6228, - "name": "couldNotLoadUserData", - "msg": "couldNotLoadUserData" - }, - { - "code": 6229, - "name": "userWrongMutability", - "msg": "userWrongMutability" - }, - { - "code": 6230, - "name": "invalidUserAccount", - "msg": "invalidUserAccount" - }, - { - "code": 6231, - "name": "couldNotLoadUserStatsData", - "msg": "couldNotLoadUserData" - }, - { - "code": 6232, - "name": "userStatsWrongMutability", - "msg": "userWrongMutability" - }, - { - "code": 6233, - "name": "invalidUserStatsAccount", - "msg": "invalidUserAccount" - }, - { - "code": 6234, - "name": "userNotFound", - "msg": "userNotFound" - }, - { - "code": 6235, - "name": "unableToLoadUserAccount", - "msg": "unableToLoadUserAccount" - }, - { - "code": 6236, - "name": "userStatsNotFound", - "msg": "userStatsNotFound" - }, - { - "code": 6237, - "name": "unableToLoadUserStatsAccount", - "msg": "unableToLoadUserStatsAccount" - }, - { - "code": 6238, - "name": "userNotInactive", - "msg": "User Not Inactive" - }, - { - "code": 6239, - "name": "revertFill", - "msg": "revertFill" - }, - { - "code": 6240, - "name": "invalidMarketAccountforDeletion", - "msg": "Invalid MarketAccount for Deletion" - }, - { - "code": 6241, - "name": "invalidSpotFulfillmentParams", - "msg": "Invalid Spot Fulfillment Params" - }, - { - "code": 6242, - "name": "failedToGetMint", - "msg": "Failed to Get Mint" - }, - { - "code": 6243, - "name": "failedPhoenixCpi", - "msg": "failedPhoenixCpi" - }, - { - "code": 6244, - "name": "failedToDeserializePhoenixMarket", - "msg": "failedToDeserializePhoenixMarket" - }, - { - "code": 6245, - "name": "invalidPricePrecision", - "msg": "invalidPricePrecision" - }, - { - "code": 6246, - "name": "invalidPhoenixProgram", - "msg": "invalidPhoenixProgram" - }, - { - "code": 6247, - "name": "invalidPhoenixMarket", - "msg": "invalidPhoenixMarket" - }, - { - "code": 6248, - "name": "invalidSwap", - "msg": "invalidSwap" - }, - { - "code": 6249, - "name": "swapLimitPriceBreached", - "msg": "swapLimitPriceBreached" - }, - { - "code": 6250, - "name": "spotMarketReduceOnly", - "msg": "spotMarketReduceOnly" - }, - { - "code": 6251, - "name": "fundingWasNotUpdated", - "msg": "fundingWasNotUpdated" - }, - { - "code": 6252, - "name": "impossibleFill", - "msg": "impossibleFill" - }, - { - "code": 6253, - "name": "cantUpdatePerpBidAskTwap", - "msg": "cantUpdatePerpBidAskTwap" - }, - { - "code": 6254, - "name": "userReduceOnly", - "msg": "userReduceOnly" - }, - { - "code": 6255, - "name": "invalidMarginCalculation", - "msg": "invalidMarginCalculation" - }, - { - "code": 6256, - "name": "cantPayUserInitFee", - "msg": "cantPayUserInitFee" - }, - { - "code": 6257, - "name": "cantReclaimRent", - "msg": "cantReclaimRent" - }, - { - "code": 6258, - "name": "insuranceFundOperationPaused", - "msg": "insuranceFundOperationPaused" - }, - { - "code": 6259, - "name": "noUnsettledPnl", - "msg": "noUnsettledPnl" - }, - { - "code": 6260, - "name": "pnlPoolCantSettleUser", - "msg": "pnlPoolCantSettleUser" - }, - { - "code": 6261, - "name": "oracleNonPositive", - "msg": "oracleInvalid" - }, - { - "code": 6262, - "name": "oracleTooVolatile", - "msg": "oracleTooVolatile" - }, - { - "code": 6263, - "name": "oracleTooUncertain", - "msg": "oracleTooUncertain" - }, - { - "code": 6264, - "name": "oracleStaleForMargin", - "msg": "oracleStaleForMargin" - }, - { - "code": 6265, - "name": "oracleInsufficientDataPoints", - "msg": "oracleInsufficientDataPoints" - }, - { - "code": 6266, - "name": "oracleStaleForAmm", - "msg": "oracleStaleForAmm" - }, - { - "code": 6267, - "name": "unableToParsePullOracleMessage", - "msg": "Unable to parse pull oracle message" - }, - { - "code": 6268, - "name": "maxBorrows", - "msg": "Can not borow more than max borrows" - }, - { - "code": 6269, - "name": "oracleUpdatesNotMonotonic", - "msg": "Updates must be monotonically increasing" - }, - { - "code": 6270, - "name": "oraclePriceFeedMessageMismatch", - "msg": "Trying to update price feed with the wrong feed id" - }, - { - "code": 6271, - "name": "oracleUnsupportedMessageType", - "msg": "The message in the update must be a PriceFeedMessage" - }, - { - "code": 6272, - "name": "oracleDeserializeMessageFailed", - "msg": "Could not deserialize the message in the update" - }, - { - "code": 6273, - "name": "oracleWrongGuardianSetOwner", - "msg": "Wrong guardian set owner in update price atomic" - }, - { - "code": 6274, - "name": "oracleWrongWriteAuthority", - "msg": "Oracle post update atomic price feed account must be drift program" - }, - { - "code": 6275, - "name": "oracleWrongVaaOwner", - "msg": "Oracle vaa owner must be wormhole program" - }, - { - "code": 6276, - "name": "oracleTooManyPriceAccountUpdates", - "msg": "Multi updates must have 2 or fewer accounts passed in remaining accounts" - }, - { - "code": 6277, - "name": "oracleMismatchedVaaAndPriceUpdates", - "msg": "Don't have the same remaining accounts number and pyth updates left" - }, - { - "code": 6278, - "name": "oracleBadRemainingAccountPublicKey", - "msg": "Remaining account passed does not match oracle update derived pda" - }, - { - "code": 6279, - "name": "failedOpenbookV2cpi", - "msg": "failedOpenbookV2cpi" - }, - { - "code": 6280, - "name": "invalidOpenbookV2Program", - "msg": "invalidOpenbookV2Program" - }, - { - "code": 6281, - "name": "invalidOpenbookV2Market", - "msg": "invalidOpenbookV2Market" - }, - { - "code": 6282, - "name": "nonZeroTransferFee", - "msg": "Non zero transfer fee" - }, - { - "code": 6283, - "name": "liquidationOrderFailedToFill", - "msg": "Liquidation order failed to fill" - }, - { - "code": 6284, - "name": "invalidPredictionMarketOrder", - "msg": "Invalid prediction market order" - }, - { - "code": 6285, - "name": "invalidVerificationIxIndex", - "msg": "Ed25519 Ix must be before place and make SignedMsg order ix" - }, - { - "code": 6286, - "name": "sigVerificationFailed", - "msg": "SignedMsg message verificaiton failed" - }, - { - "code": 6287, - "name": "mismatchedSignedMsgOrderParamsMarketIndex", - "msg": "Market index mismatched b/w taker and maker SignedMsg order params" - }, - { - "code": 6288, - "name": "invalidSignedMsgOrderParam", - "msg": "Invalid SignedMsg order param" - }, - { - "code": 6289, - "name": "placeAndTakeOrderSuccessConditionFailed", - "msg": "Place and take order success condition failed" - }, - { - "code": 6290, - "name": "invalidHighLeverageModeConfig", - "msg": "Invalid High Leverage Mode Config" - }, - { - "code": 6291, - "name": "invalidRfqUserAccount", - "msg": "Invalid RFQ User Account" - }, - { - "code": 6292, - "name": "rfqUserAccountWrongMutability", - "msg": "RFQUserAccount should be mutable" - }, - { - "code": 6293, - "name": "rfqUserAccountFull", - "msg": "RFQUserAccount has too many active RFQs" - }, - { - "code": 6294, - "name": "rfqOrderNotFilled", - "msg": "RFQ order not filled as expected" - }, - { - "code": 6295, - "name": "invalidRfqOrder", - "msg": "RFQ orders must be jit makers" - }, - { - "code": 6296, - "name": "invalidRfqMatch", - "msg": "RFQ matches must be valid" - }, - { - "code": 6297, - "name": "invalidSignedMsgUserAccount", - "msg": "Invalid SignedMsg user account" - }, - { - "code": 6298, - "name": "signedMsgUserAccountWrongMutability", - "msg": "SignedMsg account wrong mutability" - }, - { - "code": 6299, - "name": "signedMsgUserOrdersAccountFull", - "msg": "SignedMsgUserAccount has too many active orders" - }, - { - "code": 6300, - "name": "signedMsgOrderDoesNotExist", - "msg": "Order with SignedMsg uuid does not exist" - }, - { - "code": 6301, - "name": "invalidSignedMsgOrderId", - "msg": "SignedMsg order id cannot be 0s" - }, - { - "code": 6302, - "name": "invalidPoolId", - "msg": "Invalid pool id" - }, - { - "code": 6303, - "name": "invalidProtectedMakerModeConfig", - "msg": "Invalid Protected Maker Mode Config" - }, - { - "code": 6304, - "name": "invalidPythLazerStorageOwner", - "msg": "Invalid pyth lazer storage owner" - }, - { - "code": 6305, - "name": "unverifiedPythLazerMessage", - "msg": "Verification of pyth lazer message failed" - }, - { - "code": 6306, - "name": "invalidPythLazerMessage", - "msg": "Invalid pyth lazer message" - }, - { - "code": 6307, - "name": "pythLazerMessagePriceFeedMismatch", - "msg": "Pyth lazer message does not correspond to correct fed id" - }, - { - "code": 6308, - "name": "invalidLiquidateSpotWithSwap", - "msg": "invalidLiquidateSpotWithSwap" - }, - { - "code": 6309, - "name": "signedMsgUserContextUserMismatch", - "msg": "User in SignedMsg message does not match user in ix context" - }, - { - "code": 6310, - "name": "userFuelOverflowThresholdNotMet", - "msg": "User fuel overflow threshold not met" - }, - { - "code": 6311, - "name": "fuelOverflowAccountNotFound", - "msg": "FuelOverflow account not found" - }, - { - "code": 6312, - "name": "invalidTransferPerpPosition", - "msg": "Invalid Transfer Perp Position" - }, - { - "code": 6313, - "name": "invalidSignedMsgUserOrdersResize", - "msg": "Invalid SignedMsgUserOrders resize" - }, - { - "code": 6314, - "name": "couldNotDeserializeHighLeverageModeConfig", - "msg": "Could not deserialize high leverage mode config" - }, - { - "code": 6315, - "name": "invalidIfRebalanceConfig", - "msg": "Invalid If Rebalance Config" - }, - { - "code": 6316, - "name": "invalidIfRebalanceSwap", - "msg": "Invalid If Rebalance Swap" - }, - { - "code": 6317, - "name": "invalidRevenueShareResize", - "msg": "Invalid RevenueShare resize" - }, - { - "code": 6318, - "name": "builderRevoked", - "msg": "Builder has been revoked" - }, - { - "code": 6319, - "name": "invalidBuilderFee", - "msg": "Builder fee is greater than max fee bps" - }, - { - "code": 6320, - "name": "revenueShareEscrowAuthorityMismatch", - "msg": "RevenueShareEscrow authority mismatch" - }, - { - "code": 6321, - "name": "revenueShareEscrowOrdersAccountFull", - "msg": "RevenueShareEscrow has too many active orders" - }, - { - "code": 6322, - "name": "invalidRevenueShareAccount", - "msg": "Invalid RevenueShareAccount" - }, - { - "code": 6323, - "name": "cannotRevokeBuilderWithOpenOrders", - "msg": "Cannot revoke builder with open orders" - }, - { - "code": 6324, - "name": "unableToLoadRevenueShareAccount", - "msg": "Unable to load builder account" - }, - { - "code": 6325, - "name": "invalidConstituent", - "msg": "Invalid Constituent" - }, - { - "code": 6326, - "name": "invalidAmmConstituentMappingArgument", - "msg": "Invalid Amm Constituent Mapping argument" - }, - { - "code": 6327, - "name": "constituentNotFound", - "msg": "Constituent not found" - }, - { - "code": 6328, - "name": "constituentCouldNotLoad", - "msg": "Constituent could not load" - }, - { - "code": 6329, - "name": "constituentWrongMutability", - "msg": "Constituent wrong mutability" - }, - { - "code": 6330, - "name": "wrongNumberOfConstituents", - "msg": "Wrong number of constituents passed to instruction" - }, - { - "code": 6331, - "name": "insufficientConstituentTokenBalance", - "msg": "Insufficient constituent token balance" - }, - { - "code": 6332, - "name": "ammCacheStale", - "msg": "Amm Cache data too stale" - }, - { - "code": 6333, - "name": "lpPoolAumDelayed", - "msg": "LP Pool AUM not updated recently" - }, - { - "code": 6334, - "name": "constituentOracleStale", - "msg": "Constituent oracle is stale" - }, - { - "code": 6335, - "name": "lpInvariantFailed", - "msg": "LP Invariant failed" - }, - { - "code": 6336, - "name": "invalidConstituentDerivativeWeights", - "msg": "Invalid constituent derivative weights" - }, - { - "code": 6337, - "name": "maxDlpAumBreached", - "msg": "Max DLP AUM Breached" - }, - { - "code": 6338, - "name": "settleLpPoolDisabled", - "msg": "Settle Lp Pool Disabled" - }, - { - "code": 6339, - "name": "mintRedeemLpPoolDisabled", - "msg": "Mint/Redeem Lp Pool Disabled" - }, - { - "code": 6340, - "name": "lpPoolSettleInvariantBreached", - "msg": "Settlement amount exceeded" - }, - { - "code": 6341, - "name": "invalidConstituentOperation", - "msg": "Invalid constituent operation" - }, - { - "code": 6342, - "name": "unauthorized", - "msg": "Unauthorized for operation" - }, - { - "code": 6343, - "name": "invalidLpPoolId", - "msg": "Invalid Lp Pool Id for Operation" - }, - { - "code": 6344, - "name": "marketIndexNotFoundAmmCache", - "msg": "marketIndexNotFoundAmmCache" - } - ], - "types": [ - { - "name": "amm", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "oracle", - "docs": [ - "oracle price data public key" - ], - "type": "pubkey" - }, - { - "name": "historicalOracleData", - "docs": [ - "stores historically witnessed oracle data" - ], - "type": { - "defined": { - "name": "historicalOracleData" - } - } - }, - { - "name": "baseAssetAmountPerLp", - "docs": [ - "accumulated base asset amount since inception per lp share", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteAssetAmountPerLp", - "docs": [ - "accumulated quote asset amount since inception per lp share", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "feePool", - "docs": [ - "partition of fees from perp market trading moved from pnl settlements" - ], - "type": { - "defined": { - "name": "poolBalance" - } - } - }, - { - "name": "baseAssetReserve", - "docs": [ - "`x` reserves for constant product mm formula (x * y = k)", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "quoteAssetReserve", - "docs": [ - "`y` reserves for constant product mm formula (x * y = k)", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "concentrationCoef", - "docs": [ - "determines how close the min/max base asset reserve sit vs base reserves", - "allow for decreasing slippage without increasing liquidity and v.v.", - "precision: PERCENTAGE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "minBaseAssetReserve", - "docs": [ - "minimum base_asset_reserve allowed before AMM is unavailable", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "maxBaseAssetReserve", - "docs": [ - "maximum base_asset_reserve allowed before AMM is unavailable", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "sqrtK", - "docs": [ - "`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "pegMultiplier", - "docs": [ - "normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced", - "precision: PEG_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "terminalQuoteAssetReserve", - "docs": [ - "y when market is balanced. stored to save computation", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "baseAssetAmountLong", - "docs": [ - "always non-negative. tracks number of total longs in market (regardless of counterparty)", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "baseAssetAmountShort", - "docs": [ - "always non-positive. tracks number of total shorts in market (regardless of counterparty)", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "baseAssetAmountWithAmm", - "docs": [ - "tracks net position (longs-shorts) in market with AMM as counterparty", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "baseAssetAmountWithUnsettledLp", - "docs": [ - "tracks net position (longs-shorts) in market with LPs as counterparty", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "maxOpenInterest", - "docs": [ - "max allowed open interest, blocks trades that breach this value", - "precision: BASE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "quoteAssetAmount", - "docs": [ - "sum of all user's perp quote_asset_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteEntryAmountLong", - "docs": [ - "sum of all long user's quote_entry_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteEntryAmountShort", - "docs": [ - "sum of all short user's quote_entry_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteBreakEvenAmountLong", - "docs": [ - "sum of all long user's quote_break_even_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "quoteBreakEvenAmountShort", - "docs": [ - "sum of all short user's quote_break_even_amount in market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "userLpShares", - "docs": [ - "total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastFundingRate", - "docs": [ - "last funding rate in this perp market (unit is quote per base)", - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastFundingRateLong", - "docs": [ - "last funding rate for longs in this perp market (unit is quote per base)", - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastFundingRateShort", - "docs": [ - "last funding rate for shorts in this perp market (unit is quote per base)", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "last24hAvgFundingRate", - "docs": [ - "estimate of last 24h of funding rate perp market (unit is quote per base)", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "totalFee", - "docs": [ - "total fees collected by this perp market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "totalMmFee", - "docs": [ - "total fees collected by the vAMM's bid/ask spread", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "totalExchangeFee", - "docs": [ - "total fees collected by exchange fee schedule", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalFeeMinusDistributions", - "docs": [ - "total fees minus any recognized upnl and pool withdraws", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "totalFeeWithdrawn", - "docs": [ - "sum of all fees from fee pool withdrawn to revenue pool", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalLiquidationFee", - "docs": [ - "all fees collected by market for liquidations", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeFundingRateLong", - "docs": [ - "accumulated funding rate for longs since inception in market" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "cumulativeFundingRateShort", - "docs": [ - "accumulated funding rate for shorts since inception in market" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "totalSocialLoss", - "docs": [ - "accumulated social loss paid by users since inception in market" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "askBaseAssetReserve", - "docs": [ - "transformed base_asset_reserve for users going long", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "askQuoteAssetReserve", - "docs": [ - "transformed quote_asset_reserve for users going long", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "bidBaseAssetReserve", - "docs": [ - "transformed base_asset_reserve for users going short", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "bidQuoteAssetReserve", - "docs": [ - "transformed quote_asset_reserve for users going short", - "precision: AMM_RESERVE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastOracleNormalisedPrice", - "docs": [ - "the last seen oracle price partially shrunk toward the amm reserve price", - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastOracleReservePriceSpreadPct", - "docs": [ - "the gap between the oracle price and the reserve price = y * peg_multiplier / x" - ], - "type": "i64" - }, - { - "name": "lastBidPriceTwap", - "docs": [ - "average estimate of bid price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastAskPriceTwap", - "docs": [ - "average estimate of ask price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastMarkPriceTwap", - "docs": [ - "average estimate of (bid+ask)/2 price over funding_period", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastMarkPriceTwap5min", - "docs": [ - "average estimate of (bid+ask)/2 price over FIVE_MINUTES" - ], - "type": "u64" - }, - { - "name": "lastUpdateSlot", - "docs": [ - "the last blockchain slot the amm was updated" - ], - "type": "u64" - }, - { - "name": "lastOracleConfPct", - "docs": [ - "the pct size of the oracle confidence interval", - "precision: PERCENTAGE_PRECISION" - ], - "type": "u64" - }, - { - "name": "netRevenueSinceLastFunding", - "docs": [ - "the total_fee_minus_distribution change since the last funding update", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastFundingRateTs", - "docs": [ - "the last funding rate update unix_timestamp" - ], - "type": "i64" - }, - { - "name": "fundingPeriod", - "docs": [ - "the periodicity of the funding rate updates" - ], - "type": "i64" - }, - { - "name": "orderStepSize", - "docs": [ - "the base step size (increment) of orders", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "orderTickSize", - "docs": [ - "the price tick size of orders", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "minOrderSize", - "docs": [ - "the minimum base size of an order", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "mmOracleSlot", - "docs": [ - "the max base size a single user can have", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "volume24h", - "docs": [ - "estimated total of volume in market", - "QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "longIntensityVolume", - "docs": [ - "the volume intensity of long fills against AMM" - ], - "type": "u64" - }, - { - "name": "shortIntensityVolume", - "docs": [ - "the volume intensity of short fills against AMM" - ], - "type": "u64" - }, - { - "name": "lastTradeTs", - "docs": [ - "the blockchain unix timestamp at the time of the last trade" - ], - "type": "i64" - }, - { - "name": "markStd", - "docs": [ - "estimate of standard deviation of the fill (mark) prices", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "oracleStd", - "docs": [ - "estimate of standard deviation of the oracle price at each update", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastMarkPriceTwapTs", - "docs": [ - "the last unix_timestamp the mark twap was updated" - ], - "type": "i64" - }, - { - "name": "baseSpread", - "docs": [ - "the minimum spread the AMM can quote. also used as step size for some spread logic increases." - ], - "type": "u32" - }, - { - "name": "maxSpread", - "docs": [ - "the maximum spread the AMM can quote" - ], - "type": "u32" - }, - { - "name": "longSpread", - "docs": [ - "the spread for asks vs the reserve price" - ], - "type": "u32" - }, - { - "name": "shortSpread", - "docs": [ - "the spread for bids vs the reserve price" - ], - "type": "u32" - }, - { - "name": "mmOraclePrice", - "docs": [ - "MM oracle price" - ], - "type": "i64" - }, - { - "name": "maxFillReserveFraction", - "docs": [ - "the fraction of total available liquidity a single fill on the AMM can consume" - ], - "type": "u16" - }, - { - "name": "maxSlippageRatio", - "docs": [ - "the maximum slippage a single fill on the AMM can push" - ], - "type": "u16" - }, - { - "name": "curveUpdateIntensity", - "docs": [ - "the update intensity of AMM formulaic updates (adjusting k). 0-100" - ], - "type": "u8" - }, - { - "name": "ammJitIntensity", - "docs": [ - "the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.", - "(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM." - ], - "type": "u8" - }, - { - "name": "oracleSource", - "docs": [ - "the oracle provider information. used to decode/scale the oracle public key" - ], - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "lastOracleValid", - "docs": [ - "tracks whether the oracle was considered valid at the last AMM update" - ], - "type": "bool" - }, - { - "name": "targetBaseAssetAmountPerLp", - "docs": [ - "the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split", - "precision: BASE_PRECISION" - ], - "type": "i32" - }, - { - "name": "perLpBase", - "docs": [ - "expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)" - ], - "type": "i8" - }, - { - "name": "oracleLowRiskSlotDelayOverride", - "docs": [ - "the override for the state.min_perp_auction_duration", - "0 is no override, -1 is disable speed bump, 1-100 is literal speed bump" - ], - "type": "i8" - }, - { - "name": "ammSpreadAdjustment", - "docs": [ - "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" - ], - "type": "i8" - }, - { - "name": "oracleSlotDelayOverride", - "type": "i8" - }, - { - "name": "mmOracleSequenceId", - "type": "u64" - }, - { - "name": "netUnsettledFundingPnl", - "type": "i64" - }, - { - "name": "quoteAssetAmountWithUnsettledLp", - "type": "i64" - }, - { - "name": "referencePriceOffset", - "type": "i32" - }, - { - "name": "ammInventorySpreadAdjustment", - "docs": [ - "signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)" - ], - "type": "i8" - }, - { - "name": "referencePriceOffsetDeadbandPct", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 2 - ] - } - }, - { - "name": "lastFundingOracleTwap", - "type": "i64" - } - ] - } - }, - { - "name": "addAmmConstituentMappingDatum", - "type": { - "kind": "struct", - "fields": [ - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "weight", - "type": "i64" - } - ] - } - }, - { - "name": "ammCache", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "cache", - "type": { - "vec": { - "defined": { - "name": "cacheInfo" - } - } - } - } - ] - } - }, - { - "name": "ammConstituentDatum", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "lastSlot", - "type": "u64" - }, - { - "name": "weight", - "docs": [ - "PERCENTAGE_PRECISION. The weight this constituent has on the perp market" - ], - "type": "i64" - } - ] - } - }, - { - "name": "ammConstituentMapping", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "lpPool", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "weights", - "type": { - "vec": { - "defined": { - "name": "ammConstituentDatum" - } - } - } - } - ] - } - }, - { - "name": "assetTier", - "type": { - "kind": "enum", - "variants": [ - { - "name": "collateral" - }, - { - "name": "protected" - }, - { - "name": "cross" - }, - { - "name": "isolated" - }, - { - "name": "unlisted" - } - ] - } - }, - { - "name": "builderInfo", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "maxFeeTenthBps", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 6 - ] - } - } - ] - } - }, - { - "name": "cacheInfo", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "oracle", - "type": "pubkey" - }, - { - "name": "lastFeePoolTokenAmount", - "type": "u128" - }, - { - "name": "lastNetPnlPoolTokenAmount", - "type": "i128" - }, - { - "name": "lastExchangeFees", - "type": "u128" - }, - { - "name": "lastSettleAmmExFees", - "type": "u128" - }, - { - "name": "lastSettleAmmPnl", - "type": "i128" - }, - { - "name": "position", - "docs": [ - "BASE PRECISION" - ], - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "lastSettleAmount", - "type": "u64" - }, - { - "name": "lastSettleSlot", - "type": "u64" - }, - { - "name": "lastSettleTs", - "type": "i64" - }, - { - "name": "quoteOwedFromLpPool", - "type": "i64" - }, - { - "name": "ammInventoryLimit", - "type": "i64" - }, - { - "name": "oraclePrice", - "type": "i64" - }, - { - "name": "oracleSlot", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "oracleSource", - "type": "u8" - }, - { - "name": "oracleValidity", - "type": "u8" - }, - { - "name": "lpStatusForPerpMarket", - "type": "u8" - }, - { - "name": "ammPositionScalar", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 34 - ] - } - } - ] - } - }, - { - "name": "constituent", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "address of the constituent" - ], - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "lpPool", - "type": "pubkey" - }, - { - "name": "vault", - "type": "pubkey" - }, - { - "name": "totalSwapFees", - "docs": [ - "total fees received by the constituent. Positive = fees received, Negative = fees paid" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "spotBalance", - "docs": [ - "spot borrow-lend balance for constituent" - ], - "type": { - "defined": { - "name": "constituentSpotBalance" - } - } - }, - { - "name": "lastSpotBalanceTokenAmount", - "type": "i64" - }, - { - "name": "cumulativeSpotInterestAccruedTokenAmount", - "type": "i64" - }, - { - "name": "maxWeightDeviation", - "docs": [ - "max deviation from target_weight allowed for the constituent", - "precision: PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "swapFeeMin", - "docs": [ - "min fee charged on swaps to/from this constituent", - "precision: PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "swapFeeMax", - "docs": [ - "max fee charged on swaps to/from this constituent", - "precision: PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "maxBorrowTokenAmount", - "docs": [ - "Max Borrow amount:", - "precision: token precision" - ], - "type": "u64" - }, - { - "name": "vaultTokenBalance", - "docs": [ - "ata token balance in token precision" - ], - "type": "u64" - }, - { - "name": "lastOraclePrice", - "type": "i64" - }, - { - "name": "lastOracleSlot", - "type": "u64" - }, - { - "name": "oracleStalenessThreshold", - "docs": [ - "Delay allowed for valid AUM calculation" - ], - "type": "u64" - }, - { - "name": "flashLoanInitialTokenAmount", - "type": "u64" - }, - { - "name": "nextSwapId", - "docs": [ - "Every swap to/from this constituent has a monotonically increasing id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "derivativeWeight", - "docs": [ - "percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight" - ], - "type": "u64" - }, - { - "name": "volatility", - "type": "u64" - }, - { - "name": "constituentDerivativeDepegThreshold", - "type": "u64" - }, - { - "name": "constituentDerivativeIndex", - "docs": [ - "The `constituent_index` of the parent constituent. -1 if it is a parent index", - "Example: if in a pool with SOL (parent) and dSOL (derivative),", - "SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,", - "dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1" - ], - "type": "i16" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "decimals", - "type": "u8" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "vaultBump", - "type": "u8" - }, - { - "name": "gammaInventory", - "type": "u8" - }, - { - "name": "gammaExecution", - "type": "u8" - }, - { - "name": "xi", - "type": "u8" - }, - { - "name": "status", - "type": "u8" - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 162 - ] - } - } - ] - } - }, - { - "name": "constituentCorrelations", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "lpPool", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "correlations", - "type": { - "vec": "i64" - } - } - ] - } - }, - { - "name": "constituentParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxWeightDeviation", - "type": { - "option": "i64" - } - }, - { - "name": "swapFeeMin", - "type": { - "option": "i64" - } - }, - { - "name": "swapFeeMax", - "type": { - "option": "i64" - } - }, - { - "name": "maxBorrowTokenAmount", - "type": { - "option": "u64" - } - }, - { - "name": "oracleStalenessThreshold", - "type": { - "option": "u64" - } - }, - { - "name": "costToTradeBps", - "type": { - "option": "i32" - } - }, - { - "name": "constituentDerivativeIndex", - "type": { - "option": "i16" - } - }, - { - "name": "derivativeWeight", - "type": { - "option": "u64" - } - }, - { - "name": "volatility", - "type": { - "option": "u64" - } - }, - { - "name": "gammaExecution", - "type": { - "option": "u8" - } - }, - { - "name": "gammaInventory", - "type": { - "option": "u8" - } - }, - { - "name": "xi", - "type": { - "option": "u8" - } - } - ] - } - }, - { - "name": "constituentSpotBalance", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "scaledBalance", - "docs": [ - "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", - "interest of corresponding market.", - "precision: token precision" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeDeposits", - "docs": [ - "The cumulative deposits/borrows a user has made into a market", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "marketIndex", - "docs": [ - "The market index of the corresponding spot market" - ], - "type": "u16" - }, - { - "name": "balanceType", - "docs": [ - "Whether the position is deposit or borrow" - ], - "type": { - "defined": { - "name": "spotBalanceType" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 5 - ] - } - } - ] - } - }, - { - "name": "constituentTargetBase", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "lpPool", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "targets", - "type": { - "vec": { - "defined": { - "name": "targetsDatum" - } - } - } - } - ] - } - }, - { - "name": "contractTier", - "type": { - "kind": "enum", - "variants": [ - { - "name": "a" - }, - { - "name": "b" - }, - { - "name": "c" - }, - { - "name": "speculative" - }, - { - "name": "highlySpeculative" - }, - { - "name": "isolated" - } - ] - } - }, - { - "name": "contractType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "perpetual" - }, - { - "name": "future" - }, - { - "name": "prediction" - } - ] - } - }, - { - "name": "curveRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "recordId", - "type": "u64" - }, - { - "name": "pegMultiplierBefore", - "type": "u128" - }, - { - "name": "baseAssetReserveBefore", - "type": "u128" - }, - { - "name": "quoteAssetReserveBefore", - "type": "u128" - }, - { - "name": "sqrtKBefore", - "type": "u128" - }, - { - "name": "pegMultiplierAfter", - "type": "u128" - }, - { - "name": "baseAssetReserveAfter", - "type": "u128" - }, - { - "name": "quoteAssetReserveAfter", - "type": "u128" - }, - { - "name": "sqrtKAfter", - "type": "u128" - }, - { - "name": "baseAssetAmountLong", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "u128" - }, - { - "name": "baseAssetAmountShort", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "u128" - }, - { - "name": "baseAssetAmountWithAmm", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i128" - }, - { - "name": "totalFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i128" - }, - { - "name": "totalFeeMinusDistributions", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i128" - }, - { - "name": "adjustmentCost", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i128" - }, - { - "name": "oraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "fillRecord", - "type": "u128" - }, - { - "name": "numberOfUsers", - "type": "u32" - }, - { - "name": "marketIndex", - "type": "u16" - } - ] - } - }, - { - "name": "deleteUserRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "docs": [ - "unix_timestamp of action" - ], - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "keeper", - "type": { - "option": "pubkey" - } - } - ] - } - }, - { - "name": "depositDirection", - "type": { - "kind": "enum", - "variants": [ - { - "name": "deposit" - }, - { - "name": "withdraw" - } - ] - } - }, - { - "name": "depositExplanation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "none" - }, - { - "name": "transfer" - }, - { - "name": "borrow" - }, - { - "name": "repayBorrow" - }, - { - "name": "reward" - } - ] - } - }, - { - "name": "depositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "docs": [ - "unix_timestamp of action" - ], - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "user", - "docs": [ - "user account public key" - ], - "type": "pubkey" - }, - { - "name": "direction", - "type": { - "defined": { - "name": "depositDirection" - } - } - }, - { - "name": "depositRecordId", - "type": "u64" - }, - { - "name": "amount", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "marketIndex", - "docs": [ - "spot market index" - ], - "type": "u16" - }, - { - "name": "oraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "marketDepositBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "marketWithdrawBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "marketCumulativeDepositInterest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "marketCumulativeBorrowInterest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "totalDepositsAfter", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalWithdrawsAfter", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "explanation", - "type": { - "defined": { - "name": "depositExplanation" - } - } - }, - { - "name": "transferUser", - "type": { - "option": "pubkey" - } - }, - { - "name": "signer", - "type": { - "option": "pubkey" - } - }, - { - "name": "userTokenAmountAfter", - "docs": [ - "precision: token mint precision" - ], - "type": "i128" - } - ] - } - }, - { - "name": "feeStructure", - "type": { - "kind": "struct", - "fields": [ - { - "name": "feeTiers", - "type": { - "array": [ - { - "defined": { - "name": "feeTier" - } - }, - 10 - ] - } - }, - { - "name": "fillerRewardStructure", - "type": { - "defined": { - "name": "orderFillerRewardStructure" - } - } - }, - { - "name": "referrerRewardEpochUpperBound", - "type": "u64" - }, - { - "name": "flatFillerFee", - "type": "u64" - } - ] - } - }, - { - "name": "feeTier", - "type": { - "kind": "struct", - "fields": [ - { - "name": "feeNumerator", - "type": "u32" - }, - { - "name": "feeDenominator", - "type": "u32" - }, - { - "name": "makerRebateNumerator", - "type": "u32" - }, - { - "name": "makerRebateDenominator", - "type": "u32" - }, - { - "name": "referrerRewardNumerator", - "type": "u32" - }, - { - "name": "referrerRewardDenominator", - "type": "u32" - }, - { - "name": "refereeFeeNumerator", - "type": "u32" - }, - { - "name": "refereeFeeDenominator", - "type": "u32" - } - ] - } - }, - { - "name": "fuelOverflow", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "The authority of this overflow account" - ], - "type": "pubkey" - }, - { - "name": "fuelInsurance", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelDeposits", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelBorrows", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelPositions", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelTaker", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "fuelMaker", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastFuelSweepTs", - "type": "u32" - }, - { - "name": "lastResetTs", - "type": "u32" - }, - { - "name": "padding", - "type": { - "array": [ - "u128", - 6 - ] - } - } - ] - } - }, - { - "name": "fuelSeasonRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "fuelInsurance", - "type": "u128" - }, - { - "name": "fuelDeposits", - "type": "u128" - }, - { - "name": "fuelBorrows", - "type": "u128" - }, - { - "name": "fuelPositions", - "type": "u128" - }, - { - "name": "fuelTaker", - "type": "u128" - }, - { - "name": "fuelMaker", - "type": "u128" - }, - { - "name": "fuelTotal", - "type": "u128" - } - ] - } - }, - { - "name": "fuelSweepRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "userStatsFuelInsurance", - "type": "u32" - }, - { - "name": "userStatsFuelDeposits", - "type": "u32" - }, - { - "name": "userStatsFuelBorrows", - "type": "u32" - }, - { - "name": "userStatsFuelPositions", - "type": "u32" - }, - { - "name": "userStatsFuelTaker", - "type": "u32" - }, - { - "name": "userStatsFuelMaker", - "type": "u32" - }, - { - "name": "fuelOverflowFuelInsurance", - "type": "u128" - }, - { - "name": "fuelOverflowFuelDeposits", - "type": "u128" - }, - { - "name": "fuelOverflowFuelBorrows", - "type": "u128" - }, - { - "name": "fuelOverflowFuelPositions", - "type": "u128" - }, - { - "name": "fuelOverflowFuelTaker", - "type": "u128" - }, - { - "name": "fuelOverflowFuelMaker", - "type": "u128" - } - ] - } - }, - { - "name": "fundingPaymentRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fundingPayment", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "baseAssetAmount", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "userLastCumulativeFunding", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "ammCumulativeFundingLong", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "ammCumulativeFundingShort", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - } - ] - } - }, - { - "name": "fundingRateRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "recordId", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fundingRate", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "fundingRateLong", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "fundingRateShort", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "cumulativeFundingRateLong", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "cumulativeFundingRateShort", - "docs": [ - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i128" - }, - { - "name": "oraclePriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "markPriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "periodRevenue", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "baseAssetAmountWithAmm", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i128" - }, - { - "name": "baseAssetAmountWithUnsettledLp", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i128" - } - ] - } - }, - { - "name": "highLeverageModeConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "currentUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "u8" - }, - { - "name": "padding1", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "currentMaintenanceUsers", - "type": "u32" - }, - { - "name": "padding2", - "type": { - "array": [ - "u8", - 24 - ] - } - } - ] - } - }, - { - "name": "historicalIndexData", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastIndexBidPrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastIndexAskPrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastIndexPriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastIndexPriceTwap5min", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastIndexPriceTwapTs", - "docs": [ - "unix_timestamp of last snapshot" - ], - "type": "i64" - } - ] - } - }, - { - "name": "historicalOracleData", - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastOracleConf", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastOracleDelay", - "docs": [ - "number of slots since last update" - ], - "type": "i64" - }, - { - "name": "lastOraclePriceTwap", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastOraclePriceTwap5min", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastOraclePriceTwapTs", - "docs": [ - "unix_timestamp of last snapshot" - ], - "type": "i64" - } - ] - } - }, - { - "name": "ifRebalanceConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "totalInAmount", - "docs": [ - "total amount to be sold" - ], - "type": "u64" - }, - { - "name": "currentInAmount", - "docs": [ - "amount already sold" - ], - "type": "u64" - }, - { - "name": "currentOutAmount", - "docs": [ - "amount already bought" - ], - "type": "u64" - }, - { - "name": "currentOutAmountTransferred", - "docs": [ - "amount already transferred to revenue pool" - ], - "type": "u64" - }, - { - "name": "currentInAmountSinceLastTransfer", - "docs": [ - "amount already bought in epoch" - ], - "type": "u64" - }, - { - "name": "epochStartTs", - "docs": [ - "start time of epoch" - ], - "type": "i64" - }, - { - "name": "epochInAmount", - "docs": [ - "amount already bought in epoch" - ], - "type": "u64" - }, - { - "name": "epochMaxInAmount", - "docs": [ - "max amount to swap in epoch" - ], - "type": "u64" - }, - { - "name": "epochDuration", - "docs": [ - "duration of epoch" - ], - "type": "i64" - }, - { - "name": "outMarketIndex", - "docs": [ - "market index to sell" - ], - "type": "u16" - }, - { - "name": "inMarketIndex", - "docs": [ - "market index to buy" - ], - "type": "u16" - }, - { - "name": "maxSlippageBps", - "type": "u16" - }, - { - "name": "swapMode", - "type": "u8" - }, - { - "name": "status", - "type": "u8" - }, - { - "name": "padding2", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "ifRebalanceConfigParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "totalInAmount", - "type": "u64" - }, - { - "name": "epochMaxInAmount", - "type": "u64" - }, - { - "name": "epochDuration", - "type": "i64" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "maxSlippageBps", - "type": "u16" - }, - { - "name": "swapMode", - "type": "u8" - }, - { - "name": "status", - "type": "u8" - } - ] - } - }, - { - "name": "insuranceClaim", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "revenueWithdrawSinceLastSettle", - "docs": [ - "The amount of revenue last settled", - "Positive if funds left the perp market,", - "negative if funds were pulled into the perp market", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "maxRevenueWithdrawPerPeriod", - "docs": [ - "The max amount of revenue that can be withdrawn per period", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "quoteMaxInsurance", - "docs": [ - "The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "quoteSettledInsurance", - "docs": [ - "The amount of insurance that has been used to resolve bankruptcy and pnl deficits", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastRevenueWithdrawTs", - "docs": [ - "The last time revenue was settled in/out of market" - ], - "type": "i64" - } - ] - } - }, - { - "name": "insuranceFund", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "vault", - "type": "pubkey" - }, - { - "name": "totalShares", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "userShares", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "sharesBase", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "unstakingPeriod", - "type": "i64" - }, - { - "name": "lastRevenueSettleTs", - "type": "i64" - }, - { - "name": "revenueSettlePeriod", - "type": "i64" - }, - { - "name": "totalFactor", - "type": "u32" - }, - { - "name": "userFactor", - "type": "u32" - } - ] - } - }, - { - "name": "insuranceFundRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "userIfFactor", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "totalIfFactor", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "vaultAmountBefore", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "insuranceVaultAmountBefore", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "totalIfSharesBefore", - "type": "u128" - }, - { - "name": "totalIfSharesAfter", - "type": "u128" - }, - { - "name": "amount", - "docs": [ - "precision: token mint precision" - ], - "type": "i64" - } - ] - } - }, - { - "name": "insuranceFundStake", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "ifShares", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastWithdrawRequestShares", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "ifBase", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastValidTs", - "type": "i64" - }, - { - "name": "lastWithdrawRequestValue", - "type": "u64" - }, - { - "name": "lastWithdrawRequestTs", - "type": "i64" - }, - { - "name": "costBasis", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 14 - ] - } - } - ] - } - }, - { - "name": "insuranceFundStakeRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "action", - "type": { - "defined": { - "name": "stakeAction" - } - } - }, - { - "name": "amount", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "insuranceVaultAmountBefore", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "ifSharesBefore", - "type": "u128" - }, - { - "name": "userIfSharesBefore", - "type": "u128" - }, - { - "name": "totalIfSharesBefore", - "type": "u128" - }, - { - "name": "ifSharesAfter", - "type": "u128" - }, - { - "name": "userIfSharesAfter", - "type": "u128" - }, - { - "name": "totalIfSharesAfter", - "type": "u128" - } - ] - } - }, - { - "name": "insuranceFundSwapRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rebalanceConfig", - "type": "pubkey" - }, - { - "name": "inIfTotalSharesBefore", - "type": "u128" - }, - { - "name": "outIfTotalSharesBefore", - "type": "u128" - }, - { - "name": "inIfUserSharesBefore", - "type": "u128" - }, - { - "name": "outIfUserSharesBefore", - "type": "u128" - }, - { - "name": "inIfTotalSharesAfter", - "type": "u128" - }, - { - "name": "outIfTotalSharesAfter", - "type": "u128" - }, - { - "name": "inIfUserSharesAfter", - "type": "u128" - }, - { - "name": "outIfUserSharesAfter", - "type": "u128" - }, - { - "name": "ts", - "type": "i64" - }, - { - "name": "inAmount", - "type": "u64" - }, - { - "name": "outAmount", - "type": "u64" - }, - { - "name": "outOraclePrice", - "type": "u64" - }, - { - "name": "outOraclePriceTwap", - "type": "i64" - }, - { - "name": "inVaultAmountBefore", - "type": "u64" - }, - { - "name": "outVaultAmountBefore", - "type": "u64" - }, - { - "name": "inFundVaultAmountAfter", - "type": "u64" - }, - { - "name": "outFundVaultAmountAfter", - "type": "u64" - }, - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outMarketIndex", - "type": "u16" - } - ] - } - }, - { - "name": "lpAction", - "type": { - "kind": "enum", - "variants": [ - { - "name": "addLiquidity" - }, - { - "name": "removeLiquidity" - }, - { - "name": "settleLiquidity" - }, - { - "name": "removeLiquidityDerisk" - } - ] - } - }, - { - "name": "lpBorrowLendDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "direction", - "type": { - "defined": { - "name": "depositDirection" - } - } - }, - { - "name": "tokenBalance", - "type": "i64" - }, - { - "name": "lastTokenBalance", - "type": "i64" - }, - { - "name": "interestAccruedTokenAmount", - "type": "i64" - }, - { - "name": "amountDepositWithdraw", - "type": "u64" - }, - { - "name": "lpPool", - "type": "pubkey" - } - ] - } - }, - { - "name": "lpMintRedeemRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "description", - "type": "u8" - }, - { - "name": "amount", - "docs": [ - "precision: continutent mint precision, gross fees" - ], - "type": "u128" - }, - { - "name": "fee", - "docs": [ - "precision: fee on amount, constituent market mint precision" - ], - "type": "i128" - }, - { - "name": "spotMarketIndex", - "type": "u16" - }, - { - "name": "constituentIndex", - "type": "u16" - }, - { - "name": "oraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "mint", - "docs": [ - "token mint" - ], - "type": "pubkey" - }, - { - "name": "lpAmount", - "docs": [ - "lp amount, lp mint precision" - ], - "type": "u64" - }, - { - "name": "lpFee", - "docs": [ - "lp fee, lp mint precision" - ], - "type": "i64" - }, - { - "name": "lpPrice", - "docs": [ - "the fair price of the lp token, PRICE_PRECISION" - ], - "type": "u128" - }, - { - "name": "mintRedeemId", - "type": "u64" - }, - { - "name": "lastAum", - "docs": [ - "LPPool last_aum" - ], - "type": "u128" - }, - { - "name": "lastAumSlot", - "type": "u64" - }, - { - "name": "inMarketCurrentWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inMarketTargetWeight", - "type": "i64" - }, - { - "name": "lpPool", - "type": "pubkey" - } - ] - } - }, - { - "name": "lpPool", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "address of the vault." - ], - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "whitelistMint", - "type": "pubkey" - }, - { - "name": "constituentTargetBase", - "type": "pubkey" - }, - { - "name": "constituentCorrelations", - "type": "pubkey" - }, - { - "name": "maxAum", - "docs": [ - "The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)", - "which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)", - "pub quote_constituent_index: u16,", - "QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "lastAum", - "docs": [ - "QUOTE_PRECISION: AUM of the vault in USD, updated lazily" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeQuoteSentToPerpMarkets", - "docs": [ - "QUOTE PRECISION: Cumulative quotes from settles" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeQuoteReceivedFromPerpMarkets", - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalMintRedeemFeesPaid", - "docs": [ - "QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens" - ], - "type": { - "defined": { - "name": "i128" - } - } - }, - { - "name": "lastAumSlot", - "docs": [ - "timestamp of last AUM slot" - ], - "type": "u64" - }, - { - "name": "maxSettleQuoteAmount", - "type": "u64" - }, - { - "name": "padding", - "docs": [ - "timestamp of last vAMM revenue rebalance" - ], - "type": "u64" - }, - { - "name": "mintRedeemId", - "docs": [ - "Every mint/redeem has a monotonically increasing id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "settleId", - "type": "u64" - }, - { - "name": "minMintFee", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "tokenSupply", - "type": "u64" - }, - { - "name": "volatility", - "type": "u64" - }, - { - "name": "constituents", - "type": "u16" - }, - { - "name": "quoteConsituentIndex", - "type": "u16" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "gammaExecution", - "type": "u8" - }, - { - "name": "xi", - "type": "u8" - }, - { - "name": "targetOracleDelayFeeBpsPer10Slots", - "type": "u8" - }, - { - "name": "targetPositionDelayFeeBpsPer10Slots", - "type": "u8" - }, - { - "name": "lpPoolId", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 174 - ] - } - } - ] - } - }, - { - "name": "lpRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "action", - "type": { - "defined": { - "name": "lpAction" - } - } - }, - { - "name": "nShares", - "docs": [ - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "deltaBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "deltaQuoteAssetAmount", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "pnl", - "docs": [ - "realized pnl of the position settlement", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - } - ] - } - }, - { - "name": "lpSettleRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "recordId", - "type": "u64" - }, - { - "name": "lastTs", - "type": "i64" - }, - { - "name": "lastSlot", - "type": "u64" - }, - { - "name": "ts", - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "settleToLpAmount", - "type": "i64" - }, - { - "name": "perpAmmPnlDelta", - "type": "i64" - }, - { - "name": "perpAmmExFeeDelta", - "type": "i64" - }, - { - "name": "lpAum", - "type": "u128" - }, - { - "name": "lpPrice", - "type": "u128" - }, - { - "name": "lpPool", - "type": "pubkey" - } - ] - } - }, - { - "name": "lpSwapRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "slot", - "type": "u64" - }, - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "outAmount", - "docs": [ - "precision: out market mint precision, gross fees" - ], - "type": "u128" - }, - { - "name": "inAmount", - "docs": [ - "precision: in market mint precision, gross fees" - ], - "type": "u128" - }, - { - "name": "outFee", - "docs": [ - "precision: fee on amount_out, in market mint precision" - ], - "type": "i128" - }, - { - "name": "inFee", - "docs": [ - "precision: fee on amount_in, out market mint precision" - ], - "type": "i128" - }, - { - "name": "outSpotMarketIndex", - "type": "u16" - }, - { - "name": "inSpotMarketIndex", - "type": "u16" - }, - { - "name": "outConstituentIndex", - "type": "u16" - }, - { - "name": "inConstituentIndex", - "type": "u16" - }, - { - "name": "outOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastAum", - "docs": [ - "LPPool last_aum, QUOTE_PRECISION" - ], - "type": "u128" - }, - { - "name": "lastAumSlot", - "type": "u64" - }, - { - "name": "inMarketCurrentWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "outMarketCurrentWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inMarketTargetWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "outMarketTargetWeight", - "docs": [ - "PERCENTAGE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inSwapId", - "type": "u64" - }, - { - "name": "outSwapId", - "type": "u64" - }, - { - "name": "lpPool", - "type": "pubkey" - } - ] - } - }, - { - "name": "liquidateBorrowForPerpPnlRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "marketOraclePrice", - "type": "i64" - }, - { - "name": "pnlTransfer", - "type": "u128" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "liabilityPrice", - "type": "i64" - }, - { - "name": "liabilityTransfer", - "type": "u128" - } - ] - } - }, - { - "name": "liquidatePerpPnlForDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "marketOraclePrice", - "type": "i64" - }, - { - "name": "pnlTransfer", - "type": "u128" - }, - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "assetPrice", - "type": "i64" - }, - { - "name": "assetTransfer", - "type": "u128" - } - ] - } - }, - { - "name": "liquidatePerpRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "oraclePrice", - "type": "i64" - }, - { - "name": "baseAssetAmount", - "type": "i64" - }, - { - "name": "quoteAssetAmount", - "type": "i64" - }, - { - "name": "lpShares", - "docs": [ - "precision: AMM_RESERVE_PRECISION" - ], - "type": "u64" - }, - { - "name": "fillRecordId", - "type": "u64" - }, - { - "name": "userOrderId", - "type": "u32" - }, - { - "name": "liquidatorOrderId", - "type": "u32" - }, - { - "name": "liquidatorFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "ifFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": "u64" - } - ] - } - }, - { - "name": "liquidateSpotRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "assetMarketIndex", - "type": "u16" - }, - { - "name": "assetPrice", - "type": "i64" - }, - { - "name": "assetTransfer", - "type": "u128" - }, - { - "name": "liabilityMarketIndex", - "type": "u16" - }, - { - "name": "liabilityPrice", - "type": "i64" - }, - { - "name": "liabilityTransfer", - "docs": [ - "precision: token mint precision" - ], - "type": "u128" - }, - { - "name": "ifFee", - "docs": [ - "precision: token mint precision" - ], - "type": "u64" - } - ] - } - }, - { - "name": "liquidationRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "liquidationType", - "type": { - "defined": { - "name": "liquidationType" - } - } - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "liquidator", - "type": "pubkey" - }, - { - "name": "marginRequirement", - "type": "u128" - }, - { - "name": "totalCollateral", - "type": "i128" - }, - { - "name": "marginFreed", - "type": "u64" - }, - { - "name": "liquidationId", - "type": "u16" - }, - { - "name": "bankrupt", - "type": "bool" - }, - { - "name": "canceledOrderIds", - "type": { - "vec": "u32" - } - }, - { - "name": "liquidatePerp", - "type": { - "defined": { - "name": "liquidatePerpRecord" - } - } - }, - { - "name": "liquidateSpot", - "type": { - "defined": { - "name": "liquidateSpotRecord" - } - } - }, - { - "name": "liquidateBorrowForPerpPnl", - "type": { - "defined": { - "name": "liquidateBorrowForPerpPnlRecord" - } - } - }, - { - "name": "liquidatePerpPnlForDeposit", - "type": { - "defined": { - "name": "liquidatePerpPnlForDepositRecord" - } - } - }, - { - "name": "perpBankruptcy", - "type": { - "defined": { - "name": "perpBankruptcyRecord" - } - } - }, - { - "name": "spotBankruptcy", - "type": { - "defined": { - "name": "spotBankruptcyRecord" - } - } - } - ] - } - }, - { - "name": "liquidationType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "liquidatePerp" - }, - { - "name": "liquidateSpot" - }, - { - "name": "liquidateBorrowForPerpPnl" - }, - { - "name": "liquidatePerpPnlForDeposit" - }, - { - "name": "perpBankruptcy" - }, - { - "name": "spotBankruptcy" - } - ] - } - }, - { - "name": "lpPoolParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxSettleQuoteAmount", - "type": { - "option": "u64" - } - }, - { - "name": "volatility", - "type": { - "option": "u64" - } - }, - { - "name": "gammaExecution", - "type": { - "option": "u8" - } - }, - { - "name": "xi", - "type": { - "option": "u8" - } - }, - { - "name": "maxAum", - "type": { - "option": "u128" - } - }, - { - "name": "whitelistMint", - "type": { - "option": "pubkey" - } - } - ] - } - }, - { - "name": "marginMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "default" - }, - { - "name": "highLeverage" - }, - { - "name": "highLeverageMaintenance" - } - ] - } - }, - { - "name": "marketStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "initialized" - }, - { - "name": "active" - }, - { - "name": "fundingPaused" - }, - { - "name": "ammPaused" - }, - { - "name": "fillPaused" - }, - { - "name": "withdrawPaused" - }, - { - "name": "reduceOnly" - }, - { - "name": "settlement" - }, - { - "name": "delisted" - } - ] - } - }, - { - "name": "marketType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "spot" - }, - { - "name": "perp" - } - ] - } - }, - { - "name": "modifyOrderParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "direction", - "type": { - "option": { - "defined": { - "name": "positionDirection" - } - } - } - }, - { - "name": "baseAssetAmount", - "type": { - "option": "u64" - } - }, - { - "name": "price", - "type": { - "option": "u64" - } - }, - { - "name": "reduceOnly", - "type": { - "option": "bool" - } - }, - { - "name": "postOnly", - "type": { - "option": { - "defined": { - "name": "postOnlyParam" - } - } - } - }, - { - "name": "bitFlags", - "type": { - "option": "u8" - } - }, - { - "name": "maxTs", - "type": { - "option": "i64" - } - }, - { - "name": "triggerPrice", - "type": { - "option": "u64" - } - }, - { - "name": "triggerCondition", - "type": { - "option": { - "defined": { - "name": "orderTriggerCondition" - } - } - } - }, - { - "name": "oraclePriceOffset", - "type": { - "option": "i32" - } - }, - { - "name": "auctionDuration", - "type": { - "option": "u8" - } - }, - { - "name": "auctionStartPrice", - "type": { - "option": "i64" - } - }, - { - "name": "auctionEndPrice", - "type": { - "option": "i64" - } - }, - { - "name": "policy", - "type": { - "option": "u8" - } - } - ] - } - }, - { - "name": "newUserRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "docs": [ - "unix_timestamp of action" - ], - "type": "i64" - }, - { - "name": "userAuthority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "subAccountId", - "type": "u16" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "referrer", - "type": "pubkey" - } - ] - } - }, - { - "name": "openbookV2FulfillmentConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "openbookV2ProgramId", - "type": "pubkey" - }, - { - "name": "openbookV2Market", - "type": "pubkey" - }, - { - "name": "openbookV2MarketAuthority", - "type": "pubkey" - }, - { - "name": "openbookV2EventHeap", - "type": "pubkey" - }, - { - "name": "openbookV2Bids", - "type": "pubkey" - }, - { - "name": "openbookV2Asks", - "type": "pubkey" - }, - { - "name": "openbookV2BaseVault", - "type": "pubkey" - }, - { - "name": "openbookV2QuoteVault", - "type": "pubkey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": { - "name": "spotFulfillmentType" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "oracleGuardRails", - "type": { - "kind": "struct", - "fields": [ - { - "name": "priceDivergence", - "type": { - "defined": { - "name": "priceDivergenceGuardRails" - } - } - }, - { - "name": "validity", - "type": { - "defined": { - "name": "validityGuardRails" - } - } - } - ] - } - }, - { - "name": "oracleSource", - "type": { - "kind": "enum", - "variants": [ - { - "name": "pyth" - }, - { - "name": "switchboard" - }, - { - "name": "quoteAsset" - }, - { - "name": "pyth1K" - }, - { - "name": "pyth1M" - }, - { - "name": "pythStableCoin" - }, - { - "name": "prelaunch" - }, - { - "name": "pythPull" - }, - { - "name": "pyth1KPull" - }, - { - "name": "pyth1MPull" - }, - { - "name": "pythStableCoinPull" - }, - { - "name": "switchboardOnDemand" - }, - { - "name": "pythLazer" - }, - { - "name": "pythLazer1K" - }, - { - "name": "pythLazer1M" - }, - { - "name": "pythLazerStableCoin" - } - ] - } - }, - { - "name": "order", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "slot", - "docs": [ - "The slot the order was placed" - ], - "type": "u64" - }, - { - "name": "price", - "docs": [ - "The limit price for the order (can be 0 for market orders)", - "For orders with an auction, this price isn't used until the auction is complete", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "baseAssetAmount", - "docs": [ - "The size of the order", - "precision for perps: BASE_PRECISION", - "precision for spot: token mint precision" - ], - "type": "u64" - }, - { - "name": "baseAssetAmountFilled", - "docs": [ - "The amount of the order filled", - "precision for perps: BASE_PRECISION", - "precision for spot: token mint precision" - ], - "type": "u64" - }, - { - "name": "quoteAssetAmountFilled", - "docs": [ - "The amount of quote filled for the order", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "triggerPrice", - "docs": [ - "At what price the order will be triggered. Only relevant for trigger orders", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "auctionStartPrice", - "docs": [ - "The start price for the auction. Only relevant for market/oracle orders", - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "auctionEndPrice", - "docs": [ - "The end price for the auction. Only relevant for market/oracle orders", - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "maxTs", - "docs": [ - "The time when the order will expire" - ], - "type": "i64" - }, - { - "name": "oraclePriceOffset", - "docs": [ - "If set, the order limit price is the oracle price + this offset", - "precision: PRICE_PRECISION" - ], - "type": "i32" - }, - { - "name": "orderId", - "docs": [ - "The id for the order. Each users has their own order id space" - ], - "type": "u32" - }, - { - "name": "marketIndex", - "docs": [ - "The perp/spot market index" - ], - "type": "u16" - }, - { - "name": "status", - "docs": [ - "Whether the order is open or unused" - ], - "type": { - "defined": { - "name": "orderStatus" - } - } - }, - { - "name": "orderType", - "docs": [ - "The type of order" - ], - "type": { - "defined": { - "name": "orderType" - } - } - }, - { - "name": "marketType", - "docs": [ - "Whether market is spot or perp" - ], - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "userOrderId", - "docs": [ - "User generated order id. Can make it easier to place/cancel orders" - ], - "type": "u8" - }, - { - "name": "existingPositionDirection", - "docs": [ - "What the users position was when the order was placed" - ], - "type": { - "defined": { - "name": "positionDirection" - } - } - }, - { - "name": "direction", - "docs": [ - "Whether the user is going long or short. LONG = bid, SHORT = ask" - ], - "type": { - "defined": { - "name": "positionDirection" - } - } - }, - { - "name": "reduceOnly", - "docs": [ - "Whether the order is allowed to only reduce position size" - ], - "type": "bool" - }, - { - "name": "postOnly", - "docs": [ - "Whether the order must be a maker" - ], - "type": "bool" - }, - { - "name": "immediateOrCancel", - "docs": [ - "Whether the order must be canceled the same slot it is placed" - ], - "type": "bool" - }, - { - "name": "triggerCondition", - "docs": [ - "Whether the order is triggered above or below the trigger price. Only relevant for trigger orders" - ], - "type": { - "defined": { - "name": "orderTriggerCondition" - } - } - }, - { - "name": "auctionDuration", - "docs": [ - "How many slots the auction lasts" - ], - "type": "u8" - }, - { - "name": "postedSlotTail", - "docs": [ - "Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)" - ], - "type": "u8" - }, - { - "name": "bitFlags", - "docs": [ - "Bitflags for further classification", - "0: is_signed_message" - ], - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 1 - ] - } - } - ] - } - }, - { - "name": "orderAction", - "type": { - "kind": "enum", - "variants": [ - { - "name": "place" - }, - { - "name": "cancel" - }, - { - "name": "fill" - }, - { - "name": "trigger" - }, - { - "name": "expire" - } - ] - } - }, - { - "name": "orderActionExplanation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "none" - }, - { - "name": "insufficientFreeCollateral" - }, - { - "name": "oraclePriceBreachedLimitPrice" - }, - { - "name": "marketOrderFilledToLimitPrice" - }, - { - "name": "orderExpired" - }, - { - "name": "liquidation" - }, - { - "name": "orderFilledWithAmm" - }, - { - "name": "orderFilledWithAmmJit" - }, - { - "name": "orderFilledWithMatch" - }, - { - "name": "orderFilledWithMatchJit" - }, - { - "name": "marketExpired" - }, - { - "name": "riskingIncreasingOrder" - }, - { - "name": "reduceOnlyOrderIncreasedPosition" - }, - { - "name": "orderFillWithSerum" - }, - { - "name": "noBorrowLiquidity" - }, - { - "name": "orderFillWithPhoenix" - }, - { - "name": "orderFilledWithAmmJitLpSplit" - }, - { - "name": "orderFilledWithLpJit" - }, - { - "name": "deriskLp" - }, - { - "name": "orderFilledWithOpenbookV2" - }, - { - "name": "transferPerpPosition" - } - ] - } - }, - { - "name": "orderActionRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "action", - "type": { - "defined": { - "name": "orderAction" - } - } - }, - { - "name": "actionExplanation", - "type": { - "defined": { - "name": "orderActionExplanation" - } - } - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "marketType", - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "filler", - "type": { - "option": "pubkey" - } - }, - { - "name": "fillerReward", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "fillRecordId", - "type": { - "option": "u64" - } - }, - { - "name": "baseAssetAmountFilled", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "quoteAssetAmountFilled", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "takerFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "i64" - } - }, - { - "name": "referrerReward", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u32" - } - }, - { - "name": "quoteAssetAmountSurplus", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "i64" - } - }, - { - "name": "spotFulfillmentMethodFee", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "taker", - "type": { - "option": "pubkey" - } - }, - { - "name": "takerOrderId", - "type": { - "option": "u32" - } - }, - { - "name": "takerOrderDirection", - "type": { - "option": { - "defined": { - "name": "positionDirection" - } - } - } - }, - { - "name": "takerOrderBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "takerOrderCumulativeBaseAssetAmountFilled", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "takerOrderCumulativeQuoteAssetAmountFilled", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "maker", - "type": { - "option": "pubkey" - } - }, - { - "name": "makerOrderId", - "type": { - "option": "u32" - } - }, - { - "name": "makerOrderDirection", - "type": { - "option": { - "defined": { - "name": "positionDirection" - } - } - } - }, - { - "name": "makerOrderBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerOrderCumulativeBaseAssetAmountFilled", - "docs": [ - "precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerOrderCumulativeQuoteAssetAmountFilled", - "docs": [ - "precision: QUOTE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "oraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "bitFlags", - "docs": [ - "Bit flags:", - "0: is_signed_message" - ], - "type": "u8" - }, - { - "name": "takerExistingQuoteEntryAmount", - "docs": [ - "precision: QUOTE_PRECISION", - "Only Some if the taker reduced position" - ], - "type": { - "option": "u64" - } - }, - { - "name": "takerExistingBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION", - "Only Some if the taker flipped position direction" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerExistingQuoteEntryAmount", - "docs": [ - "precision: QUOTE_PRECISION", - "Only Some if the maker reduced position" - ], - "type": { - "option": "u64" - } - }, - { - "name": "makerExistingBaseAssetAmount", - "docs": [ - "precision: BASE_PRECISION", - "Only Some if the maker flipped position direction" - ], - "type": { - "option": "u64" - } - }, - { - "name": "triggerPrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": { - "option": "u64" - } - }, - { - "name": "builderIdx", - "docs": [ - "the idx of the builder in the taker's [`RevenueShareEscrow`] account" - ], - "type": { - "option": "u8" - } - }, - { - "name": "builderFee", - "docs": [ - "precision: QUOTE_PRECISION builder fee paid by the taker" - ], - "type": { - "option": "u64" - } - } - ] - } - }, - { - "name": "orderFillerRewardStructure", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rewardNumerator", - "type": "u32" - }, - { - "name": "rewardDenominator", - "type": "u32" - }, - { - "name": "timeBasedRewardLowerBound", - "type": { - "defined": { - "name": "u128" - } - } - } - ] - } - }, - { - "name": "orderParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "orderType", - "type": { - "defined": { - "name": "orderType" - } - } - }, - { - "name": "marketType", - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "direction", - "type": { - "defined": { - "name": "positionDirection" - } - } - }, - { - "name": "userOrderId", - "type": "u8" - }, - { - "name": "baseAssetAmount", - "type": "u64" - }, - { - "name": "price", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "reduceOnly", - "type": "bool" - }, - { - "name": "postOnly", - "type": { - "defined": { - "name": "postOnlyParam" - } - } - }, - { - "name": "bitFlags", - "type": "u8" - }, - { - "name": "maxTs", - "type": { - "option": "i64" - } - }, - { - "name": "triggerPrice", - "type": { - "option": "u64" - } - }, - { - "name": "triggerCondition", - "type": { - "defined": { - "name": "orderTriggerCondition" - } - } - }, - { - "name": "oraclePriceOffset", - "type": { - "option": "i32" - } - }, - { - "name": "auctionDuration", - "type": { - "option": "u8" - } - }, - { - "name": "auctionStartPrice", - "type": { - "option": "i64" - } - }, - { - "name": "auctionEndPrice", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "orderRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "order", - "type": { - "defined": { - "name": "order" - } - } - } - ] - } - }, - { - "name": "orderStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "init" - }, - { - "name": "open" - }, - { - "name": "filled" - }, - { - "name": "canceled" - } - ] - } - }, - { - "name": "orderTriggerCondition", - "type": { - "kind": "enum", - "variants": [ - { - "name": "above" - }, - { - "name": "below" - }, - { - "name": "triggeredAbove" - }, - { - "name": "triggeredBelow" - } - ] - } - }, - { - "name": "orderType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "market" - }, - { - "name": "limit" - }, - { - "name": "triggerMarket" - }, - { - "name": "triggerLimit" - }, - { - "name": "oracle" - } - ] - } - }, - { - "name": "overrideAmmCacheParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quoteOwedFromLpPool", - "type": { - "option": "i64" - } - }, - { - "name": "lastSettleSlot", - "type": { - "option": "u64" - } - }, - { - "name": "lastFeePoolTokenAmount", - "type": { - "option": "u128" - } - }, - { - "name": "lastNetPnlPoolTokenAmount", - "type": { - "option": "i128" - } - }, - { - "name": "ammPositionScalar", - "type": { - "option": "u8" - } - }, - { - "name": "ammInventoryLimit", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "perpBankruptcyRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "pnl", - "type": "i128" - }, - { - "name": "ifPayment", - "type": "u128" - }, - { - "name": "clawbackUser", - "type": { - "option": "pubkey" - } - }, - { - "name": "clawbackUserPayment", - "type": { - "option": "u128" - } - }, - { - "name": "cumulativeFundingRateDelta", - "type": "i128" - } - ] - } - }, - { - "name": "perpMarket", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "The perp market's address. It is a pda of the market index" - ], - "type": "pubkey" - }, - { - "name": "amm", - "docs": [ - "The automated market maker" - ], - "type": { - "defined": { - "name": "amm" - } - } - }, - { - "name": "pnlPool", - "docs": [ - "The market's pnl pool. When users settle negative pnl, the balance increases.", - "When users settle positive pnl, the balance decreases. Can not go negative." - ], - "type": { - "defined": { - "name": "poolBalance" - } - } - }, - { - "name": "name", - "docs": [ - "Encoded display name for the perp market e.g. SOL-PERP" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "insuranceClaim", - "docs": [ - "The perp market's claim on the insurance fund" - ], - "type": { - "defined": { - "name": "insuranceClaim" - } - } - }, - { - "name": "unrealizedPnlMaxImbalance", - "docs": [ - "The max pnl imbalance before positive pnl asset weight is discounted", - "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", - "the amm has negative pnl and the initial asset weight for positive pnl is discounted", - "precision = QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "expiryTs", - "docs": [ - "The ts when the market will be expired. Only set if market is in reduce only mode" - ], - "type": "i64" - }, - { - "name": "expiryPrice", - "docs": [ - "The price at which positions will be settled. Only set if market is expired", - "precision = PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "nextFillRecordId", - "docs": [ - "Every trade has a fill record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "nextFundingRateRecordId", - "docs": [ - "Every funding rate update has a record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "nextCurveRecordId", - "docs": [ - "Every amm k updated has a record id. This is the next id to be used" - ], - "type": "u64" - }, - { - "name": "imfFactor", - "docs": [ - "The initial margin fraction factor. Used to increase margin ratio for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealizedPnlImfFactor", - "docs": [ - "The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "liquidatorFee", - "docs": [ - "The fee the liquidator is paid for taking over perp position", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "marginRatioInitial", - "docs": [ - "The margin ratio which determines how much collateral is required to open a position", - "e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "marginRatioMaintenance", - "docs": [ - "The margin ratio which determines when a user will be liquidated", - "e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position", - "else they will be liquidated", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealizedPnlInitialAssetWeight", - "docs": [ - "The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "unrealizedPnlMaintenanceAssetWeight", - "docs": [ - "The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "numberOfUsersWithBase", - "docs": [ - "number of users in a position (base)" - ], - "type": "u32" - }, - { - "name": "numberOfUsers", - "docs": [ - "number of users in a position (pnl) or pnl (quote)" - ], - "type": "u32" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "status", - "docs": [ - "Whether a market is active, reduce only, expired, etc", - "Affects whether users can open/close positions" - ], - "type": { - "defined": { - "name": "marketStatus" - } - } - }, - { - "name": "contractType", - "docs": [ - "Currently only Perpetual markets are supported" - ], - "type": { - "defined": { - "name": "contractType" - } - } - }, - { - "name": "contractTier", - "docs": [ - "The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance", - "It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first" - ], - "type": { - "defined": { - "name": "contractTier" - } - } - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "quoteSpotMarketIndex", - "docs": [ - "The spot market that pnl is settled in" - ], - "type": "u16" - }, - { - "name": "feeAdjustment", - "docs": [ - "Between -100 and 100, represents what % to increase/decrease the fee by", - "E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps", - "if this is 50 and the fee is 5bps, the new fee will be 7.5bps" - ], - "type": "i16" - }, - { - "name": "fuelBoostPosition", - "docs": [ - "fuel multiplier for perp funding", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostTaker", - "docs": [ - "fuel multiplier for perp taker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostMaker", - "docs": [ - "fuel multiplier for perp maker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "poolId", - "type": "u8" - }, - { - "name": "highLeverageMarginRatioInitial", - "type": "u16" - }, - { - "name": "highLeverageMarginRatioMaintenance", - "type": "u16" - }, - { - "name": "protectedMakerLimitPriceDivisor", - "type": "u8" - }, - { - "name": "protectedMakerDynamicDivisor", - "type": "u8" - }, - { - "name": "lpFeeTransferScalar", - "type": "u8" - }, - { - "name": "lpStatus", - "type": "u8" - }, - { - "name": "lpPausedOperations", - "type": "u8" - }, - { - "name": "lpExchangeFeeExcluscionScalar", - "type": "u8" - }, - { - "name": "lastFillPrice", - "type": "u64" - }, - { - "name": "lpPoolId", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 23 - ] - } - } - ] - } - }, - { - "name": "perpPosition", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "lastCumulativeFundingRate", - "docs": [ - "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", - "precision: FUNDING_RATE_PRECISION" - ], - "type": "i64" - }, - { - "name": "baseAssetAmount", - "docs": [ - "the size of the users perp position", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quoteAssetAmount", - "docs": [ - "Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees", - "Updated when the user open/closes position or settles pnl. Includes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quoteBreakEvenAmount", - "docs": [ - "The amount of quote the user would need to exit their position at to break even", - "Updated when the user open/closes position or settles pnl. Includes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "quoteEntryAmount", - "docs": [ - "The amount quote the user entered the position with. Equal to base asset amount * avg entry price", - "Updated when the user open/closes position. Excludes fees/funding", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "openBids", - "docs": [ - "The amount of non reduce only trigger orders the user has open", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "openAsks", - "docs": [ - "The amount of non reduce only trigger orders the user has open", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "settledPnl", - "docs": [ - "The amount of pnl settled in this market since opening the position", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lpShares", - "docs": [ - "The number of lp (liquidity provider) shares the user has in this perp market", - "LP shares allow users to provide liquidity via the AMM", - "precision: BASE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastBaseAssetAmountPerLp", - "docs": [ - "The last base asset amount per lp the amm had", - "Used to settle the users lp position", - "precision: BASE_PRECISION" - ], - "type": "i64" - }, - { - "name": "lastQuoteAssetAmountPerLp", - "docs": [ - "The last quote asset amount per lp the amm had", - "Used to settle the users lp position", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 2 - ] - } - }, - { - "name": "maxMarginRatio", - "type": "u16" - }, - { - "name": "marketIndex", - "docs": [ - "The market index for the perp market" - ], - "type": "u16" - }, - { - "name": "openOrders", - "docs": [ - "The number of open orders" - ], - "type": "u8" - }, - { - "name": "perLpBase", - "type": "i8" - } - ] - } - }, - { - "name": "phoenixV1FulfillmentConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "phoenixProgramId", - "type": "pubkey" - }, - { - "name": "phoenixLogAuthority", - "type": "pubkey" - }, - { - "name": "phoenixMarket", - "type": "pubkey" - }, - { - "name": "phoenixBaseVault", - "type": "pubkey" - }, - { - "name": "phoenixQuoteVault", - "type": "pubkey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": { - "name": "spotFulfillmentType" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "poolBalance", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "scaledBalance", - "docs": [ - "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", - "deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "marketIndex", - "docs": [ - "The spot market the pool is for" - ], - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 6 - ] - } - } - ] - } - }, - { - "name": "positionDirection", - "type": { - "kind": "enum", - "variants": [ - { - "name": "long" - }, - { - "name": "short" - } - ] - } - }, - { - "name": "postOnlyParam", - "type": { - "kind": "enum", - "variants": [ - { - "name": "none" - }, - { - "name": "mustPostOnly" - }, - { - "name": "tryPostOnly" - }, - { - "name": "slide" - } - ] - } - }, - { - "name": "prelaunchOracle", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "price", - "type": "i64" - }, - { - "name": "maxPrice", - "type": "i64" - }, - { - "name": "confidence", - "type": "u64" - }, - { - "name": "lastUpdateSlot", - "type": "u64" - }, - { - "name": "ammLastUpdateSlot", - "type": "u64" - }, - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 70 - ] - } - } - ] - } - }, - { - "name": "prelaunchOracleParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "perpMarketIndex", - "type": "u16" - }, - { - "name": "price", - "type": { - "option": "i64" - } - }, - { - "name": "maxPrice", - "type": { - "option": "i64" - } - } - ] - } - }, - { - "name": "priceDivergenceGuardRails", - "type": { - "kind": "struct", - "fields": [ - { - "name": "markOraclePercentDivergence", - "type": "u64" - }, - { - "name": "oracleTwap5minPercentDivergence", - "type": "u64" - } - ] - } - }, - { - "name": "protectedMakerModeConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "maxUsers", - "type": "u32" - }, - { - "name": "currentUsers", - "type": "u32" - }, - { - "name": "reduceOnly", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 31 - ] - } - } - ] - } - }, - { - "name": "pythLazerOracle", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "price", - "type": "i64" - }, - { - "name": "publishTime", - "type": "u64" - }, - { - "name": "postedSlot", - "type": "u64" - }, - { - "name": "exponent", - "type": "i32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "conf", - "type": "u64" - } - ] - } - }, - { - "name": "referrerName", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "type": "pubkey" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "userStats", - "type": "pubkey" - }, - { - "name": "name", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "revenueShare", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "rust", - "packed": true - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "the owner of this account, a builder or referrer" - ], - "type": "pubkey" - }, - { - "name": "totalReferrerRewards", - "type": "u64" - }, - { - "name": "totalBuilderRewards", - "type": "u64" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 18 - ] - } - } - ] - } - }, - { - "name": "revenueShareEscrow", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "the owner of this account, a user" - ], - "type": "pubkey" - }, - { - "name": "referrer", - "type": "pubkey" - }, - { - "name": "referrerBoostExpireTs", - "type": "u32" - }, - { - "name": "referrerRewardOffset", - "type": "i8" - }, - { - "name": "refereeFeeNumeratorOffset", - "type": "i8" - }, - { - "name": "referrerBoostNumerator", - "type": "i8" - }, - { - "name": "reservedFixed", - "type": { - "array": [ - "u8", - 17 - ] - } - }, - { - "name": "padding0", - "type": "u32" - }, - { - "name": "orders", - "type": { - "vec": { - "defined": { - "name": "revenueShareOrder" - } - } - } - }, - { - "name": "padding1", - "type": "u32" - }, - { - "name": "approvedBuilders", - "type": { - "vec": { - "defined": { - "name": "builderInfo" - } - } - } - } - ] - } - }, - { - "name": "revenueShareOrder", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "feesAccrued", - "docs": [ - "fees accrued so far for this order slot. This is not exclusively fees from this order_id", - "and may include fees from other orders in the same market. This may be swept to the", - "builder's SpotPosition during settle_pnl." - ], - "type": "u64" - }, - { - "name": "orderId", - "docs": [ - "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open" - ], - "type": "u32" - }, - { - "name": "feeTenthBps", - "docs": [ - "the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%" - ], - "type": "u16" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "subAccountId", - "docs": [ - "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open" - ], - "type": "u16" - }, - { - "name": "builderIdx", - "docs": [ - "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", - "if bit_flag = Referral." - ], - "type": "u8" - }, - { - "name": "bitFlags", - "docs": [ - "bitflags that describe the state of the order.", - "[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.", - "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", - "[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.", - "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", - "[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.", - "If it is set, no other bitflag should be set." - ], - "type": "u8" - }, - { - "name": "userOrderIndex", - "docs": [ - "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches." - ], - "type": "u8" - }, - { - "name": "marketType", - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 10 - ] - } - } - ] - } - }, - { - "name": "revenueShareSettleRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "builder", - "type": { - "option": "pubkey" - } - }, - { - "name": "referrer", - "type": { - "option": "pubkey" - } - }, - { - "name": "feeSettled", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "marketType", - "type": { - "defined": { - "name": "marketType" - } - } - }, - { - "name": "builderSubAccountId", - "type": "u16" - }, - { - "name": "builderTotalReferrerRewards", - "type": "u64" - }, - { - "name": "builderTotalBuilderRewards", - "type": "u64" - } - ] - } - }, - { - "name": "serumV3FulfillmentConfig", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "type": "pubkey" - }, - { - "name": "serumProgramId", - "type": "pubkey" - }, - { - "name": "serumMarket", - "type": "pubkey" - }, - { - "name": "serumRequestQueue", - "type": "pubkey" - }, - { - "name": "serumEventQueue", - "type": "pubkey" - }, - { - "name": "serumBids", - "type": "pubkey" - }, - { - "name": "serumAsks", - "type": "pubkey" - }, - { - "name": "serumBaseVault", - "type": "pubkey" - }, - { - "name": "serumQuoteVault", - "type": "pubkey" - }, - { - "name": "serumOpenOrders", - "type": "pubkey" - }, - { - "name": "serumSignerNonce", - "type": "u64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "fulfillmentType", - "type": { - "defined": { - "name": "spotFulfillmentType" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "spotFulfillmentConfigStatus" - } - } - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "settlePnlExplanation", - "type": { - "kind": "enum", - "variants": [ - { - "name": "none" - }, - { - "name": "expiredPosition" - } - ] - } - }, - { - "name": "settlePnlMode", - "type": { - "kind": "enum", - "variants": [ - { - "name": "mustSettle" - }, - { - "name": "trySettle" - } - ] - } - }, - { - "name": "settlePnlRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "pnl", - "type": "i128" - }, - { - "name": "baseAssetAmount", - "type": "i64" - }, - { - "name": "quoteAssetAmountAfter", - "type": "i64" - }, - { - "name": "quoteEntryAmount", - "type": "i64" - }, - { - "name": "settlePrice", - "type": "i64" - }, - { - "name": "explanation", - "type": { - "defined": { - "name": "settlePnlExplanation" - } - } - } - ] - } - }, - { - "name": "signedMsgOrderId", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "uuid", - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "maxSlot", - "type": "u64" - }, - { - "name": "orderId", - "type": "u32" - }, - { - "name": "padding", - "type": "u32" - } - ] - } - }, - { - "name": "signedMsgOrderRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "hash", - "type": "string" - }, - { - "name": "matchingOrderParams", - "type": { - "defined": { - "name": "orderParams" - } - } - }, - { - "name": "userOrderId", - "type": "u32" - }, - { - "name": "signedMsgOrderMaxSlot", - "type": "u64" - }, - { - "name": "signedMsgOrderUuid", - "type": { - "array": [ - "u8", - 8 - ] - } - }, - { - "name": "ts", - "type": "i64" - } - ] - } - }, - { - "name": "signedMsgUserOrders", - "docs": [ - "* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently" - ], - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authorityPubkey", - "type": "pubkey" - }, - { - "name": "padding", - "type": "u32" - }, - { - "name": "signedMsgOrderData", - "type": { - "vec": { - "defined": { - "name": "signedMsgOrderId" - } - } - } - } - ] - } - }, - { - "name": "signedMsgWsDelegates", - "docs": [ - "* Used to store authenticated delegates for swift-like ws connections" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "delegates", - "type": { - "vec": "pubkey" - } - } - ] - } - }, - { - "name": "spotBalanceType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "deposit" - }, - { - "name": "borrow" - } - ] - } - }, - { - "name": "spotBankruptcyRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "borrowAmount", - "type": "u128" - }, - { - "name": "ifPayment", - "type": "u128" - }, - { - "name": "cumulativeDepositInterestDelta", - "type": "u128" - } - ] - } - }, - { - "name": "spotFulfillmentConfigStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "enabled" - }, - { - "name": "disabled" - } - ] - } - }, - { - "name": "spotFulfillmentType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "serumV3" - }, - { - "name": "match" - }, - { - "name": "phoenixV1" - }, - { - "name": "openbookV2" - } - ] - } - }, - { - "name": "spotInterestRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "depositBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulativeDepositInterest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "borrowBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulativeBorrowInterest", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "optimalUtilization", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimalBorrowRate", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - }, - { - "name": "maxBorrowRate", - "docs": [ - "precision: PERCENTAGE_PRECISION" - ], - "type": "u32" - } - ] - } - }, - { - "name": "spotMarket", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "pubkey", - "docs": [ - "The address of the spot market. It is a pda of the market index" - ], - "type": "pubkey" - }, - { - "name": "oracle", - "docs": [ - "The oracle used to price the markets deposits/borrows" - ], - "type": "pubkey" - }, - { - "name": "mint", - "docs": [ - "The token mint of the market" - ], - "type": "pubkey" - }, - { - "name": "vault", - "docs": [ - "The vault used to store the market's deposits", - "The amount in the vault should be equal to or greater than deposits - borrows" - ], - "type": "pubkey" - }, - { - "name": "name", - "docs": [ - "The encoded display name for the market e.g. SOL" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "historicalOracleData", - "type": { - "defined": { - "name": "historicalOracleData" - } - } - }, - { - "name": "historicalIndexData", - "type": { - "defined": { - "name": "historicalIndexData" - } - } - }, - { - "name": "revenuePool", - "docs": [ - "Revenue the protocol has collected in this markets token", - "e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool" - ], - "type": { - "defined": { - "name": "poolBalance" - } - } - }, - { - "name": "spotFeePool", - "docs": [ - "The fees collected from swaps between this market and the quote market", - "Is settled to the quote markets revenue pool" - ], - "type": { - "defined": { - "name": "poolBalance" - } - } - }, - { - "name": "insuranceFund", - "docs": [ - "Details on the insurance fund covering bankruptcies in this markets token", - "Covers bankruptcies for borrows with this markets token and perps settling in this markets token" - ], - "type": { - "defined": { - "name": "insuranceFund" - } - } - }, - { - "name": "totalSpotFee", - "docs": [ - "The total spot fees collected for this market", - "precision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "depositBalance", - "docs": [ - "The sum of the scaled balances for deposits across users and pool balances", - "To convert to the deposit token amount, multiply by the cumulative deposit interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "borrowBalance", - "docs": [ - "The sum of the scaled balances for borrows across users and pool balances", - "To convert to the borrow token amount, multiply by the cumulative borrow interest", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeDepositInterest", - "docs": [ - "The cumulative interest earned by depositors", - "Used to calculate the deposit token amount from the deposit balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "cumulativeBorrowInterest", - "docs": [ - "The cumulative interest earned by borrowers", - "Used to calculate the borrow token amount from the borrow balance", - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalSocialLoss", - "docs": [ - "The total socialized loss from borrows, in the mint's token", - "precision: token mint precision" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "totalQuoteSocialLoss", - "docs": [ - "The total socialized loss from borrows, in the quote market's token", - "preicision: QUOTE_PRECISION" - ], - "type": { - "defined": { - "name": "u128" - } - } - }, - { - "name": "withdrawGuardThreshold", - "docs": [ - "no withdraw limits/guards when deposits below this threshold", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "maxTokenDeposits", - "docs": [ - "The max amount of token deposits in this market", - "0 if there is no limit", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "depositTokenTwap", - "docs": [ - "24hr average of deposit token amount", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "borrowTokenTwap", - "docs": [ - "24hr average of borrow token amount", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "utilizationTwap", - "docs": [ - "24hr average of utilization", - "which is borrow amount over token amount", - "precision: SPOT_UTILIZATION_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastInterestTs", - "docs": [ - "Last time the cumulative deposit and borrow interest was updated" - ], - "type": "u64" - }, - { - "name": "lastTwapTs", - "docs": [ - "Last time the deposit/borrow/utilization averages were updated" - ], - "type": "u64" - }, - { - "name": "expiryTs", - "docs": [ - "The time the market is set to expire. Only set if market is in reduce only mode" - ], - "type": "i64" - }, - { - "name": "orderStepSize", - "docs": [ - "Spot orders must be a multiple of the step size", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "orderTickSize", - "docs": [ - "Spot orders must be a multiple of the tick size", - "precision: PRICE_PRECISION" - ], - "type": "u64" - }, - { - "name": "minOrderSize", - "docs": [ - "The minimum order size", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "maxPositionSize", - "docs": [ - "The maximum spot position size", - "if the limit is 0, there is no limit", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "nextFillRecordId", - "docs": [ - "Every spot trade has a fill record id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "nextDepositRecordId", - "docs": [ - "Every deposit has a deposit record id. This is the next id to use" - ], - "type": "u64" - }, - { - "name": "initialAssetWeight", - "docs": [ - "The initial asset weight used to calculate a deposits contribution to a users initial total collateral", - "e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "maintenanceAssetWeight", - "docs": [ - "The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral", - "e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "initialLiabilityWeight", - "docs": [ - "The initial liability weight used to calculate a borrows contribution to a users initial margin requirement", - "e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "maintenanceLiabilityWeight", - "docs": [ - "The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement", - "e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement", - "precision: SPOT_WEIGHT_PRECISION" - ], - "type": "u32" - }, - { - "name": "imfFactor", - "docs": [ - "The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions", - "precision: MARGIN_PRECISION" - ], - "type": "u32" - }, - { - "name": "liquidatorFee", - "docs": [ - "The fee the liquidator is paid for taking over borrow/deposit", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "ifLiquidationFee", - "docs": [ - "The fee the insurance fund receives from liquidation", - "precision: LIQUIDATOR_FEE_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimalUtilization", - "docs": [ - "The optimal utilization rate for this market.", - "Used to determine the markets borrow rate", - "precision: SPOT_UTILIZATION_PRECISION" - ], - "type": "u32" - }, - { - "name": "optimalBorrowRate", - "docs": [ - "The borrow rate for this market when the market has optimal utilization", - "precision: SPOT_RATE_PRECISION" - ], - "type": "u32" - }, - { - "name": "maxBorrowRate", - "docs": [ - "The borrow rate for this market when the market has 1000 utilization", - "precision: SPOT_RATE_PRECISION" - ], - "type": "u32" - }, - { - "name": "decimals", - "docs": [ - "The market's token mint's decimals. To from decimals to a precision, 10^decimals" - ], - "type": "u32" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "ordersEnabled", - "docs": [ - "Whether or not spot trading is enabled" - ], - "type": "bool" - }, - { - "name": "oracleSource", - "type": { - "defined": { - "name": "oracleSource" - } - } - }, - { - "name": "status", - "type": { - "defined": { - "name": "marketStatus" - } - } - }, - { - "name": "assetTier", - "docs": [ - "The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated" - ], - "type": { - "defined": { - "name": "assetTier" - } - } - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "ifPausedOperations", - "type": "u8" - }, - { - "name": "feeAdjustment", - "type": "i16" - }, - { - "name": "maxTokenBorrowsFraction", - "docs": [ - "What fraction of max_token_deposits", - "disabled when 0, 1 => 1/10000 => .01% of max_token_deposits", - "precision: X/10000" - ], - "type": "u16" - }, - { - "name": "flashLoanAmount", - "docs": [ - "For swaps, the amount of token loaned out in the begin_swap ix", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "flashLoanInitialTokenAmount", - "docs": [ - "For swaps, the amount in the users token account in the begin_swap ix", - "Used to calculate how much of the token left the system in end_swap ix", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "totalSwapFee", - "docs": [ - "The total fees received from swaps", - "precision: token mint precision" - ], - "type": "u64" - }, - { - "name": "scaleInitialAssetWeightStart", - "docs": [ - "When to begin scaling down the initial asset weight", - "disabled when 0", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "minBorrowRate", - "docs": [ - "The min borrow rate for this market when the market regardless of utilization", - "1 => 1/200 => .5%", - "precision: X/200" - ], - "type": "u8" - }, - { - "name": "fuelBoostDeposits", - "docs": [ - "fuel multiplier for spot deposits", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostBorrows", - "docs": [ - "fuel multiplier for spot borrows", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostTaker", - "docs": [ - "fuel multiplier for spot taker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostMaker", - "docs": [ - "fuel multiplier for spot maker", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "fuelBoostInsurance", - "docs": [ - "fuel multiplier for spot insurance stake", - "precision: 10" - ], - "type": "u8" - }, - { - "name": "tokenProgramFlag", - "type": "u8" - }, - { - "name": "poolId", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 40 - ] - } - } - ] - } - }, - { - "name": "spotMarketVaultDepositRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "depositBalance", - "docs": [ - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulativeDepositInterestBefore", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "cumulativeDepositInterestAfter", - "docs": [ - "precision: SPOT_CUMULATIVE_INTEREST_PRECISION" - ], - "type": "u128" - }, - { - "name": "depositTokenAmountBefore", - "type": "u64" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "spotPosition", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "scaledBalance", - "docs": [ - "The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow", - "interest of corresponding market.", - "precision: SPOT_BALANCE_PRECISION" - ], - "type": "u64" - }, - { - "name": "openBids", - "docs": [ - "How many spot non reduce only trigger orders the user has open", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "openAsks", - "docs": [ - "How many spot non reduce only trigger orders the user has open", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "cumulativeDeposits", - "docs": [ - "The cumulative deposits/borrows a user has made into a market", - "precision: token mint precision" - ], - "type": "i64" - }, - { - "name": "marketIndex", - "docs": [ - "The market index of the corresponding spot market" - ], - "type": "u16" - }, - { - "name": "balanceType", - "docs": [ - "Whether the position is deposit or borrow" - ], - "type": { - "defined": { - "name": "spotBalanceType" - } - } - }, - { - "name": "openOrders", - "docs": [ - "Number of open orders" - ], - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - } - ] - } - }, - { - "name": "stakeAction", - "type": { - "kind": "enum", - "variants": [ - { - "name": "stake" - }, - { - "name": "unstakeRequest" - }, - { - "name": "unstakeCancelRequest" - }, - { - "name": "unstake" - }, - { - "name": "unstakeTransfer" - }, - { - "name": "stakeTransfer" - }, - { - "name": "adminDeposit" - } - ] - } - }, - { - "name": "state", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "admin", - "type": "pubkey" - }, - { - "name": "whitelistMint", - "type": "pubkey" - }, - { - "name": "discountMint", - "type": "pubkey" - }, - { - "name": "signer", - "type": "pubkey" - }, - { - "name": "srmVault", - "type": "pubkey" - }, - { - "name": "perpFeeStructure", - "type": { - "defined": { - "name": "feeStructure" - } - } - }, - { - "name": "spotFeeStructure", - "type": { - "defined": { - "name": "feeStructure" - } - } - }, - { - "name": "oracleGuardRails", - "type": { - "defined": { - "name": "oracleGuardRails" - } - } - }, - { - "name": "numberOfAuthorities", - "type": "u64" - }, - { - "name": "numberOfSubAccounts", - "type": "u64" - }, - { - "name": "lpCooldownTime", - "type": "u64" - }, - { - "name": "liquidationMarginBufferRatio", - "type": "u32" - }, - { - "name": "settlementDuration", - "type": "u16" - }, - { - "name": "numberOfMarkets", - "type": "u16" - }, - { - "name": "numberOfSpotMarkets", - "type": "u16" - }, - { - "name": "signerNonce", - "type": "u8" - }, - { - "name": "minPerpAuctionDuration", - "type": "u8" - }, - { - "name": "defaultMarketOrderTimeInForce", - "type": "u8" - }, - { - "name": "defaultSpotAuctionDuration", - "type": "u8" - }, - { - "name": "exchangeStatus", - "type": "u8" - }, - { - "name": "liquidationDuration", - "type": "u8" - }, - { - "name": "initialPctToLiquidate", - "type": "u16" - }, - { - "name": "maxNumberOfSubAccounts", - "type": "u16" - }, - { - "name": "maxInitializeUserFee", - "type": "u16" - }, - { - "name": "featureBitFlags", - "type": "u8" - }, - { - "name": "lpPoolFeatureBitFlags", - "type": "u8" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - } - }, - { - "name": "swapRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "user", - "type": "pubkey" - }, - { - "name": "amountOut", - "docs": [ - "precision: out market mint precision" - ], - "type": "u64" - }, - { - "name": "amountIn", - "docs": [ - "precision: in market mint precision" - ], - "type": "u64" - }, - { - "name": "outMarketIndex", - "type": "u16" - }, - { - "name": "inMarketIndex", - "type": "u16" - }, - { - "name": "outOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "inOraclePrice", - "docs": [ - "precision: PRICE_PRECISION" - ], - "type": "i64" - }, - { - "name": "fee", - "type": "u64" - } - ] - } - }, - { - "name": "swapReduceOnly", - "type": { - "kind": "enum", - "variants": [ - { - "name": "in" - }, - { - "name": "out" - } - ] - } - }, - { - "name": "targetsDatum", - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "costToTradeBps", - "type": "i32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "targetBase", - "type": "i64" - }, - { - "name": "lastOracleSlot", - "type": "u64" - }, - { - "name": "lastPositionSlot", - "type": "u64" - } - ] - } - }, - { - "name": "transferProtocolIfSharesToRevenuePoolRecord", - "type": { - "kind": "struct", - "fields": [ - { - "name": "ts", - "type": "i64" - }, - { - "name": "marketIndex", - "type": "u16" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "shares", - "type": "u128" - }, - { - "name": "ifVaultAmountBefore", - "type": "u64" - }, - { - "name": "protocolSharesBefore", - "type": "u128" - }, - { - "name": "transferAmount", - "type": "u64" - } - ] - } - }, - { - "name": "updatePerpMarketSummaryStatsParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quoteAssetAmountWithUnsettledLp", - "type": { - "option": "i64" - } - }, - { - "name": "netUnsettledFundingPnl", - "type": { - "option": "i64" - } - }, - { - "name": "updateAmmSummaryStats", - "type": { - "option": "bool" - } - }, - { - "name": "excludeTotalLiqFee", - "type": { - "option": "bool" - } - } - ] - } - }, - { - "name": "user", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "The owner/authority of the account" - ], - "type": "pubkey" - }, - { - "name": "delegate", - "docs": [ - "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw" - ], - "type": "pubkey" - }, - { - "name": "name", - "docs": [ - "Encoded display name e.g. \"toly\"" - ], - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "spotPositions", - "docs": [ - "The user's spot positions" - ], - "type": { - "array": [ - { - "defined": { - "name": "spotPosition" - } - }, - 8 - ] - } - }, - { - "name": "perpPositions", - "docs": [ - "The user's perp positions" - ], - "type": { - "array": [ - { - "defined": { - "name": "perpPosition" - } - }, - 8 - ] - } - }, - { - "name": "orders", - "docs": [ - "The user's orders" - ], - "type": { - "array": [ - { - "defined": { - "name": "order" - } - }, - 32 - ] - } - }, - { - "name": "lastAddPerpLpSharesTs", - "docs": [ - "The last time the user added perp lp positions" - ], - "type": "i64" - }, - { - "name": "totalDeposits", - "docs": [ - "The total values of deposits the user has made", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalWithdraws", - "docs": [ - "The total values of withdrawals the user has made", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalSocialLoss", - "docs": [ - "The total socialized loss the users has incurred upon the protocol", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "settledPerpPnl", - "docs": [ - "Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "cumulativeSpotFees", - "docs": [ - "Fees (taker fees, maker rebate, filler reward) for spot", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "cumulativePerpFunding", - "docs": [ - "Cumulative funding paid/received for perps", - "precision: QUOTE_PRECISION" - ], - "type": "i64" - }, - { - "name": "liquidationMarginFreed", - "docs": [ - "The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time", - "Defaults to zero when not being liquidated", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastActiveSlot", - "docs": [ - "The last slot a user was active. Used to determine if a user is idle" - ], - "type": "u64" - }, - { - "name": "nextOrderId", - "docs": [ - "Every user order has an order id. This is the next order id to be used" - ], - "type": "u32" - }, - { - "name": "maxMarginRatio", - "docs": [ - "Custom max initial margin ratio for the user" - ], - "type": "u32" - }, - { - "name": "nextLiquidationId", - "docs": [ - "The next liquidation id to be used for user" - ], - "type": "u16" - }, - { - "name": "subAccountId", - "docs": [ - "The sub account id for this user" - ], - "type": "u16" - }, - { - "name": "status", - "docs": [ - "Whether the user is active, being liquidated or bankrupt" - ], - "type": "u8" - }, - { - "name": "isMarginTradingEnabled", - "docs": [ - "Whether the user has enabled margin trading" - ], - "type": "bool" - }, - { - "name": "idle", - "docs": [ - "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", - "Off-chain keeper bots can ignore users that are idle" - ], - "type": "bool" - }, - { - "name": "openOrders", - "docs": [ - "number of open orders" - ], - "type": "u8" - }, - { - "name": "hasOpenOrder", - "docs": [ - "Whether or not user has open order" - ], - "type": "bool" - }, - { - "name": "openAuctions", - "docs": [ - "number of open orders with auction" - ], - "type": "u8" - }, - { - "name": "hasOpenAuction", - "docs": [ - "Whether or not user has open order with auction" - ], - "type": "bool" - }, - { - "name": "marginMode", - "type": { - "defined": { - "name": "marginMode" - } - } - }, - { - "name": "poolId", - "type": "u8" - }, - { - "name": "padding1", - "type": { - "array": [ - "u8", - 3 - ] - } - }, - { - "name": "lastFuelBonusUpdateTs", - "type": "u32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 12 - ] - } - } - ] - } - }, - { - "name": "userFees", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "totalFeePaid", - "docs": [ - "Total taker fee paid", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalFeeRebate", - "docs": [ - "Total maker fee rebate", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalTokenDiscount", - "docs": [ - "Total discount from holding token", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalRefereeDiscount", - "docs": [ - "Total discount from being referred", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "totalReferrerReward", - "docs": [ - "Total reward to referrer", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "currentEpochReferrerReward", - "docs": [ - "Total reward to referrer this epoch", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - } - ] - } - }, - { - "name": "userStats", - "serialization": "bytemuckunsafe", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "authority", - "docs": [ - "The authority for all of a users sub accounts" - ], - "type": "pubkey" - }, - { - "name": "referrer", - "docs": [ - "The address that referred this user" - ], - "type": "pubkey" - }, - { - "name": "fees", - "docs": [ - "Stats on the fees paid by the user" - ], - "type": { - "defined": { - "name": "userFees" - } - } - }, - { - "name": "nextEpochTs", - "docs": [ - "The timestamp of the next epoch", - "Epoch is used to limit referrer rewards earned in single epoch" - ], - "type": "i64" - }, - { - "name": "makerVolume30d", - "docs": [ - "Rolling 30day maker volume for user", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "takerVolume30d", - "docs": [ - "Rolling 30day taker volume for user", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "fillerVolume30d", - "docs": [ - "Rolling 30day filler volume for user", - "precision: QUOTE_PRECISION" - ], - "type": "u64" - }, - { - "name": "lastMakerVolume30dTs", - "docs": [ - "last time the maker volume was updated" - ], - "type": "i64" - }, - { - "name": "lastTakerVolume30dTs", - "docs": [ - "last time the taker volume was updated" - ], - "type": "i64" - }, - { - "name": "lastFillerVolume30dTs", - "docs": [ - "last time the filler volume was updated" - ], - "type": "i64" - }, - { - "name": "ifStakedQuoteAssetAmount", - "docs": [ - "The amount of tokens staked in the quote spot markets if" - ], - "type": "u64" - }, - { - "name": "numberOfSubAccounts", - "docs": [ - "The current number of sub accounts" - ], - "type": "u16" - }, - { - "name": "numberOfSubAccountsCreated", - "docs": [ - "The number of sub accounts created. Can be greater than the number of sub accounts if user", - "has deleted sub accounts" - ], - "type": "u16" - }, - { - "name": "referrerStatus", - "docs": [ - "Flags for referrer status:", - "First bit (LSB): 1 if user is a referrer, 0 otherwise", - "Second bit: 1 if user was referred, 0 otherwise" - ], - "type": "u8" - }, - { - "name": "disableUpdatePerpBidAskTwap", - "type": "u8" - }, - { - "name": "pausedOperations", - "type": "u8" - }, - { - "name": "fuelOverflowStatus", - "docs": [ - "whether the user has a FuelOverflow account" - ], - "type": "u8" - }, - { - "name": "fuelInsurance", - "docs": [ - "accumulated fuel for token amounts of insurance" - ], - "type": "u32" - }, - { - "name": "fuelDeposits", - "docs": [ - "accumulated fuel for notional of deposits" - ], - "type": "u32" - }, - { - "name": "fuelBorrows", - "docs": [ - "accumulate fuel bonus for notional of borrows" - ], - "type": "u32" - }, - { - "name": "fuelPositions", - "docs": [ - "accumulated fuel for perp open interest" - ], - "type": "u32" - }, - { - "name": "fuelTaker", - "docs": [ - "accumulate fuel bonus for taker volume" - ], - "type": "u32" - }, - { - "name": "fuelMaker", - "docs": [ - "accumulate fuel bonus for maker volume" - ], - "type": "u32" - }, - { - "name": "ifStakedGovTokenAmount", - "docs": [ - "The amount of tokens staked in the governance spot markets if" - ], - "type": "u64" - }, - { - "name": "lastFuelIfBonusUpdateTs", - "docs": [ - "last unix ts user stats data was used to update if fuel (u32 to save space)" - ], - "type": "u32" - }, - { - "name": "padding", - "type": { - "array": [ - "u8", - 12 - ] - } - } - ] - } - }, - { - "name": "validityGuardRails", - "type": { - "kind": "struct", - "fields": [ - { - "name": "slotsBeforeStaleForAmm", - "type": "i64" - }, - { - "name": "slotsBeforeStaleForMargin", - "type": "i64" - }, - { - "name": "confidenceIntervalMaxSize", - "type": "u64" - }, - { - "name": "tooVolatileRatio", - "type": "i64" - } - ] - } - }, - { - "name": "i128", - "docs": [ - "`i128` with legacy bit layout" - ], - "type": { - "kind": "struct", - "fields": [ - { - "array": [ - "u8", - 16 - ] - } - ] - } - }, - { - "name": "u128", - "docs": [ - "`u128` with legacy bit layout" - ], - "type": { - "kind": "struct", - "fields": [ - { - "array": [ - "u8", - 16 - ] - } - ] - } - } - ] + address: 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; + metadata: { + name: 'drift'; + version: '2.151.0'; + spec: '0.1.0'; + description: 'Created with Anchor'; + }; + instructions: [ + { + name: 'addAmmConstituentMappingData'; + discriminator: [164, 236, 130, 40, 118, 179, 46, 235]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'ammConstituentMappingData'; + type: { + vec: { + defined: { + name: 'addAmmConstituentMappingDatum'; + }; + }; + }; + }, + ]; + }, + { + name: 'addInsuranceFundStake'; + discriminator: [251, 144, 115, 11, 222, 47, 62, 236]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'addMarketToAmmCache'; + discriminator: [112, 149, 195, 222, 124, 7, 87, 237]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'adminDeposit'; + discriminator: [210, 66, 65, 182, 102, 214, 176, 30]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'adminTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'adminUpdateUserStatsPausedOperations'; + discriminator: [183, 104, 63, 150, 240, 199, 3, 10]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'beginInsuranceFundSwap'; + discriminator: [176, 69, 143, 205, 32, 132, 163, 0]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'outInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'beginLpSwap'; + discriminator: [64, 44, 24, 199, 48, 125, 67, 91]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'signerOutTokenAccount'; + docs: ['Signer token accounts']; + writable: true; + }, + { + name: 'signerInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + docs: ['Constituent token accounts']; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'outConstituent'; + docs: ['Constituents']; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpPool'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'beginSwap'; + discriminator: [174, 109, 228, 1, 242, 105, 232, 105]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'amountIn'; + type: 'u64'; + }, + ]; + }, + { + name: 'cancelOrder'; + discriminator: [95, 129, 237, 240, 8, 49, 223, 132]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'cancelOrderByUserId'; + discriminator: [107, 211, 250, 133, 18, 37, 57, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'userOrderId'; + type: 'u8'; + }, + ]; + }, + { + name: 'cancelOrders'; + discriminator: [238, 225, 95, 158, 227, 103, 8, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'marketType'; + type: { + option: { + defined: { + name: 'marketType'; + }; + }; + }; + }, + { + name: 'marketIndex'; + type: { + option: 'u16'; + }; + }, + { + name: 'direction'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + ]; + }, + { + name: 'cancelOrdersByIds'; + discriminator: [134, 19, 144, 165, 94, 240, 210, 94]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderIds'; + type: { + vec: 'u32'; + }; + }, + ]; + }, + { + name: 'cancelRequestRemoveInsuranceFundStake'; + discriminator: [97, 235, 78, 62, 212, 42, 241, 127]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'changeApprovedBuilder'; + discriminator: [179, 134, 211, 45, 195, 5, 189, 173]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + relations: ['escrow']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'builder'; + type: 'pubkey'; + }, + { + name: 'maxFeeBps'; + type: 'u16'; + }, + { + name: 'add'; + type: 'bool'; + }, + ]; + }, + { + name: 'changeSignedMsgWsDelegateStatus'; + discriminator: [252, 202, 252, 219, 179, 27, 84, 138]; + accounts: [ + { + name: 'signedMsgWsDelegates'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'delegate'; + type: 'pubkey'; + }, + { + name: 'add'; + type: 'bool'; + }, + ]; + }, + { + name: 'deleteAmmCache'; + discriminator: [216, 130, 215, 206, 233, 232, 191, 88]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'deleteInitializedPerpMarket'; + discriminator: [91, 154, 24, 87, 106, 59, 190, 66]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deleteInitializedSpotMarket'; + discriminator: [31, 140, 67, 191, 189, 20, 101, 221]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deletePrelaunchOracle'; + discriminator: [59, 169, 100, 49, 69, 17, 173, 253]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'perpMarketIndex'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'deleteSignedMsgUserOrders'; + discriminator: [221, 247, 128, 253, 212, 254, 46, 153]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'deleteUser'; + discriminator: [186, 85, 17, 249, 219, 231, 98, 251]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + writable: true; + signer: true; + relations: ['user', 'userStats']; + }, + ]; + args: []; + }, + { + name: 'deposit'; + discriminator: [242, 35, 198, 137, 82, 225, 242, 182]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'depositIntoInsuranceFundStake'; + discriminator: [4, 22, 226, 201, 124, 44, 82, 230]; + accounts: [ + { + name: 'signer'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101, + ]; + }, + { + kind: 'account'; + path: 'userStats'; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoPerpMarketFeePool'; + discriminator: [34, 58, 57, 68, 97, 80, 244, 6]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'sourceVault'; + writable: true; + }, + { + name: 'driftSigner'; + }, + { + name: 'quoteSpotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoSpotMarketRevenuePool'; + discriminator: [92, 40, 151, 42, 122, 254, 139, 246]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositIntoSpotMarketVault'; + discriminator: [48, 252, 119, 73, 255, 205, 174, 247]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'sourceVault'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'depositToProgramVault'; + discriminator: [235, 171, 121, 80, 57, 239, 147, 220]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'constituentTokenAccount'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'mint'; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'disableUserHighLeverageMode'; + discriminator: [183, 155, 45, 0, 226, 85, 213, 69]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'disableMaintenance'; + type: 'bool'; + }, + ]; + }, + { + name: 'enableUserHighLeverageMode'; + discriminator: [231, 24, 230, 112, 201, 173, 73, 184]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + ]; + }, + { + name: 'endInsuranceFundSwap'; + discriminator: [206, 230, 98, 8, 249, 158, 169, 167]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'outInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inInsuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'endLpSwap'; + discriminator: [99, 125, 214, 165, 129, 175, 253, 135]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'signerOutTokenAccount'; + docs: ['Signer token accounts']; + writable: true; + }, + { + name: 'signerInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + docs: ['Constituent token accounts']; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'outConstituent'; + docs: ['Constituents']; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpPool'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'endSwap'; + discriminator: [177, 184, 27, 193, 34, 13, 210, 145]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outTokenAccount'; + writable: true; + }, + { + name: 'inTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'reduceOnly'; + type: { + option: { + defined: { + name: 'swapReduceOnly'; + }; + }; + }; + }, + ]; + }, + { + name: 'fillPerpOrder'; + discriminator: [13, 188, 248, 103, 134, 217, 106, 240]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'fillSpotOrder'; + discriminator: [212, 206, 130, 173, 21, 34, 199, 40]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'forceCancelOrders'; + discriminator: [64, 181, 196, 63, 222, 72, 64, 232]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'forceDeleteUser'; + discriminator: [2, 241, 195, 172, 227, 24, 254, 158]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + writable: true; + relations: ['user', 'userStats']; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'driftSigner'; + }, + ]; + args: []; + }, + { + name: 'initialize'; + discriminator: [175, 175, 109, 31, 13, 152, 155, 237]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [100, 114, 105, 102, 116, 95, 115, 116, 97, 116, 101]; + }, + ]; + }; + }, + { + name: 'quoteAssetMint'; + }, + { + name: 'driftSigner'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: []; + }, + { + name: 'initializeAmmCache'; + discriminator: [38, 60, 171, 158, 203, 58, 137, 8]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeConstituent'; + discriminator: [12, 196, 45, 218, 93, 89, 0, 33]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketMint'; + }, + { + name: 'constituentVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'decimals'; + type: 'u8'; + }, + { + name: 'maxWeightDeviation'; + type: 'i64'; + }, + { + name: 'swapFeeMin'; + type: 'i64'; + }, + { + name: 'swapFeeMax'; + type: 'i64'; + }, + { + name: 'maxBorrowTokenAmount'; + type: 'u64'; + }, + { + name: 'oracleStalenessThreshold'; + type: 'u64'; + }, + { + name: 'costToTrade'; + type: 'i32'; + }, + { + name: 'constituentDerivativeIndex'; + type: { + option: 'i16'; + }; + }, + { + name: 'constituentDerivativeDepegThreshold'; + type: 'u64'; + }, + { + name: 'derivativeWeight'; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'gammaInventory'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'newConstituentCorrelations'; + type: { + vec: 'i64'; + }; + }, + ]; + }, + { + name: 'initializeFuelOverflow'; + discriminator: [88, 223, 132, 161, 208, 88, 142, 42]; + accounts: [ + { + name: 'fuelOverflow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 102, + 117, + 101, + 108, + 95, + 111, + 118, + 101, + 114, + 102, + 108, + 111, + 119, + ]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeHighLeverageModeConfig'; + discriminator: [213, 167, 93, 246, 208, 130, 90, 248]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializeIfRebalanceConfig'; + discriminator: [8, 85, 184, 167, 176, 61, 173, 226]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 102, + 95, + 114, + 101, + 98, + 97, + 108, + 97, + 110, + 99, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'arg'; + path: 'params.in_market_index'; + }, + { + kind: 'arg'; + path: 'params.out_market_index'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'ifRebalanceConfigParams'; + }; + }; + }, + ]; + }, + { + name: 'initializeInsuranceFundStake'; + discriminator: [187, 179, 243, 70, 248, 90, 92, 147]; + accounts: [ + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 115, + 116, + 97, + 107, + 101, + ]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeLpPool'; + discriminator: [242, 64, 1, 222, 142, 46, 204, 227]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [108, 112, 95, 112, 111, 111, 108]; + }, + { + kind: 'arg'; + path: 'id'; + }, + ]; + }; + }, + { + name: 'mint'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'tokenProgram'; + address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'minMintFee'; + type: 'i64'; + }, + { + name: 'maxAum'; + type: 'u128'; + }, + { + name: 'maxSettleQuoteAmountPerMarket'; + type: 'u64'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'initializeOpenbookV2FulfillmentConfig'; + discriminator: [7, 221, 103, 153, 107, 57, 27, 197]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'openbookV2Program'; + }, + { + name: 'openbookV2Market'; + }, + { + name: 'driftSigner'; + }, + { + name: 'openbookV2FulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 111, + 112, + 101, + 110, + 98, + 111, + 111, + 107, + 95, + 118, + 50, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'openbookV2Market'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializePerpMarket'; + discriminator: [132, 9, 229, 118, 117, 118, 117, 62]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'perpMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 101, 114, 112, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'state.number_of_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'ammBaseAssetReserve'; + type: 'u128'; + }, + { + name: 'ammQuoteAssetReserve'; + type: 'u128'; + }, + { + name: 'ammPeriodicity'; + type: 'i64'; + }, + { + name: 'ammPegMultiplier'; + type: 'u128'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'contractTier'; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + { + name: 'marginRatioInitial'; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'activeStatus'; + type: 'bool'; + }, + { + name: 'baseSpread'; + type: 'u32'; + }, + { + name: 'maxSpread'; + type: 'u32'; + }, + { + name: 'maxOpenInterest'; + type: 'u128'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + type: 'u64'; + }, + { + name: 'orderStepSize'; + type: 'u64'; + }, + { + name: 'orderTickSize'; + type: 'u64'; + }, + { + name: 'minOrderSize'; + type: 'u64'; + }, + { + name: 'concentrationCoefScale'; + type: 'u128'; + }, + { + name: 'curveUpdateIntensity'; + type: 'u8'; + }, + { + name: 'ammJitIntensity'; + type: 'u8'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'initializePhoenixFulfillmentConfig'; + discriminator: [135, 132, 110, 107, 185, 160, 169, 154]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'phoenixProgram'; + }, + { + name: 'phoenixMarket'; + }, + { + name: 'driftSigner'; + }, + { + name: 'phoenixFulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 104, + 111, + 101, + 110, + 105, + 120, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'phoenixMarket'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializePredictionMarket'; + discriminator: [248, 70, 198, 224, 224, 105, 125, 195]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'initializePrelaunchOracle'; + discriminator: [169, 178, 84, 25, 175, 62, 29, 247]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'params.perp_market_index'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'prelaunchOracleParams'; + }; + }; + }, + ]; + }, + { + name: 'initializeProtectedMakerModeConfig'; + discriminator: [67, 103, 220, 67, 88, 32, 252, 8]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializePythLazerOracle'; + discriminator: [140, 107, 33, 214, 235, 219, 103, 20]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lazerOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 108, 97, 122, 101, 114]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + { + name: 'state'; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'feedId'; + type: 'u32'; + }, + ]; + }, + { + name: 'initializePythPullOracle'; + discriminator: [249, 140, 253, 243, 248, 74, 240, 238]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeReferrerName'; + discriminator: [235, 126, 231, 10, 42, 164, 26, 61]; + accounts: [ + { + name: 'referrerName'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 114, + 101, + 102, + 101, + 114, + 114, + 101, + 114, + 95, + 110, + 97, + 109, + 101, + ]; + }, + { + kind: 'arg'; + path: 'name'; + }, + ]; + }; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeRevenueShare'; + discriminator: [57, 9, 123, 131, 82, 52, 50, 13]; + accounts: [ + { + name: 'revenueShare'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 83, 72, 65, 82, 69]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'initializeRevenueShareEscrow'; + discriminator: [187, 18, 123, 88, 238, 104, 84, 154]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSerumFulfillmentConfig'; + discriminator: [193, 211, 132, 172, 70, 171, 7, 94]; + accounts: [ + { + name: 'baseSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'quoteSpotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'serumProgram'; + }, + { + name: 'serumMarket'; + }, + { + name: 'serumOpenOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 101, + 114, + 117, + 109, + 95, + 111, + 112, + 101, + 110, + 95, + 111, + 114, + 100, + 101, + 114, + 115, + ]; + }, + { + kind: 'account'; + path: 'serumMarket'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'serumFulfillmentConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 101, + 114, + 117, + 109, + 95, + 102, + 117, + 108, + 102, + 105, + 108, + 108, + 109, + 101, + 110, + 116, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + { + kind: 'account'; + path: 'serumMarket'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSignedMsgUserOrders'; + discriminator: [164, 99, 156, 126, 156, 57, 99, 180]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'initializeSignedMsgWsDelegates'; + discriminator: [40, 132, 96, 219, 184, 193, 80, 8]; + accounts: [ + { + name: 'signedMsgWsDelegates'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71, 95, 87, 83]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'delegates'; + type: { + vec: 'pubkey'; + }; + }, + ]; + }, + { + name: 'initializeSpotMarket'; + discriminator: [234, 196, 128, 44, 94, 15, 48, 201]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'spotMarketMint'; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'state.number_of_spot_markets'; + account: 'state'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'optimalUtilization'; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + type: 'u32'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'initialAssetWeight'; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + { + name: 'activeStatus'; + type: 'bool'; + }, + { + name: 'assetTier'; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + { + name: 'scaleInitialAssetWeightStart'; + type: 'u64'; + }, + { + name: 'withdrawGuardThreshold'; + type: 'u64'; + }, + { + name: 'orderTickSize'; + type: 'u64'; + }, + { + name: 'orderStepSize'; + type: 'u64'; + }, + { + name: 'ifTotalFactor'; + type: 'u32'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeUser'; + discriminator: [111, 17, 185, 250, 60, 122, 38, 254]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['userStats']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'initializeUserStats'; + discriminator: [254, 243, 72, 98, 251, 130, 168, 213]; + accounts: [ + { + name: 'userStats'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114, 95, 115, 116, 97, 116, 115]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'state'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'liquidateBorrowForPerpPnl'; + discriminator: [169, 17, 32, 90, 207, 148, 209, 27]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxLiabilityTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerp'; + discriminator: [75, 35, 119, 247, 191, 18, 139, 2]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxBaseAssetAmount'; + type: 'u64'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerpPnlForDeposit'; + discriminator: [237, 75, 198, 235, 233, 186, 75, 35]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxPnlTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidatePerpWithFill'; + discriminator: [95, 111, 124, 105, 86, 169, 187, 34]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'liquidateSpot'; + discriminator: [107, 0, 128, 41, 35, 229, 251, 18]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liquidatorMaxLiabilityTransfer'; + type: 'u128'; + }, + { + name: 'limitPrice'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'liquidateSpotWithSwapBegin'; + discriminator: [12, 43, 176, 83, 156, 251, 117, 13]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'liabilitySpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'liabilityMarketIndex'; + }, + ]; + }; + }, + { + name: 'assetSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'assetMarketIndex'; + }, + ]; + }; + }, + { + name: 'liabilityTokenAccount'; + writable: true; + }, + { + name: 'assetTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'swapAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'liquidateSpotWithSwapEnd'; + discriminator: [142, 88, 163, 160, 223, 75, 55, 225]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'liabilitySpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'liabilityMarketIndex'; + }, + ]; + }; + }, + { + name: 'assetSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'assetMarketIndex'; + }, + ]; + }; + }, + { + name: 'liabilityTokenAccount'; + writable: true; + }, + { + name: 'assetTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + { + name: 'instructions'; + docs: ['Instructions Sysvar for instruction introspection']; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'logUserBalances'; + discriminator: [162, 21, 35, 251, 32, 57, 161, 210]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'lpPoolAddLiquidity'; + discriminator: [49, 135, 246, 103, 93, 146, 220, 141]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'inMarketMint'; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'userInTokenAccount'; + writable: true; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'userLpTokenAccount'; + writable: true; + }, + { + name: 'lpMint'; + writable: true; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u128'; + }, + { + name: 'minMintAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'lpPoolRemoveLiquidity'; + discriminator: [164, 36, 193, 252, 196, 157, 138, 43]; + accounts: [ + { + name: 'state'; + }, + { + name: 'driftSigner'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outMarketMint'; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'userOutTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 67, + 79, + 78, + 83, + 84, + 73, + 84, + 85, + 69, + 78, + 84, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'userLpTokenAccount'; + writable: true; + }, + { + name: 'spotMarketTokenAccount'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + writable: true; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'lpPoolTokenVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 76, + 80, + 95, + 80, + 79, + 79, + 76, + 95, + 84, + 79, + 75, + 69, + 78, + 95, + 86, + 65, + 85, + 76, + 84, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + { + name: 'ammCache'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'minOutAmount'; + type: 'u128'; + }, + ]; + }, + { + name: 'lpPoolSwap'; + discriminator: [36, 161, 39, 49, 227, 1, 35, 226]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'constituentCorrelations'; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + }, + { + name: 'userInTokenAccount'; + writable: true; + }, + { + name: 'userOutTokenAccount'; + writable: true; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'inMarketMint'; + }, + { + name: 'outMarketMint'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'minOutAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'modifyOrder'; + discriminator: [47, 124, 117, 255, 201, 197, 130, 94]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'modifyOrderParams'; + type: { + defined: { + name: 'modifyOrderParams'; + }; + }; + }, + ]; + }, + { + name: 'modifyOrderByUserId'; + discriminator: [158, 77, 4, 253, 252, 194, 161, 179]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'userOrderId'; + type: 'u8'; + }, + { + name: 'modifyOrderParams'; + type: { + defined: { + name: 'modifyOrderParams'; + }; + }; + }, + ]; + }, + { + name: 'moveAmmPrice'; + discriminator: [235, 109, 2, 82, 219, 118, 6, 159]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'baseAssetReserve'; + type: 'u128'; + }, + { + name: 'quoteAssetReserve'; + type: 'u128'; + }, + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'openbookV2FulfillmentConfigStatus'; + discriminator: [25, 173, 19, 189, 4, 211, 64, 238]; + accounts: [ + { + name: 'state'; + }, + { + name: 'openbookV2FulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'overrideAmmCacheInfo'; + discriminator: [189, 198, 128, 9, 49, 145, 201, 115]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'overrideParams'; + type: { + defined: { + name: 'overrideAmmCacheParams'; + }; + }; + }, + ]; + }, + { + name: 'pauseSpotMarketDepositWithdraw'; + discriminator: [183, 119, 59, 170, 137, 35, 242, 86]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + signer: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'phoenixFulfillmentConfigStatus'; + discriminator: [96, 31, 113, 32, 12, 203, 7, 154]; + accounts: [ + { + name: 'state'; + }, + { + name: 'phoenixFulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'placeAndMakePerpOrder'; + discriminator: [149, 117, 11, 237, 47, 95, 89, 237]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'takerOrderId'; + type: 'u32'; + }, + ]; + }, + { + name: 'placeAndMakeSignedMsgPerpOrder'; + discriminator: [16, 26, 123, 131, 94, 29, 175, 98]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'takerSignedMsgUserOrders'; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'taker'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'signedMsgOrderUuid'; + type: { + array: ['u8', 8]; + }; + }, + ]; + }, + { + name: 'placeAndMakeSpotOrder'; + discriminator: [149, 158, 85, 66, 239, 9, 243, 98]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'taker'; + writable: true; + }, + { + name: 'takerStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'takerOrderId'; + type: 'u32'; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + ]; + }, + { + name: 'placeAndTakePerpOrder'; + discriminator: [213, 51, 1, 187, 108, 220, 230, 224]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'successCondition'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'placeAndTakeSpotOrder'; + discriminator: [191, 3, 138, 71, 114, 198, 202, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'fulfillmentType'; + type: { + option: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'placeOrders'; + discriminator: [60, 63, 50, 123, 12, 197, 60, 190]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + vec: { + defined: { + name: 'orderParams'; + }; + }; + }; + }, + ]; + }, + { + name: 'placePerpOrder'; + discriminator: [69, 161, 93, 202, 120, 126, 76, 185]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + ]; + }, + { + name: 'placeSignedMsgTakerOrder'; + discriminator: [32, 79, 101, 139, 25, 6, 98, 15]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'user'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'ixSysvar'; + docs: [ + 'the supplied Sysvar could be anything else.', + 'The Instruction Sysvar has not been implemented', + 'in the Anchor framework yet, so this is the safe approach.', + ]; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'signedMsgOrderParamsMessageBytes'; + type: 'bytes'; + }, + { + name: 'isDelegateSigner'; + type: 'bool'; + }, + ]; + }, + { + name: 'placeSpotOrder'; + discriminator: [45, 79, 81, 160, 248, 90, 91, 220]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + ]; + }, + { + name: 'postMultiPythPullOracleUpdatesAtomic'; + discriminator: [243, 79, 204, 228, 227, 208, 100, 244]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'guardianSet'; + }, + ]; + args: [ + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'postPythLazerOracleUpdate'; + discriminator: [218, 237, 170, 245, 39, 143, 166, 33]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythLazerStorage'; + address: '3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL'; + }, + { + name: 'ixSysvar'; + address: 'Sysvar1nstructions1111111111111111111111111'; + }, + ]; + args: [ + { + name: 'pythMessage'; + type: 'bytes'; + }, + ]; + }, + { + name: 'postPythPullOracleUpdateAtomic'; + discriminator: [116, 122, 137, 158, 224, 195, 173, 119]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'guardianSet'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'recenterPerpMarketAmm'; + discriminator: [24, 87, 10, 115, 165, 190, 80, 139]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pegMultiplier'; + type: 'u128'; + }, + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'recenterPerpMarketAmmCrank'; + discriminator: [166, 19, 64, 10, 14, 51, 101, 122]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'perpMarket'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'depth'; + type: { + option: 'u128'; + }; + }, + ]; + }, + { + name: 'reclaimRent'; + discriminator: [218, 200, 19, 197, 227, 89, 192, 22]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + relations: ['user', 'userStats']; + }, + { + name: 'rent'; + address: 'SysvarRent111111111111111111111111111111111'; + }, + ]; + args: []; + }, + { + name: 'removeAmmConstituentMappingData'; + discriminator: [20, 183, 211, 162, 16, 52, 229, 115]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'removeInsuranceFundStake'; + discriminator: [128, 166, 142, 9, 254, 187, 143, 174]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'repegAmmCurve'; + discriminator: [3, 36, 102, 89, 180, 128, 120, 213]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'newPegCandidate'; + type: 'u128'; + }, + ]; + }, + { + name: 'requestRemoveInsuranceFundStake'; + discriminator: [142, 70, 204, 92, 73, 106, 180, 52]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['insuranceFundStake', 'userStats']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'resetFuelSeason'; + discriminator: [199, 122, 192, 255, 32, 99, 63, 200]; + accounts: [ + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['userStats']; + }, + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'resetPerpMarketAmmOracleTwap'; + discriminator: [127, 10, 55, 164, 123, 226, 47, 24]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: []; + }, + { + name: 'resizeRevenueShareEscrowOrders'; + discriminator: [32, 124, 247, 225, 151, 213, 225, 38]; + accounts: [ + { + name: 'escrow'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [82, 69, 86, 95, 69, 83, 67, 82, 79, 87]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['escrow']; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'resizeSignedMsgUserOrders'; + discriminator: [137, 10, 87, 150, 18, 115, 79, 168]; + accounts: [ + { + name: 'signedMsgUserOrders'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [83, 73, 71, 78, 69, 68, 95, 77, 83, 71]; + }, + { + kind: 'account'; + path: 'authority'; + }, + ]; + }; + }, + { + name: 'authority'; + relations: ['user']; + }, + { + name: 'user'; + }, + { + name: 'payer'; + writable: true; + signer: true; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + ]; + args: [ + { + name: 'numOrders'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolvePerpBankruptcy'; + discriminator: [224, 16, 176, 214, 162, 213, 183, 222]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'quoteSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolvePerpPnlDeficit'; + discriminator: [168, 204, 68, 150, 159, 126, 95, 148]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'resolveSpotBankruptcy'; + discriminator: [124, 194, 240, 254, 198, 213, 52, 122]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'liquidator'; + writable: true; + }, + { + name: 'liquidatorStats'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'spotMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'revertFill'; + discriminator: [236, 238, 176, 69, 239, 10, 181, 193]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'fillerStats'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'setUserStatusToBeingLiquidated'; + discriminator: [106, 133, 160, 206, 193, 171, 192, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'settleExpiredMarket'; + discriminator: [120, 89, 11, 25, 122, 77, 72, 193]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'settleExpiredMarketPoolsToRevenuePool'; + discriminator: [55, 19, 238, 169, 227, 90, 200, 184]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'settleFundingPayment'; + discriminator: [222, 90, 202, 94, 28, 45, 115, 183]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'settleMultiplePnls'; + discriminator: [127, 66, 117, 57, 40, 50, 152, 127]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndexes'; + type: { + vec: 'u16'; + }; + }, + { + name: 'mode'; + type: { + defined: { + name: 'settlePnlMode'; + }; + }; + }, + ]; + }, + { + name: 'settlePerpToLpPool'; + discriminator: [5, 98, 46, 188, 10, 59, 2, 249]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + }, + { + name: 'quoteMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'constituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'constituentQuoteTokenAccount'; + writable: true; + }, + { + name: 'quoteTokenVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: []; + }, + { + name: 'settlePnl'; + discriminator: [43, 61, 234, 45, 15, 95, 152, 153]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'settleRevenueToInsuranceFund'; + discriminator: [200, 120, 93, 136, 69, 38, 199, 159]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'sweepFuel'; + discriminator: [175, 107, 19, 56, 165, 241, 43, 69]; + accounts: [ + { + name: 'fuelOverflow'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + relations: ['fuelOverflow', 'userStats']; + }, + { + name: 'signer'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'transferDeposit'; + discriminator: [20, 20, 147, 223, 41, 63, 204, 111]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['fromUser', 'toUser', 'userStats']; + }, + { + name: 'state'; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'transferPerpPosition'; + discriminator: [23, 172, 188, 168, 134, 210, 3, 108]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: { + option: 'i64'; + }; + }, + ]; + }, + { + name: 'transferPools'; + discriminator: [197, 103, 154, 25, 107, 90, 60, 94]; + accounts: [ + { + name: 'fromUser'; + writable: true; + }, + { + name: 'toUser'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['fromUser', 'toUser', 'userStats']; + }, + { + name: 'state'; + }, + { + name: 'depositFromSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'depositFromMarketIndex'; + }, + ]; + }; + }, + { + name: 'depositToSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'depositToMarketIndex'; + }, + ]; + }; + }, + { + name: 'borrowFromSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'borrowFromMarketIndex'; + }, + ]; + }; + }, + { + name: 'borrowToSpotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'borrowToMarketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'depositFromMarketIndex'; + type: 'u16'; + }, + { + name: 'depositToMarketIndex'; + type: 'u16'; + }, + { + name: 'borrowFromMarketIndex'; + type: 'u16'; + }, + { + name: 'borrowToMarketIndex'; + type: 'u16'; + }, + { + name: 'depositAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'borrowAmount'; + type: { + option: 'u64'; + }; + }, + ]; + }, + { + name: 'transferProtocolIfSharesToRevenuePool'; + discriminator: [236, 136, 147, 153, 146, 205, 104, 29]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + writable: true; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'driftSigner'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'triggerOrder'; + discriminator: [63, 112, 51, 233, 232, 47, 240, 199]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: [ + { + name: 'orderId'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateAdmin'; + discriminator: [161, 176, 40, 213, 60, 184, 179, 228]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'admin'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateAmmCache'; + discriminator: [88, 4, 63, 94, 83, 224, 255, 130]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'ammCache'; + writable: true; + }, + { + name: 'quoteMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateAmmConstituentMappingData'; + discriminator: [84, 70, 33, 167, 133, 107, 59, 24]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'ammConstituentMapping'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [65, 77, 77, 95, 77, 65, 80]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'systemProgram'; + address: '11111111111111111111111111111111'; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'ammConstituentMappingData'; + type: { + vec: { + defined: { + name: 'addAmmConstituentMappingDatum'; + }; + }; + }; + }, + ]; + }, + { + name: 'updateAmmJitIntensity'; + discriminator: [181, 191, 53, 109, 166, 249, 55, 142]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ammJitIntensity'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateAmms'; + discriminator: [201, 106, 217, 253, 4, 175, 228, 97]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'marketIndexes'; + type: { + vec: 'u16'; + }; + }, + ]; + }, + { + name: 'updateConstituentCorrelationData'; + discriminator: [79, 14, 19, 73, 221, 106, 62, 109]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentCorrelations'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 99, + 111, + 114, + 114, + 101, + 108, + 97, + 116, + 105, + 111, + 110, + 115, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'index1'; + type: 'u16'; + }, + { + name: 'index2'; + type: 'u16'; + }, + { + name: 'correlation'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateConstituentOracleInfo'; + discriminator: [198, 117, 231, 250, 147, 33, 127, 161]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'spotMarket'; + }, + { + name: 'oracle'; + }, + ]; + args: []; + }, + { + name: 'updateConstituentParams'; + discriminator: [238, 130, 122, 31, 12, 104, 192, 122]; + accounts: [ + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 99, + 111, + 110, + 115, + 116, + 105, + 116, + 117, + 101, + 110, + 116, + 95, + 116, + 97, + 114, + 103, + 101, + 116, + 95, + 98, + 97, + 115, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + ]; + }; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'constituentParams'; + type: { + defined: { + name: 'constituentParams'; + }; + }; + }, + ]; + }, + { + name: 'updateConstituentPausedOperations'; + discriminator: [185, 122, 153, 191, 131, 177, 132, 208]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateConstituentStatus'; + discriminator: [76, 159, 211, 239, 182, 214, 6, 15]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'constituent'; + writable: true; + }, + ]; + args: [ + { + name: 'newStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateDelegateUserGovTokenInsuranceStake'; + discriminator: [241, 29, 215, 228, 142, 116, 22, 160]; + accounts: [ + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: []; + }, + { + name: 'updateDiscountMint'; + discriminator: [32, 252, 122, 211, 66, 31, 47, 241]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'discountMint'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateExchangeStatus'; + discriminator: [83, 160, 252, 250, 129, 116, 49, 223]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'exchangeStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsBuilderCodes'; + discriminator: [1, 128, 177, 51, 173, 45, 11, 102]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMedianTriggerPrice'; + discriminator: [64, 185, 221, 45, 87, 147, 12, 19]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMintRedeemLpPool'; + discriminator: [26, 11, 142, 122, 206, 159, 9, 45]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsMmOracle'; + discriminator: [218, 134, 33, 186, 231, 59, 130, 149]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsSettleLpPool'; + discriminator: [186, 28, 78, 230, 155, 83, 242, 26]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFeatureBitFlagsSwapLpPool'; + discriminator: [83, 16, 150, 12, 102, 3, 22, 58]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'enable'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateFundingRate'; + discriminator: [201, 178, 116, 212, 166, 144, 72, 238]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateHighLeverageModeConfig'; + discriminator: [64, 122, 212, 93, 141, 217, 202, 55]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'highLeverageModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 104, + 105, + 103, + 104, + 95, + 108, + 101, + 118, + 101, + 114, + 97, + 103, + 101, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'currentUsers'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updateIfRebalanceConfig'; + discriminator: [142, 245, 249, 66, 249, 181, 22, 83]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'ifRebalanceConfig'; + writable: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'ifRebalanceConfigParams'; + }; + }; + }, + ]; + }, + { + name: 'updateInitialAmmCacheInfo'; + discriminator: [157, 210, 109, 67, 212, 170, 12, 107]; + accounts: [ + { + name: 'state'; + writable: true; + }, + { + name: 'admin'; + signer: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateInitialPctToLiquidate'; + discriminator: [210, 133, 225, 128, 194, 50, 13, 109]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'initialPctToLiquidate'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateInsuranceFundUnstakingPeriod'; + discriminator: [44, 69, 43, 226, 204, 223, 202, 52]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'insuranceFundUnstakingPeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateK'; + discriminator: [72, 98, 9, 139, 129, 229, 172, 56]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'sqrtK'; + type: 'u128'; + }, + ]; + }, + { + name: 'updateLiquidationDuration'; + discriminator: [28, 154, 20, 249, 102, 192, 73, 71]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidationDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateLiquidationMarginBufferRatio'; + discriminator: [132, 224, 243, 160, 154, 82, 97, 215]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidationMarginBufferRatio'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateLpConstituentTargetBase'; + discriminator: [157, 65, 50, 207, 59, 236, 161, 110]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'ammConstituentMapping'; + }, + { + name: 'constituentTargetBase'; + writable: true; + }, + { + name: 'ammCache'; + }, + { + name: 'lpPool'; + }, + ]; + args: []; + }, + { + name: 'updateLpPoolAum'; + discriminator: [88, 113, 137, 206, 246, 247, 171, 142]; + accounts: [ + { + name: 'state'; + }, + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'lpPool'; + writable: true; + }, + { + name: 'constituentTargetBase'; + writable: true; + }, + { + name: 'ammCache'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateLpPoolParams'; + discriminator: [217, 92, 2, 255, 27, 167, 178, 81]; + accounts: [ + { + name: 'lpPool'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'lpPoolParams'; + type: { + defined: { + name: 'lpPoolParams'; + }; + }; + }, + ]; + }, + { + name: 'updateOracleGuardRails'; + discriminator: [131, 112, 10, 59, 32, 54, 40, 164]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleGuardRails'; + type: { + defined: { + name: 'oracleGuardRails'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpAuctionDuration'; + discriminator: [126, 110, 52, 174, 30, 206, 215, 90]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'minPerpAuctionDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpBidAskTwap'; + discriminator: [247, 23, 255, 65, 212, 90, 221, 194]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'keeperStats'; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: []; + }, + { + name: 'updatePerpFeeStructure'; + discriminator: [23, 178, 111, 203, 73, 22, 140, 75]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'feeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketAmmOracleTwap'; + discriminator: [241, 74, 114, 123, 206, 153, 24, 202]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + ]; + args: []; + }, + { + name: 'updatePerpMarketAmmSpreadAdjustment'; + discriminator: [155, 195, 149, 43, 220, 82, 173, 205]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ammSpreadAdjustment'; + type: 'i8'; + }, + { + name: 'ammInventorySpreadAdjustment'; + type: 'i8'; + }, + { + name: 'referencePriceOffset'; + type: 'i32'; + }, + ]; + }, + { + name: 'updatePerpMarketAmmSummaryStats'; + discriminator: [122, 101, 249, 238, 209, 9, 241, 245]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'spotMarket'; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'account'; + path: 'perpMarket'; + }, + ]; + }; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'updatePerpMarketSummaryStatsParams'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketBaseSpread'; + discriminator: [71, 95, 84, 168, 9, 157, 198, 65]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'baseSpread'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketConcentrationCoef'; + discriminator: [24, 78, 232, 126, 169, 176, 230, 16]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'concentrationScale'; + type: 'u128'; + }, + ]; + }, + { + name: 'updatePerpMarketContractTier'; + discriminator: [236, 128, 15, 95, 203, 214, 68, 117]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'contractTier'; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketCurveUpdateIntensity'; + discriminator: [50, 131, 6, 156, 226, 231, 189, 72]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'curveUpdateIntensity'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketExpiry'; + discriminator: [44, 221, 227, 151, 131, 140, 22, 110]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'expiryTs'; + type: 'i64'; + }, + ]; + }, + { + name: 'updatePerpMarketFeeAdjustment'; + discriminator: [194, 174, 87, 102, 43, 148, 32, 112]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'feeAdjustment'; + type: 'i16'; + }, + ]; + }, + { + name: 'updatePerpMarketFundingPeriod'; + discriminator: [171, 161, 69, 91, 129, 139, 161, 28]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'fundingPeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updatePerpMarketHighLeverageMarginRatio'; + discriminator: [88, 112, 86, 49, 24, 116, 74, 157]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marginRatioInitial'; + type: 'u16'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketImfFactor'; + discriminator: [207, 194, 56, 132, 35, 67, 71, 244]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'imfFactor'; + type: 'u32'; + }, + { + name: 'unrealizedPnlImfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketLiquidationFee'; + discriminator: [90, 137, 9, 145, 41, 8, 148, 117]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolFeeTransferScalar'; + discriminator: [94, 228, 237, 109, 100, 185, 4, 81]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'optionalLpFeeTransferScalar'; + type: { + option: 'u8'; + }; + }, + { + name: 'optionalLpNetPnlTransferScalar'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolId'; + discriminator: [119, 208, 154, 88, 165, 92, 21, 188]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'lpPoolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolPausedOperations'; + discriminator: [181, 94, 93, 146, 51, 89, 32, 135]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'lpPausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketLpPoolStatus'; + discriminator: [67, 6, 252, 61, 54, 88, 89, 233]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'lpStatus'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketMarginRatio'; + discriminator: [130, 173, 107, 45, 119, 105, 26, 113]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'marginRatioInitial'; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxFillReserveFraction'; + discriminator: [19, 172, 114, 154, 42, 135, 161, 133]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxFillReserveFraction'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxImbalances'; + discriminator: [15, 206, 73, 133, 60, 8, 86, 89]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'unrealizedMaxImbalance'; + type: 'u64'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxOpenInterest'; + discriminator: [194, 79, 149, 224, 246, 102, 186, 140]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxOpenInterest'; + type: 'u128'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxSlippageRatio'; + discriminator: [235, 37, 40, 196, 70, 146, 54, 201]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxSlippageRatio'; + type: 'u16'; + }, + ]; + }, + { + name: 'updatePerpMarketMaxSpread'; + discriminator: [80, 252, 122, 62, 40, 218, 91, 100]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxSpread'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePerpMarketMinOrderSize'; + discriminator: [226, 74, 5, 89, 108, 223, 46, 141]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'orderSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketName'; + discriminator: [211, 31, 21, 210, 64, 108, 66, 201]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updatePerpMarketNumberOfUsers'; + discriminator: [35, 62, 144, 177, 180, 62, 215, 196]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'numberOfUsers'; + type: { + option: 'u32'; + }; + }, + { + name: 'numberOfUsersWithBase'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketOracle'; + discriminator: [182, 113, 111, 160, 67, 174, 89, 191]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'oldOracle'; + }, + { + name: 'ammCache'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 97, + 109, + 109, + 95, + 99, + 97, + 99, + 104, + 101, + 95, + 115, + 101, + 101, + 100, + ]; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'skipInvariantCheck'; + type: 'bool'; + }, + ]; + }, + { + name: 'updatePerpMarketOracleLowRiskSlotDelayOverride'; + discriminator: [124, 108, 147, 229, 109, 117, 123, 3]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleLowRiskSlotDelayOverride'; + type: 'i8'; + }, + ]; + }, + { + name: 'updatePerpMarketOracleSlotDelayOverride'; + discriminator: [165, 91, 239, 227, 63, 172, 227, 8]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'oracleSlotDelayOverride'; + type: 'i8'; + }, + ]; + }, + { + name: 'updatePerpMarketPausedOperations'; + discriminator: [53, 16, 136, 132, 30, 220, 121, 85]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketPnlPool'; + discriminator: [50, 202, 249, 224, 166, 184, 13, 143]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketProtectedMakerParams'; + discriminator: [249, 213, 115, 34, 253, 239, 75, 173]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'protectedMakerLimitPriceDivisor'; + type: { + option: 'u8'; + }; + }, + { + name: 'protectedMakerDynamicDivisor'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updatePerpMarketReferencePriceOffsetDeadbandPct'; + discriminator: [214, 73, 166, 11, 218, 76, 110, 163]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'referencePriceOffsetDeadbandPct'; + type: 'u8'; + }, + ]; + }, + { + name: 'updatePerpMarketStatus'; + discriminator: [71, 201, 175, 122, 255, 207, 196, 207]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + ]; + }, + { + name: 'updatePerpMarketStepSizeAndTickSize'; + discriminator: [231, 255, 97, 25, 146, 139, 174, 4]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'stepSize'; + type: 'u64'; + }, + { + name: 'tickSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updatePerpMarketUnrealizedAssetWeight'; + discriminator: [135, 132, 205, 165, 109, 150, 166, 106]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'unrealizedInitialAssetWeight'; + type: 'u32'; + }, + { + name: 'unrealizedMaintenanceAssetWeight'; + type: 'u32'; + }, + ]; + }, + { + name: 'updatePrelaunchOracle'; + discriminator: [220, 132, 27, 27, 233, 220, 61, 219]; + accounts: [ + { + name: 'state'; + }, + { + name: 'perpMarket'; + }, + { + name: 'oracle'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updatePrelaunchOracleParams'; + discriminator: [98, 205, 147, 243, 18, 75, 83, 207]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'prelaunchOracle'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 101, + 108, + 97, + 117, + 110, + 99, + 104, + 95, + 111, + 114, + 97, + 99, + 108, + 101, + ]; + }, + { + kind: 'arg'; + path: 'params.perp_market_index'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + writable: true; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'params'; + type: { + defined: { + name: 'prelaunchOracleParams'; + }; + }; + }, + ]; + }, + { + name: 'updateProtectedMakerModeConfig'; + discriminator: [86, 166, 235, 253, 67, 202, 223, 17]; + accounts: [ + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 112, + 114, + 111, + 116, + 101, + 99, + 116, + 101, + 100, + 95, + 109, + 97, + 107, + 101, + 114, + 95, + 109, + 111, + 100, + 101, + 95, + 99, + 111, + 110, + 102, + 105, + 103, + ]; + }, + ]; + }; + }, + { + name: 'state'; + }, + ]; + args: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'currentUsers'; + type: { + option: 'u32'; + }; + }, + ]; + }, + { + name: 'updatePythPullOracle'; + discriminator: [230, 191, 189, 94, 108, 59, 74, 197]; + accounts: [ + { + name: 'keeper'; + writable: true; + signer: true; + }, + { + name: 'pythSolanaReceiver'; + address: 'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha'; + }, + { + name: 'encodedVaa'; + }, + { + name: 'priceFeed'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [112, 121, 116, 104, 95, 112, 117, 108, 108]; + }, + { + kind: 'arg'; + path: 'feedId'; + }, + ]; + }; + }, + ]; + args: [ + { + name: 'feedId'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'params'; + type: 'bytes'; + }, + ]; + }, + { + name: 'updateSerumFulfillmentConfigStatus'; + discriminator: [171, 109, 240, 251, 95, 1, 149, 89]; + accounts: [ + { + name: 'state'; + }, + { + name: 'serumFulfillmentConfig'; + writable: true; + }, + { + name: 'admin'; + writable: true; + signer: true; + relations: ['state']; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotAuctionDuration'; + discriminator: [182, 178, 203, 72, 187, 143, 157, 107]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'defaultSpotAuctionDuration'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotFeeStructure'; + discriminator: [97, 216, 105, 131, 113, 246, 142, 141]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'feeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketAssetTier'; + discriminator: [253, 209, 231, 14, 242, 208, 243, 130]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'assetTier'; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketBorrowRate'; + discriminator: [71, 239, 236, 153, 210, 62, 254, 76]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'optimalUtilization'; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + type: 'u32'; + }, + { + name: 'minBorrowRate'; + type: { + option: 'u8'; + }; + }, + ]; + }, + { + name: 'updateSpotMarketCumulativeInterest'; + discriminator: [39, 166, 139, 243, 158, 165, 155, 225]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'spotMarketVault'; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'account'; + path: 'spotMarket'; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateSpotMarketExpiry'; + discriminator: [208, 11, 211, 159, 226, 24, 11, 247]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'expiryTs'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateSpotMarketFeeAdjustment'; + discriminator: [148, 182, 3, 126, 157, 114, 220, 99]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'feeAdjustment'; + type: 'i16'; + }, + ]; + }, + { + name: 'updateSpotMarketIfFactor'; + discriminator: [147, 30, 224, 34, 18, 230, 105, 4]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'userIfFactor'; + type: 'u32'; + }, + { + name: 'totalIfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketIfPausedOperations'; + discriminator: [101, 215, 79, 74, 59, 41, 79, 12]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketLiquidationFee'; + discriminator: [11, 13, 255, 53, 56, 136, 104, 177]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'liquidatorFee'; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketMarginWeights'; + discriminator: [109, 33, 87, 195, 255, 36, 6, 81]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'initialAssetWeight'; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + type: 'u32'; + }, + { + name: 'imfFactor'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateSpotMarketMaxTokenBorrows'; + discriminator: [57, 102, 204, 212, 253, 95, 13, 199]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxTokenBorrowsFraction'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateSpotMarketMaxTokenDeposits'; + discriminator: [56, 191, 79, 18, 26, 121, 80, 208]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'maxTokenDeposits'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketMinOrderSize'; + discriminator: [93, 128, 11, 119, 26, 20, 181, 50]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'orderSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketName'; + discriminator: [17, 208, 1, 1, 162, 211, 188, 224]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updateSpotMarketOracle'; + discriminator: [114, 184, 102, 37, 246, 186, 180, 99]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'oracle'; + }, + { + name: 'oldOracle'; + }, + ]; + args: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'skipInvariantCheck'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateSpotMarketOrdersEnabled'; + discriminator: [190, 79, 206, 15, 26, 229, 229, 43]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'ordersEnabled'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateSpotMarketPausedOperations'; + discriminator: [100, 61, 153, 81, 180, 12, 6, 248]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'pausedOperations'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketPoolId'; + discriminator: [22, 213, 197, 160, 139, 193, 81, 149]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'poolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateSpotMarketRevenueSettlePeriod'; + discriminator: [81, 92, 126, 41, 250, 225, 156, 219]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'revenueSettlePeriod'; + type: 'i64'; + }, + ]; + }, + { + name: 'updateSpotMarketScaleInitialAssetWeightStart'; + discriminator: [217, 204, 204, 118, 204, 130, 225, 147]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'scaleInitialAssetWeightStart'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateSpotMarketStatus'; + discriminator: [78, 94, 16, 188, 193, 110, 231, 31]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + ]; + }, + { + name: 'updateSpotMarketStepSizeAndTickSize'; + discriminator: [238, 153, 137, 80, 206, 59, 250, 61]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'stepSize'; + type: 'u64'; + }, + { + name: 'tickSize'; + type: 'u64'; + }, + ]; + }, + { + name: 'updateStateMaxInitializeUserFee'; + discriminator: [237, 225, 25, 237, 193, 45, 77, 97]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'maxInitializeUserFee'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateStateMaxNumberOfSubAccounts'; + discriminator: [155, 123, 214, 2, 221, 166, 204, 85]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'maxNumberOfSubAccounts'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateStateSettlementDuration'; + discriminator: [97, 68, 199, 235, 131, 80, 61, 173]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + writable: true; + }, + ]; + args: [ + { + name: 'settlementDuration'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateUserCustomMarginRatio'; + discriminator: [21, 221, 140, 187, 32, 129, 11, 123]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'marginRatio'; + type: 'u32'; + }, + ]; + }, + { + name: 'updateUserDelegate'; + discriminator: [139, 205, 141, 141, 113, 36, 94, 187]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'delegate'; + type: 'pubkey'; + }, + ]; + }, + { + name: 'updateUserGovTokenInsuranceStake'; + discriminator: [143, 99, 235, 187, 20, 159, 184, 84]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signer'; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [15, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateUserIdle'; + discriminator: [253, 133, 67, 22, 103, 161, 20, 100]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'filler'; + writable: true; + }, + { + name: 'user'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateUserMarginTradingEnabled'; + discriminator: [194, 92, 204, 223, 246, 188, 31, 203]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'marginTradingEnabled'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserName'; + discriminator: [135, 25, 185, 56, 165, 53, 34, 136]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }, + { + name: 'updateUserPerpPositionCustomMarginRatio'; + discriminator: [121, 137, 157, 155, 89, 186, 145, 113]; + accounts: [ + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marginRatio'; + type: 'u16'; + }, + ]; + }, + { + name: 'updateUserPoolId'; + discriminator: [219, 86, 73, 106, 56, 218, 128, 109]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + ]; + }, + { + name: 'updateUserProtectedMakerOrders'; + discriminator: [114, 39, 123, 198, 187, 25, 90, 219]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'protectedMakerModeConfig'; + writable: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'protectedMakerOrders'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserQuoteAssetInsuranceStake'; + discriminator: [251, 101, 156, 7, 2, 63, 30, 23]; + accounts: [ + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [115, 112, 111, 116, 95, 109, 97, 114, 107, 101, 116]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'signer'; + signer: true; + }, + { + name: 'insuranceFundVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 105, + 110, + 115, + 117, + 114, + 97, + 110, + 99, + 101, + 95, + 102, + 117, + 110, + 100, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'const'; + value: [0, 0]; + }, + ]; + }; + }, + ]; + args: []; + }, + { + name: 'updateUserReduceOnly'; + discriminator: [199, 71, 42, 67, 144, 19, 86, 109]; + accounts: [ + { + name: 'user'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [117, 115, 101, 114]; + }, + { + kind: 'account'; + path: 'authority'; + }, + { + kind: 'arg'; + path: 'subAccountId'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + ]; + args: [ + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'updateUserStatsReferrerStatus'; + discriminator: [174, 154, 72, 42, 191, 148, 145, 205]; + accounts: [ + { + name: 'state'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'userStats'; + writable: true; + }, + ]; + args: []; + }, + { + name: 'updateWithdrawGuardThreshold'; + discriminator: [56, 18, 39, 61, 155, 211, 44, 133]; + accounts: [ + { + name: 'admin'; + signer: true; + relations: ['state']; + }, + { + name: 'state'; + }, + { + name: 'spotMarket'; + writable: true; + }, + ]; + args: [ + { + name: 'withdrawGuardThreshold'; + type: 'u64'; + }, + ]; + }, + { + name: 'viewLpPoolAddLiquidityFees'; + discriminator: [80, 66, 226, 161, 70, 142, 119, 84]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'inMarketMint'; + }, + { + name: 'inConstituent'; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + }, + { + name: 'constituentTargetBase'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u128'; + }, + ]; + }, + { + name: 'viewLpPoolRemoveLiquidityFees'; + discriminator: [47, 12, 9, 102, 12, 226, 197, 89]; + accounts: [ + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'outMarketMint'; + }, + { + name: 'outConstituent'; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'lpMint'; + }, + { + name: 'constituentTargetBase'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + ]; + }, + { + name: 'viewLpPoolSwapFees'; + discriminator: [126, 189, 109, 189, 170, 156, 3, 46]; + accounts: [ + { + name: 'driftSigner'; + }, + { + name: 'state'; + }, + { + name: 'lpPool'; + }, + { + name: 'constituentTargetBase'; + }, + { + name: 'constituentCorrelations'; + }, + { + name: 'constituentInTokenAccount'; + writable: true; + }, + { + name: 'constituentOutTokenAccount'; + writable: true; + }, + { + name: 'inConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'inMarketIndex'; + }, + ]; + }; + }, + { + name: 'outConstituent'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [67, 79, 78, 83, 84, 73, 84, 85, 69, 78, 84]; + }, + { + kind: 'account'; + path: 'lpPool'; + }, + { + kind: 'arg'; + path: 'outMarketIndex'; + }, + ]; + }; + }, + { + name: 'authority'; + signer: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'inTargetWeight'; + type: 'i64'; + }, + { + name: 'outTargetWeight'; + type: 'i64'; + }, + ]; + }, + { + name: 'withdraw'; + discriminator: [183, 18, 70, 156, 148, 109, 161, 34]; + accounts: [ + { + name: 'state'; + }, + { + name: 'user'; + writable: true; + }, + { + name: 'userStats'; + writable: true; + }, + { + name: 'authority'; + signer: true; + relations: ['user', 'userStats']; + }, + { + name: 'spotMarketVault'; + writable: true; + pda: { + seeds: [ + { + kind: 'const'; + value: [ + 115, + 112, + 111, + 116, + 95, + 109, + 97, + 114, + 107, + 101, + 116, + 95, + 118, + 97, + 117, + 108, + 116, + ]; + }, + { + kind: 'arg'; + path: 'marketIndex'; + }, + ]; + }; + }, + { + name: 'driftSigner'; + }, + { + name: 'userTokenAccount'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + ]; + args: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + ]; + }, + { + name: 'withdrawFromProgramVault'; + discriminator: [120, 40, 183, 149, 232, 18, 224, 151]; + accounts: [ + { + name: 'state'; + }, + { + name: 'admin'; + writable: true; + signer: true; + }, + { + name: 'driftSigner'; + }, + { + name: 'constituent'; + writable: true; + }, + { + name: 'constituentTokenAccount'; + writable: true; + }, + { + name: 'spotMarket'; + writable: true; + }, + { + name: 'spotMarketVault'; + writable: true; + }, + { + name: 'tokenProgram'; + }, + { + name: 'mint'; + }, + { + name: 'oracle'; + }, + ]; + args: [ + { + name: 'amount'; + type: 'u64'; + }, + ]; + }, + { + name: 'zeroMmOracleFields'; + discriminator: [192, 226, 39, 204, 207, 120, 148, 250]; + accounts: [ + { + name: 'admin'; + signer: true; + }, + { + name: 'state'; + }, + { + name: 'perpMarket'; + writable: true; + }, + ]; + args: []; + }, + ]; + accounts: [ + { + name: 'ammCache'; + discriminator: [213, 114, 161, 56, 20, 22, 2, 59]; + }, + { + name: 'ammConstituentMapping'; + discriminator: [254, 89, 5, 173, 66, 54, 214, 247]; + }, + { + name: 'constituent'; + discriminator: [0, 61, 36, 35, 177, 76, 216, 205]; + }, + { + name: 'constituentCorrelations'; + discriminator: [124, 203, 115, 33, 18, 162, 67, 216]; + }, + { + name: 'constituentTargetBase'; + discriminator: [255, 142, 134, 71, 125, 66, 198, 99]; + }, + { + name: 'fuelOverflow'; + discriminator: [182, 64, 231, 177, 226, 142, 69, 58]; + }, + { + name: 'highLeverageModeConfig'; + discriminator: [3, 196, 90, 189, 193, 64, 228, 234]; + }, + { + name: 'ifRebalanceConfig'; + discriminator: [214, 84, 40, 251, 107, 144, 173, 239]; + }, + { + name: 'insuranceFundStake'; + discriminator: [110, 202, 14, 42, 95, 73, 90, 95]; + }, + { + name: 'lpPool'; + discriminator: [228, 152, 141, 224, 161, 170, 11, 89]; + }, + { + name: 'openbookV2FulfillmentConfig'; + discriminator: [3, 43, 58, 106, 131, 132, 199, 171]; + }, + { + name: 'perpMarket'; + discriminator: [10, 223, 12, 44, 107, 245, 55, 247]; + }, + { + name: 'phoenixV1FulfillmentConfig'; + discriminator: [233, 45, 62, 40, 35, 129, 48, 72]; + }, + { + name: 'prelaunchOracle'; + discriminator: [92, 14, 139, 234, 72, 244, 68, 26]; + }, + { + name: 'protectedMakerModeConfig'; + discriminator: [47, 86, 90, 9, 224, 255, 10, 69]; + }, + { + name: 'pythLazerOracle'; + discriminator: [159, 7, 161, 249, 34, 81, 121, 133]; + }, + { + name: 'referrerName'; + discriminator: [105, 133, 170, 110, 52, 42, 28, 182]; + }, + { + name: 'revenueShare'; + discriminator: [55, 40, 228, 7, 139, 52, 180, 110]; + }, + { + name: 'revenueShareEscrow'; + discriminator: [98, 167, 3, 46, 74, 177, 173, 252]; + }, + { + name: 'serumV3FulfillmentConfig'; + discriminator: [65, 160, 197, 112, 239, 168, 103, 185]; + }, + { + name: 'signedMsgUserOrders'; + discriminator: [70, 6, 50, 248, 222, 1, 143, 49]; + }, + { + name: 'signedMsgWsDelegates'; + discriminator: [190, 115, 111, 44, 216, 252, 108, 85]; + }, + { + name: 'spotMarket'; + discriminator: [100, 177, 8, 107, 168, 65, 65, 39]; + }, + { + name: 'state'; + discriminator: [216, 146, 107, 94, 104, 75, 182, 177]; + }, + { + name: 'user'; + discriminator: [159, 117, 95, 227, 239, 151, 58, 236]; + }, + { + name: 'userStats'; + discriminator: [176, 223, 136, 27, 122, 79, 32, 227]; + }, + ]; + events: [ + { + name: 'curveRecord'; + discriminator: [101, 238, 40, 228, 70, 46, 61, 117]; + }, + { + name: 'deleteUserRecord'; + discriminator: [71, 111, 190, 118, 7, 3, 132, 222]; + }, + { + name: 'depositRecord'; + discriminator: [180, 241, 218, 207, 102, 135, 44, 134]; + }, + { + name: 'fuelSeasonRecord'; + discriminator: [19, 137, 119, 33, 224, 249, 6, 87]; + }, + { + name: 'fuelSweepRecord'; + discriminator: [41, 84, 37, 246, 132, 240, 131, 8]; + }, + { + name: 'fundingPaymentRecord'; + discriminator: [8, 59, 96, 20, 137, 201, 56, 95]; + }, + { + name: 'fundingRateRecord'; + discriminator: [68, 3, 255, 26, 133, 91, 147, 254]; + }, + { + name: 'insuranceFundRecord'; + discriminator: [56, 222, 215, 235, 78, 197, 99, 146]; + }, + { + name: 'insuranceFundStakeRecord'; + discriminator: [68, 66, 156, 7, 216, 148, 250, 114]; + }, + { + name: 'insuranceFundSwapRecord'; + discriminator: [85, 190, 99, 203, 237, 33, 227, 100]; + }, + { + name: 'lpBorrowLendDepositRecord'; + discriminator: [242, 181, 11, 56, 243, 61, 79, 210]; + }, + { + name: 'lpMintRedeemRecord'; + discriminator: [53, 178, 142, 73, 78, 91, 91, 8]; + }, + { + name: 'lpRecord'; + discriminator: [101, 22, 54, 38, 178, 13, 142, 111]; + }, + { + name: 'lpSettleRecord'; + discriminator: [208, 191, 131, 110, 173, 48, 7, 2]; + }, + { + name: 'lpSwapRecord'; + discriminator: [159, 62, 130, 196, 96, 79, 176, 254]; + }, + { + name: 'liquidationRecord'; + discriminator: [127, 17, 0, 108, 182, 13, 231, 53]; + }, + { + name: 'newUserRecord'; + discriminator: [236, 186, 113, 219, 42, 51, 149, 249]; + }, + { + name: 'orderActionRecord'; + discriminator: [224, 52, 67, 71, 194, 237, 109, 1]; + }, + { + name: 'orderRecord'; + discriminator: [104, 19, 64, 56, 89, 21, 2, 90]; + }, + { + name: 'revenueShareSettleRecord'; + discriminator: [61, 162, 89, 10, 24, 20, 59, 45]; + }, + { + name: 'settlePnlRecord'; + discriminator: [57, 68, 105, 26, 119, 198, 213, 89]; + }, + { + name: 'signedMsgOrderRecord'; + discriminator: [211, 197, 25, 18, 142, 86, 113, 27]; + }, + { + name: 'spotInterestRecord'; + discriminator: [183, 186, 203, 186, 225, 187, 95, 130]; + }, + { + name: 'spotMarketVaultDepositRecord'; + discriminator: [178, 217, 23, 188, 127, 190, 32, 73]; + }, + { + name: 'swapRecord'; + discriminator: [162, 187, 123, 194, 138, 56, 250, 241]; + }, + { + name: 'transferProtocolIfSharesToRevenuePoolRecord'; + discriminator: [209, 118, 142, 167, 130, 46, 164, 151]; + }, + ]; + errors: [ + { + code: 6000; + name: 'invalidSpotMarketAuthority'; + msg: 'Invalid Spot Market Authority'; + }, + { + code: 6001; + name: 'invalidInsuranceFundAuthority'; + msg: 'Clearing house not insurance fund authority'; + }, + { + code: 6002; + name: 'insufficientDeposit'; + msg: 'Insufficient deposit'; + }, + { + code: 6003; + name: 'insufficientCollateral'; + msg: 'Insufficient collateral'; + }, + { + code: 6004; + name: 'sufficientCollateral'; + msg: 'Sufficient collateral'; + }, + { + code: 6005; + name: 'maxNumberOfPositions'; + msg: 'Max number of positions taken'; + }, + { + code: 6006; + name: 'adminControlsPricesDisabled'; + msg: 'Admin Controls Prices Disabled'; + }, + { + code: 6007; + name: 'marketDelisted'; + msg: 'Market Delisted'; + }, + { + code: 6008; + name: 'marketIndexAlreadyInitialized'; + msg: 'Market Index Already Initialized'; + }, + { + code: 6009; + name: 'userAccountAndUserPositionsAccountMismatch'; + msg: 'User Account And User Positions Account Mismatch'; + }, + { + code: 6010; + name: 'userHasNoPositionInMarket'; + msg: 'User Has No Position In Market'; + }, + { + code: 6011; + name: 'invalidInitialPeg'; + msg: 'Invalid Initial Peg'; + }, + { + code: 6012; + name: 'invalidRepegRedundant'; + msg: 'AMM repeg already configured with amt given'; + }, + { + code: 6013; + name: 'invalidRepegDirection'; + msg: 'AMM repeg incorrect repeg direction'; + }, + { + code: 6014; + name: 'invalidRepegProfitability'; + msg: 'AMM repeg out of bounds pnl'; + }, + { + code: 6015; + name: 'slippageOutsideLimit'; + msg: 'Slippage Outside Limit Price'; + }, + { + code: 6016; + name: 'orderSizeTooSmall'; + msg: 'Order Size Too Small'; + }, + { + code: 6017; + name: 'invalidUpdateK'; + msg: 'Price change too large when updating K'; + }, + { + code: 6018; + name: 'adminWithdrawTooLarge'; + msg: 'Admin tried to withdraw amount larger than fees collected'; + }, + { + code: 6019; + name: 'mathError'; + msg: 'Math Error'; + }, + { + code: 6020; + name: 'bnConversionError'; + msg: 'Conversion to u128/u64 failed with an overflow or underflow'; + }, + { + code: 6021; + name: 'clockUnavailable'; + msg: 'Clock unavailable'; + }, + { + code: 6022; + name: 'unableToLoadOracle'; + msg: 'Unable To Load Oracles'; + }, + { + code: 6023; + name: 'priceBandsBreached'; + msg: 'Price Bands Breached'; + }, + { + code: 6024; + name: 'exchangePaused'; + msg: 'Exchange is paused'; + }, + { + code: 6025; + name: 'invalidWhitelistToken'; + msg: 'Invalid whitelist token'; + }, + { + code: 6026; + name: 'whitelistTokenNotFound'; + msg: 'Whitelist token not found'; + }, + { + code: 6027; + name: 'invalidDiscountToken'; + msg: 'Invalid discount token'; + }, + { + code: 6028; + name: 'discountTokenNotFound'; + msg: 'Discount token not found'; + }, + { + code: 6029; + name: 'referrerNotFound'; + msg: 'Referrer not found'; + }, + { + code: 6030; + name: 'referrerStatsNotFound'; + msg: 'referrerNotFound'; + }, + { + code: 6031; + name: 'referrerMustBeWritable'; + msg: 'referrerMustBeWritable'; + }, + { + code: 6032; + name: 'referrerStatsMustBeWritable'; + msg: 'referrerMustBeWritable'; + }, + { + code: 6033; + name: 'referrerAndReferrerStatsAuthorityUnequal'; + msg: 'referrerAndReferrerStatsAuthorityUnequal'; + }, + { + code: 6034; + name: 'invalidReferrer'; + msg: 'invalidReferrer'; + }, + { + code: 6035; + name: 'invalidOracle'; + msg: 'invalidOracle'; + }, + { + code: 6036; + name: 'oracleNotFound'; + msg: 'oracleNotFound'; + }, + { + code: 6037; + name: 'liquidationsBlockedByOracle'; + msg: 'Liquidations Blocked By Oracle'; + }, + { + code: 6038; + name: 'maxDeposit'; + msg: 'Can not deposit more than max deposit'; + }, + { + code: 6039; + name: 'cantDeleteUserWithCollateral'; + msg: 'Can not delete user that still has collateral'; + }, + { + code: 6040; + name: 'invalidFundingProfitability'; + msg: 'AMM funding out of bounds pnl'; + }, + { + code: 6041; + name: 'castingFailure'; + msg: 'Casting Failure'; + }, + { + code: 6042; + name: 'invalidOrder'; + msg: 'invalidOrder'; + }, + { + code: 6043; + name: 'invalidOrderMaxTs'; + msg: 'invalidOrderMaxTs'; + }, + { + code: 6044; + name: 'invalidOrderMarketType'; + msg: 'invalidOrderMarketType'; + }, + { + code: 6045; + name: 'invalidOrderForInitialMarginReq'; + msg: 'invalidOrderForInitialMarginReq'; + }, + { + code: 6046; + name: 'invalidOrderNotRiskReducing'; + msg: 'invalidOrderNotRiskReducing'; + }, + { + code: 6047; + name: 'invalidOrderSizeTooSmall'; + msg: 'invalidOrderSizeTooSmall'; + }, + { + code: 6048; + name: 'invalidOrderNotStepSizeMultiple'; + msg: 'invalidOrderNotStepSizeMultiple'; + }, + { + code: 6049; + name: 'invalidOrderBaseQuoteAsset'; + msg: 'invalidOrderBaseQuoteAsset'; + }, + { + code: 6050; + name: 'invalidOrderIoc'; + msg: 'invalidOrderIoc'; + }, + { + code: 6051; + name: 'invalidOrderPostOnly'; + msg: 'invalidOrderPostOnly'; + }, + { + code: 6052; + name: 'invalidOrderIocPostOnly'; + msg: 'invalidOrderIocPostOnly'; + }, + { + code: 6053; + name: 'invalidOrderTrigger'; + msg: 'invalidOrderTrigger'; + }, + { + code: 6054; + name: 'invalidOrderAuction'; + msg: 'invalidOrderAuction'; + }, + { + code: 6055; + name: 'invalidOrderOracleOffset'; + msg: 'invalidOrderOracleOffset'; + }, + { + code: 6056; + name: 'invalidOrderMinOrderSize'; + msg: 'invalidOrderMinOrderSize'; + }, + { + code: 6057; + name: 'placePostOnlyLimitFailure'; + msg: 'Failed to Place Post-Only Limit Order'; + }, + { + code: 6058; + name: 'userHasNoOrder'; + msg: 'User has no order'; + }, + { + code: 6059; + name: 'orderAmountTooSmall'; + msg: 'Order Amount Too Small'; + }, + { + code: 6060; + name: 'maxNumberOfOrders'; + msg: 'Max number of orders taken'; + }, + { + code: 6061; + name: 'orderDoesNotExist'; + msg: 'Order does not exist'; + }, + { + code: 6062; + name: 'orderNotOpen'; + msg: 'Order not open'; + }, + { + code: 6063; + name: 'fillOrderDidNotUpdateState'; + msg: 'fillOrderDidNotUpdateState'; + }, + { + code: 6064; + name: 'reduceOnlyOrderIncreasedRisk'; + msg: 'Reduce only order increased risk'; + }, + { + code: 6065; + name: 'unableToLoadAccountLoader'; + msg: 'Unable to load AccountLoader'; + }, + { + code: 6066; + name: 'tradeSizeTooLarge'; + msg: 'Trade Size Too Large'; + }, + { + code: 6067; + name: 'userCantReferThemselves'; + msg: 'User cant refer themselves'; + }, + { + code: 6068; + name: 'didNotReceiveExpectedReferrer'; + msg: 'Did not receive expected referrer'; + }, + { + code: 6069; + name: 'couldNotDeserializeReferrer'; + msg: 'Could not deserialize referrer'; + }, + { + code: 6070; + name: 'couldNotDeserializeReferrerStats'; + msg: 'Could not deserialize referrer stats'; + }, + { + code: 6071; + name: 'userOrderIdAlreadyInUse'; + msg: 'User Order Id Already In Use'; + }, + { + code: 6072; + name: 'noPositionsLiquidatable'; + msg: 'No positions liquidatable'; + }, + { + code: 6073; + name: 'invalidMarginRatio'; + msg: 'Invalid Margin Ratio'; + }, + { + code: 6074; + name: 'cantCancelPostOnlyOrder'; + msg: 'Cant Cancel Post Only Order'; + }, + { + code: 6075; + name: 'invalidOracleOffset'; + msg: 'invalidOracleOffset'; + }, + { + code: 6076; + name: 'cantExpireOrders'; + msg: 'cantExpireOrders'; + }, + { + code: 6077; + name: 'couldNotLoadMarketData'; + msg: 'couldNotLoadMarketData'; + }, + { + code: 6078; + name: 'perpMarketNotFound'; + msg: 'perpMarketNotFound'; + }, + { + code: 6079; + name: 'invalidMarketAccount'; + msg: 'invalidMarketAccount'; + }, + { + code: 6080; + name: 'unableToLoadPerpMarketAccount'; + msg: 'unableToLoadMarketAccount'; + }, + { + code: 6081; + name: 'marketWrongMutability'; + msg: 'marketWrongMutability'; + }, + { + code: 6082; + name: 'unableToCastUnixTime'; + msg: 'unableToCastUnixTime'; + }, + { + code: 6083; + name: 'couldNotFindSpotPosition'; + msg: 'couldNotFindSpotPosition'; + }, + { + code: 6084; + name: 'noSpotPositionAvailable'; + msg: 'noSpotPositionAvailable'; + }, + { + code: 6085; + name: 'invalidSpotMarketInitialization'; + msg: 'invalidSpotMarketInitialization'; + }, + { + code: 6086; + name: 'couldNotLoadSpotMarketData'; + msg: 'couldNotLoadSpotMarketData'; + }, + { + code: 6087; + name: 'spotMarketNotFound'; + msg: 'spotMarketNotFound'; + }, + { + code: 6088; + name: 'invalidSpotMarketAccount'; + msg: 'invalidSpotMarketAccount'; + }, + { + code: 6089; + name: 'unableToLoadSpotMarketAccount'; + msg: 'unableToLoadSpotMarketAccount'; + }, + { + code: 6090; + name: 'spotMarketWrongMutability'; + msg: 'spotMarketWrongMutability'; + }, + { + code: 6091; + name: 'spotMarketInterestNotUpToDate'; + msg: 'spotInterestNotUpToDate'; + }, + { + code: 6092; + name: 'spotMarketInsufficientDeposits'; + msg: 'spotMarketInsufficientDeposits'; + }, + { + code: 6093; + name: 'userMustSettleTheirOwnPositiveUnsettledPnl'; + msg: 'userMustSettleTheirOwnPositiveUnsettledPnl'; + }, + { + code: 6094; + name: 'cantUpdatePoolBalanceType'; + msg: 'cantUpdatePoolBalanceType'; + }, + { + code: 6095; + name: 'insufficientCollateralForSettlingPnl'; + msg: 'insufficientCollateralForSettlingPnl'; + }, + { + code: 6096; + name: 'ammNotUpdatedInSameSlot'; + msg: 'ammNotUpdatedInSameSlot'; + }, + { + code: 6097; + name: 'auctionNotComplete'; + msg: 'auctionNotComplete'; + }, + { + code: 6098; + name: 'makerNotFound'; + msg: 'makerNotFound'; + }, + { + code: 6099; + name: 'makerStatsNotFound'; + msg: 'makerNotFound'; + }, + { + code: 6100; + name: 'makerMustBeWritable'; + msg: 'makerMustBeWritable'; + }, + { + code: 6101; + name: 'makerStatsMustBeWritable'; + msg: 'makerMustBeWritable'; + }, + { + code: 6102; + name: 'makerOrderNotFound'; + msg: 'makerOrderNotFound'; + }, + { + code: 6103; + name: 'couldNotDeserializeMaker'; + msg: 'couldNotDeserializeMaker'; + }, + { + code: 6104; + name: 'couldNotDeserializeMakerStats'; + msg: 'couldNotDeserializeMaker'; + }, + { + code: 6105; + name: 'auctionPriceDoesNotSatisfyMaker'; + msg: 'auctionPriceDoesNotSatisfyMaker'; + }, + { + code: 6106; + name: 'makerCantFulfillOwnOrder'; + msg: 'makerCantFulfillOwnOrder'; + }, + { + code: 6107; + name: 'makerOrderMustBePostOnly'; + msg: 'makerOrderMustBePostOnly'; + }, + { + code: 6108; + name: 'cantMatchTwoPostOnlys'; + msg: 'cantMatchTwoPostOnlys'; + }, + { + code: 6109; + name: 'orderBreachesOraclePriceLimits'; + msg: 'orderBreachesOraclePriceLimits'; + }, + { + code: 6110; + name: 'orderMustBeTriggeredFirst'; + msg: 'orderMustBeTriggeredFirst'; + }, + { + code: 6111; + name: 'orderNotTriggerable'; + msg: 'orderNotTriggerable'; + }, + { + code: 6112; + name: 'orderDidNotSatisfyTriggerCondition'; + msg: 'orderDidNotSatisfyTriggerCondition'; + }, + { + code: 6113; + name: 'positionAlreadyBeingLiquidated'; + msg: 'positionAlreadyBeingLiquidated'; + }, + { + code: 6114; + name: 'positionDoesntHaveOpenPositionOrOrders'; + msg: 'positionDoesntHaveOpenPositionOrOrders'; + }, + { + code: 6115; + name: 'allOrdersAreAlreadyLiquidations'; + msg: 'allOrdersAreAlreadyLiquidations'; + }, + { + code: 6116; + name: 'cantCancelLiquidationOrder'; + msg: 'cantCancelLiquidationOrder'; + }, + { + code: 6117; + name: 'userIsBeingLiquidated'; + msg: 'userIsBeingLiquidated'; + }, + { + code: 6118; + name: 'liquidationsOngoing'; + msg: 'liquidationsOngoing'; + }, + { + code: 6119; + name: 'wrongSpotBalanceType'; + msg: 'wrongSpotBalanceType'; + }, + { + code: 6120; + name: 'userCantLiquidateThemself'; + msg: 'userCantLiquidateThemself'; + }, + { + code: 6121; + name: 'invalidPerpPositionToLiquidate'; + msg: 'invalidPerpPositionToLiquidate'; + }, + { + code: 6122; + name: 'invalidBaseAssetAmountForLiquidatePerp'; + msg: 'invalidBaseAssetAmountForLiquidatePerp'; + }, + { + code: 6123; + name: 'invalidPositionLastFundingRate'; + msg: 'invalidPositionLastFundingRate'; + }, + { + code: 6124; + name: 'invalidPositionDelta'; + msg: 'invalidPositionDelta'; + }, + { + code: 6125; + name: 'userBankrupt'; + msg: 'userBankrupt'; + }, + { + code: 6126; + name: 'userNotBankrupt'; + msg: 'userNotBankrupt'; + }, + { + code: 6127; + name: 'userHasInvalidBorrow'; + msg: 'userHasInvalidBorrow'; + }, + { + code: 6128; + name: 'dailyWithdrawLimit'; + msg: 'dailyWithdrawLimit'; + }, + { + code: 6129; + name: 'defaultError'; + msg: 'defaultError'; + }, + { + code: 6130; + name: 'insufficientLpTokens'; + msg: 'Insufficient LP tokens'; + }, + { + code: 6131; + name: 'cantLpWithPerpPosition'; + msg: 'Cant LP with a market position'; + }, + { + code: 6132; + name: 'unableToBurnLpTokens'; + msg: 'Unable to burn LP tokens'; + }, + { + code: 6133; + name: 'tryingToRemoveLiquidityTooFast'; + msg: 'Trying to remove liqudity too fast after adding it'; + }, + { + code: 6134; + name: 'invalidSpotMarketVault'; + msg: 'Invalid Spot Market Vault'; + }, + { + code: 6135; + name: 'invalidSpotMarketState'; + msg: 'Invalid Spot Market State'; + }, + { + code: 6136; + name: 'invalidSerumProgram'; + msg: 'invalidSerumProgram'; + }, + { + code: 6137; + name: 'invalidSerumMarket'; + msg: 'invalidSerumMarket'; + }, + { + code: 6138; + name: 'invalidSerumBids'; + msg: 'invalidSerumBids'; + }, + { + code: 6139; + name: 'invalidSerumAsks'; + msg: 'invalidSerumAsks'; + }, + { + code: 6140; + name: 'invalidSerumOpenOrders'; + msg: 'invalidSerumOpenOrders'; + }, + { + code: 6141; + name: 'failedSerumCpi'; + msg: 'failedSerumCpi'; + }, + { + code: 6142; + name: 'failedToFillOnExternalMarket'; + msg: 'failedToFillOnExternalMarket'; + }, + { + code: 6143; + name: 'invalidFulfillmentConfig'; + msg: 'invalidFulfillmentConfig'; + }, + { + code: 6144; + name: 'invalidFeeStructure'; + msg: 'invalidFeeStructure'; + }, + { + code: 6145; + name: 'insufficientIfShares'; + msg: 'Insufficient IF shares'; + }, + { + code: 6146; + name: 'marketActionPaused'; + msg: 'the Market has paused this action'; + }, + { + code: 6147; + name: 'marketPlaceOrderPaused'; + msg: 'the Market status doesnt allow placing orders'; + }, + { + code: 6148; + name: 'marketFillOrderPaused'; + msg: 'the Market status doesnt allow filling orders'; + }, + { + code: 6149; + name: 'marketWithdrawPaused'; + msg: 'the Market status doesnt allow withdraws'; + }, + { + code: 6150; + name: 'protectedAssetTierViolation'; + msg: 'Action violates the Protected Asset Tier rules'; + }, + { + code: 6151; + name: 'isolatedAssetTierViolation'; + msg: 'Action violates the Isolated Asset Tier rules'; + }, + { + code: 6152; + name: 'userCantBeDeleted'; + msg: 'User Cant Be Deleted'; + }, + { + code: 6153; + name: 'reduceOnlyWithdrawIncreasedRisk'; + msg: 'Reduce Only Withdraw Increased Risk'; + }, + { + code: 6154; + name: 'maxOpenInterest'; + msg: 'Max Open Interest'; + }, + { + code: 6155; + name: 'cantResolvePerpBankruptcy'; + msg: 'Cant Resolve Perp Bankruptcy'; + }, + { + code: 6156; + name: 'liquidationDoesntSatisfyLimitPrice'; + msg: 'Liquidation Doesnt Satisfy Limit Price'; + }, + { + code: 6157; + name: 'marginTradingDisabled'; + msg: 'Margin Trading Disabled'; + }, + { + code: 6158; + name: 'invalidMarketStatusToSettlePnl'; + msg: 'Invalid Market Status to Settle Perp Pnl'; + }, + { + code: 6159; + name: 'perpMarketNotInSettlement'; + msg: 'perpMarketNotInSettlement'; + }, + { + code: 6160; + name: 'perpMarketNotInReduceOnly'; + msg: 'perpMarketNotInReduceOnly'; + }, + { + code: 6161; + name: 'perpMarketSettlementBufferNotReached'; + msg: 'perpMarketSettlementBufferNotReached'; + }, + { + code: 6162; + name: 'perpMarketSettlementUserHasOpenOrders'; + msg: 'perpMarketSettlementUserHasOpenOrders'; + }, + { + code: 6163; + name: 'perpMarketSettlementUserHasActiveLp'; + msg: 'perpMarketSettlementUserHasActiveLp'; + }, + { + code: 6164; + name: 'unableToSettleExpiredUserPosition'; + msg: 'unableToSettleExpiredUserPosition'; + }, + { + code: 6165; + name: 'unequalMarketIndexForSpotTransfer'; + msg: 'unequalMarketIndexForSpotTransfer'; + }, + { + code: 6166; + name: 'invalidPerpPositionDetected'; + msg: 'invalidPerpPositionDetected'; + }, + { + code: 6167; + name: 'invalidSpotPositionDetected'; + msg: 'invalidSpotPositionDetected'; + }, + { + code: 6168; + name: 'invalidAmmDetected'; + msg: 'invalidAmmDetected'; + }, + { + code: 6169; + name: 'invalidAmmForFillDetected'; + msg: 'invalidAmmForFillDetected'; + }, + { + code: 6170; + name: 'invalidAmmLimitPriceOverride'; + msg: 'invalidAmmLimitPriceOverride'; + }, + { + code: 6171; + name: 'invalidOrderFillPrice'; + msg: 'invalidOrderFillPrice'; + }, + { + code: 6172; + name: 'spotMarketBalanceInvariantViolated'; + msg: 'spotMarketBalanceInvariantViolated'; + }, + { + code: 6173; + name: 'spotMarketVaultInvariantViolated'; + msg: 'spotMarketVaultInvariantViolated'; + }, + { + code: 6174; + name: 'invalidPda'; + msg: 'invalidPda'; + }, + { + code: 6175; + name: 'invalidPdaSigner'; + msg: 'invalidPdaSigner'; + }, + { + code: 6176; + name: 'revenueSettingsCannotSettleToIf'; + msg: 'revenueSettingsCannotSettleToIf'; + }, + { + code: 6177; + name: 'noRevenueToSettleToIf'; + msg: 'noRevenueToSettleToIf'; + }, + { + code: 6178; + name: 'noAmmPerpPnlDeficit'; + msg: 'noAmmPerpPnlDeficit'; + }, + { + code: 6179; + name: 'sufficientPerpPnlPool'; + msg: 'sufficientPerpPnlPool'; + }, + { + code: 6180; + name: 'insufficientPerpPnlPool'; + msg: 'insufficientPerpPnlPool'; + }, + { + code: 6181; + name: 'perpPnlDeficitBelowThreshold'; + msg: 'perpPnlDeficitBelowThreshold'; + }, + { + code: 6182; + name: 'maxRevenueWithdrawPerPeriodReached'; + msg: 'maxRevenueWithdrawPerPeriodReached'; + }, + { + code: 6183; + name: 'maxIfWithdrawReached'; + msg: 'invalidSpotPositionDetected'; + }, + { + code: 6184; + name: 'noIfWithdrawAvailable'; + msg: 'noIfWithdrawAvailable'; + }, + { + code: 6185; + name: 'invalidIfUnstake'; + msg: 'invalidIfUnstake'; + }, + { + code: 6186; + name: 'invalidIfUnstakeSize'; + msg: 'invalidIfUnstakeSize'; + }, + { + code: 6187; + name: 'invalidIfUnstakeCancel'; + msg: 'invalidIfUnstakeCancel'; + }, + { + code: 6188; + name: 'invalidIfForNewStakes'; + msg: 'invalidIfForNewStakes'; + }, + { + code: 6189; + name: 'invalidIfRebase'; + msg: 'invalidIfRebase'; + }, + { + code: 6190; + name: 'invalidInsuranceUnstakeSize'; + msg: 'invalidInsuranceUnstakeSize'; + }, + { + code: 6191; + name: 'invalidOrderLimitPrice'; + msg: 'invalidOrderLimitPrice'; + }, + { + code: 6192; + name: 'invalidIfDetected'; + msg: 'invalidIfDetected'; + }, + { + code: 6193; + name: 'invalidAmmMaxSpreadDetected'; + msg: 'invalidAmmMaxSpreadDetected'; + }, + { + code: 6194; + name: 'invalidConcentrationCoef'; + msg: 'invalidConcentrationCoef'; + }, + { + code: 6195; + name: 'invalidSrmVault'; + msg: 'invalidSrmVault'; + }, + { + code: 6196; + name: 'invalidVaultOwner'; + msg: 'invalidVaultOwner'; + }, + { + code: 6197; + name: 'invalidMarketStatusForFills'; + msg: 'invalidMarketStatusForFills'; + }, + { + code: 6198; + name: 'ifWithdrawRequestInProgress'; + msg: 'ifWithdrawRequestInProgress'; + }, + { + code: 6199; + name: 'noIfWithdrawRequestInProgress'; + msg: 'noIfWithdrawRequestInProgress'; + }, + { + code: 6200; + name: 'ifWithdrawRequestTooSmall'; + msg: 'ifWithdrawRequestTooSmall'; + }, + { + code: 6201; + name: 'incorrectSpotMarketAccountPassed'; + msg: 'incorrectSpotMarketAccountPassed'; + }, + { + code: 6202; + name: 'blockchainClockInconsistency'; + msg: 'blockchainClockInconsistency'; + }, + { + code: 6203; + name: 'invalidIfSharesDetected'; + msg: 'invalidIfSharesDetected'; + }, + { + code: 6204; + name: 'newLpSizeTooSmall'; + msg: 'newLpSizeTooSmall'; + }, + { + code: 6205; + name: 'marketStatusInvalidForNewLp'; + msg: 'marketStatusInvalidForNewLp'; + }, + { + code: 6206; + name: 'invalidMarkTwapUpdateDetected'; + msg: 'invalidMarkTwapUpdateDetected'; + }, + { + code: 6207; + name: 'marketSettlementAttemptOnActiveMarket'; + msg: 'marketSettlementAttemptOnActiveMarket'; + }, + { + code: 6208; + name: 'marketSettlementRequiresSettledLp'; + msg: 'marketSettlementRequiresSettledLp'; + }, + { + code: 6209; + name: 'marketSettlementAttemptTooEarly'; + msg: 'marketSettlementAttemptTooEarly'; + }, + { + code: 6210; + name: 'marketSettlementTargetPriceInvalid'; + msg: 'marketSettlementTargetPriceInvalid'; + }, + { + code: 6211; + name: 'unsupportedSpotMarket'; + msg: 'unsupportedSpotMarket'; + }, + { + code: 6212; + name: 'spotOrdersDisabled'; + msg: 'spotOrdersDisabled'; + }, + { + code: 6213; + name: 'marketBeingInitialized'; + msg: 'Market Being Initialized'; + }, + { + code: 6214; + name: 'invalidUserSubAccountId'; + msg: 'Invalid Sub Account Id'; + }, + { + code: 6215; + name: 'invalidTriggerOrderCondition'; + msg: 'Invalid Trigger Order Condition'; + }, + { + code: 6216; + name: 'invalidSpotPosition'; + msg: 'Invalid Spot Position'; + }, + { + code: 6217; + name: 'cantTransferBetweenSameUserAccount'; + msg: 'Cant transfer between same user account'; + }, + { + code: 6218; + name: 'invalidPerpPosition'; + msg: 'Invalid Perp Position'; + }, + { + code: 6219; + name: 'unableToGetLimitPrice'; + msg: 'Unable To Get Limit Price'; + }, + { + code: 6220; + name: 'invalidLiquidation'; + msg: 'Invalid Liquidation'; + }, + { + code: 6221; + name: 'spotFulfillmentConfigDisabled'; + msg: 'Spot Fulfillment Config Disabled'; + }, + { + code: 6222; + name: 'invalidMaker'; + msg: 'Invalid Maker'; + }, + { + code: 6223; + name: 'failedUnwrap'; + msg: 'Failed Unwrap'; + }, + { + code: 6224; + name: 'maxNumberOfUsers'; + msg: 'Max Number Of Users'; + }, + { + code: 6225; + name: 'invalidOracleForSettlePnl'; + msg: 'invalidOracleForSettlePnl'; + }, + { + code: 6226; + name: 'marginOrdersOpen'; + msg: 'marginOrdersOpen'; + }, + { + code: 6227; + name: 'tierViolationLiquidatingPerpPnl'; + msg: 'tierViolationLiquidatingPerpPnl'; + }, + { + code: 6228; + name: 'couldNotLoadUserData'; + msg: 'couldNotLoadUserData'; + }, + { + code: 6229; + name: 'userWrongMutability'; + msg: 'userWrongMutability'; + }, + { + code: 6230; + name: 'invalidUserAccount'; + msg: 'invalidUserAccount'; + }, + { + code: 6231; + name: 'couldNotLoadUserStatsData'; + msg: 'couldNotLoadUserData'; + }, + { + code: 6232; + name: 'userStatsWrongMutability'; + msg: 'userWrongMutability'; + }, + { + code: 6233; + name: 'invalidUserStatsAccount'; + msg: 'invalidUserAccount'; + }, + { + code: 6234; + name: 'userNotFound'; + msg: 'userNotFound'; + }, + { + code: 6235; + name: 'unableToLoadUserAccount'; + msg: 'unableToLoadUserAccount'; + }, + { + code: 6236; + name: 'userStatsNotFound'; + msg: 'userStatsNotFound'; + }, + { + code: 6237; + name: 'unableToLoadUserStatsAccount'; + msg: 'unableToLoadUserStatsAccount'; + }, + { + code: 6238; + name: 'userNotInactive'; + msg: 'User Not Inactive'; + }, + { + code: 6239; + name: 'revertFill'; + msg: 'revertFill'; + }, + { + code: 6240; + name: 'invalidMarketAccountforDeletion'; + msg: 'Invalid MarketAccount for Deletion'; + }, + { + code: 6241; + name: 'invalidSpotFulfillmentParams'; + msg: 'Invalid Spot Fulfillment Params'; + }, + { + code: 6242; + name: 'failedToGetMint'; + msg: 'Failed to Get Mint'; + }, + { + code: 6243; + name: 'failedPhoenixCpi'; + msg: 'failedPhoenixCpi'; + }, + { + code: 6244; + name: 'failedToDeserializePhoenixMarket'; + msg: 'failedToDeserializePhoenixMarket'; + }, + { + code: 6245; + name: 'invalidPricePrecision'; + msg: 'invalidPricePrecision'; + }, + { + code: 6246; + name: 'invalidPhoenixProgram'; + msg: 'invalidPhoenixProgram'; + }, + { + code: 6247; + name: 'invalidPhoenixMarket'; + msg: 'invalidPhoenixMarket'; + }, + { + code: 6248; + name: 'invalidSwap'; + msg: 'invalidSwap'; + }, + { + code: 6249; + name: 'swapLimitPriceBreached'; + msg: 'swapLimitPriceBreached'; + }, + { + code: 6250; + name: 'spotMarketReduceOnly'; + msg: 'spotMarketReduceOnly'; + }, + { + code: 6251; + name: 'fundingWasNotUpdated'; + msg: 'fundingWasNotUpdated'; + }, + { + code: 6252; + name: 'impossibleFill'; + msg: 'impossibleFill'; + }, + { + code: 6253; + name: 'cantUpdatePerpBidAskTwap'; + msg: 'cantUpdatePerpBidAskTwap'; + }, + { + code: 6254; + name: 'userReduceOnly'; + msg: 'userReduceOnly'; + }, + { + code: 6255; + name: 'invalidMarginCalculation'; + msg: 'invalidMarginCalculation'; + }, + { + code: 6256; + name: 'cantPayUserInitFee'; + msg: 'cantPayUserInitFee'; + }, + { + code: 6257; + name: 'cantReclaimRent'; + msg: 'cantReclaimRent'; + }, + { + code: 6258; + name: 'insuranceFundOperationPaused'; + msg: 'insuranceFundOperationPaused'; + }, + { + code: 6259; + name: 'noUnsettledPnl'; + msg: 'noUnsettledPnl'; + }, + { + code: 6260; + name: 'pnlPoolCantSettleUser'; + msg: 'pnlPoolCantSettleUser'; + }, + { + code: 6261; + name: 'oracleNonPositive'; + msg: 'oracleInvalid'; + }, + { + code: 6262; + name: 'oracleTooVolatile'; + msg: 'oracleTooVolatile'; + }, + { + code: 6263; + name: 'oracleTooUncertain'; + msg: 'oracleTooUncertain'; + }, + { + code: 6264; + name: 'oracleStaleForMargin'; + msg: 'oracleStaleForMargin'; + }, + { + code: 6265; + name: 'oracleInsufficientDataPoints'; + msg: 'oracleInsufficientDataPoints'; + }, + { + code: 6266; + name: 'oracleStaleForAmm'; + msg: 'oracleStaleForAmm'; + }, + { + code: 6267; + name: 'unableToParsePullOracleMessage'; + msg: 'Unable to parse pull oracle message'; + }, + { + code: 6268; + name: 'maxBorrows'; + msg: 'Can not borow more than max borrows'; + }, + { + code: 6269; + name: 'oracleUpdatesNotMonotonic'; + msg: 'Updates must be monotonically increasing'; + }, + { + code: 6270; + name: 'oraclePriceFeedMessageMismatch'; + msg: 'Trying to update price feed with the wrong feed id'; + }, + { + code: 6271; + name: 'oracleUnsupportedMessageType'; + msg: 'The message in the update must be a PriceFeedMessage'; + }, + { + code: 6272; + name: 'oracleDeserializeMessageFailed'; + msg: 'Could not deserialize the message in the update'; + }, + { + code: 6273; + name: 'oracleWrongGuardianSetOwner'; + msg: 'Wrong guardian set owner in update price atomic'; + }, + { + code: 6274; + name: 'oracleWrongWriteAuthority'; + msg: 'Oracle post update atomic price feed account must be drift program'; + }, + { + code: 6275; + name: 'oracleWrongVaaOwner'; + msg: 'Oracle vaa owner must be wormhole program'; + }, + { + code: 6276; + name: 'oracleTooManyPriceAccountUpdates'; + msg: 'Multi updates must have 2 or fewer accounts passed in remaining accounts'; + }, + { + code: 6277; + name: 'oracleMismatchedVaaAndPriceUpdates'; + msg: "Don't have the same remaining accounts number and pyth updates left"; + }, + { + code: 6278; + name: 'oracleBadRemainingAccountPublicKey'; + msg: 'Remaining account passed does not match oracle update derived pda'; + }, + { + code: 6279; + name: 'failedOpenbookV2cpi'; + msg: 'failedOpenbookV2cpi'; + }, + { + code: 6280; + name: 'invalidOpenbookV2Program'; + msg: 'invalidOpenbookV2Program'; + }, + { + code: 6281; + name: 'invalidOpenbookV2Market'; + msg: 'invalidOpenbookV2Market'; + }, + { + code: 6282; + name: 'nonZeroTransferFee'; + msg: 'Non zero transfer fee'; + }, + { + code: 6283; + name: 'liquidationOrderFailedToFill'; + msg: 'Liquidation order failed to fill'; + }, + { + code: 6284; + name: 'invalidPredictionMarketOrder'; + msg: 'Invalid prediction market order'; + }, + { + code: 6285; + name: 'invalidVerificationIxIndex'; + msg: 'Ed25519 Ix must be before place and make SignedMsg order ix'; + }, + { + code: 6286; + name: 'sigVerificationFailed'; + msg: 'SignedMsg message verificaiton failed'; + }, + { + code: 6287; + name: 'mismatchedSignedMsgOrderParamsMarketIndex'; + msg: 'Market index mismatched b/w taker and maker SignedMsg order params'; + }, + { + code: 6288; + name: 'invalidSignedMsgOrderParam'; + msg: 'Invalid SignedMsg order param'; + }, + { + code: 6289; + name: 'placeAndTakeOrderSuccessConditionFailed'; + msg: 'Place and take order success condition failed'; + }, + { + code: 6290; + name: 'invalidHighLeverageModeConfig'; + msg: 'Invalid High Leverage Mode Config'; + }, + { + code: 6291; + name: 'invalidRfqUserAccount'; + msg: 'Invalid RFQ User Account'; + }, + { + code: 6292; + name: 'rfqUserAccountWrongMutability'; + msg: 'RFQUserAccount should be mutable'; + }, + { + code: 6293; + name: 'rfqUserAccountFull'; + msg: 'RFQUserAccount has too many active RFQs'; + }, + { + code: 6294; + name: 'rfqOrderNotFilled'; + msg: 'RFQ order not filled as expected'; + }, + { + code: 6295; + name: 'invalidRfqOrder'; + msg: 'RFQ orders must be jit makers'; + }, + { + code: 6296; + name: 'invalidRfqMatch'; + msg: 'RFQ matches must be valid'; + }, + { + code: 6297; + name: 'invalidSignedMsgUserAccount'; + msg: 'Invalid SignedMsg user account'; + }, + { + code: 6298; + name: 'signedMsgUserAccountWrongMutability'; + msg: 'SignedMsg account wrong mutability'; + }, + { + code: 6299; + name: 'signedMsgUserOrdersAccountFull'; + msg: 'SignedMsgUserAccount has too many active orders'; + }, + { + code: 6300; + name: 'signedMsgOrderDoesNotExist'; + msg: 'Order with SignedMsg uuid does not exist'; + }, + { + code: 6301; + name: 'invalidSignedMsgOrderId'; + msg: 'SignedMsg order id cannot be 0s'; + }, + { + code: 6302; + name: 'invalidPoolId'; + msg: 'Invalid pool id'; + }, + { + code: 6303; + name: 'invalidProtectedMakerModeConfig'; + msg: 'Invalid Protected Maker Mode Config'; + }, + { + code: 6304; + name: 'invalidPythLazerStorageOwner'; + msg: 'Invalid pyth lazer storage owner'; + }, + { + code: 6305; + name: 'unverifiedPythLazerMessage'; + msg: 'Verification of pyth lazer message failed'; + }, + { + code: 6306; + name: 'invalidPythLazerMessage'; + msg: 'Invalid pyth lazer message'; + }, + { + code: 6307; + name: 'pythLazerMessagePriceFeedMismatch'; + msg: 'Pyth lazer message does not correspond to correct fed id'; + }, + { + code: 6308; + name: 'invalidLiquidateSpotWithSwap'; + msg: 'invalidLiquidateSpotWithSwap'; + }, + { + code: 6309; + name: 'signedMsgUserContextUserMismatch'; + msg: 'User in SignedMsg message does not match user in ix context'; + }, + { + code: 6310; + name: 'userFuelOverflowThresholdNotMet'; + msg: 'User fuel overflow threshold not met'; + }, + { + code: 6311; + name: 'fuelOverflowAccountNotFound'; + msg: 'FuelOverflow account not found'; + }, + { + code: 6312; + name: 'invalidTransferPerpPosition'; + msg: 'Invalid Transfer Perp Position'; + }, + { + code: 6313; + name: 'invalidSignedMsgUserOrdersResize'; + msg: 'Invalid SignedMsgUserOrders resize'; + }, + { + code: 6314; + name: 'couldNotDeserializeHighLeverageModeConfig'; + msg: 'Could not deserialize high leverage mode config'; + }, + { + code: 6315; + name: 'invalidIfRebalanceConfig'; + msg: 'Invalid If Rebalance Config'; + }, + { + code: 6316; + name: 'invalidIfRebalanceSwap'; + msg: 'Invalid If Rebalance Swap'; + }, + { + code: 6317; + name: 'invalidRevenueShareResize'; + msg: 'Invalid RevenueShare resize'; + }, + { + code: 6318; + name: 'builderRevoked'; + msg: 'Builder has been revoked'; + }, + { + code: 6319; + name: 'invalidBuilderFee'; + msg: 'Builder fee is greater than max fee bps'; + }, + { + code: 6320; + name: 'revenueShareEscrowAuthorityMismatch'; + msg: 'RevenueShareEscrow authority mismatch'; + }, + { + code: 6321; + name: 'revenueShareEscrowOrdersAccountFull'; + msg: 'RevenueShareEscrow has too many active orders'; + }, + { + code: 6322; + name: 'invalidRevenueShareAccount'; + msg: 'Invalid RevenueShareAccount'; + }, + { + code: 6323; + name: 'cannotRevokeBuilderWithOpenOrders'; + msg: 'Cannot revoke builder with open orders'; + }, + { + code: 6324; + name: 'unableToLoadRevenueShareAccount'; + msg: 'Unable to load builder account'; + }, + { + code: 6325; + name: 'invalidConstituent'; + msg: 'Invalid Constituent'; + }, + { + code: 6326; + name: 'invalidAmmConstituentMappingArgument'; + msg: 'Invalid Amm Constituent Mapping argument'; + }, + { + code: 6327; + name: 'constituentNotFound'; + msg: 'Constituent not found'; + }, + { + code: 6328; + name: 'constituentCouldNotLoad'; + msg: 'Constituent could not load'; + }, + { + code: 6329; + name: 'constituentWrongMutability'; + msg: 'Constituent wrong mutability'; + }, + { + code: 6330; + name: 'wrongNumberOfConstituents'; + msg: 'Wrong number of constituents passed to instruction'; + }, + { + code: 6331; + name: 'insufficientConstituentTokenBalance'; + msg: 'Insufficient constituent token balance'; + }, + { + code: 6332; + name: 'ammCacheStale'; + msg: 'Amm Cache data too stale'; + }, + { + code: 6333; + name: 'lpPoolAumDelayed'; + msg: 'LP Pool AUM not updated recently'; + }, + { + code: 6334; + name: 'constituentOracleStale'; + msg: 'Constituent oracle is stale'; + }, + { + code: 6335; + name: 'lpInvariantFailed'; + msg: 'LP Invariant failed'; + }, + { + code: 6336; + name: 'invalidConstituentDerivativeWeights'; + msg: 'Invalid constituent derivative weights'; + }, + { + code: 6337; + name: 'maxDlpAumBreached'; + msg: 'Max DLP AUM Breached'; + }, + { + code: 6338; + name: 'settleLpPoolDisabled'; + msg: 'Settle Lp Pool Disabled'; + }, + { + code: 6339; + name: 'mintRedeemLpPoolDisabled'; + msg: 'Mint/Redeem Lp Pool Disabled'; + }, + { + code: 6340; + name: 'lpPoolSettleInvariantBreached'; + msg: 'Settlement amount exceeded'; + }, + { + code: 6341; + name: 'invalidConstituentOperation'; + msg: 'Invalid constituent operation'; + }, + { + code: 6342; + name: 'unauthorized'; + msg: 'Unauthorized for operation'; + }, + { + code: 6343; + name: 'invalidLpPoolId'; + msg: 'Invalid Lp Pool Id for Operation'; + }, + { + code: 6344; + name: 'marketIndexNotFoundAmmCache'; + msg: 'marketIndexNotFoundAmmCache'; + }, + ]; + types: [ + { + name: 'amm'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'oracle'; + docs: ['oracle price data public key']; + type: 'pubkey'; + }, + { + name: 'historicalOracleData'; + docs: ['stores historically witnessed oracle data']; + type: { + defined: { + name: 'historicalOracleData'; + }; + }; + }, + { + name: 'baseAssetAmountPerLp'; + docs: [ + 'accumulated base asset amount since inception per lp share', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteAssetAmountPerLp'; + docs: [ + 'accumulated quote asset amount since inception per lp share', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'feePool'; + docs: [ + 'partition of fees from perp market trading moved from pnl settlements', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'baseAssetReserve'; + docs: [ + '`x` reserves for constant product mm formula (x * y = k)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'quoteAssetReserve'; + docs: [ + '`y` reserves for constant product mm formula (x * y = k)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'concentrationCoef'; + docs: [ + 'determines how close the min/max base asset reserve sit vs base reserves', + 'allow for decreasing slippage without increasing liquidity and v.v.', + 'precision: PERCENTAGE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'minBaseAssetReserve'; + docs: [ + 'minimum base_asset_reserve allowed before AMM is unavailable', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'maxBaseAssetReserve'; + docs: [ + 'maximum base_asset_reserve allowed before AMM is unavailable', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'sqrtK'; + docs: [ + '`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'pegMultiplier'; + docs: [ + 'normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced', + 'precision: PEG_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'terminalQuoteAssetReserve'; + docs: [ + 'y when market is balanced. stored to save computation', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'baseAssetAmountLong'; + docs: [ + 'always non-negative. tracks number of total longs in market (regardless of counterparty)', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountShort'; + docs: [ + 'always non-positive. tracks number of total shorts in market (regardless of counterparty)', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: [ + 'tracks net position (longs-shorts) in market with AMM as counterparty', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'baseAssetAmountWithUnsettledLp'; + docs: [ + 'tracks net position (longs-shorts) in market with LPs as counterparty', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'maxOpenInterest'; + docs: [ + 'max allowed open interest, blocks trades that breach this value', + 'precision: BASE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'quoteAssetAmount'; + docs: [ + "sum of all user's perp quote_asset_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteEntryAmountLong'; + docs: [ + "sum of all long user's quote_entry_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteEntryAmountShort'; + docs: [ + "sum of all short user's quote_entry_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteBreakEvenAmountLong'; + docs: [ + "sum of all long user's quote_break_even_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'quoteBreakEvenAmountShort'; + docs: [ + "sum of all short user's quote_break_even_amount in market", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'userLpShares'; + docs: [ + 'total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastFundingRate'; + docs: [ + 'last funding rate in this perp market (unit is quote per base)', + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateLong'; + docs: [ + 'last funding rate for longs in this perp market (unit is quote per base)', + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateShort'; + docs: [ + 'last funding rate for shorts in this perp market (unit is quote per base)', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'last24hAvgFundingRate'; + docs: [ + 'estimate of last 24h of funding rate perp market (unit is quote per base)', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'totalFee'; + docs: [ + 'total fees collected by this perp market', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalMmFee'; + docs: [ + "total fees collected by the vAMM's bid/ask spread", + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalExchangeFee'; + docs: [ + 'total fees collected by exchange fee schedule', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalFeeMinusDistributions'; + docs: [ + 'total fees minus any recognized upnl and pool withdraws', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalFeeWithdrawn'; + docs: [ + 'sum of all fees from fee pool withdrawn to revenue pool', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalLiquidationFee'; + docs: [ + 'all fees collected by market for liquidations', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeFundingRateLong'; + docs: [ + 'accumulated funding rate for longs since inception in market', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'cumulativeFundingRateShort'; + docs: [ + 'accumulated funding rate for shorts since inception in market', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'totalSocialLoss'; + docs: [ + 'accumulated social loss paid by users since inception in market', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'askBaseAssetReserve'; + docs: [ + 'transformed base_asset_reserve for users going long', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'askQuoteAssetReserve'; + docs: [ + 'transformed quote_asset_reserve for users going long', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'bidBaseAssetReserve'; + docs: [ + 'transformed base_asset_reserve for users going short', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'bidQuoteAssetReserve'; + docs: [ + 'transformed quote_asset_reserve for users going short', + 'precision: AMM_RESERVE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastOracleNormalisedPrice'; + docs: [ + 'the last seen oracle price partially shrunk toward the amm reserve price', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastOracleReservePriceSpreadPct'; + docs: [ + 'the gap between the oracle price and the reserve price = y * peg_multiplier / x', + ]; + type: 'i64'; + }, + { + name: 'lastBidPriceTwap'; + docs: [ + 'average estimate of bid price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastAskPriceTwap'; + docs: [ + 'average estimate of ask price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwap'; + docs: [ + 'average estimate of (bid+ask)/2 price over funding_period', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwap5min'; + docs: ['average estimate of (bid+ask)/2 price over FIVE_MINUTES']; + type: 'u64'; + }, + { + name: 'lastUpdateSlot'; + docs: ['the last blockchain slot the amm was updated']; + type: 'u64'; + }, + { + name: 'lastOracleConfPct'; + docs: [ + 'the pct size of the oracle confidence interval', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'netRevenueSinceLastFunding'; + docs: [ + 'the total_fee_minus_distribution change since the last funding update', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastFundingRateTs'; + docs: ['the last funding rate update unix_timestamp']; + type: 'i64'; + }, + { + name: 'fundingPeriod'; + docs: ['the periodicity of the funding rate updates']; + type: 'i64'; + }, + { + name: 'orderStepSize'; + docs: [ + 'the base step size (increment) of orders', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'orderTickSize'; + docs: [ + 'the price tick size of orders', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minOrderSize'; + docs: [ + 'the minimum base size of an order', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'mmOracleSlot'; + docs: [ + 'the max base size a single user can have', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'volume24h'; + docs: ['estimated total of volume in market', 'QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'longIntensityVolume'; + docs: ['the volume intensity of long fills against AMM']; + type: 'u64'; + }, + { + name: 'shortIntensityVolume'; + docs: ['the volume intensity of short fills against AMM']; + type: 'u64'; + }, + { + name: 'lastTradeTs'; + docs: [ + 'the blockchain unix timestamp at the time of the last trade', + ]; + type: 'i64'; + }, + { + name: 'markStd'; + docs: [ + 'estimate of standard deviation of the fill (mark) prices', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'oracleStd'; + docs: [ + 'estimate of standard deviation of the oracle price at each update', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMarkPriceTwapTs'; + docs: ['the last unix_timestamp the mark twap was updated']; + type: 'i64'; + }, + { + name: 'baseSpread'; + docs: [ + 'the minimum spread the AMM can quote. also used as step size for some spread logic increases.', + ]; + type: 'u32'; + }, + { + name: 'maxSpread'; + docs: ['the maximum spread the AMM can quote']; + type: 'u32'; + }, + { + name: 'longSpread'; + docs: ['the spread for asks vs the reserve price']; + type: 'u32'; + }, + { + name: 'shortSpread'; + docs: ['the spread for bids vs the reserve price']; + type: 'u32'; + }, + { + name: 'mmOraclePrice'; + docs: ['MM oracle price']; + type: 'i64'; + }, + { + name: 'maxFillReserveFraction'; + docs: [ + 'the fraction of total available liquidity a single fill on the AMM can consume', + ]; + type: 'u16'; + }, + { + name: 'maxSlippageRatio'; + docs: ['the maximum slippage a single fill on the AMM can push']; + type: 'u16'; + }, + { + name: 'curveUpdateIntensity'; + docs: [ + 'the update intensity of AMM formulaic updates (adjusting k). 0-100', + ]; + type: 'u8'; + }, + { + name: 'ammJitIntensity'; + docs: [ + 'the jit intensity of AMM. larger intensity means larger participation in jit. 0 means no jit participation.', + '(0, 100] is intensity for protocol-owned AMM. (100, 200] is intensity for user LP-owned AMM.', + ]; + type: 'u8'; + }, + { + name: 'oracleSource'; + docs: [ + 'the oracle provider information. used to decode/scale the oracle public key', + ]; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'lastOracleValid'; + docs: [ + 'tracks whether the oracle was considered valid at the last AMM update', + ]; + type: 'bool'; + }, + { + name: 'targetBaseAssetAmountPerLp'; + docs: [ + 'the target value for `base_asset_amount_per_lp`, used during AMM JIT with LP split', + 'precision: BASE_PRECISION', + ]; + type: 'i32'; + }, + { + name: 'perLpBase'; + docs: [ + 'expo for unit of per_lp, base 10 (if per_lp_base=X, then per_lp unit is 10^X)', + ]; + type: 'i8'; + }, + { + name: 'oracleLowRiskSlotDelayOverride'; + docs: [ + 'the override for the state.min_perp_auction_duration', + '0 is no override, -1 is disable speed bump, 1-100 is literal speed bump', + ]; + type: 'i8'; + }, + { + name: 'ammSpreadAdjustment'; + docs: [ + 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', + ]; + type: 'i8'; + }, + { + name: 'oracleSlotDelayOverride'; + type: 'i8'; + }, + { + name: 'mmOracleSequenceId'; + type: 'u64'; + }, + { + name: 'netUnsettledFundingPnl'; + type: 'i64'; + }, + { + name: 'quoteAssetAmountWithUnsettledLp'; + type: 'i64'; + }, + { + name: 'referencePriceOffset'; + type: 'i32'; + }, + { + name: 'ammInventorySpreadAdjustment'; + docs: [ + 'signed scale amm_spread similar to fee_adjustment logic (-100 = 0, 100 = double)', + ]; + type: 'i8'; + }, + { + name: 'referencePriceOffsetDeadbandPct'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 2]; + }; + }, + { + name: 'lastFundingOracleTwap'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'addAmmConstituentMappingDatum'; + type: { + kind: 'struct'; + fields: [ + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'weight'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ammCache'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'cache'; + type: { + vec: { + defined: { + name: 'cacheInfo'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'ammConstituentDatum'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'lastSlot'; + type: 'u64'; + }, + { + name: 'weight'; + docs: [ + 'PERCENTAGE_PRECISION. The weight this constituent has on the perp market', + ]; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ammConstituentMapping'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'weights'; + type: { + vec: { + defined: { + name: 'ammConstituentDatum'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'assetTier'; + type: { + kind: 'enum'; + variants: [ + { + name: 'collateral'; + }, + { + name: 'protected'; + }, + { + name: 'cross'; + }, + { + name: 'isolated'; + }, + { + name: 'unlisted'; + }, + ]; + }; + }, + { + name: 'builderInfo'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'maxFeeTenthBps'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 6]; + }; + }, + ]; + }; + }, + { + name: 'cacheInfo'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'oracle'; + type: 'pubkey'; + }, + { + name: 'lastFeePoolTokenAmount'; + type: 'u128'; + }, + { + name: 'lastNetPnlPoolTokenAmount'; + type: 'i128'; + }, + { + name: 'lastExchangeFees'; + type: 'u128'; + }, + { + name: 'lastSettleAmmExFees'; + type: 'u128'; + }, + { + name: 'lastSettleAmmPnl'; + type: 'i128'; + }, + { + name: 'position'; + docs: ['BASE PRECISION']; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'lastSettleAmount'; + type: 'u64'; + }, + { + name: 'lastSettleSlot'; + type: 'u64'; + }, + { + name: 'lastSettleTs'; + type: 'i64'; + }, + { + name: 'quoteOwedFromLpPool'; + type: 'i64'; + }, + { + name: 'ammInventoryLimit'; + type: 'i64'; + }, + { + name: 'oraclePrice'; + type: 'i64'; + }, + { + name: 'oracleSlot'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'oracleSource'; + type: 'u8'; + }, + { + name: 'oracleValidity'; + type: 'u8'; + }, + { + name: 'lpStatusForPerpMarket'; + type: 'u8'; + }, + { + name: 'ammPositionScalar'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 34]; + }; + }, + ]; + }; + }, + { + name: 'constituent'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: ['address of the constituent']; + type: 'pubkey'; + }, + { + name: 'mint'; + type: 'pubkey'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'vault'; + type: 'pubkey'; + }, + { + name: 'totalSwapFees'; + docs: [ + 'total fees received by the constituent. Positive = fees received, Negative = fees paid', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'spotBalance'; + docs: ['spot borrow-lend balance for constituent']; + type: { + defined: { + name: 'constituentSpotBalance'; + }; + }; + }, + { + name: 'lastSpotBalanceTokenAmount'; + type: 'i64'; + }, + { + name: 'cumulativeSpotInterestAccruedTokenAmount'; + type: 'i64'; + }, + { + name: 'maxWeightDeviation'; + docs: [ + 'max deviation from target_weight allowed for the constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'swapFeeMin'; + docs: [ + 'min fee charged on swaps to/from this constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'swapFeeMax'; + docs: [ + 'max fee charged on swaps to/from this constituent', + 'precision: PERCENTAGE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxBorrowTokenAmount'; + docs: ['Max Borrow amount:', 'precision: token precision']; + type: 'u64'; + }, + { + name: 'vaultTokenBalance'; + docs: ['ata token balance in token precision']; + type: 'u64'; + }, + { + name: 'lastOraclePrice'; + type: 'i64'; + }, + { + name: 'lastOracleSlot'; + type: 'u64'; + }, + { + name: 'oracleStalenessThreshold'; + docs: ['Delay allowed for valid AUM calculation']; + type: 'u64'; + }, + { + name: 'flashLoanInitialTokenAmount'; + type: 'u64'; + }, + { + name: 'nextSwapId'; + docs: [ + 'Every swap to/from this constituent has a monotonically increasing id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'derivativeWeight'; + docs: [ + 'percentable of derivatve weight to go to this specific derivative PERCENTAGE_PRECISION. Zero if no derivative weight', + ]; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'constituentDerivativeDepegThreshold'; + type: 'u64'; + }, + { + name: 'constituentDerivativeIndex'; + docs: [ + 'The `constituent_index` of the parent constituent. -1 if it is a parent index', + 'Example: if in a pool with SOL (parent) and dSOL (derivative),', + 'SOL.constituent_index = 1, SOL.constituent_derivative_index = -1,', + 'dSOL.constituent_index = 2, dSOL.constituent_derivative_index = 1', + ]; + type: 'i16'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'decimals'; + type: 'u8'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'vaultBump'; + type: 'u8'; + }, + { + name: 'gammaInventory'; + type: 'u8'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 162]; + }; + }, + ]; + }; + }, + { + name: 'constituentCorrelations'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'correlations'; + type: { + vec: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'constituentParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxWeightDeviation'; + type: { + option: 'i64'; + }; + }, + { + name: 'swapFeeMin'; + type: { + option: 'i64'; + }; + }, + { + name: 'swapFeeMax'; + type: { + option: 'i64'; + }; + }, + { + name: 'maxBorrowTokenAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'oracleStalenessThreshold'; + type: { + option: 'u64'; + }; + }, + { + name: 'costToTradeBps'; + type: { + option: 'i32'; + }; + }, + { + name: 'constituentDerivativeIndex'; + type: { + option: 'i16'; + }; + }, + { + name: 'derivativeWeight'; + type: { + option: 'u64'; + }; + }, + { + name: 'volatility'; + type: { + option: 'u64'; + }; + }, + { + name: 'gammaExecution'; + type: { + option: 'u8'; + }; + }, + { + name: 'gammaInventory'; + type: { + option: 'u8'; + }; + }, + { + name: 'xi'; + type: { + option: 'u8'; + }; + }, + ]; + }; + }, + { + name: 'constituentSpotBalance'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', + 'interest of corresponding market.', + 'precision: token precision', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeDeposits'; + docs: [ + 'The cumulative deposits/borrows a user has made into a market', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'marketIndex'; + docs: ['The market index of the corresponding spot market']; + type: 'u16'; + }, + { + name: 'balanceType'; + docs: ['Whether the position is deposit or borrow']; + type: { + defined: { + name: 'spotBalanceType'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 5]; + }; + }, + ]; + }; + }, + { + name: 'constituentTargetBase'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lpPool'; + type: 'pubkey'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'targets'; + type: { + vec: { + defined: { + name: 'targetsDatum'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'contractTier'; + type: { + kind: 'enum'; + variants: [ + { + name: 'a'; + }, + { + name: 'b'; + }, + { + name: 'c'; + }, + { + name: 'speculative'; + }, + { + name: 'highlySpeculative'; + }, + { + name: 'isolated'; + }, + ]; + }; + }, + { + name: 'contractType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'perpetual'; + }, + { + name: 'future'; + }, + { + name: 'prediction'; + }, + ]; + }; + }, + { + name: 'curveRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'pegMultiplierBefore'; + type: 'u128'; + }, + { + name: 'baseAssetReserveBefore'; + type: 'u128'; + }, + { + name: 'quoteAssetReserveBefore'; + type: 'u128'; + }, + { + name: 'sqrtKBefore'; + type: 'u128'; + }, + { + name: 'pegMultiplierAfter'; + type: 'u128'; + }, + { + name: 'baseAssetReserveAfter'; + type: 'u128'; + }, + { + name: 'quoteAssetReserveAfter'; + type: 'u128'; + }, + { + name: 'sqrtKAfter'; + type: 'u128'; + }, + { + name: 'baseAssetAmountLong'; + docs: ['precision: BASE_PRECISION']; + type: 'u128'; + }, + { + name: 'baseAssetAmountShort'; + docs: ['precision: BASE_PRECISION']; + type: 'u128'; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + { + name: 'totalFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'totalFeeMinusDistributions'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'adjustmentCost'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i128'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'fillRecord'; + type: 'u128'; + }, + { + name: 'numberOfUsers'; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + ]; + }; + }, + { + name: 'deleteUserRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'keeper'; + type: { + option: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'depositDirection'; + type: { + kind: 'enum'; + variants: [ + { + name: 'deposit'; + }, + { + name: 'withdraw'; + }, + ]; + }; + }, + { + name: 'depositExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'transfer'; + }, + { + name: 'borrow'; + }, + { + name: 'repayBorrow'; + }, + { + name: 'reward'; + }, + ]; + }; + }, + { + name: 'depositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + docs: ['user account public key']; + type: 'pubkey'; + }, + { + name: 'direction'; + type: { + defined: { + name: 'depositDirection'; + }; + }; + }, + { + name: 'depositRecordId'; + type: 'u64'; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'marketIndex'; + docs: ['spot market index']; + type: 'u16'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'marketDepositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'marketWithdrawBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'marketCumulativeDepositInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'marketCumulativeBorrowInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'totalDepositsAfter'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalWithdrawsAfter'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'explanation'; + type: { + defined: { + name: 'depositExplanation'; + }; + }; + }, + { + name: 'transferUser'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'signer'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'userTokenAmountAfter'; + docs: ['precision: token mint precision']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'feeStructure'; + type: { + kind: 'struct'; + fields: [ + { + name: 'feeTiers'; + type: { + array: [ + { + defined: { + name: 'feeTier'; + }; + }, + 10, + ]; + }; + }, + { + name: 'fillerRewardStructure'; + type: { + defined: { + name: 'orderFillerRewardStructure'; + }; + }; + }, + { + name: 'referrerRewardEpochUpperBound'; + type: 'u64'; + }, + { + name: 'flatFillerFee'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'feeTier'; + type: { + kind: 'struct'; + fields: [ + { + name: 'feeNumerator'; + type: 'u32'; + }, + { + name: 'feeDenominator'; + type: 'u32'; + }, + { + name: 'makerRebateNumerator'; + type: 'u32'; + }, + { + name: 'makerRebateDenominator'; + type: 'u32'; + }, + { + name: 'referrerRewardNumerator'; + type: 'u32'; + }, + { + name: 'referrerRewardDenominator'; + type: 'u32'; + }, + { + name: 'refereeFeeNumerator'; + type: 'u32'; + }, + { + name: 'refereeFeeDenominator'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'fuelOverflow'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The authority of this overflow account']; + type: 'pubkey'; + }, + { + name: 'fuelInsurance'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelDeposits'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelBorrows'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelPositions'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelTaker'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'fuelMaker'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastFuelSweepTs'; + type: 'u32'; + }, + { + name: 'lastResetTs'; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u128', 6]; + }; + }, + ]; + }; + }, + { + name: 'fuelSeasonRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'fuelInsurance'; + type: 'u128'; + }, + { + name: 'fuelDeposits'; + type: 'u128'; + }, + { + name: 'fuelBorrows'; + type: 'u128'; + }, + { + name: 'fuelPositions'; + type: 'u128'; + }, + { + name: 'fuelTaker'; + type: 'u128'; + }, + { + name: 'fuelMaker'; + type: 'u128'; + }, + { + name: 'fuelTotal'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'fuelSweepRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'userStatsFuelInsurance'; + type: 'u32'; + }, + { + name: 'userStatsFuelDeposits'; + type: 'u32'; + }, + { + name: 'userStatsFuelBorrows'; + type: 'u32'; + }, + { + name: 'userStatsFuelPositions'; + type: 'u32'; + }, + { + name: 'userStatsFuelTaker'; + type: 'u32'; + }, + { + name: 'userStatsFuelMaker'; + type: 'u32'; + }, + { + name: 'fuelOverflowFuelInsurance'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelDeposits'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelBorrows'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelPositions'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelTaker'; + type: 'u128'; + }, + { + name: 'fuelOverflowFuelMaker'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'fundingPaymentRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fundingPayment'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + docs: ['precision: BASE_PRECISION']; + type: 'i64'; + }, + { + name: 'userLastCumulativeFunding'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i64'; + }, + { + name: 'ammCumulativeFundingLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'ammCumulativeFundingShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'fundingRateRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fundingRate'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i64'; + }, + { + name: 'fundingRateLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'fundingRateShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'cumulativeFundingRateLong'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'cumulativeFundingRateShort'; + docs: ['precision: FUNDING_RATE_PRECISION']; + type: 'i128'; + }, + { + name: 'oraclePriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'markPriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'periodRevenue'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'baseAssetAmountWithAmm'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + { + name: 'baseAssetAmountWithUnsettledLp'; + docs: ['precision: BASE_PRECISION']; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'highLeverageModeConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'currentUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'u8'; + }, + { + name: 'padding1'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'currentMaintenanceUsers'; + type: 'u32'; + }, + { + name: 'padding2'; + type: { + array: ['u8', 24]; + }; + }, + ]; + }; + }, + { + name: 'historicalIndexData'; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastIndexBidPrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexAskPrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwap5min'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastIndexPriceTwapTs'; + docs: ['unix_timestamp of last snapshot']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'historicalOracleData'; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOracleConf'; + docs: ['precision: PRICE_PRECISION']; + type: 'u64'; + }, + { + name: 'lastOracleDelay'; + docs: ['number of slots since last update']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwap'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwap5min'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastOraclePriceTwapTs'; + docs: ['unix_timestamp of last snapshot']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'totalInAmount'; + docs: ['total amount to be sold']; + type: 'u64'; + }, + { + name: 'currentInAmount'; + docs: ['amount already sold']; + type: 'u64'; + }, + { + name: 'currentOutAmount'; + docs: ['amount already bought']; + type: 'u64'; + }, + { + name: 'currentOutAmountTransferred'; + docs: ['amount already transferred to revenue pool']; + type: 'u64'; + }, + { + name: 'currentInAmountSinceLastTransfer'; + docs: ['amount already bought in epoch']; + type: 'u64'; + }, + { + name: 'epochStartTs'; + docs: ['start time of epoch']; + type: 'i64'; + }, + { + name: 'epochInAmount'; + docs: ['amount already bought in epoch']; + type: 'u64'; + }, + { + name: 'epochMaxInAmount'; + docs: ['max amount to swap in epoch']; + type: 'u64'; + }, + { + name: 'epochDuration'; + docs: ['duration of epoch']; + type: 'i64'; + }, + { + name: 'outMarketIndex'; + docs: ['market index to sell']; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + docs: ['market index to buy']; + type: 'u16'; + }, + { + name: 'maxSlippageBps'; + type: 'u16'; + }, + { + name: 'swapMode'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + { + name: 'padding2'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }; + }, + { + name: 'ifRebalanceConfigParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'totalInAmount'; + type: 'u64'; + }, + { + name: 'epochMaxInAmount'; + type: 'u64'; + }, + { + name: 'epochDuration'; + type: 'i64'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'maxSlippageBps'; + type: 'u16'; + }, + { + name: 'swapMode'; + type: 'u8'; + }, + { + name: 'status'; + type: 'u8'; + }, + ]; + }; + }, + { + name: 'insuranceClaim'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'revenueWithdrawSinceLastSettle'; + docs: [ + 'The amount of revenue last settled', + 'Positive if funds left the perp market,', + 'negative if funds were pulled into the perp market', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxRevenueWithdrawPerPeriod'; + docs: [ + 'The max amount of revenue that can be withdrawn per period', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'quoteMaxInsurance'; + docs: [ + 'The max amount of insurance that perp market can use to resolve bankruptcy and pnl deficits', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'quoteSettledInsurance'; + docs: [ + 'The amount of insurance that has been used to resolve bankruptcy and pnl deficits', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastRevenueWithdrawTs'; + docs: ['The last time revenue was settled in/out of market']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'insuranceFund'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'vault'; + type: 'pubkey'; + }, + { + name: 'totalShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'userShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'sharesBase'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'unstakingPeriod'; + type: 'i64'; + }, + { + name: 'lastRevenueSettleTs'; + type: 'i64'; + }, + { + name: 'revenueSettlePeriod'; + type: 'i64'; + }, + { + name: 'totalFactor'; + type: 'u32'; + }, + { + name: 'userFactor'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'insuranceFundRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'userIfFactor'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'totalIfFactor'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'vaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'insuranceVaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'totalIfSharesBefore'; + type: 'u128'; + }, + { + name: 'totalIfSharesAfter'; + type: 'u128'; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'insuranceFundStake'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'ifShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastWithdrawRequestShares'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'ifBase'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastValidTs'; + type: 'i64'; + }, + { + name: 'lastWithdrawRequestValue'; + type: 'u64'; + }, + { + name: 'lastWithdrawRequestTs'; + type: 'i64'; + }, + { + name: 'costBasis'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 14]; + }; + }, + ]; + }; + }, + { + name: 'insuranceFundStakeRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'action'; + type: { + defined: { + name: 'stakeAction'; + }; + }; + }, + { + name: 'amount'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'insuranceVaultAmountBefore'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + { + name: 'ifSharesBefore'; + type: 'u128'; + }, + { + name: 'userIfSharesBefore'; + type: 'u128'; + }, + { + name: 'totalIfSharesBefore'; + type: 'u128'; + }, + { + name: 'ifSharesAfter'; + type: 'u128'; + }, + { + name: 'userIfSharesAfter'; + type: 'u128'; + }, + { + name: 'totalIfSharesAfter'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'insuranceFundSwapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'rebalanceConfig'; + type: 'pubkey'; + }, + { + name: 'inIfTotalSharesBefore'; + type: 'u128'; + }, + { + name: 'outIfTotalSharesBefore'; + type: 'u128'; + }, + { + name: 'inIfUserSharesBefore'; + type: 'u128'; + }, + { + name: 'outIfUserSharesBefore'; + type: 'u128'; + }, + { + name: 'inIfTotalSharesAfter'; + type: 'u128'; + }, + { + name: 'outIfTotalSharesAfter'; + type: 'u128'; + }, + { + name: 'inIfUserSharesAfter'; + type: 'u128'; + }, + { + name: 'outIfUserSharesAfter'; + type: 'u128'; + }, + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'inAmount'; + type: 'u64'; + }, + { + name: 'outAmount'; + type: 'u64'; + }, + { + name: 'outOraclePrice'; + type: 'u64'; + }, + { + name: 'outOraclePriceTwap'; + type: 'i64'; + }, + { + name: 'inVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'outVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'inFundVaultAmountAfter'; + type: 'u64'; + }, + { + name: 'outFundVaultAmountAfter'; + type: 'u64'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + ]; + }; + }, + { + name: 'lpAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'addLiquidity'; + }, + { + name: 'removeLiquidity'; + }, + { + name: 'settleLiquidity'; + }, + { + name: 'removeLiquidityDerisk'; + }, + ]; + }; + }, + { + name: 'lpBorrowLendDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'direction'; + type: { + defined: { + name: 'depositDirection'; + }; + }; + }, + { + name: 'tokenBalance'; + type: 'i64'; + }, + { + name: 'lastTokenBalance'; + type: 'i64'; + }, + { + name: 'interestAccruedTokenAmount'; + type: 'i64'; + }, + { + name: 'amountDepositWithdraw'; + type: 'u64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpMintRedeemRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'description'; + type: 'u8'; + }, + { + name: 'amount'; + docs: ['precision: continutent mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'fee'; + docs: [ + 'precision: fee on amount, constituent market mint precision', + ]; + type: 'i128'; + }, + { + name: 'spotMarketIndex'; + type: 'u16'; + }, + { + name: 'constituentIndex'; + type: 'u16'; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'mint'; + docs: ['token mint']; + type: 'pubkey'; + }, + { + name: 'lpAmount'; + docs: ['lp amount, lp mint precision']; + type: 'u64'; + }, + { + name: 'lpFee'; + docs: ['lp fee, lp mint precision']; + type: 'i64'; + }, + { + name: 'lpPrice'; + docs: ['the fair price of the lp token, PRICE_PRECISION']; + type: 'u128'; + }, + { + name: 'mintRedeemId'; + type: 'u64'; + }, + { + name: 'lastAum'; + docs: ['LPPool last_aum']; + type: 'u128'; + }, + { + name: 'lastAumSlot'; + type: 'u64'; + }, + { + name: 'inMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inMarketTargetWeight'; + type: 'i64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpPool'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: ['address of the vault.']; + type: 'pubkey'; + }, + { + name: 'mint'; + type: 'pubkey'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + { + name: 'constituentTargetBase'; + type: 'pubkey'; + }, + { + name: 'constituentCorrelations'; + type: 'pubkey'; + }, + { + name: 'maxAum'; + docs: [ + 'The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)', + 'which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)', + 'pub quote_constituent_index: u16,', + 'QUOTE_PRECISION: Max AUM, Prohibit minting new DLP beyond this', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'lastAum'; + docs: ['QUOTE_PRECISION: AUM of the vault in USD, updated lazily']; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeQuoteSentToPerpMarkets'; + docs: ['QUOTE PRECISION: Cumulative quotes from settles']; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeQuoteReceivedFromPerpMarkets'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalMintRedeemFeesPaid'; + docs: [ + 'QUOTE_PRECISION: Total fees paid for minting and redeeming LP tokens', + ]; + type: { + defined: { + name: 'i128'; + }; + }; + }, + { + name: 'lastAumSlot'; + docs: ['timestamp of last AUM slot']; + type: 'u64'; + }, + { + name: 'maxSettleQuoteAmount'; + type: 'u64'; + }, + { + name: 'padding'; + docs: ['timestamp of last vAMM revenue rebalance']; + type: 'u64'; + }, + { + name: 'mintRedeemId'; + docs: [ + 'Every mint/redeem has a monotonically increasing id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'settleId'; + type: 'u64'; + }, + { + name: 'minMintFee'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'tokenSupply'; + type: 'u64'; + }, + { + name: 'volatility'; + type: 'u64'; + }, + { + name: 'constituents'; + type: 'u16'; + }, + { + name: 'quoteConsituentIndex'; + type: 'u16'; + }, + { + name: 'bump'; + type: 'u8'; + }, + { + name: 'gammaExecution'; + type: 'u8'; + }, + { + name: 'xi'; + type: 'u8'; + }, + { + name: 'targetOracleDelayFeeBpsPer10Slots'; + type: 'u8'; + }, + { + name: 'targetPositionDelayFeeBpsPer10Slots'; + type: 'u8'; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 174]; + }; + }, + ]; + }; + }, + { + name: 'lpRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'action'; + type: { + defined: { + name: 'lpAction'; + }; + }; + }, + { + name: 'nShares'; + docs: ['precision: AMM_RESERVE_PRECISION']; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'deltaBaseAssetAmount'; + docs: ['precision: BASE_PRECISION']; + type: 'i64'; + }, + { + name: 'deltaQuoteAssetAmount'; + docs: ['precision: QUOTE_PRECISION']; + type: 'i64'; + }, + { + name: 'pnl'; + docs: [ + 'realized pnl of the position settlement', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'lpSettleRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'recordId'; + type: 'u64'; + }, + { + name: 'lastTs'; + type: 'i64'; + }, + { + name: 'lastSlot'; + type: 'u64'; + }, + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'settleToLpAmount'; + type: 'i64'; + }, + { + name: 'perpAmmPnlDelta'; + type: 'i64'; + }, + { + name: 'perpAmmExFeeDelta'; + type: 'i64'; + }, + { + name: 'lpAum'; + type: 'u128'; + }, + { + name: 'lpPrice'; + type: 'u128'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'lpSwapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'outAmount'; + docs: ['precision: out market mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'inAmount'; + docs: ['precision: in market mint precision, gross fees']; + type: 'u128'; + }, + { + name: 'outFee'; + docs: ['precision: fee on amount_out, in market mint precision']; + type: 'i128'; + }, + { + name: 'inFee'; + docs: ['precision: fee on amount_in, out market mint precision']; + type: 'i128'; + }, + { + name: 'outSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'inSpotMarketIndex'; + type: 'u16'; + }, + { + name: 'outConstituentIndex'; + type: 'u16'; + }, + { + name: 'inConstituentIndex'; + type: 'u16'; + }, + { + name: 'outOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'inOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'lastAum'; + docs: ['LPPool last_aum, QUOTE_PRECISION']; + type: 'u128'; + }, + { + name: 'lastAumSlot'; + type: 'u64'; + }, + { + name: 'inMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'outMarketCurrentWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inMarketTargetWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'outMarketTargetWeight'; + docs: ['PERCENTAGE_PRECISION']; + type: 'i64'; + }, + { + name: 'inSwapId'; + type: 'u64'; + }, + { + name: 'outSwapId'; + type: 'u64'; + }, + { + name: 'lpPool'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'liquidateBorrowForPerpPnlRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marketOraclePrice'; + type: 'i64'; + }, + { + name: 'pnlTransfer'; + type: 'u128'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityPrice'; + type: 'i64'; + }, + { + name: 'liabilityTransfer'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'liquidatePerpPnlForDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'marketOraclePrice'; + type: 'i64'; + }, + { + name: 'pnlTransfer'; + type: 'u128'; + }, + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'assetPrice'; + type: 'i64'; + }, + { + name: 'assetTransfer'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'liquidatePerpRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'oraclePrice'; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + type: 'i64'; + }, + { + name: 'quoteAssetAmount'; + type: 'i64'; + }, + { + name: 'lpShares'; + docs: ['precision: AMM_RESERVE_PRECISION']; + type: 'u64'; + }, + { + name: 'fillRecordId'; + type: 'u64'; + }, + { + name: 'userOrderId'; + type: 'u32'; + }, + { + name: 'liquidatorOrderId'; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'ifFee'; + docs: ['precision: QUOTE_PRECISION']; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'liquidateSpotRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'assetMarketIndex'; + type: 'u16'; + }, + { + name: 'assetPrice'; + type: 'i64'; + }, + { + name: 'assetTransfer'; + type: 'u128'; + }, + { + name: 'liabilityMarketIndex'; + type: 'u16'; + }, + { + name: 'liabilityPrice'; + type: 'i64'; + }, + { + name: 'liabilityTransfer'; + docs: ['precision: token mint precision']; + type: 'u128'; + }, + { + name: 'ifFee'; + docs: ['precision: token mint precision']; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'liquidationRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'liquidationType'; + type: { + defined: { + name: 'liquidationType'; + }; + }; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'liquidator'; + type: 'pubkey'; + }, + { + name: 'marginRequirement'; + type: 'u128'; + }, + { + name: 'totalCollateral'; + type: 'i128'; + }, + { + name: 'marginFreed'; + type: 'u64'; + }, + { + name: 'liquidationId'; + type: 'u16'; + }, + { + name: 'bankrupt'; + type: 'bool'; + }, + { + name: 'canceledOrderIds'; + type: { + vec: 'u32'; + }; + }, + { + name: 'liquidatePerp'; + type: { + defined: { + name: 'liquidatePerpRecord'; + }; + }; + }, + { + name: 'liquidateSpot'; + type: { + defined: { + name: 'liquidateSpotRecord'; + }; + }; + }, + { + name: 'liquidateBorrowForPerpPnl'; + type: { + defined: { + name: 'liquidateBorrowForPerpPnlRecord'; + }; + }; + }, + { + name: 'liquidatePerpPnlForDeposit'; + type: { + defined: { + name: 'liquidatePerpPnlForDepositRecord'; + }; + }; + }, + { + name: 'perpBankruptcy'; + type: { + defined: { + name: 'perpBankruptcyRecord'; + }; + }; + }, + { + name: 'spotBankruptcy'; + type: { + defined: { + name: 'spotBankruptcyRecord'; + }; + }; + }, + ]; + }; + }, + { + name: 'liquidationType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'liquidatePerp'; + }, + { + name: 'liquidateSpot'; + }, + { + name: 'liquidateBorrowForPerpPnl'; + }, + { + name: 'liquidatePerpPnlForDeposit'; + }, + { + name: 'perpBankruptcy'; + }, + { + name: 'spotBankruptcy'; + }, + ]; + }; + }, + { + name: 'lpPoolParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxSettleQuoteAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'volatility'; + type: { + option: 'u64'; + }; + }, + { + name: 'gammaExecution'; + type: { + option: 'u8'; + }; + }, + { + name: 'xi'; + type: { + option: 'u8'; + }; + }, + { + name: 'maxAum'; + type: { + option: 'u128'; + }; + }, + { + name: 'whitelistMint'; + type: { + option: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'marginMode'; + type: { + kind: 'enum'; + variants: [ + { + name: 'default'; + }, + { + name: 'highLeverage'; + }, + { + name: 'highLeverageMaintenance'; + }, + ]; + }; + }, + { + name: 'marketStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'initialized'; + }, + { + name: 'active'; + }, + { + name: 'fundingPaused'; + }, + { + name: 'ammPaused'; + }, + { + name: 'fillPaused'; + }, + { + name: 'withdrawPaused'; + }, + { + name: 'reduceOnly'; + }, + { + name: 'settlement'; + }, + { + name: 'delisted'; + }, + ]; + }; + }, + { + name: 'marketType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'spot'; + }, + { + name: 'perp'; + }, + ]; + }; + }, + { + name: 'modifyOrderParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'direction'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'baseAssetAmount'; + type: { + option: 'u64'; + }; + }, + { + name: 'price'; + type: { + option: 'u64'; + }; + }, + { + name: 'reduceOnly'; + type: { + option: 'bool'; + }; + }, + { + name: 'postOnly'; + type: { + option: { + defined: { + name: 'postOnlyParam'; + }; + }; + }; + }, + { + name: 'bitFlags'; + type: { + option: 'u8'; + }; + }, + { + name: 'maxTs'; + type: { + option: 'i64'; + }; + }, + { + name: 'triggerPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerCondition'; + type: { + option: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }; + }, + { + name: 'oraclePriceOffset'; + type: { + option: 'i32'; + }; + }, + { + name: 'auctionDuration'; + type: { + option: 'u8'; + }; + }, + { + name: 'auctionStartPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'auctionEndPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'policy'; + type: { + option: 'u8'; + }; + }, + ]; + }; + }, + { + name: 'newUserRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + docs: ['unix_timestamp of action']; + type: 'i64'; + }, + { + name: 'userAuthority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'referrer'; + type: 'pubkey'; + }, + ]; + }; + }, + { + name: 'openbookV2FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'openbookV2ProgramId'; + type: 'pubkey'; + }, + { + name: 'openbookV2Market'; + type: 'pubkey'; + }, + { + name: 'openbookV2MarketAuthority'; + type: 'pubkey'; + }, + { + name: 'openbookV2EventHeap'; + type: 'pubkey'; + }, + { + name: 'openbookV2Bids'; + type: 'pubkey'; + }, + { + name: 'openbookV2Asks'; + type: 'pubkey'; + }, + { + name: 'openbookV2BaseVault'; + type: 'pubkey'; + }, + { + name: 'openbookV2QuoteVault'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'oracleGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'priceDivergence'; + type: { + defined: { + name: 'priceDivergenceGuardRails'; + }; + }; + }, + { + name: 'validity'; + type: { + defined: { + name: 'validityGuardRails'; + }; + }; + }, + ]; + }; + }, + { + name: 'oracleSource'; + type: { + kind: 'enum'; + variants: [ + { + name: 'pyth'; + }, + { + name: 'switchboard'; + }, + { + name: 'quoteAsset'; + }, + { + name: 'pyth1K'; + }, + { + name: 'pyth1M'; + }, + { + name: 'pythStableCoin'; + }, + { + name: 'prelaunch'; + }, + { + name: 'pythPull'; + }, + { + name: 'pyth1KPull'; + }, + { + name: 'pyth1MPull'; + }, + { + name: 'pythStableCoinPull'; + }, + { + name: 'switchboardOnDemand'; + }, + { + name: 'pythLazer'; + }, + { + name: 'pythLazer1K'; + }, + { + name: 'pythLazer1M'; + }, + { + name: 'pythLazerStableCoin'; + }, + ]; + }; + }, + { + name: 'order'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'slot'; + docs: ['The slot the order was placed']; + type: 'u64'; + }, + { + name: 'price'; + docs: [ + 'The limit price for the order (can be 0 for market orders)', + "For orders with an auction, this price isn't used until the auction is complete", + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'baseAssetAmount'; + docs: [ + 'The size of the order', + 'precision for perps: BASE_PRECISION', + 'precision for spot: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'baseAssetAmountFilled'; + docs: [ + 'The amount of the order filled', + 'precision for perps: BASE_PRECISION', + 'precision for spot: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'quoteAssetAmountFilled'; + docs: [ + 'The amount of quote filled for the order', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'triggerPrice'; + docs: [ + 'At what price the order will be triggered. Only relevant for trigger orders', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'auctionStartPrice'; + docs: [ + 'The start price for the auction. Only relevant for market/oracle orders', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'auctionEndPrice'; + docs: [ + 'The end price for the auction. Only relevant for market/oracle orders', + 'precision: PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'maxTs'; + docs: ['The time when the order will expire']; + type: 'i64'; + }, + { + name: 'oraclePriceOffset'; + docs: [ + 'If set, the order limit price is the oracle price + this offset', + 'precision: PRICE_PRECISION', + ]; + type: 'i32'; + }, + { + name: 'orderId'; + docs: [ + 'The id for the order. Each users has their own order id space', + ]; + type: 'u32'; + }, + { + name: 'marketIndex'; + docs: ['The perp/spot market index']; + type: 'u16'; + }, + { + name: 'status'; + docs: ['Whether the order is open or unused']; + type: { + defined: { + name: 'orderStatus'; + }; + }; + }, + { + name: 'orderType'; + docs: ['The type of order']; + type: { + defined: { + name: 'orderType'; + }; + }; + }, + { + name: 'marketType'; + docs: ['Whether market is spot or perp']; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'userOrderId'; + docs: [ + 'User generated order id. Can make it easier to place/cancel orders', + ]; + type: 'u8'; + }, + { + name: 'existingPositionDirection'; + docs: ['What the users position was when the order was placed']; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'direction'; + docs: [ + 'Whether the user is going long or short. LONG = bid, SHORT = ask', + ]; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'reduceOnly'; + docs: ['Whether the order is allowed to only reduce position size']; + type: 'bool'; + }, + { + name: 'postOnly'; + docs: ['Whether the order must be a maker']; + type: 'bool'; + }, + { + name: 'immediateOrCancel'; + docs: [ + 'Whether the order must be canceled the same slot it is placed', + ]; + type: 'bool'; + }, + { + name: 'triggerCondition'; + docs: [ + 'Whether the order is triggered above or below the trigger price. Only relevant for trigger orders', + ]; + type: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }, + { + name: 'auctionDuration'; + docs: ['How many slots the auction lasts']; + type: 'u8'; + }, + { + name: 'postedSlotTail'; + docs: [ + 'Last 8 bits of the slot the order was posted on-chain (not order slot for signed msg orders)', + ]; + type: 'u8'; + }, + { + name: 'bitFlags'; + docs: [ + 'Bitflags for further classification', + '0: is_signed_message', + ]; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 1]; + }; + }, + ]; + }; + }, + { + name: 'orderAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'place'; + }, + { + name: 'cancel'; + }, + { + name: 'fill'; + }, + { + name: 'trigger'; + }, + { + name: 'expire'; + }, + ]; + }; + }, + { + name: 'orderActionExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'insufficientFreeCollateral'; + }, + { + name: 'oraclePriceBreachedLimitPrice'; + }, + { + name: 'marketOrderFilledToLimitPrice'; + }, + { + name: 'orderExpired'; + }, + { + name: 'liquidation'; + }, + { + name: 'orderFilledWithAmm'; + }, + { + name: 'orderFilledWithAmmJit'; + }, + { + name: 'orderFilledWithMatch'; + }, + { + name: 'orderFilledWithMatchJit'; + }, + { + name: 'marketExpired'; + }, + { + name: 'riskingIncreasingOrder'; + }, + { + name: 'reduceOnlyOrderIncreasedPosition'; + }, + { + name: 'orderFillWithSerum'; + }, + { + name: 'noBorrowLiquidity'; + }, + { + name: 'orderFillWithPhoenix'; + }, + { + name: 'orderFilledWithAmmJitLpSplit'; + }, + { + name: 'orderFilledWithLpJit'; + }, + { + name: 'deriskLp'; + }, + { + name: 'orderFilledWithOpenbookV2'; + }, + { + name: 'transferPerpPosition'; + }, + ]; + }; + }, + { + name: 'orderActionRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'action'; + type: { + defined: { + name: 'orderAction'; + }; + }; + }, + { + name: 'actionExplanation'; + type: { + defined: { + name: 'orderActionExplanation'; + }; + }; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'filler'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'fillerReward'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'fillRecordId'; + type: { + option: 'u64'; + }; + }, + { + name: 'baseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'quoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'i64'; + }; + }, + { + name: 'referrerReward'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u32'; + }; + }, + { + name: 'quoteAssetAmountSurplus'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'i64'; + }; + }, + { + name: 'spotFulfillmentMethodFee'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'taker'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'takerOrderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'takerOrderDirection'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'takerOrderBaseAssetAmount'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerOrderCumulativeBaseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'takerOrderCumulativeQuoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'maker'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'makerOrderId'; + type: { + option: 'u32'; + }; + }, + { + name: 'makerOrderDirection'; + type: { + option: { + defined: { + name: 'positionDirection'; + }; + }; + }; + }, + { + name: 'makerOrderBaseAssetAmount'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerOrderCumulativeBaseAssetAmountFilled'; + docs: ['precision: BASE_PRECISION (perp) or MINT_PRECISION (spot)']; + type: { + option: 'u64'; + }; + }, + { + name: 'makerOrderCumulativeQuoteAssetAmountFilled'; + docs: ['precision: QUOTE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'oraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'bitFlags'; + docs: ['Bit flags:', '0: is_signed_message']; + type: 'u8'; + }, + { + name: 'takerExistingQuoteEntryAmount'; + docs: [ + 'precision: QUOTE_PRECISION', + 'Only Some if the taker reduced position', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'takerExistingBaseAssetAmount'; + docs: [ + 'precision: BASE_PRECISION', + 'Only Some if the taker flipped position direction', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'makerExistingQuoteEntryAmount'; + docs: [ + 'precision: QUOTE_PRECISION', + 'Only Some if the maker reduced position', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'makerExistingBaseAssetAmount'; + docs: [ + 'precision: BASE_PRECISION', + 'Only Some if the maker flipped position direction', + ]; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerPrice'; + docs: ['precision: PRICE_PRECISION']; + type: { + option: 'u64'; + }; + }, + { + name: 'builderIdx'; + docs: [ + "the idx of the builder in the taker's [`RevenueShareEscrow`] account", + ]; + type: { + option: 'u8'; + }; + }, + { + name: 'builderFee'; + docs: ['precision: QUOTE_PRECISION builder fee paid by the taker']; + type: { + option: 'u64'; + }; + }, + ]; + }; + }, + { + name: 'orderFillerRewardStructure'; + type: { + kind: 'struct'; + fields: [ + { + name: 'rewardNumerator'; + type: 'u32'; + }, + { + name: 'rewardDenominator'; + type: 'u32'; + }, + { + name: 'timeBasedRewardLowerBound'; + type: { + defined: { + name: 'u128'; + }; + }; + }, + ]; + }; + }, + { + name: 'orderParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'orderType'; + type: { + defined: { + name: 'orderType'; + }; + }; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'direction'; + type: { + defined: { + name: 'positionDirection'; + }; + }; + }, + { + name: 'userOrderId'; + type: 'u8'; + }, + { + name: 'baseAssetAmount'; + type: 'u64'; + }, + { + name: 'price'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'reduceOnly'; + type: 'bool'; + }, + { + name: 'postOnly'; + type: { + defined: { + name: 'postOnlyParam'; + }; + }; + }, + { + name: 'bitFlags'; + type: 'u8'; + }, + { + name: 'maxTs'; + type: { + option: 'i64'; + }; + }, + { + name: 'triggerPrice'; + type: { + option: 'u64'; + }; + }, + { + name: 'triggerCondition'; + type: { + defined: { + name: 'orderTriggerCondition'; + }; + }; + }, + { + name: 'oraclePriceOffset'; + type: { + option: 'i32'; + }; + }, + { + name: 'auctionDuration'; + type: { + option: 'u8'; + }; + }, + { + name: 'auctionStartPrice'; + type: { + option: 'i64'; + }; + }, + { + name: 'auctionEndPrice'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'orderRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'order'; + type: { + defined: { + name: 'order'; + }; + }; + }, + ]; + }; + }, + { + name: 'orderStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'init'; + }, + { + name: 'open'; + }, + { + name: 'filled'; + }, + { + name: 'canceled'; + }, + ]; + }; + }, + { + name: 'orderTriggerCondition'; + type: { + kind: 'enum'; + variants: [ + { + name: 'above'; + }, + { + name: 'below'; + }, + { + name: 'triggeredAbove'; + }, + { + name: 'triggeredBelow'; + }, + ]; + }; + }, + { + name: 'orderType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'market'; + }, + { + name: 'limit'; + }, + { + name: 'triggerMarket'; + }, + { + name: 'triggerLimit'; + }, + { + name: 'oracle'; + }, + ]; + }; + }, + { + name: 'overrideAmmCacheParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'quoteOwedFromLpPool'; + type: { + option: 'i64'; + }; + }, + { + name: 'lastSettleSlot'; + type: { + option: 'u64'; + }; + }, + { + name: 'lastFeePoolTokenAmount'; + type: { + option: 'u128'; + }; + }, + { + name: 'lastNetPnlPoolTokenAmount'; + type: { + option: 'i128'; + }; + }, + { + name: 'ammPositionScalar'; + type: { + option: 'u8'; + }; + }, + { + name: 'ammInventoryLimit'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'perpBankruptcyRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'pnl'; + type: 'i128'; + }, + { + name: 'ifPayment'; + type: 'u128'; + }, + { + name: 'clawbackUser'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'clawbackUserPayment'; + type: { + option: 'u128'; + }; + }, + { + name: 'cumulativeFundingRateDelta'; + type: 'i128'; + }, + ]; + }; + }, + { + name: 'perpMarket'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: [ + "The perp market's address. It is a pda of the market index", + ]; + type: 'pubkey'; + }, + { + name: 'amm'; + docs: ['The automated market maker']; + type: { + defined: { + name: 'amm'; + }; + }; + }, + { + name: 'pnlPool'; + docs: [ + "The market's pnl pool. When users settle negative pnl, the balance increases.", + 'When users settle positive pnl, the balance decreases. Can not go negative.', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'name'; + docs: ['Encoded display name for the perp market e.g. SOL-PERP']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'insuranceClaim'; + docs: ["The perp market's claim on the insurance fund"]; + type: { + defined: { + name: 'insuranceClaim'; + }; + }; + }, + { + name: 'unrealizedPnlMaxImbalance'; + docs: [ + 'The max pnl imbalance before positive pnl asset weight is discounted', + "pnl imbalance is the difference between long and short pnl. When it's greater than 0,", + 'the amm has negative pnl and the initial asset weight for positive pnl is discounted', + 'precision = QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'expiryTs'; + docs: [ + 'The ts when the market will be expired. Only set if market is in reduce only mode', + ]; + type: 'i64'; + }, + { + name: 'expiryPrice'; + docs: [ + 'The price at which positions will be settled. Only set if market is expired', + 'precision = PRICE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'nextFillRecordId'; + docs: [ + 'Every trade has a fill record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'nextFundingRateRecordId'; + docs: [ + 'Every funding rate update has a record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'nextCurveRecordId'; + docs: [ + 'Every amm k updated has a record id. This is the next id to be used', + ]; + type: 'u64'; + }, + { + name: 'imfFactor'; + docs: [ + 'The initial margin fraction factor. Used to increase margin ratio for large positions', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlImfFactor'; + docs: [ + 'The imf factor for unrealized pnl. Used to discount asset weight for large positive pnl', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: [ + 'The fee the liquidator is paid for taking over perp position', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + docs: [ + 'The fee the insurance fund receives from liquidation', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'marginRatioInitial'; + docs: [ + 'The margin ratio which determines how much collateral is required to open a position', + 'e.g. margin ratio of .1 means a user must have $100 of total collateral to open a $1000 position', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'marginRatioMaintenance'; + docs: [ + 'The margin ratio which determines when a user will be liquidated', + 'e.g. margin ratio of .05 means a user must have $50 of total collateral to maintain a $1000 position', + 'else they will be liquidated', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlInitialAssetWeight'; + docs: [ + 'The initial asset weight for positive pnl. Negative pnl always has an asset weight of 1', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'unrealizedPnlMaintenanceAssetWeight'; + docs: [ + 'The maintenance asset weight for positive pnl. Negative pnl always has an asset weight of 1', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'numberOfUsersWithBase'; + docs: ['number of users in a position (base)']; + type: 'u32'; + }, + { + name: 'numberOfUsers'; + docs: ['number of users in a position (pnl) or pnl (quote)']; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'status'; + docs: [ + 'Whether a market is active, reduce only, expired, etc', + 'Affects whether users can open/close positions', + ]; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + { + name: 'contractType'; + docs: ['Currently only Perpetual markets are supported']; + type: { + defined: { + name: 'contractType'; + }; + }; + }, + { + name: 'contractTier'; + docs: [ + 'The contract tier determines how much insurance a market can receive, with more speculative markets receiving less insurance', + 'It also influences the order perp markets can be liquidated, with less speculative markets being liquidated first', + ]; + type: { + defined: { + name: 'contractTier'; + }; + }; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'quoteSpotMarketIndex'; + docs: ['The spot market that pnl is settled in']; + type: 'u16'; + }, + { + name: 'feeAdjustment'; + docs: [ + 'Between -100 and 100, represents what % to increase/decrease the fee by', + 'E.g. if this is -50 and the fee is 5bps, the new fee will be 2.5bps', + 'if this is 50 and the fee is 5bps, the new fee will be 7.5bps', + ]; + type: 'i16'; + }, + { + name: 'fuelBoostPosition'; + docs: ['fuel multiplier for perp funding', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostTaker'; + docs: ['fuel multiplier for perp taker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostMaker'; + docs: ['fuel multiplier for perp maker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'highLeverageMarginRatioInitial'; + type: 'u16'; + }, + { + name: 'highLeverageMarginRatioMaintenance'; + type: 'u16'; + }, + { + name: 'protectedMakerLimitPriceDivisor'; + type: 'u8'; + }, + { + name: 'protectedMakerDynamicDivisor'; + type: 'u8'; + }, + { + name: 'lpFeeTransferScalar'; + type: 'u8'; + }, + { + name: 'lpStatus'; + type: 'u8'; + }, + { + name: 'lpPausedOperations'; + type: 'u8'; + }, + { + name: 'lpExchangeFeeExcluscionScalar'; + type: 'u8'; + }, + { + name: 'lastFillPrice'; + type: 'u64'; + }, + { + name: 'lpPoolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 23]; + }; + }, + ]; + }; + }, + { + name: 'perpPosition'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'lastCumulativeFundingRate'; + docs: [ + "The perp market's last cumulative funding rate. Used to calculate the funding payment owed to user", + 'precision: FUNDING_RATE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'baseAssetAmount'; + docs: [ + 'the size of the users perp position', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteAssetAmount'; + docs: [ + 'Used to calculate the users pnl. Upon entry, is equal to base_asset_amount * avg entry price - fees', + 'Updated when the user open/closes position or settles pnl. Includes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteBreakEvenAmount'; + docs: [ + 'The amount of quote the user would need to exit their position at to break even', + 'Updated when the user open/closes position or settles pnl. Includes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'quoteEntryAmount'; + docs: [ + 'The amount quote the user entered the position with. Equal to base asset amount * avg entry price', + 'Updated when the user open/closes position. Excludes fees/funding', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'openBids'; + docs: [ + 'The amount of non reduce only trigger orders the user has open', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'openAsks'; + docs: [ + 'The amount of non reduce only trigger orders the user has open', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'settledPnl'; + docs: [ + 'The amount of pnl settled in this market since opening the position', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lpShares'; + docs: [ + 'The number of lp (liquidity provider) shares the user has in this perp market', + 'LP shares allow users to provide liquidity via the AMM', + 'precision: BASE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastBaseAssetAmountPerLp'; + docs: [ + 'The last base asset amount per lp the amm had', + 'Used to settle the users lp position', + 'precision: BASE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'lastQuoteAssetAmountPerLp'; + docs: [ + 'The last quote asset amount per lp the amm had', + 'Used to settle the users lp position', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'padding'; + type: { + array: ['u8', 2]; + }; + }, + { + name: 'maxMarginRatio'; + type: 'u16'; + }, + { + name: 'marketIndex'; + docs: ['The market index for the perp market']; + type: 'u16'; + }, + { + name: 'openOrders'; + docs: ['The number of open orders']; + type: 'u8'; + }, + { + name: 'perLpBase'; + type: 'i8'; + }, + ]; + }; + }, + { + name: 'phoenixV1FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'phoenixProgramId'; + type: 'pubkey'; + }, + { + name: 'phoenixLogAuthority'; + type: 'pubkey'; + }, + { + name: 'phoenixMarket'; + type: 'pubkey'; + }, + { + name: 'phoenixBaseVault'; + type: 'pubkey'; + }, + { + name: 'phoenixQuoteVault'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'poolBalance'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + "To get the pool's token amount, you must multiply the scaled balance by the market's cumulative", + 'deposit interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'marketIndex'; + docs: ['The spot market the pool is for']; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 6]; + }; + }, + ]; + }; + }, + { + name: 'positionDirection'; + type: { + kind: 'enum'; + variants: [ + { + name: 'long'; + }, + { + name: 'short'; + }, + ]; + }; + }, + { + name: 'postOnlyParam'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'mustPostOnly'; + }, + { + name: 'tryPostOnly'; + }, + { + name: 'slide'; + }, + ]; + }; + }, + { + name: 'prelaunchOracle'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'price'; + type: 'i64'; + }, + { + name: 'maxPrice'; + type: 'i64'; + }, + { + name: 'confidence'; + type: 'u64'; + }, + { + name: 'lastUpdateSlot'; + type: 'u64'; + }, + { + name: 'ammLastUpdateSlot'; + type: 'u64'; + }, + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'padding'; + type: { + array: ['u8', 70]; + }; + }, + ]; + }; + }, + { + name: 'prelaunchOracleParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'perpMarketIndex'; + type: 'u16'; + }, + { + name: 'price'; + type: { + option: 'i64'; + }; + }, + { + name: 'maxPrice'; + type: { + option: 'i64'; + }; + }, + ]; + }; + }, + { + name: 'priceDivergenceGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'markOraclePercentDivergence'; + type: 'u64'; + }, + { + name: 'oracleTwap5minPercentDivergence'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'protectedMakerModeConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'maxUsers'; + type: 'u32'; + }, + { + name: 'currentUsers'; + type: 'u32'; + }, + { + name: 'reduceOnly'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 31]; + }; + }, + ]; + }; + }, + { + name: 'pythLazerOracle'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'price'; + type: 'i64'; + }, + { + name: 'publishTime'; + type: 'u64'; + }, + { + name: 'postedSlot'; + type: 'u64'; + }, + { + name: 'exponent'; + type: 'i32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'conf'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'referrerName'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + type: 'pubkey'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'userStats'; + type: 'pubkey'; + }, + { + name: 'name'; + type: { + array: ['u8', 32]; + }; + }, + ]; + }; + }, + { + name: 'revenueShare'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'rust'; + packed: true; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['the owner of this account, a builder or referrer']; + type: 'pubkey'; + }, + { + name: 'totalReferrerRewards'; + type: 'u64'; + }, + { + name: 'totalBuilderRewards'; + type: 'u64'; + }, + { + name: 'padding'; + type: { + array: ['u8', 18]; + }; + }, + ]; + }; + }, + { + name: 'revenueShareEscrow'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['the owner of this account, a user']; + type: 'pubkey'; + }, + { + name: 'referrer'; + type: 'pubkey'; + }, + { + name: 'referrerBoostExpireTs'; + type: 'u32'; + }, + { + name: 'referrerRewardOffset'; + type: 'i8'; + }, + { + name: 'refereeFeeNumeratorOffset'; + type: 'i8'; + }, + { + name: 'referrerBoostNumerator'; + type: 'i8'; + }, + { + name: 'reservedFixed'; + type: { + array: ['u8', 17]; + }; + }, + { + name: 'padding0'; + type: 'u32'; + }, + { + name: 'orders'; + type: { + vec: { + defined: { + name: 'revenueShareOrder'; + }; + }; + }; + }, + { + name: 'padding1'; + type: 'u32'; + }, + { + name: 'approvedBuilders'; + type: { + vec: { + defined: { + name: 'builderInfo'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'revenueShareOrder'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'feesAccrued'; + docs: [ + 'fees accrued so far for this order slot. This is not exclusively fees from this order_id', + 'and may include fees from other orders in the same market. This may be swept to the', + "builder's SpotPosition during settle_pnl.", + ]; + type: 'u64'; + }, + { + name: 'orderId'; + docs: [ + "the order_id of the current active order in this slot. It's only relevant while bit_flag = Open", + ]; + type: 'u32'; + }, + { + name: 'feeTenthBps'; + docs: [ + 'the builder fee on this order, in tenths of a bps, e.g. 100 = 0.01%', + ]; + type: 'u16'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'subAccountId'; + docs: [ + "the subaccount_id of the user who created this order. It's only relevant while bit_flag = Open", + ]; + type: 'u16'; + }, + { + name: 'builderIdx'; + docs: [ + "the index of the RevenueShareEscrow.approved_builders list, that this order's fee will settle to. Ignored", + 'if bit_flag = Referral.', + ]; + type: 'u8'; + }, + { + name: 'bitFlags'; + docs: [ + 'bitflags that describe the state of the order.', + '[`RevenueShareOrderBitFlag::Init`]: this order slot is available for use.', + "[`RevenueShareOrderBitFlag::Open`]: this order slot is occupied, `order_id` is the `sub_account_id`'s active order.", + '[`RevenueShareOrderBitFlag::Completed`]: this order has been filled or canceled, and is waiting to be settled into.', + "the builder's account order_id and sub_account_id are no longer relevant, it may be merged with other orders.", + '[`RevenueShareOrderBitFlag::Referral`]: this order stores referral rewards waiting to be settled for this market.', + 'If it is set, no other bitflag should be set.', + ]; + type: 'u8'; + }, + { + name: 'userOrderIndex'; + docs: [ + "the index into the User's orders list when this RevenueShareOrder was created, make sure to verify that order_id matches.", + ]; + type: 'u8'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 10]; + }; + }, + ]; + }; + }, + { + name: 'revenueShareSettleRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'builder'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'referrer'; + type: { + option: 'pubkey'; + }; + }, + { + name: 'feeSettled'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'marketType'; + type: { + defined: { + name: 'marketType'; + }; + }; + }, + { + name: 'builderSubAccountId'; + type: 'u16'; + }, + { + name: 'builderTotalReferrerRewards'; + type: 'u64'; + }, + { + name: 'builderTotalBuilderRewards'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'serumV3FulfillmentConfig'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + type: 'pubkey'; + }, + { + name: 'serumProgramId'; + type: 'pubkey'; + }, + { + name: 'serumMarket'; + type: 'pubkey'; + }, + { + name: 'serumRequestQueue'; + type: 'pubkey'; + }, + { + name: 'serumEventQueue'; + type: 'pubkey'; + }, + { + name: 'serumBids'; + type: 'pubkey'; + }, + { + name: 'serumAsks'; + type: 'pubkey'; + }, + { + name: 'serumBaseVault'; + type: 'pubkey'; + }, + { + name: 'serumQuoteVault'; + type: 'pubkey'; + }, + { + name: 'serumOpenOrders'; + type: 'pubkey'; + }, + { + name: 'serumSignerNonce'; + type: 'u64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'fulfillmentType'; + type: { + defined: { + name: 'spotFulfillmentType'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'spotFulfillmentConfigStatus'; + }; + }; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'settlePnlExplanation'; + type: { + kind: 'enum'; + variants: [ + { + name: 'none'; + }, + { + name: 'expiredPosition'; + }, + ]; + }; + }, + { + name: 'settlePnlMode'; + type: { + kind: 'enum'; + variants: [ + { + name: 'mustSettle'; + }, + { + name: 'trySettle'; + }, + ]; + }; + }, + { + name: 'settlePnlRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'pnl'; + type: 'i128'; + }, + { + name: 'baseAssetAmount'; + type: 'i64'; + }, + { + name: 'quoteAssetAmountAfter'; + type: 'i64'; + }, + { + name: 'quoteEntryAmount'; + type: 'i64'; + }, + { + name: 'settlePrice'; + type: 'i64'; + }, + { + name: 'explanation'; + type: { + defined: { + name: 'settlePnlExplanation'; + }; + }; + }, + ]; + }; + }, + { + name: 'signedMsgOrderId'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'uuid'; + type: { + array: ['u8', 8]; + }; + }, + { + name: 'maxSlot'; + type: 'u64'; + }, + { + name: 'orderId'; + type: 'u32'; + }, + { + name: 'padding'; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'signedMsgOrderRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'hash'; + type: 'string'; + }, + { + name: 'matchingOrderParams'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'userOrderId'; + type: 'u32'; + }, + { + name: 'signedMsgOrderMaxSlot'; + type: 'u64'; + }, + { + name: 'signedMsgOrderUuid'; + type: { + array: ['u8', 8]; + }; + }, + { + name: 'ts'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'signedMsgUserOrders'; + docs: [ + '* This struct is a duplicate of SignedMsgUserOrdersZeroCopy\n * It is used to give anchor an struct to generate the idl for clients\n * The struct SignedMsgUserOrdersZeroCopy is used to load the data in efficiently', + ]; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authorityPubkey'; + type: 'pubkey'; + }, + { + name: 'padding'; + type: 'u32'; + }, + { + name: 'signedMsgOrderData'; + type: { + vec: { + defined: { + name: 'signedMsgOrderId'; + }; + }; + }; + }, + ]; + }; + }, + { + name: 'signedMsgWsDelegates'; + docs: [ + '* Used to store authenticated delegates for swift-like ws connections', + ]; + type: { + kind: 'struct'; + fields: [ + { + name: 'delegates'; + type: { + vec: 'pubkey'; + }; + }, + ]; + }; + }, + { + name: 'spotBalanceType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'deposit'; + }, + { + name: 'borrow'; + }, + ]; + }; + }, + { + name: 'spotBankruptcyRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'borrowAmount'; + type: 'u128'; + }, + { + name: 'ifPayment'; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestDelta'; + type: 'u128'; + }, + ]; + }; + }, + { + name: 'spotFulfillmentConfigStatus'; + type: { + kind: 'enum'; + variants: [ + { + name: 'enabled'; + }, + { + name: 'disabled'; + }, + ]; + }; + }, + { + name: 'spotFulfillmentType'; + type: { + kind: 'enum'; + variants: [ + { + name: 'serumV3'; + }, + { + name: 'match'; + }, + { + name: 'phoenixV1'; + }, + { + name: 'openbookV2'; + }, + ]; + }; + }, + { + name: 'spotInterestRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'depositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'borrowBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeBorrowInterest'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'optimalUtilization'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + docs: ['precision: PERCENTAGE_PRECISION']; + type: 'u32'; + }, + ]; + }; + }, + { + name: 'spotMarket'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'pubkey'; + docs: [ + 'The address of the spot market. It is a pda of the market index', + ]; + type: 'pubkey'; + }, + { + name: 'oracle'; + docs: ['The oracle used to price the markets deposits/borrows']; + type: 'pubkey'; + }, + { + name: 'mint'; + docs: ['The token mint of the market']; + type: 'pubkey'; + }, + { + name: 'vault'; + docs: [ + "The vault used to store the market's deposits", + 'The amount in the vault should be equal to or greater than deposits - borrows', + ]; + type: 'pubkey'; + }, + { + name: 'name'; + docs: ['The encoded display name for the market e.g. SOL']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'historicalOracleData'; + type: { + defined: { + name: 'historicalOracleData'; + }; + }; + }, + { + name: 'historicalIndexData'; + type: { + defined: { + name: 'historicalIndexData'; + }; + }; + }, + { + name: 'revenuePool'; + docs: [ + 'Revenue the protocol has collected in this markets token', + 'e.g. for SOL-PERP, funds can be settled in usdc and will flow into the USDC revenue pool', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'spotFeePool'; + docs: [ + 'The fees collected from swaps between this market and the quote market', + 'Is settled to the quote markets revenue pool', + ]; + type: { + defined: { + name: 'poolBalance'; + }; + }; + }, + { + name: 'insuranceFund'; + docs: [ + 'Details on the insurance fund covering bankruptcies in this markets token', + 'Covers bankruptcies for borrows with this markets token and perps settling in this markets token', + ]; + type: { + defined: { + name: 'insuranceFund'; + }; + }; + }, + { + name: 'totalSpotFee'; + docs: [ + 'The total spot fees collected for this market', + 'precision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'depositBalance'; + docs: [ + 'The sum of the scaled balances for deposits across users and pool balances', + 'To convert to the deposit token amount, multiply by the cumulative deposit interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'borrowBalance'; + docs: [ + 'The sum of the scaled balances for borrows across users and pool balances', + 'To convert to the borrow token amount, multiply by the cumulative borrow interest', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeDepositInterest'; + docs: [ + 'The cumulative interest earned by depositors', + 'Used to calculate the deposit token amount from the deposit balance', + 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'cumulativeBorrowInterest'; + docs: [ + 'The cumulative interest earned by borrowers', + 'Used to calculate the borrow token amount from the borrow balance', + 'precision: SPOT_CUMULATIVE_INTEREST_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalSocialLoss'; + docs: [ + "The total socialized loss from borrows, in the mint's token", + 'precision: token mint precision', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'totalQuoteSocialLoss'; + docs: [ + "The total socialized loss from borrows, in the quote market's token", + 'preicision: QUOTE_PRECISION', + ]; + type: { + defined: { + name: 'u128'; + }; + }; + }, + { + name: 'withdrawGuardThreshold'; + docs: [ + 'no withdraw limits/guards when deposits below this threshold', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'maxTokenDeposits'; + docs: [ + 'The max amount of token deposits in this market', + '0 if there is no limit', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'depositTokenTwap'; + docs: [ + '24hr average of deposit token amount', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'borrowTokenTwap'; + docs: [ + '24hr average of borrow token amount', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'utilizationTwap'; + docs: [ + '24hr average of utilization', + 'which is borrow amount over token amount', + 'precision: SPOT_UTILIZATION_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastInterestTs'; + docs: [ + 'Last time the cumulative deposit and borrow interest was updated', + ]; + type: 'u64'; + }, + { + name: 'lastTwapTs'; + docs: [ + 'Last time the deposit/borrow/utilization averages were updated', + ]; + type: 'u64'; + }, + { + name: 'expiryTs'; + docs: [ + 'The time the market is set to expire. Only set if market is in reduce only mode', + ]; + type: 'i64'; + }, + { + name: 'orderStepSize'; + docs: [ + 'Spot orders must be a multiple of the step size', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'orderTickSize'; + docs: [ + 'Spot orders must be a multiple of the tick size', + 'precision: PRICE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minOrderSize'; + docs: ['The minimum order size', 'precision: token mint precision']; + type: 'u64'; + }, + { + name: 'maxPositionSize'; + docs: [ + 'The maximum spot position size', + 'if the limit is 0, there is no limit', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'nextFillRecordId'; + docs: [ + 'Every spot trade has a fill record id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'nextDepositRecordId'; + docs: [ + 'Every deposit has a deposit record id. This is the next id to use', + ]; + type: 'u64'; + }, + { + name: 'initialAssetWeight'; + docs: [ + 'The initial asset weight used to calculate a deposits contribution to a users initial total collateral', + 'e.g. if the asset weight is .8, $100 of deposits contributes $80 to the users initial total collateral', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maintenanceAssetWeight'; + docs: [ + 'The maintenance asset weight used to calculate a deposits contribution to a users maintenance total collateral', + 'e.g. if the asset weight is .9, $100 of deposits contributes $90 to the users maintenance total collateral', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'initialLiabilityWeight'; + docs: [ + 'The initial liability weight used to calculate a borrows contribution to a users initial margin requirement', + 'e.g. if the liability weight is .9, $100 of borrows contributes $90 to the users initial margin requirement', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maintenanceLiabilityWeight'; + docs: [ + 'The maintenance liability weight used to calculate a borrows contribution to a users maintenance margin requirement', + 'e.g. if the liability weight is .8, $100 of borrows contributes $80 to the users maintenance margin requirement', + 'precision: SPOT_WEIGHT_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'imfFactor'; + docs: [ + 'The initial margin fraction factor. Used to increase liability weight/decrease asset weight for large positions', + 'precision: MARGIN_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'liquidatorFee'; + docs: [ + 'The fee the liquidator is paid for taking over borrow/deposit', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'ifLiquidationFee'; + docs: [ + 'The fee the insurance fund receives from liquidation', + 'precision: LIQUIDATOR_FEE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'optimalUtilization'; + docs: [ + 'The optimal utilization rate for this market.', + 'Used to determine the markets borrow rate', + 'precision: SPOT_UTILIZATION_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'optimalBorrowRate'; + docs: [ + 'The borrow rate for this market when the market has optimal utilization', + 'precision: SPOT_RATE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'maxBorrowRate'; + docs: [ + 'The borrow rate for this market when the market has 1000 utilization', + 'precision: SPOT_RATE_PRECISION', + ]; + type: 'u32'; + }, + { + name: 'decimals'; + docs: [ + "The market's token mint's decimals. To from decimals to a precision, 10^decimals", + ]; + type: 'u32'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'ordersEnabled'; + docs: ['Whether or not spot trading is enabled']; + type: 'bool'; + }, + { + name: 'oracleSource'; + type: { + defined: { + name: 'oracleSource'; + }; + }; + }, + { + name: 'status'; + type: { + defined: { + name: 'marketStatus'; + }; + }; + }, + { + name: 'assetTier'; + docs: [ + 'The asset tier affects how a deposit can be used as collateral and the priority for a borrow being liquidated', + ]; + type: { + defined: { + name: 'assetTier'; + }; + }; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'ifPausedOperations'; + type: 'u8'; + }, + { + name: 'feeAdjustment'; + type: 'i16'; + }, + { + name: 'maxTokenBorrowsFraction'; + docs: [ + 'What fraction of max_token_deposits', + 'disabled when 0, 1 => 1/10000 => .01% of max_token_deposits', + 'precision: X/10000', + ]; + type: 'u16'; + }, + { + name: 'flashLoanAmount'; + docs: [ + 'For swaps, the amount of token loaned out in the begin_swap ix', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'flashLoanInitialTokenAmount'; + docs: [ + 'For swaps, the amount in the users token account in the begin_swap ix', + 'Used to calculate how much of the token left the system in end_swap ix', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'totalSwapFee'; + docs: [ + 'The total fees received from swaps', + 'precision: token mint precision', + ]; + type: 'u64'; + }, + { + name: 'scaleInitialAssetWeightStart'; + docs: [ + 'When to begin scaling down the initial asset weight', + 'disabled when 0', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'minBorrowRate'; + docs: [ + 'The min borrow rate for this market when the market regardless of utilization', + '1 => 1/200 => .5%', + 'precision: X/200', + ]; + type: 'u8'; + }, + { + name: 'fuelBoostDeposits'; + docs: ['fuel multiplier for spot deposits', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostBorrows'; + docs: ['fuel multiplier for spot borrows', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostTaker'; + docs: ['fuel multiplier for spot taker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostMaker'; + docs: ['fuel multiplier for spot maker', 'precision: 10']; + type: 'u8'; + }, + { + name: 'fuelBoostInsurance'; + docs: ['fuel multiplier for spot insurance stake', 'precision: 10']; + type: 'u8'; + }, + { + name: 'tokenProgramFlag'; + type: 'u8'; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 40]; + }; + }, + ]; + }; + }, + { + name: 'spotMarketVaultDepositRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'depositBalance'; + docs: ['precision: SPOT_BALANCE_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestBefore'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'cumulativeDepositInterestAfter'; + docs: ['precision: SPOT_CUMULATIVE_INTEREST_PRECISION']; + type: 'u128'; + }, + { + name: 'depositTokenAmountBefore'; + type: 'u64'; + }, + { + name: 'amount'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'spotPosition'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'scaledBalance'; + docs: [ + 'The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow', + 'interest of corresponding market.', + 'precision: SPOT_BALANCE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'openBids'; + docs: [ + 'How many spot non reduce only trigger orders the user has open', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'openAsks'; + docs: [ + 'How many spot non reduce only trigger orders the user has open', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'cumulativeDeposits'; + docs: [ + 'The cumulative deposits/borrows a user has made into a market', + 'precision: token mint precision', + ]; + type: 'i64'; + }, + { + name: 'marketIndex'; + docs: ['The market index of the corresponding spot market']; + type: 'u16'; + }, + { + name: 'balanceType'; + docs: ['Whether the position is deposit or borrow']; + type: { + defined: { + name: 'spotBalanceType'; + }; + }; + }, + { + name: 'openOrders'; + docs: ['Number of open orders']; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + ]; + }; + }, + { + name: 'stakeAction'; + type: { + kind: 'enum'; + variants: [ + { + name: 'stake'; + }, + { + name: 'unstakeRequest'; + }, + { + name: 'unstakeCancelRequest'; + }, + { + name: 'unstake'; + }, + { + name: 'unstakeTransfer'; + }, + { + name: 'stakeTransfer'; + }, + { + name: 'adminDeposit'; + }, + ]; + }; + }, + { + name: 'state'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'admin'; + type: 'pubkey'; + }, + { + name: 'whitelistMint'; + type: 'pubkey'; + }, + { + name: 'discountMint'; + type: 'pubkey'; + }, + { + name: 'signer'; + type: 'pubkey'; + }, + { + name: 'srmVault'; + type: 'pubkey'; + }, + { + name: 'perpFeeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + { + name: 'spotFeeStructure'; + type: { + defined: { + name: 'feeStructure'; + }; + }; + }, + { + name: 'oracleGuardRails'; + type: { + defined: { + name: 'oracleGuardRails'; + }; + }; + }, + { + name: 'numberOfAuthorities'; + type: 'u64'; + }, + { + name: 'numberOfSubAccounts'; + type: 'u64'; + }, + { + name: 'lpCooldownTime'; + type: 'u64'; + }, + { + name: 'liquidationMarginBufferRatio'; + type: 'u32'; + }, + { + name: 'settlementDuration'; + type: 'u16'; + }, + { + name: 'numberOfMarkets'; + type: 'u16'; + }, + { + name: 'numberOfSpotMarkets'; + type: 'u16'; + }, + { + name: 'signerNonce'; + type: 'u8'; + }, + { + name: 'minPerpAuctionDuration'; + type: 'u8'; + }, + { + name: 'defaultMarketOrderTimeInForce'; + type: 'u8'; + }, + { + name: 'defaultSpotAuctionDuration'; + type: 'u8'; + }, + { + name: 'exchangeStatus'; + type: 'u8'; + }, + { + name: 'liquidationDuration'; + type: 'u8'; + }, + { + name: 'initialPctToLiquidate'; + type: 'u16'; + }, + { + name: 'maxNumberOfSubAccounts'; + type: 'u16'; + }, + { + name: 'maxInitializeUserFee'; + type: 'u16'; + }, + { + name: 'featureBitFlags'; + type: 'u8'; + }, + { + name: 'lpPoolFeatureBitFlags'; + type: 'u8'; + }, + { + name: 'padding'; + type: { + array: ['u8', 8]; + }; + }, + ]; + }; + }, + { + name: 'swapRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'user'; + type: 'pubkey'; + }, + { + name: 'amountOut'; + docs: ['precision: out market mint precision']; + type: 'u64'; + }, + { + name: 'amountIn'; + docs: ['precision: in market mint precision']; + type: 'u64'; + }, + { + name: 'outMarketIndex'; + type: 'u16'; + }, + { + name: 'inMarketIndex'; + type: 'u16'; + }, + { + name: 'outOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'inOraclePrice'; + docs: ['precision: PRICE_PRECISION']; + type: 'i64'; + }, + { + name: 'fee'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'swapReduceOnly'; + type: { + kind: 'enum'; + variants: [ + { + name: 'in'; + }, + { + name: 'out'; + }, + ]; + }; + }, + { + name: 'targetsDatum'; + serialization: 'bytemuck'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'costToTradeBps'; + type: 'i32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 4]; + }; + }, + { + name: 'targetBase'; + type: 'i64'; + }, + { + name: 'lastOracleSlot'; + type: 'u64'; + }, + { + name: 'lastPositionSlot'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'transferProtocolIfSharesToRevenuePoolRecord'; + type: { + kind: 'struct'; + fields: [ + { + name: 'ts'; + type: 'i64'; + }, + { + name: 'marketIndex'; + type: 'u16'; + }, + { + name: 'amount'; + type: 'u64'; + }, + { + name: 'shares'; + type: 'u128'; + }, + { + name: 'ifVaultAmountBefore'; + type: 'u64'; + }, + { + name: 'protocolSharesBefore'; + type: 'u128'; + }, + { + name: 'transferAmount'; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'updatePerpMarketSummaryStatsParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'quoteAssetAmountWithUnsettledLp'; + type: { + option: 'i64'; + }; + }, + { + name: 'netUnsettledFundingPnl'; + type: { + option: 'i64'; + }; + }, + { + name: 'updateAmmSummaryStats'; + type: { + option: 'bool'; + }; + }, + { + name: 'excludeTotalLiqFee'; + type: { + option: 'bool'; + }; + }, + ]; + }; + }, + { + name: 'user'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The owner/authority of the account']; + type: 'pubkey'; + }, + { + name: 'delegate'; + docs: [ + "An addresses that can control the account on the authority's behalf. Has limited power, cant withdraw", + ]; + type: 'pubkey'; + }, + { + name: 'name'; + docs: ['Encoded display name e.g. "toly"']; + type: { + array: ['u8', 32]; + }; + }, + { + name: 'spotPositions'; + docs: ["The user's spot positions"]; + type: { + array: [ + { + defined: { + name: 'spotPosition'; + }; + }, + 8, + ]; + }; + }, + { + name: 'perpPositions'; + docs: ["The user's perp positions"]; + type: { + array: [ + { + defined: { + name: 'perpPosition'; + }; + }, + 8, + ]; + }; + }, + { + name: 'orders'; + docs: ["The user's orders"]; + type: { + array: [ + { + defined: { + name: 'order'; + }; + }, + 32, + ]; + }; + }, + { + name: 'lastAddPerpLpSharesTs'; + docs: ['The last time the user added perp lp positions']; + type: 'i64'; + }, + { + name: 'totalDeposits'; + docs: [ + 'The total values of deposits the user has made', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalWithdraws'; + docs: [ + 'The total values of withdrawals the user has made', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalSocialLoss'; + docs: [ + 'The total socialized loss the users has incurred upon the protocol', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'settledPerpPnl'; + docs: [ + 'Fees (taker fees, maker rebate, referrer reward, filler reward) and pnl for perps', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'cumulativeSpotFees'; + docs: [ + 'Fees (taker fees, maker rebate, filler reward) for spot', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'cumulativePerpFunding'; + docs: [ + 'Cumulative funding paid/received for perps', + 'precision: QUOTE_PRECISION', + ]; + type: 'i64'; + }, + { + name: 'liquidationMarginFreed'; + docs: [ + 'The amount of margin freed during liquidation. Used to force the liquidation to occur over a period of time', + 'Defaults to zero when not being liquidated', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastActiveSlot'; + docs: [ + 'The last slot a user was active. Used to determine if a user is idle', + ]; + type: 'u64'; + }, + { + name: 'nextOrderId'; + docs: [ + 'Every user order has an order id. This is the next order id to be used', + ]; + type: 'u32'; + }, + { + name: 'maxMarginRatio'; + docs: ['Custom max initial margin ratio for the user']; + type: 'u32'; + }, + { + name: 'nextLiquidationId'; + docs: ['The next liquidation id to be used for user']; + type: 'u16'; + }, + { + name: 'subAccountId'; + docs: ['The sub account id for this user']; + type: 'u16'; + }, + { + name: 'status'; + docs: ['Whether the user is active, being liquidated or bankrupt']; + type: 'u8'; + }, + { + name: 'isMarginTradingEnabled'; + docs: ['Whether the user has enabled margin trading']; + type: 'bool'; + }, + { + name: 'idle'; + docs: [ + "User is idle if they haven't interacted with the protocol in 1 week and they have no orders, perp positions or borrows", + 'Off-chain keeper bots can ignore users that are idle', + ]; + type: 'bool'; + }, + { + name: 'openOrders'; + docs: ['number of open orders']; + type: 'u8'; + }, + { + name: 'hasOpenOrder'; + docs: ['Whether or not user has open order']; + type: 'bool'; + }, + { + name: 'openAuctions'; + docs: ['number of open orders with auction']; + type: 'u8'; + }, + { + name: 'hasOpenAuction'; + docs: ['Whether or not user has open order with auction']; + type: 'bool'; + }, + { + name: 'marginMode'; + type: { + defined: { + name: 'marginMode'; + }; + }; + }, + { + name: 'poolId'; + type: 'u8'; + }, + { + name: 'padding1'; + type: { + array: ['u8', 3]; + }; + }, + { + name: 'lastFuelBonusUpdateTs'; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 12]; + }; + }, + ]; + }; + }, + { + name: 'userFees'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'totalFeePaid'; + docs: ['Total taker fee paid', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalFeeRebate'; + docs: ['Total maker fee rebate', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'totalTokenDiscount'; + docs: [ + 'Total discount from holding token', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalRefereeDiscount'; + docs: [ + 'Total discount from being referred', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'totalReferrerReward'; + docs: ['Total reward to referrer', 'precision: QUOTE_PRECISION']; + type: 'u64'; + }, + { + name: 'currentEpochReferrerReward'; + docs: [ + 'Total reward to referrer this epoch', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + ]; + }; + }, + { + name: 'userStats'; + serialization: 'bytemuckunsafe'; + repr: { + kind: 'c'; + }; + type: { + kind: 'struct'; + fields: [ + { + name: 'authority'; + docs: ['The authority for all of a users sub accounts']; + type: 'pubkey'; + }, + { + name: 'referrer'; + docs: ['The address that referred this user']; + type: 'pubkey'; + }, + { + name: 'fees'; + docs: ['Stats on the fees paid by the user']; + type: { + defined: { + name: 'userFees'; + }; + }; + }, + { + name: 'nextEpochTs'; + docs: [ + 'The timestamp of the next epoch', + 'Epoch is used to limit referrer rewards earned in single epoch', + ]; + type: 'i64'; + }, + { + name: 'makerVolume30d'; + docs: [ + 'Rolling 30day maker volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'takerVolume30d'; + docs: [ + 'Rolling 30day taker volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'fillerVolume30d'; + docs: [ + 'Rolling 30day filler volume for user', + 'precision: QUOTE_PRECISION', + ]; + type: 'u64'; + }, + { + name: 'lastMakerVolume30dTs'; + docs: ['last time the maker volume was updated']; + type: 'i64'; + }, + { + name: 'lastTakerVolume30dTs'; + docs: ['last time the taker volume was updated']; + type: 'i64'; + }, + { + name: 'lastFillerVolume30dTs'; + docs: ['last time the filler volume was updated']; + type: 'i64'; + }, + { + name: 'ifStakedQuoteAssetAmount'; + docs: ['The amount of tokens staked in the quote spot markets if']; + type: 'u64'; + }, + { + name: 'numberOfSubAccounts'; + docs: ['The current number of sub accounts']; + type: 'u16'; + }, + { + name: 'numberOfSubAccountsCreated'; + docs: [ + 'The number of sub accounts created. Can be greater than the number of sub accounts if user', + 'has deleted sub accounts', + ]; + type: 'u16'; + }, + { + name: 'referrerStatus'; + docs: [ + 'Flags for referrer status:', + 'First bit (LSB): 1 if user is a referrer, 0 otherwise', + 'Second bit: 1 if user was referred, 0 otherwise', + ]; + type: 'u8'; + }, + { + name: 'disableUpdatePerpBidAskTwap'; + type: 'u8'; + }, + { + name: 'pausedOperations'; + type: 'u8'; + }, + { + name: 'fuelOverflowStatus'; + docs: ['whether the user has a FuelOverflow account']; + type: 'u8'; + }, + { + name: 'fuelInsurance'; + docs: ['accumulated fuel for token amounts of insurance']; + type: 'u32'; + }, + { + name: 'fuelDeposits'; + docs: ['accumulated fuel for notional of deposits']; + type: 'u32'; + }, + { + name: 'fuelBorrows'; + docs: ['accumulate fuel bonus for notional of borrows']; + type: 'u32'; + }, + { + name: 'fuelPositions'; + docs: ['accumulated fuel for perp open interest']; + type: 'u32'; + }, + { + name: 'fuelTaker'; + docs: ['accumulate fuel bonus for taker volume']; + type: 'u32'; + }, + { + name: 'fuelMaker'; + docs: ['accumulate fuel bonus for maker volume']; + type: 'u32'; + }, + { + name: 'ifStakedGovTokenAmount'; + docs: [ + 'The amount of tokens staked in the governance spot markets if', + ]; + type: 'u64'; + }, + { + name: 'lastFuelIfBonusUpdateTs'; + docs: [ + 'last unix ts user stats data was used to update if fuel (u32 to save space)', + ]; + type: 'u32'; + }, + { + name: 'padding'; + type: { + array: ['u8', 12]; + }; + }, + ]; + }; + }, + { + name: 'validityGuardRails'; + type: { + kind: 'struct'; + fields: [ + { + name: 'slotsBeforeStaleForAmm'; + type: 'i64'; + }, + { + name: 'slotsBeforeStaleForMargin'; + type: 'i64'; + }, + { + name: 'confidenceIntervalMaxSize'; + type: 'u64'; + }, + { + name: 'tooVolatileRatio'; + type: 'i64'; + }, + ]; + }; + }, + { + name: 'i128'; + docs: ['`i128` with legacy bit layout']; + type: { + kind: 'struct'; + fields: [ + { + array: ['u8', 16]; + }, + ]; + }; + }, + { + name: 'u128'; + docs: ['`u128` with legacy bit layout']; + type: { + kind: 'struct'; + fields: [ + { + array: ['u8', 16]; + }, + ]; + }; + }, + ]; }; diff --git a/sdk/src/orderSubscriber/OrderSubscriber.ts b/sdk/src/orderSubscriber/OrderSubscriber.ts index 6ecb37234e..56439cd1c7 100644 --- a/sdk/src/orderSubscriber/OrderSubscriber.ts +++ b/sdk/src/orderSubscriber/OrderSubscriber.ts @@ -75,7 +75,7 @@ export class OrderSubscriber { } else { this.decodeFn = this.driftClient.program.account.user.coder.accounts.decodeUnchecked.bind( - this.driftClient.program.account.user.coder.accounts + this.driftClient.program.account.user.coder ); } this.eventEmitter = new EventEmitter(); diff --git a/sdk/src/types.ts b/sdk/src/types.ts index 1cc160d2d2..3c6a470233 100644 --- a/sdk/src/types.ts +++ b/sdk/src/types.ts @@ -1235,12 +1235,91 @@ export function parseAMM(amm: { */ export function parsePerpMarketAccount(account: { amm?: any; + pnlPool?: any; [key: string]: any; }): PerpMarketAccount { return { ...account, amm: account.amm ? parseAMM(account.amm) : account.amm, - } as unknown as PerpMarketAccount; + pnlPool: convertPoolBalance(account.pnlPool), + } as PerpMarketAccount; +} + +/** + * Converts an Anchor BN representation to an actual BN instance. + * Handles both BN instances and serialized BN objects like { 0: number[] }. + */ +function convertToBN(value: any): BN { + if (BN.isBN(value)) { + return value; + } + if ( + value && + typeof value === 'object' && + '0' in value && + Array.isArray(value[0]) + ) { + // Anchor serializes BN as { 0: number[] } - convert from little-endian bytes + return new BN(value[0], 'le'); + } + if (value != null) { + return new BN(value); + } + return ZERO; +} + +/** + * Converts a PoolBalance object's BN fields. + */ +function convertPoolBalance(poolBalance: any): PoolBalance | undefined { + if (!poolBalance) return poolBalance; + return { + ...poolBalance, + scaledBalance: convertToBN(poolBalance.scaledBalance), + }; +} + +/** + * Converts HistoricalOracleData object's BN fields and handles field name mappings. + */ +function convertHistoricalOracleData( + historicalOracleData: any +): HistoricalOracleData | undefined { + if (!historicalOracleData) return historicalOracleData; + return { + ...historicalOracleData, + lastOraclePrice: convertToBN(historicalOracleData.lastOraclePrice), + lastOracleDelay: convertToBN(historicalOracleData.lastOracleDelay), + lastOracleConf: convertToBN(historicalOracleData.lastOracleConf), + lastOraclePriceTwap: convertToBN(historicalOracleData.lastOraclePriceTwap), + lastOraclePriceTwap5Min: convertToBN( + historicalOracleData.lastOraclePriceTwap5Min ?? + historicalOracleData.lastOraclePriceTwap5min + ), + lastOraclePriceTwapTs: convertToBN( + historicalOracleData.lastOraclePriceTwapTs + ), + }; +} + +/** + * Converts HistoricalIndexData object's BN fields and handles field name mappings. + */ +function convertHistoricalIndexData( + historicalIndexData: any +): HistoricalIndexData | undefined { + if (!historicalIndexData) return historicalIndexData; + return { + ...historicalIndexData, + lastIndexBidPrice: convertToBN(historicalIndexData.lastIndexBidPrice), + lastIndexAskPrice: convertToBN(historicalIndexData.lastIndexAskPrice), + lastIndexPriceTwap: convertToBN(historicalIndexData.lastIndexPriceTwap), + lastIndexPriceTwap5Min: convertToBN( + historicalIndexData.lastIndexPriceTwap5Min ?? + historicalIndexData.lastIndexPriceTwap5min + ), + lastIndexPriceTwapTs: convertToBN(historicalIndexData.lastIndexPriceTwapTs), + }; } /** @@ -1248,11 +1327,87 @@ export function parsePerpMarketAccount(account: { * Handles field name mappings and provides defaults for missing fields. */ export function parseSpotMarketAccount(account: { + insuranceFund?: any; + revenuePool?: any; + spotFeePool?: any; + historicalOracleData?: any; + historicalIndexData?: any; [key: string]: any; }): SpotMarketAccount { + const insuranceFund = account.insuranceFund + ? { + ...account.insuranceFund, + totalShares: convertToBN(account.insuranceFund.totalShares), + userShares: convertToBN(account.insuranceFund.userShares), + sharesBase: convertToBN(account.insuranceFund.sharesBase), + unstakingPeriod: convertToBN(account.insuranceFund.unstakingPeriod), + lastRevenueSettleTs: convertToBN( + account.insuranceFund.lastRevenueSettleTs + ), + revenueSettlePeriod: convertToBN( + account.insuranceFund.revenueSettlePeriod + ), + } + : account.insuranceFund; + return { ...account, - } as unknown as SpotMarketAccount; + insuranceFund, + revenuePool: convertPoolBalance(account.revenuePool), + spotFeePool: convertPoolBalance(account.spotFeePool), + historicalOracleData: convertHistoricalOracleData( + account.historicalOracleData + ), + historicalIndexData: convertHistoricalIndexData( + account.historicalIndexData + ), + cumulativeDepositInterest: convertToBN(account.cumulativeDepositInterest), + cumulativeBorrowInterest: convertToBN(account.cumulativeBorrowInterest), + totalSocialLoss: convertToBN(account.totalSocialLoss), + totalQuoteSocialLoss: convertToBN(account.totalQuoteSocialLoss), + depositBalance: convertToBN(account.depositBalance), + borrowBalance: convertToBN(account.borrowBalance), + maxTokenDeposits: convertToBN(account.maxTokenDeposits), + lastInterestTs: convertToBN(account.lastInterestTs), + lastTwapTs: convertToBN(account.lastTwapTs), + scaleInitialAssetWeightStart: convertToBN( + account.scaleInitialAssetWeightStart + ), + withdrawGuardThreshold: convertToBN(account.withdrawGuardThreshold), + depositTokenTwap: convertToBN(account.depositTokenTwap), + borrowTokenTwap: convertToBN(account.borrowTokenTwap), + utilizationTwap: convertToBN(account.utilizationTwap), + nextDepositRecordId: convertToBN(account.nextDepositRecordId), + orderStepSize: convertToBN(account.orderStepSize), + orderTickSize: convertToBN(account.orderTickSize), + minOrderSize: convertToBN(account.minOrderSize), + maxPositionSize: convertToBN(account.maxPositionSize), + nextFillRecordId: convertToBN(account.nextFillRecordId), + totalSpotFee: convertToBN(account.totalSpotFee), + totalSwapFee: convertToBN(account.totalSwapFee), + flashLoanAmount: convertToBN(account.flashLoanAmount), + flashLoanInitialTokenAmount: convertToBN( + account.flashLoanInitialTokenAmount + ), + } as SpotMarketAccount; +} + +/** + * Map of account names to their parser functions. + * Parsers convert Anchor's serialized BN format to proper BN instances. + */ +export const ACCOUNT_PARSERS: Record any> = { + spotMarket: parseSpotMarketAccount, + perpMarket: parsePerpMarketAccount, +}; + +/** + * Applies the appropriate parser to an account based on its name. + * Returns the account unchanged if no parser is registered for the name. + */ +export function parseAccount(accountName: string, account: any): T { + const parser = ACCOUNT_PARSERS[accountName]; + return (parser ? parser(account) : account) as T; } export type FuelOverflowAccount = { diff --git a/sdk/src/user.ts b/sdk/src/user.ts index 5fb3eee09f..6e3ee18962 100644 --- a/sdk/src/user.ts +++ b/sdk/src/user.ts @@ -46,7 +46,7 @@ import { UserAccountSubscriber, } from './accounts/types'; import { BigNum } from './factory/bigNum'; -import { BN } from '@coral-xyz/anchor'; +import { BN, BorshAccountsCoder } from '@coral-xyz/anchor'; import { calculateBaseAssetValue, calculatePositionPNL } from './math/position'; import { calculateMarketMarginRatio, @@ -140,7 +140,8 @@ export class User { config.userAccountPublicKey, config.accountSubscription.accountLoader, this.driftClient.program.account.user.coder.accounts.decodeUnchecked.bind( - this.driftClient.program.account.user.coder.accounts + this.driftClient.program.account.user.coder + .accounts as BorshAccountsCoder ) ); } else if (config.accountSubscription?.type === 'custom') { diff --git a/sdk/src/userMap/revenueShareEscrowMap.ts b/sdk/src/userMap/revenueShareEscrowMap.ts index fb56628a23..9e9f435d93 100644 --- a/sdk/src/userMap/revenueShareEscrowMap.ts +++ b/sdk/src/userMap/revenueShareEscrowMap.ts @@ -78,7 +78,7 @@ export class RevenueShareEscrowMap { if (accountInfo && accountInfo.data) { const escrow = this.driftClient.program.account.revenueShareEscrow.coder.accounts.decode( - 'RevenueShareEscrow', + 'revenueShareEscrow', accountInfo.data ) as RevenueShareEscrowAccount; @@ -131,7 +131,7 @@ export class RevenueShareEscrowMap { ); const escrowNew = this.driftClient.program.account.revenueShareEscrow.coder.accounts.decode( - 'RevenueShareEscrow', + 'revenueShareEscrow', accountInfo.data ) as RevenueShareEscrowAccount; this.authorityEscrowMap.set(authority, escrowNew); @@ -181,7 +181,7 @@ export class RevenueShareEscrowMap { const escrow = this.driftClient.program.account.revenueShareEscrow.coder.accounts.decode( - 'RevenueShareEscrow', + 'revenueShareEscrow', buffer ) as RevenueShareEscrowAccount; @@ -207,7 +207,7 @@ export class RevenueShareEscrowMap { const escrow = this.driftClient.program.account.revenueShareEscrow.coder.accounts.decode( - 'RevenueShareEscrow', + 'revenueShareEscrow', buffer ) as RevenueShareEscrowAccount; diff --git a/sdk/src/userMap/userMap.ts b/sdk/src/userMap/userMap.ts index f022be058a..78227e7a70 100644 --- a/sdk/src/userMap/userMap.ts +++ b/sdk/src/userMap/userMap.ts @@ -135,7 +135,8 @@ export class UserMap implements UserMapInterface { } else { decodeFn = this.driftClient.program.account.user.coder.accounts.decodeUnchecked.bind( - this.driftClient.program.account.user.coder.accounts + 'user', + this.driftClient.program.account.user.coder ); } this.decode = decodeFn; diff --git a/sdk/tests/amm/test.ts b/sdk/tests/amm/test.ts index ab849c57d6..97c36577ec 100644 --- a/sdk/tests/amm/test.ts +++ b/sdk/tests/amm/test.ts @@ -812,7 +812,7 @@ describe('AMM Tests', () => { const maxOffset = Math.max( mockAmm.maxSpread / 5, (PERCENTAGE_PRECISION.toNumber() / 10000) * - (mockAmm.curveUpdateIntensity - 100) + (mockAmm.curveUpdateIntensity - 100) ); const liquidityFraction = calculateInventoryLiquidityRatio( mockAmm.baseAssetAmountWithAmm, @@ -1025,7 +1025,7 @@ describe('AMM Tests', () => { const maxOffset = Math.max( mockAmm.maxSpread / 5, (PERCENTAGE_PRECISION.toNumber() / 10000) * - (mockAmm.curveUpdateIntensity - 100) + (mockAmm.curveUpdateIntensity - 100) ); const liquidityFraction = calculateInventoryLiquidityRatio( mockAmm.baseAssetAmountWithAmm, diff --git a/sdk/tests/decode/test.ts b/sdk/tests/decode/test.ts index 20f18bebdd..2ddbd37bce 100644 --- a/sdk/tests/decode/test.ts +++ b/sdk/tests/decode/test.ts @@ -4,7 +4,6 @@ import { Connection, Keypair } from '@solana/web3.js'; import { decodeUser, Wallet, - DRIFT_PROGRAM_ID, isSpotPositionAvailable, isVariant, Order, @@ -22,7 +21,7 @@ describe('Custom user decode', () => { const wallet = new Wallet(new Keypair()); // @ts-ignore const provider = new AnchorProvider(connection, wallet); - const program = new Program(driftIDL as Idl, DRIFT_PROGRAM_ID, provider); + const program = new Program(driftIDL as Idl, provider); let totalAnchorSize = 0; let totalCustomSize = 0; @@ -139,7 +138,7 @@ function testUserAccountDecode(program: Program, buffer: Buffer, i: number) { assert(anchorUserAccount.maxMarginRatio === customUserAccount.maxMarginRatio); assert( anchorUserAccount.isMarginTradingEnabled === - customUserAccount.isMarginTradingEnabled + customUserAccount.isMarginTradingEnabled ); assert(anchorUserAccount.idle === customUserAccount.idle); assert(anchorUserAccount.openOrders === customUserAccount.openOrders); @@ -187,7 +186,6 @@ function testPerpPosition(anchor: PerpPosition, custom: PerpPosition) { assert(anchor.openAsks.eq(custom.openAsks)); assert(anchor.settledPnl.eq(custom.settledPnl)); assert(anchor.lpShares.eq(custom.lpShares)); - assert(anchor.lastBaseAssetAmountPerLp.eq(custom.lastBaseAssetAmountPerLp)); assert(anchor.lastQuoteAssetAmountPerLp.eq(custom.lastQuoteAssetAmountPerLp)); assert(anchor.openOrders === custom.openOrders); assert(anchor.perLpBase === custom.perLpBase); diff --git a/sdk/tests/dlob/helpers.ts b/sdk/tests/dlob/helpers.ts index 612fbddea0..3af37c6940 100644 --- a/sdk/tests/dlob/helpers.ts +++ b/sdk/tests/dlob/helpers.ts @@ -40,7 +40,6 @@ export const mockPerpPosition: PerpPosition = { openAsks: new BN(0), settledPnl: new BN(0), lpShares: new BN(0), - lastBaseAssetAmountPerLp: new BN(0), lastQuoteAssetAmountPerLp: new BN(0), perLpBase: 0, maxMarginRatio: 1, @@ -690,9 +689,9 @@ export class MockUserMap implements UserMapInterface { }); } - public async subscribe(): Promise {} + public async subscribe(): Promise { } - public async unsubscribe(): Promise {} + public async unsubscribe(): Promise { } public async addPubkey(userAccountPublicKey: PublicKey): Promise { const user = new User({ @@ -751,7 +750,7 @@ export class MockUserMap implements UserMapInterface { ); } - public async updateWithOrderRecord(_record: OrderRecord): Promise {} + public async updateWithOrderRecord(_record: OrderRecord): Promise { } public values(): IterableIterator { return this.userMap.values(); diff --git a/sdk/yarn.lock b/sdk/yarn.lock index 85552471dc..65fa55db9b 100644 --- a/sdk/yarn.lock +++ b/sdk/yarn.lock @@ -41,13 +41,12 @@ "@babel/helper-string-parser" "^7.27.1" "@babel/helper-validator-identifier" "^7.27.1" -"@coral-xyz/anchor-30@npm:@coral-xyz/anchor@0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.1.tgz#17f3e9134c28cd0ea83574c6bab4e410bcecec5d" - integrity sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ== +"@coral-xyz/anchor-29@npm:@coral-xyz/anchor@0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.29.0.tgz#bd0be95bedfb30a381c3e676e5926124c310ff12" + integrity sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA== dependencies: - "@coral-xyz/anchor-errors" "^0.30.1" - "@coral-xyz/borsh" "^0.30.1" + "@coral-xyz/borsh" "^0.29.0" "@noble/hashes" "^1.3.1" "@solana/web3.js" "^1.68.0" bn.js "^5.1.2" @@ -62,12 +61,31 @@ superstruct "^0.15.4" toml "^3.0.0" -"@coral-xyz/anchor-errors@^0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor-errors/-/anchor-errors-0.30.1.tgz#bdfd3a353131345244546876eb4afc0e125bec30" - integrity sha512-9Mkradf5yS5xiLWrl9WrpjqOrAV+/W2RQHDlbnAZBivoGpOs1ECjoDCkVk4aRG8ZdiFiB8zQEVlxf+8fKkmSfQ== +"@coral-xyz/anchor-31@npm:@coral-xyz/anchor@0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.31.1.tgz#0fdeebf45a3cb2e47e8ebbb815ca98542152962c" + integrity sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA== + dependencies: + "@coral-xyz/anchor-errors" "^0.31.1" + "@coral-xyz/borsh" "^0.31.1" + "@noble/hashes" "^1.3.1" + "@solana/web3.js" "^1.69.0" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + eventemitter3 "^4.0.7" + pako "^2.0.3" + superstruct "^0.15.4" + toml "^3.0.0" + +"@coral-xyz/anchor-errors@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor-errors/-/anchor-errors-0.31.1.tgz#d635cbac2533973ae6bfb5d3ba1de89ce5aece2d" + integrity sha512-NhNEku4F3zzUSBtrYz84FzYWm48+9OvmT1Hhnwr6GnPQry2dsEqH/ti/7ASjjpoFTWRnPXrjAIT1qM6Isop+LQ== -"@coral-xyz/anchor@0.29.0", "@coral-xyz/anchor@^0.29.0": +"@coral-xyz/anchor@^0.29.0": version "0.29.0" resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.29.0.tgz#bd0be95bedfb30a381c3e676e5926124c310ff12" integrity sha512-eny6QNG0WOwqV0zQ7cs/b1tIuzZGmP7U7EcH+ogt4Gdbl8HDmIYVMh/9aTmYZPaFWjtUaI8qSn73uYEXWfATdA== @@ -87,6 +105,25 @@ superstruct "^0.15.4" toml "^3.0.0" +"@coral-xyz/anchor@npm:@coral-xyz/anchor@0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.31.1.tgz#0fdeebf45a3cb2e47e8ebbb815ca98542152962c" + integrity sha512-QUqpoEK+gi2S6nlYc2atgT2r41TT3caWr/cPUEL8n8Md9437trZ68STknq897b82p5mW0XrTBNOzRbmIRJtfsA== + dependencies: + "@coral-xyz/anchor-errors" "^0.31.1" + "@coral-xyz/borsh" "^0.31.1" + "@noble/hashes" "^1.3.1" + "@solana/web3.js" "^1.69.0" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + eventemitter3 "^4.0.7" + pako "^2.0.3" + superstruct "^0.15.4" + toml "^3.0.0" + "@coral-xyz/borsh@^0.29.0": version "0.29.0" resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.29.0.tgz#79f7045df2ef66da8006d47f5399c7190363e71f" @@ -95,10 +132,10 @@ bn.js "^5.1.2" buffer-layout "^1.2.0" -"@coral-xyz/borsh@^0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.30.1.tgz#869d8833abe65685c72e9199b8688477a4f6b0e3" - integrity sha512-aaxswpPrCFKl8vZTbxLssA2RvwX2zmKLlRCIktJOwW+VpVwYtXRtlWiIP+c2pPRKneiTiWCN2GEMSH9j1zTlWQ== +"@coral-xyz/borsh@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.31.1.tgz#5328e1e0921b75d7f4a62dd3f61885a938bc7241" + integrity sha512-9N8AU9F0ubriKfNE3g1WF0/4dtlGXoBN/hd1PvbNBamBNwRgHxH4P+o3Zt7rSEloW1HUs6LfZEchlx9fW7POYw== dependencies: bn.js "^5.1.2" buffer-layout "^1.2.0" @@ -573,7 +610,7 @@ resolved "https://registry.yarnpkg.com/@solana-program/system/-/system-0.7.0.tgz#3e21c9fb31d3795eb65ba5cb663947c19b305bad" integrity sha512-FKTBsKHpvHHNc1ATRm7SlC5nF/VdJtOSjldhcyfMN9R7xo712Mo2jHIzvBgn8zQO5Kg0DcWuKB7268Kv1ocicw== -"@solana-program/token-2022@^0.4.1": +"@solana-program/token-2022@^0.4.2": version "0.4.2" resolved "https://registry.yarnpkg.com/@solana-program/token-2022/-/token-2022-0.4.2.tgz#f90a638de82acb7933a114e884a24ac4be8ef635" integrity sha512-zIpR5t4s9qEU3hZKupzIBxJ6nUV5/UVyIT400tu9vT1HMs5JHxaTTsb5GUhYjiiTvNwU0MQavbwc4Dl29L0Xvw== @@ -756,7 +793,7 @@ "@solana/errors" "2.3.0" "@solana/nominal-types" "2.3.0" -"@solana/kit@^2.1.1": +"@solana/kit@^2.3.0": version "2.3.0" resolved "https://registry.yarnpkg.com/@solana/kit/-/kit-2.3.0.tgz#92deb7c4883293617209aecac9a43d5e41ccf092" integrity sha512-sb6PgwoW2LjE5oTFu4lhlS/cGt/NB3YrShEyx7JgWFWysfgLdJnhwWThgwy/4HjNsmtMrQGWVls0yVBHcMvlMQ== @@ -1014,6 +1051,17 @@ "@solana/spl-token-metadata" "^0.1.2" buffer "^6.0.3" +"@solana/spl-token@^0.4.14": + version "0.4.14" + resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.4.14.tgz#b86bc8a17f50e9680137b585eca5f5eb9d55c025" + integrity sha512-u09zr96UBpX4U685MnvQsNzlvw9TiY005hk1vJmJr7gMJldoPG1eYU5/wNEyOA5lkMLiR/gOi9SFD4MefOYEsA== + dependencies: + "@solana/buffer-layout" "^4.0.0" + "@solana/buffer-layout-utils" "^0.2.0" + "@solana/spl-token-group" "^0.0.7" + "@solana/spl-token-metadata" "^0.1.6" + buffer "^6.0.3" + "@solana/subscribable@2.3.0": version "2.3.0" resolved "https://registry.yarnpkg.com/@solana/subscribable/-/subscribable-2.3.0.tgz#4e48f1a4eeb1ccf22065b46fb8e3ed80d1a27f80" @@ -1080,7 +1128,7 @@ "@solana/rpc-types" "2.3.0" "@solana/transaction-messages" "2.3.0" -"@solana/web3.js@1.98.0", "@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0", "@solana/web3.js@^1.30.2", "@solana/web3.js@^1.32.0", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.77.3", "@solana/web3.js@^1.90.0", "@solana/web3.js@^1.98.0", "@solana/web3.js@^1.98.2", "@solana/web3.js@~1.77.3": +"@solana/web3.js@1.98.0", "@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0", "@solana/web3.js@^1.30.2", "@solana/web3.js@^1.32.0", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.69.0", "@solana/web3.js@^1.77.3", "@solana/web3.js@^1.90.0", "@solana/web3.js@^1.98.2", "@solana/web3.js@^1.98.4", "@solana/web3.js@~1.77.3": version "1.98.0" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.0.tgz#21ecfe8198c10831df6f0cfde7f68370d0405917" integrity sha512-nz3Q5OeyGFpFCR+erX2f6JPt3sKhzhYcSycBCSPkWjzSVDh/Rr1FqTVMRe58FKO16/ivTUcuJjeS5MyBvpkbzA== @@ -1108,13 +1156,13 @@ dependencies: tslib "^2.8.0" -"@switchboard-xyz/common@3.0.14": - version "3.0.14" - resolved "https://registry.yarnpkg.com/@switchboard-xyz/common/-/common-3.0.14.tgz#5b363995bd0fefa22198286992dbe54f3e544b08" - integrity sha512-LpxzEywO0DjPYIgPzQYkf32C7agwW4YRsPN6BcIvYrw0iJdDMtPZ3SQfIGHLSlD1fwvn2KLUYuGaKegeq4aBTw== +"@switchboard-xyz/common@5.5.0": + version "5.5.0" + resolved "https://registry.yarnpkg.com/@switchboard-xyz/common/-/common-5.5.0.tgz#b064eb911909cae2b2b732ec9fb8b5c073316eeb" + integrity sha512-Wvs9KJw+YSe8O2IOsMUvPE8aQHb0t2vi/9hEQC7Pc6279s7tTTI8eVgT/0Jb2z897OHgIZTD3oGQ8IEBqIgV0w== dependencies: - "@solana/web3.js" "^1.98.0" - axios "^1.8.3" + "@solana/web3.js" "^1.98.2" + axios "^1.9.0" big.js "^6.2.2" bn.js "^5.2.1" bs58 "^6.0.0" @@ -1122,12 +1170,11 @@ decimal.js "^10.4.3" js-sha256 "^0.11.0" protobufjs "^7.4.0" - yaml "^2.6.1" -"@switchboard-xyz/common@>=3.0.0": - version "3.4.1" - resolved "https://registry.yarnpkg.com/@switchboard-xyz/common/-/common-3.4.1.tgz#3144c0730649e60129ea8c9b3c04062ceff35c6e" - integrity sha512-TropBlBYuDeBnmGHkPSmgC3clLqAxy51ZGbwk4ejAgadnszWOgYHcH7taRG4Ha17DYSCWw/LGMBKbunGo+Aoaw== +"@switchboard-xyz/common@^5.2.9": + version "5.5.1" + resolved "https://registry.yarnpkg.com/@switchboard-xyz/common/-/common-5.5.1.tgz#e9026dd6efacbf87c0489fe75f23c072b8ed11d9" + integrity sha512-0oPooEE/E6sbLfLvW/xiPM0fqnzCh6sARWBz8lW9ABJ1IRpLqd0qmFRfFZlYkyLtaQUlb5mKfe5DrPuoyUWvoA== dependencies: "@solana/web3.js" "^1.98.2" axios "^1.9.0" @@ -1138,21 +1185,25 @@ decimal.js "^10.4.3" js-sha256 "^0.11.0" protobufjs "^7.4.0" - yaml "^2.6.1" - zod "4.0.0-beta.20250505T195954" -"@switchboard-xyz/on-demand@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@switchboard-xyz/on-demand/-/on-demand-2.4.1.tgz#3db64b0596d9daa0b010ee44193d5512e0ba512d" - integrity sha512-eSlBp+c8lxpcSgh0/2xK8OaLHPziTSZlcs8V96gZGdiCJz1KgWJRNE1qnIJDOwaGdFecZdwcmajfQRtLRLED3w== +"@switchboard-xyz/on-demand@3.7.3": + version "3.7.3" + resolved "https://registry.yarnpkg.com/@switchboard-xyz/on-demand/-/on-demand-3.7.3.tgz#07e4df25e145e86e5c5dab496704056bda07c2bc" + integrity sha512-sG9errSwjYlQbIlQl0iptUQcbKrPe7QVxX20+qXuucG3qIWlA/w6sXGnITeYbt+BERyBYdfue0viBjmjOsCZrg== dependencies: - "@coral-xyz/anchor-30" "npm:@coral-xyz/anchor@0.30.1" + "@coral-xyz/anchor-31" "npm:@coral-xyz/anchor@0.31.1" "@isaacs/ttlcache" "^1.4.1" - "@switchboard-xyz/common" ">=3.0.0" - axios "^1.8.3" + "@solana/spl-token" "^0.4.14" + "@solana/web3.js" "^1.98.4" + "@switchboard-xyz/common" "^5.2.9" + axios "^1.9" bs58 "^6.0.0" buffer "^6.0.3" + events "^3.3.0" + isomorphic-ws "^5.0.0" js-yaml "^4.1.0" + tweetnacl "^1.0.3" + ws "^8.18.1" "@triton-one/yellowstone-grpc@1.4.1": version "1.4.1" @@ -1525,11 +1576,6 @@ resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.5.18.tgz#529f24a88d3ed678d50fd5c07455841fbe8ac95e" integrity sha512-cZy8Dq+uuIXbxCZpuLd2GJdeSO/lIzIspC2WtkqIpje5QyFbvLaI5wZtdUjLHjGZrlVX6GilejatWwVYYRc8tA== -"@zod/core@0.11.6": - version "0.11.6" - resolved "https://registry.yarnpkg.com/@zod/core/-/core-0.11.6.tgz#9216e98848dc9364eda35e3da90f5362f10e8887" - integrity sha512-03Bv82fFSfjDAvMfdHHdGSS6SOJs0iCcJlWJv1kJHRtoTT02hZpyip/2Lk6oo4l4FtjuwTrsEQTwg/LD8I7dJA== - acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" @@ -1564,10 +1610,10 @@ ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -anchor-bankrun@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/anchor-bankrun/-/anchor-bankrun-0.3.0.tgz#3789fcecbc201a2334cff228b99cc0da8ef0167e" - integrity sha512-PYBW5fWX+iGicIS5MIM/omhk1tQPUc0ELAnI/IkLKQJ6d75De/CQRh8MF2bU/TgGyFi6zEel80wUe3uRol9RrQ== +anchor-bankrun@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/anchor-bankrun/-/anchor-bankrun-0.5.0.tgz#62b5905f6f0ed3799d4a37e6be045887c13d4f33" + integrity sha512-cNTRv7pN9dy+kiyJ3UlNVTg9hAXhY2HtNVNXJbP/2BkS9nOdLV0qKWhgW8UR9Go0gYuEOLKuPzrGL4HFAZPsVw== ansi-colors@^4.1.3: version "4.1.3" @@ -1662,7 +1708,16 @@ available-typed-arrays@^1.0.7: dependencies: possible-typed-array-names "^1.0.0" -axios@^1.8.3, axios@^1.9.0: +axios@^1.9: + version "1.13.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.13.2.tgz#9ada120b7b5ab24509553ec3e40123521117f687" + integrity sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA== + dependencies: + follow-redirects "^1.15.6" + form-data "^4.0.4" + proxy-from-env "^1.1.0" + +axios@^1.9.0: version "1.10.0" resolved "https://registry.yarnpkg.com/axios/-/axios-1.10.0.tgz#af320aee8632eaf2a400b6a1979fa75856f38d54" integrity sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw== @@ -1681,23 +1736,13 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base-x@^3.0.2, base-x@^3.0.6: +base-x@^3.0.11, base-x@^3.0.2, base-x@^3.0.6: version "3.0.11" resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.11.tgz#40d80e2a1aeacba29792ccc6c5354806421287ff" integrity sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA== dependencies: safe-buffer "^5.0.1" -base-x@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.1.tgz#817fb7b57143c501f649805cb247617ad016a885" - integrity sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw== - -base-x@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-5.0.1.tgz#16bf35254be1df8aca15e36b7c1dda74b2aa6b03" - integrity sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg== - base64-js@^1.3.1, base64-js@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -1782,27 +1827,13 @@ browser-stdout@^1.3.1: resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== -bs58@^4.0.0, bs58@^4.0.1: +bs58@^4.0.0, bs58@^4.0.1, bs58@^5.0.0, bs58@^6.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== dependencies: base-x "^3.0.2" -bs58@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" - integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== - dependencies: - base-x "^4.0.0" - -bs58@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-6.0.0.tgz#a2cda0130558535dd281a2f8697df79caaf425d8" - integrity sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw== - dependencies: - base-x "^5.0.0" - buffer-layout@^1.2.0, buffer-layout@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" @@ -2479,6 +2510,11 @@ eventemitter3@^5.0.1: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== +events@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + expect@^28.0.0: version "28.1.3" resolved "https://registry.yarnpkg.com/expect/-/expect-28.1.3.tgz#90a7c1a124f1824133dd4533cce2d2bdcb6603ec" @@ -2640,6 +2676,17 @@ form-data@^4.0.0: hasown "^2.0.2" mime-types "^2.1.12" +form-data@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.5.tgz#b49e48858045ff4cbf6b03e1805cebcad3679053" + integrity sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + es-set-tostringtag "^2.1.0" + hasown "^2.0.2" + mime-types "^2.1.12" + fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" @@ -2702,18 +2749,18 @@ get-proto@^1.0.0, get-proto@^1.0.1: dunder-proto "^1.0.1" es-object-atoms "^1.0.0" -gill@^0.10.2: - version "0.10.2" - resolved "https://registry.yarnpkg.com/gill/-/gill-0.10.2.tgz#593c031c9964739739a07480199d0c409da40fb5" - integrity sha512-upWoY2dfOzKHOcX3UnD+B3h9WUunPv0oxeKzsIgKSaLyURpWK9oI+K2NHWbwrUFsXEK6ozu/sgkhuqyAcVTZCg== +gill@^0.10.3: + version "0.10.3" + resolved "https://registry.yarnpkg.com/gill/-/gill-0.10.3.tgz#0eeeaf18b9a6ec7adc17967f51f86be042ee2f24" + integrity sha512-4LIVA32lKcWoqU/dbwu+YpJbR59QQT6mvCtqkElBWF2aT9upmewjKN3/anhfTGy+o/RJykAV21i3RzCj9FR0Xg== dependencies: "@solana-program/address-lookup-table" "^0.7.0" "@solana-program/compute-budget" "^0.8.0" "@solana-program/system" "^0.7.0" - "@solana-program/token-2022" "^0.4.1" + "@solana-program/token-2022" "^0.4.2" "@solana/assertions" "^2.1.1" "@solana/codecs" "^2.1.1" - "@solana/kit" "^2.1.1" + "@solana/kit" "^2.3.0" "@solana/transaction-confirmation" "^2.1.1" glob-parent@^5.1.2, glob-parent@~5.1.2: @@ -3081,6 +3128,11 @@ isomorphic-ws@^4.0.1: resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== +isomorphic-ws@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz#e5529148912ecb9b451b46ed44d53dae1ce04bbf" + integrity sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw== + jayson@^4.0.0, jayson@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.2.0.tgz#b71762393fa40bc9637eaf734ca6f40d3b8c0c93" @@ -4036,44 +4088,44 @@ snake-case@^3.0.4: dot-case "^3.0.4" tslib "^2.0.3" -solana-bankrun-darwin-arm64@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-arm64/-/solana-bankrun-darwin-arm64-0.3.1.tgz#65ab6cd2e74eef260c38251f4c53721cf5b9030f" - integrity sha512-9LWtH/3/WR9fs8Ve/srdo41mpSqVHmRqDoo69Dv1Cupi+o1zMU6HiEPUHEvH2Tn/6TDbPEDf18MYNfReLUqE6A== +solana-bankrun-darwin-arm64@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-arm64/-/solana-bankrun-darwin-arm64-0.4.0.tgz#eb0f3dfffb1675f6329a1e026b12d09222b33986" + integrity sha512-6dz78Teoz7ez/3lpRLDjktYLJb79FcmJk2me4/YaB8WiO6W43OdExU4h+d2FyuAryO2DgBPXaBoBNY/8J1HJmw== -solana-bankrun-darwin-universal@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-universal/-/solana-bankrun-darwin-universal-0.3.1.tgz#bf691457cf046e8739c021ca11e48de5b4fefd45" - integrity sha512-muGHpVYWT7xCd8ZxEjs/bmsbMp8XBqroYGbE4lQPMDUuLvsJEIrjGqs3MbxEFr71sa58VpyvgywWd5ifI7sGIg== +solana-bankrun-darwin-universal@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-universal/-/solana-bankrun-darwin-universal-0.4.0.tgz#0ac13ec7637b334b1030e6f51abecc50a254b5de" + integrity sha512-zSSw/Jx3KNU42pPMmrEWABd0nOwGJfsj7nm9chVZ3ae7WQg3Uty0hHAkn5NSDCj3OOiN0py9Dr1l9vmRJpOOxg== -solana-bankrun-darwin-x64@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-x64/-/solana-bankrun-darwin-x64-0.3.1.tgz#c6f30c0a6bc3e1621ed90ce7562f26e93bf5303f" - integrity sha512-oCaxfHyt7RC3ZMldrh5AbKfy4EH3YRMl8h6fSlMZpxvjQx7nK7PxlRwMeflMnVdkKKp7U8WIDak1lilIPd3/lg== +solana-bankrun-darwin-x64@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-x64/-/solana-bankrun-darwin-x64-0.4.0.tgz#f863c5a668858b7c44be51376bd05fb077c11c99" + integrity sha512-LWjs5fsgHFtyr7YdJR6r0Ho5zrtzI6CY4wvwPXr8H2m3b4pZe6RLIZjQtabCav4cguc14G0K8yQB2PTMuGub8w== -solana-bankrun-linux-x64-gnu@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-gnu/-/solana-bankrun-linux-x64-gnu-0.3.1.tgz#78b522f1a581955a48f43a8fb560709c11301cfd" - integrity sha512-PfRFhr7igGFNt2Ecfdzh3li9eFPB3Xhmk0Eib17EFIB62YgNUg3ItRnQQFaf0spazFjjJLnglY1TRKTuYlgSVA== +solana-bankrun-linux-x64-gnu@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-gnu/-/solana-bankrun-linux-x64-gnu-0.4.0.tgz#30fd7edaf3ff6585468138d3bed6eaed37878d9e" + integrity sha512-SrlVrb82UIxt21Zr/XZFHVV/h9zd2/nP25PMpLJVLD7Pgl2yhkhfi82xj3OjxoQqWe+zkBJ+uszA0EEKr67yNw== -solana-bankrun-linux-x64-musl@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-musl/-/solana-bankrun-linux-x64-musl-0.3.1.tgz#1a044a132138a0084e82406ec7bf4939f06bed68" - integrity sha512-6r8i0NuXg3CGURql8ISMIUqhE7Hx/O7MlIworK4oN08jYrP0CXdLeB/hywNn7Z8d1NXrox/NpYUgvRm2yIzAsQ== +solana-bankrun-linux-x64-musl@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-musl/-/solana-bankrun-linux-x64-musl-0.4.0.tgz#3c870218140b1307dc44b51d2282697c99f2e1e4" + integrity sha512-Nv328ZanmURdYfcLL+jwB1oMzX4ZzK57NwIcuJjGlf0XSNLq96EoaO5buEiUTo4Ls7MqqMyLbClHcrPE7/aKyA== -solana-bankrun@0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/solana-bankrun/-/solana-bankrun-0.3.1.tgz#13665ab7c1c15ec2b3354aae56980d0ded514998" - integrity sha512-inRwON7fBU5lPC36HdEqPeDg15FXJYcf77+o0iz9amvkUMJepcwnRwEfTNyMVpVYdgjTOBW5vg+596/3fi1kGA== +"solana-bankrun@0.4,0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun/-/solana-bankrun-0.4.0.tgz#a48a7a74ce6c56be4ec7e200336026f65e90b8dc" + integrity sha512-NMmXUipPBkt8NgnyNO3SCnPERP6xT/AMNMBooljGA3+rG6NN8lmXJsKeLqQTiFsDeWD74U++QM/DgcueSWvrIg== dependencies: "@solana/web3.js" "^1.68.0" bs58 "^4.0.1" optionalDependencies: - solana-bankrun-darwin-arm64 "0.3.1" - solana-bankrun-darwin-universal "0.3.1" - solana-bankrun-darwin-x64 "0.3.1" - solana-bankrun-linux-x64-gnu "0.3.1" - solana-bankrun-linux-x64-musl "0.3.1" + solana-bankrun-darwin-arm64 "0.4.0" + solana-bankrun-darwin-universal "0.4.0" + solana-bankrun-darwin-x64 "0.4.0" + solana-bankrun-linux-x64-gnu "0.4.0" + solana-bankrun-linux-x64-musl "0.4.0" source-map-js@^1.2.1: version "1.2.1" @@ -4313,7 +4365,7 @@ tweetnacl-util@0.15.1: resolved "https://registry.yarnpkg.com/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz#b80fcdb5c97bcc508be18c44a4be50f022eea00b" integrity sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw== -tweetnacl@1.0.3: +tweetnacl@1.0.3, tweetnacl@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== @@ -4479,7 +4531,7 @@ ws@^7.5.10: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== -ws@^8.5.0: +ws@^8.18.1, ws@^8.5.0: version "8.18.3" resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472" integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg== @@ -4489,11 +4541,6 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yaml@^2.6.1: - version "2.8.0" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.8.0.tgz#15f8c9866211bdc2d3781a0890e44d4fa1a5fff6" - integrity sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ== - yargs-parser@^20.2.2, yargs-parser@^20.2.9: version "20.2.9" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" @@ -4550,13 +4597,6 @@ yocto-queue@^0.1.0: resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== -zod@4.0.0-beta.20250505T195954: - version "4.0.0-beta.20250505T195954" - resolved "https://registry.yarnpkg.com/zod/-/zod-4.0.0-beta.20250505T195954.tgz#ba9da025671de2dde9d4d033089f03c37a35022f" - integrity sha512-iB8WvxkobVIXMARvQu20fKvbS7mUTiYRpcD8OQV1xjRhxO0EEpYIRJBk6yfBzHAHEdOSDh3SxDITr5Eajr2vtg== - dependencies: - "@zod/core" "0.11.6" - zod@4.0.17: version "4.0.17" resolved "https://registry.yarnpkg.com/zod/-/zod-4.0.17.tgz#95931170715f73f7426c385c237b7477750d6c8d" diff --git a/tests/builderCodes.ts b/tests/builderCodes.ts index 4f26cd0476..6e88aaf0ac 100644 --- a/tests/builderCodes.ts +++ b/tests/builderCodes.ts @@ -1,5 +1,4 @@ import * as anchor from '@coral-xyz/anchor'; - import { Program } from '@coral-xyz/anchor'; import { @@ -60,6 +59,7 @@ import { isBuilderOrderReferral, } from '../sdk/src/math/builder'; import { createTransferInstruction } from '@solana/spl-token'; +import { Drift } from '../sdk/src/idl/drift'; dotenv.config(); @@ -103,7 +103,7 @@ function buildMsg( } describe('builder codes', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let usdcMint: Keypair; @@ -143,7 +143,6 @@ describe('builder codes', () => { ] ); - // @ts-ignore bankrunContextWrapper = new BankrunContextWrapper(context); bulkAccountLoader = new TestBulkAccountLoader( @@ -178,7 +177,6 @@ describe('builder codes', () => { }); await builderClient.initialize(usdcMint.publicKey, true); await builderClient.subscribe(); - await builderClient.updateFeatureBitFlagsBuilderCodes(true); // await builderClient.updateFeatureBitFlagsBuilderReferral(true); @@ -343,7 +341,7 @@ describe('builder codes', () => { const builderAcc: RevenueShareAccount = builderClient.program.account.revenueShare.coder.accounts.decodeUnchecked( - 'RevenueShare', + 'revenueShare', builderAccountInfo.data ); assert( @@ -386,7 +384,7 @@ describe('builder codes', () => { const revShareEscrow: RevenueShareEscrowAccount = builderClient.program.coder.accounts.decodeUnchecked( - 'RevenueShareEscrow', + 'revenueShareEscrow', accountInfo.data ); assert( @@ -436,7 +434,7 @@ describe('builder codes', () => { const revShareEscrow: RevenueShareEscrowAccount = builderClient.program.coder.accounts.decodeUnchecked( - 'RevenueShareEscrow', + 'revenueShareEscrow', accountInfo.data ); assert( @@ -471,7 +469,7 @@ describe('builder codes', () => { let revShareEscrow: RevenueShareEscrowAccount = userClient.program.coder.accounts.decodeUnchecked( - 'RevenueShareEscrow', + 'revenueShareEscrow', accountInfo.data ); const addedBuilder = revShareEscrow.approvedBuilders.find( @@ -506,7 +504,7 @@ describe('builder codes', () => { ); revShareEscrow = userClient.program.coder.accounts.decodeUnchecked( - 'RevenueShareEscrow', + 'revenueShareEscrow', accountInfo.data ); const updatedBuilder = revShareEscrow.approvedBuilders.find( @@ -537,7 +535,7 @@ describe('builder codes', () => { ); revShareEscrow = userClient.program.coder.accounts.decodeUnchecked( - 'RevenueShareEscrow', + 'revenueShareEscrow', accountInfo.data ); const removedBuilder = revShareEscrow.approvedBuilders.find( @@ -648,7 +646,8 @@ describe('builder codes', () => { fillTx ); const events = parseLogs(builderClient.program, logs); - assert(events[0].name === 'OrderActionRecord'); + console.log(events.toString()); + assert(events[0].name === 'orderActionRecord'); const fillQuoteAssetAmount = events[0].data['quoteAssetAmountFilled'] as BN; const builderFee = events[0].data['builderFee'] as BN | null; const takerFee = events[0].data['takerFee'] as BN; @@ -843,7 +842,7 @@ describe('builder codes', () => { fillTx ); const events = parseLogs(builderClient.program, logs); - assert(events[0].name === 'OrderActionRecord'); + assert(events[0].name === 'orderActionRecord'); const fillQuoteAssetAmount = events[0].data['quoteAssetAmountFilled'] as BN; const builderFee = events[0].data['builderFee'] as BN; const takerFee = events[0].data['takerFee'] as BN; @@ -937,7 +936,7 @@ describe('builder codes', () => { ); const settleEvents = parseLogs(builderClient.program, settleLogs); const builderSettleEvents = settleEvents - .filter((e) => e.name === 'RevenueShareSettleRecord') + .filter((e) => e.name === 'revenueShareSettleRecord') .map((e) => e.data) as RevenueShareSettleRecord[]; assert(builderSettleEvents.length === 1); @@ -1140,7 +1139,8 @@ describe('builder codes', () => { fillTxA ); const eventsA = parseLogs(builderClient.program, logsA); - const fillEventA = eventsA.find((e) => e.name === 'OrderActionRecord'); + console.log(eventsA.toString()); + const fillEventA = eventsA.find((e) => e.name === 'orderActionRecord'); assert(fillEventA !== undefined); const builderFeeA = fillEventA.data['builderFee'] as BN; // const referrerRewardA = new BN(fillEventA.data['referrerReward'] as number); @@ -1164,7 +1164,8 @@ describe('builder codes', () => { fillTxB ); const eventsB = parseLogs(builderClient.program, logsB); - const fillEventB = eventsB.find((e) => e.name === 'OrderActionRecord'); + console.log(eventsB.toString()); + const fillEventB = eventsB.find((e) => e.name === 'orderActionRecord'); assert(fillEventB !== undefined); const builderFeeB = fillEventB.data['builderFee'] as BN; // const referrerRewardB = new BN(fillEventB.data['referrerReward'] as number); @@ -1242,7 +1243,7 @@ describe('builder codes', () => { ); const builderAccBefore: RevenueShareAccount = builderClient.program.account.revenueShare.coder.accounts.decodeUnchecked( - 'RevenueShare', + 'revenueShare', builderAccountInfoBefore.data ); @@ -1323,7 +1324,7 @@ describe('builder codes', () => { fillTxA ); const eventsA = parseLogs(builderClient.program, logsA); - const fillEventA = eventsA.filter((e) => e.name === 'OrderActionRecord'); + const fillEventA = eventsA.filter((e) => e.name === 'orderActionRecord'); assert(fillEventA !== undefined); const builderFeeA = fillEventA.reduce( (sum, e) => sum.add(e.data['builderFee'] as BN), @@ -1401,7 +1402,7 @@ describe('builder codes', () => { ); const builderAccAfter: RevenueShareAccount = builderClient.program.account.revenueShare.coder.accounts.decodeUnchecked( - 'RevenueShare', + 'revenueShare', builderAccountInfoAfter.data ); assert( @@ -1433,7 +1434,7 @@ describe('builder codes', () => { // ); // const builderAccBefore: RevenueShareAccount = // builderClient.program.account.revenueShare.coder.accounts.decodeUnchecked( - // 'RevenueShare', + // 'revenueShare', // builderAccountInfoBefore.data // ); // // await escrowMap.slowSync(); @@ -1599,7 +1600,7 @@ describe('builder codes', () => { // ); // const builderAccAfter: RevenueShareAccount = // builderClient.program.account.revenueShare.coder.accounts.decodeUnchecked( - // 'RevenueShare', + // 'revenueShare', // builderAccountInfoAfter.data // ); // const referrerRewards = builderAccAfter.totalReferrerRewards.sub( diff --git a/tests/testHelpers.ts b/tests/testHelpers.ts index b4a1ca83a6..6d7495d11a 100644 --- a/tests/testHelpers.ts +++ b/tests/testHelpers.ts @@ -1,5 +1,6 @@ -import * as anchor from '@coral-xyz/anchor'; -import { AnchorProvider, Program, Provider } from '@coral-xyz/anchor'; +import * as anchor from '@coral-xyz/anchor-29'; +import { AnchorProvider, Program, Provider } from '@coral-xyz/anchor-29'; +import { Program as Program30 } from '@coral-xyz/anchor'; import { AccountLayout, MintLayout, @@ -62,6 +63,7 @@ import { } from '../sdk/src/bankrun/bankrunConnection'; import pythIDL from '../sdk/src/idl/pyth.json'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { Drift } from '../sdk/src/idl/drift'; export async function mockOracle( price: number = 50 * 10e7, @@ -99,19 +101,13 @@ export async function mockOracleNoProgram( expo = -7, confidence?: number ): Promise { - const provider = new AnchorProvider( - context.connection.toConnection(), - context.provider.wallet, - { - commitment: 'processed', - } - ); + // Use the existing provider from context instead of creating a new one + const provider = context.provider; - const program = new Program( - pythIDL as anchor.Idl, - new PublicKey('FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH'), - provider + const programId = new PublicKey( + 'FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH' ); + const program = new Program(pythIDL as anchor.Idl, programId, provider); const priceFeedAddress = await createPriceFeedBankrun({ oracleProgram: program, @@ -399,7 +395,7 @@ export async function createUSDCAccountForUser( export async function initializeAndSubscribeDriftClient( connection: Connection, - program: Program, + program: Program30, userKeyPair: Keypair, marketIndexes: number[], bankIndexes: number[], @@ -437,7 +433,7 @@ export async function initializeAndSubscribeDriftClient( export async function createUserWithUSDCAccount( context: BankrunContextWrapper, usdcMint: Keypair, - chProgram: Program, + chProgram: Program30, usdcAmount: BN, marketIndexes: number[], bankIndexes: number[], @@ -522,7 +518,7 @@ export async function fundWsolTokenAccountForUser( export async function createUserWithUSDCAndWSOLAccount( context: BankrunContextWrapper, usdcMint: Keypair, - chProgram: Program, + chProgram: Program30, solAmount: BN, usdcAmount: BN, marketIndexes: number[], @@ -1384,7 +1380,7 @@ export async function placeAndFillVammTrade({ export async function overwriteConstituentAccount( bankrunContextWrapper: BankrunContextWrapper, - program: Program, + program: Program30, constituentPublicKey: PublicKey, overwriteFields: Array<[key: keyof ConstituentAccount, value: any]> ) { diff --git a/yarn.lock b/yarn.lock index 2f449466ab..a84652fca3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -652,6 +652,27 @@ rpc-websockets "^7.5.0" superstruct "^0.14.2" +"@solana/web3.js@1.98.0": + version "1.98.0" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.0.tgz#21ecfe8198c10831df6f0cfde7f68370d0405917" + integrity sha512-nz3Q5OeyGFpFCR+erX2f6JPt3sKhzhYcSycBCSPkWjzSVDh/Rr1FqTVMRe58FKO16/ivTUcuJjeS5MyBvpkbzA== + dependencies: + "@babel/runtime" "^7.25.0" + "@noble/curves" "^1.4.2" + "@noble/hashes" "^1.4.0" + "@solana/buffer-layout" "^4.0.1" + agentkeepalive "^4.5.0" + bigint-buffer "^1.1.5" + bn.js "^5.2.1" + borsh "^0.7.0" + bs58 "^4.0.1" + buffer "6.0.3" + fast-stable-stringify "^1.0.0" + jayson "^4.1.1" + node-fetch "^2.7.0" + rpc-websockets "^9.0.2" + superstruct "^2.0.2" + "@solana/web3.js@^1.17.0", "@solana/web3.js@^1.21.0", "@solana/web3.js@^1.36.0", "@solana/web3.js@^1.56.2", "@solana/web3.js@^1.90.0": version "1.98.2" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.2.tgz#45167a5cfb64436944bf4dc1e8be8482bd6d4c14" @@ -763,6 +784,13 @@ dependencies: "@types/node" "*" +"@types/bs58@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@types/bs58/-/bs58-5.0.0.tgz#a5f849d47263b2dfb09846306256c56610d40cb0" + integrity sha512-cAw/jKBzo98m6Xz1X5ETqymWfIMbXbu6nK15W4LQYjeHJkVqSmM5PO8Bd9KVHQJ/F4rHcSso9LcjtgCW6TGu2w== + dependencies: + bs58 "*" + "@types/chai@5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-5.0.0.tgz#7f981e71e69c9b2d422f58f78de1c59179782133" @@ -954,10 +982,10 @@ ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -anchor-bankrun@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/anchor-bankrun/-/anchor-bankrun-0.3.0.tgz#3789fcecbc201a2334cff228b99cc0da8ef0167e" - integrity sha512-PYBW5fWX+iGicIS5MIM/omhk1tQPUc0ELAnI/IkLKQJ6d75De/CQRh8MF2bU/TgGyFi6zEel80wUe3uRol9RrQ== +anchor-bankrun@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/anchor-bankrun/-/anchor-bankrun-0.5.0.tgz#62b5905f6f0ed3799d4a37e6be045887c13d4f33" + integrity sha512-cNTRv7pN9dy+kiyJ3UlNVTg9hAXhY2HtNVNXJbP/2BkS9nOdLV0qKWhgW8UR9Go0gYuEOLKuPzrGL4HFAZPsVw== ansi-regex@5.0.1, ansi-regex@^5.0.1, ansi-regex@^6.0.1: version "5.0.1" @@ -1055,23 +1083,13 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base-x@^3.0.2: +base-x@^3.0.11, base-x@^3.0.2: version "3.0.11" resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.11.tgz#40d80e2a1aeacba29792ccc6c5354806421287ff" integrity sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA== dependencies: safe-buffer "^5.0.1" -base-x@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.1.tgz#817fb7b57143c501f649805cb247617ad016a885" - integrity sha512-uAZ8x6r6S3aUM9rbHGVOIsR15U/ZSc82b3ymnCPsT45Gk1DDvhDPdIgB5MrhirZWt+5K0EEPQH985kNqZgNPFw== - -base-x@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-5.0.1.tgz#16bf35254be1df8aca15e36b7c1dda74b2aa6b03" - integrity sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg== - base64-js@^1.3.1, base64-js@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -1142,27 +1160,13 @@ braces@^3.0.3: dependencies: fill-range "^7.1.1" -bs58@^4.0.0, bs58@^4.0.1: +bs58@*, bs58@^4.0.0, bs58@^4.0.1, bs58@^5.0.0, bs58@^6.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== dependencies: base-x "^3.0.2" -bs58@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" - integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== - dependencies: - base-x "^4.0.0" - -bs58@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-6.0.0.tgz#a2cda0130558535dd281a2f8697df79caaf425d8" - integrity sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw== - dependencies: - base-x "^5.0.0" - buffer-layout@^1.2.0, buffer-layout@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" @@ -2664,44 +2668,44 @@ snake-case@^3.0.4: dot-case "^3.0.4" tslib "^2.0.3" -solana-bankrun-darwin-arm64@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-arm64/-/solana-bankrun-darwin-arm64-0.3.0.tgz#749ce9858bf61c4244a06c4e6d99338daa154909" - integrity sha512-+NbDncf0U6l3knuacRBiqpjZ2DSp+5lZaAU518gH7/x6qubbui/d000STaIBK+uNTPBS/AL/bCN+7PkXqmA3lA== +solana-bankrun-darwin-arm64@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-arm64/-/solana-bankrun-darwin-arm64-0.4.0.tgz#eb0f3dfffb1675f6329a1e026b12d09222b33986" + integrity sha512-6dz78Teoz7ez/3lpRLDjktYLJb79FcmJk2me4/YaB8WiO6W43OdExU4h+d2FyuAryO2DgBPXaBoBNY/8J1HJmw== -solana-bankrun-darwin-universal@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-universal/-/solana-bankrun-darwin-universal-0.3.0.tgz#2d2932282bb1fe719430f2f53060cad3104ebb26" - integrity sha512-1/F0xdMa4qvc5o6z16FCCbZ5jbdvKvxpx5kyPcMWRiRPwyvi+zltMxciPAYMlg3wslQqGz88uFhrBEzq2eTumQ== +solana-bankrun-darwin-universal@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-universal/-/solana-bankrun-darwin-universal-0.4.0.tgz#0ac13ec7637b334b1030e6f51abecc50a254b5de" + integrity sha512-zSSw/Jx3KNU42pPMmrEWABd0nOwGJfsj7nm9chVZ3ae7WQg3Uty0hHAkn5NSDCj3OOiN0py9Dr1l9vmRJpOOxg== -solana-bankrun-darwin-x64@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-x64/-/solana-bankrun-darwin-x64-0.3.0.tgz#c814a13702a12ba085c32b20a66a063cffbe74a1" - integrity sha512-U6CANjkmMl+lgNA7UH0GKs5V7LtVIUDzJBZefGGqLfqUNv3EjA/PrrToM0hAOWJgkxSwdz6zW+p5sw5FmnbXtg== +solana-bankrun-darwin-x64@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-darwin-x64/-/solana-bankrun-darwin-x64-0.4.0.tgz#f863c5a668858b7c44be51376bd05fb077c11c99" + integrity sha512-LWjs5fsgHFtyr7YdJR6r0Ho5zrtzI6CY4wvwPXr8H2m3b4pZe6RLIZjQtabCav4cguc14G0K8yQB2PTMuGub8w== -solana-bankrun-linux-x64-gnu@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-gnu/-/solana-bankrun-linux-x64-gnu-0.3.0.tgz#5c5dec2d4e01f755c9cf8fe9f791a8085bf94f51" - integrity sha512-qJSkCFs0k2n4XtTnyxGMiZsuqO2TiqTYgWjQ+3mZhGNUAMys/Vq8bd7/SyBm6RR7EfVuRXRxZvh+F8oKZ77V4w== +solana-bankrun-linux-x64-gnu@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-gnu/-/solana-bankrun-linux-x64-gnu-0.4.0.tgz#30fd7edaf3ff6585468138d3bed6eaed37878d9e" + integrity sha512-SrlVrb82UIxt21Zr/XZFHVV/h9zd2/nP25PMpLJVLD7Pgl2yhkhfi82xj3OjxoQqWe+zkBJ+uszA0EEKr67yNw== -solana-bankrun-linux-x64-musl@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-musl/-/solana-bankrun-linux-x64-musl-0.3.0.tgz#0df9434f03d1aa704b085f82e40cc6129b8eea09" - integrity sha512-xsS2CS2xb1Sw4ivNXM0gPz/qpW9BX0neSvt/pnok5L330Nu9xlTnKAY8FhzzqOP9P9sJlGRM787Y6d0yYwt6xQ== +solana-bankrun-linux-x64-musl@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun-linux-x64-musl/-/solana-bankrun-linux-x64-musl-0.4.0.tgz#3c870218140b1307dc44b51d2282697c99f2e1e4" + integrity sha512-Nv328ZanmURdYfcLL+jwB1oMzX4ZzK57NwIcuJjGlf0XSNLq96EoaO5buEiUTo4Ls7MqqMyLbClHcrPE7/aKyA== -solana-bankrun@0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/solana-bankrun/-/solana-bankrun-0.3.0.tgz#1183af008e00c565d6708f0c051588589e315d1c" - integrity sha512-YkH7sa8TB/AoRPzG17CXJtYsRIQHEkEqGLz1Vwc13taXhDBkjO7z6NI5JYw7n0ybRymDHwMYTc7sd+5J40TyVQ== +solana-bankrun@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/solana-bankrun/-/solana-bankrun-0.4.0.tgz#a48a7a74ce6c56be4ec7e200336026f65e90b8dc" + integrity sha512-NMmXUipPBkt8NgnyNO3SCnPERP6xT/AMNMBooljGA3+rG6NN8lmXJsKeLqQTiFsDeWD74U++QM/DgcueSWvrIg== dependencies: "@solana/web3.js" "^1.68.0" bs58 "^4.0.1" optionalDependencies: - solana-bankrun-darwin-arm64 "0.3.0" - solana-bankrun-darwin-universal "0.3.0" - solana-bankrun-darwin-x64 "0.3.0" - solana-bankrun-linux-x64-gnu "0.3.0" - solana-bankrun-linux-x64-musl "0.3.0" + solana-bankrun-darwin-arm64 "0.4.0" + solana-bankrun-darwin-universal "0.4.0" + solana-bankrun-darwin-x64 "0.4.0" + solana-bankrun-linux-x64-gnu "0.4.0" + solana-bankrun-linux-x64-musl "0.4.0" spok@^1.4.3: version "1.5.5" From 3224655bccb96b7f0fbf99576a5ad7ea1fd45603 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Thu, 18 Dec 2025 19:06:17 +0800 Subject: [PATCH 23/25] fixing tests --- sdk/src/events/eventSubscriber.ts | 3 +- sdk/src/events/parse.ts | 11 +-- sdk/src/events/types.ts | 80 ++++++++++----------- sdk/src/oracles/prelaunchOracleClient.ts | 2 +- sdk/src/oracles/pythLazerClient.ts | 2 +- sdk/src/oracles/switchboardClient.ts | 2 +- sdk/tests/amm/test.ts | 4 +- sdk/tests/ci/verifyConstants.ts | 1 + sdk/tests/decode/test.ts | 2 +- sdk/tests/dlob/helpers.ts | 6 +- tests/admin.ts | 29 ++++---- tests/adminDeposit.ts | 2 +- tests/assetTier.ts | 2 +- tests/cancelAllOrders.ts | 2 +- tests/cappedSymFunding.ts | 30 ++++---- tests/curve.ts | 2 +- tests/deleteInitializedSpotMarket.ts | 2 +- tests/delistMarket.ts | 2 +- tests/delistMarketLiq.ts | 2 +- tests/depositIntoSpotMarketVault.ts | 2 +- tests/driftClient.ts | 18 ++--- tests/fillSpot.ts | 2 +- tests/forceUserDelete.ts | 2 +- tests/fuel.ts | 4 +- tests/fuelSweep.ts | 6 +- tests/govStakeDevnet.ts | 2 +- tests/highLeverageMode.ts | 2 +- tests/ifRebalance.ts | 2 +- tests/imbalancePerpPnl.ts | 6 +- tests/insuranceFundStake.ts | 4 +- tests/ksolver.ts | 2 +- tests/liquidateBorrowForPerpPnl.ts | 2 +- tests/liquidatePerp.ts | 6 +- tests/liquidatePerpPnlForDeposit.ts | 2 +- tests/liquidatePerpWithFill.ts | 2 +- tests/liquidateSpot.ts | 5 +- tests/liquidateSpotSocialLoss.ts | 2 +- tests/liquidateSpotWithSwap.ts | 2 +- tests/lpPool.ts | 6 +- tests/lpPoolCUs.ts | 9 +-- tests/lpPoolSwap.ts | 14 ++-- tests/marketOrder.ts | 7 +- tests/marketOrderBaseAssetAmount.ts | 10 +-- tests/maxDeposit.ts | 2 +- tests/modifyOrder.ts | 2 +- tests/multipleMakerOrders.ts | 2 +- tests/multipleSpotMakerOrders.ts | 2 +- tests/openbookHelpers.ts | 2 +- tests/openbookTest.ts | 10 +-- tests/oracleDiffSources.ts | 2 +- tests/oracleFillPriceGuardrails.ts | 6 +- tests/oracleOffsetOrders.ts | 2 +- tests/order.ts | 14 ++-- tests/ordersWithSpread.ts | 8 +-- tests/overwritePerpAccounts.ts | 1 - tests/pauseDepositWithdraw.ts | 2 +- tests/pauseExchange.ts | 2 +- tests/phoenixTest.ts | 8 +-- tests/placeAndMakePerp.ts | 2 +- tests/placeAndMakeSignedMsg.ts | 2 +- tests/placeAndMakeSignedMsgBankrun.ts | 11 +-- tests/placeAndMakeSpotOrder.ts | 2 +- tests/postOnly.ts | 6 +- tests/postOnlyAmmFulfillment.ts | 4 +- tests/prelisting.ts | 2 +- tests/prepegMarketOrderBaseAssetAmount.ts | 12 ++-- tests/pyth.ts | 4 +- tests/pythLazer.ts | 2 +- tests/pythLazerBankrun.ts | 2 +- tests/pythPull.ts | 2 +- tests/referrer.ts | 4 +- tests/repegAndSpread.ts | 16 ++--- tests/resizeSwiftUserOrderIds.ts | 2 +- tests/roundInFavorBaseAsset.ts | 2 +- tests/serumTest.ts | 10 +-- tests/settlePNLInvariant.ts | 2 +- tests/signedMsgWsDelegates.ts | 2 +- tests/spotDepositWithdraw.ts | 8 +-- tests/spotDepositWithdraw22.ts | 8 +-- tests/spotDepositWithdraw22ScaledUI.ts | 2 +- tests/spotDepositWithdraw22TransferHooks.ts | 2 +- tests/spotMarketPoolIds.ts | 2 +- tests/spotSwap.ts | 25 +++---- tests/spotSwap22.ts | 8 +-- tests/spotWithdrawUtil100.ts | 14 ++-- tests/stopLimits.ts | 6 +- tests/subaccounts.ts | 2 +- tests/surgePricing.ts | 2 +- tests/switchOracle.ts | 2 +- tests/switchboardOnDemand.ts | 2 +- tests/switchboardTxCus.ts | 2 +- tests/tokenFaucet.ts | 2 +- tests/transferPerpPosition.ts | 2 +- tests/transferPools.ts | 2 +- tests/triggerOrders.ts | 2 +- tests/triggerSpotOrder.ts | 2 +- tests/updateAMM.ts | 2 +- tests/updateK.ts | 2 +- tests/userAccount.ts | 2 +- tests/userDelegate.ts | 2 +- tests/userOrderId.ts | 2 +- tests/whitelist.ts | 2 +- 102 files changed, 278 insertions(+), 288 deletions(-) diff --git a/sdk/src/events/eventSubscriber.ts b/sdk/src/events/eventSubscriber.ts index 6866dcd091..ebac32ce25 100644 --- a/sdk/src/events/eventSubscriber.ts +++ b/sdk/src/events/eventSubscriber.ts @@ -24,6 +24,7 @@ import StrictEventEmitter from 'strict-event-emitter-types'; import { getSortFn } from './sort'; import { parseLogs } from './parse'; import { EventsServerLogProvider } from './eventsServerLogProvider'; +import { Drift } from '../idl/drift'; export class EventSubscriber { private address: PublicKey; @@ -40,7 +41,7 @@ export class EventSubscriber { public constructor( private connection: Connection, - private program: Program, + private program: Program, private options: EventSubscriptionOptions = DefaultEventSubscriptionOptions ) { this.options = Object.assign({}, DefaultEventSubscriptionOptions, options); diff --git a/sdk/src/events/parse.ts b/sdk/src/events/parse.ts index 9bc4849e6b..dbaff4a480 100644 --- a/sdk/src/events/parse.ts +++ b/sdk/src/events/parse.ts @@ -1,5 +1,6 @@ -import { Program, Event } from '@coral-xyz/anchor-29'; +import { Program, Event } from '@coral-xyz/anchor'; import { CuUsageEvent } from './types'; +import { Drift } from '../idl/drift'; const driftProgramId = 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; const PROGRAM_LOG = 'Program log: '; @@ -10,7 +11,7 @@ const PROGRAM_DATA_START_INDEX = PROGRAM_DATA.length; const PROGRAM_INSTRUCTION_START_INDEX = PROGRAM_INSTRUCTION.length; export function parseLogs( - program: Program, + program: Program, logs: string[], programId = driftProgramId ): Event[] { @@ -19,7 +20,7 @@ export function parseLogs( } export function parseLogsWithRaw( - program: Program, + program: Program, logs: string[], programId = driftProgramId ): { events: Event[]; rawLogs: string[] } { @@ -54,7 +55,7 @@ export function parseLogsWithRaw( function handleLog( execution: ExecutionContext, log: string, - program: Program, + program: Program, programId = driftProgramId ): [Event | null, string | null, boolean] { // Executing program is drift program. @@ -70,7 +71,7 @@ function handleLog( // Handles logs from *drift* program. function handleProgramLog( log: string, - program: Program, + program: Program, programId = driftProgramId ): [Event | null, string | null, boolean] { // This is a `msg!` log or a `sol_log_data` log. diff --git a/sdk/src/events/types.ts b/sdk/src/events/types.ts index 69ea7e078d..d4a31d8c9e 100644 --- a/sdk/src/events/types.ts +++ b/sdk/src/events/types.ts @@ -44,27 +44,27 @@ export type EventSubscriptionOptions = { export const DefaultEventSubscriptionOptions: EventSubscriptionOptions = { eventTypes: [ - 'DepositRecord', - 'FundingPaymentRecord', - 'LiquidationRecord', - 'OrderRecord', - 'OrderActionRecord', - 'FundingRateRecord', - 'NewUserRecord', - 'SettlePnlRecord', + 'depositRecord', + 'fundingPaymentRecord', + 'liquidationRecord', + 'orderRecord', + 'orderActionRecord', + 'fundingRateRecord', + 'newUserRecord', + 'settlePnlRecord', 'LPRecord', - 'InsuranceFundRecord', - 'SpotInterestRecord', - 'InsuranceFundStakeRecord', - 'CurveRecord', - 'SwapRecord', - 'SpotMarketVaultDepositRecord', - 'SignedMsgOrderRecord', - 'DeleteUserRecord', - 'FuelSweepRecord', - 'FuelSeasonRecord', - 'InsuranceFundSwapRecord', - 'TransferProtocolIfSharesToRevenuePoolRecord', + 'insuranceFundRecord', + 'spotInterestRecord', + 'insuranceFundStakeRecord', + 'curveRecord', + 'swapRecord', + 'spotMarketVaultDepositRecord', + 'signedMsgOrderRecord', + 'deleteUserRecord', + 'fuelSweepRecord', + 'fuelSeasonRecord', + 'insuranceFundSwapRecord', + 'transferProtocolIfSharesToRevenuePoolRecord', 'LPMintRedeemRecord', 'LPSettleRecord', 'LPSwapRecord', @@ -96,27 +96,27 @@ export type WrappedEvent = EventMap[Type] & { export type WrappedEvents = WrappedEvent[]; export type EventMap = { - DepositRecord: Event; - FundingPaymentRecord: Event; - LiquidationRecord: Event; - FundingRateRecord: Event; - OrderRecord: Event; - OrderActionRecord: Event; - SettlePnlRecord: Event; - NewUserRecord: Event; + depositRecord: Event; + fundingPaymentRecord: Event; + liquidationRecord: Event; + fundingRateRecord: Event; + orderRecord: Event; + orderActionRecord: Event; + settlePnlRecord: Event; + newUserRecord: Event; LPRecord: Event; - InsuranceFundRecord: Event; - SpotInterestRecord: Event; - InsuranceFundStakeRecord: Event; - CurveRecord: Event; - SwapRecord: Event; - SpotMarketVaultDepositRecord: Event; - SignedMsgOrderRecord: Event; - DeleteUserRecord: Event; - FuelSweepRecord: Event; - FuelSeasonRecord: Event; - InsuranceFundSwapRecord: Event; - TransferProtocolIfSharesToRevenuePoolRecord: Event; + insuranceFundRecord: Event; + spotInterestRecord: Event; + insuranceFundStakeRecord: Event; + curveRecord: Event; + swapRecord: Event; + spotMarketVaultDepositRecord: Event; + signedMsgOrderRecord: Event; + deleteUserRecord: Event; + fuelSweepRecord: Event; + fuelSeasonRecord: Event; + insuranceFundSwapRecord: Event; + transferProtocolIfSharesToRevenuePoolRecord: Event; LPSettleRecord: Event; LPMintRedeemRecord: Event; LPSwapRecord: Event; diff --git a/sdk/src/oracles/prelaunchOracleClient.ts b/sdk/src/oracles/prelaunchOracleClient.ts index 3a55f9fc7d..c9c4a60364 100644 --- a/sdk/src/oracles/prelaunchOracleClient.ts +++ b/sdk/src/oracles/prelaunchOracleClient.ts @@ -23,7 +23,7 @@ export class PrelaunchOracleClient implements OracleClient { public getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData { const prelaunchOracle = this.program.account.prelaunchOracle.coder.accounts.decodeUnchecked( - 'PrelaunchOracle', + 'prelaunchOracle', buffer ) as PrelaunchOracle; diff --git a/sdk/src/oracles/pythLazerClient.ts b/sdk/src/oracles/pythLazerClient.ts index bbf077092b..7f35871a12 100644 --- a/sdk/src/oracles/pythLazerClient.ts +++ b/sdk/src/oracles/pythLazerClient.ts @@ -49,7 +49,7 @@ export class PythLazerClient implements OracleClient { } public getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData { - const priceData = this.decodeFunc('PythLazerOracle', buffer); + const priceData = this.decodeFunc('pythLazerOracle', buffer); const confidence = convertPythPrice( priceData.conf, priceData.exponent, diff --git a/sdk/src/oracles/switchboardClient.ts b/sdk/src/oracles/switchboardClient.ts index bd3036a3f1..e93c1c86f7 100644 --- a/sdk/src/oracles/switchboardClient.ts +++ b/sdk/src/oracles/switchboardClient.ts @@ -37,7 +37,7 @@ export class SwitchboardClient implements OracleClient { public getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData { const aggregatorAccountData = this.coder.decodeUnchecked( - 'AggregatorAccountData', + 'aggregatorAccountData', buffer ) as AggregatorAccountData; diff --git a/sdk/tests/amm/test.ts b/sdk/tests/amm/test.ts index 97c36577ec..ab849c57d6 100644 --- a/sdk/tests/amm/test.ts +++ b/sdk/tests/amm/test.ts @@ -812,7 +812,7 @@ describe('AMM Tests', () => { const maxOffset = Math.max( mockAmm.maxSpread / 5, (PERCENTAGE_PRECISION.toNumber() / 10000) * - (mockAmm.curveUpdateIntensity - 100) + (mockAmm.curveUpdateIntensity - 100) ); const liquidityFraction = calculateInventoryLiquidityRatio( mockAmm.baseAssetAmountWithAmm, @@ -1025,7 +1025,7 @@ describe('AMM Tests', () => { const maxOffset = Math.max( mockAmm.maxSpread / 5, (PERCENTAGE_PRECISION.toNumber() / 10000) * - (mockAmm.curveUpdateIntensity - 100) + (mockAmm.curveUpdateIntensity - 100) ); const liquidityFraction = calculateInventoryLiquidityRatio( mockAmm.baseAssetAmountWithAmm, diff --git a/sdk/tests/ci/verifyConstants.ts b/sdk/tests/ci/verifyConstants.ts index 08f78696ef..cb99855a1d 100644 --- a/sdk/tests/ci/verifyConstants.ts +++ b/sdk/tests/ci/verifyConstants.ts @@ -22,6 +22,7 @@ describe('Verify Constants', function () { // avoid breaking pre-commit if (MAINNET_RPC_ENDPOINT === undefined || DEVNET_RPC_ENDPOINT === undefined) { + console.warn('expected MAINNET_RPC_ENDPOINT && DEVNET_RPC_ENDPOINT is set'); return; } diff --git a/sdk/tests/decode/test.ts b/sdk/tests/decode/test.ts index 2ddbd37bce..ebc9641bfd 100644 --- a/sdk/tests/decode/test.ts +++ b/sdk/tests/decode/test.ts @@ -138,7 +138,7 @@ function testUserAccountDecode(program: Program, buffer: Buffer, i: number) { assert(anchorUserAccount.maxMarginRatio === customUserAccount.maxMarginRatio); assert( anchorUserAccount.isMarginTradingEnabled === - customUserAccount.isMarginTradingEnabled + customUserAccount.isMarginTradingEnabled ); assert(anchorUserAccount.idle === customUserAccount.idle); assert(anchorUserAccount.openOrders === customUserAccount.openOrders); diff --git a/sdk/tests/dlob/helpers.ts b/sdk/tests/dlob/helpers.ts index 3af37c6940..f5dd69f33d 100644 --- a/sdk/tests/dlob/helpers.ts +++ b/sdk/tests/dlob/helpers.ts @@ -689,9 +689,9 @@ export class MockUserMap implements UserMapInterface { }); } - public async subscribe(): Promise { } + public async subscribe(): Promise {} - public async unsubscribe(): Promise { } + public async unsubscribe(): Promise {} public async addPubkey(userAccountPublicKey: PublicKey): Promise { const user = new User({ @@ -750,7 +750,7 @@ export class MockUserMap implements UserMapInterface { ); } - public async updateWithOrderRecord(_record: OrderRecord): Promise { } + public async updateWithOrderRecord(_record: OrderRecord): Promise {} public values(): IterableIterator { return this.userMap.values(); diff --git a/tests/admin.ts b/tests/admin.ts index d259fc657e..ec69751584 100644 --- a/tests/admin.ts +++ b/tests/admin.ts @@ -32,7 +32,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { createTransferCheckedInstruction } from '@solana/spl-token'; describe('admin', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; @@ -131,8 +131,7 @@ describe('admin', () => { await driftClient.fetchAccounts(); assert( driftClient.getPerpMarketAccount(0).amm.ammJitIntensity == 0, - `amm jit intensity does not match \n actual: ${ - driftClient.getPerpMarketAccount(0).amm.ammJitIntensity + `amm jit intensity does not match \n actual: ${driftClient.getPerpMarketAccount(0).amm.ammJitIntensity } \n expected: 0` ); @@ -140,8 +139,7 @@ describe('admin', () => { await driftClient.fetchAccounts(); assert( driftClient.getPerpMarketAccount(0).amm.ammJitIntensity == 100, - `amm jit intensity does not match \n actual: ${ - driftClient.getPerpMarketAccount(0).amm.ammJitIntensity + `amm jit intensity does not match \n actual: ${driftClient.getPerpMarketAccount(0).amm.ammJitIntensity } \n expected: 100` ); @@ -149,8 +147,7 @@ describe('admin', () => { await driftClient.fetchAccounts(); assert( driftClient.getPerpMarketAccount(0).amm.ammJitIntensity == 50, - `amm jit intensity does not match \n actual: ${ - driftClient.getPerpMarketAccount(0).amm.ammJitIntensity + `amm jit intensity does not match \n actual: ${driftClient.getPerpMarketAccount(0).amm.ammJitIntensity } \n expected: 50` ); }); @@ -189,7 +186,7 @@ describe('admin', () => { assert( JSON.stringify(newFeeStructure) === - JSON.stringify(state.perpFeeStructure), + JSON.stringify(state.perpFeeStructure), `fee structure does not match \n actual: ${JSON.stringify( state.perpFeeStructure )} \n expected: ${JSON.stringify(newFeeStructure)}` @@ -207,7 +204,7 @@ describe('admin', () => { assert( JSON.stringify(newFeeStructure) === - JSON.stringify(state.spotFeeStructure), + JSON.stringify(state.spotFeeStructure), `fee structure does not match \n actual: ${JSON.stringify( state.spotFeeStructure )} \n expected: ${JSON.stringify(newFeeStructure)}` @@ -235,7 +232,7 @@ describe('admin', () => { assert( JSON.stringify(oracleGuardRails) === - JSON.stringify(state.oracleGuardRails), + JSON.stringify(state.oracleGuardRails), `oracle guard rails does not match \n actual: ${JSON.stringify( state.oracleGuardRails )} \n expected: ${JSON.stringify(oracleGuardRails)}` @@ -281,7 +278,7 @@ describe('admin', () => { ); assert( JSON.stringify(market.amm.oracleSource) === - JSON.stringify(newOracleSource), + JSON.stringify(newOracleSource), `oracle source does not match \n actual: ${JSON.stringify( market.amm.oracleSource )} \n expected: ${JSON.stringify(newOracleSource)}` @@ -381,11 +378,9 @@ describe('admin', () => { const state = driftClient.getStateAccount(); assert( state.exchangeStatus === - (ExchangeStatus.DEPOSIT_PAUSED | ExchangeStatus.WITHDRAW_PAUSED), - `exchange status does not match \n actual: ${ - state.exchangeStatus - } \n expected: ${ - ExchangeStatus.DEPOSIT_PAUSED | ExchangeStatus.WITHDRAW_PAUSED + (ExchangeStatus.DEPOSIT_PAUSED | ExchangeStatus.WITHDRAW_PAUSED), + `exchange status does not match \n actual: ${state.exchangeStatus + } \n expected: ${ExchangeStatus.DEPOSIT_PAUSED | ExchangeStatus.WITHDRAW_PAUSED }` ); @@ -480,7 +475,7 @@ describe('admin', () => { const perpMarket = driftClient.getPerpMarketAccount(0); assert( perpMarket.amm.referencePriceOffsetDeadbandPct == - referenceOffsetDeadbandPct + referenceOffsetDeadbandPct ); }); diff --git a/tests/adminDeposit.ts b/tests/adminDeposit.ts index 2eee301d8c..0781a12365 100644 --- a/tests/adminDeposit.ts +++ b/tests/adminDeposit.ts @@ -25,7 +25,7 @@ import dotenv from 'dotenv'; dotenv.config(); describe('admin deposit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/assetTier.ts b/tests/assetTier.ts index 0c1797b4ba..73a285a851 100644 --- a/tests/assetTier.ts +++ b/tests/assetTier.ts @@ -42,7 +42,7 @@ import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; import { ContractTier } from '../sdk'; describe('asset tiers', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/cancelAllOrders.ts b/tests/cancelAllOrders.ts index d3cd08fcdb..06c5a2b0f8 100644 --- a/tests/cancelAllOrders.ts +++ b/tests/cancelAllOrders.ts @@ -24,7 +24,7 @@ import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; import { isVariant } from '../sdk'; describe('cancel all orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/cappedSymFunding.ts b/tests/cappedSymFunding.ts index a95fa58e1e..a0f822c6c0 100644 --- a/tests/cappedSymFunding.ts +++ b/tests/cappedSymFunding.ts @@ -76,10 +76,10 @@ async function updateFundingRateHelper( frontEndFundingCalc0, 'markTwap0:', ammAccountState0.lastMarkPriceTwap.toNumber() / - PRICE_PRECISION.toNumber(), + PRICE_PRECISION.toNumber(), 'oracleTwap0:', ammAccountState0.historicalOracleData.lastOraclePriceTwap.toNumber() / - PRICE_PRECISION.toNumber(), + PRICE_PRECISION.toNumber(), 'markTwap0:', ammAccountState0.lastMarkPriceTwap.toNumber(), 'oracleTwapPyth:', @@ -137,10 +137,10 @@ async function updateFundingRateHelper( assert(ammAccountState.lastFundingRate.abs().gte(lastFundingLong.abs())); console.log( convertToNumber(ammAccountState.lastFundingRate.abs()) / - FUNDING_RATE_BUFFER_PRECISION.toNumber(), + FUNDING_RATE_BUFFER_PRECISION.toNumber(), '>=', convertToNumber(lastFundingShort.abs()) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); assert(ammAccountState.lastFundingRate.abs().gte(lastFundingShort.abs())); @@ -153,9 +153,9 @@ async function updateFundingRateHelper( const priceSpread = ammAccountState.lastMarkPriceTwap.toNumber() / - PRICE_PRECISION.toNumber() - + PRICE_PRECISION.toNumber() - ammAccountState.historicalOracleData.lastOraclePriceTwap.toNumber() / - PRICE_PRECISION.toNumber(); + PRICE_PRECISION.toNumber(); const frontEndFundingCalc = priceSpread / ((24 * 3600) / Math.max(1, peroidicity.toNumber())); @@ -166,7 +166,7 @@ async function updateFundingRateHelper( ammAccountState.lastMarkPriceTwap.toNumber() / PRICE_PRECISION.toNumber(), 'oracleTwap:', ammAccountState.historicalOracleData.lastOraclePriceTwap.toNumber() / - PRICE_PRECISION.toNumber(), + PRICE_PRECISION.toNumber(), 'markTwap:', ammAccountState.lastMarkPriceTwap.toNumber(), 'oracleTwapPyth:', @@ -449,7 +449,7 @@ async function cappedSymFundingScenario( } describe('capped funding', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; @@ -829,15 +829,15 @@ describe('capped funding', () => { console.log( 'clamped funding:', convertToNumber(clampedFundingRate) / - FUNDING_RATE_BUFFER_PRECISION.toNumber(), + FUNDING_RATE_BUFFER_PRECISION.toNumber(), 'hourly pct:', convertToNumber(clampedFundingRatePct) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); console.log( 'short funding:', convertToNumber(fundingRateShort) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); assert(fundingRateShort.abs().eq(fundingRateLong.abs())); @@ -924,15 +924,15 @@ describe('capped funding', () => { console.log( 'clamped funding:', convertToNumber(clampedFundingRate) / - FUNDING_RATE_BUFFER_PRECISION.toNumber(), + FUNDING_RATE_BUFFER_PRECISION.toNumber(), 'hourly pct:', convertToNumber(clampedFundingRatePct) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); console.log( 'short funding:', convertToNumber(fundingRateShort) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); assert(fundingRateShort.abs().gt(fundingRateLong.abs())); @@ -981,7 +981,7 @@ describe('capped funding', () => { ); assert( feeAlloced + Math.abs(fundingPnLForShortsNum) >= - fundingPnLForLongsNum + 1e-6 + fundingPnLForLongsNum + 1e-6 ); }); it('capped sym funding: ($2000 long, $1000 short, oracle > mark)', async () => { diff --git a/tests/curve.ts b/tests/curve.ts index ff47909549..766271720f 100644 --- a/tests/curve.ts +++ b/tests/curve.ts @@ -32,7 +32,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('AMM Curve', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/deleteInitializedSpotMarket.ts b/tests/deleteInitializedSpotMarket.ts index f66267e3e8..06468e3098 100644 --- a/tests/deleteInitializedSpotMarket.ts +++ b/tests/deleteInitializedSpotMarket.ts @@ -27,7 +27,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('max deposit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/delistMarket.ts b/tests/delistMarket.ts index 82c50bd364..6b4008b933 100644 --- a/tests/delistMarket.ts +++ b/tests/delistMarket.ts @@ -83,7 +83,7 @@ describe('delist market', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { diff --git a/tests/delistMarketLiq.ts b/tests/delistMarketLiq.ts index ddc41d8a7b..7dad779673 100644 --- a/tests/delistMarketLiq.ts +++ b/tests/delistMarketLiq.ts @@ -68,7 +68,7 @@ describe('delist market, liquidation of expired position', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { diff --git a/tests/depositIntoSpotMarketVault.ts b/tests/depositIntoSpotMarketVault.ts index 476d984613..58638eee0f 100644 --- a/tests/depositIntoSpotMarketVault.ts +++ b/tests/depositIntoSpotMarketVault.ts @@ -28,7 +28,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/driftClient.ts b/tests/driftClient.ts index 6271269e39..73f5fa45ac 100644 --- a/tests/driftClient.ts +++ b/tests/driftClient.ts @@ -36,7 +36,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('drift client', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -226,7 +226,7 @@ describe('drift client', () => { assert.ok( JSON.stringify(depositRecord.direction) === - JSON.stringify({ deposit: {} }) + JSON.stringify({ deposit: {} }) ); assert.ok(depositRecord.amount.eq(new BN(10000000))); }); @@ -267,7 +267,7 @@ describe('drift client', () => { assert.ok( JSON.stringify(depositRecord.direction) === - JSON.stringify({ withdraw: {} }) + JSON.stringify({ withdraw: {} }) ); assert.ok(depositRecord.amount.eq(new BN(10000000))); }); @@ -296,7 +296,7 @@ describe('drift client', () => { marketData.amm.oracle ); - const orderR = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderR = eventSubscriber.getEventsArray('orderActionRecord')[0]; console.log(orderR.takerFee.toString()); console.log(orderR.baseAssetAmountFilled.toString()); @@ -330,7 +330,7 @@ describe('drift client', () => { assert.ok(market.amm.totalFeeMinusDistributions.eq(new BN(48001))); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderActionRecord.taker.equals(userAccountPublicKey)); assert.ok(orderActionRecord.fillRecordId.eq(new BN(1))); @@ -417,7 +417,7 @@ describe('drift client', () => { assert.ok(market.amm.totalFeeMinusDistributions.eq(new BN(72001))); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderActionRecord.taker.equals(userAccountPublicKey)); assert.ok(orderActionRecord.fillRecordId.eq(new BN(2))); assert.ok(orderActionRecord.baseAssetAmountFilled.eq(new BN(24000000000))); @@ -486,7 +486,7 @@ describe('drift client', () => { assert.ok(market.amm.totalFeeMinusDistributions.eq(new BN(120001))); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderActionRecord.taker.equals(userAccountPublicKey)); assert.ok(orderActionRecord.fillRecordId.eq(new BN(3))); console.log(orderActionRecord.baseAssetAmountFilled.toNumber()); @@ -539,7 +539,7 @@ describe('drift client', () => { assert.ok(market.amm.totalFeeMinusDistributions.eq(new BN(144001))); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderActionRecord.taker.equals(userAccountPublicKey)); assert.ok(orderActionRecord.fillRecordId.eq(new BN(4))); @@ -575,7 +575,7 @@ describe('drift client', () => { assert.ok(market.amm.baseAssetAmountWithAmm.eq(new BN(-48000000000))); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderActionRecord.taker.equals(userAccountPublicKey)); assert.ok(orderActionRecord.fillRecordId.eq(new BN(5))); diff --git a/tests/fillSpot.ts b/tests/fillSpot.ts index 2b141d1254..e7dcd89d6e 100644 --- a/tests/fillSpot.ts +++ b/tests/fillSpot.ts @@ -31,7 +31,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('place and fill spot order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; diff --git a/tests/forceUserDelete.ts b/tests/forceUserDelete.ts index d224e6c7ec..e7fbbf29aa 100644 --- a/tests/forceUserDelete.ts +++ b/tests/forceUserDelete.ts @@ -30,7 +30,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/fuel.ts b/tests/fuel.ts index 4514836014..dc41d96f70 100644 --- a/tests/fuel.ts +++ b/tests/fuel.ts @@ -36,7 +36,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe("fuelin'", () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; @@ -291,7 +291,7 @@ describe("fuelin'", () => { assert( Math.abs( fuelDictInit['insuranceFuel'].toNumber() - - fuelDictInit2['insuranceFuel'].toNumber() + fuelDictInit2['insuranceFuel'].toNumber() ) <= 1 ); diff --git a/tests/fuelSweep.ts b/tests/fuelSweep.ts index a6890c45d8..c356b5f009 100644 --- a/tests/fuelSweep.ts +++ b/tests/fuelSweep.ts @@ -27,7 +27,7 @@ import dotenv from 'dotenv'; dotenv.config(); describe('fuel sweep', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -104,7 +104,7 @@ describe('fuel sweep', () => { ); assert.isFalse( (userStatsBefore.data.fuelOverflowStatus & FuelOverflowStatus.Exists) === - FuelOverflowStatus.Exists, + FuelOverflowStatus.Exists, 'FuelOverflow account should not exist' ); userStatsBefore.data.fuelTaker = 1_000_000_000; @@ -229,7 +229,7 @@ describe('fuel sweep', () => { ); assert.isTrue( (userStatsBefore.data.fuelOverflowStatus & FuelOverflowStatus.Exists) === - FuelOverflowStatus.Exists, + FuelOverflowStatus.Exists, 'FuelSweep account should exist' ); diff --git a/tests/govStakeDevnet.ts b/tests/govStakeDevnet.ts index bd7de44653..e1759a3d62 100644 --- a/tests/govStakeDevnet.ts +++ b/tests/govStakeDevnet.ts @@ -24,7 +24,7 @@ import { dotenv.config(); describe('gov stake increase on devnet', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerDriftClientUser: User; let eventSubscriber: EventSubscriber; diff --git a/tests/highLeverageMode.ts b/tests/highLeverageMode.ts index 2cfbb4ef2b..0c2cd1bba7 100644 --- a/tests/highLeverageMode.ts +++ b/tests/highLeverageMode.ts @@ -37,7 +37,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('max leverage order params', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; let bankrunContextWrapper: BankrunContextWrapper; diff --git a/tests/ifRebalance.ts b/tests/ifRebalance.ts index dcf4373dbf..b6e731d79d 100644 --- a/tests/ifRebalance.ts +++ b/tests/ifRebalance.ts @@ -43,7 +43,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot swap', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerWSOL: PublicKey; diff --git a/tests/imbalancePerpPnl.ts b/tests/imbalancePerpPnl.ts index 84fbf8dd4b..adb21dcc3b 100644 --- a/tests/imbalancePerpPnl.ts +++ b/tests/imbalancePerpPnl.ts @@ -86,7 +86,7 @@ function examineSpread( '$', convertToNumber(spread), spread.mul(BID_ASK_SPREAD_PRECISION).div(oraclePriceData.price).toNumber() / - BID_ASK_SPREAD_PRECISION.toNumber(), + BID_ASK_SPREAD_PRECISION.toNumber(), '%', 'and max (', '$', @@ -100,7 +100,7 @@ function examineSpread( ' margin max=', (market.marginRatioInitial - market.marginRatioMaintenance) / - BID_ASK_SPREAD_PRECISION.toNumber(), + BID_ASK_SPREAD_PRECISION.toNumber(), ')' ); @@ -119,7 +119,7 @@ function examineSpread( } describe('imbalanced large perp pnl w/ borrow hitting limits', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/insuranceFundStake.ts b/tests/insuranceFundStake.ts index 0f67d1814c..75387f3e84 100644 --- a/tests/insuranceFundStake.ts +++ b/tests/insuranceFundStake.ts @@ -52,7 +52,7 @@ import { } from '../sdk/src/bankrun/bankrunConnection'; describe('insurance fund stake', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -1054,7 +1054,7 @@ describe('insurance fund stake', () => { assert( secondUserDriftClient.getUserAccount().status === - UserStatus.BEING_LIQUIDATED + UserStatus.BEING_LIQUIDATED ); assert( diff --git a/tests/ksolver.ts b/tests/ksolver.ts index d3c1d338fc..7f738ec592 100644 --- a/tests/ksolver.ts +++ b/tests/ksolver.ts @@ -166,7 +166,7 @@ describe('AMM Curve', () => { // return kSqrtI; // } - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/liquidateBorrowForPerpPnl.ts b/tests/liquidateBorrowForPerpPnl.ts index f04c9b1310..66a13d3fb5 100644 --- a/tests/liquidateBorrowForPerpPnl.ts +++ b/tests/liquidateBorrowForPerpPnl.ts @@ -35,7 +35,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate borrow for perp pnl', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/liquidatePerp.ts b/tests/liquidatePerp.ts index 8a7dc6120c..e02b8d638c 100644 --- a/tests/liquidatePerp.ts +++ b/tests/liquidatePerp.ts @@ -35,7 +35,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate perp (no open orders)', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -367,7 +367,7 @@ describe('liquidate perp (no open orders)', () => { assert(liquidationRecord.liquidatePerp.ifFee.eq(new BN(0))); assert(liquidationRecord.liquidatePerp.liquidatorFee.eq(new BN(0))); - const fillRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const fillRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(fillRecord.action, 'fill')); assert(fillRecord.marketIndex === 0); assert(isVariant(fillRecord.marketType, 'perp')); @@ -471,7 +471,7 @@ describe('liquidate perp (no open orders)', () => { assert( (driftClient.getUserAccount().status & (UserStatus.BANKRUPT | UserStatus.BEING_LIQUIDATED)) === - 0 + 0 ); console.log(driftClient.getUserAccount()); diff --git a/tests/liquidatePerpPnlForDeposit.ts b/tests/liquidatePerpPnlForDeposit.ts index cb42c23adb..8c49801fdf 100644 --- a/tests/liquidatePerpPnlForDeposit.ts +++ b/tests/liquidatePerpPnlForDeposit.ts @@ -40,7 +40,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate perp pnl for deposit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/liquidatePerpWithFill.ts b/tests/liquidatePerpWithFill.ts index f4d0b61cd3..27b9091735 100644 --- a/tests/liquidatePerpWithFill.ts +++ b/tests/liquidatePerpWithFill.ts @@ -32,7 +32,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate perp (no open orders)', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/liquidateSpot.ts b/tests/liquidateSpot.ts index 9b30c4bb27..126abc7e33 100644 --- a/tests/liquidateSpot.ts +++ b/tests/liquidateSpot.ts @@ -36,9 +36,10 @@ import { PERCENTAGE_PRECISION } from '../sdk'; import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { Drift } from '../sdk/src/idl/drift'; describe('liquidate spot', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -300,7 +301,7 @@ describe('liquidate spot', () => { ); const liquidationRecord = - eventSubscriber.getEventsArray('LiquidationRecord')[0]; + eventSubscriber.getEventsArray('liquidationRecord')[0]; assert(liquidationRecord.liquidationId === 1); assert(isVariant(liquidationRecord.liquidationType, 'liquidateSpot')); assert(liquidationRecord.liquidateSpot.assetPrice.eq(PRICE_PRECISION)); diff --git a/tests/liquidateSpotSocialLoss.ts b/tests/liquidateSpotSocialLoss.ts index 0695db6b18..a5c02d1ef5 100644 --- a/tests/liquidateSpotSocialLoss.ts +++ b/tests/liquidateSpotSocialLoss.ts @@ -33,7 +33,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate spot w/ social loss', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/liquidateSpotWithSwap.ts b/tests/liquidateSpotWithSwap.ts index f6966324ee..7d5626efc7 100644 --- a/tests/liquidateSpotWithSwap.ts +++ b/tests/liquidateSpotWithSwap.ts @@ -38,7 +38,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot swap', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerWSOL: PublicKey; diff --git a/tests/lpPool.ts b/tests/lpPool.ts index b82a5623eb..6cba4c12ea 100644 --- a/tests/lpPool.ts +++ b/tests/lpPool.ts @@ -78,6 +78,7 @@ import { CustomBorshAccountsCoder, CustomBorshCoder, } from '../sdk/src/decode/customCoder'; +import { Drift } from '../sdk/src/idl/drift'; dotenv.config(); const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { @@ -89,9 +90,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('LP Pool', () => { - const program = anchor.workspace.Drift as Program; - // @ts-ignore - program.coder.accounts = new CustomBorshAccountsCoder(program.idl); + const program = anchor.workspace.Drift as Program; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -168,7 +167,6 @@ describe('LP Pool', () => { type: 'polling', accountLoader: bulkAccountLoader, }, - coder: new CustomBorshCoder(program.idl), }); await adminClient.initialize(usdcMint.publicKey, true); await adminClient.subscribe(); diff --git a/tests/lpPoolCUs.ts b/tests/lpPoolCUs.ts index dea540f49e..c02cf69315 100644 --- a/tests/lpPoolCUs.ts +++ b/tests/lpPoolCUs.ts @@ -67,6 +67,7 @@ import { CustomBorshAccountsCoder, CustomBorshCoder, } from '../sdk/src/decode/customCoder'; +import { Drift } from '../sdk/src/idl/drift'; dotenv.config(); const NUMBER_OF_CONSTITUENTS = 10; @@ -95,9 +96,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('LP Pool', () => { - const program = anchor.workspace.Drift as Program; - // @ts-ignore - program.coder.accounts = new CustomBorshAccountsCoder(program.idl); + const program = anchor.workspace.Drift as Program; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -187,7 +186,6 @@ describe('LP Pool', () => { type: 'polling', accountLoader: bulkAccountLoader, }, - coder: new CustomBorshCoder(program.idl), }); await adminClient.initialize(usdcMint.publicKey, true); await adminClient.subscribe(); @@ -352,7 +350,6 @@ describe('LP Pool', () => { type: 'polling', accountLoader: bulkAccountLoader, }, - coder: new CustomBorshCoder(program.idl), }); await adminClient.subscribe(); await sleep(50); @@ -438,7 +435,6 @@ describe('LP Pool', () => { type: 'polling', accountLoader: bulkAccountLoader, }, - coder: new CustomBorshCoder(program.idl), }); await adminClient.subscribe(); }); @@ -464,7 +460,6 @@ describe('LP Pool', () => { type: 'polling', accountLoader: bulkAccountLoader, }, - coder: new CustomBorshCoder(program.idl), }); await userClient.subscribe(); await sleep(100); diff --git a/tests/lpPoolSwap.ts b/tests/lpPoolSwap.ts index 866436c136..338823ae84 100644 --- a/tests/lpPoolSwap.ts +++ b/tests/lpPoolSwap.ts @@ -60,13 +60,11 @@ import { CustomBorshAccountsCoder, CustomBorshCoder, } from '../sdk/src/decode/customCoder'; +import { Drift } from '../sdk/src/idl/drift'; dotenv.config(); describe('LP Pool', () => { - const program = anchor.workspace.Drift as Program; - // Align account (de)serialization with on-chain zero-copy layouts - // @ts-ignore - program.coder.accounts = new CustomBorshAccountsCoder(program.idl); + const program = anchor.workspace.Drift as Program; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -155,8 +153,6 @@ describe('LP Pool', () => { type: 'polling', accountLoader: bulkAccountLoader, }, - // Ensure the client uses the same custom coder - coder: new CustomBorshCoder(program.idl), }); await adminClient.initialize(usdcMint.publicKey, true); await adminClient.subscribe(); @@ -506,13 +502,11 @@ describe('LP Pool', () => { expect(Number(diffOutToken)).to.be.approximately(1001298, 1); console.log( - `in Token: ${inTokenBalanceBefore.amount} -> ${ - inTokenBalanceAfter.amount + `in Token: ${inTokenBalanceBefore.amount} -> ${inTokenBalanceAfter.amount } (${Number(diffInToken) / 1e6})` ); console.log( - `out Token: ${outTokenBalanceBefore.amount} -> ${ - outTokenBalanceAfter.amount + `out Token: ${outTokenBalanceBefore.amount} -> ${outTokenBalanceAfter.amount } (${Number(diffOutToken) / 1e6})` ); }); diff --git a/tests/marketOrder.ts b/tests/marketOrder.ts index f7303296f2..cb904994b7 100644 --- a/tests/marketOrder.ts +++ b/tests/marketOrder.ts @@ -37,9 +37,10 @@ import { import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { Drift } from '../sdk/src/idl/drift'; describe('market order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let driftClientUser: User; @@ -276,7 +277,7 @@ describe('market order', () => { assert(firstPosition.quoteBreakEvenAmount.eq(new BN(-1001002))); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderActionRecord.baseAssetAmountFilled.eq(baseAssetAmount)); assert.ok( @@ -320,7 +321,7 @@ describe('market order', () => { assert(firstPosition.quoteBreakEvenAmount.eq(ZERO)); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderActionRecord.baseAssetAmountFilled.eq(baseAssetAmount)); const expectedQuoteAssetAmount = new BN(1000000); diff --git a/tests/marketOrderBaseAssetAmount.ts b/tests/marketOrderBaseAssetAmount.ts index e541222f97..f59b3000d4 100644 --- a/tests/marketOrderBaseAssetAmount.ts +++ b/tests/marketOrderBaseAssetAmount.ts @@ -19,7 +19,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('market orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -187,7 +187,7 @@ describe('market orders', () => { assert.ok(market.amm.totalFee.eq(new BN(48001))); assert.ok(market.amm.totalFeeMinusDistributions.eq(new BN(48001))); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.taker.equals(userAccountPublicKey)); assert.ok(orderRecord.fillRecordId.eq(new BN(1))); assert.ok(orderRecord.baseAssetAmountFilled.eq(new BN(48000000000))); @@ -254,7 +254,7 @@ describe('market orders', () => { assert.ok(market.amm.totalFee.eq(new BN(72001))); assert.ok(market.amm.totalFeeMinusDistributions.eq(new BN(72001))); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.taker.equals(userAccountPublicKey)); assert.ok(orderRecord.fillRecordId.eq(new BN(2))); @@ -320,7 +320,7 @@ describe('market orders', () => { assert.ok(market.amm.totalFee.eq(new BN(120001))); assert.ok(market.amm.totalFeeMinusDistributions.eq(new BN(120001))); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.taker.equals(userAccountPublicKey)); assert.ok(orderRecord.fillRecordId.eq(new BN(3))); @@ -377,7 +377,7 @@ describe('market orders', () => { assert.ok(market.amm.totalFee.eq(new BN(144001))); assert.ok(market.amm.totalFeeMinusDistributions.eq(new BN(144001))); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.taker.equals(userAccountPublicKey)); assert.ok(orderRecord.fillRecordId.eq(new BN(4))); diff --git a/tests/maxDeposit.ts b/tests/maxDeposit.ts index 626ff2fdec..e761f87faa 100644 --- a/tests/maxDeposit.ts +++ b/tests/maxDeposit.ts @@ -16,7 +16,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('max deposit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/modifyOrder.ts b/tests/modifyOrder.ts index 9f67eea3f2..d914bd6236 100644 --- a/tests/modifyOrder.ts +++ b/tests/modifyOrder.ts @@ -24,7 +24,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('modify orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/multipleMakerOrders.ts b/tests/multipleMakerOrders.ts index af5473510a..35e1b74c3b 100644 --- a/tests/multipleMakerOrders.ts +++ b/tests/multipleMakerOrders.ts @@ -30,7 +30,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('multiple maker orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let fillerDriftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/multipleSpotMakerOrders.ts b/tests/multipleSpotMakerOrders.ts index 411e79e474..4808dfdb8e 100644 --- a/tests/multipleSpotMakerOrders.ts +++ b/tests/multipleSpotMakerOrders.ts @@ -33,7 +33,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('multiple maker orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let fillerDriftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/openbookHelpers.ts b/tests/openbookHelpers.ts index bc0877b9b9..2c50d03aa6 100644 --- a/tests/openbookHelpers.ts +++ b/tests/openbookHelpers.ts @@ -11,7 +11,7 @@ import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, } from '@solana/spl-token'; -import { BN, Program } from '@coral-xyz/anchor'; +import { BN, Program } from '@coral-xyz/anchor-29'; export const OPENBOOK = new PublicKey( 'opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb' diff --git a/tests/openbookTest.ts b/tests/openbookTest.ts index 3d57b25d99..0bf59e3b32 100644 --- a/tests/openbookTest.ts +++ b/tests/openbookTest.ts @@ -1,7 +1,8 @@ import { assert } from 'chai'; -import * as anchor from '@coral-xyz/anchor'; +import * as anchor from '@coral-xyz/anchor-29'; -import { Program, Idl, BN } from '@coral-xyz/anchor'; +import { Program, BN } from '@coral-xyz/anchor'; +import { Program as Program29, Idl as Idl29 } from '@coral-xyz/anchor-29'; import { OracleSource, @@ -36,10 +37,11 @@ import { Keypair } from '@solana/web3.js'; import { LAMPORTS_PRECISION, PRICE_PRECISION } from '../sdk/src'; import { WRAPPED_SOL_MINT } from '../sdk/src'; import { ZERO } from '../sdk'; +import { Drift } from '../sdk/src/idl/drift'; describe('openbook v2', () => { - const chProgram = anchor.workspace.Drift as Program; - const openbookProgram = new Program(openbookIDL as Idl, OPENBOOK); + const chProgram = anchor.workspace.Drift as Program; + const openbookProgram = new Program29(openbookIDL as Idl29, OPENBOOK); let driftClient: TestClient; diff --git a/tests/oracleDiffSources.ts b/tests/oracleDiffSources.ts index 3971f60370..7184ab328f 100644 --- a/tests/oracleDiffSources.ts +++ b/tests/oracleDiffSources.ts @@ -32,7 +32,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('oracle diff sources', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/oracleFillPriceGuardrails.ts b/tests/oracleFillPriceGuardrails.ts index dc0b5758ca..34066370b6 100644 --- a/tests/oracleFillPriceGuardrails.ts +++ b/tests/oracleFillPriceGuardrails.ts @@ -35,7 +35,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('oracle fill guardrails', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let fillerDriftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -240,8 +240,8 @@ describe('oracle fill guardrails', () => { // assert that the const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; - // console.log(eventSubscriber.getEventsArray('OrderActionRecord')); + eventSubscriber.getEventsArray('orderActionRecord')[0]; + // console.log(eventSubscriber.getEventsArray('orderActionRecord')); assert(isVariant(orderActionRecord.action, 'cancel')); await makerDriftClient.placePerpOrder({ diff --git a/tests/oracleOffsetOrders.ts b/tests/oracleOffsetOrders.ts index 2f498c2e5d..d9e13a99bc 100644 --- a/tests/oracleOffsetOrders.ts +++ b/tests/oracleOffsetOrders.ts @@ -34,7 +34,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('oracle offset', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/order.ts b/tests/order.ts index a7e8f1b45d..24a98b12d9 100644 --- a/tests/order.ts +++ b/tests/order.ts @@ -58,7 +58,7 @@ const enumsAreEqual = ( }; describe('orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let driftClientUser: User; @@ -376,7 +376,7 @@ describe('orders', () => { assert(position.openBids.eq(baseAssetAmount)); assert(position.openAsks.eq(ZERO)); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(orderRecord.ts.gt(ZERO)); assert(enumsAreEqual(orderRecord.action, OrderAction.PLACE)); assert( @@ -401,7 +401,7 @@ describe('orders', () => { assert(position.openBids.eq(ZERO)); assert(position.openAsks.eq(ZERO)); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; const expectedOrderId = 1; assert(orderRecord.ts.gt(ZERO)); assert(orderRecord.takerOrderId === expectedOrderId); @@ -505,7 +505,7 @@ describe('orders', () => { assert(firstPosition.quoteEntryAmount.eq(expectedQuoteAssetAmount)); assert(firstPosition.quoteBreakEvenAmount.eq(expectedQuoteBreakEvenAmount)); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.baseAssetAmountFilled.eq(baseAssetAmount)); assert.ok( orderRecord.quoteAssetAmountFilled.eq(expectedQuoteAssetAmount.abs()) @@ -627,7 +627,7 @@ describe('orders', () => { const expectedQuoteAssetAmount = new BN(0); assert(firstPosition.quoteBreakEvenAmount.eq(expectedQuoteAssetAmount)); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.baseAssetAmountFilled.eq(baseAssetAmount)); const expectedTradeQuoteAssetAmount = new BN(1000002); @@ -1555,7 +1555,7 @@ describe('orders', () => { await driftClientUser.fetchAccounts(); console.log('2'); - let orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[1]; + let orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[1]; console.log(orderRecord); assert(orderRecord.baseAssetAmountFilled.eq(AMM_RESERVE_PRECISION)); assert( @@ -1584,7 +1584,7 @@ describe('orders', () => { await driftClient.fetchAccounts(); await driftClientUser.fetchAccounts(); - orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[1]; + orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[1]; assert(orderRecord.baseAssetAmountFilled.eq(AMM_RESERVE_PRECISION)); assert( !isVariant(driftClientUser.getUserAccount().orders[1].status, 'open') diff --git a/tests/ordersWithSpread.ts b/tests/ordersWithSpread.ts index b3d82dc518..0cc203d1d6 100644 --- a/tests/ordersWithSpread.ts +++ b/tests/ordersWithSpread.ts @@ -38,7 +38,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('amm spread: market order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let driftClientUser: User; @@ -241,7 +241,7 @@ describe('amm spread: market order', () => { assert(firstPosition.quoteEntryAmount.eq(expectedQuoteAssetAmount)); assert(firstPosition.quoteBreakEvenAmount.eq(new BN(-1001252))); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.baseAssetAmountFilled.eq(baseAssetAmount)); assert.ok( @@ -330,7 +330,7 @@ describe('amm spread: market order', () => { const unrealizedPnl = driftClientUser.getUnrealizedPNL(); console.log('unrealized pnl', unrealizedPnl.toString()); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.baseAssetAmountFilled.eq(baseAssetAmount)); assert.ok(orderRecord.quoteAssetAmountFilled.eq(expectedQuoteAssetAmount)); @@ -732,7 +732,7 @@ describe('amm spread: market order', () => { assert(firstPosition.quoteEntryAmount.eq(expectedQuoteAssetAmount)); assert(firstPosition.quoteBreakEvenAmount.eq(new BN(-4005043))); //todo - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.baseAssetAmountFilled.eq(baseAssetAmount)); assert.ok( diff --git a/tests/overwritePerpAccounts.ts b/tests/overwritePerpAccounts.ts index 989558f399..f2863c5db0 100644 --- a/tests/overwritePerpAccounts.ts +++ b/tests/overwritePerpAccounts.ts @@ -98,7 +98,6 @@ describe('Bankrun Overwrite Accounts', () => { type: 'polling', accountLoader: bulkAccountLoader, }, - coder: new CustomBorshCoder(program.idl), }); await adminClient.initialize(usdcMint.publicKey, true); await adminClient.subscribe(); diff --git a/tests/pauseDepositWithdraw.ts b/tests/pauseDepositWithdraw.ts index 830cf6d5d3..bacd5192a6 100644 --- a/tests/pauseDepositWithdraw.ts +++ b/tests/pauseDepositWithdraw.ts @@ -40,7 +40,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/pauseExchange.ts b/tests/pauseExchange.ts index 8ca04cd020..e75c499ec8 100644 --- a/tests/pauseExchange.ts +++ b/tests/pauseExchange.ts @@ -23,7 +23,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('Pause exchange', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/phoenixTest.ts b/tests/phoenixTest.ts index 5d1bf8edbc..c3a9ca6741 100644 --- a/tests/phoenixTest.ts +++ b/tests/phoenixTest.ts @@ -553,7 +553,7 @@ describe('phoenix spot market', () => { assert(!isVariant(takerOrder.status, 'open')); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(orderActionRecord.action, 'fill')); assert(orderActionRecord.baseAssetAmountFilled.eq(new BN(1000000000))); assert(orderActionRecord.quoteAssetAmountFilled.eq(new BN(100000000))); @@ -599,7 +599,7 @@ describe('phoenix spot market', () => { assert( phoenixClient.quoteLotsToQuoteAtoms( phoenixMarketEnd.unclaimedQuoteLotFees - - phoenixMarketStart.unclaimedQuoteLotFees, + phoenixMarketStart.unclaimedQuoteLotFees, solMarketAddress.toBase58() ) === orderActionRecord.spotFulfillmentMethodFee.toNumber() ); @@ -717,7 +717,7 @@ describe('phoenix spot market', () => { assert(!isVariant(takerOrder.status, 'open')); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(orderActionRecord.action, 'fill')); assert(orderActionRecord.baseAssetAmountFilled.eq(new BN(1000000000))); assert(orderActionRecord.quoteAssetAmountFilled.eq(new BN(100000000))); @@ -768,7 +768,7 @@ describe('phoenix spot market', () => { assert( phoenixClient.quoteLotsToQuoteAtoms( phoenixMarketEnd.unclaimedQuoteLotFees - - phoenixMarketStart.unclaimedQuoteLotFees, + phoenixMarketStart.unclaimedQuoteLotFees, solMarketAddress.toBase58() ) === orderActionRecord.spotFulfillmentMethodFee.toNumber() ); diff --git a/tests/placeAndMakePerp.ts b/tests/placeAndMakePerp.ts index efdea60451..4de0705c2e 100644 --- a/tests/placeAndMakePerp.ts +++ b/tests/placeAndMakePerp.ts @@ -31,7 +31,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('place and make perp order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerDriftClientUser: User; diff --git a/tests/placeAndMakeSignedMsg.ts b/tests/placeAndMakeSignedMsg.ts index 5c64c4fbe3..4b686f4c63 100644 --- a/tests/placeAndMakeSignedMsg.ts +++ b/tests/placeAndMakeSignedMsg.ts @@ -52,7 +52,7 @@ describe('place and make signedMsg order', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerDriftClientUser: User; diff --git a/tests/placeAndMakeSignedMsgBankrun.ts b/tests/placeAndMakeSignedMsgBankrun.ts index 5cf0368d8d..037319cbc9 100644 --- a/tests/placeAndMakeSignedMsgBankrun.ts +++ b/tests/placeAndMakeSignedMsgBankrun.ts @@ -72,6 +72,7 @@ import { PYTH_LAZER_HEX_STRING_SOL_LATER, PYTH_STORAGE_DATA, } from './pythLazerData'; +import { Drift } from '../sdk/lib/browser/idl/drift'; dotenv.config(); @@ -84,7 +85,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('place and make signedMsg order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let slot: BN; @@ -301,7 +302,7 @@ describe('place and make signedMsg order', () => { // Make sure that the event is in the logs const events = eventSubscriber.getEventsByTx(txSig); const event = events.find( - (event) => event.eventType == 'SignedMsgOrderRecord' + (event) => event.eventType == 'signedMsgOrderRecord' ); assert(event !== undefined); assert( @@ -411,7 +412,7 @@ describe('place and make signedMsg order', () => { // Make sure that the event is in the logs const events = eventSubscriber.getEventsByTx(txSig); const event = events.find( - (event) => event.eventType == 'SignedMsgOrderRecord' + (event) => event.eventType == 'signedMsgOrderRecord' ); assert(event !== undefined); assert( @@ -682,7 +683,7 @@ describe('place and make signedMsg order', () => { ); const userStats: UserStatsAccount = chProgram.account.userStats.coder.accounts.decodeUnchecked( - 'UserStats', + 'userStats', userStatsData.data ); @@ -1708,7 +1709,7 @@ describe('place and make signedMsg order', () => { async function initializeNewTakerClientAndUser( bankrunContextWrapper: BankrunContextWrapper, - chProgram: Program, + chProgram: Program, usdcMint: Keypair, usdcAmount: BN, marketIndexes: number[], diff --git a/tests/placeAndMakeSpotOrder.ts b/tests/placeAndMakeSpotOrder.ts index b5ec4cca97..ad7f088dfa 100644 --- a/tests/placeAndMakeSpotOrder.ts +++ b/tests/placeAndMakeSpotOrder.ts @@ -32,7 +32,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('place and make spot order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerDriftClientUser: User; diff --git a/tests/postOnly.ts b/tests/postOnly.ts index f680dedbaa..c4dd069295 100644 --- a/tests/postOnly.ts +++ b/tests/postOnly.ts @@ -37,7 +37,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('post only', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; @@ -247,7 +247,7 @@ describe('post only', () => { assert(driftClient.getUserStats().getAccount().fees.totalFeePaid.eq(ZERO)); await fillerDriftClient.fetchAccounts(); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(orderRecord.action, 'fill')); assert(orderRecord.takerFee.eq(ZERO)); @@ -348,7 +348,7 @@ describe('post only', () => { ); await fillerDriftClient.fetchAccounts(); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(orderRecord.action, 'fill')); assert(orderRecord.takerFee.eq(new BN(0))); diff --git a/tests/postOnlyAmmFulfillment.ts b/tests/postOnlyAmmFulfillment.ts index 388f0fc595..2e7b1eab28 100644 --- a/tests/postOnlyAmmFulfillment.ts +++ b/tests/postOnlyAmmFulfillment.ts @@ -37,7 +37,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('post only maker order w/ amm fulfillments', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; @@ -314,7 +314,7 @@ describe('post only maker order w/ amm fulfillments', () => { assert(driftClientUserStats.fees.totalFeeRebate.eq(ZERO)); await fillerDriftClient.fetchAccounts(); - const orderRecords = eventSubscriber.getEventsArray('OrderActionRecord'); + const orderRecords = eventSubscriber.getEventsArray('orderActionRecord'); console.log(orderRecords.length, 'orderRecords found.'); assert(orderRecords.length == 4); diff --git a/tests/prelisting.ts b/tests/prelisting.ts index ca784e7b53..c4c121b713 100644 --- a/tests/prelisting.ts +++ b/tests/prelisting.ts @@ -32,7 +32,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('prelisting', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let adminDriftClient: TestClient; let adminDriftClientUser: User; diff --git a/tests/prepegMarketOrderBaseAssetAmount.ts b/tests/prepegMarketOrderBaseAssetAmount.ts index a736cd0ef7..eeaaddce95 100644 --- a/tests/prepegMarketOrderBaseAssetAmount.ts +++ b/tests/prepegMarketOrderBaseAssetAmount.ts @@ -36,7 +36,6 @@ import { import { getFeedData, - // initUserAccounts, mockOracle, mockUserUSDCAccount, mockUSDCMint, @@ -45,6 +44,7 @@ import { sleep, } from './testHelpers'; import { getOraclePriceFromMMOracleData } from '../sdk/src/oracles/utils'; +import { Drift } from '../sdk/src/idl/drift'; describe('prepeg', () => { const provider = anchor.AnchorProvider.local(undefined, { @@ -54,7 +54,7 @@ describe('prepeg', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { @@ -318,7 +318,7 @@ describe('prepeg', () => { assert.ok(market.amm.totalFeeMinusDistributions.gt(new BN(49750))); assert.ok(market.amm.totalExchangeFee.eq(new BN(49875))); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.taker.equals(userAccountPublicKey)); assert.ok(orderRecord.baseAssetAmountFilled.eq(new BN(49745050000))); assert.ok(orderRecord.quoteAssetAmountFilled.gt(new BN(49750001))); @@ -523,7 +523,7 @@ describe('prepeg', () => { assert(market.amm.shortSpread === 2490); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderActionRecord.taker.equals(userAccountPublicKey)); // console.log(orderRecord); @@ -563,7 +563,7 @@ describe('prepeg', () => { convertToNumber(recordEntryPrice) ); - const orderRecord = eventSubscriber.getEventsArray('OrderRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderRecord')[0]; console.log( 'record Auction:', convertToNumber(orderRecord.order.auctionStartPrice), @@ -670,7 +670,7 @@ describe('prepeg', () => { console.log(market.amm.baseAssetAmountWithAmm.toString()); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.taker.equals(userAccountPublicKey)); console.log(orderRecord.baseAssetAmountFilled.toNumber()); diff --git a/tests/pyth.ts b/tests/pyth.ts index d437bf60e8..b138118046 100644 --- a/tests/pyth.ts +++ b/tests/pyth.ts @@ -66,7 +66,7 @@ async function updateFundingRateHelper( frontEndFundingCalc0, 'markTwap0:', ammAccountState0.lastMarkPriceTwap.toNumber() / - PRICE_PRECISION.toNumber(), + PRICE_PRECISION.toNumber(), 'markTwap0:', ammAccountState0.lastMarkPriceTwap.toNumber(), 'oracleTwap0(vamm):', @@ -160,7 +160,7 @@ async function updateFundingRateHelper( } describe('pyth-oracle', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let driftClient2: TestClient; diff --git a/tests/pythLazer.ts b/tests/pythLazer.ts index 37fa85f8de..792005a56d 100644 --- a/tests/pythLazer.ts +++ b/tests/pythLazer.ts @@ -31,7 +31,7 @@ describe('pyth lazer oracles', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/pythLazerBankrun.ts b/tests/pythLazerBankrun.ts index d14ec2f085..a55f4e92b7 100644 --- a/tests/pythLazerBankrun.ts +++ b/tests/pythLazerBankrun.ts @@ -34,7 +34,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('pyth pull oracles', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/pythPull.ts b/tests/pythPull.ts index 5118651af6..2761276ec4 100644 --- a/tests/pythPull.ts +++ b/tests/pythPull.ts @@ -27,7 +27,7 @@ const GUARDIAN_SET_KEY = new PublicKey( ); describe('pyth pull oracles', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/referrer.ts b/tests/referrer.ts index a310bcd24a..1e3b381425 100644 --- a/tests/referrer.ts +++ b/tests/referrer.ts @@ -35,7 +35,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('referrer', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let referrerDriftClient: TestClient; @@ -253,7 +253,7 @@ describe('referrer', () => { await eventSubscriber.awaitTx(txSig); - const eventRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const eventRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(eventRecord.takerFee.eq(new BN(95001))); assert(eventRecord.referrerReward === 15000); diff --git a/tests/repegAndSpread.ts b/tests/repegAndSpread.ts index f6a8a26840..8c1208929c 100644 --- a/tests/repegAndSpread.ts +++ b/tests/repegAndSpread.ts @@ -136,7 +136,7 @@ describe('repeg and spread amm', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { @@ -286,7 +286,7 @@ describe('repeg and spread amm', () => { assert( JSON.stringify(oracleGuardRails) === - JSON.stringify(state.oracleGuardRails) + JSON.stringify(state.oracleGuardRails) ); const marketIndex = 0; @@ -342,7 +342,7 @@ describe('repeg and spread amm', () => { console.log( 'market0.amm.totalFeeMinusDistributions:', market0.amm.totalFeeMinusDistributions.toNumber() / - QUOTE_PRECISION.toNumber() + QUOTE_PRECISION.toNumber() ); console.log( 'market0.amm.pegMultiplier:', @@ -1010,9 +1010,9 @@ describe('repeg and spread amm', () => { const moneyMissing = Math.abs( allUserCollateral + - pnlPoolBalance + - feePoolBalance - - (usdcDepositBalance - usdcBorrowBalance) + pnlPoolBalance + + feePoolBalance - + (usdcDepositBalance - usdcBorrowBalance) ); console.log('moneyMissing:', moneyMissing); @@ -1030,8 +1030,8 @@ describe('repeg and spread amm', () => { // must be less assert( allUserUnsettledPnl + - (sinceStartTFMD - (pnlPoolBalance + feePoolBalance)) < - 0 + (sinceStartTFMD - (pnlPoolBalance + feePoolBalance)) < + 0 ); }); }); diff --git a/tests/resizeSwiftUserOrderIds.ts b/tests/resizeSwiftUserOrderIds.ts index e6ffa6d425..2f191c111f 100644 --- a/tests/resizeSwiftUserOrderIds.ts +++ b/tests/resizeSwiftUserOrderIds.ts @@ -31,7 +31,7 @@ import dotenv from 'dotenv'; dotenv.config(); describe('place and make signedMsg order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerDriftClientUser: User; diff --git a/tests/roundInFavorBaseAsset.ts b/tests/roundInFavorBaseAsset.ts index c1a3b7dec0..7887e69a0a 100644 --- a/tests/roundInFavorBaseAsset.ts +++ b/tests/roundInFavorBaseAsset.ts @@ -26,7 +26,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('round in favor', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/serumTest.ts b/tests/serumTest.ts index 7ede64540d..8075e8befb 100644 --- a/tests/serumTest.ts +++ b/tests/serumTest.ts @@ -37,7 +37,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('serum spot market', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerWSOL: PublicKey; @@ -335,7 +335,7 @@ describe('serum spot market', () => { assert(!isVariant(takerOrder.status, 'open')); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(orderActionRecord.action, 'fill')); assert(orderActionRecord.baseAssetAmountFilled.eq(new BN(1000000000))); assert(orderActionRecord.quoteAssetAmountFilled.eq(new BN(100000000))); @@ -448,7 +448,7 @@ describe('serum spot market', () => { assert(!isVariant(takerOrder.status, 'open')); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(orderActionRecord.action, 'fill')); assert(orderActionRecord.baseAssetAmountFilled.eq(new BN(1000000000))); assert(orderActionRecord.quoteAssetAmountFilled.eq(new BN(100000000))); @@ -565,7 +565,7 @@ describe('serum spot market', () => { assert(!isVariant(takerOrder.status, 'open')); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(orderActionRecord.action, 'fill')); assert(orderActionRecord.baseAssetAmountFilled.eq(new BN(1000000000))); assert(orderActionRecord.quoteAssetAmountFilled.eq(new BN(100000000))); @@ -676,7 +676,7 @@ describe('serum spot market', () => { assert(!isVariant(takerOrder.status, 'open')); const orderActionRecord = - eventSubscriber.getEventsArray('OrderActionRecord')[0]; + eventSubscriber.getEventsArray('orderActionRecord')[0]; assert(isVariant(orderActionRecord.action, 'fill')); assert(orderActionRecord.baseAssetAmountFilled.eq(new BN(1000000000))); assert(orderActionRecord.quoteAssetAmountFilled.eq(new BN(100000000))); diff --git a/tests/settlePNLInvariant.ts b/tests/settlePNLInvariant.ts index 85cffe3914..6d66906fa9 100644 --- a/tests/settlePNLInvariant.ts +++ b/tests/settlePNLInvariant.ts @@ -42,7 +42,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/signedMsgWsDelegates.ts b/tests/signedMsgWsDelegates.ts index 990be3bb75..efabd78047 100644 --- a/tests/signedMsgWsDelegates.ts +++ b/tests/signedMsgWsDelegates.ts @@ -36,7 +36,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('place and make signedMsg order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; diff --git a/tests/spotDepositWithdraw.ts b/tests/spotDepositWithdraw.ts index c24a2900d5..7bbd15efb5 100644 --- a/tests/spotDepositWithdraw.ts +++ b/tests/spotDepositWithdraw.ts @@ -45,7 +45,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; @@ -624,9 +624,9 @@ describe('spot deposit and withdraw', () => { newSpotMarketAccount.cumulativeBorrowInterest .sub(ONE) .eq(expectedCumulativeBorrowInterest) || - newSpotMarketAccount.cumulativeBorrowInterest.eq( - expectedCumulativeBorrowInterest - ) + newSpotMarketAccount.cumulativeBorrowInterest.eq( + expectedCumulativeBorrowInterest + ) ); }); diff --git a/tests/spotDepositWithdraw22.ts b/tests/spotDepositWithdraw22.ts index 77f5e2bf09..7389f90754 100644 --- a/tests/spotDepositWithdraw22.ts +++ b/tests/spotDepositWithdraw22.ts @@ -45,7 +45,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; @@ -636,9 +636,9 @@ describe('spot deposit and withdraw 22', () => { newSpotMarketAccount.cumulativeBorrowInterest .sub(ONE) .eq(expectedCumulativeBorrowInterest) || - newSpotMarketAccount.cumulativeBorrowInterest.eq( - expectedCumulativeBorrowInterest - ) + newSpotMarketAccount.cumulativeBorrowInterest.eq( + expectedCumulativeBorrowInterest + ) ); }); diff --git a/tests/spotDepositWithdraw22ScaledUI.ts b/tests/spotDepositWithdraw22ScaledUI.ts index dc4138031d..d267b44211 100644 --- a/tests/spotDepositWithdraw22ScaledUI.ts +++ b/tests/spotDepositWithdraw22ScaledUI.ts @@ -49,7 +49,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let firstUserKeypair: Keypair; let firstUserDriftClient: TestClient; diff --git a/tests/spotDepositWithdraw22TransferHooks.ts b/tests/spotDepositWithdraw22TransferHooks.ts index f01043172e..5ebc3ff894 100644 --- a/tests/spotDepositWithdraw22TransferHooks.ts +++ b/tests/spotDepositWithdraw22TransferHooks.ts @@ -60,7 +60,7 @@ const transferHookProgramId = new PublicKey( ); describe('spot deposit and withdraw 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let firstUserKeypair: Keypair; let firstUserDriftClient: TestClient; diff --git a/tests/spotMarketPoolIds.ts b/tests/spotMarketPoolIds.ts index 1395856599..90a2141338 100644 --- a/tests/spotMarketPoolIds.ts +++ b/tests/spotMarketPoolIds.ts @@ -29,7 +29,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/spotSwap.ts b/tests/spotSwap.ts index d7e244e224..7f7e0241c1 100644 --- a/tests/spotSwap.ts +++ b/tests/spotSwap.ts @@ -43,9 +43,10 @@ import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; import { DRIFT_PROGRAM_ID } from '../sdk/src'; +import { Drift } from '../sdk/src/idl/drift'; describe('spot swap', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerWSOL: PublicKey; @@ -405,9 +406,9 @@ describe('spot swap', () => { const userStatsAccount = accountInfo ? (takerDriftClient.program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', - accountInfo.data - ) as UserStatsAccount) + 'UserStats', + accountInfo.data + ) as UserStatsAccount) : undefined; // assert(userStatsAccount.fuelDeposits === 2000); @@ -423,9 +424,9 @@ describe('spot swap', () => { ); const _userStatsAccount2 = accountInfo2 ? (takerDriftClient.program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', - accountInfo2.data - ) as UserStatsAccount) + 'UserStats', + accountInfo2.data + ) as UserStatsAccount) : undefined; // console.log(userStatsAccount2.fuelDeposits.toString()); @@ -443,9 +444,9 @@ describe('spot swap', () => { ); const _userStatsAccount3 = accountInfo3 ? (takerDriftClient.program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', - accountInfo3.data - ) as UserStatsAccount) + 'UserStats', + accountInfo3.data + ) as UserStatsAccount) : undefined; // console.log(userStatsAccount3.fuelDeposits.toString()); @@ -454,7 +455,7 @@ describe('spot swap', () => { // assert(userStatsAccount.fees.totalFeePaid.eq(new BN(50000))); assert(userStatsAccount.takerVolume30D.eq(new BN(0))); - const swapRecord = eventSubscriber.getEventsArray('SwapRecord')[0]; + const swapRecord = eventSubscriber.getEventsArray('swapRecord')[0]; assert(swapRecord.amountOut.eq(new BN(1000000000))); assert(swapRecord.outMarketIndex === 1); assert(swapRecord.amountIn.eq(new BN(100040000))); @@ -589,7 +590,7 @@ describe('spot swap', () => { // ); // assert(userStatsAccount.fees.totalFeePaid.eq(new BN(99980))); - const swapRecord = eventSubscriber.getEventsArray('SwapRecord')[0]; + const swapRecord = eventSubscriber.getEventsArray('swapRecord')[0]; assert(swapRecord.amountOut.eq(new BN(99960000))); assert(swapRecord.outMarketIndex === 0); assert(swapRecord.amountIn.eq(new BN(1000000000))); diff --git a/tests/spotSwap22.ts b/tests/spotSwap22.ts index a876a74504..b5cb1c65a3 100644 --- a/tests/spotSwap22.ts +++ b/tests/spotSwap22.ts @@ -41,7 +41,7 @@ import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; import { DRIFT_PROGRAM_ID } from '../sdk/src'; describe('spot swap 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let makerDriftClient: TestClient; let makerWSOL: PublicKey; @@ -236,9 +236,9 @@ describe('spot swap 22', () => { const userStatsAccount = accountInfo ? (takerDriftClient.program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', - accountInfo.data - ) as UserStatsAccount) + 'UserStats', + accountInfo.data + ) as UserStatsAccount) : undefined; assert(userStatsAccount.takerVolume30D.eq(new BN(0))); diff --git a/tests/spotWithdrawUtil100.ts b/tests/spotWithdrawUtil100.ts index 25cf31c10d..d0c2a45853 100644 --- a/tests/spotWithdrawUtil100.ts +++ b/tests/spotWithdrawUtil100.ts @@ -50,7 +50,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('test function when spot market at >= 100% util', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; @@ -501,9 +501,9 @@ describe('test function when spot market at >= 100% util', () => { newSpotMarketAccount.cumulativeBorrowInterest .sub(ONE) .eq(expectedCumulativeBorrowInterest) || - newSpotMarketAccount.cumulativeBorrowInterest.eq( - expectedCumulativeBorrowInterest - ) + newSpotMarketAccount.cumulativeBorrowInterest.eq( + expectedCumulativeBorrowInterest + ) ); }); @@ -551,9 +551,9 @@ describe('test function when spot market at >= 100% util', () => { newSpotMarketAccount.cumulativeBorrowInterest .sub(ONE) .eq(expectedCumulativeBorrowInterest) || - newSpotMarketAccount.cumulativeBorrowInterest.eq( - expectedCumulativeBorrowInterest - ) + newSpotMarketAccount.cumulativeBorrowInterest.eq( + expectedCumulativeBorrowInterest + ) ); }); diff --git a/tests/stopLimits.ts b/tests/stopLimits.ts index 3bcae9d15a..aff53155ac 100644 --- a/tests/stopLimits.ts +++ b/tests/stopLimits.ts @@ -37,7 +37,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('stop limit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let driftClientUser: User; @@ -314,7 +314,7 @@ describe('stop limit', () => { const expectedQuoteAssetAmount = new BN(0); assert(firstPosition.quoteBreakEvenAmount.eq(expectedQuoteAssetAmount)); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; assert.ok(orderRecord.baseAssetAmountFilled.eq(baseAssetAmount)); const expectedTradeQuoteAssetAmount = new BN(1010000); @@ -401,7 +401,7 @@ describe('stop limit', () => { assert(firstPosition.quoteBreakEvenAmount.eq(expectedQuoteAssetAmount)); const expectedTradeQuoteAssetAmount = new BN(990001); - const orderRecord = eventSubscriber.getEventsArray('OrderActionRecord')[0]; + const orderRecord = eventSubscriber.getEventsArray('orderActionRecord')[0]; const expectedOrderId = 4; const expectedFillRecord = new BN(4); diff --git a/tests/subaccounts.ts b/tests/subaccounts.ts index fe0c63acc4..c4260f1ce4 100644 --- a/tests/subaccounts.ts +++ b/tests/subaccounts.ts @@ -34,7 +34,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('subaccounts', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/surgePricing.ts b/tests/surgePricing.ts index 4402201060..a553d21b34 100644 --- a/tests/surgePricing.ts +++ b/tests/surgePricing.ts @@ -30,7 +30,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('surge pricing', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/switchOracle.ts b/tests/switchOracle.ts index eaefb12f98..11a2631161 100644 --- a/tests/switchOracle.ts +++ b/tests/switchOracle.ts @@ -29,7 +29,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('switch oracles', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/switchboardOnDemand.ts b/tests/switchboardOnDemand.ts index 81e04d65d2..ab80293c1b 100644 --- a/tests/switchboardOnDemand.ts +++ b/tests/switchboardOnDemand.ts @@ -56,7 +56,7 @@ const getOracleAccountInfo = (accountData: string): AccountInfo => { }; describe('switchboard on demand', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/switchboardTxCus.ts b/tests/switchboardTxCus.ts index 9c46994d99..6288a1795f 100644 --- a/tests/switchboardTxCus.ts +++ b/tests/switchboardTxCus.ts @@ -34,7 +34,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('switchboard place orders cus', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/tokenFaucet.ts b/tests/tokenFaucet.ts index c18cf15699..42d72b8eb5 100644 --- a/tests/tokenFaucet.ts +++ b/tests/tokenFaucet.ts @@ -22,7 +22,7 @@ describe('token faucet', () => { let usdcMint: Keypair; - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/transferPerpPosition.ts b/tests/transferPerpPosition.ts index d2471a94d9..7e38f07cb8 100644 --- a/tests/transferPerpPosition.ts +++ b/tests/transferPerpPosition.ts @@ -33,7 +33,7 @@ function getOpenInterest(driftClient: TestClient, marketIndex: number) { } describe('trigger orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/transferPools.ts b/tests/transferPools.ts index a79d863601..a921f74f35 100644 --- a/tests/transferPools.ts +++ b/tests/transferPools.ts @@ -31,7 +31,7 @@ import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; import { NATIVE_MINT } from '@solana/spl-token'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/triggerOrders.ts b/tests/triggerOrders.ts index 99bf5f71ab..690cd47d36 100644 --- a/tests/triggerOrders.ts +++ b/tests/triggerOrders.ts @@ -39,7 +39,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('trigger orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/triggerSpotOrder.ts b/tests/triggerSpotOrder.ts index 0f9277e2c3..84a819d242 100644 --- a/tests/triggerSpotOrder.ts +++ b/tests/triggerSpotOrder.ts @@ -36,7 +36,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('trigger orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; diff --git a/tests/updateAMM.ts b/tests/updateAMM.ts index 08506b5537..f04afc71aa 100644 --- a/tests/updateAMM.ts +++ b/tests/updateAMM.ts @@ -96,7 +96,7 @@ describe('update amm', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { diff --git a/tests/updateK.ts b/tests/updateK.ts index 5a73be0ba8..e9b4d90a98 100644 --- a/tests/updateK.ts +++ b/tests/updateK.ts @@ -42,7 +42,7 @@ describe('update k', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; diff --git a/tests/userAccount.ts b/tests/userAccount.ts index 96384ba98a..13cf1f07ca 100644 --- a/tests/userAccount.ts +++ b/tests/userAccount.ts @@ -34,7 +34,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('User Account', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient; diff --git a/tests/userDelegate.ts b/tests/userDelegate.ts index 80dafcb539..d74c7b3178 100644 --- a/tests/userDelegate.ts +++ b/tests/userDelegate.ts @@ -28,7 +28,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('user delegate', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/userOrderId.ts b/tests/userOrderId.ts index 9ed86fd4f4..1de190bd5e 100644 --- a/tests/userOrderId.ts +++ b/tests/userOrderId.ts @@ -28,7 +28,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('user order id', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/whitelist.ts b/tests/whitelist.ts index 66c5f15ead..2bbe9fd2a6 100644 --- a/tests/whitelist.ts +++ b/tests/whitelist.ts @@ -32,7 +32,7 @@ import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('whitelist', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as Program; let bulkAccountLoader: TestBulkAccountLoader; From 67360ceddfd9c5bab3f74c2a2cd7df96d4ef1681 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 22 Dec 2025 13:23:56 +0800 Subject: [PATCH 24/25] fixing sdk tests --- Cargo.lock | 1 + programs/drift/Cargo.toml | 1 + programs/drift/src/math/bn.rs | 60 +- programs/drift/src/validation/perp_market.rs | 3 +- sdk/scripts/grpc-client-test-comparison.ts | 13 +- sdk/src/accounts/fetch.ts | 13 +- sdk/src/accounts/grpcAccountSubscriber.ts | 7 +- .../grpcDriftClientAccountSubscriber.ts | 6 +- .../grpcDriftClientAccountSubscriberV2.ts | 22 +- ...grpcInsuranceFundStakeAccountSubscriber.ts | 5 +- .../accounts/grpcMultiAccountSubscriber.ts | 25 +- .../grpcMultiUserAccountSubscriber.ts | 7 +- .../accounts/grpcProgramAccountSubscriber.ts | 7 +- sdk/src/accounts/grpcUserAccountSubscriber.ts | 5 +- .../grpcUserStatsAccountSubscriber.ts | 5 +- .../accounts/laserProgramAccountSubscriber.ts | 7 +- .../accounts/oneShotUserAccountSubscriber.ts | 7 +- .../oneShotUserStatsAccountSubscriber.ts | 11 +- .../pollingDriftClientAccountSubscriber.ts | 24 +- ...HighLeverageModeConfigAccountSubscriber.ts | 7 +- ...lingInsuranceFundStakeAccountSubscriber.ts | 8 +- .../pollingOracleAccountSubscriber.ts | 3 +- .../accounts/pollingTokenAccountSubscriber.ts | 3 +- .../pollingUserStatsAccountSubscriber.ts | 42 +- .../accounts/webSocketAccountSubscriber.ts | 8 +- .../accounts/webSocketAccountSubscriberV2.ts | 12 +- .../webSocketDriftClientAccountSubscriber.ts | 34 +- ...webSocketDriftClientAccountSubscriberV2.ts | 18 +- ...HighLeverageModeConfigAccountSubscriber.ts | 7 +- ...cketInsuranceFundStakeAccountSubscriber.ts | 7 +- .../webSocketProgramAccountSubscriber.ts | 8 +- .../webSocketProgramAccountsSubscriberV2.ts | 8 +- .../webSocketUserAccountSubscriber.ts | 7 +- .../webSocketUserStatsAccountSubsriber.ts | 7 +- .../websocketProgramUserAccountSubscriber.ts | 7 +- sdk/src/addresses/pda.ts | 2 +- sdk/src/config.ts | 37 +- .../pollingConstituentAccountSubscriber.ts | 7 +- .../webSocketConstituentAccountSubscriber.ts | 7 +- sdk/src/decode/customCoder.ts | 96 +- sdk/src/dlob/orderBookLevels.ts | 10 +- sdk/src/driftClient.ts | 25 +- sdk/src/driftClientConfig.ts | 10 +- sdk/src/events/eventSubscriber.ts | 5 +- sdk/src/events/fetchLogs.ts | 6 +- sdk/src/events/parse.ts | 12 +- sdk/src/events/types.ts | 2 + sdk/src/factory/oracleClient.ts | 6 +- sdk/src/idl/drift.json | 1751 +-------------- sdk/src/idl/drift.ts | 1956 ++--------------- sdk/src/math/amm.ts | 9 +- sdk/src/math/auction.ts | 6 +- sdk/src/math/market.ts | 4 +- sdk/src/math/oracles.ts | 9 +- sdk/src/math/trade.ts | 8 +- sdk/src/oracles/oracleClientCache.ts | 5 +- sdk/src/oracles/prelaunchOracleClient.ts | 7 +- sdk/src/oracles/pythLazerClient.ts | 4 +- sdk/src/titan/titanClient.ts | 15 +- sdk/src/types.ts | 251 +-- sdk/src/user.ts | 14 +- sdk/src/userMap/userMap.ts | 14 +- sdk/src/userMap/userStatsMap.ts | 18 +- sdk/src/userStats.ts | 6 +- sdk/tests/amm/test.ts | 40 +- sdk/tests/decode/test.ts | 2 +- sdk/tests/dlob/helpers.ts | 23 +- sdk/tests/dlob/test.ts | 66 +- test-scripts/run-anchor-tests.sh | 7 +- tests/admin.ts | 33 +- tests/adminDeposit.ts | 5 +- tests/assetTier.ts | 43 +- tests/builderCodes.ts | 67 +- tests/cancelAllOrders.ts | 23 +- tests/cappedSymFunding.ts | 77 +- tests/curve.ts | 31 +- tests/deleteInitializedSpotMarket.ts | 23 +- tests/delistMarket.ts | 43 +- tests/delistMarketLiq.ts | 53 +- tests/depositIntoSpotMarketVault.ts | 19 +- tests/driftClient.ts | 35 +- tests/fillSpot.ts | 28 +- tests/forceUserDelete.ts | 21 +- tests/fuel.ts | 39 +- tests/fuelSweep.ts | 25 +- tests/govStakeDevnet.ts | 15 +- tests/highLeverageMode.ts | 39 +- tests/ifRebalance.ts | 33 +- tests/imbalancePerpPnl.ts | 73 +- tests/insuranceFundStake.ts | 69 +- tests/ksolver.ts | 26 +- tests/liquidateBorrowForPerpPnl.ts | 37 +- tests/liquidatePerp.ts | 23 +- tests/liquidatePerpPnlForDeposit.ts | 43 +- tests/liquidatePerpWithFill.ts | 17 +- tests/liquidateSpot.ts | 42 +- tests/liquidateSpotSocialLoss.ts | 37 +- tests/liquidateSpotWithSwap.ts | 23 +- tests/liquidityBook.ts | 2 +- tests/lpPool.ts | 88 +- tests/lpPoolCUs.ts | 70 +- tests/lpPoolSwap.ts | 76 +- tests/marketOrder.ts | 36 +- tests/marketOrderBaseAssetAmount.ts | 19 +- tests/maxDeposit.ts | 13 +- tests/maxLeverageOrderParams.ts | 39 +- tests/modifyOrder.ts | 21 +- tests/multipleMakerOrders.ts | 27 +- tests/multipleSpotMakerOrders.ts | 33 +- tests/openbookTest.ts | 28 +- tests/oracleDiffSources.ts | 15 +- tests/oracleFillPriceGuardrails.ts | 33 +- tests/oracleOffsetOrders.ts | 27 +- tests/order.ts | 53 +- tests/ordersWithSpread.ts | 39 +- tests/overwritePerpAccounts.ts | 29 +- tests/pauseDepositWithdraw.ts | 35 +- tests/pauseExchange.ts | 21 +- tests/phoenixTest.ts | 44 +- tests/placeAndMakePerp.ts | 23 +- tests/placeAndMakeSignedMsg.ts | 31 +- tests/placeAndMakeSignedMsgBankrun.ts | 70 +- tests/placeAndMakeSpotOrder.ts | 25 +- tests/postOnly.ts | 31 +- tests/postOnlyAmmFulfillment.ts | 29 +- tests/prelisting.ts | 33 +- tests/prepegMarketOrderBaseAssetAmount.ts | 44 +- tests/pyth.ts | 26 +- tests/pythLazer.ts | 29 +- tests/pythLazerBankrun.ts | 16 +- tests/pythPull.ts | 11 +- tests/referencePriceOffset.ts | 57 +- tests/referrer.ts | 33 +- tests/repegAndSpread.ts | 72 +- tests/resizeSwiftUserOrderIds.ts | 19 +- tests/roundInFavorBaseAsset.ts | 17 +- tests/serumTest.ts | 29 +- tests/settlePNLInvariant.ts | 49 +- tests/signedMsgWsDelegates.ts | 15 +- tests/spotDepositWithdraw.ts | 57 +- tests/spotDepositWithdraw22.ts | 57 +- tests/spotDepositWithdraw22ScaledUI.ts | 34 +- tests/spotDepositWithdraw22TransferHooks.ts | 40 +- tests/spotMarketPoolIds.ts | 21 +- tests/spotSwap.ts | 52 +- tests/spotSwap22.ts | 37 +- tests/spotWithdrawUtil100.ts | 64 +- tests/stopLimits.ts | 34 +- tests/subaccounts.ts | 37 +- tests/surgePricing.ts | 23 +- tests/switchOracle.ts | 21 +- tests/switchboardOnDemand.ts | 11 +- tests/switchboardTxCus.ts | 36 +- tests/testHelpers.ts | 96 +- tests/testHelpersLocalValidator.ts | 30 +- tests/tokenFaucet.ts | 13 +- tests/transferPerpPosition.ts | 21 +- tests/transferPools.ts | 23 +- tests/triggerOrders.ts | 39 +- tests/triggerSpotOrder.ts | 37 +- tests/updateAMM.ts | 31 +- tests/updateK.ts | 24 +- tests/userAccount.ts | 45 +- tests/userDelegate.ts | 23 +- tests/userOrderId.ts | 23 +- tests/whitelist.ts | 27 +- 166 files changed, 2399 insertions(+), 5861 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a825bc965a..190675ffb1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -719,6 +719,7 @@ name = "drift" version = "2.152.0" dependencies = [ "anchor-lang", + "anchor-lang-idl-spec", "anchor-spl", "arrayref", "base64 0.13.1", diff --git a/programs/drift/Cargo.toml b/programs/drift/Cargo.toml index 5723c674f1..bc3c64a04f 100644 --- a/programs/drift/Cargo.toml +++ b/programs/drift/Cargo.toml @@ -26,6 +26,7 @@ idl-build = [ [dependencies] anchor-lang = "0.32.1" +anchor-lang-idl-spec = "0.1.0" anchor-spl = { version = "0.32.1", features = ["idl-build"] } solana-program = "=2.2.1" pyth-client = "0.2.2" diff --git a/programs/drift/src/math/bn.rs b/programs/drift/src/math/bn.rs index 3fcbbe11be..265fa002bd 100644 --- a/programs/drift/src/math/bn.rs +++ b/programs/drift/src/math/bn.rs @@ -14,23 +14,45 @@ use crate::error::DriftResult; pub mod compat { #![allow(non_camel_case_types)] - use anchor_lang::prelude::{ - borsh::{self}, - AnchorDeserialize, AnchorSerialize, - }; + use anchor_lang::prelude::borsh::{self}; + use anchor_lang_idl_spec::{IdlRepr, IdlType, IdlTypeDef}; use bytemuck::{Pod, Zeroable}; use std::{ cmp::Ordering, + collections::BTreeMap, convert::TryFrom, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}, }; use crate::{error::DriftResult, math::casting::Cast}; - /// `u128` with legacy bit layout - #[derive(Copy, Clone, PartialEq, Eq, Debug, Default, AnchorSerialize, AnchorDeserialize)] + /// `u128` with legacy alignment + #[repr(transparent)] + #[derive( + Copy, Clone, PartialEq, Eq, Debug, Default, borsh::BorshSerialize, borsh::BorshDeserialize, + )] pub struct u128([u8; 16]); + impl anchor_lang::IdlBuild for self::u128 { + // tell anchor IDL to treat it as std::primitive::u128 + fn create_type() -> Option { + Some(IdlTypeDef { + name: Self::get_full_path(), + docs: vec!["compatibility u128".into()], + serialization: Default::default(), + repr: Some(IdlRepr::Transparent), + generics: Default::default(), + ty: anchor_lang_idl_spec::IdlTypeDefTy::Type { + alias: IdlType::U128, + }, + }) + } + fn insert_types(_types: &mut BTreeMap) {} + fn get_full_path() -> String { + "u128".into() + } + } + impl std::fmt::Display for self::u128 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(&self.as_u128(), f) @@ -154,10 +176,32 @@ pub mod compat { } } - /// `i128` with legacy bit layout - #[derive(Copy, Clone, PartialEq, Eq, Debug, Default, AnchorSerialize, AnchorDeserialize)] + /// `i128` with legacy alignment + #[repr(transparent)] + #[derive( + Copy, Clone, PartialEq, Eq, Debug, Default, borsh::BorshSerialize, borsh::BorshDeserialize, + )] pub struct i128([u8; 16]); + impl anchor_lang::IdlBuild for self::i128 { + // tell anchor IDL to treat it as std::primitive::i128 + fn create_type() -> Option { + Some(IdlTypeDef { + name: Self::get_full_path(), + docs: vec!["compatibility i128".into()], + serialization: Default::default(), + repr: Some(IdlRepr::Transparent), + generics: Default::default(), + ty: anchor_lang_idl_spec::IdlTypeDefTy::Type { + alias: IdlType::I128, + }, + }) + } + fn get_full_path() -> String { + "i128".into() + } + } + impl std::fmt::Display for self::i128 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(&self.as_i128(), f) diff --git a/programs/drift/src/validation/perp_market.rs b/programs/drift/src/validation/perp_market.rs index c197213a7d..9747b9354e 100644 --- a/programs/drift/src/validation/perp_market.rs +++ b/programs/drift/src/validation/perp_market.rs @@ -139,7 +139,8 @@ pub fn validate_perp_market(market: &PerpMarket) -> DriftResult { if market.amm.amm_spread_adjustment >= 0 && market.amm.amm_inventory_spread_adjustment >= 0 { validate!( - market.amm.long_spread + market.amm.short_spread >= market.amm.base_spread.saturating_sub(2), + market.amm.long_spread + market.amm.short_spread + >= market.amm.base_spread.saturating_sub(2), ErrorCode::InvalidAmmDetected, "market {} amm long_spread + short_spread < base_spread - 2: {} + {} < {}", market.market_index, diff --git a/sdk/scripts/grpc-client-test-comparison.ts b/sdk/scripts/grpc-client-test-comparison.ts index c2d7c7947f..584eb939b8 100644 --- a/sdk/scripts/grpc-client-test-comparison.ts +++ b/sdk/scripts/grpc-client-test-comparison.ts @@ -30,7 +30,6 @@ async function initializeGrpcDriftClientV2VersusV1() { const wallet = new Wallet(new Keypair()); dotenv.config({ path: '../' }); - const programId = new PublicKey(DRIFT_PROGRAM_ID); const provider = new AnchorProvider( connection, // @ts-ignore @@ -40,7 +39,7 @@ async function initializeGrpcDriftClientV2VersusV1() { } ); - const program = new Program(driftIDL as Idl, programId, provider); + const program = new Program(driftIDL as Idl, provider); const allPerpMarketProgramAccounts = (await program.account.perpMarket.all()) as ProgramAccount[]; @@ -65,9 +64,8 @@ async function initializeGrpcDriftClientV2VersusV1() { const seen = new Set(); const oracleInfos: OracleInfo[] = []; for (const acct of perpMarketProgramAccounts) { - const key = `${acct.account.amm.oracle.toBase58()}-${ - Object.keys(acct.account.amm.oracleSource)[0] - }`; + const key = `${acct.account.amm.oracle.toBase58()}-${Object.keys(acct.account.amm.oracleSource)[0] + }`; if (!seen.has(key)) { seen.add(key); oracleInfos.push({ @@ -77,9 +75,8 @@ async function initializeGrpcDriftClientV2VersusV1() { } } for (const acct of spotMarketProgramAccounts) { - const key = `${acct.account.oracle.toBase58()}-${ - Object.keys(acct.account.oracleSource)[0] - }`; + const key = `${acct.account.oracle.toBase58()}-${Object.keys(acct.account.oracleSource)[0] + }`; if (!seen.has(key)) { seen.add(key); oracleInfos.push({ diff --git a/sdk/src/accounts/fetch.ts b/sdk/src/accounts/fetch.ts index 539a380e7f..42abf0ce18 100644 --- a/sdk/src/accounts/fetch.ts +++ b/sdk/src/accounts/fetch.ts @@ -11,12 +11,11 @@ import { getUserAccountPublicKey, getUserStatsAccountPublicKey, } from '../addresses/pda'; -import { Program } from '@coral-xyz/anchor'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export async function fetchUserAccounts( connection: Connection, - program: Program, + program: DriftProgram, authority: PublicKey, limit = 8 ): Promise<(UserAccount | undefined)[]> { @@ -32,7 +31,7 @@ export async function fetchUserAccounts( export async function fetchUserAccountsUsingKeys( connection: Connection, - program: Program, + program: DriftProgram, userAccountPublicKeys: PublicKey[] ): Promise<(UserAccount | undefined)[]> { const accountInfos = await connection.getMultipleAccountsInfo( @@ -53,7 +52,7 @@ export async function fetchUserAccountsUsingKeys( export async function fetchUserStatsAccount( connection: Connection, - program: Program, + program: DriftProgram, authority: PublicKey ): Promise { const userStatsPublicKey = getUserStatsAccountPublicKey( @@ -75,7 +74,7 @@ export async function fetchUserStatsAccount( export async function fetchRevenueShareAccount( connection: Connection, - program: Program, + program: DriftProgram, authority: PublicKey ): Promise { const revenueShareAccountPublicKey = getRevenueShareAccountPublicKey( @@ -94,7 +93,7 @@ export async function fetchRevenueShareAccount( export async function fetchRevenueShareEscrowAccount( connection: Connection, - program: Program, + program: DriftProgram, authority: PublicKey ): Promise { const revenueShareEscrowPubKey = getRevenueShareEscrowAccountPublicKey( diff --git a/sdk/src/accounts/grpcAccountSubscriber.ts b/sdk/src/accounts/grpcAccountSubscriber.ts index dd698fbf04..9cc1ad7c2b 100644 --- a/sdk/src/accounts/grpcAccountSubscriber.ts +++ b/sdk/src/accounts/grpcAccountSubscriber.ts @@ -1,5 +1,4 @@ import { ResubOpts, GrpcConfigs } from './types'; -import { Program } from '@coral-xyz/anchor'; import { PublicKey } from '@solana/web3.js'; import * as Buffer from 'buffer'; @@ -12,7 +11,7 @@ import { SubscribeRequest, SubscribeUpdate, } from '../isomorphic/grpc'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class grpcAccountSubscriber extends WebSocketAccountSubscriber { private client: Client; @@ -24,7 +23,7 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { client: Client, commitmentLevel: CommitmentLevel, accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts @@ -37,7 +36,7 @@ export class grpcAccountSubscriber extends WebSocketAccountSubscriber { public static async create( grpcConfigs: GrpcConfigs, accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => U, resubOpts?: ResubOpts, diff --git a/sdk/src/accounts/grpcDriftClientAccountSubscriber.ts b/sdk/src/accounts/grpcDriftClientAccountSubscriber.ts index c12ec8efb8..76176502e0 100644 --- a/sdk/src/accounts/grpcDriftClientAccountSubscriber.ts +++ b/sdk/src/accounts/grpcDriftClientAccountSubscriber.ts @@ -1,7 +1,6 @@ import { WebSocketDriftClientAccountSubscriber } from './webSocketDriftClientAccountSubscriber'; import { OracleInfo, OraclePriceData } from '../oracles/types'; -import { Program } from '@coral-xyz/anchor'; -import { findAllMarketAndOracles } from '../config'; +import { findAllMarketAndOracles, DriftProgram } from '../config'; import { getDriftStateAccountPublicKey, getPerpMarketPublicKey, @@ -11,14 +10,13 @@ import { DelistedMarketSetting, GrpcConfigs, ResubOpts } from './types'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types'; import { getOracleId } from '../oracles/oracleId'; -import { Drift } from '../idl/drift'; export class grpcDriftClientAccountSubscriber extends WebSocketDriftClientAccountSubscriber { private grpcConfigs: GrpcConfigs; constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: DriftProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], diff --git a/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts b/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts index b2fa631f82..caeb7a3cbd 100644 --- a/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts +++ b/sdk/src/accounts/grpcDriftClientAccountSubscriberV2.ts @@ -1,9 +1,8 @@ import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { OracleInfo, OraclePriceData } from '../oracles/types'; -import { Program } from '@coral-xyz/anchor'; import { PublicKey } from '@solana/web3.js'; -import { findAllMarketAndOracles } from '../config'; +import { findAllMarketAndOracles, DriftProgram } from '../config'; import { getDriftStateAccountPublicKey, getPerpMarketPublicKey, @@ -23,19 +22,13 @@ import { } from './types'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; import { grpcMultiAccountSubscriber } from './grpcMultiAccountSubscriber'; -import { - PerpMarketAccount, - SpotMarketAccount, - StateAccount, - parseSpotMarketAccount, -} from '../types'; +import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types'; import { getOracleId, getPublicKeyAndSourceFromOracleId, } from '../oracles/oracleId'; import { OracleClientCache } from '../oracles/oracleClientCache'; import { findDelistedPerpMarketsAndOracles } from './utils'; -import { Drift } from '../idl/drift'; export class grpcDriftClientAccountSubscriberV2 implements DriftClientAccountSubscriber @@ -57,7 +50,7 @@ export class grpcDriftClientAccountSubscriberV2 >; public isSubscribed: boolean; public isSubscribing: boolean; - public program: Program; + public program: DriftProgram; public perpMarketIndexes: number[]; public spotMarketIndexes: number[]; public shouldFindAllMarketsAndOracles: boolean; @@ -82,7 +75,7 @@ export class grpcDriftClientAccountSubscriberV2 constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: DriftProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], @@ -142,7 +135,7 @@ export class grpcDriftClientAccountSubscriberV2 const perpMarket = this.program.coder.accounts.decode( 'perpMarket', accountInfo.data - ); + ) as PerpMarketAccount; return [perpMarket.marketIndex, perpMarket]; }) ); @@ -167,11 +160,10 @@ export class grpcDriftClientAccountSubscriberV2 spotMarketAccountInfos .filter((accountInfo) => !!accountInfo) .map((accountInfo) => { - const decoded = this.program.coder.accounts.decode( + const spotMarket = this.program.coder.accounts.decode( 'spotMarket', accountInfo.data - ); - const spotMarket = parseSpotMarketAccount(decoded); + ) as SpotMarketAccount; return [spotMarket.marketIndex, spotMarket]; }) ); diff --git a/sdk/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts b/sdk/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts index 89387ec46f..435d3f5e06 100644 --- a/sdk/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +++ b/sdk/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts @@ -1,17 +1,16 @@ import { GrpcConfigs } from './types'; -import { Program } from '@coral-xyz/anchor'; import { PublicKey } from '@solana/web3.js'; import { InsuranceFundStake } from '../types'; import { WebSocketInsuranceFundStakeAccountSubscriber } from './webSocketInsuranceFundStakeAccountSubscriber'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class grpcInsuranceFundStakeAccountSubscriber extends WebSocketInsuranceFundStakeAccountSubscriber { private grpcConfigs: GrpcConfigs; public constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: DriftProgram, insuranceFundStakeAccountPublicKey: PublicKey, resubTimeoutMs?: number ) { diff --git a/sdk/src/accounts/grpcMultiAccountSubscriber.ts b/sdk/src/accounts/grpcMultiAccountSubscriber.ts index 34cbcbd25d..47aca5b381 100644 --- a/sdk/src/accounts/grpcMultiAccountSubscriber.ts +++ b/sdk/src/accounts/grpcMultiAccountSubscriber.ts @@ -1,8 +1,8 @@ -import { Program } from '@coral-xyz/anchor'; import { Commitment, Context, PublicKey } from '@solana/web3.js'; -import * as Buffer from 'buffer'; import bs58 from 'bs58'; +import * as Buffer from 'buffer'; +import { DriftProgram } from '../config'; import { Client, ClientDuplexStream, @@ -12,8 +12,6 @@ import { createClient, } from '../isomorphic/grpc'; import { BufferAndSlot, DataAndSlot, GrpcConfigs, ResubOpts } from './types'; -import { Drift } from '../idl/drift'; -import { parseAccount } from '../types'; interface AccountInfoLike { owner: PublicKey; @@ -42,7 +40,7 @@ export class grpcMultiAccountSubscriber { private client: Client; private stream: ClientDuplexStream; private commitmentLevel: CommitmentLevel; - private program: Program; + private program: DriftProgram; private accountName: string; private decodeBufferFn?: ( buffer: Buffer, @@ -71,7 +69,7 @@ export class grpcMultiAccountSubscriber { client: Client, commitmentLevel: CommitmentLevel, accountName: string, - program: Program, + program: DriftProgram, decodeBuffer?: (buffer: Buffer, pubkey?: string) => T, resubOpts?: ResubOpts, onUnsubscribe?: () => Promise, @@ -90,7 +88,7 @@ export class grpcMultiAccountSubscriber { public static async create( grpcConfigs: GrpcConfigs, accountName: string, - program: Program, + program: DriftProgram, decodeBuffer?: (buffer: Buffer, pubkey?: string, accountProps?: U) => T, resubOpts?: ResubOpts, clientProp?: Client, @@ -185,9 +183,7 @@ export class grpcMultiAccountSubscriber { this.accountName, newBuffer ); - const accountDecoded = parseAccount(this.accountName, decoded); - - this.setAccountData(accountId, accountDecoded, currentSlot); + this.setAccountData(accountId, decoded, currentSlot); } } }) @@ -312,11 +308,9 @@ export class grpcMultiAccountSubscriber { this.accountName, buffer ); - const data = parseAccount(this.accountName, decoded); - const handler = this.onChangeMap.get(accountPubkey); if (handler) { - handler(data, context, buffer, accountProps); + handler(decoded, context, buffer, accountProps); } }; @@ -474,9 +468,4 @@ export class grpcMultiAccountSubscriber { this.resubOpts?.resubTimeoutMs ); } - - private capitalize(value: string): string { - if (!value) return value; - return value.charAt(0).toUpperCase() + value.slice(1); - } } diff --git a/sdk/src/accounts/grpcMultiUserAccountSubscriber.ts b/sdk/src/accounts/grpcMultiUserAccountSubscriber.ts index 14d8c5435f..f7785db1d1 100644 --- a/sdk/src/accounts/grpcMultiUserAccountSubscriber.ts +++ b/sdk/src/accounts/grpcMultiUserAccountSubscriber.ts @@ -9,13 +9,12 @@ import { import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Context, PublicKey } from '@solana/web3.js'; -import { Program } from '@coral-xyz/anchor'; import { UserAccount } from '../types'; import { grpcMultiAccountSubscriber } from './grpcMultiAccountSubscriber'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class grpcMultiUserAccountSubscriber { - private program: Program; + private program: DriftProgram; private multiSubscriber: grpcMultiAccountSubscriber; private userData = new Map>(); @@ -51,7 +50,7 @@ export class grpcMultiUserAccountSubscriber { }; public constructor( - program: Program, + program: DriftProgram, grpcConfigs: GrpcConfigs, resubOpts?: ResubOpts, multiSubscriber?: grpcMultiAccountSubscriber diff --git a/sdk/src/accounts/grpcProgramAccountSubscriber.ts b/sdk/src/accounts/grpcProgramAccountSubscriber.ts index 4440597f96..5f5ffc17d6 100644 --- a/sdk/src/accounts/grpcProgramAccountSubscriber.ts +++ b/sdk/src/accounts/grpcProgramAccountSubscriber.ts @@ -1,5 +1,4 @@ import { ResubOpts, GrpcConfigs } from './types'; -import { Program } from '@coral-xyz/anchor'; import bs58 from 'bs58'; import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js'; import * as Buffer from 'buffer'; @@ -12,7 +11,7 @@ import { SubscribeRequest, SubscribeUpdate, } from '../isomorphic/grpc'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class grpcProgramAccountSubscriber< T, @@ -27,7 +26,7 @@ export class grpcProgramAccountSubscriber< commitmentLevel: CommitmentLevel, subscriptionName: string, accountDiscriminator: string, - program: Program, + program: DriftProgram, decodeBufferFn: (accountName: string, ix: Buffer) => T, options: { filters: MemcmpFilter[] } = { filters: [], @@ -50,7 +49,7 @@ export class grpcProgramAccountSubscriber< grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, - program: Program, + program: DriftProgram, decodeBufferFn: (accountName: string, ix: Buffer) => U, options: { filters: MemcmpFilter[] } = { filters: [], diff --git a/sdk/src/accounts/grpcUserAccountSubscriber.ts b/sdk/src/accounts/grpcUserAccountSubscriber.ts index 72dbbe8aac..e771993d1c 100644 --- a/sdk/src/accounts/grpcUserAccountSubscriber.ts +++ b/sdk/src/accounts/grpcUserAccountSubscriber.ts @@ -1,17 +1,16 @@ import { ResubOpts, GrpcConfigs } from './types'; -import { Program } from '@coral-xyz/anchor'; import { PublicKey } from '@solana/web3.js'; import { UserAccount } from '../types'; import { WebSocketUserAccountSubscriber } from './webSocketUserAccountSubscriber'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class grpcUserAccountSubscriber extends WebSocketUserAccountSubscriber { private grpcConfigs: GrpcConfigs; public constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: DriftProgram, userAccountPublicKey: PublicKey, resubOpts?: ResubOpts ) { diff --git a/sdk/src/accounts/grpcUserStatsAccountSubscriber.ts b/sdk/src/accounts/grpcUserStatsAccountSubscriber.ts index 59bd837ffd..17db7f058b 100644 --- a/sdk/src/accounts/grpcUserStatsAccountSubscriber.ts +++ b/sdk/src/accounts/grpcUserStatsAccountSubscriber.ts @@ -1,17 +1,16 @@ import { ResubOpts, GrpcConfigs } from './types'; -import { Program } from '@coral-xyz/anchor'; import { PublicKey } from '@solana/web3.js'; import { UserStatsAccount } from '../types'; import { WebSocketUserStatsAccountSubscriber } from './webSocketUserStatsAccountSubsriber'; import { grpcAccountSubscriber } from './grpcAccountSubscriber'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class grpcUserStatsAccountSubscriber extends WebSocketUserStatsAccountSubscriber { private grpcConfigs: GrpcConfigs; public constructor( grpcConfigs: GrpcConfigs, - program: Program, + program: DriftProgram, userStatsAccountPublicKey: PublicKey, resubOpts?: ResubOpts ) { diff --git a/sdk/src/accounts/laserProgramAccountSubscriber.ts b/sdk/src/accounts/laserProgramAccountSubscriber.ts index 059cb40f67..dff1258233 100644 --- a/sdk/src/accounts/laserProgramAccountSubscriber.ts +++ b/sdk/src/accounts/laserProgramAccountSubscriber.ts @@ -1,5 +1,4 @@ import { GrpcConfigs, ResubOpts } from './types'; -import { Program } from '@coral-xyz/anchor'; import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js'; import * as Buffer from 'buffer'; import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber'; @@ -13,7 +12,7 @@ import { CompressionAlgorithms, CommitmentLevel, } from '../isomorphic/grpc'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; type LaserCommitment = (typeof LaserCommitmentLevel)[keyof typeof LaserCommitmentLevel]; @@ -39,7 +38,7 @@ export class LaserstreamProgramAccountSubscriber< commitmentLevel: CommitmentLevel, subscriptionName: string, accountDiscriminator: string, - program: Program, + program: DriftProgram, decodeBufferFn: (accountName: string, ix: Buffer) => T, options: { filters: MemcmpFilter[] } = { filters: [] }, resubOpts?: ResubOpts @@ -60,7 +59,7 @@ export class LaserstreamProgramAccountSubscriber< grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, - program: Program, + program: DriftProgram, decodeBufferFn: (accountName: string, ix: Buffer) => U, options: { filters: MemcmpFilter[] } = { filters: [], diff --git a/sdk/src/accounts/oneShotUserAccountSubscriber.ts b/sdk/src/accounts/oneShotUserAccountSubscriber.ts index 73bdd136ab..3a829807b4 100644 --- a/sdk/src/accounts/oneShotUserAccountSubscriber.ts +++ b/sdk/src/accounts/oneShotUserAccountSubscriber.ts @@ -1,9 +1,8 @@ import { Commitment, PublicKey } from '@solana/web3.js'; import { UserAccount } from '../types'; import { BasicUserAccountSubscriber } from './basicUserAccountSubscriber'; -import { Program } from '@coral-xyz/anchor'; import { UserAccountSubscriber } from './types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; /** * Simple implementation of UserAccountSubscriber. It will fetch the UserAccount @@ -14,11 +13,11 @@ export class OneShotUserAccountSubscriber extends BasicUserAccountSubscriber implements UserAccountSubscriber { - program: Program; + program: DriftProgram; commitment: Commitment; public constructor( - program: Program, + program: DriftProgram, userAccountPublicKey: PublicKey, data?: UserAccount, slot?: number, diff --git a/sdk/src/accounts/oneShotUserStatsAccountSubscriber.ts b/sdk/src/accounts/oneShotUserStatsAccountSubscriber.ts index e4e9c0c2aa..003e4313cf 100644 --- a/sdk/src/accounts/oneShotUserStatsAccountSubscriber.ts +++ b/sdk/src/accounts/oneShotUserStatsAccountSubscriber.ts @@ -1,9 +1,8 @@ import { Commitment, PublicKey } from '@solana/web3.js'; -import { parseUserStatsAccount, UserStatsAccount } from '../types'; +import { UserStatsAccount } from '../types'; import { BasicUserStatsAccountSubscriber } from './basicUserStatsAccountSubscriber'; -import { Program } from '@coral-xyz/anchor'; import { UserStatsAccountSubscriber } from './types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; /** * Simple implementation of UserStatsAccountSubscriber. It will fetch the UserStatsAccount @@ -14,11 +13,11 @@ export class OneShotUserStatsAccountSubscriber extends BasicUserStatsAccountSubscriber implements UserStatsAccountSubscriber { - program: Program; + program: DriftProgram; commitment: Commitment; public constructor( - program: Program, + program: DriftProgram, userStatsAccountPublicKey: PublicKey, data?: UserStatsAccount, slot?: number, @@ -57,7 +56,7 @@ export class OneShotUserStatsAccountSubscriber ); if (dataAndContext.context.slot > (this.userStats?.slot ?? 0)) { this.userStats = { - data: parseUserStatsAccount(dataAndContext.data), + data: dataAndContext.data as UserStatsAccount, slot: dataAndContext.context.slot, }; } diff --git a/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts b/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts index b9e372abab..84e16ee561 100644 --- a/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts +++ b/sdk/src/accounts/pollingDriftClientAccountSubscriber.ts @@ -7,7 +7,6 @@ import { NotSubscribedError, OraclesToPoll, } from './types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { @@ -16,7 +15,6 @@ import { StateAccount, UserAccount, OracleSource, - parseAccount, } from '../types'; import { getDriftStateAccountPublicKey, @@ -29,9 +27,8 @@ import { PublicKey } from '@solana/web3.js'; import { OracleInfo, OraclePriceData } from '../oracles/types'; import { OracleClientCache } from '../oracles/oracleClientCache'; import { QUOTE_ORACLE_PRICE_DATA } from '../oracles/quoteAssetOracleClient'; -import { findAllMarketAndOracles } from '../config'; +import { findAllMarketAndOracles, DriftProgram } from '../config'; import { getOracleId } from '../oracles/oracleId'; -import { Drift } from '../idl/drift'; const ORACLE_DEFAULT_ID = getOracleId( PublicKey.default, @@ -42,7 +39,7 @@ export class PollingDriftClientAccountSubscriber implements DriftClientAccountSubscriber { isSubscribed: boolean; - program: Program; + program: DriftProgram; perpMarketIndexes: number[]; spotMarketIndexes: number[]; oracleInfos: OracleInfo[]; @@ -73,7 +70,7 @@ export class PollingDriftClientAccountSubscriber private subscriptionPromiseResolver: (val: boolean) => void; public constructor( - program: Program, + program: DriftProgram, accountLoader: BulkAccountLoader, perpMarketIndexes: number[], spotMarketIndexes: number[], @@ -258,13 +255,12 @@ export class PollingDriftClientAccountSubscriber (buffer: Buffer, slot: number) => { if (!buffer) return; - const decoded = this.program.coder.accounts.decodeUnchecked( + const data = this.program.coder.accounts.decodeUnchecked( accountToPoll.key, buffer ); - const account = parseAccount(accountToPoll.key, decoded); const dataAndSlot = { - data: account, + data, slot, }; if (accountToPoll.mapKey != undefined) { @@ -274,7 +270,7 @@ export class PollingDriftClientAccountSubscriber } // @ts-ignore - this.eventEmitter.emit(accountToPoll.eventType, account); + this.eventEmitter.emit(accountToPoll.eventType, data); this.eventEmitter.emit('update'); if (!this.isSubscribed) { @@ -332,20 +328,18 @@ export class PollingDriftClientAccountSubscriber const { buffer, slot } = bufferAndSlot; if (buffer) { - const decoded = this.program.coder.accounts.decodeUnchecked( + const data = this.program.coder.accounts.decodeUnchecked( accountToPoll.key, buffer ); - const account = parseAccount(accountToPoll.key, decoded); - if (accountToPoll.mapKey != undefined) { this[accountToPoll.key].set(accountToPoll.mapKey, { - data: account, + data, slot, }); } else { this[accountToPoll.key] = { - data: account, + data, slot, }; } diff --git a/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts b/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts index 84296cbe56..932264f87a 100644 --- a/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +++ b/sdk/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts @@ -4,19 +4,18 @@ import { HighLeverageModeConfigAccountEvents, HighLeverageModeConfigAccountSubscriber, } from './types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { PublicKey } from '@solana/web3.js'; import { BulkAccountLoader } from './bulkAccountLoader'; import { HighLeverageModeConfig } from '../types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class PollingHighLeverageModeConfigAccountSubscriber implements HighLeverageModeConfigAccountSubscriber { isSubscribed: boolean; - program: Program; + program: DriftProgram; eventEmitter: StrictEventEmitter< EventEmitter, HighLeverageModeConfigAccountEvents @@ -30,7 +29,7 @@ export class PollingHighLeverageModeConfigAccountSubscriber highLeverageModeConfigAccountAndSlot?: DataAndSlot; public constructor( - program: Program, + program: DriftProgram, publicKey: PublicKey, accountLoader: BulkAccountLoader ) { diff --git a/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts b/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts index b608aebd42..7f3a75d764 100644 --- a/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +++ b/sdk/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts @@ -4,19 +4,19 @@ import { InsuranceFundStakeAccountEvents, InsuranceFundStakeAccountSubscriber, } from './types'; -import { BN, Program } from '@coral-xyz/anchor'; +import { BN } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { PublicKey } from '@solana/web3.js'; import { BulkAccountLoader } from './bulkAccountLoader'; import { InsuranceFundStake } from '../types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class PollingInsuranceFundStakeAccountSubscriber implements InsuranceFundStakeAccountSubscriber { isSubscribed: boolean; - program: Program; + program: DriftProgram; eventEmitter: StrictEventEmitter< EventEmitter, InsuranceFundStakeAccountEvents @@ -30,7 +30,7 @@ export class PollingInsuranceFundStakeAccountSubscriber insuranceFundStakeAccountAndSlot?: DataAndSlot; public constructor( - program: Program, + program: DriftProgram, publicKey: PublicKey, accountLoader: BulkAccountLoader ) { diff --git a/sdk/src/accounts/pollingOracleAccountSubscriber.ts b/sdk/src/accounts/pollingOracleAccountSubscriber.ts index bdb6e74343..d2d4500b4d 100644 --- a/sdk/src/accounts/pollingOracleAccountSubscriber.ts +++ b/sdk/src/accounts/pollingOracleAccountSubscriber.ts @@ -4,7 +4,7 @@ import { OracleEvents, OracleAccountSubscriber, } from './types'; -import { Program } from '@coral-xyz/anchor'; + import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { PublicKey } from '@solana/web3.js'; @@ -13,7 +13,6 @@ import { OracleClient, OraclePriceData } from '../oracles/types'; export class PollingOracleAccountSubscriber implements OracleAccountSubscriber { isSubscribed: boolean; - program: Program; eventEmitter: StrictEventEmitter; publicKey: PublicKey; diff --git a/sdk/src/accounts/pollingTokenAccountSubscriber.ts b/sdk/src/accounts/pollingTokenAccountSubscriber.ts index 398b462032..a7f088ff22 100644 --- a/sdk/src/accounts/pollingTokenAccountSubscriber.ts +++ b/sdk/src/accounts/pollingTokenAccountSubscriber.ts @@ -4,7 +4,7 @@ import { TokenAccountEvents, TokenAccountSubscriber, } from './types'; -import { Program } from '@coral-xyz/anchor'; + import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { PublicKey } from '@solana/web3.js'; @@ -14,7 +14,6 @@ import { parseTokenAccount } from '../token'; export class PollingTokenAccountSubscriber implements TokenAccountSubscriber { isSubscribed: boolean; - program: Program; eventEmitter: StrictEventEmitter; publicKey: PublicKey; diff --git a/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts b/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts index a808f09369..11a34be5a1 100644 --- a/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts +++ b/sdk/src/accounts/pollingUserStatsAccountSubscriber.ts @@ -4,19 +4,19 @@ import { UserStatsAccountSubscriber, UserStatsAccountEvents, } from './types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; -import { PublicKey } from '@solana/web3.js'; -import { parseUserStatsAccount, UserStatsAccount } from '../types'; +import { Context, PublicKey } from '@solana/web3.js'; +import { UserStatsAccount } from '../types'; import { BulkAccountLoader } from './bulkAccountLoader'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; +import { Address } from '@coral-xyz/anchor'; export class PollingUserStatsAccountSubscriber implements UserStatsAccountSubscriber { isSubscribed: boolean; - program: Program; + program: DriftProgram; eventEmitter: StrictEventEmitter; userStatsAccountPublicKey: PublicKey; @@ -27,7 +27,7 @@ export class PollingUserStatsAccountSubscriber userStats?: DataAndSlot; public constructor( - program: Program, + program: DriftProgram, userStatsAccountPublicKey: PublicKey, accountLoader: BulkAccountLoader ) { @@ -98,23 +98,33 @@ export class PollingUserStatsAccountSubscriber } async fetch(): Promise { + let dataAndContext: { + data: UserStatsAccount | null; + context: { + slot: number; + }; + }; try { - const dataAndContext = - await this.program.account.userStats.fetchAndContext( - this.userStatsAccountPublicKey, - this.accountLoader.commitment - ); - if (dataAndContext.context.slot > (this.userStats?.slot ?? 0)) { - this.userStats = { - data: parseUserStatsAccount(dataAndContext.data), - slot: dataAndContext.context.slot, + dataAndContext = (await this.program.account.userStats.fetchAndContext( + this.userStatsAccountPublicKey, + this.accountLoader.commitment + )) as { + data: UserStatsAccount | null; + context: { + slot: number; }; - } + }; } catch (e) { console.log( `PollingUserStatsAccountSubscriber.fetch() UserStatsAccount does not exist: ${e.message}` ); } + if (dataAndContext.context.slot > (this.userStats?.slot ?? 0)) { + this.userStats = { + data: dataAndContext.data, + slot: dataAndContext.context.slot, + }; + } } doesAccountExist(): boolean { diff --git a/sdk/src/accounts/webSocketAccountSubscriber.ts b/sdk/src/accounts/webSocketAccountSubscriber.ts index 4db1eac61f..8b48006098 100644 --- a/sdk/src/accounts/webSocketAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketAccountSubscriber.ts @@ -4,16 +4,16 @@ import { AccountSubscriber, ResubOpts, } from './types'; -import { AnchorProvider, Program } from '@coral-xyz/anchor'; +import { AnchorProvider } from '@coral-xyz/anchor'; import { AccountInfo, Commitment, Context, PublicKey } from '@solana/web3.js'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class WebSocketAccountSubscriber implements AccountSubscriber { dataAndSlot?: DataAndSlot; bufferAndSlot?: BufferAndSlot; accountName: string; logAccountName: string; - program: Program; + program: DriftProgram; accountPublicKey: PublicKey; decodeBufferFn: (buffer: Buffer) => T; onChange: (data: T) => void; @@ -30,7 +30,7 @@ export class WebSocketAccountSubscriber implements AccountSubscriber { public constructor( accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts, diff --git a/sdk/src/accounts/webSocketAccountSubscriberV2.ts b/sdk/src/accounts/webSocketAccountSubscriberV2.ts index 9c4f26fc29..5ef8e1db43 100644 --- a/sdk/src/accounts/webSocketAccountSubscriberV2.ts +++ b/sdk/src/accounts/webSocketAccountSubscriberV2.ts @@ -4,7 +4,7 @@ import { ResubOpts, BufferAndSlot, } from './types'; -import { AnchorProvider, Program } from '@coral-xyz/anchor'; +import { AnchorProvider } from '@coral-xyz/anchor'; import { AccountInfoBase, AccountInfoWithBase64EncodedData, @@ -19,7 +19,7 @@ import { } from 'gill'; import { PublicKey } from '@solana/web3.js'; import bs58 from 'bs58'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; /** * WebSocketAccountSubscriberV2 @@ -74,7 +74,7 @@ export class WebSocketAccountSubscriberV2 implements AccountSubscriber { bufferAndSlot?: BufferAndSlot; accountName: string; logAccountName: string; - program: Program; + program: DriftProgram; accountPublicKey: PublicKey; decodeBufferFn: (buffer: Buffer) => T; onChange: (data: T) => void; @@ -112,7 +112,7 @@ export class WebSocketAccountSubscriberV2 implements AccountSubscriber { */ public constructor( accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts, @@ -211,6 +211,10 @@ export class WebSocketAccountSubscriberV2 implements AccountSubscriber { * - if `usePollingInsteadOfResub` is true, start polling loop; * - otherwise, resubscribe to WS immediately. */ + console.info('ws subscribe*****'); + console.info('ws subscribe*****'); + console.info('ws subscribe*****'); + if (this.listenerId != null || this.isUnsubscribing) { if (this.resubOpts.logResubMessages) { console.log( diff --git a/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts b/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts index 6d5edc9005..05569fa979 100644 --- a/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketDriftClientAccountSubscriber.ts @@ -7,13 +7,7 @@ import { NotSubscribedError, ResubOpts, } from './types'; -import { - PerpMarketAccount, - SpotMarketAccount, - StateAccount, - parseSpotMarketAccount, -} from '../types'; -import { Program } from '@coral-xyz/anchor'; +import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { @@ -28,12 +22,11 @@ import { Commitment, PublicKey } from '@solana/web3.js'; import { OracleInfo, OraclePriceData } from '../oracles/types'; import { OracleClientCache } from '../oracles/oracleClientCache'; import { QUOTE_ORACLE_PRICE_DATA } from '../oracles/quoteAssetOracleClient'; -import { findAllMarketAndOracles } from '../config'; +import { findAllMarketAndOracles, DriftProgram } from '../config'; import { findDelistedPerpMarketsAndOracles } from './utils'; import { getOracleId } from '../oracles/oracleId'; import { OracleSource } from '../types'; import { WebSocketAccountSubscriberV2 } from './webSocketAccountSubscriberV2'; -import { Drift } from '../idl/drift'; const ORACLE_DEFAULT_ID = getOracleId( PublicKey.default, @@ -44,7 +37,7 @@ export class WebSocketDriftClientAccountSubscriber implements DriftClientAccountSubscriber { isSubscribed: boolean; - program: Program; + program: DriftProgram; commitment?: Commitment; perpMarketIndexes: number[]; spotMarketIndexes: number[]; @@ -76,7 +69,7 @@ export class WebSocketDriftClientAccountSubscriber initialOraclePriceData: Map; customPerpMarketAccountSubscriber?: new ( accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -84,7 +77,7 @@ export class WebSocketDriftClientAccountSubscriber ) => AccountSubscriber; customOracleAccountSubscriber?: new ( accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -96,7 +89,7 @@ export class WebSocketDriftClientAccountSubscriber protected subscriptionPromiseResolver: (val: boolean) => void; public constructor( - program: Program, + program: DriftProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], @@ -106,7 +99,7 @@ export class WebSocketDriftClientAccountSubscriber commitment?: Commitment, customPerpMarketAccountSubscriber?: new ( accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -114,7 +107,7 @@ export class WebSocketDriftClientAccountSubscriber ) => WebSocketAccountSubscriberV2 | WebSocketAccountSubscriber, customOracleAccountSubscriber?: new ( accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -174,9 +167,10 @@ export class WebSocketDriftClientAccountSubscriber this.program.programId ); + console.info('start state account sub'); // create and activate main state account subscription this.stateAccountSubscriber = new WebSocketAccountSubscriber( - 'state', + 'State', this.program, statePublicKey, undefined, @@ -187,6 +181,7 @@ export class WebSocketDriftClientAccountSubscriber this.eventEmitter.emit('stateAccountUpdate', data); this.eventEmitter.emit('update'); }); + console.info('end state account sub'); // set initial data to avoid spamming getAccountInfo calls in webSocketAccountSubscriber await this.setInitialData(); @@ -245,7 +240,7 @@ export class WebSocketDriftClientAccountSubscriber const perpMarket = this.program.coder.accounts.decode( 'perpMarket', accountInfo.data - ); + ) as PerpMarketAccount; return [perpMarket.marketIndex, perpMarket]; }) ); @@ -267,11 +262,10 @@ export class WebSocketDriftClientAccountSubscriber spotMarketAccountInfos .filter((accountInfo) => !!accountInfo) .map((accountInfo) => { - const decoded = this.program.coder.accounts.decode( + const spotMarket = this.program.coder.accounts.decode( 'spotMarket', accountInfo.data - ); - const spotMarket = parseSpotMarketAccount(decoded); + ) as SpotMarketAccount; return [spotMarket.marketIndex, spotMarket]; }) ); diff --git a/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts b/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts index 36bf85474f..ead733090f 100644 --- a/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts +++ b/sdk/src/accounts/webSocketDriftClientAccountSubscriberV2.ts @@ -12,10 +12,8 @@ import { PerpMarketAccount, SpotMarketAccount, StateAccount, - parseSpotMarketAccount, - parsePerpMarketAccount, } from '../types'; -import { Program } from '@coral-xyz/anchor'; + import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { @@ -47,7 +45,7 @@ import { } from '../memcmp'; import { WebSocketProgramAccountsSubscriberV2 } from './webSocketProgramAccountsSubscriberV2'; import { WebSocketAccountSubscriberV2 } from './webSocketAccountSubscriberV2'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; const ORACLE_DEFAULT_ID = getOracleId( PublicKey.default, OracleSource.QUOTE_ASSET @@ -57,7 +55,7 @@ export class WebSocketDriftClientAccountSubscriberV2 implements DriftClientAccountSubscriber { isSubscribed: boolean; - program: Program; + program: DriftProgram; commitment?: Commitment; perpMarketIndexes: number[]; spotMarketIndexes: number[]; @@ -100,7 +98,7 @@ export class WebSocketDriftClientAccountSubscriberV2 string; public constructor( - program: Program, + program: DriftProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], @@ -206,7 +204,7 @@ export class WebSocketDriftClientAccountSubscriberV2 this.perpMarketAllAccountsSubscriber = new WebSocketProgramAccountsSubscriberV2( 'PerpMarketAccountsSubscriber', - 'PerpMarket', + 'perpMarket', this.program, (_accountName: string, buffer: Buffer) => { const decoded = @@ -214,7 +212,7 @@ export class WebSocketDriftClientAccountSubscriberV2 'perpMarket', buffer ); - return parsePerpMarketAccount(decoded); + return decoded as PerpMarketAccount; }, { filters: [getPerpMarketAccountsFilter()], @@ -227,7 +225,7 @@ export class WebSocketDriftClientAccountSubscriberV2 this.spotMarketAllAccountsSubscriber = new WebSocketProgramAccountsSubscriberV2( 'SpotMarketAccountsSubscriber', - 'SpotMarket', + 'spotMarket', this.program, (_accountName: string, buffer: Buffer) => { const decoded = @@ -235,7 +233,7 @@ export class WebSocketDriftClientAccountSubscriberV2 'spotMarket', buffer ); - return parseSpotMarketAccount(decoded); + return decoded as SpotMarketAccount; }, { filters: [getSpotMarketAccountsFilter()], diff --git a/sdk/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts b/sdk/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts index 17f19913ce..098c2e885c 100644 --- a/sdk/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts @@ -5,13 +5,12 @@ import { HighLeverageModeConfigAccountEvents, HighLeverageModeConfigAccountSubscriber, } from './types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Commitment, PublicKey } from '@solana/web3.js'; import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { HighLeverageModeConfig } from '../types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class WebSocketHighLeverageModeConfigAccountSubscriber implements HighLeverageModeConfigAccountSubscriber @@ -19,7 +18,7 @@ export class WebSocketHighLeverageModeConfigAccountSubscriber isSubscribed: boolean; resubTimeoutMs?: number; commitment?: Commitment; - program: Program; + program: DriftProgram; eventEmitter: StrictEventEmitter< EventEmitter, HighLeverageModeConfigAccountEvents @@ -29,7 +28,7 @@ export class WebSocketHighLeverageModeConfigAccountSubscriber highLeverageModeConfigDataAccountSubscriber: AccountSubscriber; public constructor( - program: Program, + program: DriftProgram, highLeverageModeConfigAccountPublicKey: PublicKey, resubTimeoutMs?: number, commitment?: Commitment diff --git a/sdk/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts b/sdk/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts index f2a731ed39..bf0d057e60 100644 --- a/sdk/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts @@ -5,13 +5,12 @@ import { InsuranceFundStakeAccountEvents, InsuranceFundStakeAccountSubscriber, } from './types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Commitment, PublicKey } from '@solana/web3.js'; import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { InsuranceFundStake } from '../types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class WebSocketInsuranceFundStakeAccountSubscriber implements InsuranceFundStakeAccountSubscriber @@ -19,7 +18,7 @@ export class WebSocketInsuranceFundStakeAccountSubscriber isSubscribed: boolean; resubTimeoutMs?: number; commitment?: Commitment; - program: Program; + program: DriftProgram; eventEmitter: StrictEventEmitter< EventEmitter, InsuranceFundStakeAccountEvents @@ -29,7 +28,7 @@ export class WebSocketInsuranceFundStakeAccountSubscriber insuranceFundStakeDataAccountSubscriber: AccountSubscriber; public constructor( - program: Program, + program: DriftProgram, insuranceFundStakeAccountPublicKey: PublicKey, resubTimeoutMs?: number, commitment?: Commitment diff --git a/sdk/src/accounts/webSocketProgramAccountSubscriber.ts b/sdk/src/accounts/webSocketProgramAccountSubscriber.ts index 85a0e8fe95..fe9266dc4c 100644 --- a/sdk/src/accounts/webSocketProgramAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketProgramAccountSubscriber.ts @@ -1,5 +1,5 @@ import { BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types'; -import { AnchorProvider, Program } from '@coral-xyz/anchor'; +import { AnchorProvider } from '@coral-xyz/anchor'; import { Commitment, Context, @@ -8,7 +8,7 @@ import { PublicKey, } from '@solana/web3.js'; import * as Buffer from 'buffer'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class WebSocketProgramAccountSubscriber implements ProgramAccountSubscriber @@ -17,7 +17,7 @@ export class WebSocketProgramAccountSubscriber accountDiscriminator: string; bufferAndSlot?: BufferAndSlot; bufferAndSlotMap: Map = new Map(); - program: Program; + program: DriftProgram; decodeBuffer: (accountName: string, ix: Buffer) => T; onChange: ( accountId: PublicKey, @@ -36,7 +36,7 @@ export class WebSocketProgramAccountSubscriber public constructor( subscriptionName: string, accountDiscriminator: string, - program: Program, + program: DriftProgram, decodeBufferFn: (accountName: string, ix: Buffer) => T, options: { filters: MemcmpFilter[]; commitment?: Commitment } = { filters: [], diff --git a/sdk/src/accounts/webSocketProgramAccountsSubscriberV2.ts b/sdk/src/accounts/webSocketProgramAccountsSubscriberV2.ts index 02508638a4..f9e94ead6e 100644 --- a/sdk/src/accounts/webSocketProgramAccountsSubscriberV2.ts +++ b/sdk/src/accounts/webSocketProgramAccountsSubscriberV2.ts @@ -1,5 +1,5 @@ import { BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types'; -import { AnchorProvider, Program } from '@coral-xyz/anchor'; +import { AnchorProvider } from '@coral-xyz/anchor'; import { Commitment, Context, MemcmpFilter, PublicKey } from '@solana/web3.js'; import { AccountInfoBase, @@ -13,7 +13,7 @@ import { Commitment as GillCommitment, } from 'gill'; import bs58 from 'bs58'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; type ProgramAccountSubscriptionAsyncIterable = AsyncIterable< Readonly<{ @@ -99,7 +99,7 @@ export class WebSocketProgramAccountsSubscriberV2 subscriptionName: string; accountDiscriminator: string; bufferAndSlotMap: Map = new Map(); - program: Program; + program: DriftProgram; decodeBuffer: (accountName: string, ix: Buffer) => T; onChange: ( accountId: PublicKey, @@ -143,7 +143,7 @@ export class WebSocketProgramAccountsSubscriberV2 public constructor( subscriptionName: string, accountDiscriminator: string, - program: Program, + program: DriftProgram, decodeBufferFn: (accountName: string, ix: Buffer) => T, options: { filters: MemcmpFilter[]; commitment?: Commitment } = { filters: [], diff --git a/sdk/src/accounts/webSocketUserAccountSubscriber.ts b/sdk/src/accounts/webSocketUserAccountSubscriber.ts index 766f3c2db7..f8fb766b89 100644 --- a/sdk/src/accounts/webSocketUserAccountSubscriber.ts +++ b/sdk/src/accounts/webSocketUserAccountSubscriber.ts @@ -6,26 +6,25 @@ import { UserAccountSubscriber, ResubOpts, } from './types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Commitment, PublicKey } from '@solana/web3.js'; import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { UserAccount } from '../types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class WebSocketUserAccountSubscriber implements UserAccountSubscriber { isSubscribed: boolean; resubOpts?: ResubOpts; commitment?: Commitment; - program: Program; + program: DriftProgram; eventEmitter: StrictEventEmitter; userAccountPublicKey: PublicKey; userDataAccountSubscriber: AccountSubscriber; public constructor( - program: Program, + program: DriftProgram, userAccountPublicKey: PublicKey, resubOpts?: ResubOpts, commitment?: Commitment diff --git a/sdk/src/accounts/webSocketUserStatsAccountSubsriber.ts b/sdk/src/accounts/webSocketUserStatsAccountSubsriber.ts index b15d91bc31..7d868f8174 100644 --- a/sdk/src/accounts/webSocketUserStatsAccountSubsriber.ts +++ b/sdk/src/accounts/webSocketUserStatsAccountSubsriber.ts @@ -6,13 +6,12 @@ import { UserStatsAccountEvents, ResubOpts, } from './types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Commitment, PublicKey } from '@solana/web3.js'; import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber'; import { UserStatsAccount } from '../types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class WebSocketUserStatsAccountSubscriber implements UserStatsAccountSubscriber @@ -20,14 +19,14 @@ export class WebSocketUserStatsAccountSubscriber isSubscribed: boolean; resubOpts?: ResubOpts; commitment?: Commitment; - program: Program; + program: DriftProgram; eventEmitter: StrictEventEmitter; userStatsAccountPublicKey: PublicKey; userStatsAccountSubscriber: AccountSubscriber; public constructor( - program: Program, + program: DriftProgram, userStatsAccountPublicKey: PublicKey, resubOpts?: ResubOpts, commitment?: Commitment diff --git a/sdk/src/accounts/websocketProgramUserAccountSubscriber.ts b/sdk/src/accounts/websocketProgramUserAccountSubscriber.ts index 74e6e7fd1b..a550362630 100644 --- a/sdk/src/accounts/websocketProgramUserAccountSubscriber.ts +++ b/sdk/src/accounts/websocketProgramUserAccountSubscriber.ts @@ -4,13 +4,12 @@ import { UserAccountEvents, UserAccountSubscriber, } from './types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Context, PublicKey } from '@solana/web3.js'; import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber'; import { UserAccount } from '../types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class WebSocketProgramUserAccountSubscriber implements UserAccountSubscriber @@ -19,12 +18,12 @@ export class WebSocketProgramUserAccountSubscriber eventEmitter: StrictEventEmitter; private userAccountPublicKey: PublicKey; - private program: Program; + private program: DriftProgram; private programSubscriber: WebSocketProgramAccountSubscriber; private userAccountAndSlot?: DataAndSlot; public constructor( - program: Program, + program: DriftProgram, userAccountPublicKey: PublicKey, programSubscriber: WebSocketProgramAccountSubscriber ) { diff --git a/sdk/src/addresses/pda.ts b/sdk/src/addresses/pda.ts index 13d7bde79f..4e3f026497 100644 --- a/sdk/src/addresses/pda.ts +++ b/sdk/src/addresses/pda.ts @@ -11,7 +11,7 @@ import { SpotMarketAccount, TokenProgramFlag } from '../types'; export async function getDriftStateAccountPublicKeyAndNonce( programId: PublicKey ): Promise<[PublicKey, number]> { - return PublicKey.findProgramAddress( + return PublicKey.findProgramAddressSync( [Buffer.from(anchor.utils.bytes.utf8.encode('drift_state'))], programId ); diff --git a/sdk/src/config.ts b/sdk/src/config.ts index 5deada1669..3df3c528b3 100644 --- a/sdk/src/config.ts +++ b/sdk/src/config.ts @@ -1,10 +1,9 @@ +import { Program, ProgramAccount } from '@coral-xyz/anchor'; import { ConfirmOptions, PublicKey } from '@solana/web3.js'; import { - PerpMarketAccount, - SpotMarketAccount, - parsePerpMarketAccount, - parseSpotMarketAccount, -} from './types'; + ON_DEMAND_DEVNET_PID, + ON_DEMAND_MAINNET_PID, +} from '@switchboard-xyz/on-demand'; import { DevnetPerpMarkets, MainnetPerpMarkets, @@ -12,19 +11,17 @@ import { PerpMarkets, } from './constants/perpMarkets'; import { - SpotMarketConfig, - SpotMarkets, DevnetSpotMarkets, MainnetSpotMarkets, + SpotMarketConfig, + SpotMarkets, } from './constants/spotMarkets'; -import { OracleInfo } from './oracles/types'; -import { Program, ProgramAccount } from '@coral-xyz/anchor'; -import { - ON_DEMAND_DEVNET_PID, - ON_DEMAND_MAINNET_PID, -} from '@switchboard-xyz/on-demand'; -import { getOracleId } from './oracles/oracleId'; import { Drift } from './idl/drift'; +import { getOracleId } from './oracles/oracleId'; +import { OracleInfo } from './oracles/types'; +import { PerpMarketAccount, SpotMarketAccount } from './types'; + +export type DriftProgram = Program; type DriftConfig = { ENV: DriftEnv; @@ -173,9 +170,7 @@ export function getMarketsAndOraclesForSubscription( }; } -export async function findAllMarketAndOracles( - program: Program -): Promise<{ +export async function findAllMarketAndOracles(program: DriftProgram): Promise<{ perpMarketIndexes: number[]; perpMarketAccounts: PerpMarketAccount[]; spotMarketIndexes: number[]; @@ -196,13 +191,13 @@ export async function findAllMarketAndOracles( const perpMarketProgramAccounts: ProgramAccount[] = perpMarketProgramAccountsRaw.map((account) => ({ - ...account, - account: parsePerpMarketAccount(account.account), + publicKey: account.publicKey, + account: account.account as PerpMarketAccount, })); const spotMarketProgramAccounts: ProgramAccount[] = spotMarketProgramAccountsRaw.map((account) => ({ - ...account, - account: parseSpotMarketAccount(account.account), + publicKey: account.publicKey, + account: account.account as SpotMarketAccount, })); for (const perpMarketProgramAccount of perpMarketProgramAccounts) { diff --git a/sdk/src/constituentMap/pollingConstituentAccountSubscriber.ts b/sdk/src/constituentMap/pollingConstituentAccountSubscriber.ts index 8da5e168d0..7842e5f04f 100644 --- a/sdk/src/constituentMap/pollingConstituentAccountSubscriber.ts +++ b/sdk/src/constituentMap/pollingConstituentAccountSubscriber.ts @@ -3,18 +3,17 @@ import { ConstituentAccountEvents, ConstituentAccountSubscriber, } from '../accounts/types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Commitment, MemcmpFilter } from '@solana/web3.js'; import { ConstituentMap } from './constituentMap'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class PollingConstituentAccountSubscriber implements ConstituentAccountSubscriber { isSubscribed: boolean; - program: Program; + program: DriftProgram; frequency: number; commitment?: Commitment; additionalFilters?: MemcmpFilter[]; @@ -25,7 +24,7 @@ export class PollingConstituentAccountSubscriber public constructor( constituentMap: ConstituentMap, - program: Program, + program: DriftProgram, frequency: number, commitment?: Commitment, additionalFilters?: MemcmpFilter[] diff --git a/sdk/src/constituentMap/webSocketConstituentAccountSubscriber.ts b/sdk/src/constituentMap/webSocketConstituentAccountSubscriber.ts index 4502867621..76a39c9417 100644 --- a/sdk/src/constituentMap/webSocketConstituentAccountSubscriber.ts +++ b/sdk/src/constituentMap/webSocketConstituentAccountSubscriber.ts @@ -3,7 +3,6 @@ import { ConstituentAccountEvents, ConstituentAccountSubscriber, } from '../accounts/types'; -import { Program } from '@coral-xyz/anchor'; import StrictEventEmitter from 'strict-event-emitter-types'; import { EventEmitter } from 'events'; import { Commitment, Context, MemcmpFilter, PublicKey } from '@solana/web3.js'; @@ -11,7 +10,7 @@ import { ConstituentAccount } from '../types'; import { WebSocketProgramAccountSubscriber } from '../accounts/webSocketProgramAccountSubscriber'; import { getConstituentFilter } from '../memcmp'; import { ConstituentMap } from './constituentMap'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class WebSocketConstituentAccountSubscriber implements ConstituentAccountSubscriber @@ -19,7 +18,7 @@ export class WebSocketConstituentAccountSubscriber isSubscribed: boolean; resubTimeoutMs?: number; commitment?: Commitment; - program: Program; + program: DriftProgram; eventEmitter: StrictEventEmitter; constituentDataAccountSubscriber: WebSocketProgramAccountSubscriber; @@ -28,7 +27,7 @@ export class WebSocketConstituentAccountSubscriber public constructor( constituentMap: ConstituentMap, - program: Program, + program: DriftProgram, resubTimeoutMs?: number, commitment?: Commitment, additionalFilters?: MemcmpFilter[] diff --git a/sdk/src/decode/customCoder.ts b/sdk/src/decode/customCoder.ts index f39c7e5081..533149adc7 100644 --- a/sdk/src/decode/customCoder.ts +++ b/sdk/src/decode/customCoder.ts @@ -1,104 +1,50 @@ import { Buffer } from 'buffer'; +import { Layout } from 'buffer-layout'; import camelcase from 'camelcase'; -import { Idl, IdlTypeDef } from '@coral-xyz/anchor-29/dist/cjs/idl'; -import { - AccountsCoder, - BorshAccountsCoder, - BorshEventCoder, - BorshInstructionCoder, - Coder, -} from '@coral-xyz/anchor-29/dist/cjs/coder'; -import { BorshTypesCoder } from '@coral-xyz/anchor-29/dist/cjs/coder/borsh/types'; +import { BorshAccountsCoder, BorshCoder, Idl } from '@coral-xyz/anchor'; import { discriminator } from '@coral-xyz/anchor-29/dist/cjs/coder/borsh/discriminator'; +import { IdlDiscriminator } from '@coral-xyz/anchor/dist/cjs/idl'; -export class CustomBorshCoder< - A extends string = string, - T extends string = string, -> implements Coder -{ - readonly idl: Idl; - - /** - * Instruction coder. - */ - readonly instruction: BorshInstructionCoder; - +export class CustomBorshCoder extends BorshCoder { /** * Account coder. */ - readonly accounts: CustomBorshAccountsCoder; - - /** - * Coder for events. - */ - readonly events: BorshEventCoder; - - /** - * Coder for user-defined types. - */ - readonly types: BorshTypesCoder; - + override readonly accounts: CustomBorshAccountsCoder; constructor(idl: Idl) { - this.instruction = new BorshInstructionCoder(idl); + super(idl); + // only need to patch the accounts encoder + // @ts-ignore this.accounts = new CustomBorshAccountsCoder(idl); - this.events = new BorshEventCoder(idl); - this.types = new BorshTypesCoder(idl); - this.idl = idl; } } /** * Custom accounts coder that wraps BorshAccountsCoder to fix encode buffer sizing. */ -export class CustomBorshAccountsCoder - implements AccountsCoder -{ - private baseCoder: BorshAccountsCoder; - private idl: Idl; - +export class CustomBorshAccountsCoder< + A extends string = string, +> extends BorshAccountsCoder { public constructor(idl: Idl) { - this.baseCoder = new BorshAccountsCoder(idl); - this.idl = idl; + super(idl); } public async encode(accountName: A, account: T): Promise { - const idlAcc = this.idl.accounts?.find((acc) => acc.name === accountName); - if (!idlAcc) { - throw new Error(`Unknown account not found in idl: ${accountName}`); - } - - const buffer = Buffer.alloc(this.size(idlAcc)); // fix encode issue - use proper size instead of fixed 1000 - const layout = this.baseCoder['accountLayouts'].get(accountName); + const buffer = Buffer.alloc(this.size(accountName)); // fix encode issue - use proper size instead of fixed 1000 + const layout = ( + this['accountLayouts'] as Map< + A, + { discriminator: IdlDiscriminator; layout: Layout } + > + ).get(accountName); if (!layout) { throw new Error(`Unknown account: ${accountName}`); } - const len = layout.encode(account, buffer); + const len = layout.layout.encode(account, buffer); const accountData = buffer.slice(0, len); - const discriminator = BorshAccountsCoder.accountDiscriminator(accountName); + const discriminator = this.accountDiscriminator(accountName); return Buffer.concat([discriminator, accountData]); } - // Delegate all other methods to the base coder - public decode(accountName: A, data: Buffer): T { - return this.baseCoder.decode(accountName, data); - } - - public decodeAny(data: Buffer): T { - return this.baseCoder.decodeAny(data); - } - - public decodeUnchecked(accountName: A, ix: Buffer): T { - return this.baseCoder.decodeUnchecked(accountName, ix); - } - - public memcmp(accountName: A, appendData?: Buffer): any { - return this.baseCoder.memcmp(accountName, appendData); - } - - public size(idlAccount: IdlTypeDef): number { - return this.baseCoder.size(idlAccount); - } - /** * Calculates and returns a unique 8 byte discriminator prepended to all anchor accounts. * diff --git a/sdk/src/dlob/orderBookLevels.ts b/sdk/src/dlob/orderBookLevels.ts index 67528a51bb..186dd1ae11 100644 --- a/sdk/src/dlob/orderBookLevels.ts +++ b/sdk/src/dlob/orderBookLevels.ts @@ -416,8 +416,8 @@ const mergeByPrice = (bidsOrAsks: L2Level[]) => { * @param bids * @param asks * @param oraclePrice - * @param oracleTwap5Min - * @param markTwap5Min + * @param oracleTwap5min + * @param markTwap5min * @param grouping * @param userBids * @param userAsks @@ -426,8 +426,8 @@ export function uncrossL2( bids: L2Level[], asks: L2Level[], oraclePrice: BN, - oracleTwap5Min: BN, - markTwap5Min: BN, + oracleTwap5min: BN, + markTwap5min: BN, grouping: BN, userBids: Set, userAsks: Set @@ -470,7 +470,7 @@ export function uncrossL2( }; // This is the best estimate of the premium in the market vs oracle to filter crossing around - const referencePrice = oraclePrice.add(markTwap5Min.sub(oracleTwap5Min)); + const referencePrice = oraclePrice.add(markTwap5min.sub(oracleTwap5min)); let bidIndex = 0; let askIndex = 0; diff --git a/sdk/src/driftClient.ts b/sdk/src/driftClient.ts index 8b6ab60fad..01117798d5 100644 --- a/sdk/src/driftClient.ts +++ b/sdk/src/driftClient.ts @@ -61,7 +61,6 @@ import { TxParams, UserAccount, UserStatsAccount, - parseUserStatsAccount, ProtectedMakerModeConfig, SignedMsgOrderParamsDelegateMessage, TokenProgramFlag, @@ -222,6 +221,7 @@ import { import { TitanClient, SwapMode as TitanSwapMode } from './titan/titanClient'; import { UnifiedSwapClient } from './swap/UnifiedSwapClient'; import { Drift } from './idl/drift'; +import { DriftProgram } from './config'; /** * Union type for swap clients (Titan and Jupiter) - Legacy type @@ -245,7 +245,7 @@ type RemainingAccountParams = { export class DriftClient { connection: Connection; wallet: IWallet; - public program: Program; + public program: DriftProgram; provider: AnchorProvider; env: DriftEnv; opts?: ConfirmOptions; @@ -690,6 +690,7 @@ export class DriftClient { this.program.programId, serumMarket ); + // @ts-ignore return (await this.program.account.serumV3FulfillmentConfig.fetch( address )) as SerumV3FulfillmentConfigAccount; @@ -2043,8 +2044,8 @@ export class DriftClient { }, ]); - return programAccounts.map((programAccount) => - parseUserStatsAccount(programAccount.account) + return programAccounts.map( + (programAccount) => programAccount.account as UserStatsAccount ); } @@ -10278,7 +10279,7 @@ export class DriftClient { const postIxs: TransactionInstruction[] = []; if (accumulatorUpdateData.updates.length > 1) { const encodedParams = this.getReceiverProgram().coder.types.encode( - 'postMultiUpdatesAtomicParams', + 'PostMultiUpdatesAtomicParams', { vaa: trimmedVaa, merklePriceUpdates: accumulatorUpdateData.updates, @@ -10345,7 +10346,7 @@ export class DriftClient { const receiverProgram = this.getReceiverProgram(); const encodedParams = receiverProgram.coder.types.encode( - 'postUpdateAtomicParams', + 'PostUpdateAtomicParams', params ); @@ -11090,15 +11091,15 @@ export class DriftClient { readablePerpMarketIndex: perpMarketIndexes, }); - return this.program.instruction.updateAmmCache({ - accounts: { + return this.program.methods + .updateAmmCache() + .accounts({ state: await this.getStatePublicKey(), keeper: this.wallet.publicKey, ammCache: getAmmCachePublicKey(this.program.programId), - quoteMarket: this.getSpotMarketAccount(0).pubkey, - }, - remainingAccounts, - }); + }) + .remainingAccounts(remainingAccounts) + .instruction(); } public async updateConstituentOracleInfo( diff --git a/sdk/src/driftClientConfig.ts b/sdk/src/driftClientConfig.ts index 17869defe6..ccfee1dabd 100644 --- a/sdk/src/driftClientConfig.ts +++ b/sdk/src/driftClientConfig.ts @@ -16,7 +16,7 @@ import { ResubOpts, DelistedMarketSetting, } from './accounts/types'; -import { Coder, Program } from '@coral-xyz/anchor'; +import { Coder } from '@coral-xyz/anchor'; import { WebSocketAccountSubscriber } from './accounts/webSocketAccountSubscriber'; import { WebSocketAccountSubscriberV2 } from './accounts/webSocketAccountSubscriberV2'; import { grpcDriftClientAccountSubscriberV2 } from './accounts/grpcDriftClientAccountSubscriberV2'; @@ -25,7 +25,7 @@ import { grpcMultiUserAccountSubscriber } from './accounts/grpcMultiUserAccountS import { WebSocketProgramAccountSubscriber } from './accounts/webSocketProgramAccountSubscriber'; import { WebSocketDriftClientAccountSubscriber } from './accounts/webSocketDriftClientAccountSubscriber'; import { WebSocketDriftClientAccountSubscriberV2 } from './accounts/webSocketDriftClientAccountSubscriberV2'; -import { Drift } from './idl/drift'; +import { DriftProgram } from './config'; export type DriftClientConfig = { connection: Connection; @@ -66,7 +66,7 @@ export type DriftClientSubscriptionConfig = logResubMessages?: boolean; driftClientAccountSubscriber?: new ( grpcConfigs: GrpcConfigs, - program: Program, + program: DriftProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], @@ -85,7 +85,7 @@ export type DriftClientSubscriptionConfig = programUserAccountSubscriber?: WebSocketProgramAccountSubscriber; perpMarketAccountSubscriber?: new ( accountName: string, - program: Program, + program: DriftProgram, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => any, resubOpts?: ResubOpts, @@ -93,7 +93,7 @@ export type DriftClientSubscriptionConfig = ) => WebSocketAccountSubscriberV2 | WebSocketAccountSubscriber; /** If you use V2 here, whatever you pass for perpMarketAccountSubscriber will be ignored and it will use v2 under the hood regardless */ driftClientAccountSubscriber?: new ( - program: Program, + program: DriftProgram, perpMarketIndexes: number[], spotMarketIndexes: number[], oracleInfos: OracleInfo[], diff --git a/sdk/src/events/eventSubscriber.ts b/sdk/src/events/eventSubscriber.ts index ebac32ce25..4db0b43497 100644 --- a/sdk/src/events/eventSubscriber.ts +++ b/sdk/src/events/eventSubscriber.ts @@ -1,5 +1,4 @@ import { Connection, PublicKey, TransactionSignature } from '@solana/web3.js'; -import { Program } from '@coral-xyz/anchor'; import { DefaultEventSubscriptionOptions, EventSubscriptionOptions, @@ -24,7 +23,7 @@ import StrictEventEmitter from 'strict-event-emitter-types'; import { getSortFn } from './sort'; import { parseLogs } from './parse'; import { EventsServerLogProvider } from './eventsServerLogProvider'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class EventSubscriber { private address: PublicKey; @@ -41,7 +40,7 @@ export class EventSubscriber { public constructor( private connection: Connection, - private program: Program, + private program: DriftProgram, private options: EventSubscriptionOptions = DefaultEventSubscriptionOptions ) { this.options = Object.assign({}, DefaultEventSubscriptionOptions, options); diff --git a/sdk/src/events/fetchLogs.ts b/sdk/src/events/fetchLogs.ts index d8d7980fce..250b213d8c 100644 --- a/sdk/src/events/fetchLogs.ts +++ b/sdk/src/events/fetchLogs.ts @@ -1,4 +1,3 @@ -import { Program } from '@coral-xyz/anchor-29'; import { Connection, Finality, @@ -10,6 +9,7 @@ import { import { WrappedEvents } from './types'; import { promiseTimeout } from '../util/promiseTimeout'; import { parseLogs } from './parse'; +import { DriftProgram } from '../config'; type Log = { txSig: TransactionSignature; slot: number; logs: string[] }; type FetchLogsResponse = { @@ -135,9 +135,9 @@ function chunk(array: readonly T[], size: number): T[][] { } export class LogParser { - private program: Program; + private program: DriftProgram; - constructor(program: Program) { + constructor(program: DriftProgram) { this.program = program; } diff --git a/sdk/src/events/parse.ts b/sdk/src/events/parse.ts index dbaff4a480..8b8e0d6d98 100644 --- a/sdk/src/events/parse.ts +++ b/sdk/src/events/parse.ts @@ -1,6 +1,6 @@ -import { Program, Event } from '@coral-xyz/anchor'; +import { Event } from '@coral-xyz/anchor'; import { CuUsageEvent } from './types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; const driftProgramId = 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; const PROGRAM_LOG = 'Program log: '; @@ -11,7 +11,7 @@ const PROGRAM_DATA_START_INDEX = PROGRAM_DATA.length; const PROGRAM_INSTRUCTION_START_INDEX = PROGRAM_INSTRUCTION.length; export function parseLogs( - program: Program, + program: DriftProgram, logs: string[], programId = driftProgramId ): Event[] { @@ -20,7 +20,7 @@ export function parseLogs( } export function parseLogsWithRaw( - program: Program, + program: DriftProgram, logs: string[], programId = driftProgramId ): { events: Event[]; rawLogs: string[] } { @@ -55,7 +55,7 @@ export function parseLogsWithRaw( function handleLog( execution: ExecutionContext, log: string, - program: Program, + program: DriftProgram, programId = driftProgramId ): [Event | null, string | null, boolean] { // Executing program is drift program. @@ -71,7 +71,7 @@ function handleLog( // Handles logs from *drift* program. function handleProgramLog( log: string, - program: Program, + program: DriftProgram, programId = driftProgramId ): [Event | null, string | null, boolean] { // This is a `msg!` log or a `sol_log_data` log. diff --git a/sdk/src/events/types.ts b/sdk/src/events/types.ts index d4a31d8c9e..6602a05488 100644 --- a/sdk/src/events/types.ts +++ b/sdk/src/events/types.ts @@ -27,6 +27,7 @@ import { LPBorrowLendDepositRecord, } from '../types'; import { EventEmitter } from 'events'; +import { IdlDiscriminator } from '@coral-xyz/anchor/dist/cjs/idl'; export type EventSubscriptionOptions = { address?: PublicKey; @@ -216,6 +217,7 @@ export type LogProviderConfig = | EventsServerLogProviderConfig; export type CuUsageEvent = { + discriminator: IdlDiscriminator; name: 'CuUsage'; fields: [ { diff --git a/sdk/src/factory/oracleClient.ts b/sdk/src/factory/oracleClient.ts index 492edcfcfc..8ac011a83b 100644 --- a/sdk/src/factory/oracleClient.ts +++ b/sdk/src/factory/oracleClient.ts @@ -4,18 +4,18 @@ import { OracleClient } from '../oracles/types'; import { PythClient } from '../oracles/pythClient'; // import { SwitchboardClient } from '../oracles/switchboardClient'; import { QuoteAssetOracleClient } from '../oracles/quoteAssetOracleClient'; -import { BN, Program } from '@coral-xyz/anchor'; +import { BN } from '@coral-xyz/anchor'; import { PrelaunchOracleClient } from '../oracles/prelaunchOracleClient'; import { SwitchboardClient } from '../oracles/switchboardClient'; import { PythPullClient } from '../oracles/pythPullClient'; import { SwitchboardOnDemandClient } from '../oracles/switchboardOnDemandClient'; import { PythLazerClient } from '../oracles/pythLazerClient'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export function getOracleClient( oracleSource: OracleSource, connection: Connection, - program: Program + program: DriftProgram ): OracleClient { if (isVariant(oracleSource, 'pyth')) { return new PythClient(connection); diff --git a/sdk/src/idl/drift.json b/sdk/src/idl/drift.json index 7b834ba91f..7a76a2cb5a 100644 --- a/sdk/src/idl/drift.json +++ b/sdk/src/idl/drift.json @@ -2,7 +2,7 @@ "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH", "metadata": { "name": "drift", - "version": "2.151.0", + "version": "2.152.0", "spec": "0.1.0", "description": "Created with Anchor" }, @@ -15768,1728 +15768,63 @@ "errors": [ { "code": 6000, - "name": "InvalidSpotMarketAuthority", - "msg": "Invalid Spot Market Authority" + "name": "InvalidEd25519InstructionProgramId", + "msg": "invalid ed25519 instruction program" }, { "code": 6001, - "name": "InvalidInsuranceFundAuthority", - "msg": "Clearing house not insurance fund authority" + "name": "InvalidEd25519InstructionDataLength", + "msg": "invalid ed25519 instruction data length" }, { "code": 6002, - "name": "InsufficientDeposit", - "msg": "Insufficient deposit" + "name": "InvalidSignatureIndex", + "msg": "invalid signature index" }, { "code": 6003, - "name": "InsufficientCollateral", - "msg": "Insufficient collateral" + "name": "InvalidSignatureOffset", + "msg": "invalid signature offset" }, { "code": 6004, - "name": "SufficientCollateral", - "msg": "Sufficient collateral" + "name": "InvalidPublicKeyOffset", + "msg": "invalid public key offset" }, { "code": 6005, - "name": "MaxNumberOfPositions", - "msg": "Max number of positions taken" + "name": "InvalidMessageOffset", + "msg": "invalid message offset" }, { "code": 6006, - "name": "AdminControlsPricesDisabled", - "msg": "Admin Controls Prices Disabled" + "name": "InvalidMessageDataSize", + "msg": "invalid message data size" }, { "code": 6007, - "name": "MarketDelisted", - "msg": "Market Delisted" + "name": "InvalidInstructionIndex", + "msg": "invalid instruction index" }, { "code": 6008, - "name": "MarketIndexAlreadyInitialized", - "msg": "Market Index Already Initialized" + "name": "MessageOffsetOverflow", + "msg": "message offset overflow" }, { "code": 6009, - "name": "UserAccountAndUserPositionsAccountMismatch", - "msg": "User Account And User Positions Account Mismatch" + "name": "InvalidMessageHex", + "msg": "invalid message hex" }, { "code": 6010, - "name": "UserHasNoPositionInMarket", - "msg": "User Has No Position In Market" + "name": "InvalidMessageData", + "msg": "invalid message data" }, { "code": 6011, - "name": "InvalidInitialPeg", - "msg": "Invalid Initial Peg" - }, - { - "code": 6012, - "name": "InvalidRepegRedundant", - "msg": "AMM repeg already configured with amt given" - }, - { - "code": 6013, - "name": "InvalidRepegDirection", - "msg": "AMM repeg incorrect repeg direction" - }, - { - "code": 6014, - "name": "InvalidRepegProfitability", - "msg": "AMM repeg out of bounds pnl" - }, - { - "code": 6015, - "name": "SlippageOutsideLimit", - "msg": "Slippage Outside Limit Price" - }, - { - "code": 6016, - "name": "OrderSizeTooSmall", - "msg": "Order Size Too Small" - }, - { - "code": 6017, - "name": "InvalidUpdateK", - "msg": "Price change too large when updating K" - }, - { - "code": 6018, - "name": "AdminWithdrawTooLarge", - "msg": "Admin tried to withdraw amount larger than fees collected" - }, - { - "code": 6019, - "name": "MathError", - "msg": "Math Error" - }, - { - "code": 6020, - "name": "BnConversionError", - "msg": "Conversion to u128/u64 failed with an overflow or underflow" - }, - { - "code": 6021, - "name": "ClockUnavailable", - "msg": "Clock unavailable" - }, - { - "code": 6022, - "name": "UnableToLoadOracle", - "msg": "Unable To Load Oracles" - }, - { - "code": 6023, - "name": "PriceBandsBreached", - "msg": "Price Bands Breached" - }, - { - "code": 6024, - "name": "ExchangePaused", - "msg": "Exchange is paused" - }, - { - "code": 6025, - "name": "InvalidWhitelistToken", - "msg": "Invalid whitelist token" - }, - { - "code": 6026, - "name": "WhitelistTokenNotFound", - "msg": "Whitelist token not found" - }, - { - "code": 6027, - "name": "InvalidDiscountToken", - "msg": "Invalid discount token" - }, - { - "code": 6028, - "name": "DiscountTokenNotFound", - "msg": "Discount token not found" - }, - { - "code": 6029, - "name": "ReferrerNotFound", - "msg": "Referrer not found" - }, - { - "code": 6030, - "name": "ReferrerStatsNotFound", - "msg": "ReferrerNotFound" - }, - { - "code": 6031, - "name": "ReferrerMustBeWritable", - "msg": "ReferrerMustBeWritable" - }, - { - "code": 6032, - "name": "ReferrerStatsMustBeWritable", - "msg": "ReferrerMustBeWritable" - }, - { - "code": 6033, - "name": "ReferrerAndReferrerStatsAuthorityUnequal", - "msg": "ReferrerAndReferrerStatsAuthorityUnequal" - }, - { - "code": 6034, - "name": "InvalidReferrer", - "msg": "InvalidReferrer" - }, - { - "code": 6035, - "name": "InvalidOracle", - "msg": "InvalidOracle" - }, - { - "code": 6036, - "name": "OracleNotFound", - "msg": "OracleNotFound" - }, - { - "code": 6037, - "name": "LiquidationsBlockedByOracle", - "msg": "Liquidations Blocked By Oracle" - }, - { - "code": 6038, - "name": "MaxDeposit", - "msg": "Can not deposit more than max deposit" - }, - { - "code": 6039, - "name": "CantDeleteUserWithCollateral", - "msg": "Can not delete user that still has collateral" - }, - { - "code": 6040, - "name": "InvalidFundingProfitability", - "msg": "AMM funding out of bounds pnl" - }, - { - "code": 6041, - "name": "CastingFailure", - "msg": "Casting Failure" - }, - { - "code": 6042, - "name": "InvalidOrder", - "msg": "InvalidOrder" - }, - { - "code": 6043, - "name": "InvalidOrderMaxTs", - "msg": "InvalidOrderMaxTs" - }, - { - "code": 6044, - "name": "InvalidOrderMarketType", - "msg": "InvalidOrderMarketType" - }, - { - "code": 6045, - "name": "InvalidOrderForInitialMarginReq", - "msg": "InvalidOrderForInitialMarginReq" - }, - { - "code": 6046, - "name": "InvalidOrderNotRiskReducing", - "msg": "InvalidOrderNotRiskReducing" - }, - { - "code": 6047, - "name": "InvalidOrderSizeTooSmall", - "msg": "InvalidOrderSizeTooSmall" - }, - { - "code": 6048, - "name": "InvalidOrderNotStepSizeMultiple", - "msg": "InvalidOrderNotStepSizeMultiple" - }, - { - "code": 6049, - "name": "InvalidOrderBaseQuoteAsset", - "msg": "InvalidOrderBaseQuoteAsset" - }, - { - "code": 6050, - "name": "InvalidOrderIOC", - "msg": "InvalidOrderIOC" - }, - { - "code": 6051, - "name": "InvalidOrderPostOnly", - "msg": "InvalidOrderPostOnly" - }, - { - "code": 6052, - "name": "InvalidOrderIOCPostOnly", - "msg": "InvalidOrderIOCPostOnly" - }, - { - "code": 6053, - "name": "InvalidOrderTrigger", - "msg": "InvalidOrderTrigger" - }, - { - "code": 6054, - "name": "InvalidOrderAuction", - "msg": "InvalidOrderAuction" - }, - { - "code": 6055, - "name": "InvalidOrderOracleOffset", - "msg": "InvalidOrderOracleOffset" - }, - { - "code": 6056, - "name": "InvalidOrderMinOrderSize", - "msg": "InvalidOrderMinOrderSize" - }, - { - "code": 6057, - "name": "PlacePostOnlyLimitFailure", - "msg": "Failed to Place Post-Only Limit Order" - }, - { - "code": 6058, - "name": "UserHasNoOrder", - "msg": "User has no order" - }, - { - "code": 6059, - "name": "OrderAmountTooSmall", - "msg": "Order Amount Too Small" - }, - { - "code": 6060, - "name": "MaxNumberOfOrders", - "msg": "Max number of orders taken" - }, - { - "code": 6061, - "name": "OrderDoesNotExist", - "msg": "Order does not exist" - }, - { - "code": 6062, - "name": "OrderNotOpen", - "msg": "Order not open" - }, - { - "code": 6063, - "name": "FillOrderDidNotUpdateState", - "msg": "FillOrderDidNotUpdateState" - }, - { - "code": 6064, - "name": "ReduceOnlyOrderIncreasedRisk", - "msg": "Reduce only order increased risk" - }, - { - "code": 6065, - "name": "UnableToLoadAccountLoader", - "msg": "Unable to load AccountLoader" - }, - { - "code": 6066, - "name": "TradeSizeTooLarge", - "msg": "Trade Size Too Large" - }, - { - "code": 6067, - "name": "UserCantReferThemselves", - "msg": "User cant refer themselves" - }, - { - "code": 6068, - "name": "DidNotReceiveExpectedReferrer", - "msg": "Did not receive expected referrer" - }, - { - "code": 6069, - "name": "CouldNotDeserializeReferrer", - "msg": "Could not deserialize referrer" - }, - { - "code": 6070, - "name": "CouldNotDeserializeReferrerStats", - "msg": "Could not deserialize referrer stats" - }, - { - "code": 6071, - "name": "UserOrderIdAlreadyInUse", - "msg": "User Order Id Already In Use" - }, - { - "code": 6072, - "name": "NoPositionsLiquidatable", - "msg": "No positions liquidatable" - }, - { - "code": 6073, - "name": "InvalidMarginRatio", - "msg": "Invalid Margin Ratio" - }, - { - "code": 6074, - "name": "CantCancelPostOnlyOrder", - "msg": "Cant Cancel Post Only Order" - }, - { - "code": 6075, - "name": "InvalidOracleOffset", - "msg": "InvalidOracleOffset" - }, - { - "code": 6076, - "name": "CantExpireOrders", - "msg": "CantExpireOrders" - }, - { - "code": 6077, - "name": "CouldNotLoadMarketData", - "msg": "CouldNotLoadMarketData" - }, - { - "code": 6078, - "name": "PerpMarketNotFound", - "msg": "PerpMarketNotFound" - }, - { - "code": 6079, - "name": "InvalidMarketAccount", - "msg": "InvalidMarketAccount" - }, - { - "code": 6080, - "name": "UnableToLoadPerpMarketAccount", - "msg": "UnableToLoadMarketAccount" - }, - { - "code": 6081, - "name": "MarketWrongMutability", - "msg": "MarketWrongMutability" - }, - { - "code": 6082, - "name": "UnableToCastUnixTime", - "msg": "UnableToCastUnixTime" - }, - { - "code": 6083, - "name": "CouldNotFindSpotPosition", - "msg": "CouldNotFindSpotPosition" - }, - { - "code": 6084, - "name": "NoSpotPositionAvailable", - "msg": "NoSpotPositionAvailable" - }, - { - "code": 6085, - "name": "InvalidSpotMarketInitialization", - "msg": "InvalidSpotMarketInitialization" - }, - { - "code": 6086, - "name": "CouldNotLoadSpotMarketData", - "msg": "CouldNotLoadSpotMarketData" - }, - { - "code": 6087, - "name": "SpotMarketNotFound", - "msg": "SpotMarketNotFound" - }, - { - "code": 6088, - "name": "InvalidSpotMarketAccount", - "msg": "InvalidSpotMarketAccount" - }, - { - "code": 6089, - "name": "UnableToLoadSpotMarketAccount", - "msg": "UnableToLoadSpotMarketAccount" - }, - { - "code": 6090, - "name": "SpotMarketWrongMutability", - "msg": "SpotMarketWrongMutability" - }, - { - "code": 6091, - "name": "SpotMarketInterestNotUpToDate", - "msg": "SpotInterestNotUpToDate" - }, - { - "code": 6092, - "name": "SpotMarketInsufficientDeposits", - "msg": "SpotMarketInsufficientDeposits" - }, - { - "code": 6093, - "name": "UserMustSettleTheirOwnPositiveUnsettledPNL", - "msg": "UserMustSettleTheirOwnPositiveUnsettledPNL" - }, - { - "code": 6094, - "name": "CantUpdatePoolBalanceType", - "msg": "CantUpdatePoolBalanceType" - }, - { - "code": 6095, - "name": "InsufficientCollateralForSettlingPNL", - "msg": "InsufficientCollateralForSettlingPNL" - }, - { - "code": 6096, - "name": "AMMNotUpdatedInSameSlot", - "msg": "AMMNotUpdatedInSameSlot" - }, - { - "code": 6097, - "name": "AuctionNotComplete", - "msg": "AuctionNotComplete" - }, - { - "code": 6098, - "name": "MakerNotFound", - "msg": "MakerNotFound" - }, - { - "code": 6099, - "name": "MakerStatsNotFound", - "msg": "MakerNotFound" - }, - { - "code": 6100, - "name": "MakerMustBeWritable", - "msg": "MakerMustBeWritable" - }, - { - "code": 6101, - "name": "MakerStatsMustBeWritable", - "msg": "MakerMustBeWritable" - }, - { - "code": 6102, - "name": "MakerOrderNotFound", - "msg": "MakerOrderNotFound" - }, - { - "code": 6103, - "name": "CouldNotDeserializeMaker", - "msg": "CouldNotDeserializeMaker" - }, - { - "code": 6104, - "name": "CouldNotDeserializeMakerStats", - "msg": "CouldNotDeserializeMaker" - }, - { - "code": 6105, - "name": "AuctionPriceDoesNotSatisfyMaker", - "msg": "AuctionPriceDoesNotSatisfyMaker" - }, - { - "code": 6106, - "name": "MakerCantFulfillOwnOrder", - "msg": "MakerCantFulfillOwnOrder" - }, - { - "code": 6107, - "name": "MakerOrderMustBePostOnly", - "msg": "MakerOrderMustBePostOnly" - }, - { - "code": 6108, - "name": "CantMatchTwoPostOnlys", - "msg": "CantMatchTwoPostOnlys" - }, - { - "code": 6109, - "name": "OrderBreachesOraclePriceLimits", - "msg": "OrderBreachesOraclePriceLimits" - }, - { - "code": 6110, - "name": "OrderMustBeTriggeredFirst", - "msg": "OrderMustBeTriggeredFirst" - }, - { - "code": 6111, - "name": "OrderNotTriggerable", - "msg": "OrderNotTriggerable" - }, - { - "code": 6112, - "name": "OrderDidNotSatisfyTriggerCondition", - "msg": "OrderDidNotSatisfyTriggerCondition" - }, - { - "code": 6113, - "name": "PositionAlreadyBeingLiquidated", - "msg": "PositionAlreadyBeingLiquidated" - }, - { - "code": 6114, - "name": "PositionDoesntHaveOpenPositionOrOrders", - "msg": "PositionDoesntHaveOpenPositionOrOrders" - }, - { - "code": 6115, - "name": "AllOrdersAreAlreadyLiquidations", - "msg": "AllOrdersAreAlreadyLiquidations" - }, - { - "code": 6116, - "name": "CantCancelLiquidationOrder", - "msg": "CantCancelLiquidationOrder" - }, - { - "code": 6117, - "name": "UserIsBeingLiquidated", - "msg": "UserIsBeingLiquidated" - }, - { - "code": 6118, - "name": "LiquidationsOngoing", - "msg": "LiquidationsOngoing" - }, - { - "code": 6119, - "name": "WrongSpotBalanceType", - "msg": "WrongSpotBalanceType" - }, - { - "code": 6120, - "name": "UserCantLiquidateThemself", - "msg": "UserCantLiquidateThemself" - }, - { - "code": 6121, - "name": "InvalidPerpPositionToLiquidate", - "msg": "InvalidPerpPositionToLiquidate" - }, - { - "code": 6122, - "name": "InvalidBaseAssetAmountForLiquidatePerp", - "msg": "InvalidBaseAssetAmountForLiquidatePerp" - }, - { - "code": 6123, - "name": "InvalidPositionLastFundingRate", - "msg": "InvalidPositionLastFundingRate" - }, - { - "code": 6124, - "name": "InvalidPositionDelta", - "msg": "InvalidPositionDelta" - }, - { - "code": 6125, - "name": "UserBankrupt", - "msg": "UserBankrupt" - }, - { - "code": 6126, - "name": "UserNotBankrupt", - "msg": "UserNotBankrupt" - }, - { - "code": 6127, - "name": "UserHasInvalidBorrow", - "msg": "UserHasInvalidBorrow" - }, - { - "code": 6128, - "name": "DailyWithdrawLimit", - "msg": "DailyWithdrawLimit" - }, - { - "code": 6129, - "name": "DefaultError", - "msg": "DefaultError" - }, - { - "code": 6130, - "name": "InsufficientLPTokens", - "msg": "Insufficient LP tokens" - }, - { - "code": 6131, - "name": "CantLPWithPerpPosition", - "msg": "Cant LP with a market position" - }, - { - "code": 6132, - "name": "UnableToBurnLPTokens", - "msg": "Unable to burn LP tokens" - }, - { - "code": 6133, - "name": "TryingToRemoveLiquidityTooFast", - "msg": "Trying to remove liqudity too fast after adding it" - }, - { - "code": 6134, - "name": "InvalidSpotMarketVault", - "msg": "Invalid Spot Market Vault" - }, - { - "code": 6135, - "name": "InvalidSpotMarketState", - "msg": "Invalid Spot Market State" - }, - { - "code": 6136, - "name": "InvalidSerumProgram", - "msg": "InvalidSerumProgram" - }, - { - "code": 6137, - "name": "InvalidSerumMarket", - "msg": "InvalidSerumMarket" - }, - { - "code": 6138, - "name": "InvalidSerumBids", - "msg": "InvalidSerumBids" - }, - { - "code": 6139, - "name": "InvalidSerumAsks", - "msg": "InvalidSerumAsks" - }, - { - "code": 6140, - "name": "InvalidSerumOpenOrders", - "msg": "InvalidSerumOpenOrders" - }, - { - "code": 6141, - "name": "FailedSerumCPI", - "msg": "FailedSerumCPI" - }, - { - "code": 6142, - "name": "FailedToFillOnExternalMarket", - "msg": "FailedToFillOnExternalMarket" - }, - { - "code": 6143, - "name": "InvalidFulfillmentConfig", - "msg": "InvalidFulfillmentConfig" - }, - { - "code": 6144, - "name": "InvalidFeeStructure", - "msg": "InvalidFeeStructure" - }, - { - "code": 6145, - "name": "InsufficientIFShares", - "msg": "Insufficient IF shares" - }, - { - "code": 6146, - "name": "MarketActionPaused", - "msg": "the Market has paused this action" - }, - { - "code": 6147, - "name": "MarketPlaceOrderPaused", - "msg": "the Market status doesnt allow placing orders" - }, - { - "code": 6148, - "name": "MarketFillOrderPaused", - "msg": "the Market status doesnt allow filling orders" - }, - { - "code": 6149, - "name": "MarketWithdrawPaused", - "msg": "the Market status doesnt allow withdraws" - }, - { - "code": 6150, - "name": "ProtectedAssetTierViolation", - "msg": "Action violates the Protected Asset Tier rules" - }, - { - "code": 6151, - "name": "IsolatedAssetTierViolation", - "msg": "Action violates the Isolated Asset Tier rules" - }, - { - "code": 6152, - "name": "UserCantBeDeleted", - "msg": "User Cant Be Deleted" - }, - { - "code": 6153, - "name": "ReduceOnlyWithdrawIncreasedRisk", - "msg": "Reduce Only Withdraw Increased Risk" - }, - { - "code": 6154, - "name": "MaxOpenInterest", - "msg": "Max Open Interest" - }, - { - "code": 6155, - "name": "CantResolvePerpBankruptcy", - "msg": "Cant Resolve Perp Bankruptcy" - }, - { - "code": 6156, - "name": "LiquidationDoesntSatisfyLimitPrice", - "msg": "Liquidation Doesnt Satisfy Limit Price" - }, - { - "code": 6157, - "name": "MarginTradingDisabled", - "msg": "Margin Trading Disabled" - }, - { - "code": 6158, - "name": "InvalidMarketStatusToSettlePnl", - "msg": "Invalid Market Status to Settle Perp Pnl" - }, - { - "code": 6159, - "name": "PerpMarketNotInSettlement", - "msg": "PerpMarketNotInSettlement" - }, - { - "code": 6160, - "name": "PerpMarketNotInReduceOnly", - "msg": "PerpMarketNotInReduceOnly" - }, - { - "code": 6161, - "name": "PerpMarketSettlementBufferNotReached", - "msg": "PerpMarketSettlementBufferNotReached" - }, - { - "code": 6162, - "name": "PerpMarketSettlementUserHasOpenOrders", - "msg": "PerpMarketSettlementUserHasOpenOrders" - }, - { - "code": 6163, - "name": "PerpMarketSettlementUserHasActiveLP", - "msg": "PerpMarketSettlementUserHasActiveLP" - }, - { - "code": 6164, - "name": "UnableToSettleExpiredUserPosition", - "msg": "UnableToSettleExpiredUserPosition" - }, - { - "code": 6165, - "name": "UnequalMarketIndexForSpotTransfer", - "msg": "UnequalMarketIndexForSpotTransfer" - }, - { - "code": 6166, - "name": "InvalidPerpPositionDetected", - "msg": "InvalidPerpPositionDetected" - }, - { - "code": 6167, - "name": "InvalidSpotPositionDetected", - "msg": "InvalidSpotPositionDetected" - }, - { - "code": 6168, - "name": "InvalidAmmDetected", - "msg": "InvalidAmmDetected" - }, - { - "code": 6169, - "name": "InvalidAmmForFillDetected", - "msg": "InvalidAmmForFillDetected" - }, - { - "code": 6170, - "name": "InvalidAmmLimitPriceOverride", - "msg": "InvalidAmmLimitPriceOverride" - }, - { - "code": 6171, - "name": "InvalidOrderFillPrice", - "msg": "InvalidOrderFillPrice" - }, - { - "code": 6172, - "name": "SpotMarketBalanceInvariantViolated", - "msg": "SpotMarketBalanceInvariantViolated" - }, - { - "code": 6173, - "name": "SpotMarketVaultInvariantViolated", - "msg": "SpotMarketVaultInvariantViolated" - }, - { - "code": 6174, - "name": "InvalidPDA", - "msg": "InvalidPDA" - }, - { - "code": 6175, - "name": "InvalidPDASigner", - "msg": "InvalidPDASigner" - }, - { - "code": 6176, - "name": "RevenueSettingsCannotSettleToIF", - "msg": "RevenueSettingsCannotSettleToIF" - }, - { - "code": 6177, - "name": "NoRevenueToSettleToIF", - "msg": "NoRevenueToSettleToIF" - }, - { - "code": 6178, - "name": "NoAmmPerpPnlDeficit", - "msg": "NoAmmPerpPnlDeficit" - }, - { - "code": 6179, - "name": "SufficientPerpPnlPool", - "msg": "SufficientPerpPnlPool" - }, - { - "code": 6180, - "name": "InsufficientPerpPnlPool", - "msg": "InsufficientPerpPnlPool" - }, - { - "code": 6181, - "name": "PerpPnlDeficitBelowThreshold", - "msg": "PerpPnlDeficitBelowThreshold" - }, - { - "code": 6182, - "name": "MaxRevenueWithdrawPerPeriodReached", - "msg": "MaxRevenueWithdrawPerPeriodReached" - }, - { - "code": 6183, - "name": "MaxIFWithdrawReached", - "msg": "InvalidSpotPositionDetected" - }, - { - "code": 6184, - "name": "NoIFWithdrawAvailable", - "msg": "NoIFWithdrawAvailable" - }, - { - "code": 6185, - "name": "InvalidIFUnstake", - "msg": "InvalidIFUnstake" - }, - { - "code": 6186, - "name": "InvalidIFUnstakeSize", - "msg": "InvalidIFUnstakeSize" - }, - { - "code": 6187, - "name": "InvalidIFUnstakeCancel", - "msg": "InvalidIFUnstakeCancel" - }, - { - "code": 6188, - "name": "InvalidIFForNewStakes", - "msg": "InvalidIFForNewStakes" - }, - { - "code": 6189, - "name": "InvalidIFRebase", - "msg": "InvalidIFRebase" - }, - { - "code": 6190, - "name": "InvalidInsuranceUnstakeSize", - "msg": "InvalidInsuranceUnstakeSize" - }, - { - "code": 6191, - "name": "InvalidOrderLimitPrice", - "msg": "InvalidOrderLimitPrice" - }, - { - "code": 6192, - "name": "InvalidIFDetected", - "msg": "InvalidIFDetected" - }, - { - "code": 6193, - "name": "InvalidAmmMaxSpreadDetected", - "msg": "InvalidAmmMaxSpreadDetected" - }, - { - "code": 6194, - "name": "InvalidConcentrationCoef", - "msg": "InvalidConcentrationCoef" - }, - { - "code": 6195, - "name": "InvalidSrmVault", - "msg": "InvalidSrmVault" - }, - { - "code": 6196, - "name": "InvalidVaultOwner", - "msg": "InvalidVaultOwner" - }, - { - "code": 6197, - "name": "InvalidMarketStatusForFills", - "msg": "InvalidMarketStatusForFills" - }, - { - "code": 6198, - "name": "IFWithdrawRequestInProgress", - "msg": "IFWithdrawRequestInProgress" - }, - { - "code": 6199, - "name": "NoIFWithdrawRequestInProgress", - "msg": "NoIFWithdrawRequestInProgress" - }, - { - "code": 6200, - "name": "IFWithdrawRequestTooSmall", - "msg": "IFWithdrawRequestTooSmall" - }, - { - "code": 6201, - "name": "IncorrectSpotMarketAccountPassed", - "msg": "IncorrectSpotMarketAccountPassed" - }, - { - "code": 6202, - "name": "BlockchainClockInconsistency", - "msg": "BlockchainClockInconsistency" - }, - { - "code": 6203, - "name": "InvalidIFSharesDetected", - "msg": "InvalidIFSharesDetected" - }, - { - "code": 6204, - "name": "NewLPSizeTooSmall", - "msg": "NewLPSizeTooSmall" - }, - { - "code": 6205, - "name": "MarketStatusInvalidForNewLP", - "msg": "MarketStatusInvalidForNewLP" - }, - { - "code": 6206, - "name": "InvalidMarkTwapUpdateDetected", - "msg": "InvalidMarkTwapUpdateDetected" - }, - { - "code": 6207, - "name": "MarketSettlementAttemptOnActiveMarket", - "msg": "MarketSettlementAttemptOnActiveMarket" - }, - { - "code": 6208, - "name": "MarketSettlementRequiresSettledLP", - "msg": "MarketSettlementRequiresSettledLP" - }, - { - "code": 6209, - "name": "MarketSettlementAttemptTooEarly", - "msg": "MarketSettlementAttemptTooEarly" - }, - { - "code": 6210, - "name": "MarketSettlementTargetPriceInvalid", - "msg": "MarketSettlementTargetPriceInvalid" - }, - { - "code": 6211, - "name": "UnsupportedSpotMarket", - "msg": "UnsupportedSpotMarket" - }, - { - "code": 6212, - "name": "SpotOrdersDisabled", - "msg": "SpotOrdersDisabled" - }, - { - "code": 6213, - "name": "MarketBeingInitialized", - "msg": "Market Being Initialized" - }, - { - "code": 6214, - "name": "InvalidUserSubAccountId", - "msg": "Invalid Sub Account Id" - }, - { - "code": 6215, - "name": "InvalidTriggerOrderCondition", - "msg": "Invalid Trigger Order Condition" - }, - { - "code": 6216, - "name": "InvalidSpotPosition", - "msg": "Invalid Spot Position" - }, - { - "code": 6217, - "name": "CantTransferBetweenSameUserAccount", - "msg": "Cant transfer between same user account" - }, - { - "code": 6218, - "name": "InvalidPerpPosition", - "msg": "Invalid Perp Position" - }, - { - "code": 6219, - "name": "UnableToGetLimitPrice", - "msg": "Unable To Get Limit Price" - }, - { - "code": 6220, - "name": "InvalidLiquidation", - "msg": "Invalid Liquidation" - }, - { - "code": 6221, - "name": "SpotFulfillmentConfigDisabled", - "msg": "Spot Fulfillment Config Disabled" - }, - { - "code": 6222, - "name": "InvalidMaker", - "msg": "Invalid Maker" - }, - { - "code": 6223, - "name": "FailedUnwrap", - "msg": "Failed Unwrap" - }, - { - "code": 6224, - "name": "MaxNumberOfUsers", - "msg": "Max Number Of Users" - }, - { - "code": 6225, - "name": "InvalidOracleForSettlePnl", - "msg": "InvalidOracleForSettlePnl" - }, - { - "code": 6226, - "name": "MarginOrdersOpen", - "msg": "MarginOrdersOpen" - }, - { - "code": 6227, - "name": "TierViolationLiquidatingPerpPnl", - "msg": "TierViolationLiquidatingPerpPnl" - }, - { - "code": 6228, - "name": "CouldNotLoadUserData", - "msg": "CouldNotLoadUserData" - }, - { - "code": 6229, - "name": "UserWrongMutability", - "msg": "UserWrongMutability" - }, - { - "code": 6230, - "name": "InvalidUserAccount", - "msg": "InvalidUserAccount" - }, - { - "code": 6231, - "name": "CouldNotLoadUserStatsData", - "msg": "CouldNotLoadUserData" - }, - { - "code": 6232, - "name": "UserStatsWrongMutability", - "msg": "UserWrongMutability" - }, - { - "code": 6233, - "name": "InvalidUserStatsAccount", - "msg": "InvalidUserAccount" - }, - { - "code": 6234, - "name": "UserNotFound", - "msg": "UserNotFound" - }, - { - "code": 6235, - "name": "UnableToLoadUserAccount", - "msg": "UnableToLoadUserAccount" - }, - { - "code": 6236, - "name": "UserStatsNotFound", - "msg": "UserStatsNotFound" - }, - { - "code": 6237, - "name": "UnableToLoadUserStatsAccount", - "msg": "UnableToLoadUserStatsAccount" - }, - { - "code": 6238, - "name": "UserNotInactive", - "msg": "User Not Inactive" - }, - { - "code": 6239, - "name": "RevertFill", - "msg": "RevertFill" - }, - { - "code": 6240, - "name": "InvalidMarketAccountforDeletion", - "msg": "Invalid MarketAccount for Deletion" - }, - { - "code": 6241, - "name": "InvalidSpotFulfillmentParams", - "msg": "Invalid Spot Fulfillment Params" - }, - { - "code": 6242, - "name": "FailedToGetMint", - "msg": "Failed to Get Mint" - }, - { - "code": 6243, - "name": "FailedPhoenixCPI", - "msg": "FailedPhoenixCPI" - }, - { - "code": 6244, - "name": "FailedToDeserializePhoenixMarket", - "msg": "FailedToDeserializePhoenixMarket" - }, - { - "code": 6245, - "name": "InvalidPricePrecision", - "msg": "InvalidPricePrecision" - }, - { - "code": 6246, - "name": "InvalidPhoenixProgram", - "msg": "InvalidPhoenixProgram" - }, - { - "code": 6247, - "name": "InvalidPhoenixMarket", - "msg": "InvalidPhoenixMarket" - }, - { - "code": 6248, - "name": "InvalidSwap", - "msg": "InvalidSwap" - }, - { - "code": 6249, - "name": "SwapLimitPriceBreached", - "msg": "SwapLimitPriceBreached" - }, - { - "code": 6250, - "name": "SpotMarketReduceOnly", - "msg": "SpotMarketReduceOnly" - }, - { - "code": 6251, - "name": "FundingWasNotUpdated", - "msg": "FundingWasNotUpdated" - }, - { - "code": 6252, - "name": "ImpossibleFill", - "msg": "ImpossibleFill" - }, - { - "code": 6253, - "name": "CantUpdatePerpBidAskTwap", - "msg": "CantUpdatePerpBidAskTwap" - }, - { - "code": 6254, - "name": "UserReduceOnly", - "msg": "UserReduceOnly" - }, - { - "code": 6255, - "name": "InvalidMarginCalculation", - "msg": "InvalidMarginCalculation" - }, - { - "code": 6256, - "name": "CantPayUserInitFee", - "msg": "CantPayUserInitFee" - }, - { - "code": 6257, - "name": "CantReclaimRent", - "msg": "CantReclaimRent" - }, - { - "code": 6258, - "name": "InsuranceFundOperationPaused", - "msg": "InsuranceFundOperationPaused" - }, - { - "code": 6259, - "name": "NoUnsettledPnl", - "msg": "NoUnsettledPnl" - }, - { - "code": 6260, - "name": "PnlPoolCantSettleUser", - "msg": "PnlPoolCantSettleUser" - }, - { - "code": 6261, - "name": "OracleNonPositive", - "msg": "OracleInvalid" - }, - { - "code": 6262, - "name": "OracleTooVolatile", - "msg": "OracleTooVolatile" - }, - { - "code": 6263, - "name": "OracleTooUncertain", - "msg": "OracleTooUncertain" - }, - { - "code": 6264, - "name": "OracleStaleForMargin", - "msg": "OracleStaleForMargin" - }, - { - "code": 6265, - "name": "OracleInsufficientDataPoints", - "msg": "OracleInsufficientDataPoints" - }, - { - "code": 6266, - "name": "OracleStaleForAMM", - "msg": "OracleStaleForAMM" - }, - { - "code": 6267, - "name": "UnableToParsePullOracleMessage", - "msg": "Unable to parse pull oracle message" - }, - { - "code": 6268, - "name": "MaxBorrows", - "msg": "Can not borow more than max borrows" - }, - { - "code": 6269, - "name": "OracleUpdatesNotMonotonic", - "msg": "Updates must be monotonically increasing" - }, - { - "code": 6270, - "name": "OraclePriceFeedMessageMismatch", - "msg": "Trying to update price feed with the wrong feed id" - }, - { - "code": 6271, - "name": "OracleUnsupportedMessageType", - "msg": "The message in the update must be a PriceFeedMessage" - }, - { - "code": 6272, - "name": "OracleDeserializeMessageFailed", - "msg": "Could not deserialize the message in the update" - }, - { - "code": 6273, - "name": "OracleWrongGuardianSetOwner", - "msg": "Wrong guardian set owner in update price atomic" - }, - { - "code": 6274, - "name": "OracleWrongWriteAuthority", - "msg": "Oracle post update atomic price feed account must be drift program" - }, - { - "code": 6275, - "name": "OracleWrongVaaOwner", - "msg": "Oracle vaa owner must be wormhole program" - }, - { - "code": 6276, - "name": "OracleTooManyPriceAccountUpdates", - "msg": "Multi updates must have 2 or fewer accounts passed in remaining accounts" - }, - { - "code": 6277, - "name": "OracleMismatchedVaaAndPriceUpdates", - "msg": "Don't have the same remaining accounts number and pyth updates left" - }, - { - "code": 6278, - "name": "OracleBadRemainingAccountPublicKey", - "msg": "Remaining account passed does not match oracle update derived pda" - }, - { - "code": 6279, - "name": "FailedOpenbookV2CPI", - "msg": "FailedOpenbookV2CPI" - }, - { - "code": 6280, - "name": "InvalidOpenbookV2Program", - "msg": "InvalidOpenbookV2Program" - }, - { - "code": 6281, - "name": "InvalidOpenbookV2Market", - "msg": "InvalidOpenbookV2Market" - }, - { - "code": 6282, - "name": "NonZeroTransferFee", - "msg": "Non zero transfer fee" - }, - { - "code": 6283, - "name": "LiquidationOrderFailedToFill", - "msg": "Liquidation order failed to fill" - }, - { - "code": 6284, - "name": "InvalidPredictionMarketOrder", - "msg": "Invalid prediction market order" - }, - { - "code": 6285, - "name": "InvalidVerificationIxIndex", - "msg": "Ed25519 Ix must be before place and make SignedMsg order ix" - }, - { - "code": 6286, - "name": "SigVerificationFailed", - "msg": "SignedMsg message verificaiton failed" - }, - { - "code": 6287, - "name": "MismatchedSignedMsgOrderParamsMarketIndex", - "msg": "Market index mismatched b/w taker and maker SignedMsg order params" - }, - { - "code": 6288, - "name": "InvalidSignedMsgOrderParam", - "msg": "Invalid SignedMsg order param" - }, - { - "code": 6289, - "name": "PlaceAndTakeOrderSuccessConditionFailed", - "msg": "Place and take order success condition failed" - }, - { - "code": 6290, - "name": "InvalidHighLeverageModeConfig", - "msg": "Invalid High Leverage Mode Config" - }, - { - "code": 6291, - "name": "InvalidRFQUserAccount", - "msg": "Invalid RFQ User Account" - }, - { - "code": 6292, - "name": "RFQUserAccountWrongMutability", - "msg": "RFQUserAccount should be mutable" - }, - { - "code": 6293, - "name": "RFQUserAccountFull", - "msg": "RFQUserAccount has too many active RFQs" - }, - { - "code": 6294, - "name": "RFQOrderNotFilled", - "msg": "RFQ order not filled as expected" - }, - { - "code": 6295, - "name": "InvalidRFQOrder", - "msg": "RFQ orders must be jit makers" - }, - { - "code": 6296, - "name": "InvalidRFQMatch", - "msg": "RFQ matches must be valid" - }, - { - "code": 6297, - "name": "InvalidSignedMsgUserAccount", - "msg": "Invalid SignedMsg user account" - }, - { - "code": 6298, - "name": "SignedMsgUserAccountWrongMutability", - "msg": "SignedMsg account wrong mutability" - }, - { - "code": 6299, - "name": "SignedMsgUserOrdersAccountFull", - "msg": "SignedMsgUserAccount has too many active orders" - }, - { - "code": 6300, - "name": "SignedMsgOrderDoesNotExist", - "msg": "Order with SignedMsg uuid does not exist" - }, - { - "code": 6301, - "name": "InvalidSignedMsgOrderId", - "msg": "SignedMsg order id cannot be 0s" - }, - { - "code": 6302, - "name": "InvalidPoolId", - "msg": "Invalid pool id" - }, - { - "code": 6303, - "name": "InvalidProtectedMakerModeConfig", - "msg": "Invalid Protected Maker Mode Config" - }, - { - "code": 6304, - "name": "InvalidPythLazerStorageOwner", - "msg": "Invalid pyth lazer storage owner" - }, - { - "code": 6305, - "name": "UnverifiedPythLazerMessage", - "msg": "Verification of pyth lazer message failed" - }, - { - "code": 6306, - "name": "InvalidPythLazerMessage", - "msg": "Invalid pyth lazer message" - }, - { - "code": 6307, - "name": "PythLazerMessagePriceFeedMismatch", - "msg": "Pyth lazer message does not correspond to correct fed id" - }, - { - "code": 6308, - "name": "InvalidLiquidateSpotWithSwap", - "msg": "InvalidLiquidateSpotWithSwap" - }, - { - "code": 6309, - "name": "SignedMsgUserContextUserMismatch", - "msg": "User in SignedMsg message does not match user in ix context" - }, - { - "code": 6310, - "name": "UserFuelOverflowThresholdNotMet", - "msg": "User fuel overflow threshold not met" - }, - { - "code": 6311, - "name": "FuelOverflowAccountNotFound", - "msg": "FuelOverflow account not found" - }, - { - "code": 6312, - "name": "InvalidTransferPerpPosition", - "msg": "Invalid Transfer Perp Position" - }, - { - "code": 6313, - "name": "InvalidSignedMsgUserOrdersResize", - "msg": "Invalid SignedMsgUserOrders resize" - }, - { - "code": 6314, - "name": "CouldNotDeserializeHighLeverageModeConfig", - "msg": "Could not deserialize high leverage mode config" - }, - { - "code": 6315, - "name": "InvalidIfRebalanceConfig", - "msg": "Invalid If Rebalance Config" - }, - { - "code": 6316, - "name": "InvalidIfRebalanceSwap", - "msg": "Invalid If Rebalance Swap" - }, - { - "code": 6317, - "name": "InvalidRevenueShareResize", - "msg": "Invalid RevenueShare resize" - }, - { - "code": 6318, - "name": "BuilderRevoked", - "msg": "Builder has been revoked" - }, - { - "code": 6319, - "name": "InvalidBuilderFee", - "msg": "Builder fee is greater than max fee bps" - }, - { - "code": 6320, - "name": "RevenueShareEscrowAuthorityMismatch", - "msg": "RevenueShareEscrow authority mismatch" - }, - { - "code": 6321, - "name": "RevenueShareEscrowOrdersAccountFull", - "msg": "RevenueShareEscrow has too many active orders" - }, - { - "code": 6322, - "name": "InvalidRevenueShareAccount", - "msg": "Invalid RevenueShareAccount" - }, - { - "code": 6323, - "name": "CannotRevokeBuilderWithOpenOrders", - "msg": "Cannot revoke builder with open orders" - }, - { - "code": 6324, - "name": "UnableToLoadRevenueShareAccount", - "msg": "Unable to load builder account" - }, - { - "code": 6325, - "name": "InvalidConstituent", - "msg": "Invalid Constituent" - }, - { - "code": 6326, - "name": "InvalidAmmConstituentMappingArgument", - "msg": "Invalid Amm Constituent Mapping argument" - }, - { - "code": 6327, - "name": "ConstituentNotFound", - "msg": "Constituent not found" - }, - { - "code": 6328, - "name": "ConstituentCouldNotLoad", - "msg": "Constituent could not load" - }, - { - "code": 6329, - "name": "ConstituentWrongMutability", - "msg": "Constituent wrong mutability" - }, - { - "code": 6330, - "name": "WrongNumberOfConstituents", - "msg": "Wrong number of constituents passed to instruction" - }, - { - "code": 6331, - "name": "InsufficientConstituentTokenBalance", - "msg": "Insufficient constituent token balance" - }, - { - "code": 6332, - "name": "AMMCacheStale", - "msg": "Amm Cache data too stale" - }, - { - "code": 6333, - "name": "LpPoolAumDelayed", - "msg": "LP Pool AUM not updated recently" - }, - { - "code": 6334, - "name": "ConstituentOracleStale", - "msg": "Constituent oracle is stale" - }, - { - "code": 6335, - "name": "LpInvariantFailed", - "msg": "LP Invariant failed" - }, - { - "code": 6336, - "name": "InvalidConstituentDerivativeWeights", - "msg": "Invalid constituent derivative weights" - }, - { - "code": 6337, - "name": "MaxDlpAumBreached", - "msg": "Max DLP AUM Breached" - }, - { - "code": 6338, - "name": "SettleLpPoolDisabled", - "msg": "Settle Lp Pool Disabled" - }, - { - "code": 6339, - "name": "MintRedeemLpPoolDisabled", - "msg": "Mint/Redeem Lp Pool Disabled" - }, - { - "code": 6340, - "name": "LpPoolSettleInvariantBreached", - "msg": "Settlement amount exceeded" - }, - { - "code": 6341, - "name": "InvalidConstituentOperation", - "msg": "Invalid constituent operation" - }, - { - "code": 6342, - "name": "Unauthorized", - "msg": "Unauthorized for operation" - }, - { - "code": 6343, - "name": "InvalidLpPoolId", - "msg": "Invalid Lp Pool Id for Operation" - }, - { - "code": 6344, - "name": "MarketIndexNotFoundAmmCache", - "msg": "MarketIndexNotFoundAmmCache" + "name": "LoadInstructionAtFailed", + "msg": "loading custom ix at index failed" } ], "types": [ @@ -21316,6 +19651,10 @@ "name": "SpotBankruptcyRecord" } } + }, + { + "name": "bit_flags", + "type": "u8" } ] } @@ -25935,35 +24274,27 @@ { "name": "i128", "docs": [ - "`i128` with legacy bit layout" + "compatibility i128" ], + "repr": { + "kind": "transparent" + }, "type": { - "kind": "struct", - "fields": [ - { - "array": [ - "u8", - 16 - ] - } - ] + "kind": "type", + "alias": "i128" } }, { "name": "u128", "docs": [ - "`u128` with legacy bit layout" + "compatibility u128" ], + "repr": { + "kind": "transparent" + }, "type": { - "kind": "struct", - "fields": [ - { - "array": [ - "u8", - 16 - ] - } - ] + "kind": "type", + "alias": "u128" } } ] diff --git a/sdk/src/idl/drift.ts b/sdk/src/idl/drift.ts index e0a0e44abb..e1fa5f63d1 100644 --- a/sdk/src/idl/drift.ts +++ b/sdk/src/idl/drift.ts @@ -8,7 +8,7 @@ export type Drift = { address: 'dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH'; metadata: { name: 'drift'; - version: '2.151.0'; + version: '2.152.0'; spec: '0.1.0'; description: 'Created with Anchor'; }; @@ -12028,1732 +12028,71 @@ export type Drift = { name: 'transferProtocolIfSharesToRevenuePoolRecord'; discriminator: [209, 118, 142, 167, 130, 46, 164, 151]; }, - ]; - errors: [ - { - code: 6000; - name: 'invalidSpotMarketAuthority'; - msg: 'Invalid Spot Market Authority'; - }, - { - code: 6001; - name: 'invalidInsuranceFundAuthority'; - msg: 'Clearing house not insurance fund authority'; - }, - { - code: 6002; - name: 'insufficientDeposit'; - msg: 'Insufficient deposit'; - }, - { - code: 6003; - name: 'insufficientCollateral'; - msg: 'Insufficient collateral'; - }, - { - code: 6004; - name: 'sufficientCollateral'; - msg: 'Sufficient collateral'; - }, - { - code: 6005; - name: 'maxNumberOfPositions'; - msg: 'Max number of positions taken'; - }, - { - code: 6006; - name: 'adminControlsPricesDisabled'; - msg: 'Admin Controls Prices Disabled'; - }, - { - code: 6007; - name: 'marketDelisted'; - msg: 'Market Delisted'; - }, - { - code: 6008; - name: 'marketIndexAlreadyInitialized'; - msg: 'Market Index Already Initialized'; - }, - { - code: 6009; - name: 'userAccountAndUserPositionsAccountMismatch'; - msg: 'User Account And User Positions Account Mismatch'; - }, - { - code: 6010; - name: 'userHasNoPositionInMarket'; - msg: 'User Has No Position In Market'; - }, - { - code: 6011; - name: 'invalidInitialPeg'; - msg: 'Invalid Initial Peg'; - }, - { - code: 6012; - name: 'invalidRepegRedundant'; - msg: 'AMM repeg already configured with amt given'; - }, - { - code: 6013; - name: 'invalidRepegDirection'; - msg: 'AMM repeg incorrect repeg direction'; - }, - { - code: 6014; - name: 'invalidRepegProfitability'; - msg: 'AMM repeg out of bounds pnl'; - }, - { - code: 6015; - name: 'slippageOutsideLimit'; - msg: 'Slippage Outside Limit Price'; - }, - { - code: 6016; - name: 'orderSizeTooSmall'; - msg: 'Order Size Too Small'; - }, - { - code: 6017; - name: 'invalidUpdateK'; - msg: 'Price change too large when updating K'; - }, - { - code: 6018; - name: 'adminWithdrawTooLarge'; - msg: 'Admin tried to withdraw amount larger than fees collected'; - }, - { - code: 6019; - name: 'mathError'; - msg: 'Math Error'; - }, - { - code: 6020; - name: 'bnConversionError'; - msg: 'Conversion to u128/u64 failed with an overflow or underflow'; - }, - { - code: 6021; - name: 'clockUnavailable'; - msg: 'Clock unavailable'; - }, - { - code: 6022; - name: 'unableToLoadOracle'; - msg: 'Unable To Load Oracles'; - }, - { - code: 6023; - name: 'priceBandsBreached'; - msg: 'Price Bands Breached'; - }, - { - code: 6024; - name: 'exchangePaused'; - msg: 'Exchange is paused'; - }, - { - code: 6025; - name: 'invalidWhitelistToken'; - msg: 'Invalid whitelist token'; - }, - { - code: 6026; - name: 'whitelistTokenNotFound'; - msg: 'Whitelist token not found'; - }, - { - code: 6027; - name: 'invalidDiscountToken'; - msg: 'Invalid discount token'; - }, - { - code: 6028; - name: 'discountTokenNotFound'; - msg: 'Discount token not found'; - }, - { - code: 6029; - name: 'referrerNotFound'; - msg: 'Referrer not found'; - }, - { - code: 6030; - name: 'referrerStatsNotFound'; - msg: 'referrerNotFound'; - }, - { - code: 6031; - name: 'referrerMustBeWritable'; - msg: 'referrerMustBeWritable'; - }, - { - code: 6032; - name: 'referrerStatsMustBeWritable'; - msg: 'referrerMustBeWritable'; - }, - { - code: 6033; - name: 'referrerAndReferrerStatsAuthorityUnequal'; - msg: 'referrerAndReferrerStatsAuthorityUnequal'; - }, - { - code: 6034; - name: 'invalidReferrer'; - msg: 'invalidReferrer'; - }, - { - code: 6035; - name: 'invalidOracle'; - msg: 'invalidOracle'; - }, - { - code: 6036; - name: 'oracleNotFound'; - msg: 'oracleNotFound'; - }, - { - code: 6037; - name: 'liquidationsBlockedByOracle'; - msg: 'Liquidations Blocked By Oracle'; - }, - { - code: 6038; - name: 'maxDeposit'; - msg: 'Can not deposit more than max deposit'; - }, - { - code: 6039; - name: 'cantDeleteUserWithCollateral'; - msg: 'Can not delete user that still has collateral'; - }, - { - code: 6040; - name: 'invalidFundingProfitability'; - msg: 'AMM funding out of bounds pnl'; - }, - { - code: 6041; - name: 'castingFailure'; - msg: 'Casting Failure'; - }, - { - code: 6042; - name: 'invalidOrder'; - msg: 'invalidOrder'; - }, - { - code: 6043; - name: 'invalidOrderMaxTs'; - msg: 'invalidOrderMaxTs'; - }, - { - code: 6044; - name: 'invalidOrderMarketType'; - msg: 'invalidOrderMarketType'; - }, - { - code: 6045; - name: 'invalidOrderForInitialMarginReq'; - msg: 'invalidOrderForInitialMarginReq'; - }, - { - code: 6046; - name: 'invalidOrderNotRiskReducing'; - msg: 'invalidOrderNotRiskReducing'; - }, - { - code: 6047; - name: 'invalidOrderSizeTooSmall'; - msg: 'invalidOrderSizeTooSmall'; - }, - { - code: 6048; - name: 'invalidOrderNotStepSizeMultiple'; - msg: 'invalidOrderNotStepSizeMultiple'; - }, - { - code: 6049; - name: 'invalidOrderBaseQuoteAsset'; - msg: 'invalidOrderBaseQuoteAsset'; - }, - { - code: 6050; - name: 'invalidOrderIoc'; - msg: 'invalidOrderIoc'; - }, - { - code: 6051; - name: 'invalidOrderPostOnly'; - msg: 'invalidOrderPostOnly'; - }, - { - code: 6052; - name: 'invalidOrderIocPostOnly'; - msg: 'invalidOrderIocPostOnly'; - }, - { - code: 6053; - name: 'invalidOrderTrigger'; - msg: 'invalidOrderTrigger'; - }, - { - code: 6054; - name: 'invalidOrderAuction'; - msg: 'invalidOrderAuction'; - }, - { - code: 6055; - name: 'invalidOrderOracleOffset'; - msg: 'invalidOrderOracleOffset'; - }, - { - code: 6056; - name: 'invalidOrderMinOrderSize'; - msg: 'invalidOrderMinOrderSize'; - }, - { - code: 6057; - name: 'placePostOnlyLimitFailure'; - msg: 'Failed to Place Post-Only Limit Order'; - }, - { - code: 6058; - name: 'userHasNoOrder'; - msg: 'User has no order'; - }, - { - code: 6059; - name: 'orderAmountTooSmall'; - msg: 'Order Amount Too Small'; - }, - { - code: 6060; - name: 'maxNumberOfOrders'; - msg: 'Max number of orders taken'; - }, - { - code: 6061; - name: 'orderDoesNotExist'; - msg: 'Order does not exist'; - }, - { - code: 6062; - name: 'orderNotOpen'; - msg: 'Order not open'; - }, - { - code: 6063; - name: 'fillOrderDidNotUpdateState'; - msg: 'fillOrderDidNotUpdateState'; - }, - { - code: 6064; - name: 'reduceOnlyOrderIncreasedRisk'; - msg: 'Reduce only order increased risk'; - }, - { - code: 6065; - name: 'unableToLoadAccountLoader'; - msg: 'Unable to load AccountLoader'; - }, - { - code: 6066; - name: 'tradeSizeTooLarge'; - msg: 'Trade Size Too Large'; - }, - { - code: 6067; - name: 'userCantReferThemselves'; - msg: 'User cant refer themselves'; - }, - { - code: 6068; - name: 'didNotReceiveExpectedReferrer'; - msg: 'Did not receive expected referrer'; - }, - { - code: 6069; - name: 'couldNotDeserializeReferrer'; - msg: 'Could not deserialize referrer'; - }, - { - code: 6070; - name: 'couldNotDeserializeReferrerStats'; - msg: 'Could not deserialize referrer stats'; - }, - { - code: 6071; - name: 'userOrderIdAlreadyInUse'; - msg: 'User Order Id Already In Use'; - }, - { - code: 6072; - name: 'noPositionsLiquidatable'; - msg: 'No positions liquidatable'; - }, - { - code: 6073; - name: 'invalidMarginRatio'; - msg: 'Invalid Margin Ratio'; - }, - { - code: 6074; - name: 'cantCancelPostOnlyOrder'; - msg: 'Cant Cancel Post Only Order'; - }, - { - code: 6075; - name: 'invalidOracleOffset'; - msg: 'invalidOracleOffset'; - }, - { - code: 6076; - name: 'cantExpireOrders'; - msg: 'cantExpireOrders'; - }, - { - code: 6077; - name: 'couldNotLoadMarketData'; - msg: 'couldNotLoadMarketData'; - }, - { - code: 6078; - name: 'perpMarketNotFound'; - msg: 'perpMarketNotFound'; - }, - { - code: 6079; - name: 'invalidMarketAccount'; - msg: 'invalidMarketAccount'; - }, - { - code: 6080; - name: 'unableToLoadPerpMarketAccount'; - msg: 'unableToLoadMarketAccount'; - }, - { - code: 6081; - name: 'marketWrongMutability'; - msg: 'marketWrongMutability'; - }, - { - code: 6082; - name: 'unableToCastUnixTime'; - msg: 'unableToCastUnixTime'; - }, - { - code: 6083; - name: 'couldNotFindSpotPosition'; - msg: 'couldNotFindSpotPosition'; - }, - { - code: 6084; - name: 'noSpotPositionAvailable'; - msg: 'noSpotPositionAvailable'; - }, - { - code: 6085; - name: 'invalidSpotMarketInitialization'; - msg: 'invalidSpotMarketInitialization'; - }, - { - code: 6086; - name: 'couldNotLoadSpotMarketData'; - msg: 'couldNotLoadSpotMarketData'; - }, - { - code: 6087; - name: 'spotMarketNotFound'; - msg: 'spotMarketNotFound'; - }, - { - code: 6088; - name: 'invalidSpotMarketAccount'; - msg: 'invalidSpotMarketAccount'; - }, - { - code: 6089; - name: 'unableToLoadSpotMarketAccount'; - msg: 'unableToLoadSpotMarketAccount'; - }, - { - code: 6090; - name: 'spotMarketWrongMutability'; - msg: 'spotMarketWrongMutability'; - }, - { - code: 6091; - name: 'spotMarketInterestNotUpToDate'; - msg: 'spotInterestNotUpToDate'; - }, - { - code: 6092; - name: 'spotMarketInsufficientDeposits'; - msg: 'spotMarketInsufficientDeposits'; - }, - { - code: 6093; - name: 'userMustSettleTheirOwnPositiveUnsettledPnl'; - msg: 'userMustSettleTheirOwnPositiveUnsettledPnl'; - }, - { - code: 6094; - name: 'cantUpdatePoolBalanceType'; - msg: 'cantUpdatePoolBalanceType'; - }, - { - code: 6095; - name: 'insufficientCollateralForSettlingPnl'; - msg: 'insufficientCollateralForSettlingPnl'; - }, - { - code: 6096; - name: 'ammNotUpdatedInSameSlot'; - msg: 'ammNotUpdatedInSameSlot'; - }, - { - code: 6097; - name: 'auctionNotComplete'; - msg: 'auctionNotComplete'; - }, - { - code: 6098; - name: 'makerNotFound'; - msg: 'makerNotFound'; - }, - { - code: 6099; - name: 'makerStatsNotFound'; - msg: 'makerNotFound'; - }, - { - code: 6100; - name: 'makerMustBeWritable'; - msg: 'makerMustBeWritable'; - }, - { - code: 6101; - name: 'makerStatsMustBeWritable'; - msg: 'makerMustBeWritable'; - }, - { - code: 6102; - name: 'makerOrderNotFound'; - msg: 'makerOrderNotFound'; - }, - { - code: 6103; - name: 'couldNotDeserializeMaker'; - msg: 'couldNotDeserializeMaker'; - }, - { - code: 6104; - name: 'couldNotDeserializeMakerStats'; - msg: 'couldNotDeserializeMaker'; - }, - { - code: 6105; - name: 'auctionPriceDoesNotSatisfyMaker'; - msg: 'auctionPriceDoesNotSatisfyMaker'; - }, - { - code: 6106; - name: 'makerCantFulfillOwnOrder'; - msg: 'makerCantFulfillOwnOrder'; - }, - { - code: 6107; - name: 'makerOrderMustBePostOnly'; - msg: 'makerOrderMustBePostOnly'; - }, - { - code: 6108; - name: 'cantMatchTwoPostOnlys'; - msg: 'cantMatchTwoPostOnlys'; - }, - { - code: 6109; - name: 'orderBreachesOraclePriceLimits'; - msg: 'orderBreachesOraclePriceLimits'; - }, - { - code: 6110; - name: 'orderMustBeTriggeredFirst'; - msg: 'orderMustBeTriggeredFirst'; - }, - { - code: 6111; - name: 'orderNotTriggerable'; - msg: 'orderNotTriggerable'; - }, - { - code: 6112; - name: 'orderDidNotSatisfyTriggerCondition'; - msg: 'orderDidNotSatisfyTriggerCondition'; - }, - { - code: 6113; - name: 'positionAlreadyBeingLiquidated'; - msg: 'positionAlreadyBeingLiquidated'; - }, - { - code: 6114; - name: 'positionDoesntHaveOpenPositionOrOrders'; - msg: 'positionDoesntHaveOpenPositionOrOrders'; - }, - { - code: 6115; - name: 'allOrdersAreAlreadyLiquidations'; - msg: 'allOrdersAreAlreadyLiquidations'; - }, - { - code: 6116; - name: 'cantCancelLiquidationOrder'; - msg: 'cantCancelLiquidationOrder'; - }, - { - code: 6117; - name: 'userIsBeingLiquidated'; - msg: 'userIsBeingLiquidated'; - }, - { - code: 6118; - name: 'liquidationsOngoing'; - msg: 'liquidationsOngoing'; - }, - { - code: 6119; - name: 'wrongSpotBalanceType'; - msg: 'wrongSpotBalanceType'; - }, - { - code: 6120; - name: 'userCantLiquidateThemself'; - msg: 'userCantLiquidateThemself'; - }, - { - code: 6121; - name: 'invalidPerpPositionToLiquidate'; - msg: 'invalidPerpPositionToLiquidate'; - }, - { - code: 6122; - name: 'invalidBaseAssetAmountForLiquidatePerp'; - msg: 'invalidBaseAssetAmountForLiquidatePerp'; - }, - { - code: 6123; - name: 'invalidPositionLastFundingRate'; - msg: 'invalidPositionLastFundingRate'; - }, - { - code: 6124; - name: 'invalidPositionDelta'; - msg: 'invalidPositionDelta'; - }, - { - code: 6125; - name: 'userBankrupt'; - msg: 'userBankrupt'; - }, - { - code: 6126; - name: 'userNotBankrupt'; - msg: 'userNotBankrupt'; - }, - { - code: 6127; - name: 'userHasInvalidBorrow'; - msg: 'userHasInvalidBorrow'; - }, - { - code: 6128; - name: 'dailyWithdrawLimit'; - msg: 'dailyWithdrawLimit'; - }, - { - code: 6129; - name: 'defaultError'; - msg: 'defaultError'; - }, - { - code: 6130; - name: 'insufficientLpTokens'; - msg: 'Insufficient LP tokens'; - }, - { - code: 6131; - name: 'cantLpWithPerpPosition'; - msg: 'Cant LP with a market position'; - }, - { - code: 6132; - name: 'unableToBurnLpTokens'; - msg: 'Unable to burn LP tokens'; - }, - { - code: 6133; - name: 'tryingToRemoveLiquidityTooFast'; - msg: 'Trying to remove liqudity too fast after adding it'; - }, - { - code: 6134; - name: 'invalidSpotMarketVault'; - msg: 'Invalid Spot Market Vault'; - }, - { - code: 6135; - name: 'invalidSpotMarketState'; - msg: 'Invalid Spot Market State'; - }, - { - code: 6136; - name: 'invalidSerumProgram'; - msg: 'invalidSerumProgram'; - }, - { - code: 6137; - name: 'invalidSerumMarket'; - msg: 'invalidSerumMarket'; - }, - { - code: 6138; - name: 'invalidSerumBids'; - msg: 'invalidSerumBids'; - }, - { - code: 6139; - name: 'invalidSerumAsks'; - msg: 'invalidSerumAsks'; - }, - { - code: 6140; - name: 'invalidSerumOpenOrders'; - msg: 'invalidSerumOpenOrders'; - }, - { - code: 6141; - name: 'failedSerumCpi'; - msg: 'failedSerumCpi'; - }, - { - code: 6142; - name: 'failedToFillOnExternalMarket'; - msg: 'failedToFillOnExternalMarket'; - }, - { - code: 6143; - name: 'invalidFulfillmentConfig'; - msg: 'invalidFulfillmentConfig'; - }, - { - code: 6144; - name: 'invalidFeeStructure'; - msg: 'invalidFeeStructure'; - }, - { - code: 6145; - name: 'insufficientIfShares'; - msg: 'Insufficient IF shares'; - }, - { - code: 6146; - name: 'marketActionPaused'; - msg: 'the Market has paused this action'; - }, - { - code: 6147; - name: 'marketPlaceOrderPaused'; - msg: 'the Market status doesnt allow placing orders'; - }, - { - code: 6148; - name: 'marketFillOrderPaused'; - msg: 'the Market status doesnt allow filling orders'; - }, - { - code: 6149; - name: 'marketWithdrawPaused'; - msg: 'the Market status doesnt allow withdraws'; - }, - { - code: 6150; - name: 'protectedAssetTierViolation'; - msg: 'Action violates the Protected Asset Tier rules'; - }, - { - code: 6151; - name: 'isolatedAssetTierViolation'; - msg: 'Action violates the Isolated Asset Tier rules'; - }, - { - code: 6152; - name: 'userCantBeDeleted'; - msg: 'User Cant Be Deleted'; - }, - { - code: 6153; - name: 'reduceOnlyWithdrawIncreasedRisk'; - msg: 'Reduce Only Withdraw Increased Risk'; - }, - { - code: 6154; - name: 'maxOpenInterest'; - msg: 'Max Open Interest'; - }, - { - code: 6155; - name: 'cantResolvePerpBankruptcy'; - msg: 'Cant Resolve Perp Bankruptcy'; - }, - { - code: 6156; - name: 'liquidationDoesntSatisfyLimitPrice'; - msg: 'Liquidation Doesnt Satisfy Limit Price'; - }, - { - code: 6157; - name: 'marginTradingDisabled'; - msg: 'Margin Trading Disabled'; - }, - { - code: 6158; - name: 'invalidMarketStatusToSettlePnl'; - msg: 'Invalid Market Status to Settle Perp Pnl'; - }, - { - code: 6159; - name: 'perpMarketNotInSettlement'; - msg: 'perpMarketNotInSettlement'; - }, - { - code: 6160; - name: 'perpMarketNotInReduceOnly'; - msg: 'perpMarketNotInReduceOnly'; - }, - { - code: 6161; - name: 'perpMarketSettlementBufferNotReached'; - msg: 'perpMarketSettlementBufferNotReached'; - }, - { - code: 6162; - name: 'perpMarketSettlementUserHasOpenOrders'; - msg: 'perpMarketSettlementUserHasOpenOrders'; - }, - { - code: 6163; - name: 'perpMarketSettlementUserHasActiveLp'; - msg: 'perpMarketSettlementUserHasActiveLp'; - }, - { - code: 6164; - name: 'unableToSettleExpiredUserPosition'; - msg: 'unableToSettleExpiredUserPosition'; - }, - { - code: 6165; - name: 'unequalMarketIndexForSpotTransfer'; - msg: 'unequalMarketIndexForSpotTransfer'; - }, - { - code: 6166; - name: 'invalidPerpPositionDetected'; - msg: 'invalidPerpPositionDetected'; - }, - { - code: 6167; - name: 'invalidSpotPositionDetected'; - msg: 'invalidSpotPositionDetected'; - }, - { - code: 6168; - name: 'invalidAmmDetected'; - msg: 'invalidAmmDetected'; - }, - { - code: 6169; - name: 'invalidAmmForFillDetected'; - msg: 'invalidAmmForFillDetected'; - }, - { - code: 6170; - name: 'invalidAmmLimitPriceOverride'; - msg: 'invalidAmmLimitPriceOverride'; - }, - { - code: 6171; - name: 'invalidOrderFillPrice'; - msg: 'invalidOrderFillPrice'; - }, - { - code: 6172; - name: 'spotMarketBalanceInvariantViolated'; - msg: 'spotMarketBalanceInvariantViolated'; - }, - { - code: 6173; - name: 'spotMarketVaultInvariantViolated'; - msg: 'spotMarketVaultInvariantViolated'; - }, - { - code: 6174; - name: 'invalidPda'; - msg: 'invalidPda'; - }, - { - code: 6175; - name: 'invalidPdaSigner'; - msg: 'invalidPdaSigner'; - }, - { - code: 6176; - name: 'revenueSettingsCannotSettleToIf'; - msg: 'revenueSettingsCannotSettleToIf'; - }, - { - code: 6177; - name: 'noRevenueToSettleToIf'; - msg: 'noRevenueToSettleToIf'; - }, - { - code: 6178; - name: 'noAmmPerpPnlDeficit'; - msg: 'noAmmPerpPnlDeficit'; - }, - { - code: 6179; - name: 'sufficientPerpPnlPool'; - msg: 'sufficientPerpPnlPool'; - }, - { - code: 6180; - name: 'insufficientPerpPnlPool'; - msg: 'insufficientPerpPnlPool'; - }, - { - code: 6181; - name: 'perpPnlDeficitBelowThreshold'; - msg: 'perpPnlDeficitBelowThreshold'; - }, - { - code: 6182; - name: 'maxRevenueWithdrawPerPeriodReached'; - msg: 'maxRevenueWithdrawPerPeriodReached'; - }, - { - code: 6183; - name: 'maxIfWithdrawReached'; - msg: 'invalidSpotPositionDetected'; - }, - { - code: 6184; - name: 'noIfWithdrawAvailable'; - msg: 'noIfWithdrawAvailable'; - }, - { - code: 6185; - name: 'invalidIfUnstake'; - msg: 'invalidIfUnstake'; - }, - { - code: 6186; - name: 'invalidIfUnstakeSize'; - msg: 'invalidIfUnstakeSize'; - }, - { - code: 6187; - name: 'invalidIfUnstakeCancel'; - msg: 'invalidIfUnstakeCancel'; - }, - { - code: 6188; - name: 'invalidIfForNewStakes'; - msg: 'invalidIfForNewStakes'; - }, - { - code: 6189; - name: 'invalidIfRebase'; - msg: 'invalidIfRebase'; - }, - { - code: 6190; - name: 'invalidInsuranceUnstakeSize'; - msg: 'invalidInsuranceUnstakeSize'; - }, - { - code: 6191; - name: 'invalidOrderLimitPrice'; - msg: 'invalidOrderLimitPrice'; - }, - { - code: 6192; - name: 'invalidIfDetected'; - msg: 'invalidIfDetected'; - }, - { - code: 6193; - name: 'invalidAmmMaxSpreadDetected'; - msg: 'invalidAmmMaxSpreadDetected'; - }, - { - code: 6194; - name: 'invalidConcentrationCoef'; - msg: 'invalidConcentrationCoef'; - }, - { - code: 6195; - name: 'invalidSrmVault'; - msg: 'invalidSrmVault'; - }, - { - code: 6196; - name: 'invalidVaultOwner'; - msg: 'invalidVaultOwner'; - }, - { - code: 6197; - name: 'invalidMarketStatusForFills'; - msg: 'invalidMarketStatusForFills'; - }, - { - code: 6198; - name: 'ifWithdrawRequestInProgress'; - msg: 'ifWithdrawRequestInProgress'; - }, - { - code: 6199; - name: 'noIfWithdrawRequestInProgress'; - msg: 'noIfWithdrawRequestInProgress'; - }, - { - code: 6200; - name: 'ifWithdrawRequestTooSmall'; - msg: 'ifWithdrawRequestTooSmall'; - }, - { - code: 6201; - name: 'incorrectSpotMarketAccountPassed'; - msg: 'incorrectSpotMarketAccountPassed'; - }, - { - code: 6202; - name: 'blockchainClockInconsistency'; - msg: 'blockchainClockInconsistency'; - }, - { - code: 6203; - name: 'invalidIfSharesDetected'; - msg: 'invalidIfSharesDetected'; - }, - { - code: 6204; - name: 'newLpSizeTooSmall'; - msg: 'newLpSizeTooSmall'; - }, - { - code: 6205; - name: 'marketStatusInvalidForNewLp'; - msg: 'marketStatusInvalidForNewLp'; - }, - { - code: 6206; - name: 'invalidMarkTwapUpdateDetected'; - msg: 'invalidMarkTwapUpdateDetected'; - }, - { - code: 6207; - name: 'marketSettlementAttemptOnActiveMarket'; - msg: 'marketSettlementAttemptOnActiveMarket'; - }, - { - code: 6208; - name: 'marketSettlementRequiresSettledLp'; - msg: 'marketSettlementRequiresSettledLp'; - }, - { - code: 6209; - name: 'marketSettlementAttemptTooEarly'; - msg: 'marketSettlementAttemptTooEarly'; - }, - { - code: 6210; - name: 'marketSettlementTargetPriceInvalid'; - msg: 'marketSettlementTargetPriceInvalid'; - }, - { - code: 6211; - name: 'unsupportedSpotMarket'; - msg: 'unsupportedSpotMarket'; - }, - { - code: 6212; - name: 'spotOrdersDisabled'; - msg: 'spotOrdersDisabled'; - }, - { - code: 6213; - name: 'marketBeingInitialized'; - msg: 'Market Being Initialized'; - }, - { - code: 6214; - name: 'invalidUserSubAccountId'; - msg: 'Invalid Sub Account Id'; - }, - { - code: 6215; - name: 'invalidTriggerOrderCondition'; - msg: 'Invalid Trigger Order Condition'; - }, - { - code: 6216; - name: 'invalidSpotPosition'; - msg: 'Invalid Spot Position'; - }, - { - code: 6217; - name: 'cantTransferBetweenSameUserAccount'; - msg: 'Cant transfer between same user account'; - }, - { - code: 6218; - name: 'invalidPerpPosition'; - msg: 'Invalid Perp Position'; - }, - { - code: 6219; - name: 'unableToGetLimitPrice'; - msg: 'Unable To Get Limit Price'; - }, - { - code: 6220; - name: 'invalidLiquidation'; - msg: 'Invalid Liquidation'; - }, - { - code: 6221; - name: 'spotFulfillmentConfigDisabled'; - msg: 'Spot Fulfillment Config Disabled'; - }, - { - code: 6222; - name: 'invalidMaker'; - msg: 'Invalid Maker'; - }, - { - code: 6223; - name: 'failedUnwrap'; - msg: 'Failed Unwrap'; - }, - { - code: 6224; - name: 'maxNumberOfUsers'; - msg: 'Max Number Of Users'; - }, - { - code: 6225; - name: 'invalidOracleForSettlePnl'; - msg: 'invalidOracleForSettlePnl'; - }, - { - code: 6226; - name: 'marginOrdersOpen'; - msg: 'marginOrdersOpen'; - }, - { - code: 6227; - name: 'tierViolationLiquidatingPerpPnl'; - msg: 'tierViolationLiquidatingPerpPnl'; - }, - { - code: 6228; - name: 'couldNotLoadUserData'; - msg: 'couldNotLoadUserData'; - }, - { - code: 6229; - name: 'userWrongMutability'; - msg: 'userWrongMutability'; - }, - { - code: 6230; - name: 'invalidUserAccount'; - msg: 'invalidUserAccount'; - }, - { - code: 6231; - name: 'couldNotLoadUserStatsData'; - msg: 'couldNotLoadUserData'; - }, - { - code: 6232; - name: 'userStatsWrongMutability'; - msg: 'userWrongMutability'; - }, - { - code: 6233; - name: 'invalidUserStatsAccount'; - msg: 'invalidUserAccount'; - }, - { - code: 6234; - name: 'userNotFound'; - msg: 'userNotFound'; - }, - { - code: 6235; - name: 'unableToLoadUserAccount'; - msg: 'unableToLoadUserAccount'; - }, - { - code: 6236; - name: 'userStatsNotFound'; - msg: 'userStatsNotFound'; - }, - { - code: 6237; - name: 'unableToLoadUserStatsAccount'; - msg: 'unableToLoadUserStatsAccount'; - }, - { - code: 6238; - name: 'userNotInactive'; - msg: 'User Not Inactive'; - }, - { - code: 6239; - name: 'revertFill'; - msg: 'revertFill'; - }, - { - code: 6240; - name: 'invalidMarketAccountforDeletion'; - msg: 'Invalid MarketAccount for Deletion'; - }, - { - code: 6241; - name: 'invalidSpotFulfillmentParams'; - msg: 'Invalid Spot Fulfillment Params'; - }, - { - code: 6242; - name: 'failedToGetMint'; - msg: 'Failed to Get Mint'; - }, - { - code: 6243; - name: 'failedPhoenixCpi'; - msg: 'failedPhoenixCpi'; - }, - { - code: 6244; - name: 'failedToDeserializePhoenixMarket'; - msg: 'failedToDeserializePhoenixMarket'; - }, - { - code: 6245; - name: 'invalidPricePrecision'; - msg: 'invalidPricePrecision'; - }, - { - code: 6246; - name: 'invalidPhoenixProgram'; - msg: 'invalidPhoenixProgram'; - }, - { - code: 6247; - name: 'invalidPhoenixMarket'; - msg: 'invalidPhoenixMarket'; - }, - { - code: 6248; - name: 'invalidSwap'; - msg: 'invalidSwap'; - }, - { - code: 6249; - name: 'swapLimitPriceBreached'; - msg: 'swapLimitPriceBreached'; - }, - { - code: 6250; - name: 'spotMarketReduceOnly'; - msg: 'spotMarketReduceOnly'; - }, - { - code: 6251; - name: 'fundingWasNotUpdated'; - msg: 'fundingWasNotUpdated'; - }, - { - code: 6252; - name: 'impossibleFill'; - msg: 'impossibleFill'; - }, - { - code: 6253; - name: 'cantUpdatePerpBidAskTwap'; - msg: 'cantUpdatePerpBidAskTwap'; - }, - { - code: 6254; - name: 'userReduceOnly'; - msg: 'userReduceOnly'; - }, - { - code: 6255; - name: 'invalidMarginCalculation'; - msg: 'invalidMarginCalculation'; - }, - { - code: 6256; - name: 'cantPayUserInitFee'; - msg: 'cantPayUserInitFee'; - }, - { - code: 6257; - name: 'cantReclaimRent'; - msg: 'cantReclaimRent'; - }, - { - code: 6258; - name: 'insuranceFundOperationPaused'; - msg: 'insuranceFundOperationPaused'; - }, - { - code: 6259; - name: 'noUnsettledPnl'; - msg: 'noUnsettledPnl'; - }, - { - code: 6260; - name: 'pnlPoolCantSettleUser'; - msg: 'pnlPoolCantSettleUser'; - }, - { - code: 6261; - name: 'oracleNonPositive'; - msg: 'oracleInvalid'; - }, - { - code: 6262; - name: 'oracleTooVolatile'; - msg: 'oracleTooVolatile'; - }, - { - code: 6263; - name: 'oracleTooUncertain'; - msg: 'oracleTooUncertain'; - }, - { - code: 6264; - name: 'oracleStaleForMargin'; - msg: 'oracleStaleForMargin'; - }, - { - code: 6265; - name: 'oracleInsufficientDataPoints'; - msg: 'oracleInsufficientDataPoints'; - }, - { - code: 6266; - name: 'oracleStaleForAmm'; - msg: 'oracleStaleForAmm'; - }, - { - code: 6267; - name: 'unableToParsePullOracleMessage'; - msg: 'Unable to parse pull oracle message'; - }, - { - code: 6268; - name: 'maxBorrows'; - msg: 'Can not borow more than max borrows'; - }, - { - code: 6269; - name: 'oracleUpdatesNotMonotonic'; - msg: 'Updates must be monotonically increasing'; - }, - { - code: 6270; - name: 'oraclePriceFeedMessageMismatch'; - msg: 'Trying to update price feed with the wrong feed id'; - }, - { - code: 6271; - name: 'oracleUnsupportedMessageType'; - msg: 'The message in the update must be a PriceFeedMessage'; - }, - { - code: 6272; - name: 'oracleDeserializeMessageFailed'; - msg: 'Could not deserialize the message in the update'; - }, - { - code: 6273; - name: 'oracleWrongGuardianSetOwner'; - msg: 'Wrong guardian set owner in update price atomic'; - }, - { - code: 6274; - name: 'oracleWrongWriteAuthority'; - msg: 'Oracle post update atomic price feed account must be drift program'; - }, - { - code: 6275; - name: 'oracleWrongVaaOwner'; - msg: 'Oracle vaa owner must be wormhole program'; - }, - { - code: 6276; - name: 'oracleTooManyPriceAccountUpdates'; - msg: 'Multi updates must have 2 or fewer accounts passed in remaining accounts'; - }, - { - code: 6277; - name: 'oracleMismatchedVaaAndPriceUpdates'; - msg: "Don't have the same remaining accounts number and pyth updates left"; - }, - { - code: 6278; - name: 'oracleBadRemainingAccountPublicKey'; - msg: 'Remaining account passed does not match oracle update derived pda'; - }, - { - code: 6279; - name: 'failedOpenbookV2cpi'; - msg: 'failedOpenbookV2cpi'; - }, - { - code: 6280; - name: 'invalidOpenbookV2Program'; - msg: 'invalidOpenbookV2Program'; - }, - { - code: 6281; - name: 'invalidOpenbookV2Market'; - msg: 'invalidOpenbookV2Market'; - }, - { - code: 6282; - name: 'nonZeroTransferFee'; - msg: 'Non zero transfer fee'; - }, - { - code: 6283; - name: 'liquidationOrderFailedToFill'; - msg: 'Liquidation order failed to fill'; - }, - { - code: 6284; - name: 'invalidPredictionMarketOrder'; - msg: 'Invalid prediction market order'; - }, - { - code: 6285; - name: 'invalidVerificationIxIndex'; - msg: 'Ed25519 Ix must be before place and make SignedMsg order ix'; - }, - { - code: 6286; - name: 'sigVerificationFailed'; - msg: 'SignedMsg message verificaiton failed'; - }, - { - code: 6287; - name: 'mismatchedSignedMsgOrderParamsMarketIndex'; - msg: 'Market index mismatched b/w taker and maker SignedMsg order params'; - }, - { - code: 6288; - name: 'invalidSignedMsgOrderParam'; - msg: 'Invalid SignedMsg order param'; - }, - { - code: 6289; - name: 'placeAndTakeOrderSuccessConditionFailed'; - msg: 'Place and take order success condition failed'; - }, - { - code: 6290; - name: 'invalidHighLeverageModeConfig'; - msg: 'Invalid High Leverage Mode Config'; - }, - { - code: 6291; - name: 'invalidRfqUserAccount'; - msg: 'Invalid RFQ User Account'; - }, - { - code: 6292; - name: 'rfqUserAccountWrongMutability'; - msg: 'RFQUserAccount should be mutable'; - }, - { - code: 6293; - name: 'rfqUserAccountFull'; - msg: 'RFQUserAccount has too many active RFQs'; - }, - { - code: 6294; - name: 'rfqOrderNotFilled'; - msg: 'RFQ order not filled as expected'; - }, - { - code: 6295; - name: 'invalidRfqOrder'; - msg: 'RFQ orders must be jit makers'; - }, - { - code: 6296; - name: 'invalidRfqMatch'; - msg: 'RFQ matches must be valid'; - }, - { - code: 6297; - name: 'invalidSignedMsgUserAccount'; - msg: 'Invalid SignedMsg user account'; - }, - { - code: 6298; - name: 'signedMsgUserAccountWrongMutability'; - msg: 'SignedMsg account wrong mutability'; - }, - { - code: 6299; - name: 'signedMsgUserOrdersAccountFull'; - msg: 'SignedMsgUserAccount has too many active orders'; - }, - { - code: 6300; - name: 'signedMsgOrderDoesNotExist'; - msg: 'Order with SignedMsg uuid does not exist'; - }, - { - code: 6301; - name: 'invalidSignedMsgOrderId'; - msg: 'SignedMsg order id cannot be 0s'; - }, - { - code: 6302; - name: 'invalidPoolId'; - msg: 'Invalid pool id'; - }, - { - code: 6303; - name: 'invalidProtectedMakerModeConfig'; - msg: 'Invalid Protected Maker Mode Config'; - }, - { - code: 6304; - name: 'invalidPythLazerStorageOwner'; - msg: 'Invalid pyth lazer storage owner'; - }, - { - code: 6305; - name: 'unverifiedPythLazerMessage'; - msg: 'Verification of pyth lazer message failed'; - }, - { - code: 6306; - name: 'invalidPythLazerMessage'; - msg: 'Invalid pyth lazer message'; - }, - { - code: 6307; - name: 'pythLazerMessagePriceFeedMismatch'; - msg: 'Pyth lazer message does not correspond to correct fed id'; - }, - { - code: 6308; - name: 'invalidLiquidateSpotWithSwap'; - msg: 'invalidLiquidateSpotWithSwap'; - }, - { - code: 6309; - name: 'signedMsgUserContextUserMismatch'; - msg: 'User in SignedMsg message does not match user in ix context'; - }, - { - code: 6310; - name: 'userFuelOverflowThresholdNotMet'; - msg: 'User fuel overflow threshold not met'; - }, - { - code: 6311; - name: 'fuelOverflowAccountNotFound'; - msg: 'FuelOverflow account not found'; - }, - { - code: 6312; - name: 'invalidTransferPerpPosition'; - msg: 'Invalid Transfer Perp Position'; - }, - { - code: 6313; - name: 'invalidSignedMsgUserOrdersResize'; - msg: 'Invalid SignedMsgUserOrders resize'; - }, - { - code: 6314; - name: 'couldNotDeserializeHighLeverageModeConfig'; - msg: 'Could not deserialize high leverage mode config'; - }, - { - code: 6315; - name: 'invalidIfRebalanceConfig'; - msg: 'Invalid If Rebalance Config'; - }, - { - code: 6316; - name: 'invalidIfRebalanceSwap'; - msg: 'Invalid If Rebalance Swap'; - }, - { - code: 6317; - name: 'invalidRevenueShareResize'; - msg: 'Invalid RevenueShare resize'; - }, - { - code: 6318; - name: 'builderRevoked'; - msg: 'Builder has been revoked'; - }, - { - code: 6319; - name: 'invalidBuilderFee'; - msg: 'Builder fee is greater than max fee bps'; - }, - { - code: 6320; - name: 'revenueShareEscrowAuthorityMismatch'; - msg: 'RevenueShareEscrow authority mismatch'; - }, - { - code: 6321; - name: 'revenueShareEscrowOrdersAccountFull'; - msg: 'RevenueShareEscrow has too many active orders'; - }, - { - code: 6322; - name: 'invalidRevenueShareAccount'; - msg: 'Invalid RevenueShareAccount'; - }, - { - code: 6323; - name: 'cannotRevokeBuilderWithOpenOrders'; - msg: 'Cannot revoke builder with open orders'; - }, - { - code: 6324; - name: 'unableToLoadRevenueShareAccount'; - msg: 'Unable to load builder account'; - }, - { - code: 6325; - name: 'invalidConstituent'; - msg: 'Invalid Constituent'; - }, - { - code: 6326; - name: 'invalidAmmConstituentMappingArgument'; - msg: 'Invalid Amm Constituent Mapping argument'; - }, - { - code: 6327; - name: 'constituentNotFound'; - msg: 'Constituent not found'; - }, - { - code: 6328; - name: 'constituentCouldNotLoad'; - msg: 'Constituent could not load'; - }, - { - code: 6329; - name: 'constituentWrongMutability'; - msg: 'Constituent wrong mutability'; - }, - { - code: 6330; - name: 'wrongNumberOfConstituents'; - msg: 'Wrong number of constituents passed to instruction'; - }, - { - code: 6331; - name: 'insufficientConstituentTokenBalance'; - msg: 'Insufficient constituent token balance'; - }, { - code: 6332; - name: 'ammCacheStale'; - msg: 'Amm Cache data too stale'; + name: 'signedMsgOrderParamsExport'; + discriminator: [141, 81, 104, 63, 186, 109, 87, 251]; }, + ]; + errors: [ { - code: 6333; - name: 'lpPoolAumDelayed'; - msg: 'LP Pool AUM not updated recently'; + code: 6000; + name: 'invalidEd25519InstructionProgramId'; + msg: 'invalid ed25519 instruction program'; }, { - code: 6334; - name: 'constituentOracleStale'; - msg: 'Constituent oracle is stale'; + code: 6001; + name: 'invalidEd25519InstructionDataLength'; + msg: 'invalid ed25519 instruction data length'; }, { - code: 6335; - name: 'lpInvariantFailed'; - msg: 'LP Invariant failed'; + code: 6002; + name: 'invalidSignatureIndex'; + msg: 'invalid signature index'; }, { - code: 6336; - name: 'invalidConstituentDerivativeWeights'; - msg: 'Invalid constituent derivative weights'; + code: 6003; + name: 'invalidSignatureOffset'; + msg: 'invalid signature offset'; }, { - code: 6337; - name: 'maxDlpAumBreached'; - msg: 'Max DLP AUM Breached'; + code: 6004; + name: 'invalidPublicKeyOffset'; + msg: 'invalid public key offset'; }, { - code: 6338; - name: 'settleLpPoolDisabled'; - msg: 'Settle Lp Pool Disabled'; + code: 6005; + name: 'invalidMessageOffset'; + msg: 'invalid message offset'; }, { - code: 6339; - name: 'mintRedeemLpPoolDisabled'; - msg: 'Mint/Redeem Lp Pool Disabled'; + code: 6006; + name: 'invalidMessageDataSize'; + msg: 'invalid message data size'; }, { - code: 6340; - name: 'lpPoolSettleInvariantBreached'; - msg: 'Settlement amount exceeded'; + code: 6007; + name: 'invalidInstructionIndex'; + msg: 'invalid instruction index'; }, { - code: 6341; - name: 'invalidConstituentOperation'; - msg: 'Invalid constituent operation'; + code: 6008; + name: 'messageOffsetOverflow'; + msg: 'message offset overflow'; }, { - code: 6342; - name: 'unauthorized'; - msg: 'Unauthorized for operation'; + code: 6009; + name: 'invalidMessageHex'; + msg: 'invalid message hex'; }, { - code: 6343; - name: 'invalidLpPoolId'; - msg: 'Invalid Lp Pool Id for Operation'; + code: 6010; + name: 'invalidMessageData'; + msg: 'invalid message data'; }, { - code: 6344; - name: 'marketIndexNotFoundAmmCache'; - msg: 'marketIndexNotFoundAmmCache'; + code: 6011; + name: 'loadInstructionAtFailed'; + msg: 'loading custom ix at index failed'; }, ]; types: [ @@ -17287,6 +15626,10 @@ export type Drift = { }; }; }, + { + name: 'bitFlags'; + type: 'u8'; + }, ]; }; }, @@ -19759,6 +18102,154 @@ export type Drift = { ]; }; }, + { + name: 'signedMsgOrderParamsDelegateMessage'; + type: { + kind: 'struct'; + fields: [ + { + name: 'signedMsgOrderParams'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'takerPubkey'; + type: 'pubkey'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'uuid'; + type: { + array: ['u8', 8]; + }; + }, + { + name: 'takeProfitOrderParams'; + type: { + option: { + defined: { + name: 'signedMsgTriggerOrderParams'; + }; + }; + }; + }, + { + name: 'stopLossOrderParams'; + type: { + option: { + defined: { + name: 'signedMsgTriggerOrderParams'; + }; + }; + }; + }, + { + name: 'maxMarginRatio'; + type: { + option: 'u16'; + }; + }, + { + name: 'builderIdx'; + type: { + option: 'u8'; + }; + }, + { + name: 'builderFeeTenthBps'; + type: { + option: 'u16'; + }; + }, + { + name: 'isolatedPositionDeposit'; + type: { + option: 'u64'; + }; + }, + ]; + }; + }, + { + name: 'signedMsgOrderParamsMessage'; + type: { + kind: 'struct'; + fields: [ + { + name: 'signedMsgOrderParams'; + type: { + defined: { + name: 'orderParams'; + }; + }; + }, + { + name: 'subAccountId'; + type: 'u16'; + }, + { + name: 'slot'; + type: 'u64'; + }, + { + name: 'uuid'; + type: { + array: ['u8', 8]; + }; + }, + { + name: 'takeProfitOrderParams'; + type: { + option: { + defined: { + name: 'signedMsgTriggerOrderParams'; + }; + }; + }; + }, + { + name: 'stopLossOrderParams'; + type: { + option: { + defined: { + name: 'signedMsgTriggerOrderParams'; + }; + }; + }; + }, + { + name: 'maxMarginRatio'; + type: { + option: 'u16'; + }; + }, + { + name: 'builderIdx'; + type: { + option: 'u8'; + }; + }, + { + name: 'builderFeeTenthBps'; + type: { + option: 'u16'; + }; + }, + { + name: 'isolatedPositionDeposit'; + type: { + option: 'u64'; + }; + }, + ]; + }; + }, { name: 'signedMsgOrderRecord'; type: { @@ -19801,6 +18292,22 @@ export type Drift = { ]; }; }, + { + name: 'signedMsgTriggerOrderParams'; + type: { + kind: 'struct'; + fields: [ + { + name: 'triggerPrice'; + type: 'u64'; + }, + { + name: 'baseAssetAmount'; + type: 'u64'; + }, + ]; + }; + }, { name: 'signedMsgUserOrders'; docs: [ @@ -21404,27 +19911,52 @@ export type Drift = { }; }, { - name: 'i128'; - docs: ['`i128` with legacy bit layout']; + name: 'signedMsgOrderParamsExport'; + docs: [ + 'unusued placeholder event to force include signed msg types into drift IDL', + ]; type: { kind: 'struct'; fields: [ { - array: ['u8', 16]; + name: 'a'; + type: { + defined: { + name: 'signedMsgOrderParamsMessage'; + }; + }; + }, + { + name: 'b'; + type: { + defined: { + name: 'signedMsgOrderParamsDelegateMessage'; + }; + }; }, ]; }; }, + { + name: 'i128'; + docs: ['compatibility i128']; + repr: { + kind: 'transparent'; + }; + type: { + kind: 'type'; + alias: 'i128'; + }; + }, { name: 'u128'; - docs: ['`u128` with legacy bit layout']; + docs: ['compatibility u128']; + repr: { + kind: 'transparent'; + }; type: { - kind: 'struct'; - fields: [ - { - array: ['u8', 16]; - }, - ]; + kind: 'type'; + alias: 'u128'; }; }, ]; diff --git a/sdk/src/math/amm.ts b/sdk/src/math/amm.ts index 55680edc4c..7d723c66f6 100644 --- a/sdk/src/math/amm.ts +++ b/sdk/src/math/amm.ts @@ -898,7 +898,7 @@ export function calculateSpread( liveOracleStd, amm.longIntensityVolume, amm.shortIntensityVolume, - amm.volume24H, + amm.volume24h, amm.ammInventorySpreadAdjustment ); let longSpread = spreads[0]; @@ -1008,7 +1008,6 @@ export function calculateSpreadReserves( ); quoteAssetReserve = clampBN(quoteAssetReserve, qarLower, qarUpper); } - const baseAssetReserve = amm.sqrtK.mul(amm.sqrtK).div(quoteAssetReserve); return { baseAssetReserve, @@ -1066,10 +1065,10 @@ export function calculateSpreadReserves( referencePriceOffset = calculateReferencePriceOffset( reservePrice, - amm.last24HAvgFundingRate, + amm.last24hAvgFundingRate, liquidityFractionAfterDeadband, - amm.historicalOracleData.lastOraclePriceTwap5Min, - amm.lastMarkPriceTwap5Min, + amm.historicalOracleData.lastOraclePriceTwap5min, + amm.lastMarkPriceTwap5min, amm.historicalOracleData.lastOraclePriceTwap, amm.lastMarkPriceTwap, maxOffset diff --git a/sdk/src/math/auction.ts b/sdk/src/math/auction.ts index 013f1388b7..658038ad3a 100644 --- a/sdk/src/math/auction.ts +++ b/sdk/src/math/auction.ts @@ -265,7 +265,7 @@ export function getTriggerAuctionStartPrice(params: { .sub(perpMarket.amm.lastMarkPriceTwapTs) .abs() .gte(new BN(60)) || - perpMarket.amm.volume24H.lte(new BN(100_000).mul(QUOTE_PRECISION)); + perpMarket.amm.volume24h.lte(new BN(100_000).mul(QUOTE_PRECISION)); let baselineStartOffset: BN; @@ -280,11 +280,11 @@ export function getTriggerAuctionStartPrice(params: { ? perpMarket.amm.lastBidPriceTwap : perpMarket.amm.lastAskPriceTwap; - const markTwapFast = perpMarket.amm.lastMarkPriceTwap5Min; + const markTwapFast = perpMarket.amm.lastMarkPriceTwap5min; const oracleTwapSlow = perpMarket.amm.historicalOracleData.lastOraclePriceTwap; const oracleTwapFast = - perpMarket.amm.historicalOracleData.lastOraclePriceTwap5Min; + perpMarket.amm.historicalOracleData.lastOraclePriceTwap5min; const offsetSlow = markTwapSlow.sub(oracleTwapSlow); const offsetFast = markTwapFast.sub(oracleTwapFast); diff --git a/sdk/src/math/market.ts b/sdk/src/math/market.ts index cae257898a..be384a9d47 100644 --- a/sdk/src/math/market.ts +++ b/sdk/src/math/market.ts @@ -413,9 +413,9 @@ export function getTriggerPrice( const lastFillPrice = market.lastFillPrice; // Calculate 5-minute basis - const markPrice5minTwap = market.amm.lastMarkPriceTwap5Min; + const markPrice5minTwap = market.amm.lastMarkPriceTwap5min; const lastOraclePriceTwap5min = - market.amm.historicalOracleData.lastOraclePriceTwap5Min; + market.amm.historicalOracleData.lastOraclePriceTwap5min; const basis5min = markPrice5minTwap.sub(lastOraclePriceTwap5min); const oraclePlusBasis5min = oraclePrice.add(basis5min); diff --git a/sdk/src/math/oracles.ts b/sdk/src/math/oracles.ts index 27248326f0..bd6fdc1b7a 100644 --- a/sdk/src/math/oracles.ts +++ b/sdk/src/math/oracles.ts @@ -186,12 +186,13 @@ export function isOracleTooDivergent( oraclePriceData: OraclePriceData, oracleGuardRails: OracleGuardRails ): boolean { + console.log(amm.historicalOracleData.lastOraclePriceTwap5min); const oracleSpreadPct = oraclePriceData.price - .sub(amm.historicalOracleData.lastOraclePriceTwap5Min) + .sub(amm.historicalOracleData.lastOraclePriceTwap5min) .mul(PERCENTAGE_PRECISION) - .div(amm.historicalOracleData.lastOraclePriceTwap5Min); + .div(amm.historicalOracleData.lastOraclePriceTwap5min); const maxDivergence = BN.max( - oracleGuardRails.priceDivergence.oracleTwap5MinPercentDivergence, + oracleGuardRails.priceDivergence.oracleTwap5minPercentDivergence, PERCENTAGE_PRECISION.div(new BN(2)) ); const tooDivergent = oracleSpreadPct.abs().gte(maxDivergence); @@ -206,7 +207,7 @@ export function calculateLiveOracleTwap( ): BN { let oracleTwap = undefined; if (period.eq(FIVE_MINUTE)) { - oracleTwap = histOracleData.lastOraclePriceTwap5Min; + oracleTwap = histOracleData.lastOraclePriceTwap5min; } else { //todo: assumes its fundingPeriod (1hr) // period = amm.fundingPeriod; diff --git a/sdk/src/math/trade.ts b/sdk/src/math/trade.ts index 2b0dec0f58..0e4b00d62b 100644 --- a/sdk/src/math/trade.ts +++ b/sdk/src/math/trade.ts @@ -999,19 +999,19 @@ export function getUser30dRollingVolumeEstimate( ) { now = now || new BN(new Date().getTime() / 1000); const sinceLastTaker = BN.max( - now.sub(userStatsAccount.lastTakerVolume30DTs), + now.sub(userStatsAccount.lastTakerVolume30dTs), ZERO ); const sinceLastMaker = BN.max( - now.sub(userStatsAccount.lastMakerVolume30DTs), + now.sub(userStatsAccount.lastMakerVolume30dTs), ZERO ); const thirtyDaysInSeconds = new BN(60 * 60 * 24 * 30); - const last30dVolume = userStatsAccount.takerVolume30D + const last30dVolume = userStatsAccount.takerVolume30d .mul(BN.max(thirtyDaysInSeconds.sub(sinceLastTaker), ZERO)) .div(thirtyDaysInSeconds) .add( - userStatsAccount.makerVolume30D + userStatsAccount.makerVolume30d .mul(BN.max(thirtyDaysInSeconds.sub(sinceLastMaker), ZERO)) .div(thirtyDaysInSeconds) ); diff --git a/sdk/src/oracles/oracleClientCache.ts b/sdk/src/oracles/oracleClientCache.ts index 472e2beb2a..7591a0420b 100644 --- a/sdk/src/oracles/oracleClientCache.ts +++ b/sdk/src/oracles/oracleClientCache.ts @@ -2,8 +2,7 @@ import { OracleClient } from './types'; import { OracleSource } from '../types'; import { getOracleClient } from '../factory/oracleClient'; import { Connection } from '@solana/web3.js'; -import { Program } from '@coral-xyz/anchor'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class OracleClientCache { cache = new Map(); @@ -12,7 +11,7 @@ export class OracleClientCache { public get( oracleSource: OracleSource, connection: Connection, - program: Program + program: DriftProgram ) { const key = Object.keys(oracleSource)[0]; if (this.cache.has(key)) { diff --git a/sdk/src/oracles/prelaunchOracleClient.ts b/sdk/src/oracles/prelaunchOracleClient.ts index c9c4a60364..5883b582fe 100644 --- a/sdk/src/oracles/prelaunchOracleClient.ts +++ b/sdk/src/oracles/prelaunchOracleClient.ts @@ -1,14 +1,13 @@ import { Connection, PublicKey } from '@solana/web3.js'; import { OracleClient, OraclePriceData } from './types'; -import { Program } from '@coral-xyz/anchor'; import { PrelaunchOracle } from '../types'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class PrelaunchOracleClient implements OracleClient { private connection: Connection; - private program: Program; + private program: DriftProgram; - public constructor(connection: Connection, program: Program) { + public constructor(connection: Connection, program: DriftProgram) { this.connection = connection; this.program = program; } diff --git a/sdk/src/oracles/pythLazerClient.ts b/sdk/src/oracles/pythLazerClient.ts index 7f35871a12..253480391c 100644 --- a/sdk/src/oracles/pythLazerClient.ts +++ b/sdk/src/oracles/pythLazerClient.ts @@ -9,13 +9,13 @@ import { } from '../constants/numericConstants'; import { Wallet } from '../wallet'; import driftIDL from '../idl/drift.json'; -import { Drift } from '../idl/drift'; +import { DriftProgram } from '../config'; export class PythLazerClient implements OracleClient { private connection: Connection; private multiple: BN; private stableCoin: boolean; - private program: Program; + private program: DriftProgram; readonly decodeFunc: (name: string, data: Buffer) => any; public constructor( diff --git a/sdk/src/titan/titanClient.ts b/sdk/src/titan/titanClient.ts index 25b7a1b753..c26ba0166a 100644 --- a/sdk/src/titan/titanClient.ts +++ b/sdk/src/titan/titanClient.ts @@ -140,9 +140,10 @@ export class TitanClient { accountsLimitWritable?: number; }): URLSearchParams { // Normalize swapMode to enum value - const normalizedSwapMode = swapMode === 'ExactOut' || swapMode === SwapMode.ExactOut - ? SwapMode.ExactOut - : SwapMode.ExactIn; + const normalizedSwapMode = + swapMode === 'ExactOut' || swapMode === SwapMode.ExactOut + ? SwapMode.ExactOut + : SwapMode.ExactIn; return new URLSearchParams({ inputMint: inputMint.toString(), @@ -332,12 +333,14 @@ export class TitanClient { // Check if we have cached quote data that matches the current parameters if (!this.lastQuoteData || this.lastQuoteParams !== params.toString()) { - throw new Error('No matching quote data found. Please get a fresh quote before attempting to swap.'); + throw new Error( + 'No matching quote data found. Please get a fresh quote before attempting to swap.' + ); } // Reuse the cached quote data const data = this.lastQuoteData; - + const route = data.quotes[ Object.keys(data.quotes).find((key) => key.toLowerCase() === 'titan') || @@ -347,7 +350,7 @@ export class TitanClient { if (!route) { throw new Error('No routes available'); } - + if (route.instructions && route.instructions.length > 0) { try { const { transactionMessage, lookupTables } = diff --git a/sdk/src/types.ts b/sdk/src/types.ts index 3c6a470233..39975f90f2 100644 --- a/sdk/src/types.ts +++ b/sdk/src/types.ts @@ -914,7 +914,7 @@ export type HistoricalOracleData = { lastOracleDelay: BN; lastOracleConf: BN; lastOraclePriceTwap: BN; - lastOraclePriceTwap5Min: BN; + lastOraclePriceTwap5min: BN; lastOraclePriceTwapTs: BN; }; @@ -922,7 +922,7 @@ export type HistoricalIndexData = { lastIndexBidPrice: BN; lastIndexAskPrice: BN; lastIndexPriceTwap: BN; - lastIndexPriceTwap5Min: BN; + lastIndexPriceTwap5min: BN; lastIndexPriceTwapTs: BN; }; @@ -1025,11 +1025,10 @@ export type PoolBalance = { export type AMM = { baseAssetReserve: BN; sqrtK: BN; - cumulativeFundingRate: BN; lastFundingRate: BN; lastFundingRateTs: BN; lastMarkPriceTwap: BN; - lastMarkPriceTwap5Min: BN; + lastMarkPriceTwap5min: BN; lastMarkPriceTwapTs: BN; lastTradeTs: BN; @@ -1045,7 +1044,7 @@ export type AMM = { pegMultiplier: BN; cumulativeFundingRateLong: BN; cumulativeFundingRateShort: BN; - last24HAvgFundingRate: BN; + last24hAvgFundingRate: BN; lastFundingRateShort: BN; lastFundingRateLong: BN; @@ -1100,7 +1099,7 @@ export type AMM = { oracleStd: BN; longIntensityVolume: BN; shortIntensityVolume: BN; - volume24H: BN; + volume24h: BN; minOrderSize: BN; mmOraclePrice: BN; mmOracleSlot: BN; @@ -1153,12 +1152,12 @@ export class PositionFlag { export type UserStatsAccount = { numberOfSubAccounts: number; numberOfSubAccountsCreated: number; - makerVolume30D: BN; - takerVolume30D: BN; - fillerVolume30D: BN; - lastMakerVolume30DTs: BN; - lastTakerVolume30DTs: BN; - lastFillerVolume30DTs: BN; + makerVolume30d: BN; + takerVolume30d: BN; + fillerVolume30d: BN; + lastMakerVolume30dTs: BN; + lastTakerVolume30dTs: BN; + lastFillerVolume30dTs: BN; fees: { totalFeePaid: BN; totalFeeRebate: BN; @@ -1184,232 +1183,6 @@ export type UserStatsAccount = { ifStakedGovTokenAmount: BN; }; -export function parseUserStatsAccount(account: { - makerVolume30d: BN; - takerVolume30d: BN; - fillerVolume30d: BN; - lastMakerVolume30dTs: BN; - lastTakerVolume30dTs: BN; - lastFillerVolume30dTs: BN; - [key: string]: any; -}): UserStatsAccount { - return { - ...account, - makerVolume30D: account.makerVolume30d, - takerVolume30D: account.takerVolume30d, - fillerVolume30D: account.fillerVolume30d, - lastMakerVolume30DTs: account.lastMakerVolume30dTs, - lastTakerVolume30DTs: account.lastTakerVolume30dTs, - lastFillerVolume30DTs: account.lastFillerVolume30dTs, - } as unknown as UserStatsAccount; -} - -/** - * Parses an Anchor-generated AMM account to the SDK's AMM type. - * Handles field name mappings and provides defaults for missing fields. - */ -export function parseAMM(amm: { - last24hAvgFundingRate?: BN; - lastMarkPriceTwap5min?: BN; - volume24h?: BN; - cumulativeFundingRate?: BN; - cumulativeFundingRateLong?: BN; - cumulativeFundingRateShort?: BN; - [key: string]: any; -}): AMM { - return { - ...amm, - last24HAvgFundingRate: - amm.last24HAvgFundingRate ?? amm.last24hAvgFundingRate ?? ZERO, - lastMarkPriceTwap5Min: - amm.lastMarkPriceTwap5Min ?? amm.lastMarkPriceTwap5min ?? ZERO, - volume24H: amm.volume24H ?? amm.volume24h ?? ZERO, - // TODO: map to long/short - cumulativeFundingRate: ZERO, - } as unknown as AMM; -} - -/** - * Parses an Anchor-generated PerpMarket account to the SDK's PerpMarketAccount type. - * Handles field name mappings and provides defaults for missing fields. - */ -export function parsePerpMarketAccount(account: { - amm?: any; - pnlPool?: any; - [key: string]: any; -}): PerpMarketAccount { - return { - ...account, - amm: account.amm ? parseAMM(account.amm) : account.amm, - pnlPool: convertPoolBalance(account.pnlPool), - } as PerpMarketAccount; -} - -/** - * Converts an Anchor BN representation to an actual BN instance. - * Handles both BN instances and serialized BN objects like { 0: number[] }. - */ -function convertToBN(value: any): BN { - if (BN.isBN(value)) { - return value; - } - if ( - value && - typeof value === 'object' && - '0' in value && - Array.isArray(value[0]) - ) { - // Anchor serializes BN as { 0: number[] } - convert from little-endian bytes - return new BN(value[0], 'le'); - } - if (value != null) { - return new BN(value); - } - return ZERO; -} - -/** - * Converts a PoolBalance object's BN fields. - */ -function convertPoolBalance(poolBalance: any): PoolBalance | undefined { - if (!poolBalance) return poolBalance; - return { - ...poolBalance, - scaledBalance: convertToBN(poolBalance.scaledBalance), - }; -} - -/** - * Converts HistoricalOracleData object's BN fields and handles field name mappings. - */ -function convertHistoricalOracleData( - historicalOracleData: any -): HistoricalOracleData | undefined { - if (!historicalOracleData) return historicalOracleData; - return { - ...historicalOracleData, - lastOraclePrice: convertToBN(historicalOracleData.lastOraclePrice), - lastOracleDelay: convertToBN(historicalOracleData.lastOracleDelay), - lastOracleConf: convertToBN(historicalOracleData.lastOracleConf), - lastOraclePriceTwap: convertToBN(historicalOracleData.lastOraclePriceTwap), - lastOraclePriceTwap5Min: convertToBN( - historicalOracleData.lastOraclePriceTwap5Min ?? - historicalOracleData.lastOraclePriceTwap5min - ), - lastOraclePriceTwapTs: convertToBN( - historicalOracleData.lastOraclePriceTwapTs - ), - }; -} - -/** - * Converts HistoricalIndexData object's BN fields and handles field name mappings. - */ -function convertHistoricalIndexData( - historicalIndexData: any -): HistoricalIndexData | undefined { - if (!historicalIndexData) return historicalIndexData; - return { - ...historicalIndexData, - lastIndexBidPrice: convertToBN(historicalIndexData.lastIndexBidPrice), - lastIndexAskPrice: convertToBN(historicalIndexData.lastIndexAskPrice), - lastIndexPriceTwap: convertToBN(historicalIndexData.lastIndexPriceTwap), - lastIndexPriceTwap5Min: convertToBN( - historicalIndexData.lastIndexPriceTwap5Min ?? - historicalIndexData.lastIndexPriceTwap5min - ), - lastIndexPriceTwapTs: convertToBN(historicalIndexData.lastIndexPriceTwapTs), - }; -} - -/** - * Parses an Anchor-generated SpotMarket account to the SDK's SpotMarketAccount type. - * Handles field name mappings and provides defaults for missing fields. - */ -export function parseSpotMarketAccount(account: { - insuranceFund?: any; - revenuePool?: any; - spotFeePool?: any; - historicalOracleData?: any; - historicalIndexData?: any; - [key: string]: any; -}): SpotMarketAccount { - const insuranceFund = account.insuranceFund - ? { - ...account.insuranceFund, - totalShares: convertToBN(account.insuranceFund.totalShares), - userShares: convertToBN(account.insuranceFund.userShares), - sharesBase: convertToBN(account.insuranceFund.sharesBase), - unstakingPeriod: convertToBN(account.insuranceFund.unstakingPeriod), - lastRevenueSettleTs: convertToBN( - account.insuranceFund.lastRevenueSettleTs - ), - revenueSettlePeriod: convertToBN( - account.insuranceFund.revenueSettlePeriod - ), - } - : account.insuranceFund; - - return { - ...account, - insuranceFund, - revenuePool: convertPoolBalance(account.revenuePool), - spotFeePool: convertPoolBalance(account.spotFeePool), - historicalOracleData: convertHistoricalOracleData( - account.historicalOracleData - ), - historicalIndexData: convertHistoricalIndexData( - account.historicalIndexData - ), - cumulativeDepositInterest: convertToBN(account.cumulativeDepositInterest), - cumulativeBorrowInterest: convertToBN(account.cumulativeBorrowInterest), - totalSocialLoss: convertToBN(account.totalSocialLoss), - totalQuoteSocialLoss: convertToBN(account.totalQuoteSocialLoss), - depositBalance: convertToBN(account.depositBalance), - borrowBalance: convertToBN(account.borrowBalance), - maxTokenDeposits: convertToBN(account.maxTokenDeposits), - lastInterestTs: convertToBN(account.lastInterestTs), - lastTwapTs: convertToBN(account.lastTwapTs), - scaleInitialAssetWeightStart: convertToBN( - account.scaleInitialAssetWeightStart - ), - withdrawGuardThreshold: convertToBN(account.withdrawGuardThreshold), - depositTokenTwap: convertToBN(account.depositTokenTwap), - borrowTokenTwap: convertToBN(account.borrowTokenTwap), - utilizationTwap: convertToBN(account.utilizationTwap), - nextDepositRecordId: convertToBN(account.nextDepositRecordId), - orderStepSize: convertToBN(account.orderStepSize), - orderTickSize: convertToBN(account.orderTickSize), - minOrderSize: convertToBN(account.minOrderSize), - maxPositionSize: convertToBN(account.maxPositionSize), - nextFillRecordId: convertToBN(account.nextFillRecordId), - totalSpotFee: convertToBN(account.totalSpotFee), - totalSwapFee: convertToBN(account.totalSwapFee), - flashLoanAmount: convertToBN(account.flashLoanAmount), - flashLoanInitialTokenAmount: convertToBN( - account.flashLoanInitialTokenAmount - ), - } as SpotMarketAccount; -} - -/** - * Map of account names to their parser functions. - * Parsers convert Anchor's serialized BN format to proper BN instances. - */ -export const ACCOUNT_PARSERS: Record any> = { - spotMarket: parseSpotMarketAccount, - perpMarket: parsePerpMarketAccount, -}; - -/** - * Applies the appropriate parser to an account based on its name. - * Returns the account unchanged if no parser is registered for the name. - */ -export function parseAccount(accountName: string, account: any): T { - const parser = ACCOUNT_PARSERS[accountName]; - return (parser ? parser(account) : account) as T; -} - export type FuelOverflowAccount = { authority: PublicKey; fuelInsurance: BN; @@ -1705,7 +1478,7 @@ export type OrderFillerRewardStructure = { export type OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: BN; - oracleTwap5MinPercentDivergence: BN; + oracleTwap5minPercentDivergence: BN; }; validity: { slotsBeforeStaleForAmm: BN; diff --git a/sdk/src/user.ts b/sdk/src/user.ts index 6e3ee18962..571cdedde8 100644 --- a/sdk/src/user.ts +++ b/sdk/src/user.ts @@ -780,12 +780,12 @@ export class User { if (strict && positionUnrealizedPnl.gt(ZERO)) { quotePrice = BN.min( quoteOraclePriceData.price, - quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5Min + quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5min ); } else if (strict && positionUnrealizedPnl.lt(ZERO)) { quotePrice = BN.max( quoteOraclePriceData.price, - quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5Min + quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5min ); } else { quotePrice = quoteOraclePriceData.price; @@ -1457,7 +1457,7 @@ export class User { if (strict) { quotePrice = BN.max( quoteOraclePriceData.price, - quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5Min + quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5min ); } else { quotePrice = quoteOraclePriceData.price; @@ -4482,7 +4482,7 @@ export class User { const quotePrice = strict ? BN.max( quoteOraclePriceData.price, - quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5Min + quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5min ) : quoteOraclePriceData.price; let perpMarginRequirement = worstCaseLiabilityValue @@ -4508,12 +4508,12 @@ export class User { if (strict && positionUnrealizedPnl.gt(ZERO)) { pnlQuotePrice = BN.min( quoteOraclePriceData.price, - quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5Min + quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5min ); } else if (strict && positionUnrealizedPnl.lt(ZERO)) { pnlQuotePrice = BN.max( quoteOraclePriceData.price, - quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5Min + quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5min ); } else { pnlQuotePrice = quoteOraclePriceData.price; @@ -4553,7 +4553,7 @@ export class User { const strictQuote = new StrictOraclePrice( quoteOraclePriceData.price, strict - ? quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5Min + ? quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5min : undefined ); const quoteTokenAmount = getTokenAmount( diff --git a/sdk/src/userMap/userMap.ts b/sdk/src/userMap/userMap.ts index 78227e7a70..3c2fd101cb 100644 --- a/sdk/src/userMap/userMap.ts +++ b/sdk/src/userMap/userMap.ts @@ -316,21 +316,21 @@ export class UserMap implements UserMapInterface { } public async updateWithEventRecord(record: WrappedEvent) { - if (record.eventType === 'DepositRecord') { + if (record.eventType === 'depositRecord') { const depositRecord = record as DepositRecord; await this.mustGet(depositRecord.user.toString()); - } else if (record.eventType === 'FundingPaymentRecord') { + } else if (record.eventType === 'fundingPaymentRecord') { const fundingPaymentRecord = record as FundingPaymentRecord; await this.mustGet(fundingPaymentRecord.user.toString()); - } else if (record.eventType === 'LiquidationRecord') { + } else if (record.eventType === 'liquidationRecord') { const liqRecord = record as LiquidationRecord; await this.mustGet(liqRecord.user.toString()); await this.mustGet(liqRecord.liquidator.toString()); - } else if (record.eventType === 'OrderRecord') { + } else if (record.eventType === 'orderRecord') { const orderRecord = record as OrderRecord; await this.updateWithOrderRecord(orderRecord); - } else if (record.eventType === 'OrderActionRecord') { + } else if (record.eventType === 'orderActionRecord') { const actionRecord = record as OrderActionRecord; if (actionRecord.taker) { @@ -339,10 +339,10 @@ export class UserMap implements UserMapInterface { if (actionRecord.maker) { await this.mustGet(actionRecord.maker.toString()); } - } else if (record.eventType === 'SettlePnlRecord') { + } else if (record.eventType === 'settlePnlRecord') { const settlePnlRecord = record as SettlePnlRecord; await this.mustGet(settlePnlRecord.user.toString()); - } else if (record.eventType === 'NewUserRecord') { + } else if (record.eventType === 'newUserRecord') { const newUserRecord = record as NewUserRecord; await this.mustGet(newUserRecord.user.toString()); } else if (record.eventType === 'LPRecord') { diff --git a/sdk/src/userMap/userStatsMap.ts b/sdk/src/userMap/userStatsMap.ts index 8e9abee863..1f9989b14a 100644 --- a/sdk/src/userMap/userStatsMap.ts +++ b/sdk/src/userMap/userStatsMap.ts @@ -119,13 +119,13 @@ export class UserStatsMap { record: WrappedEvent, userMap?: UserMap ) { - if (record.eventType === 'DepositRecord') { + if (record.eventType === 'depositRecord') { const depositRecord = record as DepositRecord; await this.mustGet(depositRecord.userAuthority.toString()); - } else if (record.eventType === 'FundingPaymentRecord') { + } else if (record.eventType === 'fundingPaymentRecord') { const fundingPaymentRecord = record as FundingPaymentRecord; await this.mustGet(fundingPaymentRecord.userAuthority.toString()); - } else if (record.eventType === 'LiquidationRecord') { + } else if (record.eventType === 'liquidationRecord') { if (!userMap) { return; } @@ -139,13 +139,13 @@ export class UserStatsMap { liqRecord.liquidator.toString() ); await this.mustGet(liquidatorUser.getUserAccount().authority.toString()); - } else if (record.eventType === 'OrderRecord') { + } else if (record.eventType === 'orderRecord') { if (!userMap) { return; } const orderRecord = record as OrderRecord; await userMap.updateWithOrderRecord(orderRecord); - } else if (record.eventType === 'OrderActionRecord') { + } else if (record.eventType === 'orderActionRecord') { if (!userMap) { return; } @@ -159,14 +159,14 @@ export class UserStatsMap { const maker = await userMap.mustGet(actionRecord.maker.toString()); await this.mustGet(maker.getUserAccount().authority.toString()); } - } else if (record.eventType === 'SettlePnlRecord') { + } else if (record.eventType === 'settlePnlRecord') { if (!userMap) { return; } const settlePnlRecord = record as SettlePnlRecord; const user = await userMap.mustGet(settlePnlRecord.user.toString()); await this.mustGet(user.getUserAccount().authority.toString()); - } else if (record.eventType === 'NewUserRecord') { + } else if (record.eventType === 'newUserRecord') { const newUserRecord = record as NewUserRecord; await this.mustGet(newUserRecord.userAuthority.toString()); } else if (record.eventType === 'LPRecord') { @@ -176,7 +176,7 @@ export class UserStatsMap { const lpRecord = record as LPRecord; const user = await userMap.mustGet(lpRecord.user.toString()); await this.mustGet(user.getUserAccount().authority.toString()); - } else if (record.eventType === 'InsuranceFundStakeRecord') { + } else if (record.eventType === 'insuranceFundStakeRecord') { const ifStakeRecord = record as InsuranceFundStakeRecord; await this.mustGet(ifStakeRecord.userAuthority.toString()); } @@ -317,7 +317,7 @@ export class UserStatsMap { if (!this.has(publicKeyString)) { const buffer = Buffer.from(accountInfo.data); const decodedUserStats = this.decode( - 'UserStats', + 'userStats', buffer ) as UserStatsAccount; programAccountBufferMap.add( diff --git a/sdk/src/userStats.ts b/sdk/src/userStats.ts index a045f533c0..6abcb47b7c 100644 --- a/sdk/src/userStats.ts +++ b/sdk/src/userStats.ts @@ -171,9 +171,9 @@ export class UserStats { public static getOldestActionTs(account: UserStatsAccount): number { return Math.min( - account.lastFillerVolume30DTs.toNumber(), - account.lastMakerVolume30DTs.toNumber(), - account.lastTakerVolume30DTs.toNumber() + account.lastFillerVolume30dTs.toNumber(), + account.lastMakerVolume30dTs.toNumber(), + account.lastTakerVolume30dTs.toNumber() ); } } diff --git a/sdk/tests/amm/test.ts b/sdk/tests/amm/test.ts index ab849c57d6..c7671b35bb 100644 --- a/sdk/tests/amm/test.ts +++ b/sdk/tests/amm/test.ts @@ -466,7 +466,7 @@ describe('AMM Tests', () => { lastFundingRate: '-16416', lastFundingRateTs: '1705845755', lastMarkPriceTwap: '1105972', - lastMarkPriceTwap5Min: '1101202', + lastMarkPriceTwap5min: '1101202', lastMarkPriceTwapTs: '1705846920', lastTradeTs: '1705846920', oracle: '3Qub3HaAJaa2xNY7SUqPKd3vVwTqDfDDkEUMPjXD2c1q', @@ -476,7 +476,7 @@ describe('AMM Tests', () => { lastOracleDelay: '2', lastOracleConf: '0', lastOraclePriceTwap: '1106680', - lastOraclePriceTwap5Min: '1102634', + lastOraclePriceTwap5min: '1102634', lastOraclePriceTwapTs: '1705846920', }, lastOracleReservePriceSpreadPct: '-262785', @@ -486,7 +486,7 @@ describe('AMM Tests', () => { pegMultiplier: '4', cumulativeFundingRateLong: '186069301', cumulativeFundingRateShort: '186007157', - last24HAvgFundingRate: '35147', + last24hAvgFundingRate: '35147', lastFundingRateShort: '-16416', lastFundingRateLong: '-16416', totalLiquidationFee: '4889264000', @@ -538,7 +538,7 @@ describe('AMM Tests', () => { longIntensityVolume: '162204', shortIntensityCount: '995', shortIntensityVolume: '2797331131', - volume24H: '91370028405', + volume24h: '91370028405', minOrderSize: '1000000000', maxPositionSize: '0', bidBaseAssetReserve: '234770820775670', @@ -613,7 +613,7 @@ describe('AMM Tests', () => { new BN(suiExample.amm.oracleStd), new BN(suiExample.amm.longIntensityVolume), new BN(suiExample.amm.shortIntensityVolume), - new BN(suiExample.amm.volume24H), + new BN(suiExample.amm.volume24h), 0, true ); @@ -654,7 +654,7 @@ describe('AMM Tests', () => { new BN(suiExample.amm.oracleStd), new BN(suiExample.amm.longIntensityVolume), new BN(suiExample.amm.shortIntensityVolume), - new BN(suiExample.amm.volume24H), + new BN(suiExample.amm.volume24h), 0, true ); @@ -683,7 +683,7 @@ describe('AMM Tests', () => { new BN(suiExample.amm.oracleStd), new BN(suiExample.amm.longIntensityVolume), new BN(suiExample.amm.shortIntensityVolume), - new BN(suiExample.amm.volume24H), + new BN(suiExample.amm.volume24h), 0, true ); @@ -742,7 +742,7 @@ describe('AMM Tests', () => { mockAmm.baseSpread = 2500; mockAmm.maxSpread = 25000; - mockAmm.last24HAvgFundingRate = new BN(7590328523); + mockAmm.last24hAvgFundingRate = new BN(7590328523); mockAmm.lastMarkPriceTwap = new BN( (oraclePriceData.price.toNumber() / 1e6 - 0.01) * 1e6 @@ -751,10 +751,10 @@ describe('AMM Tests', () => { (oraclePriceData.price.toNumber() / 1e6 + 0.015) * 1e6 ); - mockAmm.historicalOracleData.lastOraclePriceTwap5Min = new BN( + mockAmm.historicalOracleData.lastOraclePriceTwap5min = new BN( (oraclePriceData.price.toNumber() / 1e6 + 0.005) * 1e6 ); - mockAmm.lastMarkPriceTwap5Min = new BN( + mockAmm.lastMarkPriceTwap5min = new BN( (oraclePriceData.price.toNumber() / 1e6 - 0.005) * 1e6 ); @@ -831,10 +831,10 @@ describe('AMM Tests', () => { ); const referencePriceOffset = calculateReferencePriceOffset( reservePrice, - mockAmm.last24HAvgFundingRate, + mockAmm.last24hAvgFundingRate, liquidityFractionSigned, - mockAmm.historicalOracleData.lastOraclePriceTwap5Min, - mockAmm.lastMarkPriceTwap5Min, + mockAmm.historicalOracleData.lastOraclePriceTwap5min, + mockAmm.lastMarkPriceTwap5min, mockAmm.historicalOracleData.lastOraclePriceTwap, mockAmm.lastMarkPriceTwap, maxOffset @@ -954,7 +954,7 @@ describe('AMM Tests', () => { mockAmm.baseSpread = 2500; mockAmm.maxSpread = 25000; - mockAmm.last24HAvgFundingRate = new BN(-7590328523); + mockAmm.last24hAvgFundingRate = new BN(-7590328523); mockAmm.lastMarkPriceTwap = new BN( (oraclePriceData.price.toNumber() / 1e6 + 0.01) * 1e6 @@ -963,10 +963,10 @@ describe('AMM Tests', () => { (oraclePriceData.price.toNumber() / 1e6 - 0.015) * 1e6 ); - mockAmm.historicalOracleData.lastOraclePriceTwap5Min = new BN( + mockAmm.historicalOracleData.lastOraclePriceTwap5min = new BN( (oraclePriceData.price.toNumber() / 1e6 + 0.005) * 1e6 ); - mockAmm.lastMarkPriceTwap5Min = new BN( + mockAmm.lastMarkPriceTwap5min = new BN( (oraclePriceData.price.toNumber() / 1e6 - 0.005) * 1e6 ); @@ -1044,10 +1044,10 @@ describe('AMM Tests', () => { ); const referencePriceOffset = calculateReferencePriceOffset( reservePrice, - mockAmm.last24HAvgFundingRate, + mockAmm.last24hAvgFundingRate, liquidityFractionSigned, - mockAmm.historicalOracleData.lastOraclePriceTwap5Min, - mockAmm.lastMarkPriceTwap5Min, + mockAmm.historicalOracleData.lastOraclePriceTwap5min, + mockAmm.lastMarkPriceTwap5min, mockAmm.historicalOracleData.lastOraclePriceTwap, mockAmm.lastMarkPriceTwap, maxOffset @@ -1194,7 +1194,7 @@ describe('AMM Tests', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION.divn(10), - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.divn(10), + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION.divn(10), }, validity: { slotsBeforeStaleForAmm: new BN(10), diff --git a/sdk/tests/decode/test.ts b/sdk/tests/decode/test.ts index ebc9641bfd..bc2b23cd2e 100644 --- a/sdk/tests/decode/test.ts +++ b/sdk/tests/decode/test.ts @@ -51,7 +51,7 @@ function testUserAccountDecode(program: Program, buffer: Buffer, i: number) { console.log(`Testing user account decode ${i}`); const anchorStartTimestamp = Date.now(); - const anchorUserAccount = program.coder.accounts.decode('User', buffer); + const anchorUserAccount = program.coder.accounts.decode('user', buffer); const anchorEndTimestamp = Date.now(); const anchorTime = anchorEndTimestamp - anchorStartTimestamp; diff --git a/sdk/tests/dlob/helpers.ts b/sdk/tests/dlob/helpers.ts index f5dd69f33d..6a560fbbd9 100644 --- a/sdk/tests/dlob/helpers.ts +++ b/sdk/tests/dlob/helpers.ts @@ -58,18 +58,17 @@ export const mockAMM: AMM = { pegMultiplier: new BN(1), maxSlippageRatio: 1_000_000, - cumulativeFundingRate: new BN(0), lastFundingRate: new BN(0), lastFundingRateTs: new BN(0), lastMarkPriceTwap: new BN(0), - lastMarkPriceTwap5Min: new BN(0), + lastMarkPriceTwap5min: new BN(0), lastMarkPriceTwapTs: new BN(0), historicalOracleData: { lastOraclePrice: new BN(0), lastOracleConf: new BN(0), lastOracleDelay: new BN(0), lastOraclePriceTwap: new BN(0), - lastOraclePriceTwap5Min: new BN(0), + lastOraclePriceTwap5min: new BN(0), lastOraclePriceTwapTs: new BN(0), }, lastOracleReservePriceSpreadPct: new BN(0), @@ -86,7 +85,7 @@ export const mockAMM: AMM = { baseAssetAmountWithUnsettledLp: new BN(0), orderStepSize: new BN(0), orderTickSize: new BN(1), - last24HAvgFundingRate: new BN(0), + last24hAvgFundingRate: new BN(0), lastFundingRateShort: new BN(0), lastFundingRateLong: new BN(0), concentrationCoef: new BN(0), @@ -133,7 +132,7 @@ export const mockAMM: AMM = { oracleStd: new BN(0), longIntensityVolume: new BN(0), shortIntensityVolume: new BN(0), - volume24H: new BN(0), + volume24h: new BN(0), minOrderSize: new BN(0), bidBaseAssetReserve: new BN(0), @@ -386,14 +385,14 @@ export const mockSpotMarkets: Array = [ lastOracleConf: new BN(0), lastOracleDelay: new BN(0), lastOraclePriceTwap: PRICE_PRECISION, - lastOraclePriceTwap5Min: PRICE_PRECISION, + lastOraclePriceTwap5min: PRICE_PRECISION, lastOraclePriceTwapTs: new BN(0), }, historicalIndexData: { lastIndexBidPrice: PRICE_PRECISION, lastIndexAskPrice: PRICE_PRECISION, lastIndexPriceTwap: PRICE_PRECISION, - lastIndexPriceTwap5Min: PRICE_PRECISION, + lastIndexPriceTwap5min: PRICE_PRECISION, lastIndexPriceTwapTs: new BN(0), }, pausedOperations: 0, @@ -478,14 +477,14 @@ export const mockSpotMarkets: Array = [ lastOracleConf: new BN(0), lastOracleDelay: new BN(0), lastOraclePriceTwap: new BN(0), - lastOraclePriceTwap5Min: new BN(0), + lastOraclePriceTwap5min: new BN(0), lastOraclePriceTwapTs: new BN(0), }, historicalIndexData: { lastIndexBidPrice: new BN(0), lastIndexAskPrice: new BN(0), lastIndexPriceTwap: new BN(0), - lastIndexPriceTwap5Min: new BN(0), + lastIndexPriceTwap5min: new BN(0), lastIndexPriceTwapTs: new BN(0), }, pausedOperations: 0, @@ -570,14 +569,14 @@ export const mockSpotMarkets: Array = [ lastOracleConf: new BN(0), lastOracleDelay: new BN(0), lastOraclePriceTwap: new BN(0), - lastOraclePriceTwap5Min: new BN(0), + lastOraclePriceTwap5min: new BN(0), lastOraclePriceTwapTs: new BN(0), }, historicalIndexData: { lastIndexBidPrice: new BN(0), lastIndexAskPrice: new BN(0), lastIndexPriceTwap: new BN(0), - lastIndexPriceTwap5Min: new BN(0), + lastIndexPriceTwap5min: new BN(0), lastIndexPriceTwapTs: new BN(0), }, pausedOperations: 0, @@ -613,7 +612,7 @@ export const mockStateAccount: StateAccount = { oracleGuardRails: { priceDivergence: { markOraclePercentDivergence: new BN(0), - oracleTwap5MinPercentDivergence: new BN(0), + oracleTwap5minPercentDivergence: new BN(0), }, validity: { slotsBeforeStaleForAmm: new BN(0), diff --git a/sdk/tests/dlob/test.ts b/sdk/tests/dlob/test.ts index eea4a13b51..612b3d7f7b 100644 --- a/sdk/tests/dlob/test.ts +++ b/sdk/tests/dlob/test.ts @@ -6198,8 +6198,8 @@ describe('Uncross L2', () => { ]; const oraclePrice = new BN(100).mul(QUOTE_PRECISION); - const oraclePrice5Min = new BN(100).mul(QUOTE_PRECISION); - const markPrice5Min = new BN(100).mul(QUOTE_PRECISION); + const oraclePrice5min = new BN(100).mul(QUOTE_PRECISION); + const markPrice5min = new BN(100).mul(QUOTE_PRECISION); const groupingSize = QUOTE_PRECISION.divn(10); @@ -6207,8 +6207,8 @@ describe('Uncross L2', () => { bids, asks, oraclePrice, - oraclePrice5Min, - markPrice5Min, + oraclePrice5min, + markPrice5min, groupingSize, new Set(), new Set() @@ -6296,8 +6296,8 @@ describe('Uncross L2', () => { ]; const oraclePrice = new BN(100).mul(QUOTE_PRECISION); - const oraclePrice5Min = new BN(100).mul(QUOTE_PRECISION); - const markPrice5Min = new BN(100).mul(QUOTE_PRECISION); + const oraclePrice5min = new BN(100).mul(QUOTE_PRECISION); + const markPrice5min = new BN(100).mul(QUOTE_PRECISION); const groupingSize = QUOTE_PRECISION.divn(10); @@ -6305,8 +6305,8 @@ describe('Uncross L2', () => { bids, asks, oraclePrice, - oraclePrice5Min, - markPrice5Min, + oraclePrice5min, + markPrice5min, groupingSize, new Set(), new Set() @@ -6389,8 +6389,8 @@ describe('Uncross L2', () => { ]; const oraclePrice = new BN(100).mul(QUOTE_PRECISION); - const oraclePrice5Min = new BN(100).mul(QUOTE_PRECISION); - const markPrice5Min = new BN(100).mul(QUOTE_PRECISION); + const oraclePrice5min = new BN(100).mul(QUOTE_PRECISION); + const markPrice5min = new BN(100).mul(QUOTE_PRECISION); const groupingSize = QUOTE_PRECISION.divn(10); @@ -6398,8 +6398,8 @@ describe('Uncross L2', () => { bids, asks, oraclePrice, - oraclePrice5Min, - markPrice5Min, + oraclePrice5min, + markPrice5min, groupingSize, new Set(), new Set() @@ -6474,8 +6474,8 @@ describe('Uncross L2', () => { ]; const oraclePrice = new BN('29250100'); - const oraclePrice5Min = new BN('29696597'); - const markPrice5Min = new BN('31747865'); + const oraclePrice5min = new BN('29696597'); + const markPrice5min = new BN('31747865'); const groupingSize = QUOTE_PRECISION.divn(10); @@ -6483,14 +6483,14 @@ describe('Uncross L2', () => { bids, asks, oraclePrice, - oraclePrice5Min, - markPrice5Min, + oraclePrice5min, + markPrice5min, groupingSize, new Set(), new Set() ); - const referencePrice = oraclePrice.add(markPrice5Min.sub(oraclePrice5Min)); + const referencePrice = oraclePrice.add(markPrice5min.sub(oraclePrice5min)); expect(newBids[0].price.toString()).to.equal( referencePrice.sub(groupingSize).toString() @@ -6551,8 +6551,8 @@ describe('Uncross L2', () => { ]; const oraclePrice = new BN(100).mul(QUOTE_PRECISION); - const oraclePrice5Min = new BN(100).mul(QUOTE_PRECISION); - const markPrice5Min = new BN(100).mul(QUOTE_PRECISION); + const oraclePrice5min = new BN(100).mul(QUOTE_PRECISION); + const markPrice5min = new BN(100).mul(QUOTE_PRECISION); const groupingSize = QUOTE_PRECISION.divn(10); @@ -6563,8 +6563,8 @@ describe('Uncross L2', () => { bids, asks, oraclePrice, - oraclePrice5Min, - markPrice5Min, + oraclePrice5min, + markPrice5min, groupingSize, userBids, new Set() @@ -6662,8 +6662,8 @@ describe('Uncross L2', () => { ]; const oraclePrice = new BN(100).mul(QUOTE_PRECISION); - const oraclePrice5Min = new BN(100).mul(QUOTE_PRECISION); - const markPrice5Min = new BN(100).mul(QUOTE_PRECISION); + const oraclePrice5min = new BN(100).mul(QUOTE_PRECISION); + const markPrice5min = new BN(100).mul(QUOTE_PRECISION); const groupingSize = QUOTE_PRECISION.divn(10); @@ -6674,8 +6674,8 @@ describe('Uncross L2', () => { bids, asks, oraclePrice, - oraclePrice5Min, - markPrice5Min, + oraclePrice5min, + markPrice5min, groupingSize, new Set(), userAsks @@ -6831,8 +6831,8 @@ describe('Uncross L2', () => { expect(bidsAreSortedDesc(bids), 'Input bids are descending').to.be.true; const oraclePrice = new BN('103649895'); - const oraclePrice5Min = new BN('103285000'); - const markPrice5Min = new BN('103371000'); + const oraclePrice5min = new BN('103285000'); + const markPrice5min = new BN('103371000'); const groupingSize = new BN('100'); @@ -6842,8 +6842,8 @@ describe('Uncross L2', () => { bids, asks, oraclePrice, - oraclePrice5Min, - markPrice5Min, + oraclePrice5min, + markPrice5min, groupingSize, new Set(), userAsks @@ -6894,8 +6894,8 @@ describe('Uncross L2', () => { expect(bidsAreSortedDesc(bids), 'Input bids are descending').to.be.true; const oraclePrice = new BN('101711384'); - const oraclePrice5Min = new BN('101805000'); - const markPrice5Min = new BN('101867000'); + const oraclePrice5min = new BN('101805000'); + const markPrice5min = new BN('101867000'); const groupingSize = new BN('100'); @@ -6905,8 +6905,8 @@ describe('Uncross L2', () => { bids, asks, oraclePrice, - oraclePrice5Min, - markPrice5Min, + oraclePrice5min, + markPrice5min, groupingSize, new Set(), userAsks diff --git a/test-scripts/run-anchor-tests.sh b/test-scripts/run-anchor-tests.sh index dca4ddd545..88fa8cfbe5 100644 --- a/test-scripts/run-anchor-tests.sh +++ b/test-scripts/run-anchor-tests.sh @@ -23,10 +23,12 @@ test_files=( # updateK.ts # postOnlyAmmFulfillment.ts # TODO BROKEN ^^ - builderCodes.ts - decodeUser.ts # fuel.ts # fuelSweep.ts + # whitelist.ts + # TODO: ignored ^^ + builderCodes.ts + decodeUser.ts admin.ts assetTier.ts cancelAllOrders.ts @@ -91,7 +93,6 @@ test_files=( userAccount.ts userDelegate.ts userOrderId.ts - # whitelist.ts ) diff --git a/tests/admin.ts b/tests/admin.ts index ec69751584..1e5fcb3007 100644 --- a/tests/admin.ts +++ b/tests/admin.ts @@ -1,5 +1,4 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; import { assert, expect } from 'chai'; import { startAnchor } from 'solana-bankrun'; import { @@ -30,9 +29,10 @@ import { } from '../sdk/src/bankrun/bankrunConnection'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { createTransferCheckedInstruction } from '@solana/spl-token'; +import { DriftProgram } from '../sdk/src/config'; describe('admin', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; @@ -131,7 +131,8 @@ describe('admin', () => { await driftClient.fetchAccounts(); assert( driftClient.getPerpMarketAccount(0).amm.ammJitIntensity == 0, - `amm jit intensity does not match \n actual: ${driftClient.getPerpMarketAccount(0).amm.ammJitIntensity + `amm jit intensity does not match \n actual: ${ + driftClient.getPerpMarketAccount(0).amm.ammJitIntensity } \n expected: 0` ); @@ -139,7 +140,8 @@ describe('admin', () => { await driftClient.fetchAccounts(); assert( driftClient.getPerpMarketAccount(0).amm.ammJitIntensity == 100, - `amm jit intensity does not match \n actual: ${driftClient.getPerpMarketAccount(0).amm.ammJitIntensity + `amm jit intensity does not match \n actual: ${ + driftClient.getPerpMarketAccount(0).amm.ammJitIntensity } \n expected: 100` ); @@ -147,7 +149,8 @@ describe('admin', () => { await driftClient.fetchAccounts(); assert( driftClient.getPerpMarketAccount(0).amm.ammJitIntensity == 50, - `amm jit intensity does not match \n actual: ${driftClient.getPerpMarketAccount(0).amm.ammJitIntensity + `amm jit intensity does not match \n actual: ${ + driftClient.getPerpMarketAccount(0).amm.ammJitIntensity } \n expected: 50` ); }); @@ -186,7 +189,7 @@ describe('admin', () => { assert( JSON.stringify(newFeeStructure) === - JSON.stringify(state.perpFeeStructure), + JSON.stringify(state.perpFeeStructure), `fee structure does not match \n actual: ${JSON.stringify( state.perpFeeStructure )} \n expected: ${JSON.stringify(newFeeStructure)}` @@ -204,7 +207,7 @@ describe('admin', () => { assert( JSON.stringify(newFeeStructure) === - JSON.stringify(state.spotFeeStructure), + JSON.stringify(state.spotFeeStructure), `fee structure does not match \n actual: ${JSON.stringify( state.spotFeeStructure )} \n expected: ${JSON.stringify(newFeeStructure)}` @@ -215,7 +218,7 @@ describe('admin', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: new BN(1000000), - oracleTwap5MinPercentDivergence: new BN(1000000), + oracleTwap5minPercentDivergence: new BN(1000000), }, validity: { slotsBeforeStaleForAmm: new BN(1), @@ -232,7 +235,7 @@ describe('admin', () => { assert( JSON.stringify(oracleGuardRails) === - JSON.stringify(state.oracleGuardRails), + JSON.stringify(state.oracleGuardRails), `oracle guard rails does not match \n actual: ${JSON.stringify( state.oracleGuardRails )} \n expected: ${JSON.stringify(oracleGuardRails)}` @@ -278,7 +281,7 @@ describe('admin', () => { ); assert( JSON.stringify(market.amm.oracleSource) === - JSON.stringify(newOracleSource), + JSON.stringify(newOracleSource), `oracle source does not match \n actual: ${JSON.stringify( market.amm.oracleSource )} \n expected: ${JSON.stringify(newOracleSource)}` @@ -378,9 +381,11 @@ describe('admin', () => { const state = driftClient.getStateAccount(); assert( state.exchangeStatus === - (ExchangeStatus.DEPOSIT_PAUSED | ExchangeStatus.WITHDRAW_PAUSED), - `exchange status does not match \n actual: ${state.exchangeStatus - } \n expected: ${ExchangeStatus.DEPOSIT_PAUSED | ExchangeStatus.WITHDRAW_PAUSED + (ExchangeStatus.DEPOSIT_PAUSED | ExchangeStatus.WITHDRAW_PAUSED), + `exchange status does not match \n actual: ${ + state.exchangeStatus + } \n expected: ${ + ExchangeStatus.DEPOSIT_PAUSED | ExchangeStatus.WITHDRAW_PAUSED }` ); @@ -475,7 +480,7 @@ describe('admin', () => { const perpMarket = driftClient.getPerpMarketAccount(0); assert( perpMarket.amm.referencePriceOffsetDeadbandPct == - referenceOffsetDeadbandPct + referenceOffsetDeadbandPct ); }); diff --git a/tests/adminDeposit.ts b/tests/adminDeposit.ts index 0781a12365..6432b2e0e2 100644 --- a/tests/adminDeposit.ts +++ b/tests/adminDeposit.ts @@ -1,7 +1,7 @@ import * as anchor from '@coral-xyz/anchor'; import { expect } from 'chai'; -import { Program, Wallet } from '@coral-xyz/anchor'; +import { Wallet } from '@coral-xyz/anchor'; import { Keypair } from '@solana/web3.js'; @@ -22,10 +22,11 @@ import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; import dotenv from 'dotenv'; +import { DriftProgram } from '../sdk/src/config'; dotenv.config(); describe('admin deposit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/assetTier.ts b/tests/assetTier.ts index 73a285a851..c9fd2e8182 100644 --- a/tests/assetTier.ts +++ b/tests/assetTier.ts @@ -1,48 +1,45 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - -import { PublicKey, Keypair } from '@solana/web3.js'; +import { Keypair, PublicKey } from '@solana/web3.js'; import { - TestClient, + // SPOT_MARKET_WEIGHT_PRECISION, + // SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, + // OracleInfo, + AMM_RESERVE_PRECISION, + AssetTier, BN, - ZERO, + ContractTier, // SPOT_MARKET_RATE_PRECISION, // SpotBalanceType, isVariant, OracleSource, - // SPOT_MARKET_WEIGHT_PRECISION, - // SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, - // OracleInfo, - AMM_RESERVE_PRECISION, PEG_PRECISION, + QUOTE_PRECISION, QUOTE_SPOT_MARKET_INDEX, - AssetTier, SPOT_MARKET_WEIGHT_PRECISION, - QUOTE_PRECISION, + TestClient, + ZERO, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, + createUSDCAccountForUser, + createUserWithUSDCAndWSOLAccount, // setFeedPrice, initializeQuoteSpotMarket, - createUserWithUSDCAndWSOLAccount, initializeSolSpotMarket, - createUSDCAccountForUser, - // getFeedData, - // sleep, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { ContractTier } from '../sdk'; describe('asset tiers', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/builderCodes.ts b/tests/builderCodes.ts index 6e88aaf0ac..0873d1e2f2 100644 --- a/tests/builderCodes.ts +++ b/tests/builderCodes.ts @@ -1,5 +1,4 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; import { AccountInfo, @@ -10,36 +9,48 @@ import { } from '@solana/web3.js'; import { - TestClient, - OracleSource, - PYTH_LAZER_STORAGE_ACCOUNT_KEY, - PTYH_LAZER_PROGRAM_ID, assert, - getRevenueShareAccountPublicKey, - getRevenueShareEscrowAccountPublicKey, - RevenueShareAccount, - RevenueShareEscrowAccount, BASE_PRECISION, BN, - PRICE_PRECISION, + getLimitOrderParams, getMarketOrderParams, - PositionDirection, - PostOnlyParams, + getRevenueShareAccountPublicKey, + getRevenueShareEscrowAccountPublicKey, + getTokenAmount, + hasBuilder, + isVariant, MarketType, + OracleSource, OrderParams, - PEG_PRECISION, - ZERO, - isVariant, - hasBuilder, parseLogs, + PEG_PRECISION, + PositionDirection, + PostOnlyParams, + PRICE_PRECISION, + PTYH_LAZER_PROGRAM_ID, + PYTH_LAZER_STORAGE_ACCOUNT_KEY, + QUOTE_PRECISION, + RevenueShareAccount, + RevenueShareEscrowAccount, RevenueShareEscrowMap, - getTokenAmount, RevenueShareSettleRecord, - getLimitOrderParams, SignedMsgOrderParamsMessage, - QUOTE_PRECISION, + TestClient, + ZERO, } from '../sdk/src'; +import { createTransferInstruction } from '@solana/spl-token'; +import dotenv from 'dotenv'; +import { nanoid } from 'nanoid'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + isBuilderOrderCompleted, + isBuilderOrderReferral, +} from '../sdk/src/math/builder'; +import { PYTH_STORAGE_DATA } from './pythLazerData'; import { createUserWithUSDCAccount, initializeQuoteSpotMarket, @@ -48,18 +59,6 @@ import { mockUserUSDCAccount, printTxLogs, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; -import { PYTH_STORAGE_DATA } from './pythLazerData'; -import { nanoid } from 'nanoid'; -import { - isBuilderOrderCompleted, - isBuilderOrderReferral, -} from '../sdk/src/math/builder'; -import { createTransferInstruction } from '@solana/spl-token'; -import { Drift } from '../sdk/src/idl/drift'; dotenv.config(); @@ -103,7 +102,7 @@ function buildMsg( } describe('builder codes', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let usdcMint: Keypair; @@ -1509,7 +1508,7 @@ describe('builder codes', () => { // fillTxA // ); // const eventsA = parseLogs(builderClient.program, logsA); - // const fillsA = eventsA.filter((e) => e.name === 'OrderActionRecord'); + // const fillsA = eventsA.filter((e) => e.name === 'orderActionRecord'); // const fillAReferrerReward = fillsA[0]['data']['referrerReward'] as number; // assert(fillsA.length > 0); // // debug: fillsA[0]['data'] @@ -1538,7 +1537,7 @@ describe('builder codes', () => { // fillTxB // ); // const eventsB = parseLogs(builderClient.program, logsB); - // const fillsB = eventsB.filter((e) => e.name === 'OrderActionRecord'); + // const fillsB = eventsB.filter((e) => e.name === 'orderActionRecord'); // assert(fillsB.length > 0); // const fillBReferrerReward = fillsB[0]['data']['referrerReward'] as number; // // debug: fillsB[0]['data'] diff --git a/tests/cancelAllOrders.ts b/tests/cancelAllOrders.ts index 06c5a2b0f8..2f89dbedfd 100644 --- a/tests/cancelAllOrders.ts +++ b/tests/cancelAllOrders.ts @@ -1,30 +1,29 @@ import * as anchor from '@coral-xyz/anchor'; +import { assert } from 'chai'; import { BASE_PRECISION, BN, - getLimitOrderParams, OracleSource, - TestClient, PRICE_PRECISION, PositionDirection, + TestClient, + getLimitOrderParams, + isVariant, } from '../sdk/src'; -import { assert } from 'chai'; - -import { Program } from '@coral-xyz/anchor'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { - mockUSDCMint, - mockUserUSDCAccount, initializeQuoteSpotMarket, mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { isVariant } from '../sdk'; describe('cancel all orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/cappedSymFunding.ts b/tests/cappedSymFunding.ts index a0f822c6c0..eb023932ad 100644 --- a/tests/cappedSymFunding.ts +++ b/tests/cappedSymFunding.ts @@ -1,43 +1,42 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; +import { + AMM_RESERVE_PRECISION, + BASE_PRECISION, + BN, + calculateReservePrice, + ContractTier, + convertToNumber, + ExchangeStatus, + FUNDING_RATE_BUFFER_PRECISION, + isVariant, + OracleSource, + PEG_PRECISION, + PositionDirection, + PRICE_PRECISION, + QUOTE_PRECISION, + QUOTE_SPOT_MARKET_INDEX, + TestClient, + User, +} from '../sdk/src'; import { getFeedData, + initializeQuoteSpotMarket, initUserAccounts, mockOracle, - mockUserUSDCAccount, mockUSDCMint, + mockUserUSDCAccount, + printTxLogs, setFeedPrice, - initializeQuoteSpotMarket, sleep, - printTxLogs, } from './testHelpers'; -import { - TestClient, - BN, - QUOTE_SPOT_MARKET_INDEX, - PRICE_PRECISION, - FUNDING_RATE_BUFFER_PRECISION, - PEG_PRECISION, - User, - PositionDirection, - QUOTE_PRECISION, - AMM_RESERVE_PRECISION, - calculateReservePrice, - convertToNumber, - ExchangeStatus, - BASE_PRECISION, - OracleSource, - isVariant, - ContractTier, -} from '../sdk/src'; - -import { Program } from '@coral-xyz/anchor'; import { Keypair, PublicKey } from '@solana/web3.js'; import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; async function updateFundingRateHelper( driftClient: TestClient, @@ -76,10 +75,10 @@ async function updateFundingRateHelper( frontEndFundingCalc0, 'markTwap0:', ammAccountState0.lastMarkPriceTwap.toNumber() / - PRICE_PRECISION.toNumber(), + PRICE_PRECISION.toNumber(), 'oracleTwap0:', ammAccountState0.historicalOracleData.lastOraclePriceTwap.toNumber() / - PRICE_PRECISION.toNumber(), + PRICE_PRECISION.toNumber(), 'markTwap0:', ammAccountState0.lastMarkPriceTwap.toNumber(), 'oracleTwapPyth:', @@ -137,10 +136,10 @@ async function updateFundingRateHelper( assert(ammAccountState.lastFundingRate.abs().gte(lastFundingLong.abs())); console.log( convertToNumber(ammAccountState.lastFundingRate.abs()) / - FUNDING_RATE_BUFFER_PRECISION.toNumber(), + FUNDING_RATE_BUFFER_PRECISION.toNumber(), '>=', convertToNumber(lastFundingShort.abs()) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); assert(ammAccountState.lastFundingRate.abs().gte(lastFundingShort.abs())); @@ -153,9 +152,9 @@ async function updateFundingRateHelper( const priceSpread = ammAccountState.lastMarkPriceTwap.toNumber() / - PRICE_PRECISION.toNumber() - + PRICE_PRECISION.toNumber() - ammAccountState.historicalOracleData.lastOraclePriceTwap.toNumber() / - PRICE_PRECISION.toNumber(); + PRICE_PRECISION.toNumber(); const frontEndFundingCalc = priceSpread / ((24 * 3600) / Math.max(1, peroidicity.toNumber())); @@ -166,7 +165,7 @@ async function updateFundingRateHelper( ammAccountState.lastMarkPriceTwap.toNumber() / PRICE_PRECISION.toNumber(), 'oracleTwap:', ammAccountState.historicalOracleData.lastOraclePriceTwap.toNumber() / - PRICE_PRECISION.toNumber(), + PRICE_PRECISION.toNumber(), 'markTwap:', ammAccountState.lastMarkPriceTwap.toNumber(), 'oracleTwapPyth:', @@ -449,7 +448,7 @@ async function cappedSymFundingScenario( } describe('capped funding', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; @@ -829,15 +828,15 @@ describe('capped funding', () => { console.log( 'clamped funding:', convertToNumber(clampedFundingRate) / - FUNDING_RATE_BUFFER_PRECISION.toNumber(), + FUNDING_RATE_BUFFER_PRECISION.toNumber(), 'hourly pct:', convertToNumber(clampedFundingRatePct) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); console.log( 'short funding:', convertToNumber(fundingRateShort) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); assert(fundingRateShort.abs().eq(fundingRateLong.abs())); @@ -924,15 +923,15 @@ describe('capped funding', () => { console.log( 'clamped funding:', convertToNumber(clampedFundingRate) / - FUNDING_RATE_BUFFER_PRECISION.toNumber(), + FUNDING_RATE_BUFFER_PRECISION.toNumber(), 'hourly pct:', convertToNumber(clampedFundingRatePct) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); console.log( 'short funding:', convertToNumber(fundingRateShort) / - FUNDING_RATE_BUFFER_PRECISION.toNumber() + FUNDING_RATE_BUFFER_PRECISION.toNumber() ); assert(fundingRateShort.abs().gt(fundingRateLong.abs())); @@ -981,7 +980,7 @@ describe('capped funding', () => { ); assert( feeAlloced + Math.abs(fundingPnLForShortsNum) >= - fundingPnLForLongsNum + 1e-6 + fundingPnLForLongsNum + 1e-6 ); }); it('capped sym funding: ($2000 long, $1000 short, oracle > mark)', async () => { diff --git a/tests/curve.ts b/tests/curve.ts index 766271720f..9ef2402b5b 100644 --- a/tests/curve.ts +++ b/tests/curve.ts @@ -1,38 +1,39 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; + import { Keypair } from '@solana/web3.js'; import { - TestClient, - PRICE_PRECISION, - PEG_PRECISION, - QUOTE_PRECISION, BASE_PRECISION, BN, + calculateBudgetedPeg, calculateReservePrice, calculateTargetPriceTrade, - User, - PositionDirection, convertToNumber, - calculateBudgetedPeg, + PEG_PRECISION, + PositionDirection, + PRICE_PRECISION, + QUOTE_PRECISION, QUOTE_SPOT_MARKET_INDEX, + TestClient, + User, } from '../sdk/src'; import { liquidityBook } from './liquidityBook'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { assert } from '../sdk/src/assert/assert'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { - mockOracleNoProgram, initializeQuoteSpotMarket, + mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('AMM Curve', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; @@ -388,7 +389,9 @@ describe('AMM Curve', () => { // unbalanced but no net position console.log('netBaseAssetAmount:', amm.baseAssetAmountWithAmm.toString()); assert(!amm.baseAssetReserve.eq(amm.quoteAssetReserve)); - console.log(amm.baseAssetAmountWithAmm); + console.log(`************`); + console.log(amm.baseAssetAmountWithAmm.toString()); + console.log(`************`); assert(amm.baseAssetAmountWithAmm.eq(new BN(0))); // check if balanced diff --git a/tests/deleteInitializedSpotMarket.ts b/tests/deleteInitializedSpotMarket.ts index 06468e3098..4ad272486c 100644 --- a/tests/deleteInitializedSpotMarket.ts +++ b/tests/deleteInitializedSpotMarket.ts @@ -1,33 +1,30 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { - TestClient, BN, + getInsuranceFundVaultPublicKey, + getSpotMarketPublicKey, + getSpotMarketVaultPublicKey, OracleSource, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, + TestClient, } from '../sdk/src'; +import { PublicKey } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { - getInsuranceFundVaultPublicKey, - getSpotMarketPublicKey, - getSpotMarketVaultPublicKey, -} from '../sdk'; -import { PublicKey } from '@solana/web3.js'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('max deposit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/delistMarket.ts b/tests/delistMarket.ts index 6b4008b933..81db7653b0 100644 --- a/tests/delistMarket.ts +++ b/tests/delistMarket.ts @@ -1,41 +1,42 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - Wallet, BASE_PRECISION, BN, - OracleSource, - ZERO, - TestClient, + BulkAccountLoader, + calculateBaseAssetValueWithOracle, convertToNumber, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - QUOTE_PRECISION, - calculateBaseAssetValueWithOracle, + isVariant, OracleGuardRails, + OracleSource, + PERCENTAGE_PRECISION, + PositionDirection, + PRICE_PRECISION, + QUOTE_PRECISION, + TestClient, + Wallet, + ZERO, } from '../sdk/src'; +import { Keypair } from '@solana/web3.js'; +import { DriftProgram } from '../sdk/src/config'; import { + createUserWithUSDCAndWSOLAccount, + getFeedData, + getOraclePriceData, + initializeQuoteSpotMarket, + initializeSolSpotMarket, mockOracle, mockUSDCMint, mockUserUSDCAccount, - setFeedPrice, - initializeQuoteSpotMarket, - createUserWithUSDCAndWSOLAccount, - initializeSolSpotMarket, printTxLogs, - getFeedData, - getOraclePriceData, + setFeedPrice, sleep, } from './testHelpers'; -import { BulkAccountLoader, isVariant, PERCENTAGE_PRECISION } from '../sdk'; -import { Keypair } from '@solana/web3.js'; async function depositToFeePoolFromIF( amount: number, @@ -83,7 +84,7 @@ describe('delist market', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { @@ -328,7 +329,7 @@ describe('delist market', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: new BN(10).mul(PERCENTAGE_PRECISION), - oracleTwap5MinPercentDivergence: new BN(10).mul(PERCENTAGE_PRECISION), + oracleTwap5minPercentDivergence: new BN(10).mul(PERCENTAGE_PRECISION), }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -698,7 +699,7 @@ describe('delist market', () => { ); await printTxLogs(connection, txSig); - // const settleRecord = eventSubscriber.getEventsArray('SettlePnlRecord')[0]; + // const settleRecord = eventSubscriber.getEventsArray('settlePnlRecord')[0]; // console.log(settleRecord); await driftClientLoser.fetchAccounts(); diff --git a/tests/delistMarketLiq.ts b/tests/delistMarketLiq.ts index 7dad779673..26803bbd2a 100644 --- a/tests/delistMarketLiq.ts +++ b/tests/delistMarketLiq.ts @@ -1,49 +1,48 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - Wallet, + AMM_RESERVE_PRECISION, BASE_PRECISION, BN, - OracleSource, - ZERO, - TestClient, convertToNumber, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - QUOTE_PRECISION, - User, - AMM_RESERVE_PRECISION, isVariant, + LIQUIDATION_PCT_PRECISION, MARGIN_PRECISION, + OracleSource, + PositionDirection, + PRICE_PRECISION, + QUOTE_PRECISION, SPOT_MARKET_BALANCE_PRECISION, - LIQUIDATION_PCT_PRECISION, + TestClient, + User, + Wallet, + ZERO, } from '../sdk/src'; +import { Keypair } from '@solana/web3.js'; import { + BulkAccountLoader, + calculateReservePrice, + ContractTier, + UserStatus, +} from '../sdk/src'; +import { DriftProgram } from '../sdk/src/config'; +import { + createUserWithUSDCAndWSOLAccount, + getFeedData, + initializeQuoteSpotMarket, + initializeSolSpotMarket, mockOracle, mockUSDCMint, mockUserUSDCAccount, - setFeedPrice, - initializeQuoteSpotMarket, - createUserWithUSDCAndWSOLAccount, - initializeSolSpotMarket, printTxLogs, - getFeedData, + setFeedPrice, sleep, } from './testHelpers'; -import { Keypair } from '@solana/web3.js'; -import { - BulkAccountLoader, - calculateReservePrice, - ContractTier, - UserStatus, -} from '../sdk'; async function depositToFeePoolFromIF( amount: number, @@ -68,7 +67,7 @@ describe('delist market, liquidation of expired position', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { @@ -601,7 +600,7 @@ describe('delist market, liquidation of expired position', () => { // await printTxLogs(connection, txSigLiq); // const liquidationRecord = - // eventSubscriber.getEventsArray('LiquidationRecord')[0]; + // eventSubscriber.getEventsArray('liquidationRecord')[0]; // console.log(liquidationRecord); // assert(liquidationRecord.liquidationId === 1); // assert(isVariant(liquidationRecord.liquidationType, 'liquidatePerp')); @@ -743,7 +742,7 @@ describe('delist market, liquidation of expired position', () => { console.log('Cannot settle pnl under current market status'); } - // const settleRecord = eventSubscriber.getEventsArray('SettlePnlRecord')[0]; + // const settleRecord = eventSubscriber.getEventsArray('settlePnlRecord')[0]; // console.log(settleRecord); await driftClientLoser.fetchAccounts(); diff --git a/tests/depositIntoSpotMarketVault.ts b/tests/depositIntoSpotMarketVault.ts index 58638eee0f..a379c43316 100644 --- a/tests/depositIntoSpotMarketVault.ts +++ b/tests/depositIntoSpotMarketVault.ts @@ -1,20 +1,23 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, + OracleInfo, OracleSource, + SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, - OracleInfo, + TestClient, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { SPOT_MARKET_BALANCE_PRECISION } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAccount, mockOracleNoProgram, @@ -22,13 +25,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { SPOT_MARKET_BALANCE_PRECISION } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/driftClient.ts b/tests/driftClient.ts index 73f5fa45ac..184f59fa08 100644 --- a/tests/driftClient.ts +++ b/tests/driftClient.ts @@ -4,39 +4,38 @@ import { BASE_PRECISION, BN, isVariant, - PerpMarketAccount, OracleSource, + PerpMarketAccount, ZERO, -} from '../sdk'; - -import { Program } from '@coral-xyz/anchor'; +} from '../sdk/src'; import { PublicKey, TransactionSignature } from '@solana/web3.js'; import { - TestClient, calculateTradeSlippage, - PositionDirection, - getPerpMarketPublicKey, EventSubscriber, + getPerpMarketPublicKey, + PositionDirection, QUOTE_SPOT_MARKET_INDEX, + TestClient, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { + initializeQuoteSpotMarket, + mintUSDCToUser, + mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, - mockOracleNoProgram, setFeedPriceNoProgram, - initializeQuoteSpotMarket, - mintUSDCToUser, sleep, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('drift client', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -215,7 +214,7 @@ describe('drift client', () => { assert.ok(user.perpPositions[0].lastCumulativeFundingRate.toNumber() === 0); await eventSubscriber.awaitTx(txSig); - const depositRecord = eventSubscriber.getEventsArray('DepositRecord')[0]; + const depositRecord = eventSubscriber.getEventsArray('depositRecord')[0]; assert.ok( depositRecord.userAuthority.equals( @@ -226,7 +225,7 @@ describe('drift client', () => { assert.ok( JSON.stringify(depositRecord.direction) === - JSON.stringify({ deposit: {} }) + JSON.stringify({ deposit: {} }) ); assert.ok(depositRecord.amount.eq(new BN(10000000))); }); @@ -256,7 +255,7 @@ describe('drift client', () => { ); assert.ok(new BN(Number(userUSDCtoken.amount)).eq(usdcAmount)); - const depositRecord = eventSubscriber.getEventsArray('DepositRecord')[0]; + const depositRecord = eventSubscriber.getEventsArray('depositRecord')[0]; assert.ok( depositRecord.userAuthority.equals( @@ -267,7 +266,7 @@ describe('drift client', () => { assert.ok( JSON.stringify(depositRecord.direction) === - JSON.stringify({ withdraw: {} }) + JSON.stringify({ withdraw: {} }) ); assert.ok(depositRecord.amount.eq(new BN(10000000))); }); diff --git a/tests/fillSpot.ts b/tests/fillSpot.ts index e7dcd89d6e..8dd0e71796 100644 --- a/tests/fillSpot.ts +++ b/tests/fillSpot.ts @@ -1,22 +1,30 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, LAMPORTS_PER_SOL } from '@solana/web3.js'; import { - TestClient, + BASE_PRECISION, BN, - PRICE_PRECISION, + getLimitOrderParams, + OracleSource, PositionDirection, + PRICE_PRECISION, + TestClient, User, Wallet, - BASE_PRECISION, - getLimitOrderParams, - OracleSource, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { + MARGIN_PRECISION, + PostOnlyParams, + ReferrerInfo, + ZERO, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, initializeSolSpotMarket, @@ -25,13 +33,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { MARGIN_PRECISION, PostOnlyParams, ReferrerInfo, ZERO } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('place and fill spot order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; diff --git a/tests/forceUserDelete.ts b/tests/forceUserDelete.ts index e7fbbf29aa..4db5b09a17 100644 --- a/tests/forceUserDelete.ts +++ b/tests/forceUserDelete.ts @@ -1,20 +1,24 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, + OracleInfo, OracleSource, + SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, - OracleInfo, + TestClient, } from '../sdk/src'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { QUOTE_PRECISION, ZERO } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, @@ -23,14 +27,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { QUOTE_PRECISION, ZERO } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/fuel.ts b/tests/fuel.ts index dc41d96f70..f100a97969 100644 --- a/tests/fuel.ts +++ b/tests/fuel.ts @@ -1,26 +1,36 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, LAMPORTS_PER_SOL } from '@solana/web3.js'; import { - TestClient, + BASE_PRECISION, BN, + ContractTier, + FUEL_START_TS, + ONE, + OracleSource, PRICE_PRECISION, PositionDirection, + TestClient, User, - Wallet, - BASE_PRECISION, UserStatsAccount, + Wallet, getLimitOrderParams, - OracleSource, - ONE, - ContractTier, - FUEL_START_TS, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { + MARGIN_PRECISION, + PostOnlyParams, + QUOTE_PRECISION, + ReferrerInfo, + ZERO, + calculatePerpFuelBonus, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, initializeSolSpotMarket, @@ -29,14 +39,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { QUOTE_PRECISION, calculatePerpFuelBonus } from '../sdk/src'; -import { MARGIN_PRECISION, PostOnlyParams, ReferrerInfo, ZERO } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe("fuelin'", () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; @@ -291,7 +296,7 @@ describe("fuelin'", () => { assert( Math.abs( fuelDictInit['insuranceFuel'].toNumber() - - fuelDictInit2['insuranceFuel'].toNumber() + fuelDictInit2['insuranceFuel'].toNumber() ) <= 1 ); @@ -462,7 +467,7 @@ describe("fuelin'", () => { const perp0 = fillerDriftClient.getPerpMarketAccount(0); // console.log( - // perp0.amm.historicalOracleData.lastOraclePriceTwap5Min.toString() + // perp0.amm.historicalOracleData.lastOraclePriceTwap5min.toString() // ); const fuelPosition = calculatePerpFuelBonus( diff --git a/tests/fuelSweep.ts b/tests/fuelSweep.ts index c356b5f009..8226c06041 100644 --- a/tests/fuelSweep.ts +++ b/tests/fuelSweep.ts @@ -1,33 +1,32 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { AccountInfo, Keypair, PublicKey } from '@solana/web3.js'; import { BN, - TestClient, + FuelOverflowStatus, QUOTE_PRECISION, + TestClient, UserStatsAccount, getFuelOverflowAccountPublicKey, parseLogs, - FuelOverflowStatus, } from '../sdk/src'; +import dotenv from 'dotenv'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; dotenv.config(); describe('fuel sweep', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -104,7 +103,7 @@ describe('fuel sweep', () => { ); assert.isFalse( (userStatsBefore.data.fuelOverflowStatus & FuelOverflowStatus.Exists) === - FuelOverflowStatus.Exists, + FuelOverflowStatus.Exists, 'FuelOverflow account should not exist' ); userStatsBefore.data.fuelTaker = 1_000_000_000; @@ -229,7 +228,7 @@ describe('fuel sweep', () => { ); assert.isTrue( (userStatsBefore.data.fuelOverflowStatus & FuelOverflowStatus.Exists) === - FuelOverflowStatus.Exists, + FuelOverflowStatus.Exists, 'FuelSweep account should exist' ); @@ -304,7 +303,7 @@ async function getUserStatsDecoded( ); const userStatsBefore: UserStatsAccount = driftClient.program.account.userStats.coder.accounts.decode( - 'UserStats', + 'userStats', accountInfo.data ); @@ -325,7 +324,7 @@ async function overWriteUserStats( owner: userStats.owner, lamports: userStats.lamports, data: await driftClient.program.account.userStats.coder.accounts.encode( - 'UserStats', + 'userStats', userStats.data ), rentEpoch: userStats.rentEpoch, diff --git a/tests/govStakeDevnet.ts b/tests/govStakeDevnet.ts index e1759a3d62..23913390d4 100644 --- a/tests/govStakeDevnet.ts +++ b/tests/govStakeDevnet.ts @@ -1,20 +1,20 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; - import { - TestClient, EventSubscriber, - User, OracleSource, PEG_PRECISION, PRICE_PRECISION, + TestClient, + User, } from '../sdk/src'; +import dotenv from 'dotenv'; import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; + +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, @@ -24,7 +24,7 @@ import { dotenv.config(); describe('gov stake increase on devnet', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerDriftClientUser: User; let eventSubscriber: EventSubscriber; @@ -143,8 +143,7 @@ describe('gov stake increase on devnet', () => { it('should update gov stake without error', async () => { await makerDriftClient.updateUserGovTokenInsuranceStake( makerDriftClient.authority, - undefined, - 'devnet' + undefined ); }); }); diff --git a/tests/highLeverageMode.ts b/tests/highLeverageMode.ts index 0c2cd1bba7..5106a58d16 100644 --- a/tests/highLeverageMode.ts +++ b/tests/highLeverageMode.ts @@ -1,43 +1,42 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { BN, - OracleSource, - TestClient, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - OracleGuardRails, - MarketStatus, LIQUIDATION_PCT_PRECISION, + MarketStatus, + OracleGuardRails, + OracleSource, + PositionDirection, + PRICE_PRECISION, + TestClient, } from '../sdk/src'; -import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - initializeQuoteSpotMarket, - createUserWithUSDCAndWSOLAccount, - initializeSolSpotMarket, -} from './testHelpers'; +import { startAnchor } from 'solana-bankrun'; import { getMarketOrderParams, MARGIN_PRECISION, MAX_LEVERAGE_ORDER_SIZE, OrderParamsBitFlag, PERCENTAGE_PRECISION, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + createUserWithUSDCAndWSOLAccount, + initializeQuoteSpotMarket, + initializeSolSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, +} from './testHelpers'; describe('max leverage order params', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; let bankrunContextWrapper: BankrunContextWrapper; @@ -144,7 +143,7 @@ describe('max leverage order params', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION.div(new BN(10)), - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION, + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION, }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/ifRebalance.ts b/tests/ifRebalance.ts index b6e731d79d..c1a120db7f 100644 --- a/tests/ifRebalance.ts +++ b/tests/ifRebalance.ts @@ -1,8 +1,6 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Account, Keypair, @@ -14,19 +12,25 @@ import { listMarket, makePlaceOrderTransaction, SERUM } from './serumHelper'; import { BN, - TestClient, EventSubscriber, - OracleSource, - OracleInfo, - getSerumSignerPublicKey, - QUOTE_PRECISION, - unstakeSharesToAmount, getIfRebalanceConfigPublicKey, - IfRebalanceConfigAccount, + getSerumSignerPublicKey, getTokenAmount, + IfRebalanceConfigAccount, + OracleInfo, + OracleSource, + QUOTE_PRECISION, SpotBalanceType, + TestClient, + unstakeSharesToAmount, } from '../sdk/src'; +import { DexInstructions, Market, OpenOrders } from '@project-serum/serum'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, @@ -36,14 +40,9 @@ import { mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { DexInstructions, Market, OpenOrders } from '@project-serum/serum'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot swap', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerWSOL: PublicKey; @@ -427,7 +426,7 @@ describe('spot swap', () => { assert(rebalanceConfig.epochInAmount.eq(new BN(100040000))); const swapRecord = eventSubscriber.getEventsArray( - 'InsuranceFundSwapRecord' + 'insuranceFundSwapRecord' )[0]; assert(swapRecord.inIfTotalSharesBefore.eq(new BN(200000000))); @@ -456,7 +455,7 @@ describe('spot swap', () => { ); const transferRecord = eventSubscriber.getEventsArray( - 'TransferProtocolIfSharesToRevenuePoolRecord' + 'transferProtocolIfSharesToRevenuePoolRecord' )[0]; assert(transferRecord.amount.eq(new BN(1000000000))); diff --git a/tests/imbalancePerpPnl.ts b/tests/imbalancePerpPnl.ts index adb21dcc3b..4f29616d68 100644 --- a/tests/imbalancePerpPnl.ts +++ b/tests/imbalancePerpPnl.ts @@ -1,54 +1,55 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; -import { PublicKey, Keypair } from '@solana/web3.js'; + +import { Keypair, PublicKey } from '@solana/web3.js'; import { - Wallet, - getInsuranceFundStakeAccountPublicKey, - InsuranceFundStake, + AMM_RESERVE_PRECISION, BASE_PRECISION, + BID_ASK_SPREAD_PRECISION, BN, - OracleSource, - ZERO, - TestClient, + calculateBidAskPrice, + calculateNetUserPnlImbalance, + calculateUpdatedAMM, + ContractTier, convertToNumber, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - QUOTE_PRECISION, - User, - calculateNetUserPnlImbalance, + getInsuranceFundStakeAccountPublicKey, getMarketOrderParams, - calculateUpdatedAMM, - oraclePriceBands, InsuranceFundRecord, - OracleGuardRails, - AMM_RESERVE_PRECISION, - BID_ASK_SPREAD_PRECISION, - calculateBidAskPrice, - ContractTier, + InsuranceFundStake, isVariant, MARGIN_PRECISION, - PerpMarketAccount, + OracleGuardRails, + oraclePriceBands, OraclePriceData, - SPOT_MARKET_BALANCE_PRECISION, + OracleSource, + PerpMarketAccount, + PositionDirection, + PRICE_PRECISION, + QUOTE_PRECISION, QUOTE_SPOT_MARKET_INDEX, + SPOT_MARKET_BALANCE_PRECISION, + TestClient, + User, + Wallet, + ZERO, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { PERCENTAGE_PRECISION } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { + createUserWithUSDCAndWSOLAccount, + initializeQuoteSpotMarket, + initializeSolSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, setFeedPriceNoProgram, - initializeQuoteSpotMarket, - createUserWithUSDCAndWSOLAccount, - initializeSolSpotMarket, sleep, } from './testHelpers'; -import { PERCENTAGE_PRECISION } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; async function depositToFeePoolFromIF( amount: number, @@ -86,7 +87,7 @@ function examineSpread( '$', convertToNumber(spread), spread.mul(BID_ASK_SPREAD_PRECISION).div(oraclePriceData.price).toNumber() / - BID_ASK_SPREAD_PRECISION.toNumber(), + BID_ASK_SPREAD_PRECISION.toNumber(), '%', 'and max (', '$', @@ -100,7 +101,7 @@ function examineSpread( ' margin max=', (market.marginRatioInitial - market.marginRatioMaintenance) / - BID_ASK_SPREAD_PRECISION.toNumber(), + BID_ASK_SPREAD_PRECISION.toNumber(), ')' ); @@ -119,7 +120,7 @@ function examineSpread( } describe('imbalanced large perp pnl w/ borrow hitting limits', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -216,7 +217,7 @@ describe('imbalanced large perp pnl w/ borrow hitting limits', () => { await driftClient.subscribe(); const oracleGuardrails = driftClient.getStateAccount().oracleGuardRails; - oracleGuardrails.priceDivergence.oracleTwap5MinPercentDivergence = new BN( + oracleGuardrails.priceDivergence.oracleTwap5minPercentDivergence = new BN( 12 ).mul(PERCENTAGE_PRECISION); await driftClient.updateOracleGuardRails(oracleGuardrails); @@ -864,7 +865,7 @@ describe('imbalanced large perp pnl w/ borrow hitting limits', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: new BN(12).mul(PERCENTAGE_PRECISION), - oracleTwap5MinPercentDivergence: new BN(100).mul(PERCENTAGE_PRECISION), + oracleTwap5minPercentDivergence: new BN(100).mul(PERCENTAGE_PRECISION), }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -882,7 +883,7 @@ describe('imbalanced large perp pnl w/ borrow hitting limits', () => { bankrunContextWrapper.connection.printTxLogs(txSig2); const ifRecord: InsuranceFundRecord = eventSubscriber.getEventsArray( - 'InsuranceFundRecord' + 'insuranceFundRecord' )[0]; console.log(ifRecord); assert(ifRecord.vaultAmountBefore.eq(new BN('13000000000'))); @@ -1033,7 +1034,7 @@ describe('imbalanced large perp pnl w/ borrow hitting limits', () => { // console.log('Cannot settle pnl under current market status'); // } - // // const settleRecord = eventSubscriber.getEventsArray('SettlePnlRecord')[0]; + // // const settleRecord = eventSubscriber.getEventsArray('settlePnlRecord')[0]; // // console.log(settleRecord); // await driftClientLoser.fetchAccounts(); diff --git a/tests/insuranceFundStake.ts b/tests/insuranceFundStake.ts index 75387f3e84..17b684f511 100644 --- a/tests/insuranceFundStake.ts +++ b/tests/insuranceFundStake.ts @@ -1,58 +1,57 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - -import { PublicKey, Keypair } from '@solana/web3.js'; +import { Keypair, PublicKey } from '@solana/web3.js'; import { - OracleGuardRails, - TestClient, - User, + AMM_RESERVE_PRECISION, BN, - OracleSource, + convertToNumber, EventSubscriber, + getBalance, getInsuranceFundStakeAccountPublicKey, - InsuranceFundStake, - ZERO, - QUOTE_SPOT_MARKET_INDEX, - QUOTE_PRECISION, - ONE, getTokenAmount, - SpotBalanceType, - getBalance, + getUserStatsAccountPublicKey, + InsuranceFundStake, isVariant, + LIQUIDATION_PCT_PRECISION, + MarketStatus, + ONE, + OracleGuardRails, + OracleSource, PEG_PRECISION, + QUOTE_PRECISION, + QUOTE_SPOT_MARKET_INDEX, SPOT_MARKET_RATE_PRECISION, - convertToNumber, - AMM_RESERVE_PRECISION, + SpotBalanceType, + TestClient, unstakeSharesToAmount, - MarketStatus, - LIQUIDATION_PCT_PRECISION, - getUserStatsAccountPublicKey, + User, + ZERO, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { ContractTier, PERCENTAGE_PRECISION, UserStatus } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { - mockUSDCMint, - mockUserUSDCAccount, + asBN, + BankrunContextWrapper, +} from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + createUserWithUSDCAndWSOLAccount, initializeQuoteSpotMarket, initializeSolSpotMarket, - createUserWithUSDCAndWSOLAccount, - sleep, + mintUSDCToUser, mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, setFeedPriceNoProgram, - mintUSDCToUser, + sleep, } from './testHelpers'; -import { ContractTier, PERCENTAGE_PRECISION, UserStatus } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { - BankrunContextWrapper, - asBN, -} from '../sdk/src/bankrun/bankrunConnection'; describe('insurance fund stake', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -854,7 +853,7 @@ describe('insurance fund stake', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION, - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION, + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION, }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -1054,7 +1053,7 @@ describe('insurance fund stake', () => { assert( secondUserDriftClient.getUserAccount().status === - UserStatus.BEING_LIQUIDATED + UserStatus.BEING_LIQUIDATED ); assert( @@ -1062,7 +1061,7 @@ describe('insurance fund stake', () => { ); const liquidationRecord = - eventSubscriber.getEventsArray('LiquidationRecord')[0]; + eventSubscriber.getEventsArray('liquidationRecord')[0]; assert(liquidationRecord.liquidationId === 1); assert(isVariant(liquidationRecord.liquidationType, 'liquidateSpot')); assert(liquidationRecord.liquidateSpot.liabilityMarketIndex === 0); diff --git a/tests/ksolver.ts b/tests/ksolver.ts index 7f738ec592..05002bb744 100644 --- a/tests/ksolver.ts +++ b/tests/ksolver.ts @@ -1,31 +1,33 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; + import { Keypair } from '@solana/web3.js'; -import { BN, OracleSource } from '../sdk'; import { - TestClient, - PRICE_PRECISION, + BN, calculateReservePrice, - calculateTradeSlippage, calculateTargetPriceTrade, - PositionDirection, - PEG_PRECISION, + calculateTradeSlippage, + convertToNumber, MAX_LEVERAGE, + OracleSource, + PEG_PRECISION, + PositionDirection, + PRICE_PRECISION, QUOTE_PRECISION, - convertToNumber, + TestClient, User, } from '../sdk/src'; import { liquidityBook } from './liquidityBook'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('AMM Curve', () => { // K SOLVER: find opitimal k given exchange details @@ -166,7 +168,7 @@ describe('AMM Curve', () => { // return kSqrtI; // } - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/liquidateBorrowForPerpPnl.ts b/tests/liquidateBorrowForPerpPnl.ts index 66a13d3fb5..a594e9f811 100644 --- a/tests/liquidateBorrowForPerpPnl.ts +++ b/tests/liquidateBorrowForPerpPnl.ts @@ -1,41 +1,40 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { BASE_PRECISION, BN, - OracleSource, - ZERO, - TestClient, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - OracleGuardRails, - MarketStatus, LIQUIDATION_PCT_PRECISION, + MarketStatus, + OracleGuardRails, + OracleSource, + PositionDirection, + PRICE_PRECISION, + TestClient, + ZERO, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { isVariant, UserStatus } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { - mockUSDCMint, - mockUserUSDCAccount, - initializeQuoteSpotMarket, createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, + initializeQuoteSpotMarket, initializeSolSpotMarket, mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { isVariant, UserStatus } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate borrow for perp pnl', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; @@ -153,7 +152,7 @@ describe('liquidate borrow for perp pnl', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: new BN(1000000), - oracleTwap5MinPercentDivergence: new BN(1000000), + oracleTwap5minPercentDivergence: new BN(1000000), }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -247,7 +246,7 @@ describe('liquidate borrow for perp pnl', () => { ); const liquidationRecord = - eventSubscriber.getEventsArray('LiquidationRecord')[0]; + eventSubscriber.getEventsArray('liquidationRecord')[0]; assert(liquidationRecord.liquidationId === 1); assert( diff --git a/tests/liquidatePerp.ts b/tests/liquidatePerp.ts index e02b8d638c..9f7a6d1312 100644 --- a/tests/liquidatePerp.ts +++ b/tests/liquidatePerp.ts @@ -1,5 +1,6 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; + +import { assert } from 'chai'; import { BASE_PRECISION, BN, @@ -17,10 +18,14 @@ import { Wallet, ZERO, } from '../sdk/src'; -import { assert } from 'chai'; import { Keypair, LAMPORTS_PER_SOL } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; +import { PERCENTAGE_PRECISION, UserStatus } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, @@ -29,13 +34,9 @@ import { setFeedPriceNoProgram, sleep, } from './testHelpers'; -import { PERCENTAGE_PRECISION, UserStatus } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate perp (no open orders)', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -124,7 +125,7 @@ describe('liquidate perp (no open orders)', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION, - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.muln(100), + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION.muln(100), }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -347,7 +348,7 @@ describe('liquidate perp (no open orders)', () => { assert(driftClient.getUserAccount().nextLiquidationId === 2); const liquidationRecord = - eventSubscriber.getEventsArray('LiquidationRecord')[0]; + eventSubscriber.getEventsArray('liquidationRecord')[0]; assert(liquidationRecord.liquidationId === 1); assert(isVariant(liquidationRecord.liquidationType, 'liquidatePerp')); assert(liquidationRecord.liquidatePerp.marketIndex === 0); @@ -471,7 +472,7 @@ describe('liquidate perp (no open orders)', () => { assert( (driftClient.getUserAccount().status & (UserStatus.BANKRUPT | UserStatus.BEING_LIQUIDATED)) === - 0 + 0 ); console.log(driftClient.getUserAccount()); @@ -481,7 +482,7 @@ describe('liquidate perp (no open orders)', () => { // assert(driftClient.getUserAccount().perpPositions[0].lpShares.eq(ZERO)); const perpBankruptcyRecord = - eventSubscriber.getEventsArray('LiquidationRecord')[0]; + eventSubscriber.getEventsArray('liquidationRecord')[0]; assert(isVariant(perpBankruptcyRecord.liquidationType, 'perpBankruptcy')); assert(perpBankruptcyRecord.perpBankruptcy.marketIndex === 0); diff --git a/tests/liquidatePerpPnlForDeposit.ts b/tests/liquidatePerpPnlForDeposit.ts index 8c49801fdf..4602e80544 100644 --- a/tests/liquidatePerpPnlForDeposit.ts +++ b/tests/liquidatePerpPnlForDeposit.ts @@ -1,46 +1,45 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { BASE_PRECISION, BN, + EventSubscriber, + LIQUIDATION_PCT_PRECISION, + OracleGuardRails, OracleSource, - ZERO, - TestClient, PRICE_PRECISION, PositionDirection, - EventSubscriber, - OracleGuardRails, - LIQUIDATION_PCT_PRECISION, + TestClient, + ZERO, convertToNumber, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { + PERCENTAGE_PRECISION, + QUOTE_PRECISION, + UserStatus, + isVariant, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { - mockUSDCMint, - mockUserUSDCAccount, - initializeQuoteSpotMarket, createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, + initializeQuoteSpotMarket, initializeSolSpotMarket, mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { - isVariant, - PERCENTAGE_PRECISION, - QUOTE_PRECISION, - UserStatus, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate perp pnl for deposit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -156,7 +155,7 @@ describe('liquidate perp pnl for deposit', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: new BN(10).mul(PERCENTAGE_PRECISION), - oracleTwap5MinPercentDivergence: new BN(100).mul(PERCENTAGE_PRECISION), + oracleTwap5minPercentDivergence: new BN(100).mul(PERCENTAGE_PRECISION), }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -284,7 +283,7 @@ describe('liquidate perp pnl for deposit', () => { ); const liquidationRecord = - eventSubscriber.getEventsArray('LiquidationRecord')[0]; + eventSubscriber.getEventsArray('liquidationRecord')[0]; assert(liquidationRecord.liquidationId === 1); assert( diff --git a/tests/liquidatePerpWithFill.ts b/tests/liquidatePerpWithFill.ts index 27b9091735..55d97101db 100644 --- a/tests/liquidatePerpWithFill.ts +++ b/tests/liquidatePerpWithFill.ts @@ -1,5 +1,6 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; + +import { assert } from 'chai'; import { BASE_PRECISION, BN, @@ -14,10 +15,14 @@ import { TestClient, Wallet, } from '../sdk/src'; -import { assert } from 'chai'; import { Keypair, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; +import { OrderType, PERCENTAGE_PRECISION, PerpOperation } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAccount, initializeQuoteSpotMarket, @@ -26,13 +31,9 @@ import { mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { OrderType, PERCENTAGE_PRECISION, PerpOperation } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate perp (no open orders)', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -128,7 +129,7 @@ describe('liquidate perp (no open orders)', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION.muln(100), - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.muln(100), + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION.muln(100), }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/liquidateSpot.ts b/tests/liquidateSpot.ts index 126abc7e33..d9b61c4483 100644 --- a/tests/liquidateSpot.ts +++ b/tests/liquidateSpot.ts @@ -1,45 +1,43 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - TestClient, BN, - OracleSource, - ZERO, + convertToNumber, EventSubscriber, - PRICE_PRECISION, getTokenAmount, - SpotBalanceType, isVariant, - User, - QUOTE_PRECISION, - convertToNumber, LIQUIDATION_PCT_PRECISION, + OracleSource, + PRICE_PRECISION, + QUOTE_PRECISION, + SpotBalanceType, + TestClient, + User, + ZERO, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { PERCENTAGE_PRECISION } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - initializeQuoteSpotMarket, createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, + initializeQuoteSpotMarket, initializeSolSpotMarket, - sleep, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, setFeedPriceNoProgram, + sleep, } from './testHelpers'; -import { PERCENTAGE_PRECISION } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { Drift } from '../sdk/src/idl/drift'; describe('liquidate spot', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -128,7 +126,7 @@ describe('liquidate spot', () => { const oracleGuardrails = await driftClient.getStateAccount() .oracleGuardRails; - oracleGuardrails.priceDivergence.oracleTwap5MinPercentDivergence = new BN( + oracleGuardrails.priceDivergence.oracleTwap5minPercentDivergence = new BN( 100 ).mul(PERCENTAGE_PRECISION); await driftClient.updateOracleGuardRails(oracleGuardrails); diff --git a/tests/liquidateSpotSocialLoss.ts b/tests/liquidateSpotSocialLoss.ts index a5c02d1ef5..441aa42999 100644 --- a/tests/liquidateSpotSocialLoss.ts +++ b/tests/liquidateSpotSocialLoss.ts @@ -1,39 +1,38 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - TestClient, BN, - OracleSource, - ZERO, EventSubscriber, - PRICE_PRECISION, getTokenAmount, - SpotBalanceType, LIQUIDATION_PCT_PRECISION, + OracleSource, + PRICE_PRECISION, + SpotBalanceType, + TestClient, + ZERO, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { isVariant, PERCENTAGE_PRECISION, UserStatus } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { + createUserWithUSDCAndWSOLAccount, + createWSolTokenAccountForUser, + initializeQuoteSpotMarket, + initializeSolSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, setFeedPriceNoProgram, - initializeQuoteSpotMarket, - createUserWithUSDCAndWSOLAccount, - createWSolTokenAccountForUser, - initializeSolSpotMarket, } from './testHelpers'; -import { isVariant, UserStatus, PERCENTAGE_PRECISION } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('liquidate spot w/ social loss', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -121,7 +120,7 @@ describe('liquidate spot w/ social loss', () => { const oracleGuardrails = await driftClient.getStateAccount() .oracleGuardRails; - oracleGuardrails.priceDivergence.oracleTwap5MinPercentDivergence = new BN( + oracleGuardrails.priceDivergence.oracleTwap5minPercentDivergence = new BN( 100 ).mul(PERCENTAGE_PRECISION); await driftClient.updateOracleGuardRails(oracleGuardrails); @@ -195,7 +194,7 @@ describe('liquidate spot w/ social loss', () => { // ); const liquidationRecord = - eventSubscriber.getEventsArray('LiquidationRecord')[0]; + eventSubscriber.getEventsArray('liquidationRecord')[0]; assert(liquidationRecord.liquidationId === 1); assert(isVariant(liquidationRecord.liquidationType, 'liquidateSpot')); assert(liquidationRecord.liquidateSpot.assetPrice.eq(PRICE_PRECISION)); @@ -353,7 +352,7 @@ describe('liquidate spot w/ social loss', () => { // ); const bankruptcyRecord = - eventSubscriber.getEventsArray('LiquidationRecord')[0]; + eventSubscriber.getEventsArray('liquidationRecord')[0]; assert(isVariant(bankruptcyRecord.liquidationType, 'spotBankruptcy')); console.log(bankruptcyRecord.spotBankruptcy); assert(bankruptcyRecord.spotBankruptcy.marketIndex === 1); diff --git a/tests/liquidateSpotWithSwap.ts b/tests/liquidateSpotWithSwap.ts index 7d5626efc7..f2eebb2889 100644 --- a/tests/liquidateSpotWithSwap.ts +++ b/tests/liquidateSpotWithSwap.ts @@ -1,7 +1,5 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; - import { Account, Keypair, @@ -13,14 +11,20 @@ import { listMarket, makePlaceOrderTransaction, SERUM } from './serumHelper'; import { BN, - TestClient, EventSubscriber, - OracleSource, - OracleInfo, getSerumSignerPublicKey, + OracleInfo, + OracleSource, PERCENTAGE_PRECISION, + TestClient, } from '../sdk/src'; +import { DexInstructions, Market, OpenOrders } from '@project-serum/serum'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, @@ -31,14 +35,9 @@ import { mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { DexInstructions, Market, OpenOrders } from '@project-serum/serum'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot swap', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerWSOL: PublicKey; @@ -149,7 +148,7 @@ describe('spot swap', () => { const oracleGuardrails = await makerDriftClient.getStateAccount() .oracleGuardRails; oracleGuardrails.validity.tooVolatileRatio = new BN(10000); - oracleGuardrails.priceDivergence.oracleTwap5MinPercentDivergence = new BN( + oracleGuardrails.priceDivergence.oracleTwap5minPercentDivergence = new BN( 100 ).mul(PERCENTAGE_PRECISION); diff --git a/tests/liquidityBook.ts b/tests/liquidityBook.ts index a48991dd00..d18375d32b 100644 --- a/tests/liquidityBook.ts +++ b/tests/liquidityBook.ts @@ -2,9 +2,9 @@ import { BN } from '@coral-xyz/anchor'; import { PRICE_PRECISION, PerpMarketAccount, + ZERO, calculateReservePrice, calculateTargetPriceTrade, - ZERO, } from '../sdk/src'; /** diff --git a/tests/lpPool.ts b/tests/lpPool.ts index 6cba4c12ea..970e77601b 100644 --- a/tests/lpPool.ts +++ b/tests/lpPool.ts @@ -1,61 +1,66 @@ import * as anchor from '@coral-xyz/anchor'; -import { expect, assert } from 'chai'; +import { assert, expect } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - -import { - AccountInfo, - Keypair, - LAMPORTS_PER_SOL, - PublicKey, - SystemProgram, - Transaction, -} from '@solana/web3.js'; import { + MINT_SIZE, + TOKEN_PROGRAM_ID, createAssociatedTokenAccountInstruction, createInitializeMint2Instruction, createMintToInstruction, getAssociatedTokenAddress, getAssociatedTokenAddressSync, getMint, - MINT_SIZE, - TOKEN_PROGRAM_ID, } from '@solana/spl-token'; +import { + AccountInfo, + Keypair, + LAMPORTS_PER_SOL, + PublicKey, + SystemProgram, + Transaction, +} from '@solana/web3.js'; import { + AmmCache, + AmmConstituentMapping, + BASE_PRECISION, BN, - TestClient, - QUOTE_PRECISION, - getLpPoolPublicKey, - getAmmConstituentMappingPublicKey, - getConstituentTargetBasePublicKey, - PERCENTAGE_PRECISION, - PRICE_PRECISION, - PEG_PRECISION, + ConstituentAccount, + ConstituentLpOperation, ConstituentTargetBaseAccount, - AmmConstituentMapping, + CustomBorshCoder, LPPoolAccount, - getConstituentVaultPublicKey, OracleSource, - SPOT_MARKET_WEIGHT_PRECISION, + PEG_PRECISION, + PERCENTAGE_PRECISION, + PRICE_PRECISION, + PTYH_LAZER_PROGRAM_ID, + PYTH_LAZER_STORAGE_ACCOUNT_KEY, + PositionDirection, + QUOTE_PRECISION, + SPOT_MARKET_BALANCE_PRECISION, SPOT_MARKET_RATE_PRECISION, - getAmmCachePublicKey, - AmmCache, + SPOT_MARKET_WEIGHT_PRECISION, + SpotBalanceType, + TWO, + TestClient, ZERO, + getAmmCachePublicKey, + getAmmConstituentMappingPublicKey, getConstituentPublicKey, - ConstituentAccount, - PositionDirection, + getConstituentTargetBasePublicKey, + getConstituentVaultPublicKey, + getLpPoolPublicKey, getPythLazerOraclePublicKey, - PYTH_LAZER_STORAGE_ACCOUNT_KEY, - PTYH_LAZER_PROGRAM_ID, - BASE_PRECISION, - SPOT_MARKET_BALANCE_PRECISION, - SpotBalanceType, getTokenAmount, - TWO, - ConstituentLpOperation, } from '../sdk/src'; +import dotenv from 'dotenv'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { PYTH_LAZER_HEX_STRING_SOL, PYTH_STORAGE_DATA } from './pythLazerData'; import { createWSolTokenAccountForUser, initializeQuoteSpotMarket, @@ -69,16 +74,6 @@ import { overWriteSpotMarket, setFeedPriceNoProgram, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; -import { PYTH_LAZER_HEX_STRING_SOL, PYTH_STORAGE_DATA } from './pythLazerData'; -import { - CustomBorshAccountsCoder, - CustomBorshCoder, -} from '../sdk/src/decode/customCoder'; -import { Drift } from '../sdk/src/idl/drift'; dotenv.config(); const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { @@ -90,7 +85,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('LP Pool', () => { - const program = anchor.workspace.Drift as Program; + const program = anchor.workspace.Drift as DriftProgram; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -167,6 +162,7 @@ describe('LP Pool', () => { type: 'polling', accountLoader: bulkAccountLoader, }, + coder: new CustomBorshCoder(program.idl), }); await adminClient.initialize(usdcMint.publicKey, true); await adminClient.subscribe(); diff --git a/tests/lpPoolCUs.ts b/tests/lpPoolCUs.ts index c02cf69315..bb44f1559e 100644 --- a/tests/lpPoolCUs.ts +++ b/tests/lpPoolCUs.ts @@ -1,8 +1,12 @@ import * as anchor from '@coral-xyz/anchor'; -import { expect, assert } from 'chai'; - -import { Program } from '@coral-xyz/anchor'; +import { assert, expect } from 'chai'; +import { + createInitializeMint2Instruction, + getMint, + MINT_SIZE, + TOKEN_PROGRAM_ID, +} from '@solana/spl-token'; import { AccountInfo, AddressLookupTableProgram, @@ -15,40 +19,41 @@ import { TransactionMessage, VersionedTransaction, } from '@solana/web3.js'; -import { - createInitializeMint2Instruction, - getMint, - MINT_SIZE, - TOKEN_PROGRAM_ID, -} from '@solana/spl-token'; import { + AmmCache, + AmmConstituentMapping, + BASE_PRECISION, BN, - TestClient, - QUOTE_PRECISION, - getLpPoolPublicKey, + ConstituentAccount, + ConstituentTargetBaseAccount, + CustomBorshCoder, + getAmmCachePublicKey, getAmmConstituentMappingPublicKey, + getConstituentPublicKey, getConstituentTargetBasePublicKey, - PERCENTAGE_PRECISION, - PRICE_PRECISION, - PEG_PRECISION, - ConstituentTargetBaseAccount, - AmmConstituentMapping, + getLpPoolPublicKey, LPPoolAccount, OracleSource, - SPOT_MARKET_WEIGHT_PRECISION, - SPOT_MARKET_RATE_PRECISION, - getAmmCachePublicKey, - AmmCache, - ZERO, - getConstituentPublicKey, - ConstituentAccount, + PEG_PRECISION, + PERCENTAGE_PRECISION, PositionDirection, - PYTH_LAZER_STORAGE_ACCOUNT_KEY, + PRICE_PRECISION, PTYH_LAZER_PROGRAM_ID, - BASE_PRECISION, + PYTH_LAZER_STORAGE_ACCOUNT_KEY, + QUOTE_PRECISION, + SPOT_MARKET_RATE_PRECISION, + SPOT_MARKET_WEIGHT_PRECISION, + TestClient, + ZERO, } from '../sdk/src'; +import dotenv from 'dotenv'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { PYTH_STORAGE_DATA } from './pythLazerData'; import { initializeQuoteSpotMarket, mockAtaTokenAccountForMint, @@ -58,16 +63,6 @@ import { overwriteConstituentAccount, sleep, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; -import { PYTH_STORAGE_DATA } from './pythLazerData'; -import { - CustomBorshAccountsCoder, - CustomBorshCoder, -} from '../sdk/src/decode/customCoder'; -import { Drift } from '../sdk/src/idl/drift'; dotenv.config(); const NUMBER_OF_CONSTITUENTS = 10; @@ -96,7 +91,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('LP Pool', () => { - const program = anchor.workspace.Drift as Program; + const program = anchor.workspace.Drift as DriftProgram; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -186,6 +181,7 @@ describe('LP Pool', () => { type: 'polling', accountLoader: bulkAccountLoader, }, + coder: new CustomBorshCoder(program.idl), }); await adminClient.initialize(usdcMint.publicKey, true); await adminClient.subscribe(); diff --git a/tests/lpPoolSwap.ts b/tests/lpPoolSwap.ts index 338823ae84..1f65d1531c 100644 --- a/tests/lpPoolSwap.ts +++ b/tests/lpPoolSwap.ts @@ -1,6 +1,8 @@ import * as anchor from '@coral-xyz/anchor'; -import { expect, assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; +import { assert, expect } from 'chai'; + +import { DexInstructions, Market, OpenOrders } from '@project-serum/serum'; +import { NATIVE_MINT } from '@solana/spl-token'; import { Account, Keypair, @@ -8,63 +10,57 @@ import { PublicKey, Transaction, } from '@solana/web3.js'; +import dotenv from 'dotenv'; +import { startAnchor } from 'solana-bankrun'; import { BN, - TestClient, - QUOTE_PRECISION, - getLpPoolPublicKey, - getConstituentTargetBasePublicKey, - PERCENTAGE_PRECISION, - PRICE_PRECISION, - PEG_PRECISION, + BN_MAX, + ConstituentAccount, + ConstituentStatus, ConstituentTargetBaseAccount, + LPPoolAccount, OracleSource, + PEG_PRECISION, + PERCENTAGE_PRECISION, + PRICE_PRECISION, + QUOTE_PRECISION, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, - LPPoolAccount, + TestClient, + ZERO, convertToNumber, - getConstituentVaultPublicKey, getConstituentPublicKey, - ConstituentAccount, - ZERO, + getConstituentTargetBasePublicKey, + getConstituentVaultPublicKey, + getLpPoolPublicKey, getSerumSignerPublicKey, - BN_MAX, - isVariant, - ConstituentStatus, getSignedTokenAmount, getTokenAmount, + isVariant, } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { SERUM, listMarket, makePlaceOrderTransaction } from './serumHelper'; import { + createUserWithUSDCAndWSOLAccount, + createWSolTokenAccountForUser, initializeQuoteSpotMarket, + initializeSolSpotMarket, + mockAtaTokenAccountForMint, + mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, - mockOracleNoProgram, - setFeedPriceNoProgram, + overWriteMintAccount, overWriteTokenAccountBalance, overwriteConstituentAccount, - mockAtaTokenAccountForMint, - overWriteMintAccount, - createWSolTokenAccountForUser, - initializeSolSpotMarket, - createUserWithUSDCAndWSOLAccount, + setFeedPriceNoProgram, sleep, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; -import { DexInstructions, Market, OpenOrders } from '@project-serum/serum'; -import { listMarket, SERUM, makePlaceOrderTransaction } from './serumHelper'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { - CustomBorshAccountsCoder, - CustomBorshCoder, -} from '../sdk/src/decode/customCoder'; -import { Drift } from '../sdk/src/idl/drift'; dotenv.config(); describe('LP Pool', () => { - const program = anchor.workspace.Drift as Program; + const program = anchor.workspace.Drift as DriftProgram; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -502,11 +498,13 @@ describe('LP Pool', () => { expect(Number(diffOutToken)).to.be.approximately(1001298, 1); console.log( - `in Token: ${inTokenBalanceBefore.amount} -> ${inTokenBalanceAfter.amount + `in Token: ${inTokenBalanceBefore.amount} -> ${ + inTokenBalanceAfter.amount } (${Number(diffInToken) / 1e6})` ); console.log( - `out Token: ${outTokenBalanceBefore.amount} -> ${outTokenBalanceAfter.amount + `out Token: ${outTokenBalanceBefore.amount} -> ${ + outTokenBalanceAfter.amount } (${Number(diffOutToken) / 1e6})` ); }); @@ -843,7 +841,7 @@ describe('LP Pool', () => { const { beginSwapIx, endSwapIx } = await adminClient.getSwapIx( { - lpPoolId: lpPoolId, + lpPoolId, amountIn: amountIn, inMarketIndex: 0, outMarketIndex: 2, diff --git a/tests/marketOrder.ts b/tests/marketOrder.ts index cb904994b7..e8ad8f1765 100644 --- a/tests/marketOrder.ts +++ b/tests/marketOrder.ts @@ -1,46 +1,44 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, PublicKey, Transaction } from '@solana/web3.js'; import { BN, + EventSubscriber, + getMarketOrderParams, + PositionDirection, PRICE_PRECISION, TestClient, - PositionDirection, User, Wallet, - getMarketOrderParams, - EventSubscriber, } from '../sdk/src'; import { - initializeQuoteSpotMarket, - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, -} from './testHelpers'; + createAssociatedTokenAccountIdempotentInstruction, + createMintToInstruction, + getAssociatedTokenAddressSync, +} from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; import { AMM_RESERVE_PRECISION, isVariant, OracleSource, PEG_PRECISION, ZERO, -} from '../sdk'; -import { - createAssociatedTokenAccountIdempotentInstruction, - createMintToInstruction, - getAssociatedTokenAddressSync, -} from '@solana/spl-token'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { Drift } from '../sdk/src/idl/drift'; +import { DriftProgram } from '../sdk/src/config'; +import { + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, +} from './testHelpers'; describe('market order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let driftClientUser: User; diff --git a/tests/marketOrderBaseAssetAmount.ts b/tests/marketOrderBaseAssetAmount.ts index f59b3000d4..c70df395a6 100644 --- a/tests/marketOrderBaseAssetAmount.ts +++ b/tests/marketOrderBaseAssetAmount.ts @@ -1,25 +1,24 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { BN, getMarketOrderParams, OracleSource, ZERO } from '../sdk'; - -import { Program } from '@coral-xyz/anchor'; +import { BN, getMarketOrderParams, OracleSource, ZERO } from '../sdk/src'; import { PublicKey } from '@solana/web3.js'; -import { TestClient, PositionDirection, EventSubscriber } from '../sdk/src'; +import { EventSubscriber, PositionDirection, TestClient } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { - mockUSDCMint, - mockUserUSDCAccount, initializeQuoteSpotMarket, mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('market orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/maxDeposit.ts b/tests/maxDeposit.ts index e761f87faa..4e6d7ebd44 100644 --- a/tests/maxDeposit.ts +++ b/tests/maxDeposit.ts @@ -1,22 +1,21 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - -import { TestClient, QUOTE_PRECISION, BN, OracleSource } from '../sdk/src'; +import { BN, OracleSource, QUOTE_PRECISION, TestClient } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('max deposit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/maxLeverageOrderParams.ts b/tests/maxLeverageOrderParams.ts index d095740f56..ab84d01ec2 100644 --- a/tests/maxLeverageOrderParams.ts +++ b/tests/maxLeverageOrderParams.ts @@ -1,41 +1,40 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { BN, - OracleSource, - TestClient, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - OracleGuardRails, - MarketStatus, LIQUIDATION_PCT_PRECISION, + MarketStatus, + OracleGuardRails, + OracleSource, + PositionDirection, + PRICE_PRECISION, + TestClient, } from '../sdk/src'; -import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - initializeQuoteSpotMarket, - createUserWithUSDCAndWSOLAccount, - initializeSolSpotMarket, -} from './testHelpers'; +import { startAnchor } from 'solana-bankrun'; import { getMarketOrderParams, MAX_LEVERAGE_ORDER_SIZE, PERCENTAGE_PRECISION, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + createUserWithUSDCAndWSOLAccount, + initializeQuoteSpotMarket, + initializeSolSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, +} from './testHelpers'; describe('max leverage order params', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; let bankrunContextWrapper: BankrunContextWrapper; @@ -142,7 +141,7 @@ describe('max leverage order params', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION.div(new BN(10)), - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION, + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION, }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/modifyOrder.ts b/tests/modifyOrder.ts index d914bd6236..fc663a08e5 100644 --- a/tests/modifyOrder.ts +++ b/tests/modifyOrder.ts @@ -1,30 +1,29 @@ import * as anchor from '@coral-xyz/anchor'; +import { assert } from 'chai'; import { BASE_PRECISION, BN, - OracleSource, - TestClient, EventSubscriber, + OracleSource, PRICE_PRECISION, PositionDirection, + TestClient, } from '../sdk/src'; -import { assert } from 'chai'; - -import { Program } from '@coral-xyz/anchor'; +import { startAnchor } from 'solana-bankrun'; +import { OrderType, TWO } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { + initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, - initializeQuoteSpotMarket, } from './testHelpers'; -import { OrderType, TWO } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('modify orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/multipleMakerOrders.ts b/tests/multipleMakerOrders.ts index 35e1b74c3b..f642a5cb2e 100644 --- a/tests/multipleMakerOrders.ts +++ b/tests/multipleMakerOrders.ts @@ -1,21 +1,24 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { - TestClient, + BASE_PRECISION, BN, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - MarketStatus, - BASE_PRECISION, isVariant, + MarketStatus, OracleSource, PEG_PRECISION, + PositionDirection, + PRICE_PRECISION, + TestClient, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { ContractTier, MARGIN_PRECISION, OrderType } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAccount, initializeQuoteSpotMarket, @@ -24,13 +27,9 @@ import { mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { ContractTier, MARGIN_PRECISION, OrderType } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('multiple maker orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let fillerDriftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -273,7 +272,7 @@ describe('multiple maker orders', () => { bankrunContextWrapper.printTxLogs(txSig); const orderActionRecords = eventSubscriber - .getEventsArray('OrderActionRecord') + .getEventsArray('orderActionRecord') .filter((record) => isVariant(record.action, 'fill')); assert(orderActionRecords.length === 6); @@ -477,7 +476,7 @@ describe('multiple maker orders', () => { bankrunContextWrapper.printTxLogs(txSig); const orderActionRecords = eventSubscriber - .getEventsArray('OrderActionRecord') + .getEventsArray('orderActionRecord') .filter((record) => isVariant(record.action, 'fill')); console.log('orderActionRecords.length=', orderActionRecords.length); assert(orderActionRecords.length === 20); diff --git a/tests/multipleSpotMakerOrders.ts b/tests/multipleSpotMakerOrders.ts index 4808dfdb8e..cdb825347b 100644 --- a/tests/multipleSpotMakerOrders.ts +++ b/tests/multipleSpotMakerOrders.ts @@ -1,21 +1,30 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { - TestClient, + BASE_PRECISION, BN, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - MarketStatus, - BASE_PRECISION, isVariant, + MarketStatus, OracleSource, PEG_PRECISION, + PositionDirection, + PRICE_PRECISION, + TestClient, } from '../sdk/src'; +import { LAMPORTS_PER_SOL } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; +import { + ContractTier, + MARGIN_PRECISION, + OrderType, + SpotOperation, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAccount, initializeQuoteSpotMarket, @@ -25,15 +34,9 @@ import { mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { MARGIN_PRECISION, OrderType, SpotOperation } from '../sdk/src'; -import { LAMPORTS_PER_SOL } from '@solana/web3.js'; -import { ContractTier } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('multiple maker orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let fillerDriftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -311,7 +314,7 @@ describe('multiple maker orders', () => { bankrunContextWrapper.printTxLogs(txSig); const orderActionRecords = eventSubscriber - .getEventsArray('OrderActionRecord') + .getEventsArray('orderActionRecord') .filter((record) => isVariant(record.action, 'fill')); assert(orderActionRecords.length === 6); diff --git a/tests/openbookTest.ts b/tests/openbookTest.ts index 0bf59e3b32..3766223dc0 100644 --- a/tests/openbookTest.ts +++ b/tests/openbookTest.ts @@ -1,25 +1,33 @@ +import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import * as anchor from '@coral-xyz/anchor-29'; -import { Program, BN } from '@coral-xyz/anchor'; -import { Program as Program29, Idl as Idl29 } from '@coral-xyz/anchor-29'; +import { BN } from '@coral-xyz/anchor'; +import { Idl as Idl29, Program as Program29 } from '@coral-xyz/anchor-29'; +import { Keypair } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; import { + LAMPORTS_PRECISION, OracleSource, OrderType, PositionDirection, + PRICE_PRECISION, PublicKey, TestClient, + WRAPPED_SOL_MINT, + ZERO, } from '../sdk/src'; -import openbookIDL from '../sdk/src/idl/openbook.json'; -import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import openbookIDL from '../sdk/src/idl/openbook.json'; import { + createBidsAsksEventHeap, + createMarket, createOpenOrdersAccount, createOpenOrdersAccountV2, - OPENBOOK, OrderType as ObOrderType, + OPENBOOK, placeOrder, SelfTradeBehavior, Side, @@ -32,15 +40,9 @@ import { mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { createBidsAsksEventHeap, createMarket } from './openbookHelpers'; -import { Keypair } from '@solana/web3.js'; -import { LAMPORTS_PRECISION, PRICE_PRECISION } from '../sdk/src'; -import { WRAPPED_SOL_MINT } from '../sdk/src'; -import { ZERO } from '../sdk'; -import { Drift } from '../sdk/src/idl/drift'; describe('openbook v2', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; const openbookProgram = new Program29(openbookIDL as Idl29, OPENBOOK); let driftClient: TestClient; diff --git a/tests/oracleDiffSources.ts b/tests/oracleDiffSources.ts index 7184ab328f..d615b6d594 100644 --- a/tests/oracleDiffSources.ts +++ b/tests/oracleDiffSources.ts @@ -1,20 +1,18 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - TestClient, BN, + DriftClient, EventSubscriber, - OracleSource, OracleInfo, + OracleSource, + PEG_PRECISION, PRICE_PRECISION, + TestClient, Wallet, - DriftClient, - PEG_PRECISION, } from '../sdk/src'; import { @@ -26,13 +24,14 @@ import { mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -// import { PRICE_PRECISION, PEG_PRECISION, Wallet, DriftClient } from '../sdk'; +// import { PRICE_PRECISION, PEG_PRECISION, Wallet, DriftClient } from '../sdk/src'; import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; describe('oracle diff sources', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/oracleFillPriceGuardrails.ts b/tests/oracleFillPriceGuardrails.ts index 34066370b6..cdc1ccb087 100644 --- a/tests/oracleFillPriceGuardrails.ts +++ b/tests/oracleFillPriceGuardrails.ts @@ -1,21 +1,29 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { - TestClient, + BASE_PRECISION, BN, - PRICE_PRECISION, - PositionDirection, EventSubscriber, - MarketStatus, - BASE_PRECISION, isVariant, + MarketStatus, OracleSource, PEG_PRECISION, + PositionDirection, + PRICE_PRECISION, + TestClient, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { + MARGIN_PRECISION, + OrderType, + PerpOperation, + PostOnlyParams, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAccount, initializeQuoteSpotMarket, @@ -24,18 +32,9 @@ import { mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { - MARGIN_PRECISION, - OrderType, - PerpOperation, - PostOnlyParams, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('oracle fill guardrails', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let fillerDriftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/oracleOffsetOrders.ts b/tests/oracleOffsetOrders.ts index d9e13a99bc..36cd1e4e40 100644 --- a/tests/oracleOffsetOrders.ts +++ b/tests/oracleOffsetOrders.ts @@ -1,40 +1,39 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair } from '@solana/web3.js'; import { assert } from 'chai'; import { + AMM_RESERVE_PRECISION, BN, + calculateBreakEvenPrice, + getLimitOrderParams, + MarketStatus, + OracleSource, + PositionDirection, PRICE_PRECISION, TestClient, - PositionDirection, User, Wallet, - getLimitOrderParams, - MarketStatus, - AMM_RESERVE_PRECISION, - OracleSource, ZERO, - calculateBreakEvenPrice, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { calculateEntryPrice, PostOnlyParams } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { + initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, setFeedPriceNoProgram, - initializeQuoteSpotMarket, } from './testHelpers'; -import { calculateEntryPrice, PostOnlyParams } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('oracle offset', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/order.ts b/tests/order.ts index 24a98b12d9..d7056df182 100644 --- a/tests/order.ts +++ b/tests/order.ts @@ -1,40 +1,31 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, PublicKey } from '@solana/web3.js'; import { - TestClient, BN, - PRICE_PRECISION, - PositionDirection, - User, - OrderStatus, - OrderAction, - OrderTriggerCondition, + calculateBaseAssetAmountForAmmToFulfill, calculateTargetPriceTrade, - convertToNumber, - QUOTE_PRECISION, - Wallet, calculateTradeSlippage, + convertToNumber, + EventSubscriber, getLimitOrderParams, getTriggerMarketOrderParams, - EventSubscriber, - standardizeBaseAssetAmount, - calculateBaseAssetAmountForAmmToFulfill, OracleGuardRails, + OrderAction, + OrderStatus, + OrderTriggerCondition, + PositionDirection, + PRICE_PRECISION, + QUOTE_PRECISION, + standardizeBaseAssetAmount, + TestClient, + User, + Wallet, } from '../sdk/src'; -import { - mockOracleNoProgram, - mockUserUSDCAccount, - mockUSDCMint, - setFeedPriceNoProgram, - initializeQuoteSpotMarket, - sleep, -} from './testHelpers'; +import { startAnchor } from 'solana-bankrun'; import { AMM_RESERVE_PRECISION, calculateReservePrice, @@ -45,10 +36,18 @@ import { TEN_THOUSAND, TWO, ZERO, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, + setFeedPriceNoProgram, + sleep, +} from './testHelpers'; const enumsAreEqual = ( actual: Record, @@ -58,7 +57,7 @@ const enumsAreEqual = ( }; describe('orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let driftClientUser: User; @@ -1397,7 +1396,7 @@ describe('orders', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: new BN(1000000), - oracleTwap5MinPercentDivergence: new BN(1000000), + oracleTwap5minPercentDivergence: new BN(1000000), }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/ordersWithSpread.ts b/tests/ordersWithSpread.ts index 0cc203d1d6..a6b84cebf3 100644 --- a/tests/ordersWithSpread.ts +++ b/tests/ordersWithSpread.ts @@ -1,24 +1,33 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { - TestClient, + AMM_RESERVE_PRECISION, BN, + EventSubscriber, PRICE_PRECISION, PositionDirection, + TestClient, User, - getMarketOrderParams, - AMM_RESERVE_PRECISION, - calculateTradeAcquiredAmounts, - convertToNumber, ZERO, - calculateQuoteAssetAmountSwapped, - EventSubscriber, calculateBaseAssetAmountForAmmToFulfill, + calculateQuoteAssetAmountSwapped, + calculateTradeAcquiredAmounts, + convertToNumber, + getMarketOrderParams, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { + OracleSource, + PEG_PRECISION, + calculateReservePrice, + getLimitOrderParams, + getSwapDirection, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, @@ -26,19 +35,9 @@ import { mockUserUSDCAccount, setFeedPriceNoProgram, } from './testHelpers'; -import { - calculateReservePrice, - getLimitOrderParams, - getSwapDirection, - OracleSource, - PEG_PRECISION, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('amm spread: market order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let driftClientUser: User; diff --git a/tests/overwritePerpAccounts.ts b/tests/overwritePerpAccounts.ts index f2863c5db0..c104c12dd8 100644 --- a/tests/overwritePerpAccounts.ts +++ b/tests/overwritePerpAccounts.ts @@ -1,36 +1,31 @@ import * as anchor from '@coral-xyz/anchor'; import { expect } from 'chai'; -import { Program } from '@coral-xyz/anchor'; + import { Keypair, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; +import dotenv from 'dotenv'; +import { startAnchor } from 'solana-bankrun'; import { BN, - TestClient, - QUOTE_PRECISION, - PRICE_PRECISION, - PEG_PRECISION, + DriftProgram, OracleSource, + PEG_PRECISION, + PRICE_PRECISION, + QUOTE_PRECISION, + TestClient, } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; import { initializeQuoteSpotMarket, + mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, - mockOracleNoProgram, overWritePerpMarket, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; -import { - CustomBorshAccountsCoder, - CustomBorshCoder, -} from '../sdk/src/decode/customCoder'; dotenv.config(); describe('Bankrun Overwrite Accounts', () => { - const program = anchor.workspace.Drift as Program; - // @ts-ignore - program.coder.accounts = new CustomBorshAccountsCoder(program.idl); + const program = anchor.workspace.Drift as DriftProgram; let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/pauseDepositWithdraw.ts b/tests/pauseDepositWithdraw.ts index bacd5192a6..010db6273f 100644 --- a/tests/pauseDepositWithdraw.ts +++ b/tests/pauseDepositWithdraw.ts @@ -1,46 +1,45 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, - SpotBalanceType, isVariant, + OracleInfo, OracleSource, - SPOT_MARKET_WEIGHT_PRECISION, SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, - OracleInfo, + SPOT_MARKET_RATE_PRECISION, + SPOT_MARKET_WEIGHT_PRECISION, + SpotBalanceType, + TestClient, } from '../sdk/src'; -import { - createUserWithUSDCAccount, - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - sleep, -} from './testHelpers'; -import { getBalance } from '../sdk/src/math/spotBalance'; import { createBurnInstruction, TOKEN_2022_PROGRAM_ID, } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; import { QUOTE_PRECISION, SPOT_MARKET_BALANCE_PRECISION, SpotOperation, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { getBalance } from '../sdk/src/math/spotBalance'; +import { + createUserWithUSDCAccount, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, + sleep, +} from './testHelpers'; describe('spot deposit and withdraw 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/pauseExchange.ts b/tests/pauseExchange.ts index e75c499ec8..789edea14a 100644 --- a/tests/pauseExchange.ts +++ b/tests/pauseExchange.ts @@ -1,29 +1,28 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { BN, QUOTE_SPOT_MARKET_INDEX } from '../sdk'; - -import { Program } from '@coral-xyz/anchor'; +import { BN, QUOTE_SPOT_MARKET_INDEX } from '../sdk/src'; import { - TestClient, - PRICE_PRECISION, - PositionDirection, ExchangeStatus, OracleSource, + PRICE_PRECISION, + PositionDirection, + TestClient, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { + initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, - initializeQuoteSpotMarket, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('Pause exchange', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/phoenixTest.ts b/tests/phoenixTest.ts index c3a9ca6741..bd46d71369 100644 --- a/tests/phoenixTest.ts +++ b/tests/phoenixTest.ts @@ -1,14 +1,13 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; import { + AccountInfo, + Connection, Keypair, - Transaction, PublicKey, SystemProgram, + Transaction, TransactionInstruction, - Connection, - AccountInfo, } from '@solana/web3.js'; import { @@ -20,17 +19,18 @@ import { import { BN, - TestClient, + DriftProgram, EventSubscriber, - OracleSource, OracleInfo, + OracleSource, + TestClient, } from '../sdk/src'; -import { - initializeQuoteSpotMarket, - initializeSolSpotMarket, - mockOracleNoProgram, -} from './testHelpers'; +import * as Phoenix from '@ellipsis-labs/phoenix-sdk'; +import { deserializeMarketData, TokenConfig } from '@ellipsis-labs/phoenix-sdk'; +import { BankrunProvider } from 'anchor-bankrun'; +import { assert } from 'chai'; +import { startAnchor } from 'solana-bankrun'; import { castNumberToSpotPrecision, getLimitOrderParams, @@ -40,20 +40,20 @@ import { PRICE_PRECISION, SpotBalanceType, Wallet, -} from '../sdk'; -import { deserializeMarketData, TokenConfig } from '@ellipsis-labs/phoenix-sdk'; -import * as Phoenix from '@ellipsis-labs/phoenix-sdk'; -import { assert } from 'chai'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { BankrunProvider } from 'anchor-bankrun'; import { - seatAccountData, - marketAccountData, baseVaultAccountData, + marketAccountData, quoteVaultAccountData, + seatAccountData, } from './phoenixTestAccountData'; +import { + initializeQuoteSpotMarket, + initializeSolSpotMarket, + mockOracleNoProgram, +} from './testHelpers'; const PHOENIX_MARKET: AccountInfo = { executable: false, @@ -227,7 +227,7 @@ const createTokenAccountAndMintTokens = async ( }; describe('phoenix spot market', () => { - const driftProgram = anchor.workspace.Drift as Program; + const driftProgram = anchor.workspace.Drift as DriftProgram; let phoenixClient: Phoenix.Client; @@ -599,7 +599,7 @@ describe('phoenix spot market', () => { assert( phoenixClient.quoteLotsToQuoteAtoms( phoenixMarketEnd.unclaimedQuoteLotFees - - phoenixMarketStart.unclaimedQuoteLotFees, + phoenixMarketStart.unclaimedQuoteLotFees, solMarketAddress.toBase58() ) === orderActionRecord.spotFulfillmentMethodFee.toNumber() ); @@ -768,7 +768,7 @@ describe('phoenix spot market', () => { assert( phoenixClient.quoteLotsToQuoteAtoms( phoenixMarketEnd.unclaimedQuoteLotFees - - phoenixMarketStart.unclaimedQuoteLotFees, + phoenixMarketStart.unclaimedQuoteLotFees, solMarketAddress.toBase58() ) === orderActionRecord.spotFulfillmentMethodFee.toNumber() ); diff --git a/tests/placeAndMakePerp.ts b/tests/placeAndMakePerp.ts index 4de0705c2e..d37ff68fc1 100644 --- a/tests/placeAndMakePerp.ts +++ b/tests/placeAndMakePerp.ts @@ -1,23 +1,26 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair } from '@solana/web3.js'; import { + BASE_PRECISION, BN, + EventSubscriber, + getLimitOrderParams, + OracleSource, + PositionDirection, PRICE_PRECISION, TestClient, - PositionDirection, User, Wallet, - EventSubscriber, - BASE_PRECISION, - getLimitOrderParams, - OracleSource, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { PEG_PRECISION, PerpOperation, PostOnlyParams } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, @@ -25,13 +28,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { PEG_PRECISION, PerpOperation, PostOnlyParams } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('place and make perp order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerDriftClientUser: User; diff --git a/tests/placeAndMakeSignedMsg.ts b/tests/placeAndMakeSignedMsg.ts index 4b686f4c63..ce1ba8d6f8 100644 --- a/tests/placeAndMakeSignedMsg.ts +++ b/tests/placeAndMakeSignedMsg.ts @@ -1,8 +1,6 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { ComputeBudgetProgram, Keypair, @@ -12,23 +10,27 @@ import { } from '@solana/web3.js'; import { + BASE_PRECISION, BN, - PRICE_PRECISION, - TestClient, - PositionDirection, - User, - Wallet, + BulkAccountLoader, EventSubscriber, - BASE_PRECISION, getLimitOrderParams, - OracleSource, - BulkAccountLoader, - SignedMsgOrderParamsMessage, - loadKeypair, getMarketOrderParams, + loadKeypair, MarketType, + OracleSource, + PositionDirection, + PRICE_PRECISION, + SignedMsgOrderParamsMessage, + TestClient, + User, + Wallet, } from '../sdk/src'; +import dotenv from 'dotenv'; +import { nanoid } from 'nanoid'; +import { PEG_PRECISION, PostOnlyParams } from '../sdk/src'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracle, @@ -36,9 +38,6 @@ import { mockUserUSDCAccount, sleep, } from './testHelpersLocalValidator'; -import { PEG_PRECISION, PostOnlyParams } from '../sdk/src'; -import dotenv from 'dotenv'; -import { nanoid } from 'nanoid'; dotenv.config(); describe('place and make signedMsg order', () => { @@ -52,7 +51,7 @@ describe('place and make signedMsg order', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerDriftClientUser: User; diff --git a/tests/placeAndMakeSignedMsgBankrun.ts b/tests/placeAndMakeSignedMsgBankrun.ts index 037319cbc9..a55070a640 100644 --- a/tests/placeAndMakeSignedMsgBankrun.ts +++ b/tests/placeAndMakeSignedMsgBankrun.ts @@ -1,8 +1,6 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { AccountInfo, AddressLookupTableAccount, @@ -19,60 +17,60 @@ import { } from '@solana/web3.js'; import { + BASE_PRECISION, BN, - PRICE_PRECISION, - TestClient, - PositionDirection, - User, - Wallet, + convertToNumber, EventSubscriber, - BASE_PRECISION, getLimitOrderParams, - OracleSource, - OrderTriggerCondition, - SignedMsgOrderParamsMessage, - MarketType, getMarketOrderParams, - SignedMsgOrderRecord, - getSignedMsgUserAccountPublicKey, - PYTH_LAZER_STORAGE_ACCOUNT_KEY, - PTYH_LAZER_PROGRAM_ID, - OrderType, - ZERO, - Order, getPythLazerOraclePublicKey, + getSignedMsgUserAccountPublicKey, getUserStatsAccountPublicKey, - UserStatsAccount, - convertToNumber, + MarketType, + OracleSource, + Order, OrderParams, - SignedMsgOrderParamsDelegateMessage, OrderParamsBitFlag, + OrderTriggerCondition, + OrderType, + PositionDirection, + PRICE_PRECISION, + PTYH_LAZER_PROGRAM_ID, + PYTH_LAZER_STORAGE_ACCOUNT_KEY, + SignedMsgOrderParamsDelegateMessage, + SignedMsgOrderParamsMessage, + SignedMsgOrderRecord, + TestClient, + User, + UserStatsAccount, + Wallet, + ZERO, } from '../sdk/src'; -import { - initializeQuoteSpotMarket, - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - sleep, -} from './testHelpers'; +import { createHash } from 'crypto'; +import dotenv from 'dotenv'; +import { nanoid } from 'nanoid'; +import { startAnchor } from 'solana-bankrun'; import { getTriggerLimitOrderParams, PEG_PRECISION, PostOnlyParams, } from '../sdk/src'; -import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; -import { nanoid } from 'nanoid'; -import { createHash } from 'crypto'; +import { DriftProgram } from '../sdk/src/config'; import { PYTH_LAZER_HEX_STRING_SOL, PYTH_LAZER_HEX_STRING_SOL_LATER, PYTH_STORAGE_DATA, } from './pythLazerData'; -import { Drift } from '../sdk/lib/browser/idl/drift'; +import { + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, + sleep, +} from './testHelpers'; dotenv.config(); @@ -85,7 +83,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('place and make signedMsg order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let slot: BN; @@ -1709,7 +1707,7 @@ describe('place and make signedMsg order', () => { async function initializeNewTakerClientAndUser( bankrunContextWrapper: BankrunContextWrapper, - chProgram: Program, + chProgram: DriftProgram, usdcMint: Keypair, usdcAmount: BN, marketIndexes: number[], diff --git a/tests/placeAndMakeSpotOrder.ts b/tests/placeAndMakeSpotOrder.ts index ad7f088dfa..4c03d2468a 100644 --- a/tests/placeAndMakeSpotOrder.ts +++ b/tests/placeAndMakeSpotOrder.ts @@ -1,23 +1,26 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, LAMPORTS_PER_SOL } from '@solana/web3.js'; import { - TestClient, + BASE_PRECISION, BN, - PRICE_PRECISION, - PositionDirection, - User, - Wallet, EventSubscriber, - BASE_PRECISION, getLimitOrderParams, OracleSource, + PositionDirection, + PRICE_PRECISION, + TestClient, + User, + Wallet, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { MARGIN_PRECISION, PostOnlyParams } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, initializeSolSpotMarket, @@ -26,13 +29,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { MARGIN_PRECISION, PostOnlyParams } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('place and make spot order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerDriftClientUser: User; diff --git a/tests/postOnly.ts b/tests/postOnly.ts index c4dd069295..53de381b52 100644 --- a/tests/postOnly.ts +++ b/tests/postOnly.ts @@ -1,28 +1,20 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair } from '@solana/web3.js'; import { - TestClient, BN, - PRICE_PRECISION, + EventSubscriber, + MarketStatus, PositionDirection, + PRICE_PRECISION, + TestClient, User, Wallet, - EventSubscriber, - MarketStatus, } from '../sdk/src'; -import { - initializeQuoteSpotMarket, - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - setFeedPriceNoProgram, -} from './testHelpers'; +import { startAnchor } from 'solana-bankrun'; import { BASE_PRECISION, calculateReservePrice, @@ -31,13 +23,20 @@ import { OracleSource, PostOnlyParams, ZERO, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, + setFeedPriceNoProgram, +} from './testHelpers'; describe('post only', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; diff --git a/tests/postOnlyAmmFulfillment.ts b/tests/postOnlyAmmFulfillment.ts index 2e7b1eab28..62777a62bc 100644 --- a/tests/postOnlyAmmFulfillment.ts +++ b/tests/postOnlyAmmFulfillment.ts @@ -1,28 +1,31 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair } from '@solana/web3.js'; import { - TestClient, - BN, - PRICE_PRECISION, - PositionDirection, - User, - Wallet, - EventSubscriber, - MarketStatus, BASE_PRECISION, + BN, calculateReservePrice, + EventSubscriber, getLimitOrderParams, isVariant, + MarketStatus, OracleSource, PEG_PRECISION, + PositionDirection, + PRICE_PRECISION, + TestClient, + User, + Wallet, ZERO, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { convertToNumber, PostOnlyParams } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, @@ -31,13 +34,9 @@ import { setFeedPriceNoProgram, sleep, } from './testHelpers'; -import { convertToNumber, PostOnlyParams } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('post only maker order w/ amm fulfillments', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; diff --git a/tests/prelisting.ts b/tests/prelisting.ts index c4c121b713..a6c9b0b668 100644 --- a/tests/prelisting.ts +++ b/tests/prelisting.ts @@ -1,38 +1,37 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { + BASE_PRECISION, BN, - PRICE_PRECISION, - TestClient, - PositionDirection, - User, EventSubscriber, - BASE_PRECISION, getLimitOrderParams, - OracleSource, getPrelaunchOraclePublicKey, + OracleSource, + PositionDirection, + PRICE_PRECISION, + TestClient, + User, } from '../sdk/src'; -import { - initializeQuoteSpotMarket, - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, -} from './testHelpers'; +import { startAnchor } from 'solana-bankrun'; import { BID_ASK_SPREAD_PRECISION, PEG_PRECISION, PostOnlyParams, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, +} from './testHelpers'; describe('prelisting', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let adminDriftClient: TestClient; let adminDriftClientUser: User; diff --git a/tests/prepegMarketOrderBaseAssetAmount.ts b/tests/prepegMarketOrderBaseAssetAmount.ts index eeaaddce95..3c77951a48 100644 --- a/tests/prepegMarketOrderBaseAssetAmount.ts +++ b/tests/prepegMarketOrderBaseAssetAmount.ts @@ -1,50 +1,48 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; import { + BASE_PRECISION, BN, + BulkAccountLoader, calculateEffectiveLeverage, + calculatePrice, + ContractTier, getMarketOrderParams, OracleSource, - ZERO, - calculatePrice, PEG_PRECISION, - BASE_PRECISION, - BulkAccountLoader, - ContractTier, -} from '../sdk'; - -import { Program } from '@coral-xyz/anchor'; + ZERO, +} from '../sdk/src'; import { PublicKey } from '@solana/web3.js'; import { - TestClient, - PRICE_PRECISION, + AMM_TO_QUOTE_PRECISION_RATIO, + calculateBidAskPrice, + calculateInventoryScale, calculateReservePrice, + calculateSpread, + calculateTradeAcquiredAmounts, calculateTradeSlippage, - PositionDirection, - EventSubscriber, + calculateUpdatedAMM, convertToNumber, + EventSubscriber, findComputeUnitConsumption, - calculateBidAskPrice, - calculateUpdatedAMM, - AMM_TO_QUOTE_PRECISION_RATIO, - calculateTradeAcquiredAmounts, - calculateSpread, - calculateInventoryScale, + PositionDirection, + PRICE_PRECISION, QUOTE_PRECISION, + TestClient, } from '../sdk/src'; +import { DriftProgram } from '../sdk/src/config'; +import { getOraclePriceFromMMOracleData } from '../sdk/src/oracles/utils'; import { getFeedData, + initializeQuoteSpotMarket, mockOracle, - mockUserUSDCAccount, mockUSDCMint, + mockUserUSDCAccount, setFeedPrice, - initializeQuoteSpotMarket, sleep, } from './testHelpers'; -import { getOraclePriceFromMMOracleData } from '../sdk/src/oracles/utils'; -import { Drift } from '../sdk/src/idl/drift'; describe('prepeg', () => { const provider = anchor.AnchorProvider.local(undefined, { @@ -54,7 +52,7 @@ describe('prepeg', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { diff --git a/tests/pyth.ts b/tests/pyth.ts index b138118046..5bc1eaa53c 100644 --- a/tests/pyth.ts +++ b/tests/pyth.ts @@ -1,36 +1,36 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { BASE_PRECISION, BN } from '../sdk'; +import { BASE_PRECISION, BN } from '../sdk/src'; import { + getFeedDataNoProgram, + initializeQuoteSpotMarket, + initUserAccounts, mockOracleNoProgram, - mockUserUSDCAccount, mockUSDCMint, + mockUserUSDCAccount, setFeedPriceNoProgram, - initializeQuoteSpotMarket, - initUserAccounts, - getFeedDataNoProgram, } from './testHelpers'; -import { Program } from '@coral-xyz/anchor'; import { Keypair, PublicKey } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; import { calculateReservePrice, - PEG_PRECISION, - PositionDirection, convertToNumber, + FUNDING_RATE_BUFFER_PRECISION, MarketStatus, + PEG_PRECISION, + PositionDirection, PRICE_PRECISION, - FUNDING_RATE_BUFFER_PRECISION, + QUOTE_SPOT_MARKET_INDEX, TestClient, User, - QUOTE_SPOT_MARKET_INDEX, } from '../sdk/src'; -import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; async function updateFundingRateHelper( driftClient: TestClient, @@ -66,7 +66,7 @@ async function updateFundingRateHelper( frontEndFundingCalc0, 'markTwap0:', ammAccountState0.lastMarkPriceTwap.toNumber() / - PRICE_PRECISION.toNumber(), + PRICE_PRECISION.toNumber(), 'markTwap0:', ammAccountState0.lastMarkPriceTwap.toNumber(), 'oracleTwap0(vamm):', @@ -160,7 +160,7 @@ async function updateFundingRateHelper( } describe('pyth-oracle', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let driftClient2: TestClient; diff --git a/tests/pythLazer.ts b/tests/pythLazer.ts index 792005a56d..6665cbf1e5 100644 --- a/tests/pythLazer.ts +++ b/tests/pythLazer.ts @@ -1,12 +1,5 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; -import { - BulkAccountLoader, - OracleSource, - TestClient, - assert, - getPythLazerOraclePublicKey, -} from '../sdk/src'; + import { PublicKey, Transaction, @@ -14,15 +7,25 @@ import { VersionedTransaction, } from '@solana/web3.js'; import { - initializeQuoteSpotMarket, - mockUSDCMint, -} from './testHelpersLocalValidator'; -import { Wallet, loadKeypair, EventSubscriber } from '../sdk/src'; + BulkAccountLoader, + EventSubscriber, + OracleSource, + TestClient, + Wallet, + assert, + getPythLazerOraclePublicKey, + loadKeypair, +} from '../sdk/src'; +import { DriftProgram } from '../sdk/src/config'; import { PYTH_LAZER_HEX_STRING_BTC, PYTH_LAZER_HEX_STRING_MULTI, PYTH_LAZER_HEX_STRING_SOL, } from './pythLazerData'; +import { + initializeQuoteSpotMarket, + mockUSDCMint, +} from './testHelpersLocalValidator'; describe('pyth lazer oracles', () => { const provider = anchor.AnchorProvider.local(undefined, { @@ -31,7 +34,7 @@ describe('pyth lazer oracles', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/pythLazerBankrun.ts b/tests/pythLazerBankrun.ts index a55f4e92b7..d295080bbb 100644 --- a/tests/pythLazerBankrun.ts +++ b/tests/pythLazerBankrun.ts @@ -1,5 +1,7 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; + +import { AccountInfo, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; import { BN, OracleSource, @@ -14,15 +16,17 @@ import { } from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { startAnchor } from 'solana-bankrun'; -import { AccountInfo, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; -import { initializeQuoteSpotMarket, mockUSDCMint } from './testHelpers'; +import { DriftProgram } from '../sdk/src/config'; import { PYTH_LAZER_HEX_STRING_MULTI, PYTH_LAZER_HEX_STRING_SOL, PYTH_STORAGE_DATA, } from './pythLazerData'; -import { mockOracleNoProgram } from './testHelpers'; +import { + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, +} from './testHelpers'; // set up account infos to load into banks client const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { @@ -34,7 +38,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('pyth pull oracles', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/pythPull.ts b/tests/pythPull.ts index 2761276ec4..607c855216 100644 --- a/tests/pythPull.ts +++ b/tests/pythPull.ts @@ -1,5 +1,8 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; + +import { DEFAULT_WORMHOLE_PROGRAM_ID } from '@pythnetwork/pyth-solana-receiver'; +import { AccountInfo, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; import { OracleSource, TestClient, @@ -7,9 +10,7 @@ import { } from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { startAnchor } from 'solana-bankrun'; -import { AccountInfo, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; -import { DEFAULT_WORMHOLE_PROGRAM_ID } from '@pythnetwork/pyth-solana-receiver'; +import { DriftProgram } from '../sdk/src/config'; import { WORMHOLE_DATA } from './pythPullOracleData'; import { initializeQuoteSpotMarket, mockUSDCMint } from './testHelpers'; @@ -27,7 +28,7 @@ const GUARDIAN_SET_KEY = new PublicKey( ); describe('pyth pull oracles', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/referencePriceOffset.ts b/tests/referencePriceOffset.ts index 5bfa89007e..21cd1b3aa1 100644 --- a/tests/referencePriceOffset.ts +++ b/tests/referencePriceOffset.ts @@ -1,27 +1,31 @@ import * as anchor from '@coral-xyz/anchor'; import { expect } from 'chai'; -import { Program } from '@coral-xyz/anchor'; + import { Keypair, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; +import dotenv from 'dotenv'; +import { startAnchor } from 'solana-bankrun'; import { - BN, - TestClient, - QUOTE_PRECISION, - OracleSource, - calculateBidAskPrice, - convertToNumber, BASE_PRECISION, + BN, DriftClient, - calculateReferencePriceOffset, + EventSubscriber, + OracleSource, + PEG_PRECISION, PERCENTAGE_PRECISION, - calculateInventoryLiquidityRatio, - sigNum, - calculatePrice, PRICE_PRECISION, PositionDirection, + QUOTE_PRECISION, + TestClient, + calculateBidAskPrice, + calculateInventoryLiquidityRatio, + calculatePrice, + calculateReferencePriceOffset, + convertToNumber, isVariant, - PEG_PRECISION, - EventSubscriber, + sigNum, } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; import { initializeQuoteSpotMarket, mockUSDCMint, @@ -29,14 +33,6 @@ import { overWritePerpMarket, placeAndFillVammTrade, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; -import { - CustomBorshAccountsCoder, - CustomBorshCoder, -} from '../sdk/src/decode/customCoder'; dotenv.config(); // 1MPEPE-PERP @@ -57,8 +53,6 @@ const usdcMintAmount = new BN(100_000_000).mul(QUOTE_PRECISION); describe('Reference Price Offset E2E', () => { const program = anchor.workspace.Drift as Program; - // @ts-ignore - program.coder.accounts = new CustomBorshAccountsCoder(program.idl); let bankrunContextWrapper: BankrunContextWrapper; let bulkAccountLoader: TestBulkAccountLoader; @@ -159,7 +153,6 @@ describe('Reference Price Offset E2E', () => { type: 'polling', accountLoader: bulkAccountLoader, }, - coder: new CustomBorshCoder(program.idl), }); await adminClient.initialize(usdcMint.publicKey, true); @@ -303,10 +296,10 @@ describe('Reference Price Offset E2E', () => { const sdkReferencePriceOffset = calculateReferencePriceOffset( reservePrice, - perpMarket2.amm.last24HAvgFundingRate, + perpMarket2.amm.last24hAvgFundingRate, liquidityFractionSigned, - perpMarket2.amm.historicalOracleData.lastOraclePriceTwap5Min, - perpMarket2.amm.lastMarkPriceTwap5Min, + perpMarket2.amm.historicalOracleData.lastOraclePriceTwap5min, + perpMarket2.amm.lastMarkPriceTwap5min, perpMarket2.amm.historicalOracleData.lastOraclePriceTwap, perpMarket2.amm.lastMarkPriceTwap, maxOffset @@ -358,10 +351,10 @@ describe('Reference Price Offset E2E', () => { // flip reference price more perpMarket2.amm.lastMarkPriceTwap = perpMarket2.amm.lastMarkPriceTwap.add(PRICE_PRECISION); - perpMarket2.amm.lastMarkPriceTwap5Min = - perpMarket2.amm.lastMarkPriceTwap5Min.add(PRICE_PRECISION); - perpMarket2.amm.last24HAvgFundingRate = - perpMarket2.amm.last24HAvgFundingRate.addn(100000); + perpMarket2.amm.lastMarkPriceTwap5min = + perpMarket2.amm.lastMarkPriceTwap5min.add(PRICE_PRECISION); + perpMarket2.amm.last24hAvgFundingRate = + perpMarket2.amm.last24hAvgFundingRate.addn(100000); await overWritePerpMarket( adminClient, @@ -619,7 +612,7 @@ describe('Reference Price Offset E2E', () => { }); const events = eventSubscriber.getEventsByTx(txSig); - const fillEvent = events.find((e) => e.eventType == 'OrderActionRecord'); + const fillEvent = events.find((e) => e.eventType == 'orderActionRecord'); const fillPrice = fillEvent['takerOrderCumulativeQuoteAssetAmountFilled'] .mul(PRICE_PRECISION) .mul(BASE_PRECISION.div(QUOTE_PRECISION)) diff --git a/tests/referrer.ts b/tests/referrer.ts index 1e3b381425..a893f0cdbc 100644 --- a/tests/referrer.ts +++ b/tests/referrer.ts @@ -1,41 +1,40 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, PublicKey } from '@solana/web3.js'; import { - TestClient, BN, - OracleSource, EventSubscriber, - Wallet, + OracleSource, PRICE_PRECISION, ReferrerStatus, + TestClient, + Wallet, } from '../sdk/src'; -import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - initializeQuoteSpotMarket, - createFundedKeyPair, - createUserWithUSDCAccount, -} from './testHelpers'; +import { startAnchor } from 'solana-bankrun'; import { BASE_PRECISION, getMarketOrderParams, PEG_PRECISION, PositionDirection, } from '../sdk/src'; -import { decodeName } from '../sdk/src/userName'; -import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { decodeName } from '../sdk/src/userName'; +import { + createFundedKeyPair, + createUserWithUSDCAccount, + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, +} from './testHelpers'; describe('referrer', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let referrerDriftClient: TestClient; @@ -220,7 +219,7 @@ describe('referrer', () => { await eventSubscriber.awaitTx(txSig); - const newUserRecord = eventSubscriber.getEventsArray('NewUserRecord')[0]; + const newUserRecord = eventSubscriber.getEventsArray('newUserRecord')[0]; assert( newUserRecord.referrer.equals( bankrunContextWrapper.provider.wallet.publicKey diff --git a/tests/repegAndSpread.ts b/tests/repegAndSpread.ts index 8c1208929c..f892b5c2d9 100644 --- a/tests/repegAndSpread.ts +++ b/tests/repegAndSpread.ts @@ -1,55 +1,55 @@ import * as anchor from '@coral-xyz/anchor'; +import { Keypair } from '@solana/web3.js'; import { assert } from 'chai'; import { + BASE_PRECISION, + BID_ASK_SPREAD_PRECISION, BN, + BulkAccountLoader, calculatePrice, + ContractTier, + getLimitOrderParams, getMarketOrderParams, + getTokenAmount, + OracleGuardRails, + OraclePriceData, OracleSource, - BID_ASK_SPREAD_PRECISION, PEG_PRECISION, + PERCENTAGE_PRECISION, QUOTE_SPOT_MARKET_INDEX, - getTokenAmount, SpotBalanceType, - ZERO, - getLimitOrderParams, TestClient, - OraclePriceData, - OracleGuardRails, - BASE_PRECISION, - BulkAccountLoader, - PERCENTAGE_PRECISION, - ContractTier, -} from '../sdk'; -import { Keypair } from '@solana/web3.js'; -import { Program } from '@coral-xyz/anchor'; + ZERO, +} from '../sdk/src'; import { - User, // PRICE_PRECISION, AMM_RESERVE_PRECISION, - QUOTE_PRECISION, - // calculateReservePrice, - PositionDirection, - EventSubscriber, - convertToNumber, calculateBidAskPrice, - calculateUpdatedAMM, - calculateSpread, - calculateSpreadBN, - calculateInventoryScale, calculateEffectiveLeverage, + calculateInventoryScale, calculateLiveOracleStd, + calculateSpread, + calculateSpreadBN, + calculateUpdatedAMM, + convertToNumber, + EventSubscriber, + // calculateReservePrice, + PositionDirection, + QUOTE_PRECISION, + User, } from '../sdk/src'; +import { DriftProgram } from '../sdk/src/config'; import { getFeedData, + getOraclePriceData, + initializeQuoteSpotMarket, initUserAccounts, mockOracle, - mockUserUSDCAccount, mockUSDCMint, + mockUserUSDCAccount, setFeedPrice, - getOraclePriceData, - initializeQuoteSpotMarket, } from './testHelpers'; async function depositToFeePoolFromIF( @@ -136,7 +136,7 @@ describe('repeg and spread amm', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { @@ -269,7 +269,7 @@ describe('repeg and spread amm', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION, - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION, + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION, }, validity: { slotsBeforeStaleForAmm: new BN(100), @@ -286,7 +286,7 @@ describe('repeg and spread amm', () => { assert( JSON.stringify(oracleGuardRails) === - JSON.stringify(state.oracleGuardRails) + JSON.stringify(state.oracleGuardRails) ); const marketIndex = 0; @@ -342,7 +342,7 @@ describe('repeg and spread amm', () => { console.log( 'market0.amm.totalFeeMinusDistributions:', market0.amm.totalFeeMinusDistributions.toNumber() / - QUOTE_PRECISION.toNumber() + QUOTE_PRECISION.toNumber() ); console.log( 'market0.amm.pegMultiplier:', @@ -455,7 +455,7 @@ describe('repeg and spread amm', () => { liveOracleStd, prepegAMM.longIntensityVolume, prepegAMM.shortIntensityVolume, - prepegAMM.volume24H + prepegAMM.volume24h ); console.log('spreads:', ls1, ss1); const maxSpread = market0.amm.maxSpread; @@ -1010,9 +1010,9 @@ describe('repeg and spread amm', () => { const moneyMissing = Math.abs( allUserCollateral + - pnlPoolBalance + - feePoolBalance - - (usdcDepositBalance - usdcBorrowBalance) + pnlPoolBalance + + feePoolBalance - + (usdcDepositBalance - usdcBorrowBalance) ); console.log('moneyMissing:', moneyMissing); @@ -1030,8 +1030,8 @@ describe('repeg and spread amm', () => { // must be less assert( allUserUnsettledPnl + - (sinceStartTFMD - (pnlPoolBalance + feePoolBalance)) < - 0 + (sinceStartTFMD - (pnlPoolBalance + feePoolBalance)) < + 0 ); }); }); diff --git a/tests/resizeSwiftUserOrderIds.ts b/tests/resizeSwiftUserOrderIds.ts index 2f191c111f..0537079f36 100644 --- a/tests/resizeSwiftUserOrderIds.ts +++ b/tests/resizeSwiftUserOrderIds.ts @@ -1,21 +1,25 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, PublicKey } from '@solana/web3.js'; import { BN, + EventSubscriber, + OracleSource, PRICE_PRECISION, TestClient, User, Wallet, - EventSubscriber, - OracleSource, getSignedMsgUserAccountPublicKey, } from '../sdk/src'; +import dotenv from 'dotenv'; +import { startAnchor } from 'solana-bankrun'; +import { PEG_PRECISION } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, @@ -23,15 +27,10 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { PEG_PRECISION } from '../sdk/src'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; dotenv.config(); describe('place and make signedMsg order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerDriftClientUser: User; diff --git a/tests/roundInFavorBaseAsset.ts b/tests/roundInFavorBaseAsset.ts index 7887e69a0a..596b432e1b 100644 --- a/tests/roundInFavorBaseAsset.ts +++ b/tests/roundInFavorBaseAsset.ts @@ -4,29 +4,28 @@ import { BASE_PRECISION, BN, getMarketOrderParams, - OracleSource, - Wallet, MarketStatus, - TestClient, + OracleSource, PositionDirection, + TestClient, + Wallet, } from '../sdk/src'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('round in favor', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/serumTest.ts b/tests/serumTest.ts index 8075e8befb..01709abc37 100644 --- a/tests/serumTest.ts +++ b/tests/serumTest.ts @@ -1,25 +1,30 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, PublicKey, Transaction } from '@solana/web3.js'; -import { listMarket, makePlaceOrderTransaction, SERUM } from './serumHelper'; import { BN, - TestClient, - EventSubscriber, - OracleSource, - OracleInfo, - PositionDirection, castNumberToSpotPrecision, + EventSubscriber, getLimitOrderParams, getTokenAmount, isVariant, + OracleInfo, + OracleSource, + PositionDirection, PRICE_PRECISION, SpotBalanceType, + TestClient, } from '../sdk/src'; +import { listMarket, makePlaceOrderTransaction, SERUM } from './serumHelper'; +import { Market } from '@project-serum/serum'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { getMarketOrderParams, ZERO } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, @@ -29,15 +34,9 @@ import { mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { Market } from '@project-serum/serum'; -import { getMarketOrderParams, ZERO } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('serum spot market', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerWSOL: PublicKey; diff --git a/tests/settlePNLInvariant.ts b/tests/settlePNLInvariant.ts index 6d66906fa9..abeacd1d74 100644 --- a/tests/settlePNLInvariant.ts +++ b/tests/settlePNLInvariant.ts @@ -1,23 +1,36 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, + OracleInfo, + OracleSource, + SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, SPOT_MARKET_RATE_PRECISION, + SPOT_MARKET_WEIGHT_PRECISION, SpotBalanceType, + TestClient, isVariant, - OracleSource, - SPOT_MARKET_WEIGHT_PRECISION, - SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, - OracleInfo, } from '../sdk/src'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { + BASE_PRECISION, + PEG_PRECISION, + PRICE_PRECISION, + PositionDirection, + QUOTE_PRECISION, + SPOT_MARKET_BALANCE_PRECISION, + ZERO, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { getBalance } from '../sdk/src/math/spotBalance'; import { createUserWithUSDCAccount, createUserWithUSDCAndWSOLAccount, @@ -26,23 +39,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { getBalance } from '../sdk/src/math/spotBalance'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { - QUOTE_PRECISION, - ZERO, - SPOT_MARKET_BALANCE_PRECISION, - PRICE_PRECISION, - PositionDirection, - BASE_PRECISION, - PEG_PRECISION, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; @@ -251,7 +250,7 @@ describe('spot deposit and withdraw', () => { ) ); assert( - spotMarket.historicalOracleData.lastOraclePriceTwap5Min.eq( + spotMarket.historicalOracleData.lastOraclePriceTwap5min.eq( new BN(30 * PRICE_PRECISION.toNumber()) ) ); @@ -345,7 +344,7 @@ describe('spot deposit and withdraw', () => { ) ); assert( - spotMarket.historicalOracleData.lastOraclePriceTwap5Min.eq( + spotMarket.historicalOracleData.lastOraclePriceTwap5min.eq( new BN(30 * PRICE_PRECISION.toNumber()) ) ); @@ -416,7 +415,7 @@ describe('spot deposit and withdraw', () => { assert(quoteTokenAmount.eq(new BN(-30003))); - const settlePnlRecord = eventSubscriber.getEventsArray('SettlePnlRecord'); + const settlePnlRecord = eventSubscriber.getEventsArray('settlePnlRecord'); assert(settlePnlRecord.length === 1); assert(settlePnlRecord[0].pnl.eq(new BN(-30002))); }); diff --git a/tests/signedMsgWsDelegates.ts b/tests/signedMsgWsDelegates.ts index efabd78047..52b380b462 100644 --- a/tests/signedMsgWsDelegates.ts +++ b/tests/signedMsgWsDelegates.ts @@ -1,7 +1,5 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; - import { AccountInfo, Keypair, @@ -10,20 +8,21 @@ import { } from '@solana/web3.js'; import { - TestClient, OracleSource, - PYTH_LAZER_STORAGE_ACCOUNT_KEY, PTYH_LAZER_PROGRAM_ID, - getSignedMsgWsDelegatesAccountPublicKey, + PYTH_LAZER_STORAGE_ACCOUNT_KEY, + TestClient, assert, + getSignedMsgWsDelegatesAccountPublicKey, } from '../sdk/src'; -import { mockOracleNoProgram } from './testHelpers'; +import dotenv from 'dotenv'; import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import dotenv from 'dotenv'; +import { DriftProgram } from '../sdk/src/config'; import { PYTH_STORAGE_DATA } from './pythLazerData'; +import { mockOracleNoProgram } from './testHelpers'; dotenv.config(); @@ -36,7 +35,7 @@ const PYTH_STORAGE_ACCOUNT_INFO: AccountInfo = { }; describe('place and make signedMsg order', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; diff --git a/tests/spotDepositWithdraw.ts b/tests/spotDepositWithdraw.ts index 7bbd15efb5..0f23acded6 100644 --- a/tests/spotDepositWithdraw.ts +++ b/tests/spotDepositWithdraw.ts @@ -1,23 +1,38 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, - SpotBalanceType, isVariant, + OracleInfo, OracleSource, - SPOT_MARKET_WEIGHT_PRECISION, SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, - OracleInfo, + SPOT_MARKET_RATE_PRECISION, + SPOT_MARKET_WEIGHT_PRECISION, + SpotBalanceType, + TestClient, } from '../sdk/src'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { + ONE, + PRICE_PRECISION, + QUOTE_PRECISION, + SPOT_MARKET_BALANCE_PRECISION, + ZERO, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + calculateInterestAccumulated, + getBalance, + getTokenAmount, +} from '../sdk/src/math/spotBalance'; import { createUserWithUSDCAccount, createUserWithUSDCAndWSOLAccount, @@ -27,25 +42,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { - getBalance, - calculateInterestAccumulated, - getTokenAmount, -} from '../sdk/src/math/spotBalance'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { - QUOTE_PRECISION, - ZERO, - ONE, - SPOT_MARKET_BALANCE_PRECISION, - PRICE_PRECISION, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; @@ -255,7 +254,7 @@ describe('spot deposit and withdraw', () => { ) ); assert( - spotMarket.historicalOracleData.lastOraclePriceTwap5Min.eq( + spotMarket.historicalOracleData.lastOraclePriceTwap5min.eq( new BN(30 * PRICE_PRECISION.toNumber()) ) ); @@ -352,7 +351,7 @@ describe('spot deposit and withdraw', () => { ) ); assert( - spotMarket.historicalOracleData.lastOraclePriceTwap5Min.eq( + spotMarket.historicalOracleData.lastOraclePriceTwap5min.eq( new BN(30 * PRICE_PRECISION.toNumber()) ) ); @@ -624,9 +623,9 @@ describe('spot deposit and withdraw', () => { newSpotMarketAccount.cumulativeBorrowInterest .sub(ONE) .eq(expectedCumulativeBorrowInterest) || - newSpotMarketAccount.cumulativeBorrowInterest.eq( - expectedCumulativeBorrowInterest - ) + newSpotMarketAccount.cumulativeBorrowInterest.eq( + expectedCumulativeBorrowInterest + ) ); }); diff --git a/tests/spotDepositWithdraw22.ts b/tests/spotDepositWithdraw22.ts index 7389f90754..ddf181d5a2 100644 --- a/tests/spotDepositWithdraw22.ts +++ b/tests/spotDepositWithdraw22.ts @@ -1,23 +1,38 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, - SpotBalanceType, isVariant, + OracleInfo, OracleSource, - SPOT_MARKET_WEIGHT_PRECISION, SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, - OracleInfo, + SPOT_MARKET_RATE_PRECISION, + SPOT_MARKET_WEIGHT_PRECISION, + SpotBalanceType, + TestClient, } from '../sdk/src'; +import { NATIVE_MINT, TOKEN_2022_PROGRAM_ID } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { + ONE, + PRICE_PRECISION, + QUOTE_PRECISION, + SPOT_MARKET_BALANCE_PRECISION, + ZERO, +} from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + calculateInterestAccumulated, + getBalance, + getTokenAmount, +} from '../sdk/src/math/spotBalance'; import { createUserWithUSDCAccount, createUserWithUSDCAndWSOLAccount, @@ -27,25 +42,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { - getBalance, - calculateInterestAccumulated, - getTokenAmount, -} from '../sdk/src/math/spotBalance'; -import { NATIVE_MINT, TOKEN_2022_PROGRAM_ID } from '@solana/spl-token'; -import { - QUOTE_PRECISION, - ZERO, - ONE, - SPOT_MARKET_BALANCE_PRECISION, - PRICE_PRECISION, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; @@ -267,7 +266,7 @@ describe('spot deposit and withdraw 22', () => { ) ); assert( - spotMarket.historicalOracleData.lastOraclePriceTwap5Min.eq( + spotMarket.historicalOracleData.lastOraclePriceTwap5min.eq( new BN(30 * PRICE_PRECISION.toNumber()) ) ); @@ -364,7 +363,7 @@ describe('spot deposit and withdraw 22', () => { ) ); assert( - spotMarket.historicalOracleData.lastOraclePriceTwap5Min.eq( + spotMarket.historicalOracleData.lastOraclePriceTwap5min.eq( new BN(30 * PRICE_PRECISION.toNumber()) ) ); @@ -636,9 +635,9 @@ describe('spot deposit and withdraw 22', () => { newSpotMarketAccount.cumulativeBorrowInterest .sub(ONE) .eq(expectedCumulativeBorrowInterest) || - newSpotMarketAccount.cumulativeBorrowInterest.eq( - expectedCumulativeBorrowInterest - ) + newSpotMarketAccount.cumulativeBorrowInterest.eq( + expectedCumulativeBorrowInterest + ) ); }); diff --git a/tests/spotDepositWithdraw22ScaledUI.ts b/tests/spotDepositWithdraw22ScaledUI.ts index d267b44211..33d2793481 100644 --- a/tests/spotDepositWithdraw22ScaledUI.ts +++ b/tests/spotDepositWithdraw22ScaledUI.ts @@ -1,6 +1,5 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; import { Keypair, @@ -11,45 +10,46 @@ import { } from '@solana/web3.js'; import { + createInitializeAccountInstruction, + createInitializeScaledUiAmountConfigInstruction, createMintToInstruction, createTransferCheckedInstruction, getAccount, - createInitializeAccountInstruction, getAccountLenForMint, - createInitializeScaledUiAmountConfigInstruction, } from '@solana/spl-token'; import { - TestClient, BN, - OracleSource, + getTokenAmount, OracleInfo, + OracleSource, + QUOTE_PRECISION, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, - QUOTE_PRECISION, - getTokenAmount, + TestClient, } from '../sdk/src'; import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - createUserWithUSDCAccount, - initializeQuoteSpotMarket, -} from './testHelpers'; -import { - getMint, - TOKEN_2022_PROGRAM_ID, createInitializeMintInstruction, ExtensionType, + getMint, getMintLen, + TOKEN_2022_PROGRAM_ID, } from '@solana/spl-token'; import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + createUserWithUSDCAccount, + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, +} from './testHelpers'; describe('spot deposit and withdraw 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let firstUserKeypair: Keypair; let firstUserDriftClient: TestClient; diff --git a/tests/spotDepositWithdraw22TransferHooks.ts b/tests/spotDepositWithdraw22TransferHooks.ts index 5ebc3ff894..f2d595e58a 100644 --- a/tests/spotDepositWithdraw22TransferHooks.ts +++ b/tests/spotDepositWithdraw22TransferHooks.ts @@ -1,6 +1,5 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; import { Keypair, @@ -11,56 +10,57 @@ import { } from '@solana/web3.js'; import { + addExtraAccountMetasForExecute, + createInitializeAccountInstruction, createMintToInstruction, createTransferCheckedInstruction, + createUpdateTransferHookInstruction, getAccount, - addExtraAccountMetasForExecute, - createInitializeAccountInstruction, getAccountLenForMint, - createUpdateTransferHookInstruction, } from '@solana/spl-token'; import { - TestClient, BN, - OracleSource, + getTokenAmount, OracleInfo, + OracleSource, + QUOTE_PRECISION, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, - QUOTE_PRECISION, - getTokenAmount, + TestClient, } from '../sdk/src'; import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - createUserWithUSDCAccount, - initializeQuoteSpotMarket, -} from './testHelpers'; -import { - getMint, - TOKEN_2022_PROGRAM_ID, createInitializeMintInstruction, createInitializeTransferHookInstruction, ExtensionType, + getExtraAccountMetaAddress, + getExtraAccountMetas, + getMint, getMintLen, getTransferHook, - getExtraAccountMetas, - getExtraAccountMetaAddress, resolveExtraAccountMeta, + TOKEN_2022_PROGRAM_ID, } from '@solana/spl-token'; import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeExtraAccountMetaList } from './splTransferHookClient'; +import { + createUserWithUSDCAccount, + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, +} from './testHelpers'; const transferHookProgramId = new PublicKey( '4qXcCexy21qw66VgPqZjVyL9PTHsB6CdbSCZsDTac6Qq' ); describe('spot deposit and withdraw 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let firstUserKeypair: Keypair; let firstUserDriftClient: TestClient; diff --git a/tests/spotMarketPoolIds.ts b/tests/spotMarketPoolIds.ts index 90a2141338..ca5a936312 100644 --- a/tests/spotMarketPoolIds.ts +++ b/tests/spotMarketPoolIds.ts @@ -1,21 +1,24 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, + MarketStatus, + OracleInfo, OracleSource, + SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, - OracleInfo, - MarketStatus, + TestClient, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { QUOTE_PRECISION } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAccount, mockOracleNoProgram, @@ -23,13 +26,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { QUOTE_PRECISION } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/spotSwap.ts b/tests/spotSwap.ts index 7f7e0241c1..9faaff733e 100644 --- a/tests/spotSwap.ts +++ b/tests/spotSwap.ts @@ -1,8 +1,6 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Account, Keypair, @@ -14,20 +12,27 @@ import { listMarket, makePlaceOrderTransaction, SERUM } from './serumHelper'; import { BN, - TestClient, EventSubscriber, - OracleSource, - OracleInfo, - getTokenAmount, - SpotBalanceType, - ZERO, + FUEL_WINDOW, getSerumSignerPublicKey, + getTokenAmount, + getUserStatsAccountPublicKey, + OracleInfo, + OracleSource, QUOTE_PRECISION, + SpotBalanceType, + TestClient, UserStatsAccount, - getUserStatsAccountPublicKey, - FUEL_WINDOW, + ZERO, } from '../sdk/src'; +import { DexInstructions, Market, OpenOrders } from '@project-serum/serum'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { DRIFT_PROGRAM_ID } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, @@ -37,16 +42,9 @@ import { mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { DexInstructions, Market, OpenOrders } from '@project-serum/serum'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { DRIFT_PROGRAM_ID } from '../sdk/src'; -import { Drift } from '../sdk/src/idl/drift'; describe('spot swap', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerWSOL: PublicKey; @@ -406,9 +404,9 @@ describe('spot swap', () => { const userStatsAccount = accountInfo ? (takerDriftClient.program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', - accountInfo.data - ) as UserStatsAccount) + 'userStats', + accountInfo.data + ) as UserStatsAccount) : undefined; // assert(userStatsAccount.fuelDeposits === 2000); @@ -424,9 +422,9 @@ describe('spot swap', () => { ); const _userStatsAccount2 = accountInfo2 ? (takerDriftClient.program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', - accountInfo2.data - ) as UserStatsAccount) + 'userStats', + accountInfo2.data + ) as UserStatsAccount) : undefined; // console.log(userStatsAccount2.fuelDeposits.toString()); @@ -444,9 +442,9 @@ describe('spot swap', () => { ); const _userStatsAccount3 = accountInfo3 ? (takerDriftClient.program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', - accountInfo3.data - ) as UserStatsAccount) + 'userStats', + accountInfo3.data + ) as UserStatsAccount) : undefined; // console.log(userStatsAccount3.fuelDeposits.toString()); diff --git a/tests/spotSwap22.ts b/tests/spotSwap22.ts index b5cb1c65a3..c0395e0fc9 100644 --- a/tests/spotSwap22.ts +++ b/tests/spotSwap22.ts @@ -1,8 +1,6 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, LAMPORTS_PER_SOL, @@ -12,15 +10,25 @@ import { import { BN, - TestClient, EventSubscriber, - OracleSource, OracleInfo, + OracleSource, QUOTE_PRECISION, + TestClient, UserStatsAccount, getUserStatsAccountPublicKey, } from '../sdk/src'; +import { + TOKEN_2022_PROGRAM_ID, + TOKEN_PROGRAM_ID, + createTransferInstruction, +} from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { DRIFT_PROGRAM_ID } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAndWSOLAccount, createWSolTokenAccountForUser, @@ -30,18 +38,9 @@ import { mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { - TOKEN_2022_PROGRAM_ID, - TOKEN_PROGRAM_ID, - createTransferInstruction, -} from '@solana/spl-token'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { DRIFT_PROGRAM_ID } from '../sdk/src'; describe('spot swap 22', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let makerDriftClient: TestClient; let makerWSOL: PublicKey; @@ -236,14 +235,14 @@ describe('spot swap 22', () => { const userStatsAccount = accountInfo ? (takerDriftClient.program.account.user.coder.accounts.decodeUnchecked( - 'UserStats', - accountInfo.data - ) as UserStatsAccount) + 'userStats', + accountInfo.data + ) as UserStatsAccount) : undefined; assert(userStatsAccount.takerVolume30D.eq(new BN(0))); - const swapRecord = eventSubscriber.getEventsArray('SwapRecord')[0]; + const swapRecord = eventSubscriber.getEventsArray('swapRecord')[0]; assert(swapRecord.amountOut.eq(new BN(1000000000))); assert(swapRecord.outMarketIndex === 1); assert(swapRecord.amountIn.eq(new BN(100000000))); @@ -302,7 +301,7 @@ describe('spot swap 22', () => { console.log(takerUSDCAmount.toString()); assert(takerUSDCAmount.eq(new BN(199999999))); - const swapRecord = eventSubscriber.getEventsArray('SwapRecord')[0]; + const swapRecord = eventSubscriber.getEventsArray('swapRecord')[0]; assert(swapRecord.amountOut.eq(new BN(100000000))); assert(swapRecord.outMarketIndex === 0); assert(swapRecord.amountIn.eq(new BN(1000000000))); diff --git a/tests/spotWithdrawUtil100.ts b/tests/spotWithdrawUtil100.ts index d0c2a45853..a0bbb80623 100644 --- a/tests/spotWithdrawUtil100.ts +++ b/tests/spotWithdrawUtil100.ts @@ -1,35 +1,45 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; -import { setFeedPriceNoProgram } from './testHelpers'; import { PublicKey } from '@solana/web3.js'; import { - PositionDirection, - User, BASE_PRECISION, getLimitOrderParams, + PositionDirection, PostOnlyParams, + User, } from '../sdk/src'; +import { setFeedPriceNoProgram } from './testHelpers'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, - SpotBalanceType, isVariant, - OracleSource, - SPOT_MARKET_WEIGHT_PRECISION, - SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, + ONE, OracleInfo, + OracleSource, + PRICE_PRECISION, QUOTE_PRECISION, - ZERO, - ONE, SPOT_MARKET_BALANCE_PRECISION, - PRICE_PRECISION, + SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, + SPOT_MARKET_RATE_PRECISION, + SPOT_MARKET_WEIGHT_PRECISION, + SpotBalanceType, + TestClient, + ZERO, } from '../sdk/src'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { ContractTier } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + calculateInterestAccumulated, + calculateUtilization, + getBalance, +} from '../sdk/src/math/spotBalance'; import { createUserWithUSDCAccount, createUserWithUSDCAndWSOLAccount, @@ -38,19 +48,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { - getBalance, - calculateInterestAccumulated, - calculateUtilization, -} from '../sdk/src/math/spotBalance'; -import { NATIVE_MINT } from '@solana/spl-token'; -import { ContractTier } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('test function when spot market at >= 100% util', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; @@ -290,7 +290,7 @@ describe('test function when spot market at >= 100% util', () => { ) ); assert( - spotMarket.historicalOracleData.lastOraclePriceTwap5Min.eq( + spotMarket.historicalOracleData.lastOraclePriceTwap5min.eq( new BN(30 * PRICE_PRECISION.toNumber()) ) ); @@ -387,7 +387,7 @@ describe('test function when spot market at >= 100% util', () => { ) ); assert( - spotMarket.historicalOracleData.lastOraclePriceTwap5Min.eq( + spotMarket.historicalOracleData.lastOraclePriceTwap5min.eq( new BN(30 * PRICE_PRECISION.toNumber()) ) ); @@ -501,9 +501,9 @@ describe('test function when spot market at >= 100% util', () => { newSpotMarketAccount.cumulativeBorrowInterest .sub(ONE) .eq(expectedCumulativeBorrowInterest) || - newSpotMarketAccount.cumulativeBorrowInterest.eq( - expectedCumulativeBorrowInterest - ) + newSpotMarketAccount.cumulativeBorrowInterest.eq( + expectedCumulativeBorrowInterest + ) ); }); @@ -551,9 +551,9 @@ describe('test function when spot market at >= 100% util', () => { newSpotMarketAccount.cumulativeBorrowInterest .sub(ONE) .eq(expectedCumulativeBorrowInterest) || - newSpotMarketAccount.cumulativeBorrowInterest.eq( - expectedCumulativeBorrowInterest - ) + newSpotMarketAccount.cumulativeBorrowInterest.eq( + expectedCumulativeBorrowInterest + ) ); }); diff --git a/tests/stopLimits.ts b/tests/stopLimits.ts index aff53155ac..010fd3d0ec 100644 --- a/tests/stopLimits.ts +++ b/tests/stopLimits.ts @@ -1,43 +1,47 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, PublicKey, Transaction } from '@solana/web3.js'; import { - TestClient, BN, + EventSubscriber, + MarketStatus, + OrderTriggerCondition, PRICE_PRECISION, PositionDirection, + TestClient, User, Wallet, getMarketOrderParams, - OrderTriggerCondition, getTriggerLimitOrderParams, - EventSubscriber, - MarketStatus, } from '../sdk/src'; -import { - initializeQuoteSpotMarket, - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - setFeedPriceNoProgram, -} from './testHelpers'; -import { AMM_RESERVE_PRECISION, OracleSource, ZERO, isVariant } from '../sdk'; import { createAssociatedTokenAccountIdempotentInstruction, createMintToInstruction, getAssociatedTokenAddressSync, } from '@solana/spl-token'; import { startAnchor } from 'solana-bankrun'; +import { + AMM_RESERVE_PRECISION, + OracleSource, + ZERO, + isVariant, +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, + setFeedPriceNoProgram, +} from './testHelpers'; describe('stop limit', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let driftClientUser: User; diff --git a/tests/subaccounts.ts b/tests/subaccounts.ts index c4260f1ce4..cc7982bdca 100644 --- a/tests/subaccounts.ts +++ b/tests/subaccounts.ts @@ -1,40 +1,39 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; - import { + BN, + EventSubscriber, + fetchUserAccounts, getUserAccountPublicKey, isVariant, QUOTE_SPOT_MARKET_INDEX, TestClient, - BN, - EventSubscriber, - fetchUserAccounts, } from '../sdk/src'; -import { - createFundedKeyPair, - initializeQuoteSpotMarket, - initializeSolSpotMarket, - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, -} from './testHelpers'; -import { decodeName } from '../sdk/src/userName'; +import { PublicKey } from '@solana/web3.js'; import { assert } from 'chai'; +import { startAnchor } from 'solana-bankrun'; import { getTokenAmount, LAMPORTS_PRECISION, MARGIN_PRECISION, SpotBalanceType, -} from '../sdk'; -import { PublicKey } from '@solana/web3.js'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { decodeName } from '../sdk/src/userName'; +import { + createFundedKeyPair, + initializeQuoteSpotMarket, + initializeSolSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, +} from './testHelpers'; describe('subaccounts', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -204,7 +203,7 @@ describe('subaccounts', () => { assert(driftClient.getQuoteAssetTokenAmount().eq(usdcAmount)); await eventSubscriber.awaitTx(txSig); - const depositRecords = eventSubscriber.getEventsArray('DepositRecord'); + const depositRecords = eventSubscriber.getEventsArray('depositRecord'); const toUser = await getUserAccountPublicKey( chProgram.programId, diff --git a/tests/surgePricing.ts b/tests/surgePricing.ts index a553d21b34..498103ef7b 100644 --- a/tests/surgePricing.ts +++ b/tests/surgePricing.ts @@ -1,21 +1,25 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, + OracleInfo, OracleSource, - SPOT_MARKET_WEIGHT_PRECISION, SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION, - OracleInfo, + SPOT_MARKET_RATE_PRECISION, + SPOT_MARKET_WEIGHT_PRECISION, + TestClient, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { QUOTE_PRECISION, getUserAccountPublicKey } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { calculateInitUserFee } from '../sdk/src/math/state'; import { createUserWithUSDCAccount, mockOracleNoProgram, @@ -23,14 +27,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { QUOTE_PRECISION, getUserAccountPublicKey } from '../sdk/src'; -import { calculateInitUserFee } from '../sdk/src/math/state'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('surge pricing', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/switchOracle.ts b/tests/switchOracle.ts index 11a2631161..b9200e2590 100644 --- a/tests/switchOracle.ts +++ b/tests/switchOracle.ts @@ -1,18 +1,24 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { PublicKey } from '@solana/web3.js'; import { - TestClient, BN, + DriftClient, EventSubscriber, - OracleSource, OracleInfo, + OracleSource, + PEG_PRECISION, + PRICE_PRECISION, + TestClient, + Wallet, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createFundedKeyPair, createUserWithUSDCAccount, @@ -23,13 +29,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { PRICE_PRECISION, PEG_PRECISION, Wallet, DriftClient } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('switch oracles', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; @@ -207,6 +209,7 @@ describe('switch oracles', () => { type: 'websocket', }, }); + await driftClient.subscribe(); const newSolOracle = await mockOracleNoProgram(bankrunContextWrapper, 100); diff --git a/tests/switchboardOnDemand.ts b/tests/switchboardOnDemand.ts index ab80293c1b..baab724751 100644 --- a/tests/switchboardOnDemand.ts +++ b/tests/switchboardOnDemand.ts @@ -1,11 +1,11 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; + import { AccountInfo, LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; +import { OracleSource, TestClient } from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { initializeQuoteSpotMarket, mockUSDCMint } from './testHelpers'; -import { OracleSource, TestClient } from '../sdk/src'; -import { startAnchor } from 'solana-bankrun'; +import { DriftProgram } from '../sdk/src/config'; import { ORACLE_ADDRESS_1, ORACLE_ADDRESS_1_DATA, @@ -26,6 +26,7 @@ import { QUEUE_ACCOUNT_DATA, QUEUE_ADDRESS, } from './switchboardOnDemandData'; +import { initializeQuoteSpotMarket, mockUSDCMint } from './testHelpers'; const SB_ON_DEMAND_PID = 'SBondMDrcV3K4kxZR1HNVT7osZxAHVHgYXL5Ze1oMUv'; @@ -56,7 +57,7 @@ const getOracleAccountInfo = (accountData: string): AccountInfo => { }; describe('switchboard on demand', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/switchboardTxCus.ts b/tests/switchboardTxCus.ts index 6288a1795f..0144eadde4 100644 --- a/tests/switchboardTxCus.ts +++ b/tests/switchboardTxCus.ts @@ -3,38 +3,35 @@ import { assert } from 'chai'; import { BASE_PRECISION, BN, - OracleSource, - TestClient, EventSubscriber, - PRICE_PRECISION, + getOrderParams, + LIQUIDATION_PCT_PRECISION, + MarketType, + OracleSource, + OrderParams, + OrderType, PositionDirection, + PostOnlyParams, + PRICE_PRECISION, + TestClient, Wallet, - LIQUIDATION_PCT_PRECISION, } from '../sdk/src'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair, PublicKey } from '@solana/web3.js'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { + initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, - initializeQuoteSpotMarket, } from './testHelpers'; -import { - getOrderParams, - MarketType, - OrderParams, - OrderType, - PostOnlyParams, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('switchboard place orders cus', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; @@ -219,6 +216,7 @@ describe('switchboard place orders cus', () => { const cus = bankrunContextWrapper.connection.findComputeUnitConsumption(txSig); console.log(cus); - assert(cus < 415000); + // TODO: switchboard CUS went up after anchor v0.32.1 update + assert(cus < 599850); }); }); diff --git a/tests/testHelpers.ts b/tests/testHelpers.ts index 6d7495d11a..046bbecaed 100644 --- a/tests/testHelpers.ts +++ b/tests/testHelpers.ts @@ -1,26 +1,31 @@ -import * as anchor from '@coral-xyz/anchor-29'; -import { AnchorProvider, Program, Provider } from '@coral-xyz/anchor-29'; -import { Program as Program30 } from '@coral-xyz/anchor'; +import * as anchor from '@coral-xyz/anchor'; import { + AnchorProvider, + Program as Program30, + Provider, +} from '@coral-xyz/anchor'; +import { Idl as Idl29, Program as Program29 } from '@coral-xyz/anchor-29'; + +import { + ACCOUNT_SIZE, AccountLayout, - MintLayout, - NATIVE_MINT, - TOKEN_PROGRAM_ID, - createInitializeMintInstruction, + AccountState, + createAssociatedTokenAccountIdempotentInstruction, createInitializeAccountInstruction, + createInitializeMintInstruction, + createInitializePermanentDelegateInstruction, createMintToInstruction, - getAssociatedTokenAddressSync, - createAssociatedTokenAccountIdempotentInstruction, - ACCOUNT_SIZE, createSyncNativeInstruction, - createInitializePermanentDelegateInstruction, - getMintLen, ExtensionType, - unpackAccount, + getAssociatedTokenAddressSync, + getMintLen, + MintLayout, + NATIVE_MINT, RawAccount, - AccountState, - unpackMint, RawMint, + TOKEN_PROGRAM_ID, + unpackAccount, + unpackMint, } from '@solana/spl-token'; import { AccountInfo, @@ -33,37 +38,36 @@ import { Transaction, TransactionSignature, } from '@solana/web3.js'; -import { assert } from 'chai'; import buffer from 'buffer'; +import { assert } from 'chai'; import { BN, - Wallet, - OraclePriceData, + ConstituentAccount, + DriftClient, + DriftProgram, OracleInfo, + OraclePriceData, + OracleSource, + OrderType, PerpMarketAccount, PositionDirection, - DriftClient, - OrderType, + PRICE_PRECISION, + QUOTE_PRECISION, ReferrerInfo, - ConstituentAccount, - SpotMarketAccount, -} from '../sdk/src'; -import { - TestClient, SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, - PRICE_PRECISION, - QUOTE_PRECISION, + SpotMarketAccount, + TestClient, User, - OracleSource, + Wallet, } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { - BankrunContextWrapper, BankrunConnection, + BankrunContextWrapper, } from '../sdk/src/bankrun/bankrunConnection'; -import pythIDL from '../sdk/src/idl/pyth.json'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { Drift } from '../sdk/src/idl/drift'; +import pythIDL from '../sdk/src/idl/pyth.json'; export async function mockOracle( price: number = 50 * 10e7, @@ -107,7 +111,7 @@ export async function mockOracleNoProgram( const programId = new PublicKey( 'FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH' ); - const program = new Program(pythIDL as anchor.Idl, programId, provider); + const program = new Program29(pythIDL as Idl29, programId, provider); const priceFeedAddress = await createPriceFeedBankrun({ oracleProgram: program, @@ -623,7 +627,7 @@ export async function initUserAccounts( ownerWallet.publicKey ); - const chProgram = anchor.workspace.Drift as anchor.Program; // this.program-ify + const chProgram = anchor.workspace.Drift as DriftProgram; const driftClient1 = new TestClient({ connection: context.connection.toConnection(), @@ -693,7 +697,7 @@ export const createPriceFeed = async ({ confidence = undefined, expo = -4, }: { - oracleProgram: Program; + oracleProgram: Program29; initPrice: number; confidence?: number; expo?: number; @@ -733,7 +737,7 @@ export const createPriceFeedBankrun = async ({ confidence = undefined, expo = -4, }: { - oracleProgram: Program; + oracleProgram: Program29; context: BankrunContextWrapper; initPrice: number; confidence?: number; @@ -764,7 +768,7 @@ export const createPriceFeedBankrun = async ({ return collateralTokenFeed.publicKey; }; export const setFeedPrice = async ( - oracleProgram: Program, + oracleProgram: Program29, newPrice: number, priceFeed: PublicKey ) => { @@ -793,8 +797,8 @@ export const setFeedPriceNoProgram = async ( } ); - const program = new Program( - pythIDL as anchor.Idl, + const program = new Program29( + pythIDL as Idl29, new PublicKey('FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH'), provider ); @@ -814,7 +818,7 @@ export const setFeedPriceNoProgram = async ( }; export const setFeedTwap = async ( - oracleProgram: Program, + oracleProgram: Program29, newTwap: number, priceFeed: PublicKey ) => { @@ -827,7 +831,7 @@ export const setFeedTwap = async ( }); }; export const getFeedData = async ( - oracleProgram: Program, + oracleProgram: Program29, priceFeed: PublicKey ) => { const info = await oracleProgram.provider.connection.getAccountInfo( @@ -846,7 +850,7 @@ export const getFeedDataNoProgram = async ( }; export const getOraclePriceData = async ( - oracleProgram: Program, + oracleProgram: Program29, priceFeed: PublicKey ): Promise => { const info = await oracleProgram.provider.connection.getAccountInfo( @@ -1199,8 +1203,8 @@ export async function overWritePerpMarket( executable: false, owner: driftClient.program.programId, lamports: LAMPORTS_PER_SOL, - data: await driftClient.program.account.perpMarket.coder.accounts.encode( - 'PerpMarket', + data: await driftClient.program.coder.accounts.encode( + 'perpMarket', perpMarket ), }); @@ -1217,7 +1221,7 @@ export async function overWriteSpotMarket( owner: driftClient.program.programId, lamports: LAMPORTS_PER_SOL, data: await driftClient.program.account.spotMarket.coder.accounts.encode( - 'SpotMarket', + 'spotMarket', spotMarket ), }); @@ -1232,7 +1236,7 @@ export async function getPerpMarketDecoded( perpMarketPublicKey ); const perpMarketAccount: PerpMarketAccount = - driftClient.program.coder.accounts.decode('PerpMarket', accountInfo!.data); + driftClient.program.coder.accounts.decode('perpMarket', accountInfo!.data); return perpMarketAccount; } @@ -1398,7 +1402,7 @@ export async function overwriteConstituentAccount( owner: program.programId, lamports: LAMPORTS_PER_SOL, data: await program.account.constituent.coder.accounts.encode( - 'Constituent', + 'constituent', acc ), }); diff --git a/tests/testHelpersLocalValidator.ts b/tests/testHelpersLocalValidator.ts index 595a0115a0..926dafff45 100644 --- a/tests/testHelpersLocalValidator.ts +++ b/tests/testHelpersLocalValidator.ts @@ -2,15 +2,15 @@ import * as anchor from '@coral-xyz/anchor'; import { AnchorProvider, Program, Provider } from '@coral-xyz/anchor'; import { AccountLayout, - MintLayout, - NATIVE_MINT, - TOKEN_PROGRAM_ID, - getMinimumBalanceForRentExemptMint, - getMinimumBalanceForRentExemptAccount, - createInitializeMintInstruction, createInitializeAccountInstruction, + createInitializeMintInstruction, createMintToInstruction, createWrappedNativeAccount, + getMinimumBalanceForRentExemptAccount, + getMinimumBalanceForRentExemptMint, + MintLayout, + NATIVE_MINT, + TOKEN_PROGRAM_ID, } from '@solana/spl-token'; import { Connection, @@ -21,23 +21,21 @@ import { Transaction, TransactionSignature, } from '@solana/web3.js'; -import { assert } from 'chai'; import buffer from 'buffer'; +import { assert } from 'chai'; import { BN, - Wallet, - OraclePriceData, - OracleInfo, BulkAccountLoader, -} from '../sdk'; -import { - TestClient, - SPOT_MARKET_RATE_PRECISION, - SPOT_MARKET_WEIGHT_PRECISION, + OracleInfo, + OraclePriceData, + OracleSource, PRICE_PRECISION, QUOTE_PRECISION, + SPOT_MARKET_RATE_PRECISION, + SPOT_MARKET_WEIGHT_PRECISION, + TestClient, User, - OracleSource, + Wallet, } from '../sdk/src'; export async function mockOracle( diff --git a/tests/tokenFaucet.ts b/tests/tokenFaucet.ts index 42d72b8eb5..5eb8257e71 100644 --- a/tests/tokenFaucet.ts +++ b/tests/tokenFaucet.ts @@ -1,19 +1,20 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; -import { TestClient, TokenFaucet } from '../sdk/src'; -import { BN } from '../sdk'; -import { Keypair, PublicKey } from '@solana/web3.js'; -import { initializeQuoteSpotMarket, mockUSDCMint } from './testHelpers'; + +import { Program } from '@coral-xyz/anchor-29'; import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, unpackAccount, unpackMint, } from '@solana/spl-token'; +import { Keypair, PublicKey } from '@solana/web3.js'; import { startAnchor } from 'solana-bankrun'; +import { BN, TestClient, TokenFaucet } from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { initializeQuoteSpotMarket, mockUSDCMint } from './testHelpers'; describe('token faucet', () => { const program = anchor.workspace.TokenFaucet as Program; @@ -22,7 +23,7 @@ describe('token faucet', () => { let usdcMint: Keypair; - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let bulkAccountLoader: TestBulkAccountLoader; diff --git a/tests/transferPerpPosition.ts b/tests/transferPerpPosition.ts index 7e38f07cb8..25da24e08d 100644 --- a/tests/transferPerpPosition.ts +++ b/tests/transferPerpPosition.ts @@ -1,28 +1,27 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { - TestClient, BN, + OracleGuardRails, PRICE_PRECISION, PositionDirection, + TestClient, getMarketOrderParams, - OracleGuardRails, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { BASE_PRECISION, OracleSource, PERCENTAGE_PRECISION } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { + initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, setFeedPriceNoProgram, - initializeQuoteSpotMarket, } from './testHelpers'; -import { BASE_PRECISION, OracleSource, PERCENTAGE_PRECISION } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; function getOpenInterest(driftClient: TestClient, marketIndex: number) { const perpMarket = driftClient.getPerpMarketAccount(marketIndex); @@ -33,7 +32,7 @@ function getOpenInterest(driftClient: TestClient, marketIndex: number) { } describe('trigger orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; @@ -114,7 +113,7 @@ describe('trigger orders', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/transferPools.ts b/tests/transferPools.ts index a921f74f35..e3b4c6bef7 100644 --- a/tests/transferPools.ts +++ b/tests/transferPools.ts @@ -1,21 +1,25 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; import { - TestClient, BN, EventSubscriber, - SPOT_MARKET_RATE_PRECISION, + MarketStatus, + OracleInfo, OracleSource, + SPOT_MARKET_RATE_PRECISION, SPOT_MARKET_WEIGHT_PRECISION, - OracleInfo, - MarketStatus, + TestClient, } from '../sdk/src'; +import { NATIVE_MINT } from '@solana/spl-token'; +import { startAnchor } from 'solana-bankrun'; +import { QUOTE_PRECISION, ZERO } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createUserWithUSDCAccount, createUserWithUSDCAndWSOLAccount, @@ -24,14 +28,9 @@ import { mockUserUSDCAccount, sleep, } from './testHelpers'; -import { QUOTE_PRECISION, ZERO } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; -import { NATIVE_MINT } from '@solana/spl-token'; describe('spot deposit and withdraw', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let admin: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/triggerOrders.ts b/tests/triggerOrders.ts index 690cd47d36..48c78ba4e6 100644 --- a/tests/triggerOrders.ts +++ b/tests/triggerOrders.ts @@ -1,31 +1,23 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair } from '@solana/web3.js'; import { - TestClient, BN, - PRICE_PRECISION, - PositionDirection, - User, - Wallet, getMarketOrderParams, - OrderTriggerCondition, - getTriggerMarketOrderParams, getTriggerLimitOrderParams, + getTriggerMarketOrderParams, OracleGuardRails, + OrderTriggerCondition, + PositionDirection, + PRICE_PRECISION, + TestClient, + User, + Wallet, } from '../sdk/src'; -import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - setFeedPriceNoProgram, - initializeQuoteSpotMarket, -} from './testHelpers'; +import { startAnchor } from 'solana-bankrun'; import { BASE_PRECISION, convertToNumber, @@ -33,13 +25,20 @@ import { PERCENTAGE_PRECISION, QUOTE_PRECISION, ZERO, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, + setFeedPriceNoProgram, +} from './testHelpers'; describe('trigger orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; @@ -121,7 +120,7 @@ describe('trigger orders', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/triggerSpotOrder.ts b/tests/triggerSpotOrder.ts index 84a819d242..2f3c4ce4fe 100644 --- a/tests/triggerSpotOrder.ts +++ b/tests/triggerSpotOrder.ts @@ -1,42 +1,41 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { Keypair } from '@solana/web3.js'; import { - TestClient, BN, - PRICE_PRECISION, + getTriggerMarketOrderParams, + OracleGuardRails, + OrderTriggerCondition, PositionDirection, + PRICE_PRECISION, + TestClient, User, Wallet, - OrderTriggerCondition, - getTriggerMarketOrderParams, - OracleGuardRails, } from '../sdk/src'; -import { - mockOracleNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - setFeedPriceNoProgram, - initializeQuoteSpotMarket, - initializeSolSpotMarket, -} from './testHelpers'; +import { startAnchor } from 'solana-bankrun'; import { BASE_PRECISION, isVariant, OracleSource, PERCENTAGE_PRECISION, -} from '../sdk'; -import { startAnchor } from 'solana-bankrun'; +} from '../sdk/src'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + initializeQuoteSpotMarket, + initializeSolSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, + setFeedPriceNoProgram, +} from './testHelpers'; describe('trigger orders', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let fillerDriftClient: TestClient; let fillerDriftClientUser: User; @@ -119,7 +118,7 @@ describe('trigger orders', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), - oracleTwap5MinPercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), + oracleTwap5minPercentDivergence: PERCENTAGE_PRECISION.mul(new BN(10)), }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/updateAMM.ts b/tests/updateAMM.ts index f04afc71aa..f5f5ce9fff 100644 --- a/tests/updateAMM.ts +++ b/tests/updateAMM.ts @@ -8,35 +8,34 @@ import { getMarketOrderParams, OracleSource, PEG_PRECISION, -} from '../sdk'; - -import { Program } from '@coral-xyz/anchor'; +} from '../sdk/src'; import { - TestClient, - PRICE_PRECISION, AMM_RESERVE_PRECISION, - QUOTE_PRECISION, + calculateBidAskPrice, calculateReservePrice, - OracleGuardRails, calculateTradeSlippage, - PositionDirection, - EventSubscriber, + calculateUpdatedAMM, convertToNumber, + EventSubscriber, findComputeUnitConsumption, - calculateBidAskPrice, - calculateUpdatedAMM, + OracleGuardRails, + PositionDirection, + PRICE_PRECISION, + QUOTE_PRECISION, + TestClient, } from '../sdk/src'; +import { DriftProgram } from '../sdk/src/config'; import { getFeedData, + getOraclePriceData, + initializeQuoteSpotMarket, // initUserAccounts, mockOracle, - mockUserUSDCAccount, mockUSDCMint, + mockUserUSDCAccount, setFeedPrice, - getOraclePriceData, - initializeQuoteSpotMarket, } from './testHelpers'; async function feePoolInjection(fees, marketIndex, driftClient) { @@ -96,7 +95,7 @@ describe('update amm', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; const eventSubscriber = new EventSubscriber(connection, chProgram, { @@ -518,7 +517,7 @@ describe('update amm', () => { const oracleGuardRails: OracleGuardRails = { priceDivergence: { markOraclePercentDivergence: new BN(1000000), - oracleTwap5MinPercentDivergence: new BN(1000000), + oracleTwap5minPercentDivergence: new BN(1000000), }, validity: { slotsBeforeStaleForAmm: new BN(100), diff --git a/tests/updateK.ts b/tests/updateK.ts index e9b4d90a98..e7cfdfffc9 100644 --- a/tests/updateK.ts +++ b/tests/updateK.ts @@ -6,31 +6,31 @@ import { BN, BulkAccountLoader, calculateTradeSlippage, -} from '../sdk'; +} from '../sdk/src'; import { Keypair } from '@solana/web3.js'; -import { Program } from '@coral-xyz/anchor'; import { - TestClient, - PRICE_PRECISION, + calculateBudgetedKBN, calculateReservePrice, - User, + convertToNumber, + MarketStatus, PEG_PRECISION, PositionDirection, - convertToNumber, - squareRootBN, - calculateBudgetedKBN, + PRICE_PRECISION, QUOTE_SPOT_MARKET_INDEX, - MarketStatus, + squareRootBN, + TestClient, + User, } from '../sdk/src'; +import { QUOTE_PRECISION } from '../sdk/src'; +import { DriftProgram } from '../sdk/src/config'; import { createPriceFeed, + initializeQuoteSpotMarket, mockUSDCMint, mockUserUSDCAccount, - initializeQuoteSpotMarket, } from './testHelpers'; -import { QUOTE_PRECISION } from '../sdk/src'; const ZERO = new BN(0); @@ -42,7 +42,7 @@ describe('update k', () => { }); const connection = provider.connection; anchor.setProvider(provider); - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; diff --git a/tests/userAccount.ts b/tests/userAccount.ts index 13cf1f07ca..ccfc149159 100644 --- a/tests/userAccount.ts +++ b/tests/userAccount.ts @@ -1,40 +1,41 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; -import { - mockOracleNoProgram, - setFeedPriceNoProgram, - mockUSDCMint, - mockUserUSDCAccount, - initializeQuoteSpotMarket, - getFeedDataNoProgram, - sleep, -} from './testHelpers'; + import { Keypair } from '@solana/web3.js'; import { assert } from 'chai'; +import { startAnchor } from 'solana-bankrun'; import { - TestClient, - User, - PEG_PRECISION, - MAX_LEVERAGE, - PositionDirection, - QUOTE_SPOT_MARKET_INDEX, - MarketStatus, + AMM_RESERVE_PRECISION, BASE_PRECISION, BN, + MAX_LEVERAGE, + MarketStatus, OracleSource, - calculateWorstCaseBaseAssetAmount, + PEG_PRECISION, + PositionDirection, + QUOTE_SPOT_MARKET_INDEX, + TestClient, + User, calculateMarketMarginRatio, + calculatePrice, calculateReservePrice, + calculateWorstCaseBaseAssetAmount, convertToNumber, - calculatePrice, - AMM_RESERVE_PRECISION, } from '../sdk/src'; -import { startAnchor } from 'solana-bankrun'; import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; +import { + getFeedDataNoProgram, + initializeQuoteSpotMarket, + mockOracleNoProgram, + mockUSDCMint, + mockUserUSDCAccount, + setFeedPriceNoProgram, + sleep, +} from './testHelpers'; describe('User Account', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient; diff --git a/tests/userDelegate.ts b/tests/userDelegate.ts index d74c7b3178..6de8762902 100644 --- a/tests/userDelegate.ts +++ b/tests/userDelegate.ts @@ -1,19 +1,23 @@ import * as anchor from '@coral-xyz/anchor'; -import { Program } from '@coral-xyz/anchor'; - import { - QUOTE_SPOT_MARKET_INDEX, - TestClient, BN, EventSubscriber, - PRICE_PRECISION, + MarketStatus, OracleSource, PositionDirection, + PRICE_PRECISION, + QUOTE_SPOT_MARKET_INDEX, + TestClient, Wallet, - MarketStatus, } from '../sdk/src'; +import { Keypair } from '@solana/web3.js'; +import { assert } from 'chai'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { createFundedKeyPair, initializeQuoteSpotMarket, @@ -21,14 +25,9 @@ import { mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { assert } from 'chai'; -import { Keypair } from '@solana/web3.js'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('user delegate', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let driftClient: TestClient; let eventSubscriber: EventSubscriber; diff --git a/tests/userOrderId.ts b/tests/userOrderId.ts index 1de190bd5e..d45dd0e9cb 100644 --- a/tests/userOrderId.ts +++ b/tests/userOrderId.ts @@ -1,34 +1,33 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { Program } from '@coral-xyz/anchor'; - import { - TestClient, + AMM_RESERVE_PRECISION, BN, + MarketStatus, + OracleSource, PRICE_PRECISION, PositionDirection, + TestClient, User, getLimitOrderParams, - MarketStatus, - AMM_RESERVE_PRECISION, - OracleSource, isVariant, } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { ContractTier, ExchangeStatus } from '../sdk/src'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { ContractTier, ExchangeStatus } from '../sdk'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('user order id', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; @@ -123,7 +122,7 @@ describe('user order id', () => { undefined, undefined, undefined, - false + 0 ); await driftClient.updatePerpMarketStatus(0, MarketStatus.ACTIVE); diff --git a/tests/whitelist.ts b/tests/whitelist.ts index 2bbe9fd2a6..297a512038 100644 --- a/tests/whitelist.ts +++ b/tests/whitelist.ts @@ -1,15 +1,7 @@ import * as anchor from '@coral-xyz/anchor'; import { assert } from 'chai'; -import { BASE_PRECISION, BN, OracleSource } from '../sdk'; +import { BASE_PRECISION, BN, OracleSource } from '../sdk/src'; -import { Program } from '@coral-xyz/anchor'; - -import { - Keypair, - PublicKey, - SystemProgram, - Transaction, -} from '@solana/web3.js'; import { MINT_SIZE, TOKEN_PROGRAM_ID, @@ -18,21 +10,28 @@ import { createMintToInstruction, getAssociatedTokenAddressSync, } from '@solana/spl-token'; +import { + Keypair, + PublicKey, + SystemProgram, + Transaction, +} from '@solana/web3.js'; -import { TestClient, PRICE_PRECISION } from '../sdk/src'; +import { PRICE_PRECISION, TestClient } from '../sdk/src'; +import { startAnchor } from 'solana-bankrun'; +import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; +import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; +import { DriftProgram } from '../sdk/src/config'; import { initializeQuoteSpotMarket, mockOracleNoProgram, mockUSDCMint, mockUserUSDCAccount, } from './testHelpers'; -import { startAnchor } from 'solana-bankrun'; -import { TestBulkAccountLoader } from '../sdk/src/accounts/testBulkAccountLoader'; -import { BankrunContextWrapper } from '../sdk/src/bankrun/bankrunConnection'; describe('whitelist', () => { - const chProgram = anchor.workspace.Drift as Program; + const chProgram = anchor.workspace.Drift as DriftProgram; let bulkAccountLoader: TestBulkAccountLoader; From b6de39766f07488fa1801961256e0ecfab634aba Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Mon, 22 Dec 2025 15:20:56 +0800 Subject: [PATCH 25/25] ci fix --- .github/workflows/main.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4aa400d6bc..0b0683dece 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ env: CARGO_TERM_COLOR: always RUST_TOOLCHAIN: 1.91.1 SOLANA_VERSION: 2.3.0 - ANCHOR_VERSION: 0.32.1 + ANCHOR_VERSION: 0.31.1 NODE_VERSION: "22.14.x" jobs: @@ -126,7 +126,7 @@ jobs: - name: Install Anchor CLI if: steps.cache-anchor.outputs.cache-hit != 'true' run: | - sudo apt install libudev-dev + sudo apt update -y && sudo apt install libudev-dev cargo install --git https://github.com/coral-xyz/anchor --tag v${{ env.ANCHOR_VERSION }} anchor-cli --locked - name: Setup node @@ -333,6 +333,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Install Anchor CLI + run: | + cargo install --git https://github.com/coral-xyz/anchor --tag v${{ env.ANCHOR_VERSION }} anchor-cli --locked + - name: Verifiable Build run: | anchor build --verifiable -s ${{ env.SOLANA_VERSION }} -d solanafoundation/anchor:v${{ env.ANCHOR_VERSION }}