From df8940423640e4a7ae5359edb5620982fc5731d9 Mon Sep 17 00:00:00 2001 From: Obie Kaku Date: Sun, 24 Mar 2024 18:44:57 -0500 Subject: [PATCH] added membrane stuffs --- Cargo.lock | 378 ++++++++++++++---- packages/osmosis-destinations/Cargo.toml | 2 +- .../osmosis-destinations/src/comp_prefs.rs | 3 + .../src/dest_project_gen.rs | 164 +++++++- packages/osmosis-destinations/src/grants.rs | 68 +++- packages/osmosis-destinations/src/lib.rs | 1 + .../src/membrane_types.rs | 57 +++ 7 files changed, 569 insertions(+), 104 deletions(-) create mode 100644 packages/osmosis-destinations/src/membrane_types.rs diff --git a/Cargo.lock b/Cargo.lock index 0cc446c..e379ce7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -114,6 +114,32 @@ version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +[[package]] +name = "apollo-cw-asset" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "423502406a307052f6877030f48b5fb4e9fb338fc5e7c8ca1064210def52876b" +dependencies = [ + "cosmwasm-std", + "cw-storage-plus 1.2.0", + "cw20 1.1.2", + "schemars", + "serde", +] + +[[package]] +name = "apollo-utils" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e669b1a4c378832d63a87b3ca2efafc6f4881a61af5dd3e5a6b222c54f2a02ec" +dependencies = [ + "apollo-cw-asset", + "cosmwasm-schema", + "cosmwasm-std", + "cw20 1.1.2", + "regex", +] + [[package]] name = "astroport" version = "2.8.0" @@ -125,18 +151,18 @@ dependencies = [ "cw-utils 0.15.1", "cw20 0.15.1", "itertools 0.10.5", - "uint", + "uint 0.9.5", ] [[package]] name = "async-recursion" -version = "1.0.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -158,18 +184,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "461abc97219de0eaaf81fe3ef974a540158f3d079c2ab200f891f1a2ef201e85" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -257,9 +283,9 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -329,7 +355,7 @@ version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cexpr", "clang-sys", "itertools 0.12.1", @@ -342,7 +368,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.52", + "syn 2.0.53", "which", ] @@ -400,9 +426,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "block-buffer" @@ -447,11 +473,56 @@ dependencies = [ "wyndex-stake", ] +[[package]] +name = "borsh" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" +dependencies = [ + "borsh-derive", + "hashbrown 0.11.2", +] + +[[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", + "proc-macro-crate", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "bs58" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ "sha2 0.10.8", ] @@ -470,9 +541,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" dependencies = [ "serde", ] @@ -696,7 +767,7 @@ dependencies = [ "hex", "schemars", "serde", - "serde-json-wasm", + "serde-json-wasm 0.5.2", "sha2 0.10.8", "static_assertions", "thiserror", @@ -805,7 +876,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -830,6 +901,17 @@ dependencies = [ "cosmwasm-std", ] +[[package]] +name = "cw-coins" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ef23b8172fcf1764a2193d6ac97a9c69e1c8aff194519032290eb98b887e18" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", +] + [[package]] name = "cw-controllers" version = "0.13.4" @@ -896,6 +978,23 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "cw-dex" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c4c002da51161e832615de09aa796e6915507418a7e4658204cd6c91ce89e7" +dependencies = [ + "apollo-cw-asset", + "apollo-utils", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 1.2.0", + "cw-utils 1.0.3", + "cw20 1.1.2", + "osmosis-std 0.14.0", + "thiserror", +] + [[package]] name = "cw-fable" version = "0.1.0" @@ -921,9 +1020,9 @@ dependencies = [ [[package]] name = "cw-multi-test" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fff029689ae89127cf6d7655809a68d712f3edbdb9686c70b018ba438b26ca" +checksum = "cc392a5cb7e778e3f90adbf7faa43c4db7f35b6623224b08886d796718edb875" dependencies = [ "anyhow", "bech32", @@ -976,7 +1075,7 @@ dependencies = [ "cw-orch-contract-derive 0.20.1", "cw-orch-core 0.21.1", "cw-orch-daemon 0.21.0", - "cw-orch-fns-derive 0.18.0", + "cw-orch-fns-derive 0.18.1", "cw-orch-mock 0.21.1", "cw-orch-networks 0.20.3", "cw-orch-traits 0.21.0", @@ -1013,7 +1112,7 @@ checksum = "94e9c3e46e2511c26d07da1fb5fcb47f83fa6d169dbb6eeff42c1b899b849726" dependencies = [ "convert_case", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -1151,9 +1250,9 @@ dependencies = [ [[package]] name = "cw-orch-fns-derive" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "650dd1b708742406023b51e1b49a83a91ba31f8dd653c5b6cc7d3c3c0c214bfd" +checksum = "6423cd853c9a4aa07cc0a92a179b99bd8f8f6c696a468e3ca2ecd2575905db21" dependencies = [ "convert_case", "proc-macro2", @@ -2004,9 +2103,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" +checksum = "c007b1ae3abe1cb6f85a16305acd418b7ca6343b953633fee2b76d8f108b830f" [[package]] name = "fixed-hash" @@ -2152,7 +2251,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -2234,9 +2333,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb" dependencies = [ "bytes", "fnv", @@ -2244,13 +2343,22 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.5", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", "tracing", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -2301,6 +2409,9 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] [[package]] name = "hex_lit" @@ -2568,7 +2679,7 @@ dependencies = [ "tendermint-light-client-verifier", "tendermint-proto 0.32.2", "time", - "uint", + "uint 0.9.5", ] [[package]] @@ -2631,9 +2742,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -2777,12 +2888,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-targets 0.52.4", ] [[package]] @@ -2791,7 +2902,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", "redox_syscall", ] @@ -2824,6 +2935,27 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" +[[package]] +name = "membrane" +version = "0.1.0" +source = "git+https://github.com/MembraneFinance/membrane-core.git#eda13577af0741a0ce21cac6667e19e7f77f5253" +dependencies = [ + "apollo-cw-asset", + "cosmwasm-schema", + "cosmwasm-std", + "cw-coins", + "cw-dex", + "cw-storage-plus 0.13.4", + "osmosis-std 0.15.3", + "prost 0.11.9", + "pyth-sdk-cw", + "schemars", + "serde", + "serde-json-wasm 1.0.1", + "thiserror", + "uint 0.8.5", +] + [[package]] name = "memchr" version = "2.7.1" @@ -2948,7 +3080,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3018,7 +3150,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -3035,7 +3167,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3075,6 +3207,7 @@ dependencies = [ "cw20 1.1.2", "cw20-stake 2.1.0", "cw20-vesting 1.6.0", + "membrane", "osmosis-std 0.21.0", "outpost-utils", "sail-destinations", @@ -3101,6 +3234,38 @@ dependencies = [ "thiserror", ] +[[package]] +name = "osmosis-std" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fc0a9075efd64ed5a8be3bf134cbf1080570d68384f2ad58ffaac6c00d063fd" +dependencies = [ + "chrono", + "cosmwasm-std", + "osmosis-std-derive 0.13.2", + "prost 0.11.9", + "prost-types 0.11.9", + "schemars", + "serde", + "serde-cw-value", +] + +[[package]] +name = "osmosis-std" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87725a7480b98887167edf878daa52201a13322ad88e34355a7f2ddc663e047e" +dependencies = [ + "chrono", + "cosmwasm-std", + "osmosis-std-derive 0.15.3", + "prost 0.11.9", + "prost-types 0.11.9", + "schemars", + "serde", + "serde-cw-value", +] + [[package]] name = "osmosis-std" version = "0.20.1" @@ -3328,7 +3493,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3384,7 +3549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3395,7 +3560,16 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-serde", - "uint", + "uint 0.9.5", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", ] [[package]] @@ -3450,7 +3624,7 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -3492,6 +3666,31 @@ dependencies = [ "thiserror", ] +[[package]] +name = "pyth-sdk" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00bf2540203ca3c7a5712fdb8b5897534b7f6a0b6e7b0923ff00466c5f9efcb3" +dependencies = [ + "borsh", + "borsh-derive", + "hex", + "schemars", + "serde", +] + +[[package]] +name = "pyth-sdk-cw" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c04e9f2961bce1ef13b09afcdb5aee7d4ddde83669e5f9d2824ba422cb00de48" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "pyth-sdk", + "thiserror", +] + [[package]] name = "quote" version = "1.0.35" @@ -3559,9 +3758,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -3588,9 +3787,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.11.26" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78bf93c4af7a8bb7d879d51cebe797356ff10ae8516ace542b5182d9dcac10b2" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64 0.21.7", "bytes", @@ -3692,6 +3891,12 @@ 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" @@ -3703,11 +3908,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -3985,6 +4190,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" +dependencies = [ + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.14" @@ -4002,7 +4216,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4035,7 +4249,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4153,9 +4367,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" @@ -4221,7 +4435,7 @@ dependencies = [ "proc-macro2", "quote", "struct_iterable_internal", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4264,9 +4478,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" dependencies = [ "proc-macro2", "quote", @@ -4534,7 +4748,7 @@ dependencies = [ "tokio", "tracing", "url", - "uuid 1.7.0", + "uuid 1.8.0", "walkdir", ] @@ -4596,7 +4810,7 @@ checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4692,7 +4906,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4739,9 +4953,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" dependencies = [ "futures-core", "pin-project-lite", @@ -4885,7 +5099,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] [[package]] @@ -4930,6 +5144,18 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[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" @@ -5024,9 +5250,9 @@ checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" [[package]] name = "vcpkg" @@ -5086,7 +5312,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-shared", ] @@ -5120,7 +5346,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5203,7 +5429,7 @@ dependencies = [ "protobuf", "schemars", "serde", - "uint", + "uint 0.9.5", ] [[package]] @@ -5498,7 +5724,7 @@ dependencies = [ "cw20-base 1.1.2", "itertools 0.10.5", "thiserror", - "uint", + "uint 0.9.5", ] [[package]] @@ -5514,7 +5740,7 @@ dependencies = [ "cw20-base 1.1.2", "itertools 0.10.5", "thiserror", - "uint", + "uint 0.9.5", ] [[package]] @@ -5884,5 +6110,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.53", ] diff --git a/packages/osmosis-destinations/Cargo.toml b/packages/osmosis-destinations/Cargo.toml index 152ccdd..2476c52 100644 --- a/packages/osmosis-destinations/Cargo.toml +++ b/packages/osmosis-destinations/Cargo.toml @@ -24,5 +24,5 @@ bond-router = { workspace = true, optional = true } cw-grant-spec = { workspace = true } osmosis-std = { workspace = true } sail-destinations = { workspace = true } -# membrane = { workspace = true } +membrane = { git = "https://github.com/MembraneFinance/membrane-core.git", version = "0.1.0" } struct_iterable = { workspace = true } diff --git a/packages/osmosis-destinations/src/comp_prefs.rs b/packages/osmosis-destinations/src/comp_prefs.rs index cef3b98..5d23bf6 100644 --- a/packages/osmosis-destinations/src/comp_prefs.rs +++ b/packages/osmosis-destinations/src/comp_prefs.rs @@ -234,12 +234,14 @@ impl OsmosisProjectAddresses { pub struct MembraneAddresses { pub cdp: String, pub staking: String, + pub stability_pool: String, } #[cw_serde] pub struct MembraneAddrs { pub cdp: Addr, pub staking: Addr, + pub stability_pool: Addr, } impl MembraneAddresses { @@ -247,6 +249,7 @@ impl MembraneAddresses { Ok(MembraneAddrs { cdp: api.addr_validate(&self.cdp)?, staking: api.addr_validate(&self.staking)?, + stability_pool: api.addr_validate(&self.stability_pool)?, }) } } diff --git a/packages/osmosis-destinations/src/dest_project_gen.rs b/packages/osmosis-destinations/src/dest_project_gen.rs index c0c334e..acde41a 100644 --- a/packages/osmosis-destinations/src/dest_project_gen.rs +++ b/packages/osmosis-destinations/src/dest_project_gen.rs @@ -1,11 +1,13 @@ use crate::{ errors::OsmosisDestinationError, mars_types::{RedBankAction, RedBankExecuteMsgs}, + membrane_types::{MembraneStabilityPoolExecuteMsg, MembraneStakingExecuteMsg}, }; use cosmos_sdk_proto::cosmos::base::v1beta1::Coin as CsdkCoin; use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, Coin, Event, Uint128}; +use cosmwasm_std::{Addr, Coin, Decimal, Event, QuerierWrapper, Uint128}; +use membrane::{cdp, stability_pool, types::Basket}; use outpost_utils::{ helpers::DestProjectMsgs, msg_gen::{create_exec_contract_msg, CosmosProtoMsg}, @@ -96,18 +98,18 @@ pub fn fund_red_bank_acct_msgs( }) } -// stake mbrn +/// stake mbrn pub fn stake_mbrn_msgs( staker_addr: &Addr, - membrane_staking_contract_addr: &Addr, + staking_contract_addr: &Addr, mbrn_to_stake: Coin, ) -> DestinationResult { Ok(DestProjectMsgs { msgs: vec![CosmosProtoMsg::ExecuteContract(create_exec_contract_msg( - membrane_staking_contract_addr, + staking_contract_addr, staker_addr, - &MembraneExecuteMsg::Stake { user: None }, - Some(vec![cosmos_sdk_proto::cosmos::base::v1beta1::Coin { + &membrane::staking::ExecuteMsg::Stake { user: None }, + Some(vec![CsdkCoin { denom: mbrn_to_stake.denom.to_string(), amount: mbrn_to_stake.amount.to_string(), }]), @@ -117,17 +119,141 @@ pub fn stake_mbrn_msgs( }) } -#[cw_serde] -pub enum MembraneExecuteMsg { - Stake { - user: Option, - }, - CdpDeposit { - /// Position ID to deposit into. - /// If the user wants to create a new/separate position, no position id is passed. - position_id: Option, - /// Position owner. - /// Defaults to the sender. - position_owner: Option, - }, +/// deposit cdt into the stability pool +pub fn deposit_into_stability_pool_msgs( + depositor_addr: &Addr, + stability_pool_contract_addr: &Addr, + cdt_to_deposit: Coin, +) -> DestinationResult { + Ok(DestProjectMsgs { + msgs: vec![CosmosProtoMsg::ExecuteContract(create_exec_contract_msg( + stability_pool_contract_addr, + depositor_addr, + &stability_pool::ExecuteMsg::Deposit { user: None }, + Some(vec![CsdkCoin { + denom: cdt_to_deposit.denom.to_string(), + amount: cdt_to_deposit.amount.to_string(), + }]), + )?)], + sub_msgs: vec![], + events: vec![Event::new("deposit_into_stability_pool") + .add_attribute("amount", cdt_to_deposit.to_string())], + }) +} + +/// deposit basket assets into the user's CDP +pub fn deposit_into_cdp_msgs( + depositor_addr: &Addr, + cdp_contract_addr: &Addr, + position_id: Uint128, + deposits: &Vec, +) -> DestinationResult { + Ok(DestProjectMsgs { + msgs: vec![CosmosProtoMsg::ExecuteContract(create_exec_contract_msg( + cdp_contract_addr, + depositor_addr, + &cdp::ExecuteMsg::Deposit { + position_id: Some(position_id), + position_owner: None, + }, + Some( + deposits + .into_iter() + .map(|coin| CsdkCoin { + denom: coin.denom.to_string(), + amount: coin.amount.to_string(), + }) + .collect::>(), + ), + )?)], + sub_msgs: vec![], + events: vec![Event::new("deposit_into_cdp") + .add_attribute( + "deposits", + deposits + .iter() + .map(|coin| coin.to_string()) + .collect::>() + .join(","), + ) + .add_attribute("position_id", position_id.to_string())], + }) +} + +/// filter out assets that are not in the CDP basket +pub fn basket_denoms_filter( + querier: &QuerierWrapper, + cdp_contract_addr: &Addr, + assets: &Vec, +) -> Result, OsmosisDestinationError> { + // check the currently allowed assets + let basket: Basket = + querier.query_wasm_smart(cdp_contract_addr, &cdp::QueryMsg::GetBasket {})?; + + Ok(assets + .into_iter() + // filter out assets that are not in the basket + .filter(|coin| { + basket + .collateral_types + .iter() + // very weird checking Asset against Coin.denom. might work might blow up + .any(|asset| asset.asset.info.to_string().eq(&coin.denom)) + }) + .cloned() + .collect()) +} + +/// Mint CDT +pub fn mint_cdt_msgs( + minter_addr: &Addr, + cdp_contract_addr: &Addr, + position_id: Uint128, + desired_ltv: Decimal, +) -> DestinationResult { + Ok(DestProjectMsgs { + msgs: vec![CosmosProtoMsg::ExecuteContract(create_exec_contract_msg( + cdp_contract_addr, + minter_addr, + &cdp::ExecuteMsg::IncreaseDebt { + position_id, + amount: None, + LTV: Some(desired_ltv), + mint_to_addr: None, + }, + None, + )?)], + sub_msgs: vec![], + events: vec![Event::new("mint_cdt") + .add_attribute("desired_ltv", desired_ltv.to_string()) + .add_attribute("position_id", position_id.to_string())], + }) +} + +/// Repay CDT +pub fn repay_cdt_msgs( + repayer_addr: &Addr, + cdp_contract_addr: &Addr, + position_id: Uint128, + repay_amount: Coin, +) -> DestinationResult { + Ok(DestProjectMsgs { + msgs: vec![CosmosProtoMsg::ExecuteContract(create_exec_contract_msg( + cdp_contract_addr, + repayer_addr, + &cdp::ExecuteMsg::Repay { + position_id, + position_owner: None, + send_excess_to: None, + }, + Some(vec![CsdkCoin { + denom: repay_amount.denom.to_string(), + amount: repay_amount.amount.to_string(), + }]), + )?)], + sub_msgs: vec![], + events: vec![Event::new("repay_cdt") + .add_attribute("repay_amount", repay_amount.to_string()) + .add_attribute("position_id", position_id.to_string())], + }) } diff --git a/packages/osmosis-destinations/src/grants.rs b/packages/osmosis-destinations/src/grants.rs index f3c3ca6..59d8e4f 100644 --- a/packages/osmosis-destinations/src/grants.rs +++ b/packages/osmosis-destinations/src/grants.rs @@ -1,7 +1,9 @@ -use cosmwasm_std::{Addr, Uint128}; -use cw_grant_spec::grants::{GrantBase, GrantRequirement}; +use cosmos_sdk_proto::cosmos::base::v1beta1::Coin as CsdkCoin; +use cosmwasm_std::{Addr, Coin, Decimal, Uint128}; +use cw_grant_spec::grants::{ContractExecutionAuthorizationLimit, GrantBase, GrantRequirement}; +use membrane::cdp; -use crate::{dest_project_gen::MembraneExecuteMsg, mars_types::RedBankExecuteMsgs}; +use crate::mars_types::RedBankExecuteMsgs; pub fn membrane_stake_grant( base: GrantBase, @@ -11,26 +13,76 @@ pub fn membrane_stake_grant( vec![GrantRequirement::contract_exec_messages_auth( base, contract_addr, - vec![&MembraneExecuteMsg::Stake { user: None }], + vec![&membrane::staking::ExecuteMsg::Stake { user: None }], Some(mbrn_denom), )] } +pub fn membrane_deposit_into_stability_ool_grant( + base: GrantBase, + contract_addr: Addr, + cdt_denom: &str, +) -> Vec { + vec![GrantRequirement::contract_exec_messages_auth( + base, + contract_addr, + vec![&membrane::stability_pool::ExecuteMsg::Deposit { user: None }], + Some(cdt_denom), + )] +} + pub fn membrane_deposit_grant( base: GrantBase, contract_addr: Addr, position_id: Uint128, - _asset: String, - mbrn_denom: &str, + deposits: &Vec, ) -> Vec { vec![GrantRequirement::contract_exec_messages_auth( base, contract_addr, - vec![&MembraneExecuteMsg::CdpDeposit { + vec![&cdp::ExecuteMsg::Deposit { position_id: Some(position_id), position_owner: None, }], - Some(mbrn_denom), + // We need to accept any basket denom, unsure if this will allow anythign or nothing + None, + )] +} + +pub fn membrane_mint_cdt_grant( + base: GrantBase, + contract_addr: Addr, + position_id: Uint128, + desired_ltv: Decimal, +) -> Vec { + vec![GrantRequirement::contract_exec_messages_auth( + base, + contract_addr, + vec![&membrane::cdp::ExecuteMsg::IncreaseDebt { + position_id, + amount: None, + LTV: Some(desired_ltv), + mint_to_addr: None, + }], + None, + )] +} + +pub fn membrane_repay_cdt_grant( + base: GrantBase, + contract_addr: Addr, + position_id: Uint128, +) -> Vec { + vec![GrantRequirement::contract_exec_messages_auth( + base, + contract_addr, + vec![&membrane::cdp::ExecuteMsg::Repay { + position_id, + position_owner: None, + send_excess_to: None, + }], + // this should allow any basket denom, unsure if this will allow anythign or nothing + None, )] } diff --git a/packages/osmosis-destinations/src/lib.rs b/packages/osmosis-destinations/src/lib.rs index 4066364..d54550c 100644 --- a/packages/osmosis-destinations/src/lib.rs +++ b/packages/osmosis-destinations/src/lib.rs @@ -2,6 +2,7 @@ pub mod dest_project_gen; pub mod errors; pub mod grants; pub mod mars_types; +pub mod membrane_types; pub mod pools; pub mod comp_prefs; diff --git a/packages/osmosis-destinations/src/membrane_types.rs b/packages/osmosis-destinations/src/membrane_types.rs new file mode 100644 index 0000000..e8a3119 --- /dev/null +++ b/packages/osmosis-destinations/src/membrane_types.rs @@ -0,0 +1,57 @@ +use cosmwasm_schema::cw_serde; +use cosmwasm_std::{Decimal, Uint128}; + +#[cw_serde] +pub enum MembraneStabilityPoolExecuteMsg { + /// Deposit the debt token into the pool + Deposit { + /// User address, defaults to info.sender + user: Option, + }, + /// Claim ALL liquidation revenue && MBRN incentives + /// Can be queried from UserClaims + ClaimRewards {}, +} + +#[cw_serde] +pub enum MembraneStakingExecuteMsg { + Stake { user: Option }, +} + +#[cw_serde] +pub enum MembraneCDPExecuteMsg { + Deposit { + /// Position ID to deposit into. + /// If the user wants to create a new/separate position, no position id is passed. + position_id: Option, + /// Position owner. + /// Defaults to the sender. + position_owner: Option, + }, + // CDP Mint CDT + IncreaseDebt { + /// Position ID to increase debt of + position_id: Uint128, + /// Amount of debt to increase + amount: Option, + /// LTV to borrow up to + LTV: Option, + /// Mint debt tokens to this address + mint_to_addr: Option, + }, + // CDP Repay position debt + Repay { + /// Position ID to repay debt of + position_id: Uint128, + /// Position owner to repay debt of if not the sender + position_owner: Option, + /// Send excess assets to this address if not the sender + send_excess_to: Option, + }, +} + +#[cw_serde] +pub enum MembraneCDPQueryMsg { + /// Returns the contract's Basket + GetBasket {}, +}