From 5aa0796efc64c5126e7223be704ca577dcb6bb91 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Tue, 26 Nov 2024 15:43:22 +0200 Subject: [PATCH 01/22] sc upgrade --- Cargo.lock | 1692 +++----------------- Cargo.toml | 4 +- delegation-mock/Cargo.toml | 4 +- delegation-mock/meta/Cargo.toml | 4 +- delegation-mock/meta/src/main.rs | 2 +- delegation-mock/wasm/Cargo.lock | 63 +- delegation-mock/wasm/Cargo.toml | 2 +- liquid-staking/Cargo.toml | 6 +- liquid-staking/meta/Cargo.toml | 4 +- liquid-staking/meta/src/main.rs | 2 +- liquid-staking/src/config.rs | 12 +- liquid-staking/src/delegation.rs | 11 +- liquid-staking/src/events.rs | 6 +- liquid-staking/src/lib.rs | 7 - liquid-staking/src/liquidity_pool.rs | 3 +- liquid-staking/tests/contract_setup/mod.rs | 5 +- liquid-staking/wasm/Cargo.lock | 67 +- liquid-staking/wasm/Cargo.toml | 2 +- 18 files changed, 300 insertions(+), 1596 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 123c908..be0d16d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,31 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -dependencies = [ - "lazy_static", - "regex", -] - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "ahash" version = "0.8.11" @@ -39,15 +14,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - [[package]] name = "anstream" version = "0.6.14" @@ -103,26 +69,11 @@ version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" -[[package]] -name = "arbitrary" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" -dependencies = [ - "derive_arbitrary", -] - [[package]] name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "atomic-waker" -version = "1.1.2" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "autocfg" @@ -130,21 +81,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" -[[package]] -name = "backtrace" -version = "0.3.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base64" version = "0.22.1" @@ -152,50 +88,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] -name = "bech32" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" - -[[package]] -name = "bip39" -version = "2.0.0" +name = "base64ct" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" -dependencies = [ - "bitcoin_hashes", - "rand 0.8.5", - "rand_core 0.6.4", - "serde", - "unicode-normalization", -] +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] -name = "bitcoin_hashes" +name = "bech32" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" [[package]] name = "bitflags" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" - -[[package]] -name = "block-buffer" -version = "0.9.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", -] +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" @@ -206,40 +114,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bstr" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" -dependencies = [ - "memchr", - "serde", -] - [[package]] name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" - -[[package]] -name = "cc" -version = "1.0.98" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" - [[package]] name = "cfg-if" version = "1.0.0" @@ -303,10 +183,10 @@ dependencies = [ ] [[package]] -name = "common-path" -version = "1.0.0" +name = "const-oid" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "convert_case" @@ -317,31 +197,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "copy_dir" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543d1dd138ef086e2ff05e3a48cf9da045da2033d16f8538fd76b86cd49b2ca3" -dependencies = [ - "walkdir", -] - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -351,40 +206,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc32fast" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - [[package]] name = "crypto-common" version = "0.1.6" @@ -397,17 +218,31 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "delegation-mock" version = "0.0.0" @@ -422,27 +257,17 @@ name = "delegation-mock-meta" version = "0.0.0" dependencies = [ "delegation-mock", - "multiversx-sc-meta", -] - -[[package]] -name = "derive_arbitrary" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "multiversx-sc-meta-lib", ] [[package]] -name = "digest" -version = "0.9.0" +name = "der" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ - "generic-array", + "const-oid", + "zeroize", ] [[package]] @@ -451,42 +276,31 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "crypto-common", - "subtle", -] - -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn", ] [[package]] name = "ed25519" -version = "1.5.3" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ + "pkcs8", "signature", ] [[package]] name = "ed25519-dalek" -version = "1.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", - "rand 0.7.3", "serde", - "sha2 0.9.9", + "sha2", + "subtle", "zeroize", ] @@ -496,15 +310,6 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" -[[package]] -name = "encoding_rs" -version = "0.8.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" -dependencies = [ - "cfg-if", -] - [[package]] name = "endian-type" version = "0.1.2" @@ -518,110 +323,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "errno" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "fastrand" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" - -[[package]] -name = "flate2" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-io" -version = "0.3.30" +name = "fiat-crypto" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "generic-array" @@ -633,17 +338,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.15" @@ -652,45 +346,7 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "gimli" -version = "0.28.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" - -[[package]] -name = "globset" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" -dependencies = [ - "aho-corasick", - "bstr", - "log", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "h2" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" -dependencies = [ - "atomic-waker", - "bytes", - "fnv", - "futures-core", - "futures-sink", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", + "wasi", ] [[package]] @@ -700,6 +356,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", + "serde", ] [[package]] @@ -708,12 +365,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "hex" version = "0.4.3" @@ -727,190 +378,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" [[package]] -name = "hmac" -version = "0.12.1" +name = "indexmap" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ - "digest 0.10.7", + "equivalent", + "hashbrown", + "serde", ] [[package]] -name = "http" -version = "1.1.0" +name = "is_terminal_polyfill" +version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" -dependencies = [ - "bytes", - "fnv", - "itoa", -] +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" [[package]] -name = "http-body" -version = "1.0.0" +name = "itertools" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ - "bytes", - "http", + "either", ] [[package]] -name = "http-body-util" -version = "0.1.1" +name = "itertools" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "pin-project-lite", + "either", ] [[package]] -name = "httparse" -version = "1.8.0" +name = "itoa" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "hyper" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-tls" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" -dependencies = [ - "bytes", - "http-body-util", - "hyper", - "hyper-util", - "native-tls", - "tokio", - "tokio-native-tls", - "tower-service", -] - -[[package]] -name = "hyper-util" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http", - "http-body", - "hyper", - "pin-project-lite", - "socket2", - "tokio", - "tower", - "tower-service", - "tracing", -] - -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "ignore" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" -dependencies = [ - "crossbeam-deque", - "globset", - "log", - "memchr", - "regex-automata", - "same-file", - "walkdir", - "winapi-util", -] - -[[package]] -name = "indexmap" -version = "2.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "keccak" @@ -928,16 +434,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] -name = "libc" -version = "0.2.155" +name = "leb128" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] -name = "linux-raw-sys" -version = "0.4.14" +name = "libc" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "liquid-staking" @@ -955,25 +461,9 @@ name = "liquid-staking-abi" version = "0.0.0" dependencies = [ "liquid-staking", - "multiversx-sc-meta", -] - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", + "multiversx-sc-meta-lib", ] -[[package]] -name = "lockfree-object-pool" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" - [[package]] name = "log" version = "0.4.21" @@ -982,41 +472,25 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "mime" -version = "0.3.17" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] -name = "miniz_oxide" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.11" +name = "multiversx-chain-core" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", + "bitflags", + "multiversx-sc-codec", ] [[package]] name = "multiversx-chain-scenario-format" -version = "0.22.2" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a9190bdd56300e801e7793fc4ee7dc0c76c1149aac019da8c71cc58254966fe" +checksum = "dcca77966bf5eb9c9f96d0597f17a4fa7b64681cc7b83e39bdf31f8c6ca04d44" dependencies = [ "bech32", "hex", @@ -1029,22 +503,23 @@ dependencies = [ [[package]] name = "multiversx-chain-vm" -version = "0.8.4" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f69520691466bc184475320c27db21137e68be5e959df25c1a14b09e055d0d58" +checksum = "fb84ccafc930d8a9d84de56758cef7070bfce951475d3f751be447acd4404d7a" dependencies = [ - "bitflags 2.5.0", + "bitflags", "colored", "ed25519-dalek", "hex", "hex-literal", - "itertools 0.12.1", + "itertools 0.13.0", + "multiversx-chain-core", "multiversx-chain-vm-executor", "num-bigint", "num-traits", - "rand 0.8.5", + "rand", "rand_seeder", - "sha2 0.10.8", + "sha2", "sha3", ] @@ -1056,12 +531,13 @@ checksum = "b59072fa0624b55ae5ae3fa6bfa91515bbeb4ac440214bc4a509e2c8806d6e9f" [[package]] name = "multiversx-sc" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599a8eb65ec60fcd5f71366e83c8e71fc4ab0a89b313367634a61a75d745fb3b" +checksum = "7d3e07165056a974c3d3a23f866a1cb037fa5b2a629854b663a8a71c056cb8f3" dependencies = [ - "bitflags 2.5.0", + "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -1070,9 +546,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c94397b2fba14e40edfa55905b3f453ed57aa06c9b1960ad6a0ca6bfb7a236" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -1082,9 +558,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf72a8042da0bc19da0b8f0d4f61b4c66ae853560fefc69cd8fea87bf1aa8c14" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -1094,9 +570,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52004e5331f71143580faafba4865df8568a059e2d1b800ab1f7149863e5c" +checksum = "96104c7f49fab0f0daa0373d9554016a8d22b97442e01e3b80a72d7f9ea33931" dependencies = [ "hex", "proc-macro2", @@ -1106,114 +582,62 @@ dependencies = [ ] [[package]] -name = "multiversx-sc-meta" -version = "0.50.1" +name = "multiversx-sc-meta-lib" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cf5088bd4fc9990eb5ea6d7cf46d00d34b6c448d79f812d3ec04ca55a76218e" +checksum = "fa9910c2a0f1fdda3991fe4bff5d747dac19a31b50b41c8b2bf9dcf7e8d6150f" dependencies = [ "clap", "colored", - "common-path", "convert_case", - "copy_dir", "hex", "lazy_static", "multiversx-sc", - "pathdiff", - "reqwest", - "ruplacer", "rustc_version", "semver", "serde", "serde_json", "toml", - "wasmparser", + "wasmparser 0.216.0", "wasmprinter", - "zip", + "wat", ] [[package]] name = "multiversx-sc-modules" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e77beee1a1aa0977ae40842dcae10e77ba830b6363a382a70bfce18671a7b35" +checksum = "26ef05d960e804fc353093dece6ab64782d17e99ed9e25cbd2f204f64b666334" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-scenario" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45aa790269c95ebb267f6ab5e9e182ad27c1bec4987bb7b72716b97f8786da86" +checksum = "87bd017700291d55cb2837b57525fa5c5f9ea45ff0438335691aea2aa86c7e4b" dependencies = [ "base64", "bech32", - "clap", "colored", "hex", - "itertools 0.12.1", + "itertools 0.13.0", "log", "multiversx-chain-scenario-format", "multiversx-chain-vm", "multiversx-chain-vm-executor", "multiversx-sc", - "multiversx-sc-meta", - "multiversx-sdk", + "multiversx-sc-meta-lib", "num-bigint", "num-traits", "pathdiff", "serde", "serde_json", - "sha2 0.10.8", - "tokio", + "sha2", "unwrap-infallible", ] -[[package]] -name = "multiversx-sdk" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cb2f8dd4a17ce9c9fa1ab3d80152929702968be6536499f32bd7e2278c2e0fb" -dependencies = [ - "anyhow", - "base64", - "bech32", - "bip39", - "hex", - "hmac", - "itertools 0.12.1", - "pbkdf2", - "pem", - "rand 0.8.5", - "reqwest", - "serde", - "serde_json", - "serde_repr", - "sha2 0.10.8", - "sha3", - "tokio", - "zeroize", -] - -[[package]] -name = "native-tls" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nibble_vec" version = "0.1.0" @@ -1251,104 +675,12 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "object" -version = "0.32.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - -[[package]] -name = "openssl" -version = "0.10.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" -dependencies = [ - "bitflags 2.5.0", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "openssl-sys" -version = "0.9.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "parking_lot" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.52.5", -] - [[package]] name = "pathdiff" version = "0.2.1" @@ -1356,68 +688,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] -name = "pbkdf2" -version = "0.12.2" +name = "pkcs8" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "pem" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" -dependencies = [ - "base64", - "serde", -] - -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - -[[package]] -name = "pin-project" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "der", + "spki", ] -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1426,18 +705,18 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1452,19 +731,6 @@ dependencies = [ "nibble_vec", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - [[package]] name = "rand" version = "0.8.5" @@ -1472,18 +738,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", ] [[package]] @@ -1493,16 +749,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -1511,128 +758,18 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.15", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] name = "rand_seeder" -version = "0.2.3" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2890aaef0aa82719a50e808de264f9484b74b442e1a3a0e5ee38243ac40bdb" +checksum = "4a9febe641d2842ffc76ee962668a17578767c4e01735e4802b21ed9a24b2e4e" dependencies = [ - "rand_core 0.6.4", + "rand_core", ] -[[package]] -name = "redox_syscall" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" -dependencies = [ - "bitflags 2.5.0", -] - -[[package]] -name = "regex" -version = "1.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" - -[[package]] -name = "reqwest" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" -dependencies = [ - "base64", - "bytes", - "encoding_rs", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-tls", - "hyper-util", - "ipnet", - "js-sys", - "log", - "mime", - "native-tls", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls-pemfile", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tokio-native-tls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "ruplacer" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58a26a1b15ff113d31d139357f7422708312978ed69cd5dd47e36d1b80b7eaf3" -dependencies = [ - "Inflector", - "anyhow", - "clap", - "colored", - "ignore", - "regex", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" - [[package]] name = "rustc_version" version = "0.4.0" @@ -1642,87 +779,11 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "0.38.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" -dependencies = [ - "bitflags 2.5.0", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustls-pemfile" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" -dependencies = [ - "base64", - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" - [[package]] name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "schannel" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "security-framework" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" -dependencies = [ - "bitflags 2.5.0", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" -dependencies = [ - "core-foundation-sys", - "libc", -] +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "semver" @@ -1756,23 +817,11 @@ version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ - "indexmap", "itoa", "ryu", "serde", ] -[[package]] -name = "serde_repr" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "serde_spanned" version = "0.6.6" @@ -1782,31 +831,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.10.8" @@ -1815,7 +839,7 @@ checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -1824,38 +848,17 @@ version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.7", + "digest", "keccak", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" -dependencies = [ - "libc", -] - [[package]] name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" - -[[package]] -name = "simd-adler32" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" - -[[package]] -name = "slab" -version = "0.4.9" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "autocfg", + "rand_core", ] [[package]] @@ -1865,13 +868,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] -name = "socket2" -version = "0.5.7" +name = "spki" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ - "libc", - "windows-sys 0.52.0", + "base64ct", + "der", ] [[package]] @@ -1888,9 +891,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.61" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -1898,130 +901,12 @@ dependencies = [ ] [[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tempfile" -version = "3.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" -dependencies = [ - "cfg-if", - "fastrand", - "rustix", - "windows-sys 0.52.0", -] - -[[package]] -name = "thiserror" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "parking_lot", - "pin-project-lite", - "signal-hook-registry", - "socket2", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-macros" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-native-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" -dependencies = [ - "native-tls", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.7.11" +name = "termcolor" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "pin-project-lite", - "tokio", + "winapi-util", ] [[package]] @@ -2059,87 +944,18 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "log", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -2147,21 +963,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] -name = "unwrap-infallible" -version = "0.1.5" +name = "unicode-width" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" [[package]] -name = "url" -version = "2.5.0" +name = "unwrap-infallible" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] +checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" [[package]] name = "utf8parse" @@ -2169,43 +980,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2213,102 +993,70 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "wasm-bindgen" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.42" +name = "wasm-encoder" +version = "0.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "ebf48234b389415b226a4daef6562933d38c7b28a8b8f64c5c4130dad1561ab7" dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", + "leb128", + "wasmparser 0.220.0", ] [[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" +name = "wasmparser" +version = "0.216.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "bcdee6bea3619d311fb4b299721e89a986c3470f804b6d534340e412589028e3" dependencies = [ - "quote", - "wasm-bindgen-macro-support", + "ahash", + "bitflags", + "hashbrown", + "indexmap", + "semver", + "serde", ] [[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" +name = "wasmparser" +version = "0.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "e246c2772ce3ebc83f89a2d4487ac5794cad6c309b2071818a88c7db7c36d87b" dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", + "bitflags", + "indexmap", ] [[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - -[[package]] -name = "wasmparser" -version = "0.207.0" +name = "wasmprinter" +version = "0.216.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" +checksum = "8f82916f3892e53620639217d6ec78fe15c678352a3fbf3f3745b6417d0bd70f" dependencies = [ - "ahash", - "bitflags 2.5.0", - "hashbrown", - "indexmap", - "semver", + "anyhow", + "termcolor", + "wasmparser 0.216.0", ] [[package]] -name = "wasmprinter" -version = "0.207.0" +name = "wast" +version = "220.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2d8a7b4dabb460208e6b4334d9db5766e84505038b2529e69c3d07ac619115" +checksum = "4e708c8de08751fd66e70961a32bae9d71901f14a70871e181cb8461a3bb3165" dependencies = [ - "anyhow", - "wasmparser", + "bumpalo", + "leb128", + "memchr", + "unicode-width", + "wasm-encoder", ] [[package]] -name = "web-sys" -version = "0.3.69" +name = "wat" +version = "1.220.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "de4f1d7d59614ba690541360102b995c4eb1b9ed373701d5102cc1a968b1c5a3" dependencies = [ - "js-sys", - "wasm-bindgen", + "wast", ] [[package]] @@ -2468,16 +1216,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "zerocopy" version = "0.7.34" @@ -2503,47 +1241,3 @@ name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "zip" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b7a5a9285bd4ee13bdeb3f8a4917eb46557e53f270c783849db8bef37b0ad00" -dependencies = [ - "arbitrary", - "crc32fast", - "crossbeam-utils", - "displaydoc", - "flate2", - "indexmap", - "thiserror", - "zopfli", -] - -[[package]] -name = "zopfli" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" -dependencies = [ - "bumpalo", - "crc32fast", - "lockfree-object-pool", - "log", - "once_cell", - "simd-adler32", -] diff --git a/Cargo.toml b/Cargo.toml index b550088..3564f99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,9 @@ [workspace] +resolver = "2" + members = [ "liquid-staking", "liquid-staking/meta", "delegation-mock", - "delegation-mock/meta" + "delegation-mock/meta", ] diff --git a/delegation-mock/Cargo.toml b/delegation-mock/Cargo.toml index 6f7ed4b..b9d4cae 100644 --- a/delegation-mock/Cargo.toml +++ b/delegation-mock/Cargo.toml @@ -9,11 +9,11 @@ publish = false path = "src/delegation.rs" [dependencies.multiversx-sc] -version = "0.50.1" +version = "0.54.4" [dependencies.itertools] version = "0.10.1" default-features = false [dev-dependencies.multiversx-sc-scenario] -version = "0.50.1" +version = "0.54.4" diff --git a/delegation-mock/meta/Cargo.toml b/delegation-mock/meta/Cargo.toml index e4bb6b2..b43cbb4 100644 --- a/delegation-mock/meta/Cargo.toml +++ b/delegation-mock/meta/Cargo.toml @@ -8,5 +8,5 @@ authors = ["Sorin Petreasca "] [dependencies.delegation-mock] path = ".." -[dependencies.multiversx-sc-meta] -version = "0.50.1" +[dependencies.multiversx-sc-meta-lib] +version = "0.54.4" diff --git a/delegation-mock/meta/src/main.rs b/delegation-mock/meta/src/main.rs index 86d2e74..71ddc61 100644 --- a/delegation-mock/meta/src/main.rs +++ b/delegation-mock/meta/src/main.rs @@ -1,3 +1,3 @@ fn main() { - multiversx_sc_meta::cli_main::(); + multiversx_sc_meta_lib::cli_main::(); } diff --git a/delegation-mock/wasm/Cargo.lock b/delegation-mock/wasm/Cargo.lock index b22ebb8..da4b1aa 100644 --- a/delegation-mock/wasm/Cargo.lock +++ b/delegation-mock/wasm/Cargo.lock @@ -4,21 +4,21 @@ version = 3 [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "delegation-mock" @@ -38,9 +38,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "endian-type" @@ -69,14 +69,25 @@ dependencies = [ "either", ] +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599a8eb65ec60fcd5f71366e83c8e71fc4ab0a89b313367634a61a75d745fb3b" +checksum = "7d3e07165056a974c3d3a23f866a1cb037fa5b2a629854b663a8a71c056cb8f3" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -85,9 +96,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c94397b2fba14e40edfa55905b3f453ed57aa06c9b1960ad6a0ca6bfb7a236" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -96,9 +107,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf72a8042da0bc19da0b8f0d4f61b4c66ae853560fefc69cd8fea87bf1aa8c14" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -108,9 +119,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52004e5331f71143580faafba4865df8568a059e2d1b800ab1f7149863e5c" +checksum = "96104c7f49fab0f0daa0373d9554016a8d22b97442e01e3b80a72d7f9ea33931" dependencies = [ "hex", "proc-macro2", @@ -121,9 +132,9 @@ dependencies = [ [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "563d26f500165b0d0772559c085b4e02d43b62959d319bda72703d6e5c1009ac" +checksum = "bb7ade4ead678bd9e3af2a6c334f9438df5c5a28e57ab72891247bad6c73aaad" dependencies = [ "multiversx-sc", ] @@ -148,18 +159,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -182,9 +193,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.61" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -193,9 +204,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unwrap-infallible" diff --git a/delegation-mock/wasm/Cargo.toml b/delegation-mock/wasm/Cargo.toml index 8542e74..e6ed7d9 100644 --- a/delegation-mock/wasm/Cargo.toml +++ b/delegation-mock/wasm/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.50.1" +version = "0.54.4" [workspace] members = ["."] diff --git a/liquid-staking/Cargo.toml b/liquid-staking/Cargo.toml index d8bae9b..38812b9 100644 --- a/liquid-staking/Cargo.toml +++ b/liquid-staking/Cargo.toml @@ -13,13 +13,13 @@ version = "0.10.1" default-features = false [dependencies.multiversx-sc] -version = "0.50.1" +version = "0.54.4" [dependencies.multiversx-sc-modules] -version = "0.50.1" +version = "0.54.4" [dependencies.delegation-mock] path = "../delegation-mock" [dev-dependencies.multiversx-sc-scenario] -version = "0.50.1" +version = "0.54.4" diff --git a/liquid-staking/meta/Cargo.toml b/liquid-staking/meta/Cargo.toml index 38c0ca7..b7930db 100644 --- a/liquid-staking/meta/Cargo.toml +++ b/liquid-staking/meta/Cargo.toml @@ -8,5 +8,5 @@ publish = false [dependencies.liquid-staking] path = ".." -[dependencies.multiversx-sc-meta] -version = "0.50.1" +[dependencies.multiversx-sc-meta-lib] +version = "0.54.4" diff --git a/liquid-staking/meta/src/main.rs b/liquid-staking/meta/src/main.rs index 5e33cf1..318631a 100644 --- a/liquid-staking/meta/src/main.rs +++ b/liquid-staking/meta/src/main.rs @@ -1,3 +1,3 @@ fn main() { - multiversx_sc_meta::cli_main::(); + multiversx_sc_meta_lib::cli_main::(); } diff --git a/liquid-staking/src/config.rs b/liquid-staking/src/config.rs index bed92b0..07a421e 100644 --- a/liquid-staking/src/config.rs +++ b/liquid-staking/src/config.rs @@ -6,17 +6,9 @@ use super::liquidity_pool::State; pub const MAX_PERCENTAGE: u64 = 100_000; pub const UNBOND_PERIOD: u64 = 10; +#[type_abi] #[derive( - TopEncode, - TopDecode, - NestedEncode, - NestedDecode, - TypeAbi, - Clone, - PartialEq, - Eq, - Debug, - ManagedVecItem, + TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, PartialEq, Eq, Debug, ManagedVecItem, )] pub struct UnstakeTokenAttributes { pub delegation_contract: ManagedAddress, diff --git a/liquid-staking/src/delegation.rs b/liquid-staking/src/delegation.rs index b36dbc6..3d77de7 100644 --- a/liquid-staking/src/delegation.rs +++ b/liquid-staking/src/delegation.rs @@ -14,7 +14,8 @@ pub const EGLD_TO_WHITELIST: u64 = 1_000_000_000_000_000_000; pub const MIN_BLOCKS_BEFORE_CLEAR_ONGOING_OP: u64 = 10; use super::liquidity_pool::State; -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, TypeAbi, Clone)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, Clone)] pub enum ClaimStatusType { Finished, Delegable, @@ -22,7 +23,8 @@ pub enum ClaimStatusType { Redelegated, } -#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, TypeAbi, Clone)] +#[type_abi] +#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, Clone)] pub struct ClaimStatus { pub status: ClaimStatusType, pub last_claim_epoch: u64, @@ -39,9 +41,8 @@ impl Default for ClaimStatus { } } -#[derive( - TopEncode, TopDecode, NestedEncode, NestedDecode, TypeAbi, Clone, PartialEq, Eq, Debug, -)] +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, PartialEq, Eq, Debug)] pub struct DelegationContractData { pub admin_address: ManagedAddress, pub total_staked: BigUint, diff --git a/liquid-staking/src/events.rs b/liquid-staking/src/events.rs index 7e9d6c1..2774552 100644 --- a/liquid-staking/src/events.rs +++ b/liquid-staking/src/events.rs @@ -3,7 +3,8 @@ use super::contexts::base::StorageCache; multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -#[derive(TypeAbi, TopEncode)] +#[type_abi] +#[derive(TopEncode)] pub struct AddLiquidityEvent { caller: ManagedAddress, ls_token_id: TokenIdentifier, @@ -16,7 +17,8 @@ pub struct AddLiquidityEvent { timestamp: u64, } -#[derive(TypeAbi, TopEncode)] +#[type_abi] +#[derive(TopEncode)] pub struct RemoveLiquidityEvent { caller: ManagedAddress, ls_token_id: TokenIdentifier, diff --git a/liquid-staking/src/lib.rs b/liquid-staking/src/lib.rs index 430f268..309452f 100644 --- a/liquid-staking/src/lib.rs +++ b/liquid-staking/src/lib.rs @@ -76,8 +76,6 @@ pub trait LiquidStaking: let delegation_contract = self.get_delegation_contract_for_delegate(&payment); - drop(storage_cache); - let gas_for_async_call = self.get_gas_for_async_call(); self.tx() .to(delegation_contract.clone()) @@ -167,7 +165,6 @@ pub trait LiquidStaking: let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); delegation_contract_mapper .update(|contract_data| contract_data.egld_in_ongoing_undelegation += &egld_to_unstake); - drop(storage_cache); let gas_for_async_call = self.get_gas_for_async_call(); self.tx() @@ -306,8 +303,6 @@ pub trait LiquidStaking: ERROR_NOT_ACTIVE ); - drop(storage_cache); - let gas_for_async_call = self.get_gas_for_async_call(); self.tx() .to(delegation_contract.clone()) @@ -456,8 +451,6 @@ pub trait LiquidStaking: let delegation_contract = self.get_delegation_contract_for_delegate(&rewards_reserve); - drop(storage_cache); - let gas_for_async_call = self.get_gas_for_async_call(); self.tx() .to(delegation_contract.clone()) diff --git a/liquid-staking/src/liquidity_pool.rs b/liquid-staking/src/liquidity_pool.rs index 3d70b11..f36f5da 100644 --- a/liquid-staking/src/liquidity_pool.rs +++ b/liquid-staking/src/liquidity_pool.rs @@ -6,7 +6,8 @@ use super::errors::*; use super::config; -#[derive(TypeAbi, TopEncode, TopDecode, PartialEq, Eq, Copy, Clone, Debug)] +#[type_abi] +#[derive(TopEncode, TopDecode, PartialEq, Eq, Copy, Clone, Debug)] pub enum State { Inactive, Active, diff --git a/liquid-staking/tests/contract_setup/mod.rs b/liquid-staking/tests/contract_setup/mod.rs index 95688e2..3fa2654 100644 --- a/liquid-staking/tests/contract_setup/mod.rs +++ b/liquid-staking/tests/contract_setup/mod.rs @@ -1,10 +1,7 @@ use std::ops::Mul; use liquid_staking::{config::ConfigModule, LiquidStaking}; -use multiversx_sc::{ - imports::StorageTokenWrapper, - types::{Address, BigUint, EsdtLocalRole}, -}; +use multiversx_sc::types::{Address, BigUint, EsdtLocalRole}; use multiversx_sc_scenario::{ imports::{BlockchainStateWrapper, ContractObjWrapper}, diff --git a/liquid-staking/wasm/Cargo.lock b/liquid-staking/wasm/Cargo.lock index 3969058..7ee21e0 100644 --- a/liquid-staking/wasm/Cargo.lock +++ b/liquid-staking/wasm/Cargo.lock @@ -4,21 +4,21 @@ version = 3 [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "delegation-mock" @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "endian-type" @@ -79,14 +79,25 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] +[[package]] +name = "multiversx-chain-core" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c483122550dca9dd4286f970000d855e9d0184e4fe5c5527209a131ac1207638" +dependencies = [ + "bitflags", + "multiversx-sc-codec", +] + [[package]] name = "multiversx-sc" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "599a8eb65ec60fcd5f71366e83c8e71fc4ab0a89b313367634a61a75d745fb3b" +checksum = "7d3e07165056a974c3d3a23f866a1cb037fa5b2a629854b663a8a71c056cb8f3" dependencies = [ "bitflags", "hex-literal", + "multiversx-chain-core", "multiversx-sc-codec", "multiversx-sc-derive", "num-traits", @@ -95,9 +106,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c94397b2fba14e40edfa55905b3f453ed57aa06c9b1960ad6a0ca6bfb7a236" +checksum = "2b72f7f6a3e0828c5e38fe0e98298706837f8337fe06bca3ff21df22c84b6256" dependencies = [ "arrayvec", "multiversx-sc-codec-derive", @@ -106,9 +117,9 @@ dependencies = [ [[package]] name = "multiversx-sc-codec-derive" -version = "0.19.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf72a8042da0bc19da0b8f0d4f61b4c66ae853560fefc69cd8fea87bf1aa8c14" +checksum = "23b915f0f463fd1811de124b51d68cb2067f5a4796cde2a9570316780cf18961" dependencies = [ "hex", "proc-macro2", @@ -118,9 +129,9 @@ dependencies = [ [[package]] name = "multiversx-sc-derive" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ab52004e5331f71143580faafba4865df8568a059e2d1b800ab1f7149863e5c" +checksum = "96104c7f49fab0f0daa0373d9554016a8d22b97442e01e3b80a72d7f9ea33931" dependencies = [ "hex", "proc-macro2", @@ -131,18 +142,18 @@ dependencies = [ [[package]] name = "multiversx-sc-modules" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e77beee1a1aa0977ae40842dcae10e77ba830b6363a382a70bfce18671a7b35" +checksum = "26ef05d960e804fc353093dece6ab64782d17e99ed9e25cbd2f204f64b666334" dependencies = [ "multiversx-sc", ] [[package]] name = "multiversx-sc-wasm-adapter" -version = "0.50.1" +version = "0.54.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "563d26f500165b0d0772559c085b4e02d43b62959d319bda72703d6e5c1009ac" +checksum = "bb7ade4ead678bd9e3af2a6c334f9438df5c5a28e57ab72891247bad6c73aaad" dependencies = [ "multiversx-sc", ] @@ -167,18 +178,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -201,9 +212,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.61" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -212,9 +223,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unwrap-infallible" diff --git a/liquid-staking/wasm/Cargo.toml b/liquid-staking/wasm/Cargo.toml index bbeb34b..61ece8f 100644 --- a/liquid-staking/wasm/Cargo.toml +++ b/liquid-staking/wasm/Cargo.toml @@ -28,7 +28,7 @@ panic = "abort" path = ".." [dependencies.multiversx-sc-wasm-adapter] -version = "0.50.1" +version = "0.54.4" [workspace] members = ["."] From 7b3685fe29bd0d52c86e0d417bbbd073a68af6a3 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Thu, 28 Nov 2024 10:05:05 +0200 Subject: [PATCH 02/22] split functionalities --- Cargo.lock | 17 +--- delegation-mock/Cargo.toml | 4 - liquid-staking/Cargo.toml | 4 - liquid-staking/meta/Cargo.toml | 2 +- liquid-staking/src/config.rs | 2 +- liquid-staking/src/delegation.rs | 20 ++-- liquid-staking/src/events.rs | 4 +- liquid-staking/src/lib.rs | 93 +++---------------- liquid-staking/src/liquidity/add_liquidity.rs | 89 ++++++++++++++++++ liquid-staking/src/liquidity/mod.rs | 4 + .../src/liquidity/remove_liquidity.rs | 0 liquid-staking/src/liquidity_pool.rs | 6 +- 12 files changed, 123 insertions(+), 122 deletions(-) create mode 100644 liquid-staking/src/liquidity/add_liquidity.rs create mode 100644 liquid-staking/src/liquidity/mod.rs create mode 100644 liquid-staking/src/liquidity/remove_liquidity.rs diff --git a/Cargo.lock b/Cargo.lock index be0d16d..64cb7a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,7 +247,6 @@ dependencies = [ name = "delegation-mock" version = "0.0.0" dependencies = [ - "itertools 0.10.5", "multiversx-sc", "multiversx-sc-scenario", ] @@ -394,15 +393,6 @@ version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.13.0" @@ -450,14 +440,13 @@ name = "liquid-staking" version = "0.0.0" dependencies = [ "delegation-mock", - "itertools 0.10.5", "multiversx-sc", "multiversx-sc-modules", "multiversx-sc-scenario", ] [[package]] -name = "liquid-staking-abi" +name = "liquid-staking-meta" version = "0.0.0" dependencies = [ "liquid-staking", @@ -512,7 +501,7 @@ dependencies = [ "ed25519-dalek", "hex", "hex-literal", - "itertools 0.13.0", + "itertools", "multiversx-chain-core", "multiversx-chain-vm-executor", "num-bigint", @@ -622,7 +611,7 @@ dependencies = [ "bech32", "colored", "hex", - "itertools 0.13.0", + "itertools", "log", "multiversx-chain-scenario-format", "multiversx-chain-vm", diff --git a/delegation-mock/Cargo.toml b/delegation-mock/Cargo.toml index b9d4cae..eebfa2f 100644 --- a/delegation-mock/Cargo.toml +++ b/delegation-mock/Cargo.toml @@ -11,9 +11,5 @@ path = "src/delegation.rs" [dependencies.multiversx-sc] version = "0.54.4" -[dependencies.itertools] -version = "0.10.1" -default-features = false - [dev-dependencies.multiversx-sc-scenario] version = "0.54.4" diff --git a/liquid-staking/Cargo.toml b/liquid-staking/Cargo.toml index 38812b9..bb7fe33 100644 --- a/liquid-staking/Cargo.toml +++ b/liquid-staking/Cargo.toml @@ -8,10 +8,6 @@ publish = false [lib] path = "src/lib.rs" -[dependencies.itertools] -version = "0.10.1" -default-features = false - [dependencies.multiversx-sc] version = "0.54.4" diff --git a/liquid-staking/meta/Cargo.toml b/liquid-staking/meta/Cargo.toml index b7930db..4fa1c46 100644 --- a/liquid-staking/meta/Cargo.toml +++ b/liquid-staking/meta/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "liquid-staking-abi" +name = "liquid-staking-meta" version = "0.0.0" authors = ["Sorin Petreasca "] edition = "2021" diff --git a/liquid-staking/src/config.rs b/liquid-staking/src/config.rs index 07a421e..3a85142 100644 --- a/liquid-staking/src/config.rs +++ b/liquid-staking/src/config.rs @@ -1,7 +1,7 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use super::liquidity_pool::State; +use crate::liquidity_pool::State; pub const MAX_PERCENTAGE: u64 = 100_000; pub const UNBOND_PERIOD: u64 = 10; diff --git a/liquid-staking/src/delegation.rs b/liquid-staking/src/delegation.rs index 3d77de7..a318f9e 100644 --- a/liquid-staking/src/delegation.rs +++ b/liquid-staking/src/delegation.rs @@ -1,6 +1,6 @@ use crate::{delegation_proxy, ERROR_BAD_WHITELIST_FEE}; -use super::errors::{ +use crate::errors::{ ERROR_ALREADY_WHITELISTED, ERROR_BAD_DELEGATION_ADDRESS, ERROR_CLAIM_EPOCH, ERROR_CLAIM_IN_PROGRESS, ERROR_DELEGATION_CAP, ERROR_FIRST_DELEGATION_NODE, ERROR_NOT_WHITELISTED, ERROR_NO_DELEGATION_CONTRACTS, ERROR_OLD_CLAIM_START, @@ -12,7 +12,7 @@ multiversx_sc::derive_imports!(); pub const MAX_DELEGATION_ADDRESSES: usize = 20; pub const EGLD_TO_WHITELIST: u64 = 1_000_000_000_000_000_000; pub const MIN_BLOCKS_BEFORE_CLEAR_ONGOING_OP: u64 = 10; -use super::liquidity_pool::State; +use crate::liquidity_pool::State; #[type_abi] #[derive(NestedEncode, NestedDecode, TopEncode, TopDecode, PartialEq, Eq, Clone)] @@ -57,7 +57,7 @@ pub struct DelegationContractData { #[multiversx_sc::module] pub trait DelegationModule: - super::config::ConfigModule + crate::config::ConfigModule + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule { #[only_owner] @@ -132,14 +132,12 @@ pub trait DelegationModule: .typed(delegation_proxy::DelegationMockProxy) .delegate() .egld(payment.clone()) - .callback( - DelegationModule::callbacks(self).whitelist_contract_callback( - caller, - contract_address, - contract_data, - apy, - ), - ) + .callback(self.callbacks().whitelist_contract_callback( + caller, + contract_address, + contract_data, + apy, + )) .async_call_and_exit(); } diff --git a/liquid-staking/src/events.rs b/liquid-staking/src/events.rs index 2774552..6b3d9a6 100644 --- a/liquid-staking/src/events.rs +++ b/liquid-staking/src/events.rs @@ -1,4 +1,4 @@ -use super::contexts::base::StorageCache; +use crate::contexts::base::StorageCache; multiversx_sc::imports!(); multiversx_sc::derive_imports!(); @@ -35,7 +35,7 @@ pub struct RemoveLiquidityEvent { #[multiversx_sc::module] pub trait EventsModule: - super::config::ConfigModule + crate::config::ConfigModule + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule { fn emit_add_liquidity_event( diff --git a/liquid-staking/src/lib.rs b/liquid-staking/src/lib.rs index 93c0f0a..c4e0dd8 100644 --- a/liquid-staking/src/lib.rs +++ b/liquid-staking/src/lib.rs @@ -18,11 +18,13 @@ pub mod delegation; mod delegation_proxy; pub mod errors; mod events; +mod liquidity; mod liquidity_pool; use { delegation::{ClaimStatus, ClaimStatusType}, errors::*, + liquidity::*, }; use config::{UnstakeTokenAttributes, UNBOND_PERIOD}; @@ -30,10 +32,11 @@ use contexts::base::*; use liquidity_pool::State; #[multiversx_sc::contract] -pub trait LiquidStaking: +pub trait LiquidStaking: liquidity_pool::LiquidityPoolModule + config::ConfigModule + events::EventsModule + + liquidity::AddLiquidity + delegation::DelegationModule + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule { @@ -54,83 +57,6 @@ pub trait LiquidStaking: #[upgrade] fn upgrade(&self) {} - #[payable("EGLD")] - #[endpoint(addLiquidity)] - fn add_liquidity(&self) { - self.blockchain().check_caller_is_user_account(); - let storage_cache = StorageCache::new(self); - let caller = self.blockchain().get_caller(); - - let payment = self.call_value().egld_value().clone_value(); - require!( - self.is_state_active(storage_cache.contract_state), - ERROR_NOT_ACTIVE - ); - if storage_cache.ls_token_supply == 0 { - require!( - caller == self.blockchain().get_owner_address(), - ERROR_DELEGATION_CONTRACT_NOT_INITIALIZED - ); - } - require!(payment > MIN_EGLD_TO_DELEGATE, ERROR_BAD_PAYMENT_AMOUNT); - - let delegation_contract = self.get_delegation_contract_for_delegate(&payment); - - let gas_for_async_call = self.get_gas_for_async_call(); - self.tx() - .to(delegation_contract.clone()) - .typed(delegation_proxy::DelegationMockProxy) - .delegate() - .egld(payment.clone()) - .gas(gas_for_async_call) - .callback(LiquidStaking::callbacks(self).add_liquidity_callback( - caller, - delegation_contract, - payment, - )) - .gas_for_callback(MIN_GAS_FOR_CALLBACK) - .register_promise(); - } - - #[promises_callback] - fn add_liquidity_callback( - &self, - caller: ManagedAddress, - delegation_contract: ManagedAddress, - staked_tokens: BigUint, - #[call_result] result: ManagedAsyncCallResult<()>, - ) { - match result { - ManagedAsyncCallResult::Ok(()) => { - let mut storage_cache = StorageCache::new(self); - self.delegation_contract_data(&delegation_contract) - .update(|contract_data| { - contract_data.total_staked_from_ls_contract += &staked_tokens; - }); - - let mut ls_token_amount_before_add = BigUint::zero(); - if storage_cache.ls_token_supply == 0 { - ls_token_amount_before_add += MINIMUM_LIQUIDITY; - } - let ls_token_amount = self.pool_add_liquidity(&staked_tokens, &mut storage_cache) - - ls_token_amount_before_add; - let user_payment = self.mint_ls_token(ls_token_amount); - self.send().direct_esdt( - &caller, - &user_payment.token_identifier, - user_payment.token_nonce, - &user_payment.amount, - ); - - self.emit_add_liquidity_event(&storage_cache, &caller, user_payment.amount); - } - ManagedAsyncCallResult::Err(_) => { - self.send().direct_egld(&caller, &staked_tokens); - self.move_delegation_contract_to_back(delegation_contract); - } - } - } - #[payable("*")] #[endpoint(removeLiquidity)] fn remove_liquidity(&self) { @@ -172,7 +98,7 @@ pub trait LiquidStaking: .typed(delegation_proxy::DelegationMockProxy) .undelegate(egld_to_unstake.clone()) .gas(gas_for_async_call) - .callback(LiquidStaking::callbacks(self).remove_liquidity_callback( + .callback(self.callbacks().remove_liquidity_callback( caller, delegation_contract, egld_to_unstake, @@ -309,7 +235,10 @@ pub trait LiquidStaking: .typed(delegation_proxy::DelegationMockProxy) .withdraw() .gas(gas_for_async_call) - .callback(LiquidStaking::callbacks(self).withdraw_tokens_callback(delegation_contract)) + .callback( + self.callbacks() + .withdraw_tokens_callback(delegation_contract), + ) .gas_for_callback(MIN_GAS_FOR_CALLBACK) .register_promise(); } @@ -372,7 +301,7 @@ pub trait LiquidStaking: .typed(delegation_proxy::DelegationMockProxy) .claim_rewards() .gas(DEFAULT_GAS_TO_CLAIM_REWARDS) - .callback(LiquidStaking::callbacks(self).claim_rewards_callback()) + .callback(self.callbacks().claim_rewards_callback()) .register_promise(); delegation_addresses.remove_node(¤t_node); @@ -459,7 +388,7 @@ pub trait LiquidStaking: .egld(rewards_reserve.clone()) .gas(gas_for_async_call) .callback( - LiquidStaking::callbacks(self) + self.callbacks() .delegate_rewards_callback(delegation_contract, rewards_reserve), ) .gas_for_callback(MIN_GAS_FOR_CALLBACK) diff --git a/liquid-staking/src/liquidity/add_liquidity.rs b/liquid-staking/src/liquidity/add_liquidity.rs new file mode 100644 index 0000000..0f0c01d --- /dev/null +++ b/liquid-staking/src/liquidity/add_liquidity.rs @@ -0,0 +1,89 @@ +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +use crate::{config, delegation_proxy, errors::*, StorageCache}; + +pub const MIN_EGLD_TO_DELEGATE: u64 = 1_000_000_000_000_000_000; +pub const MIN_GAS_FOR_CALLBACK: u64 = 12_000_000; +pub const MINIMUM_LIQUIDITY: u64 = 1_000; + +#[multiversx_sc::module] +pub trait AddLiquidity: + config::ConfigModule + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule +{ + #[payable("EGLD")] + #[endpoint(addLiquidity)] + fn add_liquidity(&self) { + self.blockchain().check_caller_is_user_account(); + let storage_cache = StorageCache::new(self); + let caller = self.blockchain().get_caller(); + + let payment = self.call_value().egld_value().clone_value(); + require!( + self.is_state_active(storage_cache.contract_state), + ERROR_NOT_ACTIVE + ); + if storage_cache.ls_token_supply == 0 { + require!( + caller == self.blockchain().get_owner_address(), + ERROR_DELEGATION_CONTRACT_NOT_INITIALIZED + ); + } + require!(payment > MIN_EGLD_TO_DELEGATE, ERROR_BAD_PAYMENT_AMOUNT); + + let delegation_contract = self.get_delegation_contract_for_delegate(&payment); + + let gas_for_async_call = self.get_gas_for_async_call(); + self.tx() + .to(delegation_contract.clone()) + .typed(delegation_proxy::DelegationMockProxy) + .delegate() + .egld(payment.clone()) + .gas(gas_for_async_call) + .callback( + self.callbacks() + .add_liquidity_callback(caller, delegation_contract, payment), + ) + .gas_for_callback(MIN_GAS_FOR_CALLBACK) + .register_promise(); + } + + #[promises_callback] + fn add_liquidity_callback( + &self, + caller: ManagedAddress, + delegation_contract: ManagedAddress, + staked_tokens: BigUint, + #[call_result] result: ManagedAsyncCallResult<()>, + ) { + match result { + ManagedAsyncCallResult::Ok(()) => { + let mut storage_cache = StorageCache::new(self); + self.delegation_contract_data(&delegation_contract) + .update(|contract_data| { + contract_data.total_staked_from_ls_contract += &staked_tokens; + }); + + let mut ls_token_amount_before_add = BigUint::zero(); + if storage_cache.ls_token_supply == 0 { + ls_token_amount_before_add += MINIMUM_LIQUIDITY; + } + let ls_token_amount = self.pool_add_liquidity(&staked_tokens, &mut storage_cache) + - ls_token_amount_before_add; + let user_payment = self.mint_ls_token(ls_token_amount); + self.send().direct_esdt( + &caller, + &user_payment.token_identifier, + user_payment.token_nonce, + &user_payment.amount, + ); + + self.emit_add_liquidity_event(&storage_cache, &caller, user_payment.amount); + } + ManagedAsyncCallResult::Err(_) => { + self.send().direct_egld(&caller, &staked_tokens); + self.move_delegation_contract_to_back(delegation_contract); + } + } + } +} diff --git a/liquid-staking/src/liquidity/mod.rs b/liquid-staking/src/liquidity/mod.rs new file mode 100644 index 0000000..86ab448 --- /dev/null +++ b/liquid-staking/src/liquidity/mod.rs @@ -0,0 +1,4 @@ +mod add_liquidity; +mod remove_liquidity; + +pub use add_liquidity::AddLiquidity; diff --git a/liquid-staking/src/liquidity/remove_liquidity.rs b/liquid-staking/src/liquidity/remove_liquidity.rs new file mode 100644 index 0000000..e69de29 diff --git a/liquid-staking/src/liquidity_pool.rs b/liquid-staking/src/liquidity_pool.rs index f36f5da..170f233 100644 --- a/liquid-staking/src/liquidity_pool.rs +++ b/liquid-staking/src/liquidity_pool.rs @@ -1,10 +1,10 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use super::contexts::base::StorageCache; -use super::errors::*; +use crate::contexts::base::StorageCache; +use crate::errors::*; -use super::config; +use crate::config; #[type_abi] #[derive(TopEncode, TopDecode, PartialEq, Eq, Copy, Clone, Debug)] From 0166e48e18a2a3092f8c6140329b75535aa83ad7 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Thu, 28 Nov 2024 10:27:08 +0200 Subject: [PATCH 03/22] module fix --- liquid-staking/src/lib.rs | 3 +-- liquid-staking/src/liquidity/mod.rs | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/liquid-staking/src/lib.rs b/liquid-staking/src/lib.rs index c4e0dd8..02865aa 100644 --- a/liquid-staking/src/lib.rs +++ b/liquid-staking/src/lib.rs @@ -24,7 +24,6 @@ mod liquidity_pool; use { delegation::{ClaimStatus, ClaimStatusType}, errors::*, - liquidity::*, }; use config::{UnstakeTokenAttributes, UNBOND_PERIOD}; @@ -36,7 +35,7 @@ pub trait LiquidStaking: liquidity_pool::LiquidityPoolModule + config::ConfigModule + events::EventsModule - + liquidity::AddLiquidity + + liquidity::add_liquidity::AddLiquidity + delegation::DelegationModule + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule { diff --git a/liquid-staking/src/liquidity/mod.rs b/liquid-staking/src/liquidity/mod.rs index 86ab448..06c8187 100644 --- a/liquid-staking/src/liquidity/mod.rs +++ b/liquid-staking/src/liquidity/mod.rs @@ -1,4 +1,2 @@ -mod add_liquidity; -mod remove_liquidity; - -pub use add_liquidity::AddLiquidity; +pub mod add_liquidity; +pub mod remove_liquidity; From da8173b4df6b25a8cf6f2b6e54a00a6bc4dabcca Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Thu, 28 Nov 2024 10:27:23 +0200 Subject: [PATCH 04/22] callback fix --- liquid-staking/src/delegation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liquid-staking/src/delegation.rs b/liquid-staking/src/delegation.rs index a318f9e..c2c6669 100644 --- a/liquid-staking/src/delegation.rs +++ b/liquid-staking/src/delegation.rs @@ -132,7 +132,7 @@ pub trait DelegationModule: .typed(delegation_proxy::DelegationMockProxy) .delegate() .egld(payment.clone()) - .callback(self.callbacks().whitelist_contract_callback( + .callback(DelegationModule::callbacks(self).whitelist_contract_callback( caller, contract_address, contract_data, From a73369bf2604e6d072489a293c559292e0e949a6 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Thu, 28 Nov 2024 11:50:57 +0200 Subject: [PATCH 05/22] split SC in modules --- delegation-mock/wasm/Cargo.lock | 16 - liquid-staking/src/basics/constants.rs | 8 + liquid-staking/src/{ => basics}/errors.rs | 12 +- liquid-staking/src/{ => basics}/events.rs | 4 +- liquid-staking/src/basics/mod.rs | 4 + liquid-staking/src/basics/views.rs | 18 + liquid-staking/src/delegation.rs | 35 +- liquid-staking/src/funds/claim.rs | 80 ++++ liquid-staking/src/funds/delegate_rewards.rs | 86 ++++ liquid-staking/src/funds/mod.rs | 5 + .../src/funds/recompute_token_reserve.rs | 46 ++ liquid-staking/src/funds/unbond.rs | 68 +++ liquid-staking/src/funds/withdraw.rs | 56 +++ liquid-staking/src/lib.rs | 425 +----------------- liquid-staking/src/liquidity/add_liquidity.rs | 31 +- .../src/liquidity/remove_liquidity.rs | 135 ++++++ liquid-staking/src/liquidity_pool.rs | 2 +- .../tests/contract_interactions/mod.rs | 13 +- liquid-staking/wasm/Cargo.lock | 17 - liquid-staking/wasm/src/lib.rs | 20 +- 20 files changed, 595 insertions(+), 486 deletions(-) create mode 100644 liquid-staking/src/basics/constants.rs rename liquid-staking/src/{ => basics}/errors.rs (83%) rename liquid-staking/src/{ => basics}/events.rs (100%) create mode 100644 liquid-staking/src/basics/mod.rs create mode 100644 liquid-staking/src/basics/views.rs create mode 100644 liquid-staking/src/funds/claim.rs create mode 100644 liquid-staking/src/funds/delegate_rewards.rs create mode 100644 liquid-staking/src/funds/mod.rs create mode 100644 liquid-staking/src/funds/recompute_token_reserve.rs create mode 100644 liquid-staking/src/funds/unbond.rs create mode 100644 liquid-staking/src/funds/withdraw.rs diff --git a/delegation-mock/wasm/Cargo.lock b/delegation-mock/wasm/Cargo.lock index da4b1aa..6896fe1 100644 --- a/delegation-mock/wasm/Cargo.lock +++ b/delegation-mock/wasm/Cargo.lock @@ -24,7 +24,6 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" name = "delegation-mock" version = "0.0.0" dependencies = [ - "itertools", "multiversx-sc", ] @@ -36,12 +35,6 @@ dependencies = [ "multiversx-sc-wasm-adapter", ] -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - [[package]] name = "endian-type" version = "0.1.2" @@ -60,15 +53,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - [[package]] name = "multiversx-chain-core" version = "0.11.1" diff --git a/liquid-staking/src/basics/constants.rs b/liquid-staking/src/basics/constants.rs new file mode 100644 index 0000000..22a8051 --- /dev/null +++ b/liquid-staking/src/basics/constants.rs @@ -0,0 +1,8 @@ +pub const DEFAULT_GAS_TO_CLAIM_REWARDS: u64 = 6_000_000; +pub const MIN_GAS_FOR_ASYNC_CALL: u64 = 12_000_000; +pub const MIN_GAS_FOR_CALLBACK: u64 = 12_000_000; +pub const MIN_EGLD_TO_DELEGATE: u64 = 1_000_000_000_000_000_000; +pub const RECOMPUTE_BLOCK_OFFSET: u64 = 10; +pub const MINIMUM_LIQUIDITY: u64 = 1_000; +pub const DEFAULT_MIN_GAS_TO_SAVE_PROGRESS: u64 = 30_000_000; +pub const MIN_GAS_FINISH_EXEC: u64 = 20_000_000; diff --git a/liquid-staking/src/errors.rs b/liquid-staking/src/basics/errors.rs similarity index 83% rename from liquid-staking/src/errors.rs rename to liquid-staking/src/basics/errors.rs index 92712a0..eb8964c 100644 --- a/liquid-staking/src/errors.rs +++ b/liquid-staking/src/basics/errors.rs @@ -1,11 +1,11 @@ -pub static ERROR_ACTIVE: &[u8] = b"Active state"; +//pub static ERROR_ACTIVE: &[u8] = b"Active state"; pub static ERROR_NOT_ACTIVE: &[u8] = b"Not active"; pub static ERROR_LS_TOKEN_NOT_ISSUED: &[u8] = b"LS token not issued"; pub static ERROR_DELEGATION_CONTRACT_NOT_INITIALIZED: &[u8] = b"Delegation contract was not initialized yet"; pub static ERROR_INSUFFICIENT_GAS: &[u8] = b"Insufficient gas remaining for the callback"; -pub static ERROR_CLAIM_START: &[u8] = b"Claim operation must be new or pending"; +//pub static ERROR_CLAIM_START: &[u8] = b"Claim operation must be new or pending"; pub static ERROR_CLAIM_IN_PROGRESS: &[u8] = b"Claim operation is already in progress"; pub static ERROR_OLD_CLAIM_START: &[u8] = b"Previous claimed rewards must be redelegated or lesser than 1 EGLD"; @@ -19,12 +19,12 @@ pub static ERROR_BAD_PAYMENT_TOKEN: &[u8] = b"Bad payment token"; pub static ERROR_BAD_PAYMENT_AMOUNT: &[u8] = b"Insufficient delegated amount"; pub static ERROR_BAD_WHITELIST_FEE: &[u8] = b"Whitelisting contracts costs 1 EGLD"; pub static ERROR_INSUFFICIENT_UNSTAKE_AMOUNT: &[u8] = b"Insufficient unstake amount"; -pub static ERROR_INSUFFICIENT_UNBONDED_AMOUNT: &[u8] = b"Insufficient incoming withdraw amount"; +//pub static ERROR_INSUFFICIENT_UNBONDED_AMOUNT: &[u8] = b"Insufficient incoming withdraw amount"; pub static ERROR_INSUFFICIENT_LIQUIDITY: &[u8] = b"Insufficient liquidity minted"; pub static ERROR_INSUFFICIENT_LIQ_BURNED: &[u8] = b"Insufficient liquidity burned"; -pub static ERROR_NOT_ENOUGH_RESERVE: &[u8] = b"Not enough reserve"; -pub static ERROR_NOT_ENOUGH_LP: &[u8] = b"Not enough LP token supply"; +//pub static ERROR_NOT_ENOUGH_RESERVE: &[u8] = b"Not enough reserve"; +//pub static ERROR_NOT_ENOUGH_LP: &[u8] = b"Not enough LP token supply"; pub static ERROR_BAD_DELEGATION_ADDRESS: &[u8] = b"No delegation contract available"; pub static ERROR_BAD_DELEGATION_AMOUNT: &[u8] = b"Delegation amount must be at least 1 EGLD"; @@ -36,4 +36,4 @@ pub static ERROR_DELEGATION_CAP: &[u8] = b"Delegation cap must be higher than the total staked amount"; pub static ERROR_ONLY_DELEGATION_ADMIN: &[u8] = b"Only the admin of the delegation contract can change the status"; -pub static ERROR_NOTHING_TO_UNBOND: &[u8] = b"Nothing to unbond"; +//pub static ERROR_NOTHING_TO_UNBOND: &[u8] = b"Nothing to unbond"; diff --git a/liquid-staking/src/events.rs b/liquid-staking/src/basics/events.rs similarity index 100% rename from liquid-staking/src/events.rs rename to liquid-staking/src/basics/events.rs index 6b3d9a6..4630bc0 100644 --- a/liquid-staking/src/events.rs +++ b/liquid-staking/src/basics/events.rs @@ -1,8 +1,8 @@ -use crate::contexts::base::StorageCache; - multiversx_sc::imports!(); multiversx_sc::derive_imports!(); +use crate::contexts::base::StorageCache; + #[type_abi] #[derive(TopEncode)] pub struct AddLiquidityEvent { diff --git a/liquid-staking/src/basics/mod.rs b/liquid-staking/src/basics/mod.rs new file mode 100644 index 0000000..4b646a9 --- /dev/null +++ b/liquid-staking/src/basics/mod.rs @@ -0,0 +1,4 @@ +pub mod constants; +pub mod errors; +pub mod events; +pub mod views; diff --git a/liquid-staking/src/basics/views.rs b/liquid-staking/src/basics/views.rs new file mode 100644 index 0000000..5f40dc9 --- /dev/null +++ b/liquid-staking/src/basics/views.rs @@ -0,0 +1,18 @@ +multiversx_sc::imports!(); + +use crate::{contexts::base::StorageCache, liquidity_pool}; + +#[multiversx_sc::module] +pub trait ViewsModule: + crate::config::ConfigModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + liquidity_pool::LiquidityPoolModule +{ + // views + #[view(getLsValueForPosition)] + fn get_ls_value_for_position(&self, ls_token_amount: BigUint) -> BigUint { + let mut storage_cache = StorageCache::new(self); + storage_cache.skip_commit = true; + self.get_egld_amount(&ls_token_amount, &storage_cache) + } +} diff --git a/liquid-staking/src/delegation.rs b/liquid-staking/src/delegation.rs index c2c6669..e284c71 100644 --- a/liquid-staking/src/delegation.rs +++ b/liquid-staking/src/delegation.rs @@ -1,13 +1,18 @@ -use crate::{delegation_proxy, ERROR_BAD_WHITELIST_FEE}; +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); -use crate::errors::{ +use crate::basics::constants::{MIN_GAS_FINISH_EXEC, MIN_GAS_FOR_ASYNC_CALL, MIN_GAS_FOR_CALLBACK}; +use crate::{ + basics::errors::{ERROR_BAD_WHITELIST_FEE, ERROR_INSUFFICIENT_GAS}, + delegation_proxy, +}; + +use crate::basics::errors::{ ERROR_ALREADY_WHITELISTED, ERROR_BAD_DELEGATION_ADDRESS, ERROR_CLAIM_EPOCH, ERROR_CLAIM_IN_PROGRESS, ERROR_DELEGATION_CAP, ERROR_FIRST_DELEGATION_NODE, ERROR_NOT_WHITELISTED, ERROR_NO_DELEGATION_CONTRACTS, ERROR_OLD_CLAIM_START, ERROR_ONLY_DELEGATION_ADMIN, }; -multiversx_sc::imports!(); -multiversx_sc::derive_imports!(); pub const MAX_DELEGATION_ADDRESSES: usize = 20; pub const EGLD_TO_WHITELIST: u64 = 1_000_000_000_000_000_000; @@ -132,12 +137,14 @@ pub trait DelegationModule: .typed(delegation_proxy::DelegationMockProxy) .delegate() .egld(payment.clone()) - .callback(DelegationModule::callbacks(self).whitelist_contract_callback( - caller, - contract_address, - contract_data, - apy, - )) + .callback( + DelegationModule::callbacks(self).whitelist_contract_callback( + caller, + contract_address, + contract_data, + apy, + ), + ) .async_call_and_exit(); } @@ -258,6 +265,14 @@ pub trait DelegationModule: } } + fn get_gas_for_async_call(&self) -> u64 { + let gas_left = self.blockchain().get_gas_left(); + require!( + gas_left > MIN_GAS_FOR_ASYNC_CALL + MIN_GAS_FOR_CALLBACK + MIN_GAS_FINISH_EXEC, + ERROR_INSUFFICIENT_GAS + ); + gas_left - MIN_GAS_FOR_CALLBACK - MIN_GAS_FINISH_EXEC + } fn move_delegation_contract_to_back(&self, delegation_contract: ManagedAddress) { self.remove_delegation_address_from_list(&delegation_contract); self.delegation_addresses_list() diff --git a/liquid-staking/src/funds/claim.rs b/liquid-staking/src/funds/claim.rs new file mode 100644 index 0000000..cfaf906 --- /dev/null +++ b/liquid-staking/src/funds/claim.rs @@ -0,0 +1,80 @@ +multiversx_sc::imports!(); + +use crate::{ + basics::constants::{DEFAULT_GAS_TO_CLAIM_REWARDS, DEFAULT_MIN_GAS_TO_SAVE_PROGRESS}, + basics::errors::{ERROR_NOT_ACTIVE, ERROR_NO_DELEGATION_CONTRACTS}, + config::{self}, + delegation::{self, ClaimStatusType}, + delegation_proxy, StorageCache, +}; + +#[multiversx_sc::module] +pub trait ClaimModule: + config::ConfigModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + delegation::DelegationModule +{ + #[endpoint(claimRewards)] + fn claim_rewards(&self) { + let storage_cache = StorageCache::new(self); + + require!( + self.is_state_active(storage_cache.contract_state), + ERROR_NOT_ACTIVE + ); + + let delegation_addresses_mapper = self.delegation_addresses_list(); + require!( + !delegation_addresses_mapper.is_empty(), + ERROR_NO_DELEGATION_CONTRACTS + ); + let claim_status_mapper = self.delegation_claim_status(); + let old_claim_status = claim_status_mapper.get(); + let current_epoch = self.blockchain().get_block_epoch(); + + self.check_claim_operation(old_claim_status, current_epoch); + let mut delegation_addresses = self.addresses_to_claim(); + if delegation_addresses.is_empty() { + self.prepare_claim_operation(); + } + + while !delegation_addresses.is_empty() { + let gas_left = self.blockchain().get_gas_left(); + if gas_left < DEFAULT_MIN_GAS_TO_SAVE_PROGRESS { + break; + } + + let current_node = delegation_addresses.pop_back().unwrap(); + let address = current_node.clone().into_value(); + + self.tx() + .to(&address) + .typed(delegation_proxy::DelegationMockProxy) + .claim_rewards() + .gas(DEFAULT_GAS_TO_CLAIM_REWARDS) + .callback(ClaimModule::callbacks(self).claim_rewards_callback()) + .register_promise(); + + delegation_addresses.remove_node(¤t_node); + } + + if delegation_addresses.is_empty() { + claim_status_mapper.update(|claim_status| { + claim_status.status = ClaimStatusType::Finished; + claim_status.last_claim_block = self.blockchain().get_block_nonce(); + claim_status.last_claim_epoch = self.blockchain().get_block_epoch(); + }); + } + } + + #[promises_callback] + fn claim_rewards_callback(&self, #[call_result] result: ManagedAsyncCallResult<()>) { + match result { + ManagedAsyncCallResult::Ok(_) => { + let payment = self.call_value().egld_value().clone_value(); + self.rewards_reserve().update(|value| *value += payment); + } + ManagedAsyncCallResult::Err(_) => {} + } + } +} diff --git a/liquid-staking/src/funds/delegate_rewards.rs b/liquid-staking/src/funds/delegate_rewards.rs new file mode 100644 index 0000000..3a50ed7 --- /dev/null +++ b/liquid-staking/src/funds/delegate_rewards.rs @@ -0,0 +1,86 @@ +multiversx_sc::imports!(); + +use crate::{ + basics, + basics::constants::{MIN_EGLD_TO_DELEGATE, MIN_GAS_FOR_CALLBACK}, + basics::errors::{ERROR_BAD_DELEGATION_AMOUNT, ERROR_CLAIM_REDELEGATE, ERROR_NOT_ACTIVE}, + config, + delegation::{self, ClaimStatusType}, + delegation_proxy, StorageCache, +}; + +#[multiversx_sc::module] +pub trait DelegateRewardsModule: + config::ConfigModule + + delegation::DelegationModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + basics::events::EventsModule +{ + #[endpoint(delegateRewards)] + fn delegate_rewards(&self) { + let storage_cache = StorageCache::new(self); + let claim_status = self.delegation_claim_status().get(); + require!( + self.is_state_active(storage_cache.contract_state), + ERROR_NOT_ACTIVE + ); + require!( + claim_status.status == ClaimStatusType::Delegable, + ERROR_CLAIM_REDELEGATE + ); + + let rewards_reserve = self.rewards_reserve().get(); + self.rewards_reserve().set(BigUint::zero()); + + require!( + rewards_reserve >= MIN_EGLD_TO_DELEGATE, + ERROR_BAD_DELEGATION_AMOUNT + ); + + let delegation_contract = self.get_delegation_contract_for_delegate(&rewards_reserve); + + let gas_for_async_call = self.get_gas_for_async_call(); + self.tx() + .to(delegation_contract.clone()) + .typed(delegation_proxy::DelegationMockProxy) + .delegate() + .egld(rewards_reserve.clone()) + .gas(gas_for_async_call) + .callback( + DelegateRewardsModule::callbacks(self) + .delegate_rewards_callback(delegation_contract, rewards_reserve), + ) + .gas_for_callback(MIN_GAS_FOR_CALLBACK) + .register_promise(); + } + + #[promises_callback] + fn delegate_rewards_callback( + &self, + delegation_contract: ManagedAddress, + staked_tokens: BigUint, + #[call_result] result: ManagedAsyncCallResult<()>, + ) { + let mut storage_cache = StorageCache::new(self); + match result { + ManagedAsyncCallResult::Ok(()) => { + self.delegation_contract_data(&delegation_contract) + .update(|contract_data| { + contract_data.total_staked_from_ls_contract += &staked_tokens; + }); + + self.delegation_claim_status() + .update(|claim_status| claim_status.status = ClaimStatusType::Redelegated); + + storage_cache.virtual_egld_reserve += &staked_tokens; + let sc_address = self.blockchain().get_sc_address(); + self.emit_add_liquidity_event(&storage_cache, &sc_address, BigUint::zero()); + } + ManagedAsyncCallResult::Err(_) => { + self.move_delegation_contract_to_back(delegation_contract); + self.rewards_reserve() + .update(|value| *value += staked_tokens) + } + } + } +} diff --git a/liquid-staking/src/funds/mod.rs b/liquid-staking/src/funds/mod.rs new file mode 100644 index 0000000..2e33a74 --- /dev/null +++ b/liquid-staking/src/funds/mod.rs @@ -0,0 +1,5 @@ +pub mod claim; +pub mod delegate_rewards; +pub mod recompute_token_reserve; +pub mod unbond; +pub mod withdraw; diff --git a/liquid-staking/src/funds/recompute_token_reserve.rs b/liquid-staking/src/funds/recompute_token_reserve.rs new file mode 100644 index 0000000..2ff3370 --- /dev/null +++ b/liquid-staking/src/funds/recompute_token_reserve.rs @@ -0,0 +1,46 @@ +multiversx_sc::imports!(); + +use crate::{ + basics::constants::{MIN_EGLD_TO_DELEGATE, RECOMPUTE_BLOCK_OFFSET}, + basics::errors::{ERROR_NOT_ACTIVE, ERROR_RECOMPUTE_RESERVES, ERROR_RECOMPUTE_TOO_SOON}, + config, + delegation::{self, ClaimStatusType}, + StorageCache, +}; + +#[multiversx_sc::module] +pub trait RecomputeTokenReserveModule: + config::ConfigModule + + delegation::DelegationModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule +{ + #[endpoint(recomputeTokenReserve)] + fn recompute_token_reserve(&self) { + let storage_cache = StorageCache::new(self); + let claim_status_mapper = self.delegation_claim_status(); + let mut claim_status = claim_status_mapper.get(); + + require!( + self.is_state_active(storage_cache.contract_state), + ERROR_NOT_ACTIVE + ); + require!( + claim_status.status == ClaimStatusType::Finished, + ERROR_RECOMPUTE_RESERVES + ); + + let current_block = self.blockchain().get_block_nonce(); + require!( + current_block >= claim_status.last_claim_block + RECOMPUTE_BLOCK_OFFSET, + ERROR_RECOMPUTE_TOO_SOON + ); + + if self.rewards_reserve().get() >= MIN_EGLD_TO_DELEGATE { + claim_status.status = ClaimStatusType::Delegable; + } else { + claim_status.status = ClaimStatusType::Insufficient; + } + + claim_status_mapper.set(claim_status); + } +} diff --git a/liquid-staking/src/funds/unbond.rs b/liquid-staking/src/funds/unbond.rs new file mode 100644 index 0000000..191bd52 --- /dev/null +++ b/liquid-staking/src/funds/unbond.rs @@ -0,0 +1,68 @@ +multiversx_sc::imports!(); + +use crate::{ + basics::errors::{ + ERROR_BAD_PAYMENT_AMOUNT, ERROR_BAD_PAYMENT_TOKEN, ERROR_NOT_ACTIVE, + ERROR_UNSTAKE_PERIOD_NOT_PASSED, + }, + config::{self, UnstakeTokenAttributes}, + delegation, liquidity_pool, StorageCache, +}; + +#[multiversx_sc::module] +pub trait UnbondModule: + config::ConfigModule + + delegation::DelegationModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + liquidity_pool::LiquidityPoolModule +{ + #[payable("*")] + #[endpoint(unbondTokens)] + fn unbond_tokens(&self) { + self.blockchain().check_caller_is_user_account(); + let storage_cache = StorageCache::new(self); + let payment = self.call_value().single_esdt(); + let caller = self.blockchain().get_caller(); + + require!( + self.is_state_active(storage_cache.contract_state), + ERROR_NOT_ACTIVE + ); + + require!( + payment.token_identifier == self.unstake_token().get_token_id(), + ERROR_BAD_PAYMENT_TOKEN + ); + require!(payment.amount > 0, ERROR_BAD_PAYMENT_AMOUNT); + + let mut total_unstake_amount = BigUint::zero(); + + let unstake_token_attributes: UnstakeTokenAttributes = self + .unstake_token() + .get_token_attributes(payment.token_nonce); + + let current_epoch = self.blockchain().get_block_epoch(); + require!( + current_epoch >= unstake_token_attributes.unbond_epoch, + ERROR_UNSTAKE_PERIOD_NOT_PASSED + ); + + let delegation_contract = unstake_token_attributes.delegation_contract.clone(); + let unstake_amount = unstake_token_attributes.unstake_amount.clone(); + let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); + let delegation_contract_data = delegation_contract_mapper.get(); + + require!( + delegation_contract_data.total_unbonded_from_ls_contract >= unstake_amount, + "Nothing to unbond" + ); + delegation_contract_mapper.update(|contract_data| { + contract_data.total_unstaked_from_ls_contract -= &unstake_amount; + contract_data.total_unbonded_from_ls_contract -= &unstake_amount + }); + + total_unstake_amount += unstake_amount; + self.burn_unstake_tokens(payment.token_nonce); + self.send().direct_egld(&caller, &total_unstake_amount); + } +} diff --git a/liquid-staking/src/funds/withdraw.rs b/liquid-staking/src/funds/withdraw.rs new file mode 100644 index 0000000..59267b4 --- /dev/null +++ b/liquid-staking/src/funds/withdraw.rs @@ -0,0 +1,56 @@ +multiversx_sc::imports!(); + +use crate::{ + basics::constants::MIN_GAS_FOR_CALLBACK, + basics::errors::ERROR_NOT_ACTIVE, + config::{self}, + delegation, delegation_proxy, StorageCache, +}; + +#[multiversx_sc::module] +pub trait WithdrawModule: + config::ConfigModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + delegation::DelegationModule +{ + #[endpoint(withdrawAll)] + fn withdraw_all(&self, delegation_contract: ManagedAddress) { + self.blockchain().check_caller_is_user_account(); + let storage_cache = StorageCache::new(self); + + require!( + self.is_state_active(storage_cache.contract_state), + ERROR_NOT_ACTIVE + ); + + let gas_for_async_call = self.get_gas_for_async_call(); + self.tx() + .to(delegation_contract.clone()) + .typed(delegation_proxy::DelegationMockProxy) + .withdraw() + .gas(gas_for_async_call) + .callback(WithdrawModule::callbacks(self).withdraw_tokens_callback(delegation_contract)) + .gas_for_callback(MIN_GAS_FOR_CALLBACK) + .register_promise(); + } + + #[promises_callback] + fn withdraw_tokens_callback( + &self, + provider: ManagedAddress, + #[call_result] result: ManagedAsyncCallResult<()>, + ) { + match result { + ManagedAsyncCallResult::Ok(()) => { + let withdraw_amount = self.call_value().egld_value().clone_value(); + let delegation_contract_mapper = self.delegation_contract_data(&provider); + if withdraw_amount > 0u64 { + delegation_contract_mapper.update(|contract_data| { + contract_data.total_unbonded_from_ls_contract += &withdraw_amount + }); + } + } + ManagedAsyncCallResult::Err(_) => {} + } + } +} diff --git a/liquid-staking/src/lib.rs b/liquid-staking/src/lib.rs index 02865aa..1662f27 100644 --- a/liquid-staking/src/lib.rs +++ b/liquid-staking/src/lib.rs @@ -3,40 +3,34 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -pub const DEFAULT_GAS_TO_CLAIM_REWARDS: u64 = 6_000_000; -pub const MIN_GAS_FOR_ASYNC_CALL: u64 = 12_000_000; -pub const MIN_GAS_FOR_CALLBACK: u64 = 12_000_000; -pub const MIN_EGLD_TO_DELEGATE: u64 = 1_000_000_000_000_000_000; -pub const RECOMPUTE_BLOCK_OFFSET: u64 = 10; -pub const MINIMUM_LIQUIDITY: u64 = 1_000; -pub const DEFAULT_MIN_GAS_TO_SAVE_PROGRESS: u64 = 30_000_000; -pub const MIN_GAS_FINISH_EXEC: u64 = 20_000_000; - +pub mod basics; pub mod config; -mod contexts; +pub mod contexts; pub mod delegation; -mod delegation_proxy; -pub mod errors; -mod events; -mod liquidity; -mod liquidity_pool; +pub mod delegation_proxy; +pub mod funds; +pub mod liquidity; +pub mod liquidity_pool; -use { - delegation::{ClaimStatus, ClaimStatusType}, - errors::*, -}; +use delegation::{ClaimStatus, ClaimStatusType}; -use config::{UnstakeTokenAttributes, UNBOND_PERIOD}; use contexts::base::*; use liquidity_pool::State; #[multiversx_sc::contract] pub trait LiquidStaking: - liquidity_pool::LiquidityPoolModule + basics::events::EventsModule + + basics::views::ViewsModule + config::ConfigModule - + events::EventsModule - + liquidity::add_liquidity::AddLiquidity + delegation::DelegationModule + + funds::claim::ClaimModule + + funds::delegate_rewards::DelegateRewardsModule + + funds::recompute_token_reserve::RecomputeTokenReserveModule + + funds::unbond::UnbondModule + + funds::withdraw::WithdrawModule + + liquidity::add_liquidity::AddLiquidityModule + + liquidity::remove_liquidity::RemoveLiquidityModule + + liquidity_pool::LiquidityPoolModule + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule { #[init] @@ -55,389 +49,4 @@ pub trait LiquidStaking: #[upgrade] fn upgrade(&self) {} - - #[payable("*")] - #[endpoint(removeLiquidity)] - fn remove_liquidity(&self) { - self.blockchain().check_caller_is_user_account(); - let mut storage_cache = StorageCache::new(self); - let caller = self.blockchain().get_caller(); - let payment = self.call_value().single_esdt(); - - require!( - self.is_state_active(storage_cache.contract_state), - ERROR_NOT_ACTIVE - ); - require!( - storage_cache.ls_token_id.is_valid_esdt_identifier(), - ERROR_LS_TOKEN_NOT_ISSUED - ); - require!( - payment.token_identifier == storage_cache.ls_token_id, - ERROR_BAD_PAYMENT_TOKEN - ); - require!(payment.amount > 0, ERROR_BAD_PAYMENT_AMOUNT); - - let egld_to_unstake = self.pool_remove_liquidity(&payment.amount, &mut storage_cache); - require!( - egld_to_unstake >= MIN_EGLD_TO_DELEGATE, - ERROR_INSUFFICIENT_UNSTAKE_AMOUNT - ); - self.burn_ls_token(&payment.amount); - - let delegation_contract = self.get_delegation_contract_for_undelegate(&egld_to_unstake); - - let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); - delegation_contract_mapper - .update(|contract_data| contract_data.egld_in_ongoing_undelegation += &egld_to_unstake); - - let gas_for_async_call = self.get_gas_for_async_call(); - self.tx() - .to(delegation_contract.clone()) - .typed(delegation_proxy::DelegationMockProxy) - .undelegate(egld_to_unstake.clone()) - .gas(gas_for_async_call) - .callback(self.callbacks().remove_liquidity_callback( - caller, - delegation_contract, - egld_to_unstake, - payment.amount, - )) - .gas_for_callback(MIN_GAS_FOR_CALLBACK) - .register_promise(); - } - - #[promises_callback] - fn remove_liquidity_callback( - &self, - caller: ManagedAddress, - delegation_contract: ManagedAddress, - egld_to_unstake: BigUint, - ls_tokens_to_be_burned: BigUint, - #[call_result] result: ManagedAsyncCallResult<()>, - ) { - let mut storage_cache = StorageCache::new(self); - let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); - - delegation_contract_mapper.update(|contract_data| { - contract_data.egld_in_ongoing_undelegation -= &egld_to_unstake; - }); - - match result { - ManagedAsyncCallResult::Ok(()) => { - let current_epoch = self.blockchain().get_block_epoch(); - let unbond_epoch = current_epoch + UNBOND_PERIOD; - - delegation_contract_mapper.update(|contract_data| { - contract_data.total_staked_from_ls_contract -= &egld_to_unstake; - contract_data.total_unstaked_from_ls_contract += &egld_to_unstake; - }); - - let virtual_position = UnstakeTokenAttributes { - delegation_contract, - unstake_epoch: current_epoch, - unstake_amount: egld_to_unstake, - unbond_epoch, - }; - - let user_payment = self.mint_unstake_tokens(&virtual_position); - self.send().direct_esdt( - &caller, - &user_payment.token_identifier, - user_payment.token_nonce, - &user_payment.amount, - ); - - self.emit_remove_liquidity_event( - &storage_cache, - ls_tokens_to_be_burned, - user_payment.amount, - ); - } - ManagedAsyncCallResult::Err(_) => { - let ls_token_amount = self.pool_add_liquidity(&egld_to_unstake, &mut storage_cache); - let user_payment = self.mint_ls_token(ls_token_amount); - self.send().direct_esdt( - &caller, - &user_payment.token_identifier, - user_payment.token_nonce, - &user_payment.amount, - ); - self.move_delegation_contract_to_back(delegation_contract); - } - } - } - - #[payable("*")] - #[endpoint(unbondTokens)] - fn unbond_tokens(&self) { - self.blockchain().check_caller_is_user_account(); - let storage_cache = StorageCache::new(self); - let payment = self.call_value().single_esdt(); - let caller = self.blockchain().get_caller(); - - require!( - self.is_state_active(storage_cache.contract_state), - ERROR_NOT_ACTIVE - ); - - require!( - payment.token_identifier == self.unstake_token().get_token_id(), - ERROR_BAD_PAYMENT_TOKEN - ); - require!(payment.amount > 0, ERROR_BAD_PAYMENT_AMOUNT); - - let mut total_unstake_amount = BigUint::zero(); - - let unstake_token_attributes: UnstakeTokenAttributes = self - .unstake_token() - .get_token_attributes(payment.token_nonce); - - let current_epoch = self.blockchain().get_block_epoch(); - require!( - current_epoch >= unstake_token_attributes.unbond_epoch, - ERROR_UNSTAKE_PERIOD_NOT_PASSED - ); - - let delegation_contract = unstake_token_attributes.delegation_contract.clone(); - let unstake_amount = unstake_token_attributes.unstake_amount.clone(); - let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); - let delegation_contract_data = delegation_contract_mapper.get(); - - require!( - delegation_contract_data.total_unbonded_from_ls_contract >= unstake_amount, - "Nothing to unbond" - ); - delegation_contract_mapper.update(|contract_data| { - contract_data.total_unstaked_from_ls_contract -= &unstake_amount; - contract_data.total_unbonded_from_ls_contract -= &unstake_amount - }); - - total_unstake_amount += unstake_amount; - self.burn_unstake_tokens(payment.token_nonce); - self.send().direct_egld(&caller, &total_unstake_amount); - } - - #[endpoint(withdrawAll)] - fn withdraw_all(&self, delegation_contract: ManagedAddress) { - self.blockchain().check_caller_is_user_account(); - let storage_cache = StorageCache::new(self); - - require!( - self.is_state_active(storage_cache.contract_state), - ERROR_NOT_ACTIVE - ); - - let gas_for_async_call = self.get_gas_for_async_call(); - self.tx() - .to(delegation_contract.clone()) - .typed(delegation_proxy::DelegationMockProxy) - .withdraw() - .gas(gas_for_async_call) - .callback( - self.callbacks() - .withdraw_tokens_callback(delegation_contract), - ) - .gas_for_callback(MIN_GAS_FOR_CALLBACK) - .register_promise(); - } - - #[promises_callback] - fn withdraw_tokens_callback( - &self, - provider: ManagedAddress, - #[call_result] result: ManagedAsyncCallResult<()>, - ) { - match result { - ManagedAsyncCallResult::Ok(()) => { - let withdraw_amount = self.call_value().egld_value().clone_value(); - let delegation_contract_mapper = self.delegation_contract_data(&provider); - if withdraw_amount > 0u64 { - delegation_contract_mapper.update(|contract_data| { - contract_data.total_unbonded_from_ls_contract += &withdraw_amount - }); - } - } - ManagedAsyncCallResult::Err(_) => {} - } - } - - #[endpoint(claimRewards)] - fn claim_rewards(&self) { - let storage_cache = StorageCache::new(self); - - require!( - self.is_state_active(storage_cache.contract_state), - ERROR_NOT_ACTIVE - ); - - let delegation_addresses_mapper = self.delegation_addresses_list(); - require!( - !delegation_addresses_mapper.is_empty(), - ERROR_NO_DELEGATION_CONTRACTS - ); - let claim_status_mapper = self.delegation_claim_status(); - let old_claim_status = claim_status_mapper.get(); - let current_epoch = self.blockchain().get_block_epoch(); - - self.check_claim_operation(old_claim_status, current_epoch); - let mut delegation_addresses = self.addresses_to_claim(); - if delegation_addresses.is_empty() { - self.prepare_claim_operation(); - } - - while !delegation_addresses.is_empty() { - let gas_left = self.blockchain().get_gas_left(); - if gas_left < DEFAULT_MIN_GAS_TO_SAVE_PROGRESS { - break; - } - - let current_node = delegation_addresses.pop_back().unwrap(); - let address = current_node.clone().into_value(); - - self.tx() - .to(&address) - .typed(delegation_proxy::DelegationMockProxy) - .claim_rewards() - .gas(DEFAULT_GAS_TO_CLAIM_REWARDS) - .callback(self.callbacks().claim_rewards_callback()) - .register_promise(); - - delegation_addresses.remove_node(¤t_node); - } - - if delegation_addresses.is_empty() { - claim_status_mapper.update(|claim_status| { - claim_status.status = ClaimStatusType::Finished; - claim_status.last_claim_block = self.blockchain().get_block_nonce(); - claim_status.last_claim_epoch = self.blockchain().get_block_epoch(); - }); - } - } - - #[promises_callback] - fn claim_rewards_callback(&self, #[call_result] result: ManagedAsyncCallResult<()>) { - match result { - ManagedAsyncCallResult::Ok(_) => { - let payment = self.call_value().egld_value().clone_value(); - self.rewards_reserve().update(|value| *value += payment); - } - ManagedAsyncCallResult::Err(_) => {} - } - } - - #[endpoint(recomputeTokenReserve)] - fn recompute_token_reserve(&self) { - let storage_cache = StorageCache::new(self); - let claim_status_mapper = self.delegation_claim_status(); - let mut claim_status = claim_status_mapper.get(); - - require!( - self.is_state_active(storage_cache.contract_state), - ERROR_NOT_ACTIVE - ); - require!( - claim_status.status == ClaimStatusType::Finished, - ERROR_RECOMPUTE_RESERVES - ); - - let current_block = self.blockchain().get_block_nonce(); - require!( - current_block >= claim_status.last_claim_block + RECOMPUTE_BLOCK_OFFSET, - ERROR_RECOMPUTE_TOO_SOON - ); - - if self.rewards_reserve().get() >= MIN_EGLD_TO_DELEGATE { - claim_status.status = ClaimStatusType::Delegable; - } else { - claim_status.status = ClaimStatusType::Insufficient; - } - - claim_status_mapper.set(claim_status); - } - - #[endpoint(delegateRewards)] - fn delegate_rewards(&self) { - let storage_cache = StorageCache::new(self); - let claim_status = self.delegation_claim_status().get(); - require!( - self.is_state_active(storage_cache.contract_state), - ERROR_NOT_ACTIVE - ); - require!( - claim_status.status == ClaimStatusType::Delegable, - ERROR_CLAIM_REDELEGATE - ); - - let rewards_reserve = self.rewards_reserve().get(); - self.rewards_reserve().set(BigUint::zero()); - - require!( - rewards_reserve >= MIN_EGLD_TO_DELEGATE, - ERROR_BAD_DELEGATION_AMOUNT - ); - - let delegation_contract = self.get_delegation_contract_for_delegate(&rewards_reserve); - - let gas_for_async_call = self.get_gas_for_async_call(); - self.tx() - .to(delegation_contract.clone()) - .typed(delegation_proxy::DelegationMockProxy) - .delegate() - .egld(rewards_reserve.clone()) - .gas(gas_for_async_call) - .callback( - self.callbacks() - .delegate_rewards_callback(delegation_contract, rewards_reserve), - ) - .gas_for_callback(MIN_GAS_FOR_CALLBACK) - .register_promise(); - } - - #[promises_callback] - fn delegate_rewards_callback( - &self, - delegation_contract: ManagedAddress, - staked_tokens: BigUint, - #[call_result] result: ManagedAsyncCallResult<()>, - ) { - let mut storage_cache = StorageCache::new(self); - match result { - ManagedAsyncCallResult::Ok(()) => { - self.delegation_contract_data(&delegation_contract) - .update(|contract_data| { - contract_data.total_staked_from_ls_contract += &staked_tokens; - }); - - self.delegation_claim_status() - .update(|claim_status| claim_status.status = ClaimStatusType::Redelegated); - - storage_cache.virtual_egld_reserve += &staked_tokens; - let sc_address = self.blockchain().get_sc_address(); - self.emit_add_liquidity_event(&storage_cache, &sc_address, BigUint::zero()); - } - ManagedAsyncCallResult::Err(_) => { - self.move_delegation_contract_to_back(delegation_contract); - self.rewards_reserve() - .update(|value| *value += staked_tokens) - } - } - } - - fn get_gas_for_async_call(&self) -> u64 { - let gas_left = self.blockchain().get_gas_left(); - require!( - gas_left > MIN_GAS_FOR_ASYNC_CALL + MIN_GAS_FOR_CALLBACK + MIN_GAS_FINISH_EXEC, - ERROR_INSUFFICIENT_GAS - ); - gas_left - MIN_GAS_FOR_CALLBACK - MIN_GAS_FINISH_EXEC - } - - // views - #[view(getLsValueForPosition)] - fn get_ls_value_for_position(&self, ls_token_amount: BigUint) -> BigUint { - let mut storage_cache = StorageCache::new(self); - storage_cache.skip_commit = true; - self.get_egld_amount(&ls_token_amount, &storage_cache) - } } diff --git a/liquid-staking/src/liquidity/add_liquidity.rs b/liquid-staking/src/liquidity/add_liquidity.rs index 0f0c01d..7d08818 100644 --- a/liquid-staking/src/liquidity/add_liquidity.rs +++ b/liquid-staking/src/liquidity/add_liquidity.rs @@ -1,15 +1,21 @@ multiversx_sc::imports!(); -multiversx_sc::derive_imports!(); -use crate::{config, delegation_proxy, errors::*, StorageCache}; - -pub const MIN_EGLD_TO_DELEGATE: u64 = 1_000_000_000_000_000_000; -pub const MIN_GAS_FOR_CALLBACK: u64 = 12_000_000; -pub const MINIMUM_LIQUIDITY: u64 = 1_000; +use crate::{ + basics, + basics::constants::{MINIMUM_LIQUIDITY, MIN_EGLD_TO_DELEGATE, MIN_GAS_FOR_CALLBACK}, + basics::errors::{ + ERROR_BAD_PAYMENT_AMOUNT, ERROR_DELEGATION_CONTRACT_NOT_INITIALIZED, ERROR_NOT_ACTIVE, + }, + config, delegation, delegation_proxy, liquidity_pool, StorageCache, +}; #[multiversx_sc::module] -pub trait AddLiquidity: - config::ConfigModule + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule +pub trait AddLiquidityModule: + config::ConfigModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + delegation::DelegationModule + + liquidity_pool::LiquidityPoolModule + + basics::events::EventsModule { #[payable("EGLD")] #[endpoint(addLiquidity)] @@ -40,10 +46,11 @@ pub trait AddLiquidity: .delegate() .egld(payment.clone()) .gas(gas_for_async_call) - .callback( - self.callbacks() - .add_liquidity_callback(caller, delegation_contract, payment), - ) + .callback(AddLiquidityModule::callbacks(self).add_liquidity_callback( + caller, + delegation_contract, + payment, + )) .gas_for_callback(MIN_GAS_FOR_CALLBACK) .register_promise(); } diff --git a/liquid-staking/src/liquidity/remove_liquidity.rs b/liquid-staking/src/liquidity/remove_liquidity.rs index e69de29..e249e76 100644 --- a/liquid-staking/src/liquidity/remove_liquidity.rs +++ b/liquid-staking/src/liquidity/remove_liquidity.rs @@ -0,0 +1,135 @@ +multiversx_sc::imports!(); + +use crate::{ + basics, + basics::constants::{MIN_EGLD_TO_DELEGATE, MIN_GAS_FOR_CALLBACK}, + basics::errors::{ + ERROR_BAD_PAYMENT_AMOUNT, ERROR_BAD_PAYMENT_TOKEN, ERROR_INSUFFICIENT_UNSTAKE_AMOUNT, + ERROR_LS_TOKEN_NOT_ISSUED, ERROR_NOT_ACTIVE, + }, + config::{self, UnstakeTokenAttributes, UNBOND_PERIOD}, + delegation, delegation_proxy, liquidity_pool, StorageCache, +}; + +#[multiversx_sc::module] +pub trait RemoveLiquidityModule: + config::ConfigModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + delegation::DelegationModule + + liquidity_pool::LiquidityPoolModule + + basics::events::EventsModule +{ + #[payable("*")] + #[endpoint(removeLiquidity)] + fn remove_liquidity(&self) { + self.blockchain().check_caller_is_user_account(); + let mut storage_cache = StorageCache::new(self); + let caller = self.blockchain().get_caller(); + let payment = self.call_value().single_esdt(); + + require!( + self.is_state_active(storage_cache.contract_state), + ERROR_NOT_ACTIVE + ); + require!( + storage_cache.ls_token_id.is_valid_esdt_identifier(), + ERROR_LS_TOKEN_NOT_ISSUED + ); + require!( + payment.token_identifier == storage_cache.ls_token_id, + ERROR_BAD_PAYMENT_TOKEN + ); + require!(payment.amount > 0, ERROR_BAD_PAYMENT_AMOUNT); + + let egld_to_unstake = self.pool_remove_liquidity(&payment.amount, &mut storage_cache); + require!( + egld_to_unstake >= MIN_EGLD_TO_DELEGATE, + ERROR_INSUFFICIENT_UNSTAKE_AMOUNT + ); + self.burn_ls_token(&payment.amount); + + let delegation_contract = self.get_delegation_contract_for_undelegate(&egld_to_unstake); + + let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); + delegation_contract_mapper + .update(|contract_data| contract_data.egld_in_ongoing_undelegation += &egld_to_unstake); + + let gas_for_async_call = self.get_gas_for_async_call(); + self.tx() + .to(delegation_contract.clone()) + .typed(delegation_proxy::DelegationMockProxy) + .undelegate(egld_to_unstake.clone()) + .gas(gas_for_async_call) + .callback( + RemoveLiquidityModule::callbacks(self).remove_liquidity_callback( + caller, + delegation_contract, + egld_to_unstake, + payment.amount, + ), + ) + .gas_for_callback(MIN_GAS_FOR_CALLBACK) + .register_promise(); + } + + #[promises_callback] + fn remove_liquidity_callback( + &self, + caller: ManagedAddress, + delegation_contract: ManagedAddress, + egld_to_unstake: BigUint, + ls_tokens_to_be_burned: BigUint, + #[call_result] result: ManagedAsyncCallResult<()>, + ) { + let mut storage_cache = StorageCache::new(self); + let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); + + delegation_contract_mapper.update(|contract_data| { + contract_data.egld_in_ongoing_undelegation -= &egld_to_unstake; + }); + + match result { + ManagedAsyncCallResult::Ok(()) => { + let current_epoch = self.blockchain().get_block_epoch(); + let unbond_epoch = current_epoch + UNBOND_PERIOD; + + delegation_contract_mapper.update(|contract_data| { + contract_data.total_staked_from_ls_contract -= &egld_to_unstake; + contract_data.total_unstaked_from_ls_contract += &egld_to_unstake; + }); + + let virtual_position = UnstakeTokenAttributes { + delegation_contract, + unstake_epoch: current_epoch, + unstake_amount: egld_to_unstake, + unbond_epoch, + }; + + let user_payment = self.mint_unstake_tokens(&virtual_position); + self.send().direct_esdt( + &caller, + &user_payment.token_identifier, + user_payment.token_nonce, + &user_payment.amount, + ); + + self.emit_remove_liquidity_event( + &storage_cache, + ls_tokens_to_be_burned, + user_payment.amount, + ); + } + ManagedAsyncCallResult::Err(_) => { + let ls_token_amount = self.pool_add_liquidity(&egld_to_unstake, &mut storage_cache); + let user_payment = self.mint_ls_token(ls_token_amount); + self.send().direct_esdt( + &caller, + &user_payment.token_identifier, + user_payment.token_nonce, + &user_payment.amount, + ); + self.move_delegation_contract_to_back(delegation_contract); + } + } + } +} diff --git a/liquid-staking/src/liquidity_pool.rs b/liquid-staking/src/liquidity_pool.rs index 170f233..c0a2ce5 100644 --- a/liquid-staking/src/liquidity_pool.rs +++ b/liquid-staking/src/liquidity_pool.rs @@ -1,8 +1,8 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); +use crate::basics::errors::{ERROR_INSUFFICIENT_LIQUIDITY, ERROR_INSUFFICIENT_LIQ_BURNED}; use crate::contexts::base::StorageCache; -use crate::errors::*; use crate::config; diff --git a/liquid-staking/tests/contract_interactions/mod.rs b/liquid-staking/tests/contract_interactions/mod.rs index 5bb4537..37540df 100644 --- a/liquid-staking/tests/contract_interactions/mod.rs +++ b/liquid-staking/tests/contract_interactions/mod.rs @@ -1,10 +1,15 @@ use crate::contract_setup::LiquidStakingContractSetup; +use basics::views::ViewsModule; +use config::{ConfigModule, UnstakeTokenAttributes}; +use delegation::DelegationModule; use delegation_mock::DelegationMock; -use liquid_staking::{ - config::{ConfigModule, UnstakeTokenAttributes}, - delegation::DelegationModule, - LiquidStaking, +use funds::{ + claim::ClaimModule, delegate_rewards::DelegateRewardsModule, + recompute_token_reserve::RecomputeTokenReserveModule, unbond::UnbondModule, + withdraw::WithdrawModule, }; +use liquid_staking::*; +use liquidity::{add_liquidity::AddLiquidityModule, remove_liquidity::RemoveLiquidityModule}; use multiversx_sc::types::Address; use multiversx_sc_scenario::{managed_address, num_bigint, rust_biguint, DebugApi}; diff --git a/liquid-staking/wasm/Cargo.lock b/liquid-staking/wasm/Cargo.lock index 7ee21e0..7e5083f 100644 --- a/liquid-staking/wasm/Cargo.lock +++ b/liquid-staking/wasm/Cargo.lock @@ -24,16 +24,9 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" name = "delegation-mock" version = "0.0.0" dependencies = [ - "itertools", "multiversx-sc", ] -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - [[package]] name = "endian-type" version = "0.1.2" @@ -52,21 +45,11 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - [[package]] name = "liquid-staking" version = "0.0.0" dependencies = [ "delegation-mock", - "itertools", "multiversx-sc", "multiversx-sc-modules", ] diff --git a/liquid-staking/wasm/src/lib.rs b/liquid-staking/wasm/src/lib.rs index 8b59c83..e094b74 100644 --- a/liquid-staking/wasm/src/lib.rs +++ b/liquid-staking/wasm/src/lib.rs @@ -21,13 +21,6 @@ multiversx_sc_wasm_adapter::endpoints! { ( init => init upgrade => upgrade - addLiquidity => add_liquidity - removeLiquidity => remove_liquidity - unbondTokens => unbond_tokens - withdrawAll => withdraw_all - claimRewards => claim_rewards - recomputeTokenReserve => recompute_token_reserve - delegateRewards => delegate_rewards getLsValueForPosition => get_ls_value_for_position registerLsToken => register_ls_token registerUnstakeToken => register_unstake_token @@ -51,11 +44,18 @@ multiversx_sc_wasm_adapter::endpoints! { getAddressesToClaim => addresses_to_claim getDelegationClaimStatus => delegation_claim_status getDelegationContractData => delegation_contract_data - add_liquidity_callback => add_liquidity_callback - remove_liquidity_callback => remove_liquidity_callback - withdraw_tokens_callback => withdraw_tokens_callback + claimRewards => claim_rewards + delegateRewards => delegate_rewards + recomputeTokenReserve => recompute_token_reserve + unbondTokens => unbond_tokens + withdrawAll => withdraw_all + addLiquidity => add_liquidity + removeLiquidity => remove_liquidity claim_rewards_callback => claim_rewards_callback delegate_rewards_callback => delegate_rewards_callback + withdraw_tokens_callback => withdraw_tokens_callback + add_liquidity_callback => add_liquidity_callback + remove_liquidity_callback => remove_liquidity_callback ) } From ebd16a753851bb63ce8f0a758e227b851d03a6f4 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Thu, 28 Nov 2024 11:51:36 +0200 Subject: [PATCH 06/22] remove unused errors --- liquid-staking/src/basics/errors.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/liquid-staking/src/basics/errors.rs b/liquid-staking/src/basics/errors.rs index eb8964c..1781f80 100644 --- a/liquid-staking/src/basics/errors.rs +++ b/liquid-staking/src/basics/errors.rs @@ -1,11 +1,9 @@ -//pub static ERROR_ACTIVE: &[u8] = b"Active state"; pub static ERROR_NOT_ACTIVE: &[u8] = b"Not active"; pub static ERROR_LS_TOKEN_NOT_ISSUED: &[u8] = b"LS token not issued"; pub static ERROR_DELEGATION_CONTRACT_NOT_INITIALIZED: &[u8] = b"Delegation contract was not initialized yet"; pub static ERROR_INSUFFICIENT_GAS: &[u8] = b"Insufficient gas remaining for the callback"; -//pub static ERROR_CLAIM_START: &[u8] = b"Claim operation must be new or pending"; pub static ERROR_CLAIM_IN_PROGRESS: &[u8] = b"Claim operation is already in progress"; pub static ERROR_OLD_CLAIM_START: &[u8] = b"Previous claimed rewards must be redelegated or lesser than 1 EGLD"; @@ -19,13 +17,9 @@ pub static ERROR_BAD_PAYMENT_TOKEN: &[u8] = b"Bad payment token"; pub static ERROR_BAD_PAYMENT_AMOUNT: &[u8] = b"Insufficient delegated amount"; pub static ERROR_BAD_WHITELIST_FEE: &[u8] = b"Whitelisting contracts costs 1 EGLD"; pub static ERROR_INSUFFICIENT_UNSTAKE_AMOUNT: &[u8] = b"Insufficient unstake amount"; -//pub static ERROR_INSUFFICIENT_UNBONDED_AMOUNT: &[u8] = b"Insufficient incoming withdraw amount"; pub static ERROR_INSUFFICIENT_LIQUIDITY: &[u8] = b"Insufficient liquidity minted"; pub static ERROR_INSUFFICIENT_LIQ_BURNED: &[u8] = b"Insufficient liquidity burned"; -//pub static ERROR_NOT_ENOUGH_RESERVE: &[u8] = b"Not enough reserve"; -//pub static ERROR_NOT_ENOUGH_LP: &[u8] = b"Not enough LP token supply"; - pub static ERROR_BAD_DELEGATION_ADDRESS: &[u8] = b"No delegation contract available"; pub static ERROR_BAD_DELEGATION_AMOUNT: &[u8] = b"Delegation amount must be at least 1 EGLD"; pub static ERROR_NO_DELEGATION_CONTRACTS: &[u8] = b"There are no delegation contracts whitelisted"; @@ -36,4 +30,3 @@ pub static ERROR_DELEGATION_CAP: &[u8] = b"Delegation cap must be higher than the total staked amount"; pub static ERROR_ONLY_DELEGATION_ADMIN: &[u8] = b"Only the admin of the delegation contract can change the status"; -//pub static ERROR_NOTHING_TO_UNBOND: &[u8] = b"Nothing to unbond"; From cefdb0f2d6b0976229bfd193b2549689d0d37b97 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Thu, 28 Nov 2024 17:13:48 +0200 Subject: [PATCH 07/22] view with no StorageCache --- liquid-staking/src/basics/views.rs | 12 ++++++++---- liquid-staking/src/contexts/base.rs | 5 ----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/liquid-staking/src/basics/views.rs b/liquid-staking/src/basics/views.rs index 5f40dc9..6940145 100644 --- a/liquid-staking/src/basics/views.rs +++ b/liquid-staking/src/basics/views.rs @@ -1,6 +1,6 @@ multiversx_sc::imports!(); -use crate::{contexts::base::StorageCache, liquidity_pool}; +use crate::{basics::errors::ERROR_INSUFFICIENT_LIQ_BURNED, liquidity_pool}; #[multiversx_sc::module] pub trait ViewsModule: @@ -11,8 +11,12 @@ pub trait ViewsModule: // views #[view(getLsValueForPosition)] fn get_ls_value_for_position(&self, ls_token_amount: BigUint) -> BigUint { - let mut storage_cache = StorageCache::new(self); - storage_cache.skip_commit = true; - self.get_egld_amount(&ls_token_amount, &storage_cache) + let ls_token_supply = self.ls_token_supply().get(); + let virtual_egld_reserve = self.virtual_egld_reserve().get(); + + let egld_amount = ls_token_amount * &virtual_egld_reserve / ls_token_supply; + require!(egld_amount > 0u64, ERROR_INSUFFICIENT_LIQ_BURNED); + + egld_amount } } diff --git a/liquid-staking/src/contexts/base.rs b/liquid-staking/src/contexts/base.rs index 3bf36ae..8ea4a11 100644 --- a/liquid-staking/src/contexts/base.rs +++ b/liquid-staking/src/contexts/base.rs @@ -13,7 +13,6 @@ where pub ls_token_id: TokenIdentifier, pub ls_token_supply: BigUint, pub virtual_egld_reserve: BigUint, - pub skip_commit: bool, } impl<'a, C> StorageCache<'a, C> @@ -27,7 +26,6 @@ where ls_token_supply: sc_ref.ls_token_supply().get(), virtual_egld_reserve: sc_ref.virtual_egld_reserve().get(), sc_ref, - skip_commit: false, } } } @@ -37,9 +35,6 @@ where C: ConfigModule, { fn drop(&mut self) { - if self.skip_commit { - return; - } // commit changes to storage for the mutable fields self.sc_ref.ls_token_supply().set(&self.ls_token_supply); self.sc_ref From 80516839f1c75169451cead7f3eb25f72d9ab1b6 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 13:43:54 +0200 Subject: [PATCH 08/22] Update liquid-staking/src/delegation.rs Co-authored-by: dorin-iancu <72252689+dorin-iancu@users.noreply.github.com> --- liquid-staking/src/delegation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liquid-staking/src/delegation.rs b/liquid-staking/src/delegation.rs index e284c71..90f4a55 100644 --- a/liquid-staking/src/delegation.rs +++ b/liquid-staking/src/delegation.rs @@ -265,7 +265,7 @@ pub trait DelegationModule: } } - fn get_gas_for_async_call(&self) -> u64 { + fn get_gas_for_async_call(&self) -> GasLimit { let gas_left = self.blockchain().get_gas_left(); require!( gas_left > MIN_GAS_FOR_ASYNC_CALL + MIN_GAS_FOR_CALLBACK + MIN_GAS_FINISH_EXEC, From 4d775199f7fd746ffbc86f3cb31794ecceb41e74 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 13:44:04 +0200 Subject: [PATCH 09/22] Update liquid-staking/src/basics/constants.rs Co-authored-by: dorin-iancu <72252689+dorin-iancu@users.noreply.github.com> --- liquid-staking/src/basics/constants.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liquid-staking/src/basics/constants.rs b/liquid-staking/src/basics/constants.rs index 22a8051..61db3af 100644 --- a/liquid-staking/src/basics/constants.rs +++ b/liquid-staking/src/basics/constants.rs @@ -1,7 +1,7 @@ pub const DEFAULT_GAS_TO_CLAIM_REWARDS: u64 = 6_000_000; pub const MIN_GAS_FOR_ASYNC_CALL: u64 = 12_000_000; pub const MIN_GAS_FOR_CALLBACK: u64 = 12_000_000; -pub const MIN_EGLD_TO_DELEGATE: u64 = 1_000_000_000_000_000_000; +pub const MIN_EGLD_TO_DELEGATE: u64 = 1_000_000_000_000_000_000; // 1 EGLD pub const RECOMPUTE_BLOCK_OFFSET: u64 = 10; pub const MINIMUM_LIQUIDITY: u64 = 1_000; pub const DEFAULT_MIN_GAS_TO_SAVE_PROGRESS: u64 = 30_000_000; From 2950786188f55e39cb37234dbe8176dd9dff79ff Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 13:44:35 +0200 Subject: [PATCH 10/22] Update liquid-staking/src/liquidity/add_liquidity.rs Co-authored-by: dorin-iancu <72252689+dorin-iancu@users.noreply.github.com> --- liquid-staking/src/liquidity/add_liquidity.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/liquid-staking/src/liquidity/add_liquidity.rs b/liquid-staking/src/liquidity/add_liquidity.rs index 7d08818..42523ed 100644 --- a/liquid-staking/src/liquidity/add_liquidity.rs +++ b/liquid-staking/src/liquidity/add_liquidity.rs @@ -75,6 +75,7 @@ pub trait AddLiquidityModule: if storage_cache.ls_token_supply == 0 { ls_token_amount_before_add += MINIMUM_LIQUIDITY; } + let ls_token_amount = self.pool_add_liquidity(&staked_tokens, &mut storage_cache) - ls_token_amount_before_add; let user_payment = self.mint_ls_token(ls_token_amount); From f30a1f1565235234f33a60cefefb720f9ff0b5ae Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 13:44:55 +0200 Subject: [PATCH 11/22] Update liquid-staking/src/funds/delegate_rewards.rs Co-authored-by: dorin-iancu <72252689+dorin-iancu@users.noreply.github.com> --- liquid-staking/src/funds/delegate_rewards.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/liquid-staking/src/funds/delegate_rewards.rs b/liquid-staking/src/funds/delegate_rewards.rs index 3a50ed7..eb3e8f4 100644 --- a/liquid-staking/src/funds/delegate_rewards.rs +++ b/liquid-staking/src/funds/delegate_rewards.rs @@ -29,8 +29,7 @@ pub trait DelegateRewardsModule: ERROR_CLAIM_REDELEGATE ); - let rewards_reserve = self.rewards_reserve().get(); - self.rewards_reserve().set(BigUint::zero()); + let rewards_reserve = self.rewards_reserve().take(); require!( rewards_reserve >= MIN_EGLD_TO_DELEGATE, From 257431af7549dad8b7b1c6fc6a7a93c62ec67cd2 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 13:52:36 +0200 Subject: [PATCH 12/22] Update liquid-staking/src/liquidity/remove_liquidity.rs Co-authored-by: dorin-iancu <72252689+dorin-iancu@users.noreply.github.com> --- liquid-staking/src/liquidity/remove_liquidity.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/liquid-staking/src/liquidity/remove_liquidity.rs b/liquid-staking/src/liquidity/remove_liquidity.rs index e249e76..88181fa 100644 --- a/liquid-staking/src/liquidity/remove_liquidity.rs +++ b/liquid-staking/src/liquidity/remove_liquidity.rs @@ -96,6 +96,7 @@ pub trait RemoveLiquidityModule: delegation_contract_mapper.update(|contract_data| { contract_data.total_staked_from_ls_contract -= &egld_to_unstake; contract_data.total_unstaked_from_ls_contract += &egld_to_unstake; + contract_data.egld_in_ongoing_undelegation -= &egld_to_unstake; }); let virtual_position = UnstakeTokenAttributes { @@ -120,6 +121,10 @@ pub trait RemoveLiquidityModule: ); } ManagedAsyncCallResult::Err(_) => { + delegation_contract_mapper.update(|contract_data| { + contract_data.egld_in_ongoing_undelegation -= &egld_to_unstake; + }); + let ls_token_amount = self.pool_add_liquidity(&egld_to_unstake, &mut storage_cache); let user_payment = self.mint_ls_token(ls_token_amount); self.send().direct_esdt( From 4da9a2d75a29d19c61b47dac3b8888bd6c65cee8 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 13:55:14 +0200 Subject: [PATCH 13/22] Dorin review fixes part 1 --- liquid-staking/src/basics/constants.rs | 22 ++++++++++++++++------ liquid-staking/src/delegation.rs | 8 ++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/liquid-staking/src/basics/constants.rs b/liquid-staking/src/basics/constants.rs index 61db3af..1bd95d9 100644 --- a/liquid-staking/src/basics/constants.rs +++ b/liquid-staking/src/basics/constants.rs @@ -1,8 +1,18 @@ -pub const DEFAULT_GAS_TO_CLAIM_REWARDS: u64 = 6_000_000; -pub const MIN_GAS_FOR_ASYNC_CALL: u64 = 12_000_000; -pub const MIN_GAS_FOR_CALLBACK: u64 = 12_000_000; +pub type GasLimit = u64; +pub type Blocks = u64; + +pub const DEFAULT_MIN_GAS_TO_SAVE_PROGRESS: GasLimit = 30_000_000; +pub const DEFAULT_GAS_TO_CLAIM_REWARDS: GasLimit = 6_000_000; +pub const MIN_GAS_FOR_ASYNC_CALL: GasLimit = 12_000_000; +pub const MIN_GAS_FOR_CALLBACK: GasLimit = 12_000_000; +pub const MIN_GAS_FINISH_EXEC: GasLimit = 20_000_000; + +pub const MIN_BLOCKS_BEFORE_CLEAR_ONGOING_OP: Blocks = 10; +pub const RECOMPUTE_BLOCK_OFFSET: Blocks = 10; + pub const MIN_EGLD_TO_DELEGATE: u64 = 1_000_000_000_000_000_000; // 1 EGLD -pub const RECOMPUTE_BLOCK_OFFSET: u64 = 10; +pub const EGLD_TO_WHITELIST: u64 = 1_000_000_000_000_000_000; // 1 EGLD + pub const MINIMUM_LIQUIDITY: u64 = 1_000; -pub const DEFAULT_MIN_GAS_TO_SAVE_PROGRESS: u64 = 30_000_000; -pub const MIN_GAS_FINISH_EXEC: u64 = 20_000_000; + +pub const MAX_DELEGATION_ADDRESSES: usize = 20; diff --git a/liquid-staking/src/delegation.rs b/liquid-staking/src/delegation.rs index 90f4a55..60e0518 100644 --- a/liquid-staking/src/delegation.rs +++ b/liquid-staking/src/delegation.rs @@ -1,7 +1,10 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use crate::basics::constants::{MIN_GAS_FINISH_EXEC, MIN_GAS_FOR_ASYNC_CALL, MIN_GAS_FOR_CALLBACK}; +use crate::basics::constants::{ + GasLimit, EGLD_TO_WHITELIST, MAX_DELEGATION_ADDRESSES, MIN_BLOCKS_BEFORE_CLEAR_ONGOING_OP, + MIN_GAS_FINISH_EXEC, MIN_GAS_FOR_ASYNC_CALL, MIN_GAS_FOR_CALLBACK, +}; use crate::{ basics::errors::{ERROR_BAD_WHITELIST_FEE, ERROR_INSUFFICIENT_GAS}, delegation_proxy, @@ -14,9 +17,6 @@ use crate::basics::errors::{ ERROR_ONLY_DELEGATION_ADMIN, }; -pub const MAX_DELEGATION_ADDRESSES: usize = 20; -pub const EGLD_TO_WHITELIST: u64 = 1_000_000_000_000_000_000; -pub const MIN_BLOCKS_BEFORE_CLEAR_ONGOING_OP: u64 = 10; use crate::liquidity_pool::State; #[type_abi] From 89c4df9a7cbe7ad25d763264cdd0f7da6b4b812a Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 13:55:37 +0200 Subject: [PATCH 14/22] Update liquid-staking/src/funds/delegate_rewards.rs Co-authored-by: dorin-iancu <72252689+dorin-iancu@users.noreply.github.com> --- liquid-staking/src/funds/delegate_rewards.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/liquid-staking/src/funds/delegate_rewards.rs b/liquid-staking/src/funds/delegate_rewards.rs index eb3e8f4..160c811 100644 --- a/liquid-staking/src/funds/delegate_rewards.rs +++ b/liquid-staking/src/funds/delegate_rewards.rs @@ -60,7 +60,6 @@ pub trait DelegateRewardsModule: staked_tokens: BigUint, #[call_result] result: ManagedAsyncCallResult<()>, ) { - let mut storage_cache = StorageCache::new(self); match result { ManagedAsyncCallResult::Ok(()) => { self.delegation_contract_data(&delegation_contract) @@ -71,8 +70,10 @@ pub trait DelegateRewardsModule: self.delegation_claim_status() .update(|claim_status| claim_status.status = ClaimStatusType::Redelegated); + let mut storage_cache = StorageCache::new(self); storage_cache.virtual_egld_reserve += &staked_tokens; let sc_address = self.blockchain().get_sc_address(); + self.emit_add_liquidity_event(&storage_cache, &sc_address, BigUint::zero()); } ManagedAsyncCallResult::Err(_) => { From 88c2ff9baa74b91430e1c9b252c87891952f3b2d Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 13:56:20 +0200 Subject: [PATCH 15/22] Update liquid-staking/src/funds/withdraw.rs Co-authored-by: dorin-iancu <72252689+dorin-iancu@users.noreply.github.com> --- liquid-staking/src/funds/withdraw.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/liquid-staking/src/funds/withdraw.rs b/liquid-staking/src/funds/withdraw.rs index 59267b4..9b1d17c 100644 --- a/liquid-staking/src/funds/withdraw.rs +++ b/liquid-staking/src/funds/withdraw.rs @@ -43,9 +43,11 @@ pub trait WithdrawModule: match result { ManagedAsyncCallResult::Ok(()) => { let withdraw_amount = self.call_value().egld_value().clone_value(); - let delegation_contract_mapper = self.delegation_contract_data(&provider); - if withdraw_amount > 0u64 { - delegation_contract_mapper.update(|contract_data| { + if withdraw_amount == 0u64 { + return; + } + + self.delegation_contract_data(&provider);.update(|contract_data| { contract_data.total_unbonded_from_ls_contract += &withdraw_amount }); } From 1f20cb5ed869014a5e259187b84867710d679be9 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 14:02:30 +0200 Subject: [PATCH 16/22] Dorin review fixes part 2 --- liquid-staking/src/funds/withdraw.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/liquid-staking/src/funds/withdraw.rs b/liquid-staking/src/funds/withdraw.rs index 9b1d17c..7a1a285 100644 --- a/liquid-staking/src/funds/withdraw.rs +++ b/liquid-staking/src/funds/withdraw.rs @@ -44,13 +44,13 @@ pub trait WithdrawModule: ManagedAsyncCallResult::Ok(()) => { let withdraw_amount = self.call_value().egld_value().clone_value(); if withdraw_amount == 0u64 { - return; + return; } - - self.delegation_contract_data(&provider);.update(|contract_data| { + + self.delegation_contract_data(&provider) + .update(|contract_data| { contract_data.total_unbonded_from_ls_contract += &withdraw_amount }); - } } ManagedAsyncCallResult::Err(_) => {} } From 1351dd7059c1b4580b2fa9ce9c361f51ff180401 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 14:03:15 +0200 Subject: [PATCH 17/22] Update liquid-staking/src/liquidity/add_liquidity.rs Co-authored-by: dorin-iancu <72252689+dorin-iancu@users.noreply.github.com> --- liquid-staking/src/liquidity/add_liquidity.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liquid-staking/src/liquidity/add_liquidity.rs b/liquid-staking/src/liquidity/add_liquidity.rs index 42523ed..8c0d34f 100644 --- a/liquid-staking/src/liquidity/add_liquidity.rs +++ b/liquid-staking/src/liquidity/add_liquidity.rs @@ -65,12 +65,12 @@ pub trait AddLiquidityModule: ) { match result { ManagedAsyncCallResult::Ok(()) => { - let mut storage_cache = StorageCache::new(self); self.delegation_contract_data(&delegation_contract) .update(|contract_data| { contract_data.total_staked_from_ls_contract += &staked_tokens; }); + let mut storage_cache = StorageCache::new(self); let mut ls_token_amount_before_add = BigUint::zero(); if storage_cache.ls_token_supply == 0 { ls_token_amount_before_add += MINIMUM_LIQUIDITY; From 884b2c20513b64f6b136a0c68f46e8612016268b Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 14:13:36 +0200 Subject: [PATCH 18/22] Dorin review fixes part 3 --- liquid-staking/src/funds/delegate_rewards.rs | 2 +- liquid-staking/src/liquidity/remove_liquidity.rs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/liquid-staking/src/funds/delegate_rewards.rs b/liquid-staking/src/funds/delegate_rewards.rs index 160c811..14efebf 100644 --- a/liquid-staking/src/funds/delegate_rewards.rs +++ b/liquid-staking/src/funds/delegate_rewards.rs @@ -73,7 +73,7 @@ pub trait DelegateRewardsModule: let mut storage_cache = StorageCache::new(self); storage_cache.virtual_egld_reserve += &staked_tokens; let sc_address = self.blockchain().get_sc_address(); - + self.emit_add_liquidity_event(&storage_cache, &sc_address, BigUint::zero()); } ManagedAsyncCallResult::Err(_) => { diff --git a/liquid-staking/src/liquidity/remove_liquidity.rs b/liquid-staking/src/liquidity/remove_liquidity.rs index 88181fa..cd823e5 100644 --- a/liquid-staking/src/liquidity/remove_liquidity.rs +++ b/liquid-staking/src/liquidity/remove_liquidity.rs @@ -84,10 +84,6 @@ pub trait RemoveLiquidityModule: let mut storage_cache = StorageCache::new(self); let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); - delegation_contract_mapper.update(|contract_data| { - contract_data.egld_in_ongoing_undelegation -= &egld_to_unstake; - }); - match result { ManagedAsyncCallResult::Ok(()) => { let current_epoch = self.blockchain().get_block_epoch(); @@ -121,10 +117,10 @@ pub trait RemoveLiquidityModule: ); } ManagedAsyncCallResult::Err(_) => { - delegation_contract_mapper.update(|contract_data| { - contract_data.egld_in_ongoing_undelegation -= &egld_to_unstake; - }); - + delegation_contract_mapper.update(|contract_data| { + contract_data.egld_in_ongoing_undelegation -= &egld_to_unstake; + }); + let ls_token_amount = self.pool_add_liquidity(&egld_to_unstake, &mut storage_cache); let user_payment = self.mint_ls_token(ls_token_amount); self.send().direct_esdt( From 6f8a6b61f6e27779e1904f093ab652326e2e2121 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 15:08:32 +0200 Subject: [PATCH 19/22] Dorin review fixes part 4 --- liquid-staking/src/basics/events.rs | 10 ++++ liquid-staking/src/funds/claim.rs | 25 ++++++--- liquid-staking/src/funds/delegate_rewards.rs | 35 ++++++------ liquid-staking/src/funds/withdraw.rs | 23 ++++---- liquid-staking/src/liquidity/add_liquidity.rs | 38 +++++++------ .../src/liquidity/remove_liquidity.rs | 53 +++++++++++-------- 6 files changed, 112 insertions(+), 72 deletions(-) diff --git a/liquid-staking/src/basics/events.rs b/liquid-staking/src/basics/events.rs index 4630bc0..3160029 100644 --- a/liquid-staking/src/basics/events.rs +++ b/liquid-staking/src/basics/events.rs @@ -108,4 +108,14 @@ pub trait EventsModule: #[indexed] epoch: u64, remove_liquidity_event: &RemoveLiquidityEvent, ); + + #[event("successful_claim")] + fn successful_claim_event( + &self, + amount_available_to_claim: BigUint, + #[indexed] caller: &ManagedAddress, + ); + + #[event("failed_claim")] + fn failed_claim_event(&self, #[indexed] caller: &ManagedAddress); } diff --git a/liquid-staking/src/funds/claim.rs b/liquid-staking/src/funds/claim.rs index cfaf906..1bedad3 100644 --- a/liquid-staking/src/funds/claim.rs +++ b/liquid-staking/src/funds/claim.rs @@ -1,8 +1,11 @@ multiversx_sc::imports!(); use crate::{ - basics::constants::{DEFAULT_GAS_TO_CLAIM_REWARDS, DEFAULT_MIN_GAS_TO_SAVE_PROGRESS}, - basics::errors::{ERROR_NOT_ACTIVE, ERROR_NO_DELEGATION_CONTRACTS}, + basics::{ + constants::{DEFAULT_GAS_TO_CLAIM_REWARDS, DEFAULT_MIN_GAS_TO_SAVE_PROGRESS}, + errors::{ERROR_NOT_ACTIVE, ERROR_NO_DELEGATION_CONTRACTS}, + events, + }, config::{self}, delegation::{self, ClaimStatusType}, delegation_proxy, StorageCache, @@ -13,6 +16,7 @@ pub trait ClaimModule: config::ConfigModule + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + delegation::DelegationModule + + events::EventsModule { #[endpoint(claimRewards)] fn claim_rewards(&self) { @@ -48,11 +52,11 @@ pub trait ClaimModule: let address = current_node.clone().into_value(); self.tx() - .to(&address) + .to(address.clone()) .typed(delegation_proxy::DelegationMockProxy) .claim_rewards() .gas(DEFAULT_GAS_TO_CLAIM_REWARDS) - .callback(ClaimModule::callbacks(self).claim_rewards_callback()) + .callback(ClaimModule::callbacks(self).claim_rewards_callback(address)) .register_promise(); delegation_addresses.remove_node(¤t_node); @@ -68,13 +72,20 @@ pub trait ClaimModule: } #[promises_callback] - fn claim_rewards_callback(&self, #[call_result] result: ManagedAsyncCallResult<()>) { + fn claim_rewards_callback( + &self, + delegation_address: ManagedAddress, + #[call_result] result: ManagedAsyncCallResult<()>, + ) { match result { ManagedAsyncCallResult::Ok(_) => { let payment = self.call_value().egld_value().clone_value(); - self.rewards_reserve().update(|value| *value += payment); + self.rewards_reserve().update(|value| *value += &payment); + self.successful_claim_event(payment, &delegation_address); + } + ManagedAsyncCallResult::Err(_) => { + self.failed_claim_event(&delegation_address); } - ManagedAsyncCallResult::Err(_) => {} } } } diff --git a/liquid-staking/src/funds/delegate_rewards.rs b/liquid-staking/src/funds/delegate_rewards.rs index 14efebf..f8de87f 100644 --- a/liquid-staking/src/funds/delegate_rewards.rs +++ b/liquid-staking/src/funds/delegate_rewards.rs @@ -35,22 +35,7 @@ pub trait DelegateRewardsModule: rewards_reserve >= MIN_EGLD_TO_DELEGATE, ERROR_BAD_DELEGATION_AMOUNT ); - - let delegation_contract = self.get_delegation_contract_for_delegate(&rewards_reserve); - - let gas_for_async_call = self.get_gas_for_async_call(); - self.tx() - .to(delegation_contract.clone()) - .typed(delegation_proxy::DelegationMockProxy) - .delegate() - .egld(rewards_reserve.clone()) - .gas(gas_for_async_call) - .callback( - DelegateRewardsModule::callbacks(self) - .delegate_rewards_callback(delegation_contract, rewards_reserve), - ) - .gas_for_callback(MIN_GAS_FOR_CALLBACK) - .register_promise(); + self.call_delegate(rewards_reserve); } #[promises_callback] @@ -83,4 +68,22 @@ pub trait DelegateRewardsModule: } } } + + fn call_delegate(&self, rewards_reserve: BigUint) { + let delegation_contract = self.get_delegation_contract_for_delegate(&rewards_reserve); + + let gas_for_async_call = self.get_gas_for_async_call(); + self.tx() + .to(delegation_contract.clone()) + .typed(delegation_proxy::DelegationMockProxy) + .delegate() + .egld(rewards_reserve.clone()) + .gas(gas_for_async_call) + .callback( + DelegateRewardsModule::callbacks(self) + .delegate_rewards_callback(delegation_contract, rewards_reserve), + ) + .gas_for_callback(MIN_GAS_FOR_CALLBACK) + .register_promise(); + } } diff --git a/liquid-staking/src/funds/withdraw.rs b/liquid-staking/src/funds/withdraw.rs index 7a1a285..10173af 100644 --- a/liquid-staking/src/funds/withdraw.rs +++ b/liquid-staking/src/funds/withdraw.rs @@ -22,16 +22,7 @@ pub trait WithdrawModule: self.is_state_active(storage_cache.contract_state), ERROR_NOT_ACTIVE ); - - let gas_for_async_call = self.get_gas_for_async_call(); - self.tx() - .to(delegation_contract.clone()) - .typed(delegation_proxy::DelegationMockProxy) - .withdraw() - .gas(gas_for_async_call) - .callback(WithdrawModule::callbacks(self).withdraw_tokens_callback(delegation_contract)) - .gas_for_callback(MIN_GAS_FOR_CALLBACK) - .register_promise(); + self.call_withdraw(delegation_contract); } #[promises_callback] @@ -55,4 +46,16 @@ pub trait WithdrawModule: ManagedAsyncCallResult::Err(_) => {} } } + + fn call_withdraw(&self, delegation_contract: ManagedAddress) { + let gas_for_async_call = self.get_gas_for_async_call(); + self.tx() + .to(delegation_contract.clone()) + .typed(delegation_proxy::DelegationMockProxy) + .withdraw() + .gas(gas_for_async_call) + .callback(WithdrawModule::callbacks(self).withdraw_tokens_callback(delegation_contract)) + .gas_for_callback(MIN_GAS_FOR_CALLBACK) + .register_promise(); + } } diff --git a/liquid-staking/src/liquidity/add_liquidity.rs b/liquid-staking/src/liquidity/add_liquidity.rs index 8c0d34f..fe76e5a 100644 --- a/liquid-staking/src/liquidity/add_liquidity.rs +++ b/liquid-staking/src/liquidity/add_liquidity.rs @@ -37,22 +37,7 @@ pub trait AddLiquidityModule: } require!(payment > MIN_EGLD_TO_DELEGATE, ERROR_BAD_PAYMENT_AMOUNT); - let delegation_contract = self.get_delegation_contract_for_delegate(&payment); - - let gas_for_async_call = self.get_gas_for_async_call(); - self.tx() - .to(delegation_contract.clone()) - .typed(delegation_proxy::DelegationMockProxy) - .delegate() - .egld(payment.clone()) - .gas(gas_for_async_call) - .callback(AddLiquidityModule::callbacks(self).add_liquidity_callback( - caller, - delegation_contract, - payment, - )) - .gas_for_callback(MIN_GAS_FOR_CALLBACK) - .register_promise(); + self.call_delegate(caller, payment); } #[promises_callback] @@ -75,7 +60,7 @@ pub trait AddLiquidityModule: if storage_cache.ls_token_supply == 0 { ls_token_amount_before_add += MINIMUM_LIQUIDITY; } - + let ls_token_amount = self.pool_add_liquidity(&staked_tokens, &mut storage_cache) - ls_token_amount_before_add; let user_payment = self.mint_ls_token(ls_token_amount); @@ -94,4 +79,23 @@ pub trait AddLiquidityModule: } } } + + fn call_delegate(&self, caller: ManagedAddress, payment: BigUint) { + let delegation_contract = self.get_delegation_contract_for_delegate(&payment); + + let gas_for_async_call = self.get_gas_for_async_call(); + self.tx() + .to(delegation_contract.clone()) + .typed(delegation_proxy::DelegationMockProxy) + .delegate() + .egld(payment.clone()) + .gas(gas_for_async_call) + .callback(AddLiquidityModule::callbacks(self).add_liquidity_callback( + caller, + delegation_contract, + payment, + )) + .gas_for_callback(MIN_GAS_FOR_CALLBACK) + .register_promise(); + } } diff --git a/liquid-staking/src/liquidity/remove_liquidity.rs b/liquid-staking/src/liquidity/remove_liquidity.rs index cd823e5..3fd0137 100644 --- a/liquid-staking/src/liquidity/remove_liquidity.rs +++ b/liquid-staking/src/liquidity/remove_liquidity.rs @@ -48,28 +48,7 @@ pub trait RemoveLiquidityModule: ); self.burn_ls_token(&payment.amount); - let delegation_contract = self.get_delegation_contract_for_undelegate(&egld_to_unstake); - - let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); - delegation_contract_mapper - .update(|contract_data| contract_data.egld_in_ongoing_undelegation += &egld_to_unstake); - - let gas_for_async_call = self.get_gas_for_async_call(); - self.tx() - .to(delegation_contract.clone()) - .typed(delegation_proxy::DelegationMockProxy) - .undelegate(egld_to_unstake.clone()) - .gas(gas_for_async_call) - .callback( - RemoveLiquidityModule::callbacks(self).remove_liquidity_callback( - caller, - delegation_contract, - egld_to_unstake, - payment.amount, - ), - ) - .gas_for_callback(MIN_GAS_FOR_CALLBACK) - .register_promise(); + self.call_undelegate(egld_to_unstake, caller, payment.amount); } #[promises_callback] @@ -133,4 +112,34 @@ pub trait RemoveLiquidityModule: } } } + + fn call_undelegate( + &self, + egld_to_unstake: BigUint, + caller: ManagedAddress, + ls_tokens_to_be_burned: BigUint, + ) { + let delegation_contract = self.get_delegation_contract_for_undelegate(&egld_to_unstake); + + let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); + delegation_contract_mapper + .update(|contract_data| contract_data.egld_in_ongoing_undelegation += &egld_to_unstake); + + let gas_for_async_call = self.get_gas_for_async_call(); + self.tx() + .to(delegation_contract.clone()) + .typed(delegation_proxy::DelegationMockProxy) + .undelegate(egld_to_unstake.clone()) + .gas(gas_for_async_call) + .callback( + RemoveLiquidityModule::callbacks(self).remove_liquidity_callback( + caller, + delegation_contract, + egld_to_unstake, + ls_tokens_to_be_burned, + ), + ) + .gas_for_callback(MIN_GAS_FOR_CALLBACK) + .register_promise(); + } } From d775d7c517c91cf8fcbdb361732d6ab7e5ccf691 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Mon, 2 Dec 2024 15:09:28 +0200 Subject: [PATCH 20/22] clippy --- liquid-staking/src/contexts/base.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liquid-staking/src/contexts/base.rs b/liquid-staking/src/contexts/base.rs index 8ea4a11..9ba962e 100644 --- a/liquid-staking/src/contexts/base.rs +++ b/liquid-staking/src/contexts/base.rs @@ -30,7 +30,7 @@ where } } -impl<'a, C> Drop for StorageCache<'a, C> +impl Drop for StorageCache<'_, C> where C: ConfigModule, { From 8ed6ca24d58fb7bbf06d127d682ec450fc31bdcd Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Tue, 3 Dec 2024 10:35:08 +0200 Subject: [PATCH 21/22] unbound refactor --- liquid-staking/src/funds/unbond.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/liquid-staking/src/funds/unbond.rs b/liquid-staking/src/funds/unbond.rs index 191bd52..2e316fb 100644 --- a/liquid-staking/src/funds/unbond.rs +++ b/liquid-staking/src/funds/unbond.rs @@ -47,6 +47,20 @@ pub trait UnbondModule: ERROR_UNSTAKE_PERIOD_NOT_PASSED ); + self.handle_unstaked_tokens( + unstake_token_attributes, + &mut total_unstake_amount, + payment.token_nonce, + ); + self.send().direct_egld(&caller, &total_unstake_amount); + } + + fn handle_unstaked_tokens( + &self, + unstake_token_attributes: UnstakeTokenAttributes, + total_unstake_amount: &mut BigUint, + nonce: u64, + ) { let delegation_contract = unstake_token_attributes.delegation_contract.clone(); let unstake_amount = unstake_token_attributes.unstake_amount.clone(); let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); @@ -61,8 +75,7 @@ pub trait UnbondModule: contract_data.total_unbonded_from_ls_contract -= &unstake_amount }); - total_unstake_amount += unstake_amount; - self.burn_unstake_tokens(payment.token_nonce); - self.send().direct_egld(&caller, &total_unstake_amount); + *total_unstake_amount += unstake_amount; + self.burn_unstake_tokens(nonce); } } From ce02a3cd910db4fdd12188c1959e4d9d72d44686 Mon Sep 17 00:00:00 2001 From: Alin Cruceat Date: Tue, 3 Dec 2024 10:42:13 +0200 Subject: [PATCH 22/22] refactor unbond --- liquid-staking/src/funds/unbond.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/liquid-staking/src/funds/unbond.rs b/liquid-staking/src/funds/unbond.rs index 2e316fb..7778c8d 100644 --- a/liquid-staking/src/funds/unbond.rs +++ b/liquid-staking/src/funds/unbond.rs @@ -35,8 +35,6 @@ pub trait UnbondModule: ); require!(payment.amount > 0, ERROR_BAD_PAYMENT_AMOUNT); - let mut total_unstake_amount = BigUint::zero(); - let unstake_token_attributes: UnstakeTokenAttributes = self .unstake_token() .get_token_attributes(payment.token_nonce); @@ -47,20 +45,17 @@ pub trait UnbondModule: ERROR_UNSTAKE_PERIOD_NOT_PASSED ); - self.handle_unstaked_tokens( - unstake_token_attributes, - &mut total_unstake_amount, - payment.token_nonce, - ); + let total_unstake_amount = + self.handle_unstake_amount(unstake_token_attributes, payment.token_nonce); + self.send().direct_egld(&caller, &total_unstake_amount); } - fn handle_unstaked_tokens( + fn handle_unstake_amount( &self, unstake_token_attributes: UnstakeTokenAttributes, - total_unstake_amount: &mut BigUint, nonce: u64, - ) { + ) -> BigUint { let delegation_contract = unstake_token_attributes.delegation_contract.clone(); let unstake_amount = unstake_token_attributes.unstake_amount.clone(); let delegation_contract_mapper = self.delegation_contract_data(&delegation_contract); @@ -75,7 +70,7 @@ pub trait UnbondModule: contract_data.total_unbonded_from_ls_contract -= &unstake_amount }); - *total_unstake_amount += unstake_amount; self.burn_unstake_tokens(nonce); + unstake_amount } }