From a47802d900b583b78cc9a3c3c8eff34a6f760806 Mon Sep 17 00:00:00 2001 From: Wei Date: Fri, 6 Jan 2023 16:55:11 +0800 Subject: [PATCH 1/3] add marinade adapter --- Anchor.toml | 1 + Cargo.lock | 163 ++++++++++++++------------- programs/adapter-marinade/Cargo.toml | 19 ++++ programs/adapter-marinade/Xargo.toml | 2 + programs/adapter-marinade/src/lib.rs | 123 ++++++++++++++++++++ 5 files changed, 232 insertions(+), 76 deletions(-) create mode 100644 programs/adapter-marinade/Cargo.toml create mode 100644 programs/adapter-marinade/Xargo.toml create mode 100644 programs/adapter-marinade/src/lib.rs diff --git a/Anchor.toml b/Anchor.toml index f397419..897af17 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -10,6 +10,7 @@ adapter_katana = "ADPTwDKJTizC3V8gZXDxt5uLjJv4pBnh1nTTf9dZJnS2" adapter_tulip = "ADPT9nhC1asRcEB13FKymLTatqWGCuZHDznGgnakWKxW" adapter_friktion = "ADPTzbsaBdXA3FqXoPHjaTjPfh9kadxxFKxonZihP1Ji" adapter_nft_finance = "ADPTyBr92sBCE1hdYBRvXbMpF4hKs17xyDjFPxopcsrh" +adapter_marinade = "3fUTvDPGzfRHpRkbZdTGzHzZHzBm1Km5cyAssfKZwTh3" [registry] url = "https://anchor.projectserum.com" diff --git a/Cargo.lock b/Cargo.lock index 8b6918c..7ce76bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,6 +51,14 @@ dependencies = [ "anchor-spl", ] +[[package]] +name = "adapter-marinade" +version = "0.1.0" +dependencies = [ + "adapter-common", + "anchor-lang", +] + [[package]] name = "adapter-nft-finance" version = "0.1.0" @@ -121,16 +129,16 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] @@ -269,7 +277,7 @@ dependencies = [ "anchor-attribute-state", "anchor-derive-accounts", "arrayref", - "base64 0.13.0", + "base64 0.13.1", "bincode", "borsh", "bytemuck", @@ -310,9 +318,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" [[package]] name = "arrayref" @@ -351,9 +359,9 @@ checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bincode" @@ -372,16 +380,16 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "blake3" -version = "1.3.1" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" +checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", "arrayvec", "cc", "cfg-if", "constant_time_eq", - "digest 0.10.5", + "digest 0.10.6", ] [[package]] @@ -468,9 +476,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bumpalo" -version = "3.11.0" +version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "bv" @@ -484,18 +492,18 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da" +checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9e1f5fa78f69496407a27ae9ed989e3c3b072310286f5ef385525e4cbc24a9" +checksum = "5fe233b960f12f8007e3db2d136e3cb1c291bfd7396e384ee76025fc1a3932b4" dependencies = [ "proc-macro2", "quote", @@ -510,9 +518,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" [[package]] name = "cfg-if" @@ -542,9 +550,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.1.5" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" [[package]] name = "cpufeatures" @@ -605,9 +613,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.3", "crypto-common", @@ -622,9 +630,9 @@ checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "env_logger" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", @@ -665,9 +673,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -754,9 +762,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "js-sys" @@ -769,9 +777,12 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] [[package]] name = "lazy_static" @@ -781,9 +792,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.135" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libsecp256k1" @@ -860,9 +871,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95af15f345b17af2efc8ead6080fb8bc376f8cec1b35277b935637595fe77498" +checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" dependencies = [ "libc", ] @@ -919,9 +930,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" [[package]] name = "opaque-debug" @@ -942,9 +953,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ "cfg-if", "instant", @@ -956,9 +967,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-crate" @@ -982,9 +993,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.43" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" dependencies = [ "unicode-ident", ] @@ -1004,9 +1015,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -1063,9 +1074,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" dependencies = [ "aho-corasick", "memchr", @@ -1074,9 +1085,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rustc-hex" @@ -1095,15 +1106,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "scopeguard" @@ -1113,33 +1124,33 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "semver" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" [[package]] name = "serde" -version = "1.0.145" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.7" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfc50e8183eeeb6178dcb167ae34a8051d63535023ae38b5d8d12beae193d37b" +checksum = "718dc5fff5b36f99093fc49b280cfc96ce6fc824317783bff5a1fed0c7a64819" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -1148,9 +1159,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.86" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" dependencies = [ "itoa", "ryu", @@ -1237,7 +1248,7 @@ version = "1.9.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5deafc4902425d40197f74166640300dd20b078e4ffd518c1bb56ceb7e01680" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "bincode", "bitflags", "blake3", @@ -1338,9 +1349,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.99" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", @@ -1358,18 +1369,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" dependencies = [ "proc-macro2", "quote", @@ -1378,9 +1389,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" dependencies = [ "serde", ] @@ -1425,9 +1436,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "uint" @@ -1443,9 +1454,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "unicode-segmentation" diff --git a/programs/adapter-marinade/Cargo.toml b/programs/adapter-marinade/Cargo.toml new file mode 100644 index 0000000..f81a06c --- /dev/null +++ b/programs/adapter-marinade/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "adapter-marinade" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "adapter_marinade" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] + +[dependencies] +anchor-lang = "0.24.2" +adapter-common = { path = "../../adapter_common",version= "0.1.0" } \ No newline at end of file diff --git a/programs/adapter-marinade/Xargo.toml b/programs/adapter-marinade/Xargo.toml new file mode 100644 index 0000000..475fb71 --- /dev/null +++ b/programs/adapter-marinade/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/programs/adapter-marinade/src/lib.rs b/programs/adapter-marinade/src/lib.rs new file mode 100644 index 0000000..e860c43 --- /dev/null +++ b/programs/adapter-marinade/src/lib.rs @@ -0,0 +1,123 @@ +use anchor_lang::prelude::*; +use anchor_lang::solana_program::{hash::hash, instruction::Instruction, program::invoke}; + +declare_id!("3fUTvDPGzfRHpRkbZdTGzHzZHzBm1Km5cyAssfKZwTh3"); + +pub mod adapter_marinade { + use adapter_common::{load_remaining_accounts, load_token_account_and_balance, sighash}; + + use super::*; + use std::borrow::BorrowMut; + + pub fn deposit<'a, 'b, 'c, 'info>( + ctx: Context<'a, 'b, 'c, 'info, Action<'info>>, + input: Vec, + ) -> Result<()> { + let mut deposit_data = sighash("global", "deposit").to_vec(); + let mut input_bytes = &input[..]; + let input_struct = DepositInputWrapper::deserialize(&mut input_bytes)?; + + let mut share_balance = load_token_account_and_balance(ctx.remaining_accounts, 7); + let mut token_balance = load_token_account_and_balance(ctx.remaining_accounts, 6); + let deposit_amount = input_struct.deposit_amount; + + deposit_data.append(deposit_amount.to_le_bytes().to_vec().borrow_mut()); + let deposit_accounts = load_remaining_accounts( + ctx.remaining_accounts, + vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + ); + + let ix = Instruction { + program_id: ctx.accounts.base_program_id.key(), + accounts: deposit_accounts, + data: deposit_data, + }; + invoke(&ix, ctx.remaining_accounts)?; + // Wrap Output + let output_struct = DepositOutputWrapper { + share_amount: share_balance.get_balance_change(), + deposit_amount: token_balance.get_balance_change(), + ..Default::default() + }; + let mut output: Vec = Vec::new(); + output_struct.serialize(&mut output).unwrap(); + + // Return Result + anchor_lang::solana_program::program::set_return_data(&output); + + msg!("Output: {:?}", output_struct); + + Ok(()) + } + pub fn withdraw<'a, 'b, 'c, 'info>( + ctx: Context<'a, 'b, 'c, 'info, Action<'info>>, + input: Vec, + ) -> Result<()> { + let mut withdraw_data = sighash("global", "liquid_unstake").to_vec(); + let mut input_bytes = &input[..]; + let input_struct = WithdrawInputWrapper::deserialize(&mut input_bytes)?; + + let mut share_balance = load_token_account_and_balance(ctx.remaining_accounts, 5); + let mut token_balance = load_token_account_and_balance(ctx.remaining_accounts, 7); + let withdraw_amount = input_struct.withdraw_amount; + + withdraw_data.append(withdraw_amount.to_le_bytes().to_vec().borrow_mut()); + let withdraw_accounts = load_remaining_accounts( + ctx.remaining_accounts, + vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + ); + + let ix = Instruction { + program_id: ctx.accounts.base_program_id.key(), + accounts: withdraw_accounts, + data: withdraw_data, + }; + invoke(&ix, ctx.remaining_accounts)?; + // Wrap Output + let output_struct = WithdrawOutputWrapper { + share_amount: share_balance.get_balance_change(), + withdraw_amount: token_balance.get_balance_change(), + ..Default::default() + }; + let mut output: Vec = Vec::new(); + output_struct.serialize(&mut output).unwrap(); + + // Return Result + anchor_lang::solana_program::program::set_return_data(&output); + + msg!("Output: {:?}", output_struct); + + Ok(()) + } +} + +#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Default)] +pub struct DepositInputWrapper { + pub deposit_amount: u64, +} +#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Default)] +pub struct DepositOutputWrapper { + pub share_amount: u64, + pub deposit_amount: u64, + pub dummy_3: u64, + pub dummy_4: u64, +} + +#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Default)] +pub struct WithdrawInputWrapper { + pub withdraw_amount: u64, +} +#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, Default)] +pub struct WithdrawOutputWrapper { + pub withdraw_amount: u64, + pub share_amount: u64, + pub dummy_3: u64, + pub dummy_4: u64, +} + +pub struct Action<'info> { + // TODO: Add constraints + pub gateway_authority: Signer<'info>, + /// CHECK: Safe + pub base_program_id: AccountInfo<'info>, +} From ef0a0bca3a755102dc9648a013dd0d4e312e6a29 Mon Sep 17 00:00:00 2001 From: Wei Date: Fri, 13 Jan 2023 16:07:32 +0800 Subject: [PATCH 2/3] v0.2.1-test.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ce4c4d1..ac1dfc1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dappio-wonderland/adapter-idls", - "version": "0.2.1", + "version": "0.2.1-test.3", "description": "Dappio Adapter IDLs: The IDL files of Dappio Adapters", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", From 7f590600ebe2afb9cdcfe2d018a57efc0dc5f4d9 Mon Sep 17 00:00:00 2001 From: Wei Date: Fri, 13 Jan 2023 16:14:00 +0800 Subject: [PATCH 3/3] v0.2.1-test.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ac1dfc1..3320388 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dappio-wonderland/adapter-idls", - "version": "0.2.1-test.3", + "version": "0.2.1-test.4", "description": "Dappio Adapter IDLs: The IDL files of Dappio Adapters", "main": "dist/src/index.js", "types": "dist/src/index.d.ts",