From 577f70992cf02a665ccb3639e07aac4a73cb8408 Mon Sep 17 00:00:00 2001 From: jordy25519 Date: Wed, 23 Oct 2024 11:40:33 +0800 Subject: [PATCH] Bump drift-rs version (#86) * Bump drift-rs v1.0.0-alpha.2 * gateway makes minimal network subscriptions by default * Add '--markets' for user to supply intended markets. market + oracle subs are created from this * update README --- .github/workflows/build.yml | 2 +- Cargo.lock | 504 ++++++++++++++++++------------------ Cargo.toml | 4 +- README.md | 80 ++++-- src/controller.rs | 142 ++++++++-- src/main.rs | 44 +++- src/types.rs | 42 +-- src/websocket.rs | 47 +--- 8 files changed, 501 insertions(+), 364 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 515c851..3d6d04e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,4 +58,4 @@ jobs: run: | cargo -V cp libdrift_ffi_sys.so ./target/debug/deps - cargo test --all -- --test-threads=2 + cargo test --all -- --test-threads=3 diff --git a/Cargo.lock b/Cargo.lock index 3e9c6f3..57288de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ "ahash 0.8.11", "base64 0.22.1", "bitflags 2.6.0", - "brotli", + "brotli 6.0.0", "bytes", "bytestring", "derive_more", @@ -123,7 +123,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -240,14 +240,14 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] @@ -474,7 +474,7 @@ dependencies = [ "borsh 0.10.4", "bytemuck", "getrandom 0.2.15", - "solana-program 1.18.23", + "solana-program 1.18.26", "thiserror", ] @@ -595,9 +595,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" [[package]] name = "argh" @@ -618,7 +618,7 @@ dependencies = [ "argh_shared", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -835,11 +835,11 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.12" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa" +checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" dependencies = [ - "brotli", + "brotli 7.0.0", "flate2", "futures-core", "memchr", @@ -864,7 +864,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1073,7 +1073,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "syn_derive", ] @@ -1132,6 +1132,17 @@ dependencies = [ "brotli-decompressor", ] +[[package]] +name = "brotli" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + [[package]] name = "brotli-decompressor" version = "4.0.1" @@ -1197,22 +1208,22 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26" +checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1223,9 +1234,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "bytestring" @@ -1248,9 +1259,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.22" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "jobserver", "libc", @@ -1584,7 +1595,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1595,7 +1606,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1681,7 +1692,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1724,7 +1735,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1747,12 +1758,12 @@ checksum = "a6cbae11b3de8fce2a456e8ea3dada226b35fe791f0dc1d360c0941f0bb681f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "drift-gateway" -version = "1.0.4" +version = "1.1.0" dependencies = [ "actix-web", "argh", @@ -1773,30 +1784,30 @@ dependencies = [ [[package]] name = "drift-idl-gen" -version = "0.1.0" -source = "git+https://github.com/drift-labs/drift-rs?tag=v1.0.0-alpha.0#2abbbb6ba589a28af6330ee8a2094630c3dde027" +version = "0.1.1" +source = "git+https://github.com/drift-labs/drift-rs?tag=v1.0.0-alpha.2#8bf9630aa8cc7a3749e8c0e9afd41254c418e370" dependencies = [ "proc-macro2", "quote", "serde", "serde_json", "sha2 0.10.8", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "drift-rs" -version = "1.0.0" -source = "git+https://github.com/drift-labs/drift-rs?tag=v1.0.0-alpha.0#2abbbb6ba589a28af6330ee8a2094630c3dde027" +version = "1.0.0-alpha.2" +source = "git+https://github.com/drift-labs/drift-rs?tag=v1.0.0-alpha.2#8bf9630aa8cc7a3749e8c0e9afd41254c418e370" dependencies = [ "abi_stable", + "ahash 0.8.11", "anchor-lang", "base64 0.22.1", "bytemuck", "dashmap 6.1.0", "drift-idl-gen", "env_logger 0.11.5", - "fnv", "futures-util", "log", "regex", @@ -1890,7 +1901,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -1996,9 +2007,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -2011,9 +2022,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -2021,15 +2032,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -2038,38 +2049,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -2141,9 +2152,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "goblin" @@ -2168,7 +2179,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.5.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -2217,6 +2228,12 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "heck" version = "0.3.3" @@ -2301,9 +2318,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -2319,9 +2336,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -2412,9 +2429,9 @@ dependencies = [ [[package]] name = "impl-more" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206ca75c9c03ba3d4ace2460e57b189f39f43de612c2f85836e65c929701bb2d" +checksum = "aae21c3177a27788957044151cc2800043d127acaa460a47ebb9b84dfa2c6aa0" [[package]] name = "indexmap" @@ -2428,12 +2445,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.0", ] [[package]] @@ -2469,9 +2486,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is_terminal_polyfill" @@ -2514,9 +2531,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -2559,9 +2576,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "libloading" @@ -2843,7 +2860,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2915,7 +2932,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -2926,9 +2943,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] @@ -2944,9 +2961,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -3137,9 +3154,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -3338,18 +3355,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -3359,9 +3376,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -3376,9 +3393,9 @@ checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rend" @@ -3641,9 +3658,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" [[package]] name = "ryu" @@ -3653,9 +3670,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ "windows-sys 0.59.0", ] @@ -3683,7 +3700,7 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -3733,9 +3750,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.211" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "1ac55e59090389fb9f0dd9e0f3c09615afed1d19094284d0b200441f13550793" dependencies = [ "serde_derive", ] @@ -3751,20 +3768,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.211" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "54be4f245ce16bc58d57ef2716271d0d4519e0f6defa147f6e081005bcb278ff" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -3803,7 +3820,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -3939,9 +3956,9 @@ dependencies = [ [[package]] name = "solana-account-decoder" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c23b9de815f607b6cdadf0a65118bf90d812cfd29397c326b4dc222daad684" +checksum = "41d87c6ef8c13eb759fa8d887e12c67afd851799050b6afd501a27726551f52e" dependencies = [ "Inflector", "base64 0.22.1", @@ -3964,9 +3981,9 @@ dependencies = [ [[package]] name = "solana-clap-utils" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4453ca3d1c13c7ac914adbad7aa58cb3cdfa7710e581ffcdbff65d1b2895377" +checksum = "5f9709683a4d480a0185827292405cad0b6f414abaa479c7d1dfe5e2194aeec8" dependencies = [ "chrono", "clap 2.34.0", @@ -3981,16 +3998,16 @@ dependencies = [ [[package]] name = "solana-client" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7d9dde51417ce52076059b3802db8e14c7c92e00e562208d9d53361bfd3f12" +checksum = "67169e4f1faabb717ce81b5ca93960da21e3ac5c9b75cb6792f9b3ce38db459f" dependencies = [ "async-trait", "bincode", "dashmap 5.5.3", "futures", "futures-util", - "indexmap 2.5.0", + "indexmap 2.6.0", "indicatif", "log", "quinn", @@ -4014,9 +4031,9 @@ dependencies = [ [[package]] name = "solana-compute-budget" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99f17feb6ffde6f6bfeff274f90345a1290cb04b0a60ea186c452a2435660c06" +checksum = "5acde49a883ca3e099a8050ad8321ea56b02041995dadcf84b0dab14561cc34a" dependencies = [ "rustc_version", "solana-sdk", @@ -4024,9 +4041,9 @@ dependencies = [ [[package]] name = "solana-config-program" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db0730a851d7785f572617878009ec35ac020922fba473c536382ff30207859d" +checksum = "f638e44fb308bdc1ce99eb0fee194b2cb212917b258999cdb4a8b056d48973d4" dependencies = [ "bincode", "chrono", @@ -4038,15 +4055,15 @@ dependencies = [ [[package]] name = "solana-connection-cache" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cb3522f31e8624a87116f770e082c9ac74fd0a9a2252ff11c952704218de246" +checksum = "3fd01a4d43b780996970cb3669946b002f71d34e6a26a19bd6d2a74513ecc0aa" dependencies = [ "async-trait", "bincode", "crossbeam-channel", "futures-util", - "indexmap 2.5.0", + "indexmap 2.6.0", "log", "rand 0.8.5", "rayon", @@ -4059,22 +4076,22 @@ dependencies = [ [[package]] name = "solana-curve25519" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "698aeff176242ed50c887bea4c7e6e332ba5f120b7b02745d3a3cce3a719dcdd" +checksum = "44b61d8eda3319deca3627e3eb3970ce2ad179ad39c106d6c003d06c90e3031d" dependencies = [ "bytemuck", "bytemuck_derive", "curve25519-dalek", - "solana-program 2.0.11", + "solana-program 2.0.13", "thiserror", ] [[package]] name = "solana-frozen-abi" -version = "1.18.23" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bfcde2fc6946c99c7e3400fadd04d1628d675bfd66cb34d461c0f3224bd27d1" +checksum = "03ab2c30c15311b511c0d1151e4ab6bc9a3e080a37e7c6e7c2d96f5784cf9434" dependencies = [ "block-buffer 0.10.4", "bs58 0.4.0", @@ -4097,21 +4114,21 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.18.23" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5024d241425f4e99f112ee03bfa89e526c86c7ca9bd7e13448a7f2dffb7e060" +checksum = "c142f779c3633ac83c84d04ff06c70e1f558c876f13358bed77ba629c7417932" dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "solana-inline-spl" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4137c8f12ed9362a7e55587f5556765a235192847ecff2f04fc46dde165303e2" +checksum = "7f6614014b976112fb6c9bf259f87c6659b8fdea628c656639e02211324d2b34" dependencies = [ "bytemuck", "rustc_version", @@ -4120,9 +4137,9 @@ dependencies = [ [[package]] name = "solana-logger" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94ce4da36c6b28b6d741cbd99bf4238b8ae93ce0c8f8c72225faa21a140645e" +checksum = "c6b996befdb2bdbd816524fc7afe0e158fced33ff61c36ab29ae803c0462455d" dependencies = [ "env_logger 0.9.3", "lazy_static", @@ -4131,9 +4148,9 @@ dependencies = [ [[package]] name = "solana-measure" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79ed5420dcffe2f7759c70eb6cac560c92304bf06d505012ad367b44bac7c8b4" +checksum = "79d44cdbcf9e1489564cdae1cd92b8806b0ee89d05d36a58fef8c0d293ea7c2a" dependencies = [ "log", "solana-sdk", @@ -4141,9 +4158,9 @@ dependencies = [ [[package]] name = "solana-metrics" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "893c7b904946e99214bbaee7d366148a9b0fe2564ef6dfe7161a5a2d8c0c5738" +checksum = "68979964a3a004f1af4f1571814817e7e050ef4c1b2a1bdaa3ff35e980072d69" dependencies = [ "crossbeam-channel", "gethostname", @@ -4156,9 +4173,9 @@ dependencies = [ [[package]] name = "solana-net-utils" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c556a6d542c1937376e785f793dc590ffe20330affca70ce9f4a7ade437ee7bd" +checksum = "44bb419eb9293a277982cf14a58772e9b9ab30ff6f9421bc4ac0826d40122760" dependencies = [ "bincode", "clap 3.2.25", @@ -4179,9 +4196,9 @@ dependencies = [ [[package]] name = "solana-perf" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7e28aa36fbdd41eb83f95c4bdaf498e881e17ff76e7d8a84eaafb475355ae" +checksum = "00c4128122787a61d8f94fdaa04cb71b3dbb017d9939ac4d632264c55ec345de" dependencies = [ "ahash 0.8.11", "bincode", @@ -4206,9 +4223,9 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.18.23" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76056fecde0fe0ece8b457b719729c17173333471c72ad41969982975a10d6e0" +checksum = "c10f4588cefd716b24a1a40dd32c278e43a560ab8ce4de6b5805c9d113afdfa1" dependencies = [ "ark-bn254", "ark-ec", @@ -4252,7 +4269,7 @@ dependencies = [ "sha3 0.10.8", "solana-frozen-abi", "solana-frozen-abi-macro", - "solana-sdk-macro 1.18.23", + "solana-sdk-macro 1.18.26", "thiserror", "tiny-bip39", "wasm-bindgen", @@ -4261,9 +4278,9 @@ dependencies = [ [[package]] name = "solana-program" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9ae1a4ec088d868ed0ee777a9a85a3e2d44f192d7f4aa9f0f8dec16c342a92" +checksum = "29249ce5b5c7bd018013adbb97439b0b1b986f16bb07c54db28f82e97baaa2f1" dependencies = [ "ark-bn254", "ark-ec", @@ -4300,16 +4317,16 @@ dependencies = [ "serde_derive", "sha2 0.10.8", "sha3 0.10.8", - "solana-sdk-macro 2.0.11", + "solana-sdk-macro 2.0.13", "thiserror", "wasm-bindgen", ] [[package]] name = "solana-program-runtime" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50a8682d95f49de15b3e6e60e59754f3e36151cb5f8da7728297bc5b95976cbb" +checksum = "948bfeb10ba38b55a8b2db2de8ccfa8f57b44b6d73c98e8e0de8b10f10ce043b" dependencies = [ "base64 0.22.1", "bincode", @@ -4336,9 +4353,9 @@ dependencies = [ [[package]] name = "solana-pubsub-client" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7b784d5718ce45a67aa00465c515dd0e14cf0cf953b8bb658b42e8cab31ad3a" +checksum = "e3ce9fa94ef00f7dfec749fc6835a4c36e8cfa2166c4a80736af1b49ef5bcd8e" dependencies = [ "crossbeam-channel", "futures-util", @@ -4361,9 +4378,9 @@ dependencies = [ [[package]] name = "solana-quic-client" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e397e7a3efe22128c35783f1ec2c306def1fe8f5f66f1f61ce7a94e2bdbb5a0" +checksum = "00764a5e5e36a94515d05f771e869c920671f5753cfc71ebf366546c891450b4" dependencies = [ "async-mutex", "async-trait", @@ -4387,9 +4404,9 @@ dependencies = [ [[package]] name = "solana-rayon-threadlimit" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eb8779f9cff08b973e3b4cde6c73b993445d43f856128b673d720b9ea3998ba" +checksum = "33119350281687a17a8321f897dfd27009fc862711ee6555c26beb5b84d6c08c" dependencies = [ "lazy_static", "num_cpus", @@ -4397,9 +4414,9 @@ dependencies = [ [[package]] name = "solana-remote-wallet" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80229078147b493b777804cbebe83dfcf0cd25f3a0a7d7bbe6487942a7c32bab" +checksum = "aba8725448426110b9ac20d7256f43aad1ea46458fe35c63d174cf962af4a9d0" dependencies = [ "console", "dialoguer", @@ -4416,9 +4433,9 @@ dependencies = [ [[package]] name = "solana-rpc-client" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1278725cbf0cf850043ecc8ea7ea5ce00e26c8c738c68c23eee1d47b5eff04ad" +checksum = "bd96f6a505a492544ee2459b608af3fe07da6c8ffc0bd842489e836ac2c3fce6" dependencies = [ "async-trait", "base64 0.22.1", @@ -4443,9 +4460,9 @@ dependencies = [ [[package]] name = "solana-rpc-client-api" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05384a936fa8e0e77d4aee19f742950e2c057f264c9f1f5cbea5e4a251c66064" +checksum = "d04f79b88c53b675d5d885d498e7a7e6a4fdd60ffe56e543faddb5d94c6094ba" dependencies = [ "anyhow", "base64 0.22.1", @@ -4467,9 +4484,9 @@ dependencies = [ [[package]] name = "solana-rpc-client-nonce-utils" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1460a8a59466be8c704e328402fdd638ddf0afb73e7f368acee4e923cf2620e" +checksum = "42d46d162566cbf7d6eb2ae369fbb8a934bc846906cbe959aed9123c1ac92b85" dependencies = [ "clap 2.34.0", "solana-clap-utils", @@ -4480,9 +4497,9 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7092e9e22a2e8308a0f09c33f3411d2c9b51cac341468749398c8dbe5d32fb7a" +checksum = "24dae5bda29858add4df3a6c5eaf71c0d2042ca3317a9fd81d7e9f436278a1fe" dependencies = [ "bincode", "bitflags 2.6.0", @@ -4520,8 +4537,8 @@ dependencies = [ "sha2 0.10.8", "sha3 0.10.8", "siphasher", - "solana-program 2.0.11", - "solana-sdk-macro 2.0.11", + "solana-program 2.0.13", + "solana-sdk-macro 2.0.13", "thiserror", "uriparse", "wasm-bindgen", @@ -4529,28 +4546,28 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.18.23" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a8613ca80150f7e277e773620ba65d2c5fcc3a08eb8026627d601421ab43aef" +checksum = "1b75d0f193a27719257af19144fdaebec0415d1c9e9226ae4bd29b791be5e9bd" dependencies = [ "bs58 0.4.0", "proc-macro2", "quote", "rustversion", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] name = "solana-sdk-macro" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b26de6abbe042a1e77cfbc755c8ebc96bac3c5d07a8d45f67108774369925e41" +checksum = "704c9cacc61a5b9b6f717773cf4b3b45a4239dc7fa8c585258fceaf9b8e1cb94" dependencies = [ "bs58 0.5.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -4561,9 +4578,9 @@ checksum = "468aa43b7edb1f9b7b7b686d5c3aeb6630dc1708e86e31343499dd5c4d775183" [[package]] name = "solana-streamer" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e1fe86ca58726eb2a8e392c6ee30ec99d188bbad0552603a9460973db27ea" +checksum = "8cf77ab19483dce4b4307c9e6f195a8c52f0c219026b78af3a9fae1e63ba9222" dependencies = [ "async-channel", "bytes", @@ -4571,7 +4588,7 @@ dependencies = [ "dashmap 5.5.3", "futures-util", "histogram", - "indexmap 2.5.0", + "indexmap 2.6.0", "itertools 0.12.1", "libc", "log", @@ -4595,9 +4612,9 @@ dependencies = [ [[package]] name = "solana-thin-client" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04af07db7a995233ea5b71bfe05bed11c1c47595117adaeafe7f9a0ded710181" +checksum = "a8c880be4e50ff473b3e82b600162244b6eb28cb5a616dc90ee9232d34998680" dependencies = [ "bincode", "log", @@ -4610,14 +4627,14 @@ dependencies = [ [[package]] name = "solana-tpu-client" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca6195b9922aa268f24af550ec15cd64fc07bf4f2014842ba1c13f4bb56b98a" +checksum = "1e65c01edbca303273e735ae383dde54bd5c5b8a051c51162c0ff886b0939ec6" dependencies = [ "async-trait", "bincode", "futures-util", - "indexmap 2.5.0", + "indexmap 2.6.0", "indicatif", "log", "rayon", @@ -4634,9 +4651,9 @@ dependencies = [ [[package]] name = "solana-transaction-metrics-tracker" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0ca973b7caeb3054029a13a6a7d4f15808c7f7aee020402d6f962fb3d6589cc" +checksum = "44727bef1f8c57a6ed9a74761d8b7ddfcf4b4e2237cbcc5dc7f8f59985e07755" dependencies = [ "Inflector", "base64 0.22.1", @@ -4650,9 +4667,9 @@ dependencies = [ [[package]] name = "solana-transaction-status" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "983f032cf30e9bf292d2ba324161225889ff6833dc466564f4983db1beb26cac" +checksum = "d51d9d4a6004708f9563a29aa87fdf9960c1e7420b69dd82e8b817cf8f02430b" dependencies = [ "Inflector", "base64 0.22.1", @@ -4677,9 +4694,9 @@ dependencies = [ [[package]] name = "solana-type-overrides" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2843050d3b1e81bb4fdb2e409978c4a3257295ef79f869a2493139eabc39eff" +checksum = "2ab21276d6296965dc7181d785075b20e97b6789c76e8376cf363b3e2f7439b6" dependencies = [ "lazy_static", "rand 0.8.5", @@ -4687,9 +4704,9 @@ dependencies = [ [[package]] name = "solana-udp-client" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d17ed3191074bcfc361f4d14a2d728993727f6d9fa3b914c0468571f06d16bfa" +checksum = "10e902d4dc29cafc0794073805a2db1b48b818251480a9fbaec3959df72aec2f" dependencies = [ "async-trait", "solana-connection-cache", @@ -4702,9 +4719,9 @@ dependencies = [ [[package]] name = "solana-version" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f3b4f44e274fdc866ecb59d84dcd03bf9f11123d42414637b6df932318c220a" +checksum = "0bcbc570264e5a61a8f84439dfc254931460769fedfb91ff16253acfc3644c9d" dependencies = [ "log", "rustc_version", @@ -4716,9 +4733,9 @@ dependencies = [ [[package]] name = "solana-vote" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d74481c4d0b0325e7e2e8c3019984ffe08720c1403e2b3d773c3ca95138acd60" +checksum = "5fa1401a42023379f14af9165954f44ad02888a327dfd2a4abce0f18fa7cfab9" dependencies = [ "itertools 0.12.1", "log", @@ -4731,9 +4748,9 @@ dependencies = [ [[package]] name = "solana-vote-program" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6aac1cb6470cc9af4b6483b463fbbaadf665358b4bcfcb4b268b6331ef9f718" +checksum = "cfd8e539a9963c2914ff8426dfe92351a902892aea465cd507e36d638ca0b7d6" dependencies = [ "bincode", "log", @@ -4743,7 +4760,7 @@ dependencies = [ "serde", "serde_derive", "solana-metrics", - "solana-program 2.0.11", + "solana-program 2.0.13", "solana-program-runtime", "solana-sdk", "thiserror", @@ -4751,9 +4768,9 @@ dependencies = [ [[package]] name = "solana-zk-token-sdk" -version = "2.0.11" +version = "2.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc454c6b3a6018c1b0ef24fe90bf8b73af3e859148fc7fcbfbca3dc67c557cdc" +checksum = "a1dd7a8d6843cb3de4c13c2cfec1994519735ea4110b7f36b80b41d57bea1c07" dependencies = [ "aes-gcm-siv", "base64 0.22.1", @@ -4773,7 +4790,7 @@ dependencies = [ "serde_json", "sha3 0.9.1", "solana-curve25519", - "solana-program 2.0.11", + "solana-program 2.0.13", "solana-sdk", "subtle", "thiserror", @@ -4821,7 +4838,7 @@ dependencies = [ "borsh 1.5.1", "num-derive", "num-traits", - "solana-program 2.0.11", + "solana-program 2.0.13", "spl-token", "spl-token-2022", "thiserror", @@ -4834,7 +4851,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a38ea8b6dedb7065887f12d62ed62c1743aa70749e8558f963609793f6fb12bc" dependencies = [ "bytemuck", - "solana-program 2.0.11", + "solana-program 2.0.13", "spl-discriminator-derive", ] @@ -4846,7 +4863,7 @@ checksum = "d9e8418ea6269dcfb01c712f0444d2c75542c04448b480e87de59d2865edc750" dependencies = [ "quote", "spl-discriminator-syn", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -4858,7 +4875,7 @@ dependencies = [ "proc-macro2", "quote", "sha2 0.10.8", - "syn 2.0.79", + "syn 2.0.82", "thiserror", ] @@ -4868,7 +4885,7 @@ version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0dba2f2bb6419523405d21c301a32c9f9568354d4742552e7972af801f4bdb3" dependencies = [ - "solana-program 2.0.11", + "solana-program 2.0.13", ] [[package]] @@ -4880,7 +4897,7 @@ dependencies = [ "borsh 1.5.1", "bytemuck", "bytemuck_derive", - "solana-program 2.0.11", + "solana-program 2.0.13", "solana-zk-token-sdk", "spl-program-error", ] @@ -4893,7 +4910,7 @@ checksum = "d7b28bed65356558133751cc32b48a7a5ddfc59ac4e941314630bbed1ac10532" dependencies = [ "num-derive", "num-traits", - "solana-program 2.0.11", + "solana-program 2.0.13", "spl-program-error-derive", "thiserror", ] @@ -4907,7 +4924,7 @@ dependencies = [ "proc-macro2", "quote", "sha2 0.10.8", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -4917,7 +4934,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37a75a5f0fcc58126693ed78a17042e9dc53f07e357d6be91789f7d62aff61a4" dependencies = [ "bytemuck", - "solana-program 2.0.11", + "solana-program 2.0.13", "spl-discriminator", "spl-pod", "spl-program-error", @@ -4935,7 +4952,7 @@ dependencies = [ "num-derive", "num-traits", "num_enum", - "solana-program 2.0.11", + "solana-program 2.0.13", "thiserror", ] @@ -4950,7 +4967,7 @@ dependencies = [ "num-derive", "num-traits", "num_enum", - "solana-program 2.0.11", + "solana-program 2.0.13", "solana-security-txt", "solana-zk-token-sdk", "spl-memo", @@ -4970,7 +4987,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df8752b85a5ecc1d9f3a43bce3dd9a6a053673aacf5deb513d1cbb88d3534ffd" dependencies = [ "bytemuck", - "solana-program 2.0.11", + "solana-program 2.0.13", "spl-discriminator", "spl-pod", "spl-program-error", @@ -4983,7 +5000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6c2318ddff97e006ed9b1291ebec0750a78547f870f62a69c56fe3b46a5d8fc" dependencies = [ "borsh 1.5.1", - "solana-program 2.0.11", + "solana-program 2.0.13", "spl-discriminator", "spl-pod", "spl-program-error", @@ -4998,7 +5015,7 @@ checksum = "a110f33d941275d9f868b96daaa993f1e73b6806cc8836e43075b4d3ad8338a7" dependencies = [ "arrayref", "bytemuck", - "solana-program 2.0.11", + "solana-program 2.0.13", "spl-discriminator", "spl-pod", "spl-program-error", @@ -5013,7 +5030,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdcd73ec187bc409464c60759232e309f83b52a18a9c5610bf281c9c6432918c" dependencies = [ "bytemuck", - "solana-program 2.0.11", + "solana-program 2.0.13", "spl-discriminator", "spl-pod", "spl-program-error", @@ -5062,9 +5079,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -5080,7 +5097,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -5191,7 +5208,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -5261,9 +5278,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" dependencies = [ "backtrace", "bytes", @@ -5285,7 +5302,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -5358,7 +5375,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "toml_datetime", "winnow", ] @@ -5389,7 +5406,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -5478,18 +5495,15 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicase" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check", -] +checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" @@ -5590,9 +5604,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" [[package]] name = "vec_map" @@ -5635,9 +5649,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -5646,24 +5660,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -5673,9 +5687,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5683,28 +5697,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -5977,7 +5991,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] @@ -5997,7 +6011,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.82", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index fd2c8f6..4529a76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "drift-gateway" -version = "1.0.4" +version = "1.1.0" edition = "2021" [dependencies] actix-web = "*" argh = "*" -drift-rs = { git = "https://github.com/drift-labs/drift-rs", tag = "v1.0.0-alpha.0" } +drift-rs = { git = "https://github.com/drift-labs/drift-rs", tag = "v1.0.0-alpha.2" } env_logger = "*" futures-util = "*" log = "*" diff --git a/README.md b/README.md index aec4607..3fc0d9d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Self hosted API gateway to easily interact with Drift V2 Protocol - [Environment Variables](#environment-variables) - [Delegated Signing Mode](#delegated-signing-mode) - [Sub-account Switching](#sub-account-switching) + - [Emulation Mode](#emulation-mode) + - [CU price/limits](#cu-price--limits) 3. [API Examples](#api-examples) - [HTTP API](#http-api) - [`GET` Market Info](#get-market-info) @@ -29,6 +31,8 @@ Self hosted API gateway to easily interact with Drift V2 Protocol - [Websocket API](#websocket-api) - [Subscribing](#subscribing) - [Event Payloads](#event-payloads) + 4. [Errors](#errors) + 5. [FAQ](#faq) ## Build & Run @@ -45,7 +49,7 @@ docker run \ -e DRIFT_GATEWAY_KEY= \ -p 8080:8080 \ --platform linux/x86_64 \ - ghcr.io/drift-labs/gateway https://rpc-provider.example.com --host 0.0.0.0 + ghcr.io/drift-labs/gateway https://rpc-provider.example.com --host 0.0.0.0 --markets wbtc,drift ``` Build the Docker image: @@ -64,7 +68,7 @@ docker run \ -e DRIFT_GATEWAY_KEY= \ -e RUST_LOG=info \ -p 8080:8080 \ - drift-gateway https://api.mainnet-beta.solana.com --host 0.0.0.0 + drift-gateway https://api.mainnet-beta.solana.com --host 0.0.0.0 --markets wbtc,drift ``` ### From Source @@ -96,7 +100,7 @@ drift-gateway --dev https://api.devnet.solana.com # or mainnet # NB: `api.mainnet-beta.solana.com` is not recommend for production use cases -drift-gateway https://rpc-provider.example.com +drift-gateway https://rpc-provider.example.com --markets sol-perp,sol,weth ``` ## Usage @@ -110,6 +114,7 @@ These runtime environment variables are required: | Variable | Description | Example Value | |---------------------|-------------------------------------------|------------------------------| | `DRIFT_GATEWAY_KEY` | Path to your key file or seed in Base58. Transactions will be signed with this keypair | `` or `seedBase58` | +| `INIT_RPC_THROTTLE` | Adds a delay (seconds) between RPC bursts during gateway startup. Useful to avoid 429/rate-limit errors. Can be set to `0`, if RPC node is highspec | `1` | ```bash Usage: drift-gateway [--dev] [--host ] [--port ] [--delegate ] [--emulate ] @@ -120,17 +125,28 @@ Positional Arguments: rpc_host the solana RPC URL Options: - --dev run in devnet mode - --host gateway host address - --port gateway port - --ws-port gateway Ws port - --delegate use delegated signing mode, provide the delegators pubkey - --emulate run the gateway in read-only mode for given authority pubkey - --tx-commitment solana commitment level for transaction confirmation [processed|confirmed|finalized] (default: confirmed) - --commitment solana commitment level for state updates [processed|confirmed|finalized] (default: confirmed) - --default-sub-account-id default sub-account ID for account related operations (default: 0) - --verbose enable debug logging - --skip-tx-preflight skip tx preflight checks + --markets list of markets to trade e.g '--markets sol-perp,wbtc,pyusd' + gateway creates market subscriptions for responsive trading + --dev run in devnet mode + --host gateway host address + --port gateway port + --ws-port gateway Ws port + --keep-alive-timeout + http keep-alive timeout in seconds + --delegate use delegated signing mode provide the delegator's pubkey + (i.e the main account) 'DRIFT_GATEWAY_KEY' should be set to + the delegate's private key + --emulate run the gateway in read-only mode for given authority pubkey + --tx-commitment solana commitment level to use for transaction confirmation + (default: confirmed) + --commitment solana commitment level to use for state updates (default: + confirmed) + --default-sub-account-id + default sub_account_id to use (default: 0) + --skip-tx-preflight + skip tx preflight checks + --verbose enable debug logging + --help display usage information ``` ### Delegated Signing Mode @@ -150,6 +166,14 @@ A `subAccountId` URL query parameter may be supplied to switch the sub-account p e.g `http:///v1/orders?subAccountId=3` will return orders for the wallet's sub-account 3 +## Emulation Mode + +Passing the `--emulate ` flag will instruct the gateway to run in read-only mode. + +The gateway will receive all events, positions, etc. as normal but be unable to send transactions. + +note therefore `DRIFT_GATEWAY_KEY` is not required to be set. + ## CU Price & Limits **CU limit** may be set on transaction request with the query parameter `computeUnitLimit=300000`, the default if unset is `200000`. @@ -765,14 +789,6 @@ settled funding payment event for open perp positions } ``` -## Emulation Mode - -Passing the `--emulate ` flag will instruct the gateway to run in read-only mode. - -The gateway will receive all events, positions, etc. as normal but be unable to send transactions. - -note therefore `DRIFT_GATEWAY_KEY` is not required to be set. - ### Errors error responses have the following JSON structure: @@ -787,9 +803,11 @@ error responses have the following JSON structure: Some endpoints send transactions to the drift program and can return program error codes. The full list of drift program error codes is available in the [API docs](https://drift-labs.github.io/v2-teacher/#errors) -### Common Errors +### FAQ -`AccountNotFound` usually means the drift user (sub)account has not been initialized. +#### `AccountNotFound` + +Usually means the drift user (sub)account has not been initialized. Use the UI or Ts/Python sdk to initialize the sub-account first. ```json @@ -799,8 +817,18 @@ Use the UI or Ts/Python sdk to initialize the sub-account first. } ``` -The free \_api.mainnet-beta.solana.com_RPC cannot be used due to rate-limits on `getProgramAccounts` calls +#### `429`s / gateway hitting RPC rate limits + +this can occur during gateway startup as drift market data is pulled from the network and subscriptions are intialized. +try setting `INIT_RPC_THROTTLE=2` for e.g. 2s or longer, this allows some time between request bursts on start up. + +The free \_api.mainnet-beta.solana.com_ RPC support is limited due to rate-limits ```rust -Some(GetProgramAccounts), kind: Reqwest(reqwest::Error { kind: Status(410), ... +Some(GetProgramAccounts), kind: Reqwest(reqwest::Error { kind: Status(429), ... ``` + +#### Slow queries + +Queries longer than a few _ms_ may be due to missing market subscriptions. +Ensure gateway is properly configured with intended markets. diff --git a/src/controller.rs b/src/controller.rs index 7d96ac7..09adce7 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -1,8 +1,8 @@ -use std::{borrow::Cow, str::FromStr, sync::Arc}; +use std::{borrow::Cow, collections::HashSet, str::FromStr, sync::Arc, time::Duration}; use drift_rs::{ constants::ProgramData, - drift_idl::types::{MarginRequirementType, MarketType}, + drift_idl::{self, types::MarginRequirementType}, event_subscriber::{try_parse_log, CommitmentConfig, RpcClient}, math::{ constants::BASE_PRECISION, @@ -12,14 +12,15 @@ use drift_rs::{ calculate_margin_requirements, }, }, - priority_fee_subscriber::PriorityFeeSubscriber, + priority_fee_subscriber::{PriorityFeeSubscriber, PriorityFeeSubscriberConfig}, types::{ - self, MarketId, ModifyOrderParams, OrderStatus, RpcSendTransactionConfig, SdkError, - VersionedMessage, + self, accounts::SpotMarket, MarketId, MarketType, ModifyOrderParams, OrderStatus, + RpcSendTransactionConfig, SdkError, SdkResult, VersionedMessage, }, DriftClient, Pubkey, TransactionBuilder, Wallet, }; -use log::{debug, warn}; +use futures_util::{stream::FuturesUnordered, StreamExt}; +use log::{debug, info, warn}; use rust_decimal::Decimal; use solana_client::{client_error::ClientErrorKind, rpc_config::RpcTransactionConfig}; use solana_sdk::signature::Signature; @@ -84,6 +85,14 @@ impl AppState { .sub_account(sub_account_id.unwrap_or(self.default_subaccount_id)) } + /// Initialize Gateway Drift client + /// + /// * `endpoint` - Solana RPC node HTTP/S endpoint + /// * `devnet` - whether to run against devnet or not + /// * `wallet` - wallet to use for tx signing + /// * `commitment` - Slot finalisation/commitement levels + /// * `default_subaccount_id` - by default all queries will use this subaccount + /// * `skip_tx_preflight` - submit txs without checking preflight results pub async fn new( endpoint: &str, devnet: bool, @@ -104,34 +113,86 @@ impl AppState { let client = DriftClient::new(context, rpc_client, wallet.clone()) .await .expect("ok"); - client.subscribe().await.expect("subd onchain data"); - let default_subaccount_address = wallet.sub_account(default_subaccount_id.unwrap_or(0)); - if let Err(err) = client.subscribe_account(&default_subaccount_address).await { - log::error!("couldn't subscribe to user updates: {err:?}"); + let default_subaccount = wallet.sub_account(default_subaccount_id.unwrap_or(0)); + if let Err(err) = client.subscribe_account(&default_subaccount).await { + log::error!(target: LOG_TARGET, "couldn't subscribe to user updates: {err:?}"); } else { - log::info!("subscribed to subaccount: {default_subaccount_address}"); + log::info!(target: LOG_TARGET, "subscribed to subaccount: {default_subaccount}"); } - let priority_fee_subscriber = PriorityFeeSubscriber::new( - endpoint.to_string(), + let priority_fee_subscriber = PriorityFeeSubscriber::with_config( + RpcClient::new_with_commitment(endpoint.into(), state_commitment), &[client - .get_perp_market_account(0) + .program_data() + .perp_market_config_by_index(0) .expect("market exists") .pubkey], - ) - .subscribe(); + PriorityFeeSubscriberConfig { + refresh_frequency: Some(Duration::from_millis(400 * 10)), + window: None, + }, + ); + + let priority_fee_subscriber = if !wallet.is_emulating() { + client + .subscribe_blockhashes() + .await + .expect("blockhashes subscribed"); + priority_fee_subscriber.subscribe() + } else { + Arc::new(priority_fee_subscriber) + }; + Self { - delegated: wallet.is_delegated(), - wallet, client: Arc::new(client), + delegated: wallet.is_delegated(), tx_commitment, default_subaccount_id: default_subaccount_id.unwrap_or(0), skip_tx_preflight, priority_fee_subscriber, + wallet, } } + /// Start market and oracle data subscriptions + /// + /// * configured_markets - list of static markets provided by user + /// + /// additional subscriptions will be included based on user's current positions (on default subaccouunt) + pub(crate) async fn subscribe_market_data(&self, configured_markets: &[MarketId]) { + let (spot, perps) = self + .client + .all_positions(&self.default_sub_account()) + .await + .expect("loaded user positions"); + + let mut user_markets: Vec = spot + .iter() + .map(|s| MarketId::spot(s.market_index)) + .chain(perps.iter().map(|p| MarketId::perp(p.market_index))) + .collect(); + user_markets.push(MarketId::QUOTE_SPOT); // usdc needed for most functions + user_markets.extend_from_slice(configured_markets); + + let init_rpc_throttle: u64 = std::env::var("INIT_RPC_THROTTLE") + .map(|s| s.parse().unwrap()) + .unwrap_or(1); + + let markets = Vec::from_iter(HashSet::::from_iter(user_markets).into_iter()); + info!(target: LOG_TARGET, "start market subscriptions: {markets:?}"); + tokio::time::sleep(Duration::from_secs(init_rpc_throttle)).await; + self.client + .subscribe_oracles(&markets) + .await + .expect("oracles subscribed"); + tokio::time::sleep(Duration::from_secs(init_rpc_throttle)).await; + self.client + .subscribe_markets(&markets) + .await + .expect("markets subscribed"); + } + /// Return SOL balance of the tx signing account pub async fn get_sol_balance(&self) -> GatewayResult { let balance = self @@ -186,7 +247,7 @@ impl AppState { .await?; // calculating spot token balance requires knowing the 'spot market account' data - let filtered_spot_positions = all_spot + let filtered_spot_positions: Vec<&drift_idl::types::SpotPosition> = all_spot .iter() .filter(|p| { if let Some(GetPositionsRequest { ref market }) = req { @@ -195,12 +256,22 @@ impl AppState { true } }) - .map(|x| { - let spot_market_info = self - .client - .get_spot_market_account(x.market_index) - .expect("spot market"); - SpotPosition::from_sdk_type(x, &spot_market_info) + .collect(); + + let spot_market_futs = filtered_spot_positions + .iter() + .map(|x| self.client.get_spot_market_account(x.market_index)); + + let spot_market_futs = FuturesUnordered::from_iter(spot_market_futs); + let spot_markets = spot_market_futs + .collect::>>() + .await; + + let filtered_spot_positions = filtered_spot_positions + .iter() + .zip(spot_markets.iter()) + .map(|(position, market)| { + SpotPosition::from_sdk_type(position, market.as_ref().expect("spot market")) }) .collect(); @@ -263,6 +334,7 @@ impl AppState { ) -> GatewayResult { let sub_account = self.resolve_sub_account(ctx.sub_account_id); let user = self.client.get_user_account(&sub_account).await?; + let oracle_price = self .client .oracle_price(MarketId::perp(market.market_index)) @@ -319,7 +391,8 @@ impl AppState { .into_iter() .filter(|o| { if let Some(GetOrdersRequest { ref market }) = req { - o.market_index == market.market_index && o.market_type == market.market_type + o.market_index == market.market_index + && o.market_type == market.market_type.into() } else { true } @@ -327,7 +400,7 @@ impl AppState { .map(|o| { let base_decimals = get_market_decimals( self.client.program_data(), - Market::new(o.market_index, o.market_type), + Market::new(o.market_index, o.market_type.into()), ); Order::from_sdk_order(o, base_decimals) }) @@ -349,7 +422,7 @@ impl AppState { &self, market_index: u16, ) -> GatewayResult { - let perp = self.client.get_perp_market_info(market_index).await?; + let perp = self.client.get_perp_market_account(market_index).await?; let open_interest = (perp.get_open_interest() / BASE_PRECISION) as u64; let max_open_interest = (perp.amm.max_open_interest.as_u128() / BASE_PRECISION) as u64; @@ -661,3 +734,16 @@ pub fn create_wallet( } } } + +/// Wallet extension traits +trait WalletExt { + /// True if the wallet is running in emulation mode (unable to sign txs) + fn is_emulating(&self) -> bool; +} + +impl WalletExt for Wallet { + /// True if the wallet is running in emulation mode (unable to sign txs) + fn is_emulating(&self) -> bool { + self.authority() != &self.signer() && !self.is_delegated() + } +} diff --git a/src/main.rs b/src/main.rs index 077af70..6e262c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use actix_web::{ }; use argh::FromArgs; use drift_rs::{ - types::{CommitmentConfig, MarginRequirementType}, + types::{CommitmentConfig, MarginRequirementType, MarketId}, Pubkey, }; use log::{debug, info, warn}; @@ -240,6 +240,14 @@ async fn main() -> std::io::Result<()> { ) .await; + // start market+oracle subs + let mut markets = Vec::::default(); + if let Some(ref user_markets) = config.markets { + markets.extend(parse_markets(&state.client, user_markets).expect("valid markets")); + }; + state.subscribe_market_data(&markets).await; + info!(target: LOG_TARGET, "subscribed to market data updates 🛜"); + info!( target: LOG_TARGET, "🏛️ gateway listening at http://{}:{}", config.host, config.port @@ -248,7 +256,7 @@ async fn main() -> std::io::Result<()> { if delegate.is_some() { info!( target: LOG_TARGET, - "🪪: authority: {:?}, default sub-account: {:?}, 🔑 delegate: {:?}", + "🪪 authority: {:?}, default sub-account: {:?}, 🔑 delegate: {:?}", state.authority(), state.default_sub_account(), state.signer(), @@ -256,7 +264,7 @@ async fn main() -> std::io::Result<()> { } else { info!( target: LOG_TARGET, - "🪪: authority: {:?}, default sub-account: {:?}", + "🪪 authority: {:?}, default sub-account: {:?}", state.authority(), state.default_sub_account() ); @@ -358,6 +366,11 @@ struct GatewayConfig { /// the solana RPC URL #[argh(positional)] rpc_host: String, + /// list of markets to trade + /// e.g '--markets sol-perp,wbtc,pyusd' + /// gateway creates market subscriptions for responsive trading + #[argh(option)] + markets: Option, /// run in devnet mode #[argh(switch)] dev: bool, @@ -373,7 +386,8 @@ struct GatewayConfig { /// http keep-alive timeout in seconds #[argh(option, default = "3600")] keep_alive_timeout: u32, - /// use delegated signing mode, provide the delegator's pubkey (i.e the main account) + /// use delegated signing mode + /// provide the delegator's pubkey (i.e the main account) /// 'DRIFT_GATEWAY_KEY' should be set to the delegate's private key #[argh(option)] delegate: Option, @@ -389,12 +403,28 @@ struct GatewayConfig { /// default sub_account_id to use (default: 0) #[argh(option, default = "0")] default_sub_account_id: u16, - /// enable debug logging - #[argh(switch)] - verbose: bool, /// skip tx preflight checks #[argh(switch)] skip_tx_preflight: bool, + /// enable debug logging + #[argh(switch)] + verbose: bool, +} + +/// Parse raw markets list from user command +fn parse_markets(client: &drift_rs::DriftClient, markets: &str) -> Result, ()> { + let mut configured_markets = Vec::::default(); + + for ticker in markets.split(",") { + if let Some(market) = client.market_lookup(ticker) { + configured_markets.push(market); + } else { + log::error!(target: LOG_TARGET, "invalid market: {ticker:?}"); + return Err(()); + } + } + + Ok(configured_markets) } #[cfg(test)] diff --git a/src/types.rs b/src/types.rs index 33db1e9..7887926 100644 --- a/src/types.rs +++ b/src/types.rs @@ -31,8 +31,8 @@ pub struct Order { order_type: sdk_types::OrderType, market_index: u16, #[serde( - serialize_with = "market_type_ser", - deserialize_with = "market_type_de" + serialize_with = "ser_market_type", + deserialize_with = "de_market_type" )] market_type: MarketType, amount: Decimal, @@ -55,7 +55,7 @@ impl Order { Order { market_index: value.market_index, - market_type: value.market_type, + market_type: value.market_type.into(), price: Decimal::new(value.price as i64, PRICE_DECIMALS), amount: Decimal::new(value.base_asset_amount as i64 * to_sign, base_decimals), filled: Decimal::new(value.base_asset_amount_filled as i64, base_decimals), @@ -263,26 +263,28 @@ pub struct PlaceOrder { max_ts: Option, } -fn market_type_ser(market_type: &sdk_types::MarketType, serializer: S) -> Result +pub fn ser_market_type(x: &MarketType, s: S) -> Result where S: Serializer, { - let s = match market_type { - sdk_types::MarketType::Spot => "spot", - sdk_types::MarketType::Perp => "perp", - }; - serializer.serialize_str(s) + s.serialize_str(match x { + MarketType::Perp => "perp", + MarketType::Spot => "spot", + }) } -fn market_type_de<'de, D>(deserializer: D) -> Result +pub fn de_market_type<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>, { - let market_type = Deserialize::deserialize(deserializer)?; - match market_type { - "spot" => Ok(sdk_types::MarketType::Spot), - "perp" => Ok(sdk_types::MarketType::Perp), - _ => Err(serde::de::Error::custom("invalid market type")), + let s = String::deserialize(deserializer)?; + match s.as_str() { + "perp" => Ok(MarketType::Perp), + "spot" => Ok(MarketType::Spot), + _ => Err(serde::de::Error::custom(format!( + "unknown market type: {}", + s + ))), } } @@ -310,7 +312,7 @@ impl PlaceOrder { OrderParams { market_index: self.market.market_index, - market_type: self.market.market_type, + market_type: self.market.market_type.into(), order_type: self.order_type, base_asset_amount: base_amount, direction: if self.amount.is_sign_negative() { @@ -342,8 +344,8 @@ pub struct Market { /// The market index pub market_index: u16, #[serde( - serialize_with = "market_type_ser", - deserialize_with = "market_type_de" + serialize_with = "ser_market_type", + deserialize_with = "de_market_type" )] /// The market type (Spot or Perp) pub market_type: MarketType, @@ -650,7 +652,7 @@ mod tests { base_asset_amount: 1 * BASE_PRECISION as u64, price: 0, market_index: 0, - market_type: MarketType::Perp, + market_type: MarketType::Perp.into(), oracle_price_offset: -500_000, ..Default::default() }; @@ -671,7 +673,7 @@ mod tests { let o = drift_rs::types::Order { base_asset_amount: input, price: input, - market_type: MarketType::Perp, + market_type: MarketType::Perp.into(), ..Default::default() }; let gateway_order = Order::from_sdk_order(o, base_decimals); diff --git a/src/websocket.rs b/src/websocket.rs index d3542c7..5105fc5 100644 --- a/src/websocket.rs +++ b/src/websocket.rs @@ -231,8 +231,8 @@ pub(crate) enum AccountEvent { order_id: u32, market_index: u16, #[serde( - serialize_with = "ser_market_type", - deserialize_with = "de_market_type" + serialize_with = "crate::types::ser_market_type", + deserialize_with = "crate::types::de_market_type" )] market_type: MarketType, ts: u64, @@ -372,8 +372,8 @@ pub(crate) struct OrderWithDecimals { pub order_type: OrderType, /// Whether market is spot or perp #[serde( - serialize_with = "ser_market_type", - deserialize_with = "de_market_type" + serialize_with = "crate::types::ser_market_type", + deserialize_with = "crate::types::de_market_type" )] pub market_type: MarketType, /// User generated order id. Can make it easier to place/cancel orders @@ -410,7 +410,7 @@ impl OrderWithDecimals { order_id: value.order_id, market_index: value.market_index, order_type: value.order_type, - market_type: value.market_type, + market_type: value.market_type.into(), user_order_id: value.user_order_id, direction: value.direction, reduce_only: value.reduce_only, @@ -477,31 +477,6 @@ where } } -fn ser_market_type(x: &MarketType, s: S) -> Result -where - S: Serializer, -{ - s.serialize_str(match x { - MarketType::Perp => "perp", - MarketType::Spot => "spot", - }) -} - -fn de_market_type<'de, D>(deserializer: D) -> Result -where - D: Deserializer<'de>, -{ - let s = String::deserialize(deserializer)?; - match s.as_str() { - "perp" => Ok(MarketType::Perp), - "spot" => Ok(MarketType::Spot), - _ => Err(serde::de::Error::custom(format!( - "unknown market type: {}", - s - ))), - } -} - /// Map drift-program events into gateway friendly types for events to the specific UserAccount pub(crate) fn map_drift_event_for_account( program_data: &ProgramData, @@ -527,8 +502,10 @@ pub(crate) fn map_drift_event_for_account( tx_idx, ts, } => { - let decimals = - get_market_decimals(program_data, Market::new(*market_index, *market_type)); + let decimals = get_market_decimals( + program_data, + Market::new(*market_index, (*market_type).into()), + ); let fill = if *maker == Some(sub_account_address) { Some(AccountEvent::fill( maker_side.unwrap(), @@ -542,7 +519,7 @@ pub(crate) fn map_drift_event_for_account( signature, *tx_idx, *market_index, - *market_type, + (*market_type).into(), (*maker).map(|x| x.to_string()), Some(*maker_order_id), Some(*maker_fee), @@ -563,7 +540,7 @@ pub(crate) fn map_drift_event_for_account( signature, *tx_idx, *market_index, - *market_type, + (*market_type).into(), (*maker).map(|x| x.to_string()), Some(*maker_order_id), Some(*maker_fee), @@ -637,7 +614,7 @@ pub(crate) fn map_drift_event_for_account( } => { let decimals = get_market_decimals( program_data, - Market::new(order.market_index, order.market_type), + Market::new(order.market_index, order.market_type.into()), ); ( Channel::Orders,