From d1b8240dfab489cf1da043947dd8f9e91b6b1b94 Mon Sep 17 00:00:00 2001 From: PFC <81114960+PFC-developer@users.noreply.github.com> Date: Sat, 28 Oct 2023 15:12:50 -0500 Subject: [PATCH] feat: dust-collection functional/tested --- Cargo.lock | 1588 +------------------------ Cargo.toml | 9 +- contracts/hub-tf/Cargo.toml | 5 +- contracts/hub-tf/src/contract.rs | 82 +- contracts/hub-tf/src/execute.rs | 435 ++++--- contracts/hub-tf/src/testing/tests.rs | 425 +++++-- contracts/hub/Cargo.toml | 2 +- contracts/hub/src/contract.rs | 74 +- contracts/hub/src/execute.rs | 2 +- packages/steak/src/hub.rs | 75 +- packages/steak/src/hub_tf.rs | 21 +- 11 files changed, 813 insertions(+), 1905 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 243fd28e..8767aca5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,59 +2,12 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli 0.27.2", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.6", - "once_cell", - "version_check", -] - [[package]] name = "anyhow" version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object 0.30.3", - "rustc-demangle", -] - [[package]] name = "base16ct" version = "0.1.1" @@ -73,12 +26,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dea908e7347a8c64e378c17e30ef880ad73e3b4498346b055c2c00ea342f3179" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "block-buffer" version = "0.9.0" @@ -97,34 +44,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bumpalo" -version = "3.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" - -[[package]] -name = "bytecheck" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" -dependencies = [ - "bytecheck_derive", - "ptr_meta", - "simdutf8", -] - -[[package]] -name = "bytecheck_derive" -version = "0.6.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "byteorder" version = "1.4.3" @@ -137,43 +56,18 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "clru" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "591ff76ca0691bd91c1b0b5b987e5cf93b21ec810ad96665c5a569c60846dd93" - [[package]] name = "const-oid" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "722e23542a15cea1f65d4a1419c4cfd7a26706c70871a13a04238ca3f40f1661" -[[package]] -name = "corosensei" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9847f90f32a50b0dcbd68bc23ff242798b13080b97b0569f6ed96a45ce4cf2cd" -dependencies = [ - "autocfg", - "cfg-if", - "libc", - "scopeguard", - "windows-sys 0.33.0", -] - [[package]] name = "cosmwasm-crypto" version = "1.2.4" @@ -240,40 +134,6 @@ dependencies = [ "uint", ] -[[package]] -name = "cosmwasm-storage" -version = "1.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88f7944b5204c3a998f73248925a097ace887bdf01c2f70de00d8b92cd69e807" -dependencies = [ - "cosmwasm-std", - "serde", -] - -[[package]] -name = "cosmwasm-vm" -version = "1.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb647b2f444c88b02da06794f27fc4270989fb50969c47998a493a79d77ccef" -dependencies = [ - "bitflags", - "bytecheck", - "clru", - "cosmwasm-crypto", - "cosmwasm-std", - "enumset", - "hex", - "loupe", - "parity-wasm", - "schemars", - "serde", - "serde_json", - "sha2 0.10.6", - "thiserror", - "wasmer", - "wasmer-middlewares", -] - [[package]] name = "cpufeatures" version = "0.2.2" @@ -283,117 +143,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cranelift-bforest" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38faa2a16616c8e78a18d37b4726b98bfd2de192f2fdc8a39ddf568a408a0f75" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f192472a3ba23860afd07d2b0217dc628f21fcc72617aa1336d98e1671f33b" -dependencies = [ - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "gimli 0.26.2", - "log", - "regalloc", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32ddb89e9b89d3d9b36a5b7d7ea3261c98235a76ac95ba46826b8ec40b1a24" -dependencies = [ - "cranelift-codegen-shared", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01fd0d9f288cc1b42d9333b7a776b17e278fc888c28e6a0f09b5573d45a150bc" - -[[package]] -name = "cranelift-entity" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3bfe172b83167604601faf9dc60453e0d0a93415b57a9c4d1a7ae6849185cf" - -[[package]] -name = "cranelift-frontend" -version = "0.82.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a006e3e32d80ce0e4ba7f1f9ddf66066d052a8c884a110b91d05404d6ce26dce" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset 0.8.0", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" -dependencies = [ - "cfg-if", -] - [[package]] name = "crunchy" version = "0.2.2" @@ -652,40 +401,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - [[package]] name = "der" version = "0.6.0" @@ -733,32 +448,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" -[[package]] -name = "dynasm" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add9a102807b524ec050363f09e06f1504214b0e1c7797f64261c891022dce8b" -dependencies = [ - "bitflags", - "byteorder", - "lazy_static", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "dynasmrt" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64fba5a42bd76a17cad4bfa00de168ee1cbfa06a5e8ce992ae880218c05641a9" -dependencies = [ - "byteorder", - "dynasm", - "memmap2", -] - [[package]] name = "ecdsa" version = "0.14.8" @@ -812,83 +501,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "enum-iterator" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "enumset" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" -dependencies = [ - "enumset_derive", -] - -[[package]] -name = "enumset_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "ff" version = "0.12.0" @@ -899,12 +511,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "forward_ref" version = "1.0.0" @@ -914,7 +520,7 @@ checksum = "c8cbd1169bd7b4a0a20d92b9af7a7e0422888bd38a6f5ec29c1fd8c1558a272e" [[package]] name = "funds-distributor-api" version = "0.1.0" -source = "git+https://github.com/terra-money/enterprise-contracts.git?branch=main#6028fa7bf7110df3a8e82cfd9cd67686401d0061" +source = "git+https://github.com/terra-money/enterprise-contracts.git?branch=main#6d736c0bbc1a6ac52d862c8b80d63be6bb43d419" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -954,23 +560,6 @@ dependencies = [ "wasi 0.10.2+wasi-snapshot-preview1", ] -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - -[[package]] -name = "gimli" -version = "0.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" - [[package]] name = "group" version = "0.12.1" @@ -983,117 +572,38 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.11.2" +name = "hex" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] -name = "hashbrown" -version = "0.12.3" +name = "hmac" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "ahash", + "digest 0.10.5", ] [[package]] -name = "hermit-abi" -version = "0.2.6" +name = "itertools" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ - "libc", + "either", ] [[package]] -name = "hermit-abi" -version = "0.3.1" +name = "itoa" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.5", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" -dependencies = [ - "hermit-abi 0.3.1", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" - -[[package]] -name = "js-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "k256" -version = "0.11.6" +name = "k256" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ @@ -1103,158 +613,12 @@ dependencies = [ "sha2 0.10.6", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "leb128" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" - [[package]] name = "libc" version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "linux-raw-sys" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64f40e5e03e0d54f03845c8197d0291253cdbedfb1cb46b13c2c117554a9f4c" - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "loupe" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6a72dfa44fe15b5e76b94307eeb2ff995a8c5b283b55008940c02e0c5b634d" -dependencies = [ - "indexmap", - "loupe-derive", - "rustversion", -] - -[[package]] -name = "loupe-derive" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "memmap2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" -dependencies = [ - "autocfg", -] - -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - -[[package]] -name = "more-asserts" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" - -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi 0.2.6", - "libc", -] - -[[package]] -name = "object" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" -dependencies = [ - "crc32fast", - "hashbrown 0.11.2", - "indexmap", - "memchr", -] - -[[package]] -name = "object" -version = "0.30.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.17.1" @@ -1279,12 +643,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parity-wasm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" - [[package]] name = "pfc-dust-collector" version = "0.1.0" @@ -1325,30 +683,6 @@ dependencies = [ "serde", ] -[[package]] -name = "pfc-ibc-reflect" -version = "0.0.1" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cosmwasm-vm", - "schemars", - "serde", -] - -[[package]] -name = "pfc-ibc-reflect-send" -version = "0.0.1" -dependencies = [ - "cosmwasm-schema", - "cosmwasm-std", - "cosmwasm-storage", - "cosmwasm-vm", - "schemars", - "serde", -] - [[package]] name = "pfc-steak" version = "3.0.9" @@ -1371,7 +705,6 @@ dependencies = [ "cw20 1.0.1", "cw20-base 1.0.0", "funds-distributor-api", - "pfc-dust-collector", "pfc-fee-split", "pfc-steak", "serde", @@ -1432,12 +765,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "pin-project-lite" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" - [[package]] name = "pkcs8" version = "0.9.0" @@ -1448,30 +775,6 @@ dependencies = [ "spki", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.54" @@ -1534,26 +837,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "ptr_meta" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" -dependencies = [ - "ptr_meta_derive", -] - -[[package]] -name = "ptr_meta_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "quote" version = "1.0.26" @@ -1582,98 +865,89 @@ dependencies = [ ] [[package]] -name = "rayon" -version = "1.7.0" +name = "rfc6979" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "88c86280f057430a52f4861551b092a01b419b8eacefc7c995eacb9dc132fe32" dependencies = [ - "either", - "rayon-core", + "crypto-bigint", + "hmac", + "zeroize", ] [[package]] -name = "rayon-core" -version = "1.11.0" +name = "ryu" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] -name = "redox_syscall" -version = "0.3.5" +name = "schemars" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" dependencies = [ - "bitflags", + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", ] [[package]] -name = "regalloc" -version = "0.0.34" +name = "schemars_derive" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62446b1d3ebf980bdc68837700af1d77b37bc430e524bf95319c6eada2a4cc02" +checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" dependencies = [ - "log", - "rustc-hash", - "smallvec", + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 1.0.109", ] [[package]] -name = "region" -version = "3.0.0" +name = "sec1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", ] [[package]] -name = "rend" -version = "0.4.0" +name = "semver" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" -dependencies = [ - "bytecheck", -] +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" [[package]] -name = "rfc6979" -version = "0.3.0" +name = "serde" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88c86280f057430a52f4861551b092a01b419b8eacefc7c995eacb9dc132fe32" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ - "crypto-bigint", - "hmac", - "zeroize", + "serde_derive", ] [[package]] -name = "rkyv" -version = "0.7.41" +name = "serde-json-wasm" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" +checksum = "a15bee9b04dd165c3f4e142628982ddde884c2022a89e8ddf99c4829bf2c3a58" dependencies = [ - "bytecheck", - "hashbrown 0.12.3", - "ptr_meta", - "rend", - "rkyv_derive", - "seahash", + "serde", ] [[package]] -name = "rkyv_derive" -version = "0.7.41" +name = "serde_derive" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -1681,140 +955,8 @@ dependencies = [ ] [[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustix" -version = "0.37.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bbfc1d1c7c40c01715f47d71444744a81669ca84e8b63e25a55e169b1f86433" -dependencies = [ - "bitflags", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustversion" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" - -[[package]] -name = "ryu" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" - -[[package]] -name = "schemars" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" -dependencies = [ - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn 1.0.109", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "seahash" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct", - "der", - "generic-array", - "pkcs8", - "subtle", - "zeroize", -] - -[[package]] -name = "semver" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" - -[[package]] -name = "serde" -version = "1.0.136" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-json-wasm" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15bee9b04dd165c3f4e142628982ddde884c2022a89e8ddf99c4829bf2c3a58" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_bytes" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" -dependencies = [ - "serde", -] - -[[package]] -name = "serde_derive" -version = "1.0.136" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "serde_derive_internals" -version = "0.26.0" +name = "serde_derive_internals" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ @@ -1868,18 +1010,6 @@ dependencies = [ "rand_core 0.6.3", ] -[[package]] -name = "simdutf8" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" - -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - [[package]] name = "spki" version = "0.6.0" @@ -1890,12 +1020,6 @@ dependencies = [ "der", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "static_assertions" version = "1.1.0" @@ -1930,25 +1054,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "target-lexicon" -version = "0.12.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" - -[[package]] -name = "tempfile" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" -dependencies = [ - "cfg-if", - "fastrand", - "redox_syscall", - "rustix", - "windows-sys 0.45.0", -] - [[package]] name = "thiserror" version = "1.0.40" @@ -1969,39 +1074,6 @@ dependencies = [ "syn 2.0.11", ] -[[package]] -name = "tracing" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" -dependencies = [ - "cfg-if", - "log", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.11", -] - -[[package]] -name = "tracing-core" -version = "0.1.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" -dependencies = [ - "once_cell", -] - [[package]] name = "typenum" version = "1.15.0" @@ -2044,536 +1116,6 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" -[[package]] -name = "wasm-bindgen" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 1.0.109", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" - -[[package]] -name = "wasmer" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea8d8361c9d006ea3d7797de7bd6b1492ffd0f91a22430cfda6c1658ad57bedf" -dependencies = [ - "cfg-if", - "indexmap", - "js-sys", - "loupe", - "more-asserts", - "target-lexicon", - "thiserror", - "wasm-bindgen", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-compiler-cranelift", - "wasmer-compiler-singlepass", - "wasmer-derive", - "wasmer-engine", - "wasmer-engine-dylib", - "wasmer-engine-universal", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-artifact" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aaf9428c29c1d8ad2ac0e45889ba8a568a835e33fd058964e5e500f2f7ce325" -dependencies = [ - "enumset", - "loupe", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-compiler" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67a6cd866aed456656db2cfea96c18baabbd33f676578482b85c51e1ee19d2c" -dependencies = [ - "enumset", - "loupe", - "rkyv", - "serde", - "serde_bytes", - "smallvec", - "target-lexicon", - "thiserror", - "wasmer-types", - "wasmparser", -] - -[[package]] -name = "wasmer-compiler-cranelift" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48be2f9f6495f08649e4f8b946a2cbbe119faf5a654aa1457f9504a99d23dae0" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "gimli 0.26.2", - "loupe", - "more-asserts", - "rayon", - "smallvec", - "target-lexicon", - "tracing", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-compiler-singlepass" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ca2a35204d8befa85062bc7aac259a8db8070b801b8a783770ba58231d729e" -dependencies = [ - "byteorder", - "dynasm", - "dynasmrt", - "gimli 0.26.2", - "lazy_static", - "loupe", - "more-asserts", - "rayon", - "smallvec", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-derive" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e50405cc2a2f74ff574584710a5f2c1d5c93744acce2ca0866084739284b51" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "wasmer-engine" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f98f010978c244db431b392aeab0661df7ea0822343334f8f2a920763548e45" -dependencies = [ - "backtrace", - "enumset", - "lazy_static", - "loupe", - "memmap2", - "more-asserts", - "rustc-demangle", - "serde", - "serde_bytes", - "target-lexicon", - "thiserror", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-engine-dylib" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0358af9c154724587731175553805648d9acb8f6657880d165e378672b7e53" -dependencies = [ - "cfg-if", - "enum-iterator", - "enumset", - "leb128", - "libloading", - "loupe", - "object 0.28.4", - "rkyv", - "serde", - "tempfile", - "tracing", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-engine", - "wasmer-object", - "wasmer-types", - "wasmer-vm", - "which", -] - -[[package]] -name = "wasmer-engine-universal" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440dc3d93c9ca47865a4f4edd037ea81bf983b5796b59b3d712d844b32dbef15" -dependencies = [ - "cfg-if", - "enumset", - "leb128", - "loupe", - "region", - "rkyv", - "wasmer-compiler", - "wasmer-engine", - "wasmer-engine-universal-artifact", - "wasmer-types", - "wasmer-vm", - "winapi", -] - -[[package]] -name = "wasmer-engine-universal-artifact" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f1db3f54152657eb6e86c44b66525ff7801dad8328fe677da48dd06af9ad41" -dependencies = [ - "enum-iterator", - "enumset", - "loupe", - "rkyv", - "thiserror", - "wasmer-artifact", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-middlewares" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7812438ed2f37203a37007cdb5332b8475cb2b16e15d51299b2647894e9ed3a" -dependencies = [ - "loupe", - "wasmer", - "wasmer-types", - "wasmer-vm", -] - -[[package]] -name = "wasmer-object" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d831335ff3a44ecf451303f6f891175c642488036b92ceceb24ac8623a8fa8b" -dependencies = [ - "object 0.28.4", - "thiserror", - "wasmer-compiler", - "wasmer-types", -] - -[[package]] -name = "wasmer-types" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39df01ea05dc0a9bab67e054c7cb01521e53b35a7bb90bd02eca564ed0b2667f" -dependencies = [ - "backtrace", - "enum-iterator", - "indexmap", - "loupe", - "more-asserts", - "rkyv", - "serde", - "thiserror", -] - -[[package]] -name = "wasmer-vm" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d965fa61f4dc4cdb35a54daaf7ecec3563fbb94154a6c35433f879466247dd" -dependencies = [ - "backtrace", - "cc", - "cfg-if", - "corosensei", - "enum-iterator", - "indexmap", - "lazy_static", - "libc", - "loupe", - "mach", - "memoffset 0.6.5", - "more-asserts", - "region", - "rkyv", - "scopeguard", - "serde", - "thiserror", - "wasmer-artifact", - "wasmer-types", - "winapi", -] - -[[package]] -name = "wasmparser" -version = "0.83.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" - -[[package]] -name = "which" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" -dependencies = [ - "either", - "libc", - "once_cell", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43dbb096663629518eb1dfa72d80243ca5a6aca764cae62a2df70af760a9be75" -dependencies = [ - "windows_aarch64_msvc 0.33.0", - "windows_i686_gnu 0.33.0", - "windows_i686_msvc 0.33.0", - "windows_x86_64_gnu 0.33.0", - "windows_x86_64_msvc 0.33.0", -] - -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-targets" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" -dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" - [[package]] name = "zeroize" version = "1.5.7" diff --git a/Cargo.toml b/Cargo.toml index 20494aea..1f043b08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] -members = ["contracts/*", "packages/*"] +members = ["contracts/token", "contracts/hub", "contracts/hub-tf", "packages/*"] +resolver = '1' [profile.release.package.pfc-steak] opt-level = 3 @@ -9,6 +10,12 @@ codegen-units = 1 incremental = false [profile.release] +opt-level = 3 +debug = false rpath = false lto = true +debug-assertions = false +codegen-units = 1 +panic = 'abort' +incremental = false overflow-checks = true diff --git a/contracts/hub-tf/Cargo.toml b/contracts/hub-tf/Cargo.toml index f5d5369b..4b068fa1 100644 --- a/contracts/hub-tf/Cargo.toml +++ b/contracts/hub-tf/Cargo.toml @@ -14,7 +14,7 @@ backtraces = ["cosmwasm-std/backtraces"] [dependencies] #cosmwasm-std = { version = "1.2.1", features=["iterator","stargate","cosmwasm_1_1","staking"]} -cosmwasm-std = { version = "1.2.1", features=["iterator","stargate","staking"]} +cosmwasm-std = { version = "1.0.1", features=["iterator","stargate","staking"]} cw2= "1.0.1" #cw20 = "1.0.0" @@ -29,6 +29,7 @@ pfc-steak = { path = "../../packages/steak" } serde = { version = "1.0.103", default-features = false, features = ["derive"] } pfc-fee-split = "0.2.5" pfc-dust-collector="0.1.0" -#kujira = "0.7.25" +#{ path="../../packages/pfc-dust-collector" } osmosis-std-derive="0.13.2" +[dev-dependencies] protobuf = { version = "3.1.0", features = ["with-bytes"] } \ No newline at end of file diff --git a/contracts/hub-tf/src/contract.rs b/contracts/hub-tf/src/contract.rs index 8b47d083..06d94c61 100644 --- a/contracts/hub-tf/src/contract.rs +++ b/contracts/hub-tf/src/contract.rs @@ -1,11 +1,15 @@ -use cosmwasm_std::{Binary, Deps, DepsMut, entry_point, Env, MessageInfo, Reply, Response, StdError, StdResult, to_binary}; -use cw2::{ContractVersion, get_contract_version, set_contract_version}; +use cosmwasm_std::{ + entry_point, to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, + StdResult, +}; +use cw2::{get_contract_version, set_contract_version, ContractVersion}; +use std::convert::TryInto; use pfc_steak::hub::{CallbackMsg, MigrateMsg, QueryMsg}; use pfc_steak::hub_tf::{ExecuteMsg, InstantiateMsg, TokenFactoryType}; -use crate::{execute, queries}; use crate::state::State; +use crate::{execute, queries}; //use crate::helpers::{ unwrap_reply}; @@ -41,6 +45,7 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S .unwrap_or(info.sender), info.funds, exec_msg, + true, ), ExecuteMsg::Unbond { receiver } => execute::queue_unbond( deps, @@ -48,7 +53,8 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S receiver .map(|s| api.addr_validate(&s)) .transpose()? - .unwrap_or(info.sender), info.funds, + .unwrap_or(info.sender), + info.funds, ), ExecuteMsg::WithdrawUnbonded { receiver } => execute::withdraw_unbonded( deps, @@ -71,9 +77,10 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S ExecuteMsg::RemoveValidatorEx { validator } => { execute::remove_validator_ex(deps, env, info.sender, validator) } - ExecuteMsg::Redelegate { validator_from,validator_to } => { - execute::redelegate(deps, env, info.sender, validator_from,validator_to) - } + ExecuteMsg::Redelegate { + validator_from, + validator_to, + } => execute::redelegate(deps, env, info.sender, validator_from, validator_to), ExecuteMsg::TransferOwnership { new_owner } => { execute::transfer_ownership(deps, info.sender, new_owner) @@ -83,9 +90,10 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S ExecuteMsg::Rebalance { minimum } => execute::rebalance(deps, env, minimum), ExecuteMsg::Reconcile {} => execute::reconcile(deps, env), ExecuteMsg::SubmitBatch {} => execute::submit_batch(deps, env), - ExecuteMsg::TransferFeeAccount { fee_account_type, new_fee_account } => { - execute::transfer_fee_account(deps, info.sender, fee_account_type, new_fee_account) - } + ExecuteMsg::TransferFeeAccount { + fee_account_type, + new_fee_account, + } => execute::transfer_fee_account(deps, info.sender, fee_account_type, new_fee_account), ExecuteMsg::UpdateFee { new_fee } => execute::update_fee(deps, info.sender, new_fee), ExecuteMsg::Callback(callback_msg) => callback(deps, env, info, callback_msg), ExecuteMsg::PauseValidator { validator } => { @@ -94,15 +102,27 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S ExecuteMsg::UnPauseValidator { validator } => { execute::unpause_validator(deps, env, info.sender, validator) } - ExecuteMsg::SetUnbondPeriod { unbond_period } => execute::set_unbond_period(deps, env, info.sender, unbond_period), + ExecuteMsg::SetUnbondPeriod { unbond_period } => { + execute::set_unbond_period(deps, env, info.sender, unbond_period) + } - ExecuteMsg::SetDustCollector { dust_collector } => { execute::set_dust_collector(deps, env, info.sender, dust_collector) } - ExecuteMsg::CollectDust { max_tokens } => { execute::collect_dust(deps, env, max_tokens) } - ExecuteMsg::ReturnDenom {} => { execute::return_denom(deps, env, info.funds) } + ExecuteMsg::SetDustCollector { dust_collector } => { + execute::set_dust_collector(deps, env, info.sender, dust_collector) + } + ExecuteMsg::CollectDust { max_tokens } => { + let max_tokens_usize_r = max_tokens.try_into(); + if let Ok(max_tokens_usize) = max_tokens_usize_r { + execute::collect_dust(deps, env, max_tokens_usize) + } else { + Err(StdError::generic_err("max_tokens too large")) + } + } + ExecuteMsg::ReturnDenom {} => { + execute::bond(deps, env, info.sender, info.funds, None, false) + } } } - fn callback( deps: DepsMut, env: Env, @@ -121,21 +141,14 @@ fn callback( } #[entry_point] -pub fn reply(deps: DepsMut, env: Env, reply: Reply) -> StdResult { +pub fn reply(_deps: DepsMut, _env: Env, reply: Reply) -> StdResult { match reply.id { - REPLY_REGISTER_RECEIVED_COINS => { - execute::collect_dust(deps, env,10) - } - _ => { - Err(StdError::generic_err(format!( - "invalid reply id: {} {:?}", - reply.id, - reply.result - )) - ) - } + REPLY_REGISTER_RECEIVED_COINS => Ok(Response::default()), + _ => Err(StdError::generic_err(format!( + "invalid reply id: {} {:?}", + reply.id, reply.result + ))), } - } #[entry_point] @@ -186,16 +199,19 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> StdResult {} "3.0.1" | "3.0.2" => { - let state = State::default(); + let state = State::default(); let kuji = state.kuji_token_factory.load(deps.storage)?; if kuji { - state.token_factory_type.save(deps.storage,&TokenFactoryType::Kujira)? + state + .token_factory_type + .save(deps.storage, &TokenFactoryType::Kujira)? } else { - state.token_factory_type.save(deps.storage,&TokenFactoryType::CosmWasm)? + state + .token_factory_type + .save(deps.storage, &TokenFactoryType::CosmWasm)? } - } - _ => {} + _ => {} }, _ => { return Err(StdError::generic_err( diff --git a/contracts/hub-tf/src/execute.rs b/contracts/hub-tf/src/execute.rs index 1561ae7c..0da980be 100644 --- a/contracts/hub-tf/src/execute.rs +++ b/contracts/hub-tf/src/execute.rs @@ -2,23 +2,27 @@ use std::collections::HashSet; use std::iter::FromIterator; use std::str::FromStr; -use cosmwasm_std::{Addr, BankMsg, Coin, CosmosMsg, Decimal, DepsMut, DistributionMsg, Env, Event, Order, Response, StdError, StdResult, SubMsg, to_binary, Uint128, WasmMsg}; - -use pfc_steak::DecimalCheckedOps; -use pfc_steak::hub::{ - Batch, CallbackMsg, FeeType, PendingBatch, UnbondRequest, +use cosmwasm_std::{ + to_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, DepsMut, DistributionMsg, Env, Event, + Order, ReplyOn, Response, StdError, StdResult, SubMsg, Uint128, WasmMsg, }; + +use pfc_steak::hub::{Batch, CallbackMsg, FeeType, PendingBatch, UnbondRequest}; use pfc_steak::hub_tf::{ExecuteMsg, InstantiateMsg, TokenFactoryType}; +use pfc_steak::DecimalCheckedOps; -use crate::{injective, token_factory}; use crate::contract::{REPLY_REGISTER_RECEIVED_COINS, SPECIAL_SEND_MESSAGE_TO_TRANSFER}; -use crate::helpers::{get_denom_balance, parse_received_fund, query_all_delegations, query_delegation, query_delegations}; +use crate::helpers::{ + get_denom_balance, parse_received_fund, query_all_delegations, query_delegation, + query_delegations, +}; use crate::kujira; use crate::math::{ compute_mint_amount, compute_redelegations_for_rebalancing, compute_redelegations_for_removal, compute_unbond_amount, compute_undelegations, reconcile_batches, }; -use crate::state::{previous_batches, State, unbond_requests, VALIDATORS, VALIDATORS_ACTIVE}; +use crate::state::{previous_batches, unbond_requests, State, VALIDATORS, VALIDATORS_ACTIVE}; +use crate::{injective, token_factory}; //use crate::token_factory::denom::{MsgBurn, MsgCreateDenom, MsgMint}; use crate::types::{Coins, Delegation, Redelegation}; @@ -64,15 +68,17 @@ pub fn instantiate(deps: DepsMut, env: Env, msg: InstantiateMsg) -> StdResult StdResult { >::into( - token_factory::denom::MsgCreateDenom { sender: env.contract.address.to_string(), subdenom: steak_denom_msg }) - } - TokenFactoryType::Kujira => { - >::into( - kujira::denom::MsgCreateDenom { sender: env.contract.address.to_string(), subdenom: steak_denom_msg }) - } - TokenFactoryType::Injective => { - >::into( - injective::denom::MsgCreateDenom { sender: env.contract.address.to_string(), subdenom: steak_denom_msg }) + token_factory::denom::MsgCreateDenom { + sender: env.contract.address.to_string(), + subdenom: steak_denom_msg, + }, + ) } + TokenFactoryType::Kujira => >::into( + kujira::denom::MsgCreateDenom { + sender: env.contract.address.to_string(), + subdenom: steak_denom_msg, + }, + ), + TokenFactoryType::Injective => >::into( + injective::denom::MsgCreateDenom { + sender: env.contract.address.to_string(), + subdenom: steak_denom_msg, + }, + ), }; Ok(Response::new().add_message(c)) } - //-------------------------------------------------------------------------------------------------- // Bonding and harvesting logics //-------------------------------------------------------------------------------------------------- @@ -115,7 +130,15 @@ pub fn instantiate(deps: DepsMut, env: Env, msg: InstantiateMsg) -> StdResult, bond_msg: Option) -> StdResult { +/// +pub fn bond( + deps: DepsMut, + env: Env, + receiver: Addr, + funds: Vec, + bond_msg: Option, + mint_steak: bool, +) -> StdResult { let state = State::default(); let denom = state.denom.load(deps.storage)?; let amount_to_bond = parse_received_fund(&funds, &denom)?; @@ -139,7 +162,12 @@ pub fn bond(deps: DepsMut, env: Env, receiver: Addr, funds: Vec, bond_msg: // Query the current delegations made to validators, and find the validator with the smallest // delegated amount through a linear search // The code for linear search is a bit uglier than using `sort_by` but cheaper: O(n) vs O(n * log(n)) - let delegations_non_active = query_delegations(&deps.querier, &non_active_validator_list, &env.contract.address, &denom)?; + let delegations_non_active = query_delegations( + &deps.querier, + &non_active_validator_list, + &env.contract.address, + &denom, + )?; let delegations = query_delegations(&deps.querier, &validators, &env.contract.address, &denom)?; let mut validator = &delegations[0].validator; @@ -155,60 +183,88 @@ pub fn bond(deps: DepsMut, env: Env, receiver: Addr, funds: Vec, bond_msg: amount: amount_to_bond.u128(), denom: denom.clone(), }; - - // Query the current supply of Steak and compute the amount to mint - // let usteak_supply = steak_minted; - let usteak_to_mint = compute_mint_amount(steak_minted, amount_to_bond, &delegations, &delegations_non_active); - state.steak_minted.save(deps.storage, &(steak_minted + usteak_to_mint))?; - // TODO deal with multiple token returns - state.prev_denom.save( - deps.storage, - &get_denom_balance(&deps.querier, env.contract.address.clone(), denom.clone())?, - )?; - - let delegate_submsg = SubMsg::reply_on_success( - new_delegation.to_cosmos_msg(), - REPLY_REGISTER_RECEIVED_COINS, - ); - - let mint_msg = match token_factory_type { - TokenFactoryType::CosmWasm => { - >::into(token_factory::denom::MsgMint { - sender: env.contract.address.to_string(), - amount: Some(token_factory::denom::Coin { - denom: steak_denom.clone(), - amount: usteak_to_mint.to_string(), - }), - }) - } - TokenFactoryType::Kujira => { - >::into(kujira::denom::MsgMint { - sender: env.contract.address.to_string(), - recipient: env.contract.address.to_string(), - amount: Some(kujira::denom::Coin { - denom: steak_denom.clone(), - amount: usteak_to_mint.to_string(), - }), - }) - } - TokenFactoryType::Injective => { - >::into(injective::denom::MsgMint { - sender: env.contract.address.to_string(), - amount: Some(injective::denom::Coin { - denom: steak_denom.clone(), - amount: usteak_to_mint.to_string(), - }), - }) - } + let delegate_submsg = SubMsg { + msg: new_delegation.to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never, }; - let contract_info = deps.querier.query_wasm_contract_info(receiver.to_string()); + if mint_steak { + // Query the current supply of Steak and compute the amount to mint + // let usteak_supply = steak_minted; + let usteak_to_mint = compute_mint_amount( + steak_minted, + amount_to_bond, + &delegations, + &delegations_non_active, + ); + state + .steak_minted + .save(deps.storage, &(steak_minted + usteak_to_mint))?; + // TODO deal with multiple token returns + state.prev_denom.save( + deps.storage, + &get_denom_balance(&deps.querier, env.contract.address.clone(), denom.clone())?, + )?; + + let mint_msg = match token_factory_type { + TokenFactoryType::CosmWasm => >::into( + token_factory::denom::MsgMint { + sender: env.contract.address.to_string(), + amount: Some(token_factory::denom::Coin { + denom: steak_denom.clone(), + amount: usteak_to_mint.to_string(), + }), + }, + ), + TokenFactoryType::Kujira => { + >::into(kujira::denom::MsgMint { + sender: env.contract.address.to_string(), + recipient: env.contract.address.to_string(), + amount: Some(kujira::denom::Coin { + denom: steak_denom.clone(), + amount: usteak_to_mint.to_string(), + }), + }) + } + TokenFactoryType::Injective => { + >::into(injective::denom::MsgMint { + sender: env.contract.address.to_string(), + amount: Some(injective::denom::Coin { + denom: steak_denom.clone(), + amount: usteak_to_mint.to_string(), + }), + }) + } + }; - // send the uSteak, optionally calling a smart contract - let send_transfer_msg: CosmosMsg = match contract_info { - Ok(_) => { - if let Some(exec_msg) = bond_msg { - if exec_msg == SPECIAL_SEND_MESSAGE_TO_TRANSFER { // this is for backwards compatibility only + let contract_info = deps.querier.query_wasm_contract_info(receiver.to_string()); + + // send the uSteak, optionally calling a smart contract + let send_transfer_msg: CosmosMsg = match contract_info { + Ok(_) => { + if let Some(exec_msg) = bond_msg { + if exec_msg == SPECIAL_SEND_MESSAGE_TO_TRANSFER { + // this is for backwards compatibility only + CosmosMsg::Bank(BankMsg::Send { + to_address: receiver.to_string(), + amount: vec![Coin { + denom: steak_denom, + amount: usteak_to_mint, + }], + }) + } else { + CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: receiver.to_string(), + msg: to_binary(&exec_msg)?, + funds: vec![Coin { + denom: steak_denom, + amount: usteak_to_mint, + }], + }) + } + } else { CosmosMsg::Bank(BankMsg::Send { to_address: receiver.to_string(), amount: vec![Coin { @@ -216,51 +272,44 @@ pub fn bond(deps: DepsMut, env: Env, receiver: Addr, funds: Vec, bond_msg: amount: usteak_to_mint, }], }) - } else { - CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: receiver.to_string(), - msg: to_binary(&exec_msg)?, - funds: vec![Coin { - denom: steak_denom, - amount: usteak_to_mint, - }], - }) } - } else { - CosmosMsg::Bank(BankMsg::Send { - to_address: receiver.to_string(), - amount: vec![Coin { - denom: steak_denom, - amount: usteak_to_mint, - }], - }) } - } - Err(_) => { - CosmosMsg::Bank(BankMsg::Send { + Err(_) => CosmosMsg::Bank(BankMsg::Send { to_address: receiver.to_string(), amount: vec![Coin { denom: steak_denom, amount: usteak_to_mint, }], - }) - } - }; + }), + }; - let event = Event::new("steakhub/bonded") - .add_attribute("time", env.block.time.seconds().to_string()) - .add_attribute("height", env.block.height.to_string()) - .add_attribute("steak_receiver", receiver) - .add_attribute("denom_bonded", denom) - .add_attribute("denom_amount", amount_to_bond) - .add_attribute("usteak_minted", usteak_to_mint); + let event = Event::new("steakhub/bonded") + .add_attribute("time", env.block.time.seconds().to_string()) + .add_attribute("height", env.block.height.to_string()) + .add_attribute("steak_receiver", receiver) + .add_attribute("denom_bonded", denom) + .add_attribute("denom_amount", amount_to_bond) + .add_attribute("usteak_minted", usteak_to_mint); - Ok(Response::new() - .add_submessage(delegate_submsg) - .add_messages(vec![mint_msg, send_transfer_msg]) - // .add_message(send_msg) - .add_event(event) - .add_attribute("action", "steakhub/bond")) + Ok(Response::new() + .add_submessage(delegate_submsg) + .add_messages(vec![mint_msg, send_transfer_msg]) + // .add_message(send_msg) + .add_event(event) + .add_attribute("action", "steakhub/bond")) + } else { + let event = Event::new("steakhub/bonded-nomint") + .add_attribute("time", env.block.time.seconds().to_string()) + .add_attribute("height", env.block.height.to_string()) + .add_attribute("from", receiver) + .add_attribute("denom_bonded", denom) + .add_attribute("denom_amount", amount_to_bond); + + Ok(Response::new() + .add_submessage(delegate_submsg) + .add_event(event) + .add_attribute("action", "steakhub/bond-nomint")) + } } pub fn harvest(deps: DepsMut, env: Env) -> StdResult { @@ -275,13 +324,13 @@ pub fn harvest(deps: DepsMut, env: Env) -> StdResult { .querier .query_all_delegations(&env.contract.address)? .into_iter() - .map(|d| { - SubMsg::reply_on_success( - CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { - validator: d.validator, - }), - REPLY_REGISTER_RECEIVED_COINS, - ) + .map(|d| SubMsg { + id: REPLY_REGISTER_RECEIVED_COINS, + msg: CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { + validator: d.validator, + }), + gas_limit: None, + reply_on: ReplyOn::Never, }) .collect::>(); @@ -362,11 +411,10 @@ pub fn reinvest(deps: DepsMut, env: Env) -> StdResult { let fee_type = state.fee_account_type.load(deps.storage)?; let send_msgs = match fee_type { - FeeType::Wallet => - vec![CosmosMsg::Bank(BankMsg::Send { - to_address: fee_account.to_string(), - amount: vec![Coin::new(fee_amount.into(), &denom)], - })], + FeeType::Wallet => vec![CosmosMsg::Bank(BankMsg::Send { + to_address: fee_account.to_string(), + amount: vec![Coin::new(fee_amount.into(), &denom)], + })], FeeType::FeeSplit => { let msg = pfc_fee_split::fee_split_msg::ExecuteMsg::Deposit { flush: false }; @@ -451,7 +499,11 @@ pub fn queue_unbond( let state = State::default(); let steak_denom = state.steak_denom.load(deps.storage)?; - let usteak_to_burn = funds.iter().filter(|p| p.denom == steak_denom).map(|steak_funds| steak_funds.amount).sum::(); + let usteak_to_burn = funds + .iter() + .filter(|p| p.denom == steak_denom) + .map(|steak_funds| steak_funds.amount) + .sum::(); if funds.len() != 1 || usteak_to_burn.is_zero() { return Err(StdError::generic_err(format!( "you can only send {} tokens to unbond", @@ -531,11 +583,20 @@ pub fn submit_batch(deps: DepsMut, env: Env) -> StdResult { // for unbonding we still need to look at // TODO verify denom let delegations = query_all_delegations(&deps.querier, &env.contract.address)?; - let delegations_active = query_delegations(&deps.querier, &active_validator_list, &env.contract.address, &denom)?; + let delegations_active = query_delegations( + &deps.querier, + &active_validator_list, + &env.contract.address, + &denom, + )?; // let usteak_supply = query_cw20_total_supply(&deps.querier, &steak_token)?; - let amount_to_unbond = - compute_unbond_amount(usteak_supply, pending_batch.usteak_to_burn, &delegations, &delegations_active); + let amount_to_unbond = compute_unbond_amount( + usteak_supply, + pending_batch.usteak_to_burn, + &delegations, + &delegations_active, + ); let new_undelegations = compute_undelegations(amount_to_unbond, &delegations, &denom); @@ -576,28 +637,34 @@ pub fn submit_batch(deps: DepsMut, env: Env) -> StdResult { let undelegate_submsgs = new_undelegations .iter() - .map(|d| SubMsg::reply_on_success(d.to_cosmos_msg(), REPLY_REGISTER_RECEIVED_COINS)) + .map(|d| SubMsg { + id: REPLY_REGISTER_RECEIVED_COINS, + msg: d.to_cosmos_msg(), + gas_limit: None, + reply_on: ReplyOn::Never, + }) .collect::>(); - let burn_msg = match token_factory_type { - TokenFactoryType::Kujira => + TokenFactoryType::Kujira => { >::into(kujira::denom::MsgBurn { sender: env.contract.address.to_string(), amount: Some(kujira::denom::Coin { denom: steak_denom, amount: pending_batch.usteak_to_burn.to_string(), }), - }), - TokenFactoryType::CosmWasm => - >::into(token_factory::denom::MsgBurn { + }) + } + TokenFactoryType::CosmWasm => >::into( + token_factory::denom::MsgBurn { sender: env.contract.address.to_string(), amount: Some(token_factory::denom::Coin { denom: steak_denom, amount: pending_batch.usteak_to_burn.to_string(), }), - }), - TokenFactoryType::Injective => + }, + ), + TokenFactoryType::Injective => { >::into(injective::denom::MsgBurn { sender: env.contract.address.to_string(), amount: Some(injective::denom::Coin { @@ -605,10 +672,13 @@ pub fn submit_batch(deps: DepsMut, env: Env) -> StdResult { amount: pending_batch.usteak_to_burn.to_string(), }), }) + } }; // yes.. this will fail if supply is less than the amount to burn. this is intentional. - state.steak_minted.save(deps.storage, &(usteak_supply - pending_batch.usteak_to_burn))?; - + state.steak_minted.save( + deps.storage, + &(usteak_supply - pending_batch.usteak_to_burn), + )?; let event = Event::new("steakhub/unbond_submitted") .add_attribute("time", env.block.time.seconds().to_string()) @@ -745,11 +815,9 @@ pub fn withdraw_unbonded( if batch.total_shares.is_zero() { previous_batches().remove(deps.storage, request.id)?; } else { - previous_batches() - .save(deps.storage, batch.id, &batch)?; + previous_batches().save(deps.storage, batch.id, &batch)?; } - unbond_requests() - .remove(deps.storage, (request.id, user.as_ref()))?; + unbond_requests().remove(deps.storage, (request.id, user.as_ref()))?; } } } @@ -805,7 +873,12 @@ pub fn rebalance(deps: DepsMut, env: Env, minimum: Uint128) -> StdResult>(); let amount: u128 = new_redelegations.iter().map(|rd| rd.amount).sum(); @@ -871,7 +944,12 @@ pub fn remove_validator( let redelegate_submsgs = new_redelegations .iter() - .map(|d| SubMsg::reply_on_success(d.to_cosmos_msg(), REPLY_REGISTER_RECEIVED_COINS)) + .map(|d| SubMsg { + id: REPLY_REGISTER_RECEIVED_COINS, + msg: d.to_cosmos_msg(), + gas_limit: None, + reply_on: ReplyOn::Never, + }) .collect::>(); let event = Event::new("steak/validator_removed").add_attribute("validator", validator); @@ -899,7 +977,6 @@ pub fn remove_validator_ex( } VALIDATORS.remove(deps.storage, &validator)?; - let event = Event::new("steak/validator_removed_ex").add_attribute("validator", validator); Ok(Response::new() @@ -1054,39 +1131,50 @@ pub fn set_dust_collector( ) -> StdResult { let state = State::default(); - state.assert_owner(deps.storage, &sender)?; if let Some(ref dust_addr) = dust_collector { - state.dust_collector.save(deps.storage, &Some(deps.api.addr_validate(dust_addr)?))?; + state + .dust_collector + .save(deps.storage, &Some(deps.api.addr_validate(dust_addr)?))?; } else { state.dust_collector.save(deps.storage, &None)?; }; - let event = Event::new("steak/set_dust_collector") - .add_attribute("dust_collector", dust_collector.unwrap_or("-cleared-".into())); + let event = Event::new("steak/set_dust_collector").add_attribute( + "dust_collector", + dust_collector.unwrap_or("-cleared-".into()), + ); Ok(Response::new() .add_event(event) .add_attribute("action", "steakhub/set_dust_collector")) } -pub fn collect_dust(deps: DepsMut, _env: Env, max_tokens: u64) -> StdResult { +pub fn collect_dust(deps: DepsMut, env: Env, max_tokens: usize) -> StdResult { let state = State::default(); - - if let Some(_dust_addr) = state.dust_collector.load(deps.storage)? { - Ok(Response::new().add_attribute("dust", "tbd")) - } else { - Ok(Response::new().add_attribute("dust", "dust-collector-called")) + let denom = state.denom.load(deps.storage)?; + let steak_denom = state.steak_denom.load(deps.storage)?; + let balances = deps.querier.query_all_balances(env.contract.address)?; + let balances_filtered = balances + .into_iter() + .filter(|p| !(p.denom == denom || p.denom == steak_denom)) + .take(max_tokens) + .collect::>(); + if balances_filtered.is_empty() { + return Ok(Response::new().add_attribute("dust", "no-dust")); } -} - -pub fn return_denom(deps: DepsMut, _env: Env, _funds: Vec) -> StdResult { - let state = State::default(); - - if let Some(_dust_addr) = state.dust_collector.load(deps.storage)? { - Ok(Response::new().add_attribute("dust", "returned")) + if let Some(dust_addr) = state.dust_collector.load(deps.storage)? { + let balances_count = balances_filtered.len(); + let msg = CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: dust_addr.to_string(), + funds: balances_filtered, + msg: to_binary(&pfc_dust_collector::dust_collector::ExecuteMsg::DustReceived {})?, + }); + Ok(Response::new() + .add_attribute("dust", format!("sent {} tokens", balances_count)) + .add_message(msg)) } else { - Err(StdError::generic_err("No Dust collector set")) + Ok(Response::new().add_attribute("dust", "dust-collector-called")) } } @@ -1102,21 +1190,26 @@ pub fn redelegate( state.assert_owner(deps.storage, &sender)?; let denom = state.denom.load(deps.storage)?; - let delegation = query_delegation(&deps.querier, &validator_from, &env.contract.address, &denom)?; - - let redelegation_msg = SubMsg::reply_on_success(Redelegation::new( + let delegation = query_delegation( + &deps.querier, &validator_from, - &validator_to, - delegation.amount, + &env.contract.address, &denom, - ).to_cosmos_msg(), REPLY_REGISTER_RECEIVED_COINS); + )?; + + let redelegation_msg = SubMsg { + id: REPLY_REGISTER_RECEIVED_COINS, + msg: Redelegation::new(&validator_from, &validator_to, delegation.amount, &denom) + .to_cosmos_msg(), + gas_limit: None, + reply_on: ReplyOn::Never, + }; state.prev_denom.save( deps.storage, &get_denom_balance(&deps.querier, env.contract.address, denom)?, )?; - let event = Event::new("steak/redelegate") .add_attribute("validator_from", validator_from) .add_attribute("validator_to", validator_to) @@ -1126,4 +1219,4 @@ pub fn redelegate( .add_submessage(redelegation_msg) .add_event(event) .add_attribute("action", "steakhub/redelegate")) -} \ No newline at end of file +} diff --git a/contracts/hub-tf/src/testing/tests.rs b/contracts/hub-tf/src/testing/tests.rs index f838f887..9ebc0fda 100644 --- a/contracts/hub-tf/src/testing/tests.rs +++ b/contracts/hub-tf/src/testing/tests.rs @@ -1,21 +1,23 @@ use std::str::FromStr; -use cosmwasm_std::{Addr, BankMsg, Coin, CosmosMsg, Decimal, DistributionMsg, Order, OwnedDeps, ReplyOn, StdError, SubMsg, to_binary, Uint128, WasmMsg}; -use cosmwasm_std::testing::{MOCK_CONTRACT_ADDR, mock_env, mock_info, MockApi, MockStorage}; +use cosmwasm_std::testing::{mock_env, mock_info, MockApi, MockStorage, MOCK_CONTRACT_ADDR}; +use cosmwasm_std::{ + to_binary, Addr, BankMsg, Coin, CosmosMsg, Decimal, DistributionMsg, Order, OwnedDeps, ReplyOn, + StdError, SubMsg, Uint128, WasmMsg, +}; use pfc_steak::hub::{ - Batch, CallbackMsg, ConfigResponse, PendingBatch, QueryMsg, - StateResponse, UnbondRequest, UnbondRequestsByBatchResponseItem, - UnbondRequestsByUserResponseItem, + Batch, CallbackMsg, ConfigResponse, PendingBatch, QueryMsg, StateResponse, UnbondRequest, + UnbondRequestsByBatchResponseItem, UnbondRequestsByUserResponseItem, }; use pfc_steak::hub_tf::{ExecuteMsg, InstantiateMsg}; -use crate::contract::{execute, instantiate, REPLY_REGISTER_RECEIVED_COINS}; +use crate::contract::{execute, instantiate, REPLY_REGISTER_RECEIVED_COINS}; use crate::helpers::{parse_coin, parse_received_fund}; use crate::math::{ compute_redelegations_for_rebalancing, compute_redelegations_for_removal, compute_undelegations, }; -use crate::state::{previous_batches, State, unbond_requests, VALIDATORS}; +use crate::state::{previous_batches, unbond_requests, State, VALIDATORS}; use crate::token_factory::denom; use crate::token_factory::denom::{MsgBurn, MsgCreateDenom, MsgMint}; use crate::types::{Coins, Delegation, Redelegation, Undelegation}; @@ -51,15 +53,16 @@ fn setup_test() -> OwnedDeps { "charlie".to_string(), ], token_factory: "CosmWasm".to_string(), - dust_collector: Some("dusty_1".to_string()) + dust_collector: Some("dusty_1".to_string()), }, ) - .unwrap(); - + .unwrap(); assert_eq!(res.messages.len(), 1); - let c = >::into( - MsgCreateDenom { sender: "cosmos2contract".to_string(), subdenom: "boneXYZ".to_string() }); + let c = >::into(MsgCreateDenom { + sender: "cosmos2contract".to_string(), + subdenom: "boneXYZ".to_string(), + }); assert_eq!(res.messages[0], SubMsg::new(c)); deps @@ -80,8 +83,8 @@ fn setup_test_fee_split() -> OwnedDeps { fee_account: "fee_split_contract".to_string(), fee_amount: Decimal::from_ratio(10_u128, 100_u128), //10% max_fee_amount: Decimal::from_ratio(20_u128, 100_u128), //20% - epoch_period: 259200, // 3 * 24 * 60 * 60 = 3 days - unbond_period: 1814400, // 21 * 24 * 60 * 60 = 21 days + epoch_period: 259200, // 3 * 24 * 60 * 60 = 3 days + unbond_period: 1814400, // 21 * 24 * 60 * 60 = 21 days validators: vec![ "alice".to_string(), "bob".to_string(), @@ -89,14 +92,16 @@ fn setup_test_fee_split() -> OwnedDeps { ], token_factory: "CosmWasm".to_string(), - dust_collector: Some("dusty_2".to_string()) + dust_collector: Some("dusty_2".to_string()), }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 1); - let c = >::into( - MsgCreateDenom { sender: "cosmos2contract".to_string(), subdenom: "sXYZ".to_string() }); + let c = >::into(MsgCreateDenom { + sender: "cosmos2contract".to_string(), + subdenom: "sXYZ".to_string(), + }); assert_eq!(res.messages[0], SubMsg::new(c)); deps @@ -130,7 +135,7 @@ fn proper_instantiation() { "charlie".to_string(), ], paused_validators: vec![], - dust_collector:Some("dusty_1".to_string()), + dust_collector: Some("dusty_1".to_string()), token_factory: Some("CosmWasm".to_string()) } ); @@ -193,9 +198,12 @@ fn bonding() { deps.as_mut(), mock_env(), mock_info("user_1", &[Coin::new(1_000_000, "uxyz")]), - ExecuteMsg::Bond { receiver: None, exec_msg: None }, + ExecuteMsg::Bond { + receiver: None, + exec_msg: None, + }, ) - .unwrap(); + .unwrap(); // 3 messages. (switched to 3 so we can 'send' instead of 'transfer' minted tokens, so contract will know about it // 1 - delegate @@ -204,7 +212,12 @@ fn bonding() { assert_eq!(res.messages.len(), 3); assert_eq!( res.messages[0], - SubMsg::reply_on_success(Delegation::new("alice", 1_000_000, "uxyz").to_cosmos_msg(), REPLY_REGISTER_RECEIVED_COINS) + SubMsg { + msg: Delegation::new("alice", 1_000_000, "uxyz").to_cosmos_msg(), + gas_limit: None, + id: REPLY_REGISTER_RECEIVED_COINS, + reply_on: ReplyOn::Never, + } ); let mint_msg = >::into(MsgMint { sender: "cosmos2contract".to_string(), @@ -229,14 +242,16 @@ fn bonding() { id: 0, msg: CosmosMsg::Bank(BankMsg::Send { to_address: "user_1".to_string(), - amount: vec![Coin { denom: "factory/cosmos2contract/boneXYZ".to_string(), amount: Uint128::new(1_000_000) }], + amount: vec![Coin { + denom: "factory/cosmos2contract/boneXYZ".to_string(), + amount: Uint128::new(1_000_000) + }], }), gas_limit: None, reply_on: ReplyOn::Never, } ); - // Bond when there are existing delegations, and Luna:Steak exchange rate is >1 // Previously user 1 delegated 1,000,000 uluna. We assume we have accumulated 2.5% yield at 1025000 staked deps.querier.set_staking_delegations(&[ @@ -255,12 +270,17 @@ fn bonding() { exec_msg: None, }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 3); assert_eq!( res.messages[0], - SubMsg::reply_on_success(Delegation::new("charlie", 12345, "uxyz").to_cosmos_msg(), REPLY_REGISTER_RECEIVED_COINS) + SubMsg { + msg: Delegation::new("charlie", 12345, "uxyz").to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + } ); let mint_msg = >::into(MsgMint { sender: "cosmos2contract".to_string(), @@ -286,7 +306,10 @@ fn bonding() { msg: CosmosMsg::Bank(BankMsg::Send { to_address: "user_3".to_string(), - amount: vec![Coin { denom: "factory/cosmos2contract/boneXYZ".to_string(), amount: Uint128::new(12_043) }], + amount: vec![Coin { + denom: "factory/cosmos2contract/boneXYZ".to_string(), + amount: Uint128::new(12_043) + }], }), gas_limit: None, reply_on: ReplyOn::Never, @@ -323,42 +346,47 @@ fn harvesting() { Delegation::new("charlie", 341666, "uxyz"), ]); - let res = execute( deps.as_mut(), mock_env(), mock_info("worker", &[]), ExecuteMsg::Harvest {}, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 4); assert_eq!( res.messages[0], - SubMsg::reply_on_success( - CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { + SubMsg { + msg: CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { validator: "alice".to_string(), }), - REPLY_REGISTER_RECEIVED_COINS, - ) + gas_limit: None, + id: REPLY_REGISTER_RECEIVED_COINS, + reply_on: ReplyOn::Never, + } ); assert_eq!( res.messages[1], - SubMsg::reply_on_success( - CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { + SubMsg { + msg: CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { validator: "bob".to_string(), }), - REPLY_REGISTER_RECEIVED_COINS, - ) + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + } ); assert_eq!( res.messages[2], - SubMsg::reply_on_success( - CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { + SubMsg { + msg: CosmosMsg::Distribution(DistributionMsg::WithdrawDelegatorReward { validator: "charlie".to_string(), }), - REPLY_REGISTER_RECEIVED_COINS, - ) + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + } ); assert_eq!( res.messages[3], @@ -375,7 +403,6 @@ fn harvesting() { ); } - #[test] fn reinvesting() { let mut deps = setup_test(); @@ -386,8 +413,12 @@ fn reinvesting() { Delegation::new("bob", 333333, "uxyz"), Delegation::new("charlie", 333333, "uxyz"), ]); - state.prev_denom.save(deps.as_mut().storage, &Uint128::from(0 as u32)).unwrap(); - deps.querier.set_bank_balances(&[Coin::new(234u128, "uxyz")]); + state + .prev_denom + .save(deps.as_mut().storage, &Uint128::from(0 as u32)) + .unwrap(); + deps.querier + .set_bank_balances(&[Coin::new(234u128, "uxyz")]); // After the swaps, `unlocked_coins` should contain only uxyz and unknown denoms state @@ -411,7 +442,7 @@ fn reinvesting() { mock_info(MOCK_CONTRACT_ADDR, &[]), ExecuteMsg::Callback(CallbackMsg::Reinvest {}), ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 2); assert_eq!( @@ -458,8 +489,12 @@ fn reinvesting_fee_split() { Delegation::new("bob", 333333, "uxyz"), Delegation::new("charlie", 333333, "uxyz"), ]); - state.prev_denom.save(deps.as_mut().storage, &Uint128::from(0 as u32)).unwrap(); - deps.querier.set_bank_balances(&[Coin::new(234u128, "uxyz")]); + state + .prev_denom + .save(deps.as_mut().storage, &Uint128::from(0 as u32)) + .unwrap(); + deps.querier + .set_bank_balances(&[Coin::new(234u128, "uxyz")]); // After the swaps, `unlocked_coins` should contain only uxyz and unknown denoms state @@ -483,7 +518,7 @@ fn reinvesting_fee_split() { mock_info(MOCK_CONTRACT_ADDR, &[]), ExecuteMsg::Callback(CallbackMsg::Reinvest {}), ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 2); assert_eq!( @@ -501,7 +536,9 @@ fn reinvesting_fee_split() { res.messages[1], SubMsg { id: 0, - msg: send_msg.into_cosmos_msg("fee_split_contract", vec![Coin::new(23u128, "uxyz")]).unwrap(), + msg: send_msg + .into_cosmos_msg("fee_split_contract", vec![Coin::new(23u128, "uxyz")]) + .unwrap(), gas_limit: None, reply_on: ReplyOn::Never, } @@ -527,10 +564,16 @@ fn queuing_unbond() { let err = execute( deps.as_mut(), mock_env(), - mock_info("random_token", &[Coin { denom: "asldkj".into(), amount: Uint128::new(69_420) }]), + mock_info( + "random_token", + &[Coin { + denom: "asldkj".into(), + amount: Uint128::new(69_420), + }], + ), ExecuteMsg::Unbond { receiver: None }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -542,12 +585,18 @@ fn queuing_unbond() { let res = execute( deps.as_mut(), mock_env_at_timestamp(12345), // est_unbond_start_time = 269200 - mock_info("steak_token", &[Coin { denom: "factory/cosmos2contract/boneXYZ".into(), amount: Uint128::new(23_456) }]), + mock_info( + "steak_token", + &[Coin { + denom: "factory/cosmos2contract/boneXYZ".into(), + amount: Uint128::new(23_456), + }], + ), ExecuteMsg::Unbond { receiver: Some("user_1".to_string()), }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 0); @@ -556,10 +605,16 @@ fn queuing_unbond() { let res = execute( deps.as_mut(), mock_env_at_timestamp(269201), // est_unbond_start_time = 269200 - mock_info("user_3", &[Coin { denom: "factory/cosmos2contract/boneXYZ".into(), amount: Uint128::new(69_420) }]), + mock_info( + "user_3", + &[Coin { + denom: "factory/cosmos2contract/boneXYZ".into(), + amount: Uint128::new(69_420), + }], + ), ExecuteMsg::Unbond { receiver: None }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 1); assert_eq!( @@ -632,8 +687,10 @@ fn submitting_batch() { Delegation::new("bob", 345_782, "uxyz"), Delegation::new("charlie", 345_781, "uxyz"), ]); - state.steak_minted.save(deps.as_mut().storage, &Uint128::new(1_012_043)).unwrap(); - + state + .steak_minted + .save(deps.as_mut().storage, &Uint128::new(1_012_043)) + .unwrap(); // We continue from the contract state at the end of the last test let unbond_reqs = vec![ @@ -691,23 +748,35 @@ fn submitting_batch() { mock_info(MOCK_CONTRACT_ADDR, &[]), ExecuteMsg::SubmitBatch {}, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 4); assert_eq!( res.messages[0], - SubMsg::reply_on_success(Undelegation::new("alice", 31732, "uxyz").to_cosmos_msg(), REPLY_REGISTER_RECEIVED_COINS) + SubMsg { + msg: Undelegation::new("alice", 31732, "uxyz").to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + } ); assert_eq!( res.messages[1], - SubMsg::reply_on_success(Undelegation::new("bob", 31733, "uxyz").to_cosmos_msg(), REPLY_REGISTER_RECEIVED_COINS) + SubMsg { + msg: Undelegation::new("bob", 31733, "uxyz").to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + } ); assert_eq!( res.messages[2], - SubMsg::reply_on_success( - Undelegation::new("charlie", 31732, "uxyz").to_cosmos_msg(), - REPLY_REGISTER_RECEIVED_COINS, - ) + SubMsg { + msg: Undelegation::new("charlie", 31732, "uxyz").to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + } ); let burn_msg = >::into(MsgBurn { @@ -719,8 +788,7 @@ fn submitting_batch() { }); assert_eq!( res.messages[3], - - SubMsg { + SubMsg { id: 0, msg: burn_msg, gas_limit: None, @@ -833,7 +901,7 @@ fn reconciling() { mock_info("worker", &[]), ExecuteMsg::Reconcile {}, ) - .unwrap(); + .unwrap(); // Expected received: batch 2 + batch 3 = 1385 + 1506 = 2891 // Expected unlocked: 10000 @@ -995,7 +1063,7 @@ fn withdrawing_unbonded() { mock_info("user_1", &[]), ExecuteMsg::WithdrawUnbonded { receiver: None }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!(err, StdError::generic_err("withdrawable amount is zero")); @@ -1016,7 +1084,7 @@ fn withdrawing_unbonded() { mock_info("user_1", &[]), ExecuteMsg::WithdrawUnbonded { receiver: None }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 1); assert_eq!( @@ -1093,7 +1161,7 @@ fn withdrawing_unbonded() { receiver: Some("user_2".to_string()), }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 1); assert_eq!( @@ -1148,7 +1216,7 @@ fn adding_validator() { validator: "dave".to_string(), }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -1163,7 +1231,7 @@ fn adding_validator() { validator: "alice".to_string(), }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -1178,7 +1246,7 @@ fn adding_validator() { validator: "dave".to_string(), }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 0); @@ -1208,7 +1276,7 @@ fn removing_validator() { validator: "charlie".to_string(), }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -1223,7 +1291,7 @@ fn removing_validator() { validator: "dave".to_string(), }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -1242,22 +1310,26 @@ fn removing_validator() { validator: "charlie".to_string(), }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 2); assert_eq!( res.messages[0], - SubMsg::reply_on_success( - Redelegation::new("charlie", "alice", 170833, "uxyz").to_cosmos_msg(), - REPLY_REGISTER_RECEIVED_COINS, - ), + SubMsg { + msg: Redelegation::new("charlie", "alice", 170833, "uxyz").to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + }, ); assert_eq!( res.messages[1], - SubMsg::reply_on_success( - Redelegation::new("charlie", "bob", 170833, "uxyz").to_cosmos_msg(), - REPLY_REGISTER_RECEIVED_COINS, - ), + SubMsg { + msg: Redelegation::new("charlie", "bob", 170833, "uxyz").to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + }, ); assert!(VALIDATORS.contains(deps.as_ref().storage, "alice")); @@ -1278,7 +1350,7 @@ fn transferring_ownership() { new_owner: "jake".to_string(), }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -1293,7 +1365,7 @@ fn transferring_ownership() { new_owner: "jake".to_string(), }, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 0); @@ -1306,7 +1378,7 @@ fn transferring_ownership() { mock_info("pumpkin", &[]), ExecuteMsg::AcceptOwnership {}, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -1319,7 +1391,7 @@ fn transferring_ownership() { mock_info("jake", &[]), ExecuteMsg::AcceptOwnership {}, ) - .unwrap(); + .unwrap(); assert_eq!(res.messages.len(), 0); @@ -1331,7 +1403,6 @@ fn transferring_ownership() { fn splitting_fees() { let mut deps = setup_test(); - let err = execute( deps.as_mut(), mock_env(), @@ -1341,7 +1412,7 @@ fn splitting_fees() { new_fee_account: "charlie".to_string(), }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -1357,7 +1428,7 @@ fn splitting_fees() { new_fee_account: "charlie".to_string(), }, ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, @@ -1373,7 +1444,7 @@ fn splitting_fees() { new_fee_account: "charlie".to_string(), }, ) - .unwrap(); + .unwrap(); let res: ConfigResponse = query_helper(deps.as_ref(), QueryMsg::Config {}); assert_eq!( res, @@ -1394,12 +1465,11 @@ fn splitting_fees() { "charlie".to_string(), ], paused_validators: vec![], - dust_collector:Some("dusty_1".to_string()), + dust_collector: Some("dusty_1".to_string()), token_factory: Some("CosmWasm".to_string()) } ); - execute( deps.as_mut(), mock_env(), @@ -1409,7 +1479,7 @@ fn splitting_fees() { new_fee_account: "contract".to_string(), }, ) - .unwrap(); + .unwrap(); let res: ConfigResponse = query_helper(deps.as_ref(), QueryMsg::Config {}); assert_eq!( res, @@ -1625,17 +1695,14 @@ fn querying_unbond_requests() { ); assert_eq!( res, - vec![ - unbond_reqs[0].clone().into(), - unbond_reqs[3].clone().into(), - ] + vec![unbond_reqs[0].clone().into(), unbond_reqs[3].clone().into(),] ); /* - for x in unbond_requests().range(deps.as_ref().storage, None, None, Order::Ascending) { - let rec = x.unwrap(); - eprintln!("Key {}/{} = {:?}", rec.0.0, rec.0.1, rec.1) - } -*/ + for x in unbond_requests().range(deps.as_ref().storage, None, None, Order::Ascending) { + let rec = x.unwrap(); + eprintln!("Key {}/{} = {:?}", rec.0.0, rec.0.1, rec.1) + } + */ let res: Vec = query_helper( deps.as_ref(), QueryMsg::UnbondRequestsByUser { @@ -1713,9 +1780,13 @@ fn computing_redelegations_for_rebalancing() { Delegation::new("dave", 40471, "uxyz"), Delegation::new("evan", 2345, "uxyz"), ]; - let active_validators: Vec = vec!["alice".to_string(), "bob".to_string(), - "charlie".to_string(), "dave".to_string(), - "evan".to_string()]; + let active_validators: Vec = vec![ + "alice".to_string(), + "bob".to_string(), + "charlie".to_string(), + "dave".to_string(), + "evan".to_string(), + ]; // uluna_per_validator = (69420 + 88888 + 1234 + 40471 + 2345) / 4 = 40471 // remainer = 3 // src_delegations: @@ -1747,15 +1818,20 @@ fn computing_redelegations_for_rebalancing() { ]; assert_eq!( - compute_redelegations_for_rebalancing(active_validators, ¤t_delegations, Uint128::from(10 as u64)), + compute_redelegations_for_rebalancing( + active_validators, + ¤t_delegations, + Uint128::from(10 as u64) + ), expected, ); - - let partially_active = vec!["alice".to_string(), - "charlie".to_string(), - "dave".to_string(), - "evan".to_string()]; + let partially_active = vec![ + "alice".to_string(), + "charlie".to_string(), + "dave".to_string(), + "evan".to_string(), + ]; let partially_expected = vec![ Redelegation::new("alice", "dave", 10118, "uxyz"), @@ -1763,7 +1839,11 @@ fn computing_redelegations_for_rebalancing() { Redelegation::new("charlie", "evan", 38299, "uxyz"), ]; assert_eq!( - compute_redelegations_for_rebalancing(partially_active.clone(), ¤t_delegations, Uint128::from(10 as u64)), + compute_redelegations_for_rebalancing( + partially_active.clone(), + ¤t_delegations, + Uint128::from(10 as u64) + ), partially_expected, ); @@ -1772,7 +1852,11 @@ fn computing_redelegations_for_rebalancing() { Redelegation::new("charlie", "evan", 29414, "uxyz"), ]; assert_eq!( - compute_redelegations_for_rebalancing(partially_active, ¤t_delegations, Uint128::from(15_000 as u64)), + compute_redelegations_for_rebalancing( + partially_active, + ¤t_delegations, + Uint128::from(15_000 as u64) + ), partially_expected_minimums, ); } @@ -1860,7 +1944,7 @@ fn receiving_funds() { &[Coin::new(12345, "uatom"), Coin::new(23456, "uxyz")], "uxyz", ) - .unwrap_err(); + .unwrap_err(); assert_eq!( err, StdError::generic_err("must deposit exactly one coin; received 2") @@ -1882,7 +1966,6 @@ fn receiving_funds() { assert_eq!(amount, Uint128::new(69420)); } - #[test] fn reconciling_underflow() { let mut deps = setup_test(); @@ -1941,7 +2024,10 @@ fn reconciling_underflow() { Coin::new(12345, "uatom"), Coin::new(234, "ukrw"), Coin::new(345, "uusd"), - Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), + Coin::new( + 69420, + "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B", + ), ]); execute( deps.as_mut(), @@ -1949,7 +2035,7 @@ fn reconciling_underflow() { mock_info("worker", &[]), ExecuteMsg::Reconcile {}, ) - .unwrap(); + .unwrap(); } #[test] @@ -2010,7 +2096,10 @@ fn reconciling_underflow_second() { Coin::new(12345 - 1323, "uatom"), Coin::new(234, "ukrw"), Coin::new(345, "uusd"), - Coin::new(69420, "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"), + Coin::new( + 69420, + "ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B", + ), ]); execute( deps.as_mut(), @@ -2018,5 +2107,97 @@ fn reconciling_underflow_second() { mock_info("worker", &[]), ExecuteMsg::Reconcile {}, ) - .unwrap(); -} \ No newline at end of file + .unwrap(); +} +#[test] +fn dust_return_denom() { + let mut deps = setup_test(); + + // Bond when no delegation has been made + // In this case, the full deposit simply goes to the first validator + let res = execute( + deps.as_mut(), + mock_env(), + mock_info("user_1", &[Coin::new(1_000_000, "uxyz")]), + ExecuteMsg::Bond { + receiver: None, + exec_msg: None, + }, + ) + .unwrap(); + + // 3 messages. (switched to 3 so we can 'send' instead of 'transfer' minted tokens, so contract will know about it + // 1 - delegate + // 2 - mint token (to ourselves) + // 3 - send/transfer it + assert_eq!(res.messages.len(), 3); + assert_eq!( + res.messages[0], + SubMsg { + msg: Delegation::new("alice", 1_000_000, "uxyz").to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + } + ); + let mint_msg = >::into(MsgMint { + sender: "cosmos2contract".to_string(), + amount: Some(denom::Coin { + denom: "factory/cosmos2contract/boneXYZ".to_string(), + amount: Uint128::new(1_000_000).to_string(), + }), + }); + assert_eq!( + res.messages[1], + SubMsg { + id: 0, + msg: mint_msg, + gas_limit: None, + reply_on: ReplyOn::Never, + } + ); + + assert_eq!( + res.messages[2], + SubMsg { + id: 0, + msg: CosmosMsg::Bank(BankMsg::Send { + to_address: "user_1".to_string(), + amount: vec![Coin { + denom: "factory/cosmos2contract/boneXYZ".to_string(), + amount: Uint128::new(1_000_000) + }], + }), + gas_limit: None, + reply_on: ReplyOn::Never, + } + ); + + // Bond when there are existing delegations, and Luna:Steak exchange rate is >1 + // Previously user 1 delegated 1,000,000 uluna. We assume we have accumulated 2.5% yield at 1025000 staked + deps.querier.set_staking_delegations(&[ + Delegation::new("alice", 341667, "uxyz"), + Delegation::new("bob", 341667, "uxyz"), + Delegation::new("charlie", 341666, "uxyz"), + ]); + + // Charlie has the smallest amount of delegation, so the full deposit goes to him + let res = execute( + deps.as_mut(), + mock_env(), + mock_info("user_2", &[Coin::new(12345, "uxyz")]), + ExecuteMsg::ReturnDenom {}, + ) + .unwrap(); + eprintln!("{:?}", res.messages); + assert_eq!(res.messages.len(), 1); + assert_eq!( + res.messages[0], + SubMsg { + msg: Delegation::new("charlie", 12345, "uxyz").to_cosmos_msg(), + id: REPLY_REGISTER_RECEIVED_COINS, + gas_limit: None, + reply_on: ReplyOn::Never + } + ); +} diff --git a/contracts/hub/Cargo.toml b/contracts/hub/Cargo.toml index 1820cf79..58c5ffdf 100644 --- a/contracts/hub/Cargo.toml +++ b/contracts/hub/Cargo.toml @@ -21,7 +21,7 @@ cw-storage-plus = "0.13" pfc-steak = { path = "../../packages/steak" } serde = { version = "1.0.103", default-features = false, features = ["derive"] } pfc-fee-split = "0.2.3" -pfc-dust-collector = "0.1.0" +#pfc-dust-collector = {path = "../../packages/pfc-dust-collector"} funds-distributor-api = {git="https://github.com/terra-money/enterprise-contracts.git" , branch="main"} #[dev-dependencies] #serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/hub/src/contract.rs b/contracts/hub/src/contract.rs index 28967d9e..88420496 100644 --- a/contracts/hub/src/contract.rs +++ b/contracts/hub/src/contract.rs @@ -1,16 +1,19 @@ use cosmwasm_std::{ - Binary, Decimal, Deps, DepsMut, entry_point, Env, from_binary, MessageInfo, Reply, Response, - StdError, StdResult, to_binary, + entry_point, from_binary, to_binary, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Reply, + Response, StdError, StdResult, }; -use cw2::{ContractVersion, get_contract_version, set_contract_version}; +use cw2::{get_contract_version, set_contract_version, ContractVersion}; use cw20::Cw20ReceiveMsg; +use std::convert::TryInto; -use pfc_steak::hub::{CallbackMsg, ExecuteMsg, FeeType, InstantiateMsg, MigrateMsg, QueryMsg, ReceiveMsg}; +use pfc_steak::hub::{ + CallbackMsg, ExecuteMsg, FeeType, InstantiateMsg, MigrateMsg, QueryMsg, ReceiveMsg, +}; -use crate::{execute, queries}; use crate::helpers::{get_denom_balance, unwrap_reply}; use crate::migrations::ConfigV100; use crate::state::State; +use crate::{execute, queries}; /// Contract name that is used for migration. pub const CONTRACT_NAME: &str = "steak-hub"; @@ -45,9 +48,9 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S .unwrap_or(info.sender), info.funds, exec_msg, - false + false, ), - ExecuteMsg::BondEx { receiver, } => execute::bond( + ExecuteMsg::BondEx { receiver } => execute::bond( deps, env, receiver @@ -56,7 +59,7 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S .unwrap_or(info.sender), info.funds, None, - true + true, ), ExecuteMsg::WithdrawUnbonded { receiver } => execute::withdraw_unbonded( deps, @@ -79,9 +82,10 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S ExecuteMsg::RemoveValidatorEx { validator } => { execute::remove_validator_ex(deps, env, info.sender, validator) } - ExecuteMsg::Redelegate { validator_from,validator_to } => { - execute::redelegate(deps, env, info.sender, validator_from,validator_to) - } + ExecuteMsg::Redelegate { + validator_from, + validator_to, + } => execute::redelegate(deps, env, info.sender, validator_from, validator_to), ExecuteMsg::TransferOwnership { new_owner } => { execute::transfer_ownership(deps, info.sender, new_owner) } @@ -90,9 +94,10 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S ExecuteMsg::Rebalance { minimum } => execute::rebalance(deps, env, minimum), ExecuteMsg::Reconcile {} => execute::reconcile(deps, env), ExecuteMsg::SubmitBatch {} => execute::submit_batch(deps, env), - ExecuteMsg::TransferFeeAccount { fee_account_type, new_fee_account } => { - execute::transfer_fee_account(deps, info.sender, fee_account_type, new_fee_account) - } + ExecuteMsg::TransferFeeAccount { + fee_account_type, + new_fee_account, + } => execute::transfer_fee_account(deps, info.sender, fee_account_type, new_fee_account), ExecuteMsg::UpdateFee { new_fee } => execute::update_fee(deps, info.sender, new_fee), ExecuteMsg::Callback(callback_msg) => callback(deps, env, info, callback_msg), ExecuteMsg::PauseValidator { validator } => { @@ -101,10 +106,21 @@ pub fn execute(deps: DepsMut, env: Env, info: MessageInfo, msg: ExecuteMsg) -> S ExecuteMsg::UnPauseValidator { validator } => { execute::unpause_validator(deps, env, info.sender, validator) } - ExecuteMsg::SetUnbondPeriod { unbond_period } => execute::set_unbond_period(deps, env, info.sender, unbond_period), - ExecuteMsg::SetDustCollector { dust_collector } => { execute::set_dust_collector(deps, env, info.sender, dust_collector) } - ExecuteMsg::CollectDust {} => { execute::collect_dust(deps, env) } - ExecuteMsg::ReturnDenom {} => { execute::return_denom(deps, env, info.funds) } + ExecuteMsg::SetUnbondPeriod { unbond_period } => { + execute::set_unbond_period(deps, env, info.sender, unbond_period) + } + ExecuteMsg::SetDustCollector { dust_collector } => { + execute::set_dust_collector(deps, env, info.sender, dust_collector) + } + ExecuteMsg::CollectDust { max_tokens } => { + let max_tokens_usize_r = max_tokens.try_into(); + if let Ok(max_tokens_usize) = max_tokens_usize_r { + execute::collect_dust(deps, env, max_tokens_usize) + } else { + Err(StdError::generic_err("max_tokens too large")) + } + } + ExecuteMsg::ReturnDenom {} => execute::return_denom(deps, env, info.funds), } } @@ -221,20 +237,26 @@ pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> StdResult state.fee_account.save(deps.storage, &owner)?; state.max_fee_rate.save(deps.storage, &Decimal::zero())?; state.fee_rate.save(deps.storage, &Decimal::zero())?; - state.fee_account_type.save(deps.storage, &FeeType::Wallet)?; + state + .fee_account_type + .save(deps.storage, &FeeType::Wallet)?; ConfigV100::upgrade_stores(deps.storage, &deps.querier, env.contract.address)?; state.dust_collector.save(deps.storage, &None)?; } "2.1.4" => { let state = State::default(); ConfigV100::upgrade_stores(deps.storage, &deps.querier, env.contract.address)?; - state.fee_account_type.save(deps.storage, &FeeType::Wallet)?; + state + .fee_account_type + .save(deps.storage, &FeeType::Wallet)?; state.dust_collector.save(deps.storage, &None)?; } "2.1.5" => { ConfigV100::upgrade_stores(deps.storage, &deps.querier, env.contract.address)?; let state = State::default(); - state.fee_account_type.save(deps.storage, &FeeType::Wallet)?; + state + .fee_account_type + .save(deps.storage, &FeeType::Wallet)?; state.dust_collector.save(deps.storage, &None)?; } "2.1.6" | "2.1.7" => { @@ -246,12 +268,16 @@ pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> StdResult &get_denom_balance(&deps.querier, env.contract.address, denom)?, )?; - state.fee_account_type.save(deps.storage, &FeeType::Wallet)?; + state + .fee_account_type + .save(deps.storage, &FeeType::Wallet)?; state.dust_collector.save(deps.storage, &None)?; } - "2.1.8" |"2.1.16"=> { + "2.1.8" | "2.1.16" => { let state = State::default(); - state.fee_account_type.save(deps.storage, &FeeType::Wallet)?; + state + .fee_account_type + .save(deps.storage, &FeeType::Wallet)?; state.dust_collector.save(deps.storage, &None)?; } "3.0.1" => { diff --git a/contracts/hub/src/execute.rs b/contracts/hub/src/execute.rs index 9c6b24f4..4f71070c 100644 --- a/contracts/hub/src/execute.rs +++ b/contracts/hub/src/execute.rs @@ -1048,7 +1048,7 @@ pub fn set_dust_collector( .add_attribute("action", "steakhub/set_dust_collector")) } -pub fn collect_dust(deps: DepsMut, _env: Env) -> StdResult { +pub fn collect_dust(deps: DepsMut, _env: Env,_max_tokens:usize) -> StdResult { let state = State::default(); if let Some(_dust_addr) = state.dust_collector.load(deps.storage)? { diff --git a/packages/steak/src/hub.rs b/packages/steak/src/hub.rs index e7c912e9..637b8de6 100644 --- a/packages/steak/src/hub.rs +++ b/packages/steak/src/hub.rs @@ -1,6 +1,8 @@ use std::str::FromStr; -use cosmwasm_std::{Addr, Binary, Coin, CosmosMsg, Decimal, Empty, StdResult, to_binary, Uint128, WasmMsg}; +use cosmwasm_std::{ + to_binary, Addr, Binary, Coin, CosmosMsg, Decimal, Empty, StdResult, Uint128, WasmMsg, +}; use cw20::Cw20ReceiveMsg; use cw20_base::msg::InstantiateMarketingInfo as Cw20InstantiateMarketingInfo; use schemars::JsonSchema; @@ -9,8 +11,9 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub enum Cw20HookMsg { Distribute {}, - Transfer{} + Transfer {}, } + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub enum EnterpriseCw20HookMsg { Distribute {}, @@ -57,41 +60,69 @@ pub enum ExecuteMsg { /// Implements the Cw20 receiver interface Receive(Cw20ReceiveMsg), /// Bond specified amount of Luna - Bond { receiver: Option, exec_msg: Option }, + Bond { + receiver: Option, + exec_msg: Option, + }, /// Bond specified amount of Luna, just minting it directly (cw-20 version only) - BondEx { receiver: Option }, + BondEx { + receiver: Option, + }, /// Withdraw Luna that have finished unbonding in previous batches - WithdrawUnbonded { receiver: Option }, + WithdrawUnbonded { + receiver: Option, + }, /// Withdraw Luna that has finished unbonding in previous batches, for given address - WithdrawUnbondedAdmin { address: String }, + WithdrawUnbondedAdmin { + address: String, + }, /// Add a validator to the whitelist; callable by the owner - AddValidator { validator: String }, + AddValidator { + validator: String, + }, /// Remove a validator from the whitelist; callable by the owner - RemoveValidator { validator: String }, + RemoveValidator { + validator: String, + }, /// Remove a validator from the whitelist; callable by the owner. Does not undelegate. use for typos - RemoveValidatorEx { validator: String }, + RemoveValidatorEx { + validator: String, + }, /// Pause a validator from accepting new delegations - PauseValidator { validator: String }, + PauseValidator { + validator: String, + }, /// Unpause a validator from accepting new delegations - UnPauseValidator { validator: String }, + UnPauseValidator { + validator: String, + }, /// Transfer ownership to another account; will not take effect unless the new owner accepts - TransferOwnership { new_owner: String }, + TransferOwnership { + new_owner: String, + }, /// Accept an ownership transfer AcceptOwnership {}, /// Claim staking rewards, swap all for Luna, and restake Harvest {}, /// Use redelegations to balance the amounts of Luna delegated to validators - Rebalance { minimum: Uint128 }, + Rebalance { + minimum: Uint128, + }, /// redelegate stake from one validator to another - Redelegate { validator_from: String, validator_to: String }, + Redelegate { + validator_from: String, + validator_to: String, + }, /// Update Luna amounts in unbonding batches to reflect any slashing or rounding errors Reconcile {}, /// Submit the current pending batch of unbonding requests to be unbonded SubmitBatch {}, /// Set unbond period - SetUnbondPeriod { unbond_period: u64 }, + SetUnbondPeriod { + unbond_period: u64, + }, /// Transfer Fee collection account to another account TransferFeeAccount { @@ -99,13 +130,19 @@ pub enum ExecuteMsg { new_fee_account: String, }, /// Update fee collection amount - UpdateFee { new_fee: Decimal }, + UpdateFee { + new_fee: Decimal, + }, /// Callbacks; can only be invoked by the contract itself Callback(CallbackMsg), // Set The Duster. - SetDustCollector { dust_collector: Option }, + SetDustCollector { + dust_collector: Option, + }, /// Collect the Dust - CollectDust {}, + CollectDust { + max_tokens: u32, + }, /// Return the Dust in shiny 'base denom' ReturnDenom {}, } @@ -193,7 +230,7 @@ pub struct ConfigResponse { pub validators: Vec, pub paused_validators: Vec, pub dust_collector: Option, - pub token_factory: Option + pub token_factory: Option, } #[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)] diff --git a/packages/steak/src/hub_tf.rs b/packages/steak/src/hub_tf.rs index fda9bdb4..01fbabdb 100644 --- a/packages/steak/src/hub_tf.rs +++ b/packages/steak/src/hub_tf.rs @@ -1,5 +1,5 @@ -use std::str::FromStr; use cosmwasm_schema::cw_serde; +use std::str::FromStr; // use cosmwasm_std::{Decimal, Uint128}; @@ -7,9 +7,9 @@ use crate::hub::CallbackMsg; #[cw_serde] pub enum TokenFactoryType { - CosmWasm =1, - Kujira =2, - Injective =3 + CosmWasm = 1, + Kujira = 2, + Injective = 3, } impl ToString for TokenFactoryType { fn to_string(&self) -> String { @@ -63,7 +63,10 @@ pub struct InstantiateMsg { #[cw_serde] pub enum ExecuteMsg { /// Bond specified amount of Luna - Bond { receiver: Option, exec_msg: Option }, + Bond { + receiver: Option, + exec_msg: Option, + }, /// Bond specified amount of Luna Unbond { receiver: Option }, @@ -92,7 +95,10 @@ pub enum ExecuteMsg { /// Use redelegations to balance the amounts of Luna delegated to validators Rebalance { minimum: Uint128 }, /// redelegate stake from one validator to another - Redelegate { validator_from: String, validator_to: String }, + Redelegate { + validator_from: String, + validator_to: String, + }, /// Update Luna amounts in unbonding batches to reflect any slashing or rounding errors Reconcile {}, /// Submit the current pending batch of unbonding requests to be unbonded @@ -112,8 +118,7 @@ pub enum ExecuteMsg { /// Set Dust Collector Contract SetDustCollector { dust_collector: Option }, /// Collect the Dust - CollectDust { max_tokens: u64}, + CollectDust { max_tokens: u32 }, /// Return the Dust in shiny 'base denom' ReturnDenom {}, } -