diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b78c4f..337b273 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [0.3.2] - 2024-05-06 + +- Replace `cw-dex/astroport` with `cw-dex-astroport`. + # [0.3.1] - 2024-02-06 - Bump `cw-dex` to version `0.5.1`. diff --git a/Cargo.lock b/Cargo.lock index b1d3695..2ec2f24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,10 +64,10 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "423502406a307052f6877030f48b5fb4e9fb338fc5e7c8ca1064210def52876b" dependencies = [ - "astroport", + "astroport 2.9.0", "cosmwasm-std", - "cw-storage-plus 1.1.0", - "cw20 1.1.0", + "cw-storage-plus 1.2.0", + "cw20 1.1.2", "schemars", "serde", ] @@ -81,7 +81,7 @@ dependencies = [ "apollo-cw-asset", "cosmwasm-schema", "cosmwasm-std", - "cw20 1.1.0", + "cw20 1.1.2", "regex", ] @@ -96,10 +96,41 @@ dependencies = [ "cw-storage-plus 0.15.1", "cw-utils 0.15.1", "cw20 0.15.1", - "itertools", + "itertools 0.10.5", "uint", ] +[[package]] +name = "astroport" +version = "5.0.0-rc.1-tokenfactory" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf6999cd2652543814f071f6e67c718ad4608607c90bc3bc89566b8a5985db3" +dependencies = [ + "astroport-circular-buffer", + "cosmos-sdk-proto 0.19.0", + "cosmwasm-schema", + "cosmwasm-std", + "cw-asset", + "cw-storage-plus 1.2.0", + "cw-utils 1.0.1", + "cw20 1.1.2", + "itertools 0.12.1", + "prost 0.11.9", + "uint", +] + +[[package]] +name = "astroport-circular-buffer" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c7369d3c4126804f861620db2221c15b5fa7b7718f12180e265b087c933fb6" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus 0.15.1", + "thiserror", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -119,7 +150,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -130,7 +161,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -240,6 +271,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + [[package]] name = "bindgen" version = "0.60.1" @@ -313,9 +350,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128a44527fc0d6abf05f9eda748b9027536e12dff93f5acc8449f51583309350" +checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" [[package]] name = "bollard" @@ -523,8 +560,8 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20b42021d8488665b1a0d9748f1f81df7235362d194f44481e2e61bf376b77b4" dependencies = [ - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "tendermint-proto 0.23.9", ] @@ -534,12 +571,23 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673d31bd830c0772d78545de20d975129b6ab2f7db4e4e9313c3b8777d319194" dependencies = [ - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "tendermint-proto 0.26.0", "tonic", ] +[[package]] +name = "cosmos-sdk-proto" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73c9d2043a9e617b0d602fbc0a0ecd621568edbf3a9774890a6d562389bd8e1c" +dependencies = [ + "prost 0.11.9", + "prost-types 0.11.9", + "tendermint-proto 0.32.2", +] + [[package]] name = "cosmrs" version = "0.9.0" @@ -563,11 +611,12 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.4.0" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca101fbf2f76723711a30ea3771ef312ec3ec254ad021b237871ed802f9f175" +checksum = "e6b4c3f9c4616d6413d4b5fc4c270a4cc32a374b9be08671e80e1a019f805d8f" dependencies = [ "digest 0.10.7", + "ecdsa 0.16.8", "ed25519-zebra", "k256 0.13.1", "rand_core 0.6.4", @@ -576,18 +625,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.4.0" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c73d2dd292f60e42849d2b07c03d809cf31e128a4299a805abd6d24553bcaaf5" +checksum = "c586ced10c3b00e809ee664a895025a024f60d65d34fe4c09daed4a4db68a3f3" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.4.0" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce34a08020433989af5cc470104f6bd22134320fe0221bd8aeb919fd5ec92d5" +checksum = "8467874827d384c131955ff6f4d47d02e72a956a08eb3c0ff24f8c903a5517b4" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -598,9 +647,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.4.0" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96694ec781a7dd6dea1f968a2529ade009c21ad999c88b5f53d6cc495b3b96f7" +checksum = "f6db85d98ac80922aef465e564d5b21fa9cfac5058cb62df7f116c3682337393" dependencies = [ "proc-macro2", "quote", @@ -609,11 +658,12 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.4.0" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a44d3f9c25b2f864737c6605a98f2e4675d53fd8bbc7cf4d7c02475661a793d" +checksum = "712fe58f39d55c812f7b2c84e097cdede3a39d520f89b6dc3153837e31741927" dependencies = [ "base64 0.21.4", + "bech32", "bnum", "cosmwasm-crypto", "cosmwasm-derive", @@ -624,6 +674,7 @@ dependencies = [ "serde", "serde-json-wasm", "sha2 0.10.8", + "static_assertions", "thiserror", ] @@ -698,6 +749,29 @@ dependencies = [ "zeroize", ] +[[package]] +name = "cw-address-like" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" +dependencies = [ + "cosmwasm-std", +] + +[[package]] +name = "cw-asset" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c999a12f8cd8736f6f86e9a4ede5905530cb23cfdef946b9da1c506ad1b70799" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-address-like", + "cw-storage-plus 1.2.0", + "cw20 1.1.2", + "thiserror", +] + [[package]] name = "cw-controllers" version = "1.1.0" @@ -706,7 +780,7 @@ checksum = "d5d8edce4b78785f36413f67387e4be7d0cb7d032b5d4164bcc024f9c3f3f2ea" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.2.0", "cw-utils 1.0.1", "schemars", "serde", @@ -715,22 +789,52 @@ dependencies = [ [[package]] name = "cw-dex" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f47ce1f0a02665dfe244bd5e396ecd3f8628fb8e6aabd1be38689501b6c139a" +checksum = "cd655e137d57d6c77696247d2417cfee75b15d027b1465741f45fa88bfcbf1b7" dependencies = [ "apollo-cw-asset", "apollo-utils", - "astroport", "cosmwasm-schema", "cosmwasm-std", "cw-utils 1.0.1", - "cw2 1.1.0", - "cw20 1.1.0", - "osmosis-std 0.19.2", + "cw20 1.1.2", "thiserror", ] +[[package]] +name = "cw-dex-astroport" +version = "0.2.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32c217056c99f6fa18310c24e7a06f1b5ee489165d066e796ebd136e1ddce90b" +dependencies = [ + "apollo-cw-asset", + "apollo-utils", + "astroport 2.9.0", + "astroport 5.0.0-rc.1-tokenfactory", + "cosmwasm-schema", + "cosmwasm-std", + "cw-dex", + "cw-utils 1.0.1", + "cw2 1.1.0", + "cw20 1.1.2", +] + +[[package]] +name = "cw-dex-osmosis" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1691781e4deda5b4fb564542752e9226763997996a71abadb80f770cd7ec04c" +dependencies = [ + "apollo-cw-asset", + "apollo-utils", + "cosmwasm-schema", + "cosmwasm-std", + "cw-dex", + "cw-utils 1.0.1", + "osmosis-std 0.22.0", +] + [[package]] name = "cw-dex-router" version = "0.3.1" @@ -741,11 +845,13 @@ dependencies = [ "cosmwasm-std", "cw-controllers", "cw-dex", + "cw-dex-astroport", + "cw-dex-osmosis", "cw-it 0.1.0", "cw-it 0.2.3", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.2.0", "cw2 1.1.0", - "cw20 1.1.0", + "cw20 1.1.2", "osmosis-testing 0.12.0", "serde_json", "test-case", @@ -766,7 +872,7 @@ dependencies = [ "git2", "git2_credentials", "osmosis-testing 0.13.1", - "prost", + "prost 0.11.9", "serde", "serde_json", "testcontainers", @@ -788,7 +894,7 @@ dependencies = [ "cosmwasm-std", "osmosis-std 0.19.2", "osmosis-test-tube", - "prost", + "prost 0.11.9", "serde", "serde_json", "strum", @@ -809,9 +915,9 @@ dependencies = [ [[package]] name = "cw-storage-plus" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f0e92a069d62067f3472c62e30adedb4cab1754725c0f2a682b3128d2bf3c79" +checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" dependencies = [ "cosmwasm-std", "schemars", @@ -869,7 +975,7 @@ checksum = "29ac2dc7a55ad64173ca1e0a46697c31b7a5c51342f55a1e84a724da4eb99908" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus 1.1.0", + "cw-storage-plus 1.2.0", "schemars", "serde", "thiserror", @@ -890,9 +996,9 @@ dependencies = [ [[package]] name = "cw20" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "011c45920f8200bd5d32d4fe52502506f64f2f75651ab408054d4cfc75ca3a9b" +checksum = "526e39bb20534e25a1cd0386727f0038f4da294e5e535729ba3ef54055246abd" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -1323,7 +1429,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -1730,6 +1836,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -2043,8 +2158,8 @@ dependencies = [ "chrono", "cosmwasm-std", "osmosis-std-derive 0.12.0 (git+https://github.com/apollodao/osmosis-rust.git?branch=osmosis-v13)", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "schemars", "serde", "serde-cw-value", @@ -2058,8 +2173,8 @@ dependencies = [ "chrono", "cosmwasm-std", "osmosis-std-derive 0.12.0 (git+https://github.com/apollodao/osmosis-rust?rev=430236bd63f26d618e11e59709a56c808c4d427c)", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "schemars", "serde", "serde-cw-value", @@ -2074,8 +2189,24 @@ dependencies = [ "chrono", "cosmwasm-std", "osmosis-std-derive 0.16.2", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", + "schemars", + "serde", + "serde-cw-value", +] + +[[package]] +name = "osmosis-std" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8641c376f01f5af329dc2a34e4f5527eaeb0bde18cda8d86fed958d04c86159c" +dependencies = [ + "chrono", + "cosmwasm-std", + "osmosis-std-derive 0.20.1", + "prost 0.12.4", + "prost-types 0.12.4", "schemars", "serde", "serde-cw-value", @@ -2086,7 +2217,7 @@ name = "osmosis-std-derive" version = "0.12.0" source = "git+https://github.com/apollodao/osmosis-rust.git?branch=osmosis-v13#38a48533ed88243070b105cb9085e34c2b0c4eeb" dependencies = [ - "itertools", + "itertools 0.10.5", "proc-macro2", "quote", "syn 1.0.109", @@ -2097,7 +2228,7 @@ name = "osmosis-std-derive" version = "0.12.0" source = "git+https://github.com/apollodao/osmosis-rust?rev=430236bd63f26d618e11e59709a56c808c4d427c#430236bd63f26d618e11e59709a56c808c4d427c" dependencies = [ - "itertools", + "itertools 0.10.5", "proc-macro2", "quote", "syn 1.0.109", @@ -2109,9 +2240,22 @@ version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f47f0b2f22adb341bb59e5a3a1b464dde033181954bd055b9ae86d6511ba465b" dependencies = [ - "itertools", + "itertools 0.10.5", + "proc-macro2", + "prost-types 0.11.9", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "osmosis-std-derive" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5ebdfd1bc8ed04db596e110c6baa9b174b04f6ed1ec22c666ddc5cb3fa91bd7" +dependencies = [ + "itertools 0.10.5", "proc-macro2", - "prost-types", + "prost-types 0.11.9", "quote", "syn 1.0.109", ] @@ -2127,7 +2271,7 @@ dependencies = [ "cosmrs", "cosmwasm-std", "osmosis-std 0.19.2", - "prost", + "prost 0.11.9", "serde", "serde_json", "test-tube", @@ -2143,9 +2287,9 @@ dependencies = [ "bindgen", "cosmrs", "cosmwasm-std", - "itertools", + "itertools 0.10.5", "osmosis-std 0.12.0 (git+https://github.com/apollodao/osmosis-rust?rev=430236bd63f26d618e11e59709a56c808c4d427c)", - "prost", + "prost 0.11.9", "serde", "serde_json", "thiserror", @@ -2161,9 +2305,9 @@ dependencies = [ "bindgen", "cosmrs", "cosmwasm-std", - "itertools", + "itertools 0.10.5", "osmosis-std 0.12.0 (git+https://github.com/apollodao/osmosis-rust.git?branch=osmosis-v13)", - "prost", + "prost 0.11.9", "serde", "serde_json", "thiserror", @@ -2261,7 +2405,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -2292,7 +2436,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -2365,9 +2509,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -2379,7 +2523,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +dependencies = [ + "bytes", + "prost-derive 0.12.4", ] [[package]] @@ -2389,26 +2543,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", - "itertools", + "itertools 0.10.5", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost", + "prost 0.11.9", +] + +[[package]] +name = "prost-types" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +dependencies = [ + "prost 0.12.4", ] [[package]] name = "quote" -version = "1.0.33" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -2775,9 +2951,9 @@ dependencies = [ [[package]] name = "serde-json-wasm" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" +checksum = "9e9213a07d53faa0b8dd81e767a54a8188a242fdb9be99ab75ec576a774bfdd7" dependencies = [ "serde", ] @@ -2799,7 +2975,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -2832,7 +3008,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -3063,9 +3239,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -3106,8 +3282,8 @@ dependencies = [ "k256 0.11.6", "num-traits", "once_cell", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "ripemd160", "serde", "serde_bytes", @@ -3146,8 +3322,8 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "serde", "serde_bytes", "subtle-encoding", @@ -3164,8 +3340,26 @@ dependencies = [ "flex-error", "num-derive", "num-traits", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + +[[package]] +name = "tendermint-proto" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0cec054567d16d85e8c3f6a3139963d1a66d9d3051ed545d31562550e9bcc3d" +dependencies = [ + "bytes", + "flex-error", + "num-derive", + "num-traits", + "prost 0.11.9", + "prost-types 0.11.9", "serde", "serde_bytes", "subtle-encoding", @@ -3233,7 +3427,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -3245,7 +3439,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", "test-case-core", ] @@ -3259,7 +3453,7 @@ dependencies = [ "cosmrs", "cosmwasm-std", "osmosis-std 0.19.2", - "prost", + "prost 0.11.9", "serde", "serde_json", "thiserror", @@ -3293,22 +3487,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -3378,7 +3572,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -3460,8 +3654,8 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost", - "prost-derive", + "prost 0.11.9", + "prost-derive 0.11.9", "tokio", "tokio-stream", "tokio-util 0.7.9", @@ -3524,7 +3718,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] [[package]] @@ -3684,7 +3878,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -3706,7 +3900,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3956,5 +4150,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.60", ] diff --git a/Cargo.toml b/Cargo.toml index 98e452e..309c5da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,8 +37,8 @@ rpath = false default = [] # use library feature to disable all instantiate/execute/query exports library = [] -osmosis = ["cw-dex/osmosis"] -astroport = ["cw-dex/astroport"] +osmosis = ["cw-dex-osmosis"] +astroport = ["cw-dex-astroport"] [package.metadata.optimizer] builds = [ @@ -52,6 +52,8 @@ cosmwasm-schema = "1.2.1" apollo-cw-asset = "0.1.0" cw-controllers = "1.0.1" cw-dex = "0.5.1" +cw-dex-astroport = { version = "0.2.0-rc.1", optional = true} +cw-dex-osmosis = { version = "0.1.0", optional = true} cw-storage-plus = "1.0.1" cw2 = "1.0.1" cw20 = "1.0.1" diff --git a/src/contract.rs b/src/contract.rs index 5cbff57..19bf857 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -2,8 +2,8 @@ use apollo_cw_asset::{Asset, AssetInfo, AssetInfoUnchecked, AssetList, AssetList #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - from_binary, to_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Env, Event, MessageInfo, Order, - Response, StdResult, Uint128, + from_json, to_json_binary, Addr, Binary, CosmosMsg, Deps, DepsMut, Env, Event, MessageInfo, + Order, Response, StdResult, Uint128, }; use cw2::set_contract_version; use cw20::Cw20ReceiveMsg; @@ -12,6 +12,7 @@ use crate::error::ContractError; use crate::helpers::{receive_asset, receive_assets}; use crate::msg::{CallbackMsg, Cw20HookMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use crate::operations::{SwapOperation, SwapOperationsList, SwapOperationsListUnchecked}; +use crate::pool::PoolAccess; use crate::state::{ADMIN, PATHS}; const CONTRACT_NAME: &str = "crates.io:cw-dex-router"; @@ -124,7 +125,7 @@ pub fn receive_cw20( ) -> Result { let sender = deps.api.addr_validate(&cw20_msg.sender)?; - match from_binary(&cw20_msg.msg)? { + match from_json(&cw20_msg.msg)? { Cw20HookMsg::ExecuteSwapOperations { operations, minimum_receive, @@ -336,11 +337,11 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { QueryMsg::SimulateSwapOperations { offer_amount, operations, - } => to_binary(&simulate_swap_operations(deps, offer_amount, operations)?), + } => to_json_binary(&simulate_swap_operations(deps, offer_amount, operations)?), QueryMsg::SimulateBasketLiquidate { offer_assets, receive_asset, - } => to_binary(&simulate_basket_liquidate( + } => to_json_binary(&simulate_basket_liquidate( deps, offer_assets, receive_asset, @@ -348,16 +349,16 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { QueryMsg::PathForPair { offer_asset, ask_asset, - } => to_binary(&query_path_for_pair( + } => to_json_binary(&query_path_for_pair( deps, offer_asset.check(deps.api)?, ask_asset.check(deps.api)?, )?), QueryMsg::SupportedOfferAssets { ask_asset } => { - to_binary(&query_supported_offer_assets(deps, ask_asset)?) + to_json_binary(&query_supported_offer_assets(deps, ask_asset)?) } QueryMsg::SupportedAskAssets { offer_asset } => { - to_binary(&query_supported_ask_assets(deps, offer_asset)?) + to_json_binary(&query_supported_ask_assets(deps, offer_asset)?) } } } diff --git a/src/helpers.rs b/src/helpers.rs index 90b8830..a009cf4 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -6,7 +6,7 @@ use cosmwasm_schema::cw_serde; use cw20::{Cw20Coin, Cw20ExecuteMsg}; use cosmwasm_std::{ - to_binary, Addr, Api, Coin, CosmosMsg, Env, MessageInfo, QuerierWrapper, QueryRequest, + to_json_binary, Addr, Api, Coin, CosmosMsg, Env, MessageInfo, QuerierWrapper, QueryRequest, StdError, StdResult, Uint128, WasmMsg, WasmQuery, }; @@ -48,7 +48,7 @@ impl CwDexRouterUnchecked { Ok(CosmosMsg::Wasm(WasmMsg::Instantiate { code_id, admin, - msg: to_binary(&InstantiateMsg {})?, + msg: to_json_binary(&InstantiateMsg {})?, funds: vec![], label: label.unwrap_or_else(|| "cw-dex-router".to_string()), })) @@ -65,7 +65,7 @@ impl CwDexRouter { } pub fn call>(&self, msg: T, funds: Vec) -> StdResult { - let msg = to_binary(&msg.into())?; + let msg = to_json_binary(&msg.into())?; Ok(WasmMsg::Execute { contract_addr: self.addr().into(), msg, @@ -119,7 +119,7 @@ impl CwDexRouter { .map(|x| { Ok(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: x.address, - msg: to_binary(&Cw20ExecuteMsg::IncreaseAllowance { + msg: to_json_binary(&Cw20ExecuteMsg::IncreaseAllowance { spender: self.addr().to_string(), amount: x.amount, expires: None, @@ -169,7 +169,7 @@ impl CwDexRouter { ) -> StdResult { querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: self.0.to_string(), - msg: to_binary(&QueryMsg::SimulateSwapOperations { + msg: to_json_binary(&QueryMsg::SimulateSwapOperations { offer_amount, operations: operations.into(), })?, @@ -184,7 +184,7 @@ impl CwDexRouter { ) -> StdResult { querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: self.0.to_string(), - msg: to_binary(&QueryMsg::SimulateBasketLiquidate { + msg: to_json_binary(&QueryMsg::SimulateBasketLiquidate { offer_assets: offer_assets.into(), receive_asset: receive_asset.to_owned().into(), })?, @@ -199,7 +199,7 @@ impl CwDexRouter { ) -> StdResult { querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: self.0.to_string(), - msg: to_binary(&QueryMsg::PathForPair { + msg: to_json_binary(&QueryMsg::PathForPair { offer_asset: offer_asset.to_owned().into(), ask_asset: ask_asset.to_owned().into(), })?, @@ -213,7 +213,7 @@ impl CwDexRouter { ) -> StdResult> { querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: self.0.to_string(), - msg: to_binary(&QueryMsg::SupportedOfferAssets { + msg: to_json_binary(&QueryMsg::SupportedOfferAssets { ask_asset: ask_asset.to_owned().into(), })?, })) @@ -226,7 +226,7 @@ impl CwDexRouter { ) -> StdResult> { querier.query(&QueryRequest::Wasm(WasmQuery::Smart { contract_addr: self.0.to_string(), - msg: to_binary(&QueryMsg::SupportedAskAssets { + msg: to_json_binary(&QueryMsg::SupportedAskAssets { offer_asset: offer_asset.to_owned().into(), })?, })) diff --git a/src/lib.rs b/src/lib.rs index 3b46fe3..14d4562 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ mod error; pub mod helpers; pub mod msg; pub mod operations; +pub mod pool; pub mod state; pub use crate::error::ContractError; diff --git a/src/operations.rs b/src/operations.rs index 8ddf11c..7efb36c 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -1,10 +1,9 @@ use crate::msg::CallbackMsg; +use crate::pool::{Pool, PoolAccess}; use crate::ContractError; use apollo_cw_asset::{Asset, AssetInfo, AssetInfoBase}; use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, CosmosMsg, Deps, Env, Response, Uint128}; -use cw_dex::traits::Pool as PoolTrait; -use cw_dex::Pool; #[cw_serde] pub struct SwapOperationBase { @@ -32,6 +31,8 @@ pub type SwapOperationUnchecked = SwapOperationBase; pub type SwapOperation = SwapOperationBase; impl SwapOperationUnchecked { + #[allow(unreachable_code)] + #[allow(unused_variables)] pub fn check(&self, deps: Deps) -> Result { let op = SwapOperation { ask_asset_info: self.ask_asset_info.check(deps.api)?, @@ -39,7 +40,7 @@ impl SwapOperationUnchecked { pool: self.pool.clone(), }; // validate pool assets - let pool_assets = op.pool.pool_assets(deps)?; + let pool_assets = op.pool.as_trait().pool_assets(deps)?; if !pool_assets.contains(&op.offer_asset_info) || !pool_assets.contains(&op.ask_asset_info) { Err(ContractError::InvalidSwapOperations { @@ -63,7 +64,7 @@ impl SwapOperation { let offer_asset = Asset::new(self.offer_asset_info.clone(), offer_amount); let minimum_receive = minimum_receive.unwrap_or(Uint128::one()); - let mut response = self.pool.swap( + let mut response = self.pool.as_trait().swap( deps, env, offer_asset.clone(), @@ -74,9 +75,11 @@ impl SwapOperation { if recipient != env.contract.address { // Simulate swap to know how much will be returned, then add message // to send tokens to recipient - let receive_amount = - self.pool - .simulate_swap(deps, offer_asset, self.ask_asset_info.clone())?; + let receive_amount = self.pool.as_trait().simulate_swap( + deps, + offer_asset, + self.ask_asset_info.clone(), + )?; let receive_asset = Asset::new(self.ask_asset_info.clone(), receive_amount); response = response.add_message(receive_asset.transfer_msg(recipient)?); } @@ -115,7 +118,8 @@ impl SwapOperationsListUnchecked { pub fn new(operations: Vec) -> Self { Self(operations) } - + #[allow(unreachable_code)] + #[allow(unused_variables)] pub fn check(&self, deps: Deps) -> Result { let operations = self .0 @@ -171,6 +175,8 @@ impl SwapOperationsList { Self::new(operations) } + #[allow(unreachable_code)] + #[allow(unused_variables)] pub fn into_execute_msgs( &self, env: &Env, @@ -227,8 +233,8 @@ impl From for SwapOperationsListUnchecked { mod unit_tests { use crate::operations::{SwapOperation, SwapOperationsList}; use apollo_cw_asset::AssetInfo; - use cw_dex::osmosis::OsmosisPool; - use cw_dex::Pool; + use crate::pool::Pool; + use cw_dex_osmosis::OsmosisPool; #[test] fn test_reverse() { diff --git a/src/pool.rs b/src/pool.rs new file mode 100644 index 0000000..dc69501 --- /dev/null +++ b/src/pool.rs @@ -0,0 +1,31 @@ +use cosmwasm_schema::cw_serde; + +#[cw_serde] +pub enum Pool { + #[cfg(feature = "osmosis")] + Osmosis(cw_dex_osmosis::OsmosisPool), + + #[cfg(feature = "astroport")] + Astroport(cw_dex_astroport::AstroportPool), +} + +// Define a trait for accessing the underlying Pool trait object +pub trait PoolAccess { + fn as_trait(&self) -> &dyn cw_dex::traits::Pool; +} + +// Implement this trait for your Pool enum +impl PoolAccess for Pool { + fn as_trait(&self) -> &dyn cw_dex::traits::Pool { + match self { + #[cfg(feature = "osmosis")] + Pool::Osmosis(ref osmosis_pool) => osmosis_pool, + + #[cfg(feature = "astroport")] + Pool::Astroport(ref astroport_pool) => astroport_pool, + _ => { + panic!("Pool variant not supported"); + } + } + } +}