diff --git a/Cargo.lock b/Cargo.lock index 58ba464..3b6a027 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,6 +89,182 @@ dependencies = [ "alloc-no-stdlib", ] +[[package]] +name = "anchor-attribute-access-control" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2 1.0.50", + "quote 1.0.23", + "regex", + "syn 1.0.107", +] + +[[package]] +name = "anchor-attribute-account" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "anyhow", + "bs58 0.4.0", + "proc-macro2 1.0.50", + "quote 1.0.23", + "rustversion", + "syn 1.0.107", +] + +[[package]] +name = "anchor-attribute-constant" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "proc-macro2 1.0.50", + "syn 1.0.107", +] + +[[package]] +name = "anchor-attribute-error" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "anchor-attribute-event" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "anchor-attribute-interface" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "anyhow", + "heck 0.3.3", + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "anchor-attribute-program" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "anchor-attribute-state" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "anchor-client" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-lang", + "anyhow", + "regex", + "serde", + "solana-client", + "solana-sdk", + "thiserror", + "url", +] + +[[package]] +name = "anchor-derive-accounts" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "anchor-lang" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-attribute-access-control", + "anchor-attribute-account", + "anchor-attribute-constant", + "anchor-attribute-error", + "anchor-attribute-event", + "anchor-attribute-interface", + "anchor-attribute-program", + "anchor-attribute-state", + "anchor-derive-accounts", + "arrayref", + "base64 0.13.1", + "bincode", + "borsh 0.9.3", + "bytemuck", + "solana-program", + "thiserror", +] + +[[package]] +name = "anchor-spl" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anchor-lang", + "solana-program", + "spl-associated-token-account", + "spl-token", +] + +[[package]] +name = "anchor-syn" +version = "0.20.1" +source = "git+https://github.com/project-serum/anchor?tag=v0.20.1#a81ff88d76956533a4ca5ae74d5dec37d7d76b51" +dependencies = [ + "anyhow", + "bs58 0.3.1", + "heck 0.3.3", + "proc-macro2 1.0.50", + "proc-macro2-diagnostics", + "quote 1.0.23", + "serde", + "serde_json", + "sha2 0.9.9", + "syn 1.0.107", + "thiserror", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -216,9 +392,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.62" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "689894c2db1ea643a50834b999abf1c110887402542955ff5451dab8f861f9ed" +checksum = "eff18d764974428cf3a9328e23fc5c986f5fbed46e6cd4cdf42544df5d297ec1" dependencies = [ "proc-macro2 1.0.50", "quote 1.0.23", @@ -375,29 +551,85 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" +[[package]] +name = "borsh" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b13fa9bf62be34702e5ee4526aff22530ae22fe34a0c4290d30d5e4e782e6" +dependencies = [ + "borsh-derive 0.7.2", +] + [[package]] name = "borsh" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" dependencies = [ - "borsh-derive", + "borsh-derive 0.9.3", "hashbrown 0.11.2", ] +[[package]] +name = "borsh-derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6aaa45f8eec26e4bf71e7e5492cf53a91591af8f871f422d550e7cc43f6b927" +dependencies = [ + "borsh-derive-internal 0.7.2", + "borsh-schema-derive-internal 0.7.2", + "proc-macro2 1.0.50", + "syn 1.0.107", +] + +[[package]] +name = "borsh-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307f3740906bac2c118a8122fe22681232b244f1369273e45f1156b45c43d2dd" +dependencies = [ + "borsh-derive-internal 0.8.2", + "borsh-schema-derive-internal 0.8.2", + "proc-macro-crate 0.1.5", + "proc-macro2 1.0.50", + "syn 1.0.107", +] + [[package]] name = "borsh-derive" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", + "borsh-derive-internal 0.9.3", + "borsh-schema-derive-internal 0.9.3", "proc-macro-crate 0.1.5", "proc-macro2 1.0.50", "syn 1.0.107", ] +[[package]] +name = "borsh-derive-internal" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61621b9d3cca65cc54e2583db84ef912d59ae60d2f04ba61bc0d7fc57556bda2" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2104c73179359431cc98e016998f2f23bc7a05bc53e79741bcba705f30047bc" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + [[package]] name = "borsh-derive-internal" version = "0.9.3" @@ -409,6 +641,28 @@ dependencies = [ "syn 1.0.107", ] +[[package]] +name = "borsh-schema-derive-internal" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b38abfda570837b0949c2c7ebd31417e15607861c23eacb2f668c69f6f3bf7" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae29eb8418fcd46f723f8691a2ac06857d31179d33d2f2d91eb13967de97c728" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + [[package]] name = "borsh-schema-derive-internal" version = "0.9.3" @@ -441,6 +695,12 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "bs58" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" + [[package]] name = "bs58" version = "0.4.0" @@ -463,6 +723,27 @@ dependencies = [ "serde", ] +[[package]] +name = "bytecheck" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f" +dependencies = [ + "bytecheck_derive", + "ptr_meta", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + [[package]] name = "bytemuck" version = "1.13.0" @@ -589,9 +870,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.1" +version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec7a4128863c188deefe750ac1d1dfe66c236909f845af04beed823638dc1b2" +checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" dependencies = [ "bitflags", "clap_derive 4.1.0", @@ -608,7 +889,7 @@ version = "3.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" dependencies = [ - "heck", + "heck 0.4.0", "proc-macro-error", "proc-macro2 1.0.50", "quote 1.0.23", @@ -621,7 +902,7 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" dependencies = [ - "heck", + "heck 0.4.0", "proc-macro-error", "proc-macro2 1.0.50", "quote 1.0.23", @@ -1036,9 +1317,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "encode_unicode" @@ -1100,6 +1381,19 @@ dependencies = [ "termcolor", ] +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + [[package]] name = "errno" version = "0.2.8" @@ -1333,7 +1627,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util", + "tokio-util 0.7.2", "tracing", ] @@ -1355,6 +1649,15 @@ dependencies = [ "ahash", ] +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "heck" version = "0.4.0" @@ -1379,6 +1682,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "histogram" version = "0.6.9" @@ -1493,9 +1802,9 @@ checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" dependencies = [ "http", "hyper", - "rustls", + "rustls 0.20.8", "tokio", - "tokio-rustls", + "tokio-rustls 0.23.4", ] [[package]] @@ -1651,7 +1960,7 @@ dependencies = [ "chrono", "clap 3.2.23", "crossbeam-channel", - "env_logger", + "env_logger 0.9.3", "futures", "futures-util", "histogram", @@ -1667,7 +1976,37 @@ dependencies = [ "spl-memo", "thiserror", "tokio", - "tonic", + "tonic 0.8.3", +] + +[[package]] +name = "jito-orca-client" +version = "0.1.0" +dependencies = [ + "anchor-client", + "anchor-lang", + "anchor-spl", + "anyhow", + "clap 4.1.4", + "env_logger 0.10.0", + "futures", + "jito-protos", + "jito-searcher-client", + "log", + "rust_decimal", + "rust_decimal_macros", + "solana-client", + "solana-client-helpers", + "solana-metrics", + "solana-program", + "solana-sdk", + "solana-transaction-status", + "spl-memo", + "spl-token", + "thiserror", + "tokio", + "tonic 0.5.2", + "whirlpool", ] [[package]] @@ -1676,11 +2015,11 @@ version = "0.1.0" dependencies = [ "bincode", "bytes", - "prost", + "prost 0.11.6", "prost-types", "solana-perf", "solana-sdk", - "tonic", + "tonic 0.8.3", "tonic-build", ] @@ -1690,9 +2029,9 @@ version = "0.1.0" dependencies = [ "bincode", "chrono", - "clap 4.1.1", + "clap 4.1.4", "crossbeam-channel", - "env_logger", + "env_logger 0.9.3", "futures", "futures-util", "histogram", @@ -1708,7 +2047,7 @@ dependencies = [ "spl-memo", "thiserror", "tokio", - "tonic", + "tonic 0.8.3", ] [[package]] @@ -1729,7 +2068,7 @@ dependencies = [ "solana-transaction-status", "thiserror", "tokio", - "tonic", + "tonic 0.8.3", ] [[package]] @@ -1978,6 +2317,66 @@ dependencies = [ "winapi", ] +[[package]] +name = "mpl-token-auth-rules" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a14e1ac5350734fd07f17d7eab733d27b7b45ca963642c565ec34ab015d9ceda" +dependencies = [ + "borsh 0.9.3", + "mpl-token-metadata-context-derive", + "num-derive", + "num-traits", + "rmp-serde", + "serde", + "shank", + "solana-program", + "solana-zk-token-sdk", + "thiserror", +] + +[[package]] +name = "mpl-token-metadata" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5accdfde5c18465c65bd664169845a185f8a00d973d5c15396fef858dd2e52d9" +dependencies = [ + "arrayref", + "borsh 0.9.3", + "mpl-token-auth-rules", + "mpl-token-metadata-context-derive", + "mpl-utils", + "num-derive", + "num-traits", + "shank", + "solana-program", + "spl-associated-token-account", + "spl-token", + "thiserror", +] + +[[package]] +name = "mpl-token-metadata-context-derive" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12989bc45715b0ee91944855130131479f9c772e198a910c3eb0ea327d5bffc3" +dependencies = [ + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "mpl-utils" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6195ce98b92f1d0ea06d0cc9b2392d81673e02b8fb063589926fa73ee6b071a" +dependencies = [ + "arrayref", + "borsh 0.9.3", + "solana-program", + "spl-token", +] + [[package]] name = "multimap" version = "0.8.3" @@ -2006,6 +2405,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + [[package]] name = "ntapi" version = "0.3.7" @@ -2126,20 +2534,20 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" +checksum = "8d829733185c1ca374f17e52b762f24f535ec625d2cc1f070e34c8a9068f341b" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.7" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" +checksum = "2be1598bf1c313dcdd12092e3f1920f463462525a21b7b4e11b4168353d0123e" dependencies = [ - "proc-macro-crate 1.2.1", + "proc-macro-crate 1.3.0", "proc-macro2 1.0.50", "quote 1.0.23", "syn 1.0.107", @@ -2232,6 +2640,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "paste" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" + [[package]] name = "pbkdf2" version = "0.4.0" @@ -2372,13 +2786,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] @@ -2423,6 +2836,29 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", + "version_check", + "yansi", +] + +[[package]] +name = "prost" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5e2533f59d08fcf364fd374ebda0692a70bd6d7e66ef97f306f45c6c5d8020" +dependencies = [ + "bytes", + "prost-derive 0.8.0", +] + [[package]] name = "prost" version = "0.11.6" @@ -2430,7 +2866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21dc42e00223fc37204bd4aa177e69420c604ca4a183209a8f9de30c6d934698" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.6", ] [[package]] @@ -2440,14 +2876,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f8ad728fb08fe212df3c05169e940fbb6d9d16a877ddde14644a983ba2012e" dependencies = [ "bytes", - "heck", + "heck 0.4.0", "itertools", "lazy_static", "log", "multimap", "petgraph", "prettyplease", - "prost", + "prost 0.11.6", "prost-types", "regex", "syn 1.0.107", @@ -2455,6 +2891,19 @@ dependencies = [ "which", ] +[[package]] +name = "prost-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "600d2f334aa05acb02a755e217ef1ab6dea4d51b58b7846588b747edec04efba" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + [[package]] name = "prost-derive" version = "0.11.6" @@ -2475,7 +2924,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5e0526209433e96d83d750dd81a99118edbc55739e7e61a46764fd2ad537788" dependencies = [ "bytes", - "prost", + "prost 0.11.6", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", ] [[package]] @@ -2499,11 +2968,11 @@ dependencies = [ "fxhash", "quinn-proto", "quinn-udp", - "rustls", + "rustls 0.20.8", "thiserror", "tokio", "tracing", - "webpki", + "webpki 0.22.0", ] [[package]] @@ -2516,14 +2985,14 @@ dependencies = [ "fxhash", "rand 0.8.5", "ring", - "rustls", - "rustls-native-certs", + "rustls 0.20.8", + "rustls-native-certs 0.6.2", "rustls-pemfile 0.2.1", "slab", "thiserror", "tinyvec", "tracing", - "webpki", + "webpki 0.22.0", ] [[package]] @@ -2650,9 +3119,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.10.1" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3" +checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -2718,6 +3187,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "rend" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95" +dependencies = [ + "bytecheck", +] + [[package]] name = "reqwest" version = "0.11.14" @@ -2742,20 +3220,20 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.20.8", "rustls-pemfile 1.0.2", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-rustls", - "tokio-util", + "tokio-rustls 0.23.4", + "tokio-util 0.7.2", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots", + "webpki-roots 0.22.6", "winreg", ] @@ -2774,6 +3252,53 @@ dependencies = [ "winapi", ] +[[package]] +name = "rkyv" +version = "0.7.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15" +dependencies = [ + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eaedadc88b53e36dd32d940ed21ae4d850d5916f2581526921f553a72ac34c4" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "syn 1.0.107", +] + +[[package]] +name = "rmp" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5b13be192e0220b8afb7222aa5813cb62cc269ebb5cac346ca6487681d2913e" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + [[package]] name = "rpassword" version = "6.0.1" @@ -2786,12 +3311,46 @@ dependencies = [ "winapi", ] +[[package]] +name = "rust_decimal" +version = "1.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe32e8c89834541077a5c5bbe5691aa69324361e27e6aeb3552a737db4a70c8" +dependencies = [ + "arrayvec", + "borsh 0.9.3", + "bytecheck", + "byteorder", + "bytes", + "num-traits", + "rand 0.8.5", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rust_decimal_macros" +version = "1.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71a78314ee3b7e684f34f1574fe0935cac8eb453217974473be82f032d9b4ee" +dependencies = [ + "quote 1.0.23", + "rust_decimal", +] + [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + [[package]] name = "rustc_version" version = "0.4.0" @@ -2824,6 +3383,19 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64 0.13.1", + "log", + "ring", + "sct 0.6.1", + "webpki 0.21.4", +] + [[package]] name = "rustls" version = "0.20.8" @@ -2832,8 +3404,20 @@ checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", "ring", - "sct", - "webpki", + "sct 0.7.0", + "webpki 0.22.0", +] + +[[package]] +name = "rustls-native-certs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +dependencies = [ + "openssl-probe", + "rustls 0.19.1", + "schannel", + "security-framework", ] [[package]] @@ -2899,6 +3483,16 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "sct" version = "0.7.0" @@ -2909,11 +3503,17 @@ dependencies = [ "untrusted", ] +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + [[package]] name = "security-framework" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645926f31b250a2dca3c232496c2d898d91036e45ca0e97e0e2390c54e11be36" +checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" dependencies = [ "bitflags", "core-foundation", @@ -3059,6 +3659,40 @@ dependencies = [ "keccak", ] +[[package]] +name = "shank" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63e565b5e95ad88ab38f312e89444c749360641c509ef2de0093b49f55974a5" +dependencies = [ + "shank_macro", +] + +[[package]] +name = "shank_macro" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63927d22a1e8b74bda98cc6e151fcdf178b7abb0dc6c4f81e0bbf5ffe2fc4ec8" +dependencies = [ + "proc-macro2 1.0.50", + "quote 1.0.23", + "shank_macro_impl", + "syn 1.0.107", +] + +[[package]] +name = "shank_macro_impl" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ce03403df682f80f4dc1efafa87a4d0cb89b03726d0565e6364bdca5b9a441" +dependencies = [ + "anyhow", + "proc-macro2 1.0.50", + "quote 1.0.23", + "serde", + "syn 1.0.107", +] + [[package]] name = "shell-words" version = "1.1.0" @@ -3124,7 +3758,7 @@ dependencies = [ "Inflector", "base64 0.13.1", "bincode", - "bs58", + "bs58 0.4.0", "bv", "lazy_static", "serde", @@ -3205,7 +3839,7 @@ dependencies = [ "async-trait", "base64 0.13.1", "bincode", - "bs58", + "bs58 0.4.0", "bytes", "clap 2.34.0", "crossbeam-channel", @@ -3224,7 +3858,7 @@ dependencies = [ "rand_chacha 0.2.2", "rayon", "reqwest", - "rustls", + "rustls 0.20.8", "semver", "serde", "serde_derive", @@ -3249,6 +3883,20 @@ dependencies = [ "url", ] +[[package]] +name = "solana-client-helpers" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13b109be3d34e0d16fd424c0dbd23a18dad4b522f8c98c14e56423ce9b28b67c" +dependencies = [ + "solana-client", + "solana-sdk", + "spl-associated-token-account", + "spl-token", + "spl-token-swap", + "thiserror", +] + [[package]] name = "solana-config-program" version = "1.14.13" @@ -3296,7 +3944,7 @@ dependencies = [ "ahash", "blake3", "block-buffer 0.9.0", - "bs58", + "bs58 0.4.0", "bv", "byteorder", "cc", @@ -3339,7 +3987,7 @@ version = "1.14.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447d16a70a1b5383736ef44801050c0e1affd022303b22ed899352f958c2de4b" dependencies = [ - "env_logger", + "env_logger 0.9.3", "lazy_static", "log", ] @@ -3427,9 +4075,9 @@ dependencies = [ "bincode", "bitflags", "blake3", - "borsh", - "borsh-derive", - "bs58", + "borsh 0.9.3", + "borsh-derive 0.9.3", + "bs58 0.4.0", "bv", "bytemuck", "cc", @@ -3532,8 +4180,8 @@ dependencies = [ "base64 0.13.1", "bincode", "bitflags", - "borsh", - "bs58", + "borsh 0.9.3", + "bs58 0.4.0", "bytemuck", "byteorder", "chrono", @@ -3579,7 +4227,7 @@ version = "1.14.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d0acbad862093ea123f3a27364336dcb0c8373522cd6810496a34e932c56c1" dependencies = [ - "bs58", + "bs58 0.4.0", "proc-macro2 1.0.50", "quote 1.0.23", "rustversion", @@ -3606,7 +4254,7 @@ dependencies = [ "quinn", "rand 0.7.3", "rcgen", - "rustls", + "rustls 0.20.8", "solana-metrics", "solana-perf", "solana-sdk", @@ -3624,8 +4272,8 @@ dependencies = [ "Inflector", "base64 0.13.1", "bincode", - "borsh", - "bs58", + "borsh 0.9.3", + "bs58 0.4.0", "lazy_static", "log", "serde", @@ -3735,7 +4383,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbc000f0fdf1f12f99d77d398137c1751345b18c88258ce0f99b7872cf6c9bd6" dependencies = [ "assert_matches", - "borsh", + "borsh 0.9.3", "num-derive", "num-traits", "solana-program", @@ -3744,6 +4392,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "spl-math" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ecdd22720b9e5ab578a862928f5010ca197419502bdace600ccd5d23dae9352" +dependencies = [ + "borsh 0.7.2", + "borsh-derive 0.8.2", + "num-derive", + "num-traits", + "solana-program", + "thiserror", + "uint 0.8.5", +] + [[package]] name = "spl-memo" version = "3.0.1" @@ -3786,6 +4449,28 @@ dependencies = [ "thiserror", ] +[[package]] +name = "spl-token-swap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c63b79be6174568e8724912b15e62d0c6b0424ac98397e9a5a867ac2881553af" +dependencies = [ + "arrayref", + "enum_dispatch", + "num-derive", + "num-traits", + "solana-program", + "spl-math", + "spl-token", + "thiserror", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.8.0" @@ -4015,15 +4700,26 @@ dependencies = [ "syn 1.0.107", ] +[[package]] +name = "tokio-rustls" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +dependencies = [ + "rustls 0.19.1", + "tokio", + "webpki 0.21.4", +] + [[package]] name = "tokio-rustls" version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ - "rustls", + "rustls 0.20.8", "tokio", - "webpki", + "webpki 0.22.0", ] [[package]] @@ -4045,12 +4741,26 @@ checksum = "f714dd15bead90401d77e04243611caec13726c2408afd5b31901dfcdcb3b181" dependencies = [ "futures-util", "log", - "rustls", + "rustls 0.20.8", "tokio", - "tokio-rustls", + "tokio-rustls 0.23.4", "tungstenite", - "webpki", - "webpki-roots", + "webpki 0.22.0", + "webpki-roots 0.22.6", +] + +[[package]] +name = "tokio-util" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", ] [[package]] @@ -4076,6 +4786,57 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" + +[[package]] +name = "toml_edit" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "729bfd096e40da9c001f778f5cdecbd2957929a24e10e5883d9392220a751581" +dependencies = [ + "indexmap", + "nom8", + "toml_datetime", +] + +[[package]] +name = "tonic" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "796c5e1cd49905e65dd8e700d4cb1dffcbfdb4fc9d017de08c1a537afd83627c" +dependencies = [ + "async-stream", + "async-trait", + "base64 0.13.1", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost 0.8.0", + "prost-derive 0.8.0", + "rustls-native-certs 0.5.0", + "tokio", + "tokio-rustls 0.22.0", + "tokio-stream", + "tokio-util 0.6.10", + "tower", + "tower-layer", + "tower-service", + "tracing", + "tracing-futures", + "webpki-roots 0.21.1", +] + [[package]] name = "tonic" version = "0.8.3" @@ -4096,20 +4857,20 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost", - "prost-derive", - "rustls-native-certs", + "prost 0.11.6", + "prost-derive 0.11.6", + "rustls-native-certs 0.6.2", "rustls-pemfile 1.0.2", "tokio", - "tokio-rustls", + "tokio-rustls 0.23.4", "tokio-stream", - "tokio-util", + "tokio-util 0.7.2", "tower", "tower-layer", "tower-service", "tracing", "tracing-futures", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -4139,7 +4900,7 @@ dependencies = [ "rand 0.8.5", "slab", "tokio", - "tokio-util", + "tokio-util 0.7.2", "tower-layer", "tower-service", "tracing", @@ -4238,13 +4999,13 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "rustls", + "rustls 0.20.8", "sha-1", "thiserror", "url", "utf-8", - "webpki", - "webpki-roots", + "webpki 0.22.0", + "webpki-roots 0.22.6", ] [[package]] @@ -4253,6 +5014,30 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "uint" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" +dependencies = [ + "byteorder", + "crunchy", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unicode-bidi" version = "0.3.10" @@ -4274,6 +5059,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "unicode-width" version = "0.1.10" @@ -4451,6 +5242,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "webpki" version = "0.22.0" @@ -4461,13 +5262,22 @@ dependencies = [ "untrusted", ] +[[package]] +name = "webpki-roots" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +dependencies = [ + "webpki 0.21.4", +] + [[package]] name = "webpki-roots" version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki", + "webpki 0.22.0", ] [[package]] @@ -4481,6 +5291,21 @@ dependencies = [ "once_cell", ] +[[package]] +name = "whirlpool" +version = "0.1.0" +source = "git+https://github.com/orca-so/whirlpools?tag=0.2.0#34040c0645094dbf70ed31480a7d5c0804371620" +dependencies = [ + "anchor-lang", + "anchor-spl", + "borsh 0.9.3", + "mpl-token-metadata", + "solana-program", + "spl-token", + "thiserror", + "uint 0.9.5", +] + [[package]] name = "winapi" version = "0.3.9" @@ -4605,6 +5430,12 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + [[package]] name = "yasna" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 59e4881..cfe4356 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,6 @@ members = [ "backrun", "cli", "jito_protos", + "orca_client", "searcher_client", ] diff --git a/orca_client/Cargo.toml b/orca_client/Cargo.toml new file mode 100644 index 0000000..d1df79a --- /dev/null +++ b/orca_client/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "jito-orca-client" +version = "0.1.0" +edition = "2021" + +[dependencies] +futures = "0.3.1" +solana-client = "=1.14.13" +solana-metrics = "=1.14.13" +solana-sdk = "=1.14.13" +solana-transaction-status = "=1.14.13" +solana-program="1.14.13" +spl-token = "3.5.0" +spl-memo = "3.0.1" +thiserror = "1.0.34" +tokio = { version = "~1.14.1", features = ["rt-multi-thread"] } +tonic = { version = "0.5.2", features = ["tls", "tls-roots", "tls-webpki-roots"] } +log = "0.4.17" +jito-protos = { path = "../jito_protos" } +jito-searcher-client = { path = "../searcher_client" } +solana-client-helpers = "1.1.0" +clap = {version = "4.1.4", features = ["derive", "env"]} + +anchor-lang = { git = "https://github.com/project-serum/anchor", tag = "v0.20.1", version = "0.20.1", package = "anchor-lang" } +anchor-spl = { git = "https://github.com/project-serum/anchor", tag = "v0.20.1", version = "0.20.1", package = "anchor-spl" } +anchor-client = { git = "https://github.com/project-serum/anchor", tag = "v0.20.1", version = "0.20.1", package = "anchor-client" } +anyhow = "1.0.68" +whirlpool = { git = "https://github.com/orca-so/whirlpools", tag = "0.2.0", package = "whirlpool", features = ["cpi"] } +rust_decimal = { version = "1.23", features = ["maths"] } +rust_decimal_macros = "1.23" +env_logger = "0.10.0" + diff --git a/orca_client/src/main.rs b/orca_client/src/main.rs new file mode 100644 index 0000000..42c862f --- /dev/null +++ b/orca_client/src/main.rs @@ -0,0 +1,148 @@ +mod orca; +mod orca_utils; + +use std::{env, rc::Rc, str::FromStr, sync::Arc, time::Duration}; + +use anchor_client::{Client as AnchorClient, Cluster}; +use clap::Parser; +use env_logger::TimestampPrecision; +use jito_protos::searcher::{NextScheduledLeaderRequest, SubscribeBundleResultsRequest}; +use jito_searcher_client::{get_searcher_client, send_bundle_with_confirmation}; +use log::info; +use orca::swap; +use solana_client::{nonblocking::rpc_client::RpcClient as AsyncRpcClient, rpc_client::RpcClient}; +use solana_client_helpers::Client as SolanaClient; +use solana_program::pubkey::Pubkey; +use solana_sdk::{ + commitment_config::CommitmentConfig, + signature::{read_keypair_file, Signer}, + system_instruction::transfer, + transaction::{Transaction, VersionedTransaction}, +}; +use spl_memo::build_memo; +use tokio::time::sleep; + +#[derive(Parser, Debug)] +#[clap(author, version, about, long_about=None)] +struct Args { + #[clap(long, env)] + rpc_url: String, + + #[clap(long, env)] + rpc_ws_url: String, + + #[clap(long, env)] + keypair_path: String, + + #[clap(long, env)] + block_engine_url: String, + + #[clap(long, env)] + tip_account: String, +} + +/// Example of how to build orca swap from SAMO-> USDC with a memo and submit as a bundle +fn main() { + let args: Args = Args::parse(); + if env::var("RUST_LOG").is_err() { + env::set_var("RUST_LOG", "info") + } + env_logger::builder() + .format_timestamp(Some(TimestampPrecision::Micros)) + .init(); + + let connection = + RpcClient::new_with_commitment(args.rpc_url.to_string(), CommitmentConfig::confirmed()); + + let payer = + read_keypair_file(args.keypair_path.clone()).expect("example requires a keypair file"); + + let payer_pubkey = payer.pubkey(); + + let solana_client = SolanaClient { + client: connection, + payer, + }; + let auth_keypair = + Arc::new(read_keypair_file(args.keypair_path.clone()).expect("reads keypair at path")); + + // build Anchor client + let cluster = Cluster::Custom(args.rpc_url.clone(), args.rpc_ws_url); + let payer = + read_keypair_file(args.keypair_path.clone()).expect("example requires a keypair file"); + let anchor_client = AnchorClient::new_with_options( + cluster.clone(), + Rc::new(payer), + CommitmentConfig::confirmed(), + ); + + let program = anchor_client.program(whirlpool::id()); + let instructions = swap(100000, &solana_client, program, payer_pubkey).unwrap(); + + let blockhash = solana_client + .client + .get_latest_blockhash() + .expect("get blockhash"); + + let payer = + read_keypair_file(args.keypair_path.clone()).expect("example requires a keypair file"); + // TODO: make these mutable so that we can pass in a more recent blockhash once jito is leader + + let tip_account = Pubkey::from_str(&args.tip_account).expect("valid pubkey for tip account"); + + let tx_0 = VersionedTransaction::from(Transaction::new_signed_with_payer( + &[ + build_memo( + format!("i b swimmin in da mempool 🏊🏊🏊🏊").as_bytes(), + &[], + ), + transfer(&payer.pubkey(), &tip_account, 10000), + ], + Some(&payer_pubkey), + &[&payer], + blockhash.clone(), + )); + let tx_1 = VersionedTransaction::from(Transaction::new_signed_with_payer( + instructions.as_ref(), + Some(&payer_pubkey), + &[&payer], + blockhash.clone(), + )); + + let rt = tokio::runtime::Runtime::new().unwrap(); + + rt.block_on(async { + let mut searcher_client = + get_searcher_client(args.block_engine_url.as_str(), &auth_keypair) + .await + .unwrap(); + // wait for jito-solana leader slot + let mut is_leader_slot = false; + while !is_leader_slot { + let next_leader = searcher_client + .get_next_scheduled_leader(NextScheduledLeaderRequest {}) + .await + .expect("gets next scheduled leader") + .into_inner(); + let num_slots = next_leader.next_leader_slot - next_leader.current_slot; + is_leader_slot = num_slots <= 2; + info!("next jito leader slot in {num_slots} slots"); + sleep(Duration::from_millis(500)).await; + } + let mut bundle_results_subscription = searcher_client + .subscribe_bundle_results(SubscribeBundleResultsRequest {}) + .await + .expect("subscribe to bundle results") + .into_inner(); + info!("bundle resu"); + send_bundle_with_confirmation( + &[tx_0, tx_1], + &AsyncRpcClient::new(args.rpc_url.clone()), + &mut searcher_client, + &mut bundle_results_subscription, + ) + .await + .unwrap(); + info!("done"); + }); +} diff --git a/orca_client/src/orca.rs b/orca_client/src/orca.rs new file mode 100644 index 0000000..b4723d1 --- /dev/null +++ b/orca_client/src/orca.rs @@ -0,0 +1,132 @@ +use anchor_client::Program; +use anchor_lang::{ + prelude::*, + solana_program::{instruction::Instruction, pubkey}, + AccountDeserialize, +}; +use anyhow::Result; +use log::info; +use solana_client_helpers::{ + spl_associated_token_account::get_associated_token_address, Client as SolanaClient, +}; +use spl_token::ID as TOKEN_PROGRAM_ID; +use whirlpool::{ + math::MIN_SQRT_PRICE_X64, + state::{TickArray, Whirlpool}, +}; + +use crate::orca_utils::*; + +const ORCA_WHIRLPOOL_PROGRAM_ID: Pubkey = pubkey!("whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"); + +// SAMO/USDC(64) whirlpool need to be cloned on local-validator +const SAMO_USDC_WHIRLPOOL_ADDRESS: Pubkey = pubkey!("9vqYJjDUFecLL2xPUC4Rc7hyCtZ6iJ4mDiVZX7aFXoAe"); + +pub fn swap( + amount_in: u64, + solana_client: &SolanaClient, + program: Program, + payer_pubkey: Pubkey, +) -> Result> { + // swap input + let a_to_b = true; + + // get whirlpool + let mut whirlpool_data: &[u8] = &solana_client + .get_account_data(&SAMO_USDC_WHIRLPOOL_ADDRESS) + .unwrap(); + let whirlpool = Whirlpool::try_deserialize(&mut whirlpool_data).unwrap(); + + info!( + "whirlpool token_mint_a {}", + whirlpool.token_mint_a.to_string() + ); + info!( + "whirlpool token_mint_b {}", + whirlpool.token_mint_b.to_string() + ); + info!( + "whirlpool token_vault_a {}", + whirlpool.token_vault_a.to_string() + ); + info!( + "whirlpool token_vault_b {}", + whirlpool.token_vault_b.to_string() + ); + info!("whirlpool tick_spacing {}", whirlpool.tick_spacing); + info!( + "whirlpool tick_current_index {}", + whirlpool.tick_current_index + ); + info!("whirlpool sqrt_price {}", whirlpool.sqrt_price); + + // get tickarray for swap + let tick_arrays = poolutil_get_tick_array_pubkeys_for_swap( + whirlpool.tick_current_index, + whirlpool.tick_spacing, + a_to_b, + &ORCA_WHIRLPOOL_PROGRAM_ID, + &SAMO_USDC_WHIRLPOOL_ADDRESS, + ); + let mut ta0_data: &[u8] = &solana_client.get_account_data(&tick_arrays[0]).unwrap(); + let mut ta1_data: &[u8] = &solana_client.get_account_data(&tick_arrays[1]).unwrap(); + let mut ta2_data: &[u8] = &solana_client.get_account_data(&tick_arrays[2]).unwrap(); + let ta0 = TickArray::try_deserialize(&mut ta0_data).unwrap(); + let ta1 = TickArray::try_deserialize(&mut ta1_data).unwrap(); + let ta2 = TickArray::try_deserialize(&mut ta2_data).unwrap(); + + info!("tick_arrays[0] {}", tick_arrays[0].to_string()); + info!("tick_arrays[1] {}", tick_arrays[1].to_string()); + info!("tick_arrays[2] {}", tick_arrays[2].to_string()); + + // get quote + let [quote_amount_in, quote_amount_out] = get_swap_quote( + &whirlpool, + [ta0, ta1, ta2], + amount_in, + true, // amount is input amount + a_to_b, + ); + let amount_out = calc_slippage(quote_amount_out, 1, 100); // 1% + info!("quote amount_in {}", quote_amount_in); + info!("quote amount_out {}", quote_amount_out); + info!("amount_out (slippage included) {}", amount_out); + + // get oracle + let oracle = pdautil_get_oracle(&ORCA_WHIRLPOOL_PROGRAM_ID, &SAMO_USDC_WHIRLPOOL_ADDRESS); + + // get ATA + // - Assume that the ATA has already been created + // - If one token of pair is SOL, the WSOL account must be processed (avoid SOL in this example) + let ata_a = get_associated_token_address(&payer_pubkey, &whirlpool.token_mint_a); + let ata_b = get_associated_token_address(&payer_pubkey, &whirlpool.token_mint_b); + info!("ata_a {}", ata_a.to_string()); + info!("ata_b {}", ata_b.to_string()); + + // execute proxy_swap + let instructions = program + .request() + .accounts(whirlpool::accounts::Swap { + whirlpool: SAMO_USDC_WHIRLPOOL_ADDRESS, + token_program: TOKEN_PROGRAM_ID, + token_authority: payer_pubkey, + token_owner_account_a: ata_a, + token_owner_account_b: ata_b, + token_vault_a: whirlpool.token_vault_a, + token_vault_b: whirlpool.token_vault_b, + tick_array_0: tick_arrays[0], + tick_array_1: tick_arrays[1], + tick_array_2: tick_arrays[2], + oracle, + }) + .args(whirlpool::instruction::Swap { + a_to_b: a_to_b, + amount_specified_is_input: true, + other_amount_threshold: amount_out, + sqrt_price_limit: MIN_SQRT_PRICE_X64, // a to b + amount: amount_in, + }) + .instructions()?; + + Ok(instructions) +} diff --git a/orca_client/src/orca_utils.rs b/orca_client/src/orca_utils.rs new file mode 100644 index 0000000..813eca1 --- /dev/null +++ b/orca_client/src/orca_utils.rs @@ -0,0 +1,120 @@ +/// Helper functions courtesy of @yugure-orca ( https://github.com/yugure-orca/whirlpools ) +use std::cell::RefCell; + +use anchor_client::solana_sdk::pubkey::Pubkey; +use whirlpool::{ + manager::swap_manager::swap, + math::{MAX_SQRT_PRICE_X64, MIN_SQRT_PRICE_X64}, + state::{TickArray, Whirlpool, MAX_TICK_INDEX, MIN_TICK_INDEX, TICK_ARRAY_SIZE}, + util::SwapTickSequence, +}; + +pub fn div_floor(a: i32, b: i32) -> i32 { + if a < 0 && a % b != 0 { + a / b - 1 + } else { + a / b + } +} + +pub fn tickutil_get_start_tick_index( + tick_current_index: i32, + tick_spacing: u16, + offset: i32, +) -> i32 { + let ticks_in_array = TICK_ARRAY_SIZE * tick_spacing as i32; + let real_index = div_floor(tick_current_index, ticks_in_array); + let start_tick_index = (real_index + offset) * ticks_in_array; + + assert!(MIN_TICK_INDEX <= start_tick_index); + assert!(start_tick_index + ticks_in_array <= MAX_TICK_INDEX); + start_tick_index +} + +pub fn pdautil_get_tick_array( + program_id: &Pubkey, + whirlpool_pubkey: &Pubkey, + start_tick_index: i32, +) -> Pubkey { + let start_tick_index_str = start_tick_index.to_string(); + let seeds = [ + b"tick_array", + whirlpool_pubkey.as_ref(), + start_tick_index_str.as_bytes(), + ]; + let (pubkey, _bump) = Pubkey::find_program_address(&seeds, program_id); + pubkey +} + +pub fn poolutil_get_tick_array_pubkeys_for_swap( + tick_current_index: i32, + tick_spacing: u16, + a_to_b: bool, + program_id: &Pubkey, + whirlpool_pubkey: &Pubkey, +) -> [Pubkey; 3] { + let mut offset = 0; + let mut pubkeys: [Pubkey; 3] = Default::default(); + let shifted = if a_to_b { 0i32 } else { tick_spacing as i32 }; + + for i in 0..pubkeys.len() { + let start_tick_index = + tickutil_get_start_tick_index(tick_current_index + shifted, tick_spacing, offset); + let tick_array_pubkey = + pdautil_get_tick_array(program_id, whirlpool_pubkey, start_tick_index); + pubkeys[i] = tick_array_pubkey; + offset = if a_to_b { offset - 1 } else { offset + 1 }; + } + + pubkeys +} + +pub fn pdautil_get_oracle(program_id: &Pubkey, whirlpool_pubkey: &Pubkey) -> Pubkey { + let seeds = [b"oracle", whirlpool_pubkey.as_ref()]; + let (pubkey, _bump) = Pubkey::find_program_address(&seeds, program_id); + pubkey +} + +pub fn get_swap_quote( + whirlpool: &Whirlpool, + tick_arrays: [TickArray; 3], + amount: u64, + amount_specified_is_input: bool, + a_to_b: bool, +) -> [u64; 2] { + let ta0_refcell = RefCell::new(tick_arrays[0]); + let ta1_refcell = RefCell::new(tick_arrays[1]); + let ta2_refcell = RefCell::new(tick_arrays[2]); + let mut swap_tick_sequence = SwapTickSequence::new( + ta0_refcell.borrow_mut(), + Some(ta1_refcell.borrow_mut()), + Some(ta2_refcell.borrow_mut()), + ); + + // dummy + let timestamp = whirlpool.reward_last_updated_timestamp; + let sqrt_price_limit = if a_to_b { + MIN_SQRT_PRICE_X64 + } else { + MAX_SQRT_PRICE_X64 + }; + + let swap_update = swap( + whirlpool, + &mut swap_tick_sequence, + amount, + sqrt_price_limit, + amount_specified_is_input, + a_to_b, + timestamp, + ) + .unwrap(); + + [swap_update.amount_a, swap_update.amount_b] +} + +pub fn calc_slippage(amount: u64, slippage_num: u64, slippage_denom: u64) -> u64 { + let num = (slippage_denom - slippage_num) as u128; + let denom = slippage_denom as u128; + u64::try_from((amount as u128) * num / denom).unwrap() +} diff --git a/searcher_client/src/lib.rs b/searcher_client/src/lib.rs index e6a1baf..7c3e5a1 100644 --- a/searcher_client/src/lib.rs +++ b/searcher_client/src/lib.rs @@ -121,7 +121,7 @@ pub async fn send_bundle_with_confirmation( Some(Reason::WinningBatchBidRejected(WinningBatchBidRejected { auction_id, simulated_bid_lamports, - msg: _ + msg: _, })) => { return Err(Box::new(BundleRejectionError::WinningBatchBidRejected( auction_id, @@ -131,7 +131,7 @@ pub async fn send_bundle_with_confirmation( Some(Reason::StateAuctionBidRejected(StateAuctionBidRejected { auction_id, simulated_bid_lamports, - msg: _ + msg: _, })) => { return Err(Box::new(BundleRejectionError::StateAuctionBidRejected( auction_id,