From d31df7cde06f2c920fc98a9c2934cbe946d3bee6 Mon Sep 17 00:00:00 2001 From: Arrowana Date: Mon, 17 Jul 2023 14:17:09 +1000 Subject: [PATCH] Jupiter changes for jupiter-core compat --- Cargo.lock | 270 +++++++++++++----- Cargo.toml | 11 +- .../stakedex_interface/src/instructions.rs | 102 ++----- libs/marinade/src/lib.rs | 26 +- libs/spl_stake_pool/Cargo.toml | 7 +- libs/spl_stake_pool/src/lib.rs | 1 + libs/unstake_it/src/lib.rs | 3 +- stakedex_sdk/Cargo.toml | 1 + stakedex_sdk/tests/test_main.rs | 30 +- 9 files changed, 259 insertions(+), 192 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47948be..cbfcc40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1975,7 +1975,7 @@ dependencies = [ [[package]] name = "lido" version = "1.3.6" -source = "git+https://github.com/jup-ag/solido?branch=jupiter#ec25a9b9f3415bf5fd0354cf3ae6d239c28e2c87" +source = "git+https://github.com/jup-ag/solido?rev=2c85ddf7b50d8162d2b81d79d7fcbfd5e05dc967#2c85ddf7b50d8162d2b81d79d7fcbfd5e05dc967" dependencies = [ "arrayref", "borsh 0.10.3", @@ -2023,14 +2023,11 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "marinade_finance_interface" -version = "0.1.0" -source = "git+https://github.com/igneous-labs/marinade_finance_interface?branch=master#4d1895b6b1c34d731c1589e6d8a6c8feb6258152" +version = "0.0.0" +source = "git+https://github.com/jup-ag/marinade_finance_interface?rev=5747b5350c5505fc2ea597c3f8ae1f8cf71c363d#5747b5350c5505fc2ea597c3f8ae1f8cf71c363d" dependencies = [ "borsh 0.10.3", - "num-derive 0.4.1", - "num-traits", "solana-program", - "thiserror", ] [[package]] @@ -3394,10 +3391,10 @@ dependencies = [ "serde_json", "solana-config-program", "solana-sdk", - "spl-token 4.0.0", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "spl-token-2022 1.0.0", "spl-token-group-interface", - "spl-token-metadata-interface", + "spl-token-metadata-interface 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror", "zstd", ] @@ -4004,8 +4001,8 @@ dependencies = [ "solana-account-decoder", "solana-sdk", "spl-associated-token-account", - "spl-memo", - "spl-token 4.0.0", + "spl-memo 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "spl-token-2022 1.0.0", "thiserror", ] @@ -4144,7 +4141,7 @@ dependencies = [ "num-derive 0.4.1", "num-traits", "solana-program", - "spl-token 4.0.0", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "spl-token-2022 1.0.0", "thiserror", ] @@ -4157,7 +4154,27 @@ checksum = "cce5d563b58ef1bb2cdbbfe0dfb9ffdc24903b10ae6a4df2d8f425ece375033f" dependencies = [ "bytemuck", "solana-program", - "spl-discriminator-derive", + "spl-discriminator-derive 0.1.1", +] + +[[package]] +name = "spl-discriminator" +version = "0.1.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "bytemuck", + "solana-program", + "spl-discriminator-derive 0.1.0", +] + +[[package]] +name = "spl-discriminator-derive" +version = "0.1.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "quote", + "spl-discriminator-syn 0.1.0", + "syn 2.0.41", ] [[package]] @@ -4167,10 +4184,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fadbefec4f3c678215ca72bd71862697bb06b41fd77c0088902dd3203354387b" dependencies = [ "quote", - "spl-discriminator-syn", + "spl-discriminator-syn 0.1.1", "syn 2.0.41", ] +[[package]] +name = "spl-discriminator-syn" +version = "0.1.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "proc-macro2", + "quote", + "solana-program", + "syn 2.0.41", + "thiserror", +] + [[package]] name = "spl-discriminator-syn" version = "0.1.1" @@ -4213,6 +4242,19 @@ dependencies = [ "uint 0.9.5", ] +[[package]] +name = "spl-math" +version = "0.2.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "borsh 0.10.3", + "num-derive 0.4.1", + "num-traits", + "solana-program", + "thiserror", + "uint 0.9.5", +] + [[package]] name = "spl-memo" version = "4.0.0" @@ -4222,6 +4264,14 @@ dependencies = [ "solana-program", ] +[[package]] +name = "spl-memo" +version = "4.0.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "solana-program", +] + [[package]] name = "spl-pod" version = "0.1.0" @@ -4232,7 +4282,19 @@ dependencies = [ "bytemuck", "solana-program", "solana-zk-token-sdk", - "spl-program-error", + "spl-program-error 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "spl-pod" +version = "0.1.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "borsh 0.10.3", + "bytemuck", + "solana-program", + "solana-zk-token-sdk", + "spl-program-error 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", ] [[package]] @@ -4244,10 +4306,33 @@ dependencies = [ "num-derive 0.4.1", "num-traits", "solana-program", - "spl-program-error-derive", + "spl-program-error-derive 0.3.1", + "thiserror", +] + +[[package]] +name = "spl-program-error" +version = "0.3.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "num-derive 0.4.1", + "num-traits", + "solana-program", + "spl-program-error-derive 0.3.0", "thiserror", ] +[[package]] +name = "spl-program-error-derive" +version = "0.3.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "proc-macro2", + "quote", + "solana-program", + "syn 2.0.41", +] + [[package]] name = "spl-program-error-derive" version = "0.3.1" @@ -4262,39 +4347,35 @@ dependencies = [ [[package]] name = "spl-stake-pool" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f973333ac37c47dac368cc13088ebebaa7d67e50a7f56a2a83f090bc32c2cb" +version = "0.7.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" dependencies = [ "arrayref", "bincode", "borsh 0.10.3", - "bytemuck", "num-derive 0.4.1", "num-traits", "num_enum 0.7.2", "serde", "serde_derive", "solana-program", - "solana-security-txt", - "spl-math 0.2.0", - "spl-pod", - "spl-token-2022 0.9.0", + "spl-math 0.2.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-pod 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-token-2022 0.8.0", "thiserror", ] [[package]] name = "spl-tlv-account-resolution" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "062e148d3eab7b165582757453632ffeef490c02c86a48bfdb4988f63eefb3b9" +version = "0.3.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" dependencies = [ "bytemuck", "solana-program", - "spl-discriminator", - "spl-pod", - "spl-program-error", - "spl-type-length-value", + "spl-discriminator 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-pod 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-program-error 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-type-length-value 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", ] [[package]] @@ -4305,10 +4386,10 @@ checksum = "615d381f48ddd2bb3c57c7f7fb207591a2a05054639b18a62e785117dd7a8683" dependencies = [ "bytemuck", "solana-program", - "spl-discriminator", - "spl-pod", - "spl-program-error", - "spl-type-length-value", + "spl-discriminator 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-pod 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-program-error 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-type-length-value 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4341,11 +4422,24 @@ dependencies = [ "thiserror", ] +[[package]] +name = "spl-token" +version = "4.0.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "arrayref", + "bytemuck", + "num-derive 0.4.1", + "num-traits", + "num_enum 0.7.2", + "solana-program", + "thiserror", +] + [[package]] name = "spl-token-2022" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4abf34a65ba420584a0c35f3903f8d727d1f13ababbdc3f714c6b065a686e86" +version = "0.8.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" dependencies = [ "arrayref", "bytemuck", @@ -4354,12 +4448,12 @@ dependencies = [ "num_enum 0.7.2", "solana-program", "solana-zk-token-sdk", - "spl-memo", - "spl-pod", - "spl-token 4.0.0", - "spl-token-metadata-interface", - "spl-transfer-hook-interface 0.3.0", - "spl-type-length-value", + "spl-memo 4.0.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-pod 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-token 4.0.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-token-metadata-interface 0.2.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-transfer-hook-interface 0.2.0", + "spl-type-length-value 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", "thiserror", ] @@ -4377,13 +4471,13 @@ dependencies = [ "solana-program", "solana-security-txt", "solana-zk-token-sdk", - "spl-memo", - "spl-pod", - "spl-token 4.0.0", + "spl-memo 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-pod 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "spl-token-group-interface", - "spl-token-metadata-interface", + "spl-token-metadata-interface 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "spl-transfer-hook-interface 0.4.1", - "spl-type-length-value", + "spl-type-length-value 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror", ] @@ -4395,9 +4489,9 @@ checksum = "b889509d49fa74a4a033ca5dae6c2307e9e918122d97e58562f5c4ffa795c75d" dependencies = [ "bytemuck", "solana-program", - "spl-discriminator", - "spl-pod", - "spl-program-error", + "spl-discriminator 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-pod 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-program-error 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4408,26 +4502,38 @@ checksum = "4c16ce3ba6979645fb7627aa1e435576172dd63088dc7848cb09aa331fa1fe4f" dependencies = [ "borsh 0.10.3", "solana-program", - "spl-discriminator", - "spl-pod", - "spl-program-error", - "spl-type-length-value", + "spl-discriminator 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-pod 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-program-error 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-type-length-value 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "spl-token-metadata-interface" +version = "0.2.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "borsh 0.10.3", + "solana-program", + "spl-discriminator 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-pod 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-program-error 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-type-length-value 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", ] [[package]] name = "spl-transfer-hook-interface" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051d31803f873cabe71aec3c1b849f35248beae5d19a347d93a5c9cccc5d5a9b" +version = "0.2.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" dependencies = [ "arrayref", "bytemuck", "solana-program", - "spl-discriminator", - "spl-pod", - "spl-program-error", - "spl-tlv-account-resolution 0.4.0", - "spl-type-length-value", + "spl-discriminator 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-pod 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-program-error 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-tlv-account-resolution 0.3.0", + "spl-type-length-value 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", ] [[package]] @@ -4439,11 +4545,11 @@ dependencies = [ "arrayref", "bytemuck", "solana-program", - "spl-discriminator", - "spl-pod", - "spl-program-error", + "spl-discriminator 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-pod 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-program-error 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "spl-tlv-account-resolution 0.5.1", - "spl-type-length-value", + "spl-type-length-value 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4454,9 +4560,21 @@ checksum = "a468e6f6371f9c69aae760186ea9f1a01c2908351b06a5e0026d21cfc4d7ecac" dependencies = [ "bytemuck", "solana-program", - "spl-discriminator", - "spl-pod", - "spl-program-error", + "spl-discriminator 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-pod 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-program-error 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "spl-type-length-value" +version = "0.3.0" +source = "git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9#a3996814cb44eab2834f72113b742c875ac7b1b9" +dependencies = [ + "bytemuck", + "solana-program", + "spl-discriminator 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-pod 0.1.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", + "spl-program-error 0.3.0 (git+https://github.com/solana-labs/solana-program-library.git?rev=a3996814cb44eab2834f72113b742c875ac7b1b9)", ] [[package]] @@ -4499,7 +4617,7 @@ dependencies = [ "lido", "solana-client", "solana-program", - "spl-token 4.0.0", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stakedex_deposit_sol_interface", "stakedex_sdk_common", "stakedex_withdraw_stake_interface", @@ -4513,7 +4631,7 @@ dependencies = [ "borsh 0.10.3", "marinade_finance_interface", "solana-program", - "spl-token 4.0.0", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stakedex_deposit_sol_interface", "stakedex_deposit_stake_interface", "stakedex_sdk_common", @@ -4553,7 +4671,7 @@ dependencies = [ "sanctum-macros", "solana-program", "solana-sdk", - "spl-token 4.0.0", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stakedex_deposit_sol_interface", "stakedex_interface", "thiserror", @@ -4568,7 +4686,7 @@ dependencies = [ "borsh 0.10.3", "solana-program", "spl-stake-pool", - "spl-token 4.0.0", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stakedex_deposit_sol_interface", "stakedex_deposit_stake_interface", "stakedex_sdk_common", @@ -4582,7 +4700,7 @@ dependencies = [ "anyhow", "solana-program", "spl-math 0.1.0", - "spl-token 4.0.0", + "spl-token 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stakedex_deposit_stake_interface", "stakedex_sdk_common", "unstake-lib", @@ -5072,7 +5190,7 @@ name = "unstake-lib" version = "0.1.0" source = "git+https://github.com/igneous-labs/sanctum-unstake-program.git?rev=069f941#069f941d275cc41b2ec0e3c2dbfae78cae63d786" dependencies = [ - "spl-math 0.2.0", + "spl-math 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "unstake_interface", ] diff --git a/Cargo.toml b/Cargo.toml index 72b9069..90552f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,7 @@ [workspace] resolver = "2" -members = [ - "stakedex_sdk", - "common", - "libs/*", - "interfaces/*" -] +members = ["stakedex_sdk", "common", "libs/*", "interfaces/*"] [workspace.dependencies] anyhow = "^1.0" @@ -16,8 +11,8 @@ itertools = ">=0.1" jupiter-amm-interface = "~0.3.2" lazy_static = "^1.0" # set git dependencies to branch instead of locking to rev so that consumers can upgrade easily -lido = { git = "https://github.com/jup-ag/solido", branch = "jupiter", features = ["no-entrypoint"] } # rev = "ec25a9b" -marinade_finance_interface = { git = "https://github.com/igneous-labs/marinade_finance_interface", branch = "master" } # rev = "4d1895b" +lido = { git = "https://github.com/jup-ag/solido", rev = "2c85ddf7b50d8162d2b81d79d7fcbfd5e05dc967", features = ["no-entrypoint"] } +marinade_finance_interface = { git = "https://github.com/jup-ag/marinade_finance_interface", rev = "5747b5350c5505fc2ea597c3f8ae1f8cf71c363d" } # rev = "4d1895b" num-derive = ">=0.1" num-traits = ">=0.1" rust_decimal = ">=1.0,<=1.32.0" # anything >1.32 uses borsh ^1 diff --git a/interfaces/stakedex_interface/src/instructions.rs b/interfaces/stakedex_interface/src/instructions.rs index a901d73..a0380e5 100644 --- a/interfaces/stakedex_interface/src/instructions.rs +++ b/interfaces/stakedex_interface/src/instructions.rs @@ -158,56 +158,16 @@ impl From> for StakeWrappedSolKeys { impl From for [AccountMeta; STAKE_WRAPPED_SOL_IX_ACCOUNTS_LEN] { fn from(keys: StakeWrappedSolKeys) -> Self { [ - AccountMeta { - pubkey: keys.user, - is_signer: true, - is_writable: false, - }, - AccountMeta { - pubkey: keys.wsol_from, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.dest_token_to, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.wsol_bridge_in, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.sol_bridge_out, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.dest_token_fee_token_account, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.dest_token_mint, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.wsol_mint, - is_signer: false, - is_writable: false, - }, - AccountMeta { - pubkey: keys.token_program, - is_signer: false, - is_writable: false, - }, - AccountMeta { - pubkey: keys.system_program, - is_signer: false, - is_writable: false, - }, + AccountMeta::new_readonly(keys.user, false), + AccountMeta::new(keys.wsol_from, false), + AccountMeta::new(keys.dest_token_to, false), + AccountMeta::new(keys.wsol_bridge_in, false), + AccountMeta::new(keys.sol_bridge_out, false), + AccountMeta::new(keys.dest_token_fee_token_account, false), + AccountMeta::new(keys.dest_token_mint, false), + AccountMeta::new_readonly(keys.wsol_mint, false), + AccountMeta::new_readonly(keys.token_program, false), + AccountMeta::new_readonly(keys.system_program, false), ] } } @@ -464,41 +424,13 @@ impl From> for SwapViaStakeKeys { impl From for [AccountMeta; SWAP_VIA_STAKE_IX_ACCOUNTS_LEN] { fn from(keys: SwapViaStakeKeys) -> Self { [ - AccountMeta { - pubkey: keys.user, - is_signer: true, - is_writable: true, - }, - AccountMeta { - pubkey: keys.src_token_from, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.dest_token_to, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.bridge_stake, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.dest_token_fee_token_account, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.src_token_mint, - is_signer: false, - is_writable: true, - }, - AccountMeta { - pubkey: keys.dest_token_mint, - is_signer: false, - is_writable: true, - }, + AccountMeta::new(keys.user, false), + AccountMeta::new(keys.src_token_from, false), + AccountMeta::new(keys.dest_token_to, false), + AccountMeta::new(keys.bridge_stake, false), + AccountMeta::new(keys.dest_token_fee_token_account, false), + AccountMeta::new(keys.src_token_mint, false), + AccountMeta::new(keys.dest_token_mint, false), ] } } diff --git a/libs/marinade/src/lib.rs b/libs/marinade/src/lib.rs index 590e985..582cbee 100644 --- a/libs/marinade/src/lib.rs +++ b/libs/marinade/src/lib.rs @@ -8,7 +8,7 @@ use anyhow::{anyhow, Result}; use borsh::BorshDeserialize; use consts::VALIDATOR_RECORD_BYTE_LENGTH; use marinade_finance_interface::{ - Fee, FeeCents, LiqPool, List, StakeSystem, State, ValidatorRecord, ValidatorSystem, + Fee, LiqPool, List, StakeSystem, State, ValidatorRecord, ValidatorSystem, }; use solana_program::{borsh0_10::try_from_slice_unchecked, pubkey::Pubkey}; @@ -28,11 +28,13 @@ impl Default for MarinadeStakedex { account: Pubkey::default(), item_size: 0, count: 0, - reserved1: Pubkey::default(), - reserved2: 0, + new_account: Pubkey::default(), + copied_count: 0, + // reserved1: Pubkey::default(), + // reserved2: 0, }; let zero_fee = Fee { basis_points: 0 }; - let zero_fee_cents = FeeCents { bp_cents: 0 }; + // let zero_fee_cents = FeeCents { bp_cents: 0 }; Self { state: State { msol_mint: Pubkey::default(), @@ -84,14 +86,14 @@ impl Default for MarinadeStakedex { min_withdraw: 0, staking_sol_cap: 0, emergency_cooling_down: 0, - pause_authority: Pubkey::default(), - paused: false, - delayed_unstake_fee: zero_fee_cents.clone(), - withdraw_stake_account_fee: zero_fee_cents, - withdraw_stake_account_enabled: false, - last_stake_move_epoch: 0, - stake_moved: 0, - max_stake_moved_per_epoch: zero_fee, + // pause_authority: Pubkey::default(), + // paused: false, + // delayed_unstake_fee: zero_fee_cents.clone(), + // withdraw_stake_account_fee: zero_fee_cents, + // withdraw_stake_account_enabled: false, + // last_stake_move_epoch: 0, + // stake_moved: 0, + // max_stake_moved_per_epoch: zero_fee, }, validator_records: Vec::new(), } diff --git a/libs/spl_stake_pool/Cargo.toml b/libs/spl_stake_pool/Cargo.toml index 6180587..26a4191 100644 --- a/libs/spl_stake_pool/Cargo.toml +++ b/libs/spl_stake_pool/Cargo.toml @@ -10,9 +10,12 @@ anyhow = { workspace = true } bincode = { workspace = true } borsh = { workspace = true } solana-program = { workspace = true } -spl-stake-pool = { workspace = true } +spl-stake-pool = { git = "https://github.com/solana-labs/solana-program-library.git", rev = "a3996814cb44eab2834f72113b742c875ac7b1b9", features = [ + "no-entrypoint", +] } +# spl-stake-pool = "^0.6.4" spl-token = { workspace = true } stakedex_deposit_sol_interface = { workspace = true } stakedex_deposit_stake_interface = { workspace = true } stakedex_sdk_common = { workspace = true } -stakedex_withdraw_stake_interface = { workspace = true } \ No newline at end of file +stakedex_withdraw_stake_interface = { workspace = true } diff --git a/libs/spl_stake_pool/src/lib.rs b/libs/spl_stake_pool/src/lib.rs index b408ef5..73ced83 100644 --- a/libs/spl_stake_pool/src/lib.rs +++ b/libs/spl_stake_pool/src/lib.rs @@ -8,6 +8,7 @@ use spl_stake_pool::{ use stakedex_sdk_common::{WithdrawStakeQuote, STAKE_ACCOUNT_RENT_EXEMPT_LAMPORTS}; mod stakedex_traits; +pub use spl_stake_pool::ID; pub use stakedex_traits::*; /// A SPL stake pool with possibly custom program ID diff --git a/libs/unstake_it/src/lib.rs b/libs/unstake_it/src/lib.rs index 4c3edf9..6941c4f 100644 --- a/libs/unstake_it/src/lib.rs +++ b/libs/unstake_it/src/lib.rs @@ -1,12 +1,11 @@ use anyhow::Result; -use solana_program::{borsh0_10::try_from_slice_unchecked, pubkey::Pubkey}; +use solana_program::{borsh0_9::try_from_slice_unchecked, pubkey::Pubkey}; use unstake_interface::{Fee, FeeEnum, Pool, ProtocolFee, Rational}; mod pda; mod stakedex_traits; pub use pda::*; -pub use stakedex_traits::*; pub const UNSTAKE_IT_LABEL: &str = "Unstake.it"; diff --git a/stakedex_sdk/Cargo.toml b/stakedex_sdk/Cargo.toml index 0576b12..dd88986 100644 --- a/stakedex_sdk/Cargo.toml +++ b/stakedex_sdk/Cargo.toml @@ -27,3 +27,4 @@ stakedex_unstake_it = { workspace = true } [dev-dependencies] solana-client = { workspace = true } +lazy_static = { workspace = true } diff --git a/stakedex_sdk/tests/test_main.rs b/stakedex_sdk/tests/test_main.rs index 5d8e6b5..ba320a9 100644 --- a/stakedex_sdk/tests/test_main.rs +++ b/stakedex_sdk/tests/test_main.rs @@ -61,13 +61,25 @@ fn fetch_accounts(accounts_pubkeys: &[Pubkey]) -> HashMap { } #[test] -fn test_swap_via_stake_unknown_token() { +fn test_quote_swap_via_stake_jitosol_bsol() { + STAKEDEX + .quote_swap_via_stake(&QuoteParams { + amount: 1_000_000_000, + input_mint: jitosol::ID, + output_mint: bsol::ID, + swap_mode: jupiter_amm_interface::SwapMode::ExactIn, + }) + .unwrap(); +} + +#[test] +fn test_quote_swap_via_stake_unknown_token() { let unknown_token = Pubkey::new_unique(); let res = STAKEDEX.quote_swap_via_stake(&QuoteParams { amount: 1_000_000_000, input_mint: unknown_token, output_mint: bsol::ID, - swap_mode: SwapMode::default(), + swap_mode: jupiter_amm_interface::SwapMode::ExactIn, }); assert!(res.is_err()); } @@ -247,13 +259,17 @@ fn test_jsol_drain_vsa_edge_case() { .validator_list .validators .iter() - .max_by_key(|v| v.active_stake_lamports) + .max_by_key(|v| u64::from(v.active_stake_lamports)) .unwrap(); let max_withdraw_lamports = largest_active_stake_vsi.active_stake_lamports; let parts_after_fees = (STAKEDEX.jpool.stake_pool.stake_withdrawal_fee.denominator - STAKEDEX.jpool.stake_pool.stake_withdrawal_fee.numerator) as u128; +<<<<<<< HEAD let max_withdraw_lamports_bef_fees = u128::from(max_withdraw_lamports) +======= + let max_withdraw_lamports_bef_fees = (u128::from(u64::from(max_withdraw_lamports)) +>>>>>>> 6314bd6 (Jupiter changes for jupiter-core compat) * (STAKEDEX.jpool.stake_pool.stake_withdrawal_fee.denominator as u128) + parts_after_fees - 1) @@ -265,17 +281,17 @@ fn test_jsol_drain_vsa_edge_case() { .unwrap(); let max_possible_quote = STAKEDEX .quote_swap_via_stake(&QuoteParams { - amount: max_withdraw_jsol, - input_mint: jsol::ID, + amount: 100_000_000_000, + input_mint: stsol::ID, output_mint: msol::ID, - swap_mode: SwapMode::default(), + swap_mode: jupiter_amm_interface::SwapMode::ExactIn, }) .unwrap(); let should_fail = STAKEDEX.quote_swap_via_stake(&QuoteParams { amount: max_withdraw_jsol + 1, input_mint: jsol::ID, output_mint: msol::ID, - swap_mode: SwapMode::default(), + swap_mode: SwapMode::ExactIn, }); assert!(should_fail.is_err());