From 2f52e1a00a05ebf00edf0369f7a01516c902d319 Mon Sep 17 00:00:00 2001 From: Dorin Marian Iancu Date: Tue, 30 Jan 2024 10:41:12 +0200 Subject: [PATCH] example hook impl --- Cargo.toml | 3 + dex/pair/src/pair_actions/add_liq.rs | 4 +- dex/pair/src/pair_actions/remove_liq.rs | 14 +- dex/pair/src/pair_actions/swap.rs | 15 +- dex/pair/src/pair_hooks/hook_type.rs | 65 +++ dex/sample-hooks/pair-hooks-sample/Cargo.toml | 21 + .../pair-hooks-sample/meta/Cargo.toml | 12 + .../pair-hooks-sample/meta/src/main.rs | 3 + .../pair-hooks-sample/multiversx.json | 3 + dex/sample-hooks/pair-hooks-sample/src/lib.rs | 140 ++++++ .../pair-hooks-sample/wasm/Cargo.lock | 407 ++++++++++++++++++ .../pair-hooks-sample/wasm/Cargo.toml | 31 ++ .../pair-hooks-sample/wasm/src/lib.rs | 28 ++ 13 files changed, 739 insertions(+), 7 deletions(-) create mode 100644 dex/sample-hooks/pair-hooks-sample/Cargo.toml create mode 100644 dex/sample-hooks/pair-hooks-sample/meta/Cargo.toml create mode 100644 dex/sample-hooks/pair-hooks-sample/meta/src/main.rs create mode 100644 dex/sample-hooks/pair-hooks-sample/multiversx.json create mode 100644 dex/sample-hooks/pair-hooks-sample/src/lib.rs create mode 100644 dex/sample-hooks/pair-hooks-sample/wasm/Cargo.lock create mode 100644 dex/sample-hooks/pair-hooks-sample/wasm/Cargo.toml create mode 100644 dex/sample-hooks/pair-hooks-sample/wasm/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index dbdd0d3ec..d3c9de76a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,9 @@ members = [ "dex/pair-mock", "dex/pair-mock/meta", + "dex/sample-hooks/pair-hooks-sample", + "dex/sample-hooks/pair-hooks-sample/meta", + "energy-integration/energy-factory-mock", "energy-integration/energy-factory-mock/meta", "energy-integration/energy-update", diff --git a/dex/pair/src/pair_actions/add_liq.rs b/dex/pair/src/pair_actions/add_liq.rs index 62a52b1b6..a2372e5cc 100644 --- a/dex/pair/src/pair_actions/add_liq.rs +++ b/dex/pair/src/pair_actions/add_liq.rs @@ -79,7 +79,7 @@ pub trait AddLiquidityModule: (HookType::BeforeAddLiq, HookType::AfterAddLiq) }; let payments_after_hook = - self.call_hook(hook_type_before, caller.clone(), payments_vec, args.clone()); + self.call_hook(hook_type_before, caller.clone(), payments_vec, args); let first_payment = payments_after_hook.get(0); let second_payment = payments_after_hook.get(1); @@ -133,7 +133,7 @@ pub trait AddLiquidityModule: hook_type_after, caller.clone(), ManagedVec::from_single_item(lp_payment), - args, + ManagedVec::new(), ); lp_payment = lp_payment_after_hook.get(0); diff --git a/dex/pair/src/pair_actions/remove_liq.rs b/dex/pair/src/pair_actions/remove_liq.rs index eab4bcc8b..0a850488a 100644 --- a/dex/pair/src/pair_actions/remove_liq.rs +++ b/dex/pair/src/pair_actions/remove_liq.rs @@ -2,6 +2,7 @@ use crate::{ contexts::remove_liquidity::RemoveLiquidityContext, pair_hooks::hook_type::HookType, StorageCache, SwapTokensOrder, ERROR_BAD_PAYMENT_TOKENS, ERROR_INVALID_ARGS, ERROR_K_INVARIANT_FAILED, ERROR_LP_TOKEN_NOT_ISSUED, ERROR_NOT_ACTIVE, ERROR_NOT_WHITELISTED, + ERROR_SLIPPAGE_ON_REMOVE, }; use super::common_result_types::RemoveLiquidityResultType; @@ -74,7 +75,7 @@ pub trait RemoveLiquidityModule: HookType::BeforeRemoveLiq, caller.clone(), ManagedVec::from_single_item(payment), - args.clone(), + ManagedVec::new(), ); let payment = payments_after_hook.get(0); @@ -105,6 +106,17 @@ pub trait RemoveLiquidityModule: args, ); + let first_payment_after = output_payments_after_hook.get(0); + let second_payment_after = output_payments_after_hook.get(1); + require!( + first_payment_after.amount >= remove_liq_context.first_token_amount_min, + ERROR_SLIPPAGE_ON_REMOVE + ); + require!( + second_payment_after.amount >= remove_liq_context.second_token_amount_min, + ERROR_SLIPPAGE_ON_REMOVE + ); + self.send_multiple_tokens_if_not_zero(&caller, &output_payments_after_hook); self.emit_remove_liquidity_event(&storage_cache, remove_liq_context); diff --git a/dex/pair/src/pair_actions/swap.rs b/dex/pair/src/pair_actions/swap.rs index 579b1ff1f..dbf52911e 100644 --- a/dex/pair/src/pair_actions/swap.rs +++ b/dex/pair/src/pair_actions/swap.rs @@ -127,8 +127,6 @@ pub trait SwapModule: let mut args = ManagedVec::new(); self.encode_arg_to_vec(&SwapType::FixedInput, &mut args); - self.encode_arg_to_vec(&token_out, &mut args); - self.encode_arg_to_vec(&amount_out_min, &mut args); let payments_after_hook = self.call_hook( HookType::BeforeSwap, @@ -138,6 +136,9 @@ pub trait SwapModule: ); let payment = payments_after_hook.get(0); + self.encode_arg_to_vec(&token_out, &mut args); + self.encode_arg_to_vec(&amount_out_min, &mut args); + let mut swap_context = SwapContext::new( payment.token_identifier, payment.amount, @@ -167,6 +168,11 @@ pub trait SwapModule: let output_payments_after_hook = self.call_hook(HookType::AfterSwap, caller.clone(), output_payments, args); + require!( + output_payments_after_hook.get(0).amount >= swap_context.output_token_amount, + ERROR_SLIPPAGE_EXCEEDED + ); + self.send_multiple_tokens_if_not_zero(&caller, &output_payments_after_hook); self.emit_swap_event(&storage_cache, swap_context); @@ -209,8 +215,6 @@ pub trait SwapModule: let mut args = ManagedVec::new(); self.encode_arg_to_vec(&SwapType::FixedOutput, &mut args); - self.encode_arg_to_vec(&token_out, &mut args); - self.encode_arg_to_vec(&amount_out, &mut args); let payments_after_hook = self.call_hook( HookType::BeforeSwap, @@ -220,6 +224,9 @@ pub trait SwapModule: ); let payment = payments_after_hook.get(0); + self.encode_arg_to_vec(&token_out, &mut args); + self.encode_arg_to_vec(&amount_out, &mut args); + let mut swap_context = SwapContext::new( payment.token_identifier, payment.amount, diff --git a/dex/pair/src/pair_hooks/hook_type.rs b/dex/pair/src/pair_hooks/hook_type.rs index f18a84496..63c7ca67e 100644 --- a/dex/pair/src/pair_hooks/hook_type.rs +++ b/dex/pair/src/pair_hooks/hook_type.rs @@ -1,3 +1,5 @@ +use crate::pair_actions::swap::SwapType; + multiversx_sc::imports!(); multiversx_sc::derive_imports!(); @@ -21,3 +23,66 @@ pub struct Hook { pub dest_address: ManagedAddress, pub endpoint_name: ManagedBuffer, } + +pub trait PairHook { + type Sc: ContractBase; + + fn before_add_initial_liq( + sc: &Self::Sc, + first_payment: EsdtTokenPayment<::Api>, + second_payment: EsdtTokenPayment<::Api>, + original_caller: ManagedAddress<::Api>, + ); + + fn after_add_initial_liq( + sc: &Self::Sc, + lp_payment: EsdtTokenPayment<::Api>, + original_caller: ManagedAddress<::Api>, + ); + + fn before_add_liq( + sc: &Self::Sc, + first_payment: EsdtTokenPayment<::Api>, + second_payment: EsdtTokenPayment<::Api>, + original_caller: ManagedAddress<::Api>, + first_token_amount_min: BigUint<::Api>, + second_token_amount_min: BigUint<::Api>, + ); + + fn after_add_liq( + sc: &Self::Sc, + lp_payment: EsdtTokenPayment<::Api>, + original_caller: ManagedAddress<::Api>, + ); + + fn before_remove_liq( + sc: &Self::Sc, + lp_payment: EsdtTokenPayment<::Api>, + original_caller: ManagedAddress<::Api>, + ); + + fn after_remove_liq( + sc: &Self::Sc, + first_payment: EsdtTokenPayment<::Api>, + second_payment: EsdtTokenPayment<::Api>, + original_caller: ManagedAddress<::Api>, + first_token_amount_min: BigUint<::Api>, + second_token_amount_min: BigUint<::Api>, + ); + + fn before_swap( + sc: &Self::Sc, + payment: EsdtTokenPayment<::Api>, + original_caller: ManagedAddress<::Api>, + swap_type: SwapType, + ); + + fn after_swap( + sc: &Self::Sc, + payment: EsdtTokenPayment<::Api>, + original_caller: ManagedAddress<::Api>, + swap_type: SwapType, + token_out: TokenIdentifier<::Api>, + amount_out: BigUint<::Api>, + ); +} diff --git a/dex/sample-hooks/pair-hooks-sample/Cargo.toml b/dex/sample-hooks/pair-hooks-sample/Cargo.toml new file mode 100644 index 000000000..211b40099 --- /dev/null +++ b/dex/sample-hooks/pair-hooks-sample/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "pair-hooks-sample" +version = "0.0.0" +authors = ["you"] +edition = "2021" +publish = false + +[lib] +path = "src/lib.rs" + +[dependencies.multiversx-sc] +version = "=0.46.1" + +[dependencies.pair] +path = "../../pair" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dev-dependencies.multiversx-sc-scenario] +version = "=0.46.1" diff --git a/dex/sample-hooks/pair-hooks-sample/meta/Cargo.toml b/dex/sample-hooks/pair-hooks-sample/meta/Cargo.toml new file mode 100644 index 000000000..06eda390c --- /dev/null +++ b/dex/sample-hooks/pair-hooks-sample/meta/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "pair-hooks-sample-meta" +version = "0.0.0" +edition = "2021" +publish = false + +[dependencies.pair-hooks-sample] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "=0.46.1" +default-features = false diff --git a/dex/sample-hooks/pair-hooks-sample/meta/src/main.rs b/dex/sample-hooks/pair-hooks-sample/meta/src/main.rs new file mode 100644 index 000000000..956f28e39 --- /dev/null +++ b/dex/sample-hooks/pair-hooks-sample/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/dex/sample-hooks/pair-hooks-sample/multiversx.json b/dex/sample-hooks/pair-hooks-sample/multiversx.json new file mode 100644 index 000000000..736553962 --- /dev/null +++ b/dex/sample-hooks/pair-hooks-sample/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/dex/sample-hooks/pair-hooks-sample/src/lib.rs b/dex/sample-hooks/pair-hooks-sample/src/lib.rs new file mode 100644 index 000000000..b76d0137e --- /dev/null +++ b/dex/sample-hooks/pair-hooks-sample/src/lib.rs @@ -0,0 +1,140 @@ +#![no_std] + +use core::marker::PhantomData; + +use pair::pair_hooks::hook_type::PairHook; + +multiversx_sc::imports!(); + +#[multiversx_sc::contract] +pub trait PairHooksSample { + #[init] + fn init(&self, known_pairs: MultiValueEncoded) { + let mapper = self.known_pairs(); + for pair in known_pairs { + mapper.add(&pair); + } + } + + #[payable("*")] + #[endpoint(beforeAddInitialLiqHook)] + fn before_add_initial_liq_hook(&self, original_caller: ManagedAddress) { + self.require_known_pair(); + + let [first_payment, second_payment] = self.call_value().multi_esdt(); + Wrapper::::before_add_initial_liq( + self, + first_payment, + second_payment, + original_caller, + ); + } + + #[payable("*")] + #[endpoint(afterAddInitialLiqHook)] + fn after_add_initial_liq_hook(&self, original_caller: ManagedAddress) { + self.require_known_pair(); + + let lp_payment = self.call_value().single_esdt(); + Wrapper::::after_add_initial_liq(self, lp_payment, original_caller); + } + + fn require_known_pair(&self) { + let caller = self.blockchain().get_caller(); + require!( + self.known_pairs().contains(&caller), + "Only known pairs may call this endpoint" + ); + } + + #[storage_mapper("knownPairs")] + fn known_pairs(&self) -> WhitelistMapper; +} + +pub struct Wrapper { + _phantom: PhantomData, +} + +impl PairHook for Wrapper { + type Sc = T; + + fn before_add_initial_liq( + sc: &Self::Sc, + first_payment: EsdtTokenPayment<::Api>, + second_payment: EsdtTokenPayment<::Api>, + _original_caller: ManagedAddress<::Api>, + ) { + let caller = sc.blockchain().get_caller(); + sc.send() + .direct_non_zero_esdt_payment(&caller, &first_payment); + sc.send() + .direct_non_zero_esdt_payment(&caller, &second_payment); + } + + fn after_add_initial_liq( + sc: &Self::Sc, + lp_payment: EsdtTokenPayment<::Api>, + _original_caller: ManagedAddress<::Api>, + ) { + let caller = sc.blockchain().get_caller(); + sc.send().direct_non_zero_esdt_payment(&caller, &lp_payment); + } + + fn before_add_liq( + _sc: &Self::Sc, + _first_payment: EsdtTokenPayment<::Api>, + _second_payment: EsdtTokenPayment<::Api>, + _original_caller: ManagedAddress<::Api>, + _first_token_amount_min: BigUint<::Api>, + _second_token_amount_min: BigUint<::Api>, + ) { + todo!() + } + + fn after_add_liq( + _sc: &Self::Sc, + _lp_payment: EsdtTokenPayment<::Api>, + _original_caller: ManagedAddress<::Api>, + ) { + todo!() + } + + fn before_remove_liq( + _sc: &Self::Sc, + _lp_payment: EsdtTokenPayment<::Api>, + _original_caller: ManagedAddress<::Api>, + ) { + todo!() + } + + fn after_remove_liq( + _sc: &Self::Sc, + _first_payment: EsdtTokenPayment<::Api>, + _second_payment: EsdtTokenPayment<::Api>, + _original_caller: ManagedAddress<::Api>, + _first_token_amount_min: BigUint<::Api>, + _second_token_amount_min: BigUint<::Api>, + ) { + todo!() + } + + fn before_swap( + _sc: &Self::Sc, + _payment: EsdtTokenPayment<::Api>, + _original_caller: ManagedAddress<::Api>, + _swap_type: pair::pair_actions::swap::SwapType, + ) { + todo!() + } + + fn after_swap( + _sc: &Self::Sc, + _payment: EsdtTokenPayment<::Api>, + _original_caller: ManagedAddress<::Api>, + _swap_type: pair::pair_actions::swap::SwapType, + _token_out: TokenIdentifier<::Api>, + _amount_out: BigUint<::Api>, + ) { + todo!() + } +} diff --git a/dex/sample-hooks/pair-hooks-sample/wasm/Cargo.lock b/dex/sample-hooks/pair-hooks-sample/wasm/Cargo.lock new file mode 100644 index 000000000..b4c6c24cc --- /dev/null +++ b/dex/sample-hooks/pair-hooks-sample/wasm/Cargo.lock @@ -0,0 +1,407 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "common-types" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "common_errors" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "common_structs" +version = "0.0.0" +dependencies = [ + "fixed-supply-token", + "math", + "mergeable", + "multiversx-sc", + "unwrappable", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "energy-factory" +version = "0.0.0" +dependencies = [ + "common_structs", + "legacy_token_decode_module", + "math", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "sc_whitelist_module", + "simple-lock", + "unwrappable", + "utils", +] + +[[package]] +name = "energy-query" +version = "0.0.0" +dependencies = [ + "energy-factory", + "multiversx-sc", +] + +[[package]] +name = "fees-collector" +version = "0.0.0" +dependencies = [ + "common-types", + "common_errors", + "energy-factory", + "energy-query", + "locking_module", + "multiversx-sc", + "multiversx-sc-modules", + "sc_whitelist_module", + "simple-lock", + "utils", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "fixed-supply-token" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +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 = "legacy_token_decode_module" +version = "0.0.0" +dependencies = [ + "common_structs", + "multiversx-sc", + "utils", +] + +[[package]] +name = "locking_module" +version = "0.0.0" +dependencies = [ + "energy-factory", + "multiversx-sc", + "simple-lock", +] + +[[package]] +name = "math" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "mergeable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c94b173dc5ff0e157f767275fe6b7a1b4d2ad343bef7b66cd22a6353e016b93" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19908153158c03df4582af08f47c0eb39fb52a7dff4736b301a66acbbb9955d3" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b03b43f9cad320992f54ed162de2ed63e3ec83ed01361e57ee9c1865fba5a2" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b78945957036c281ad6ee21bb5120dcefa2017688adf43ec94e3e7c982efb09" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-modules" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c63ffaba95e630ff75981e2f5f50da64f523219b52f484234c66f3adc248885f" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9579f40c00da56a5a68e010ff851fa48ac7b9c6a16ad4314795cb32d889d9e78" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "pair" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "fees-collector", + "itertools", + "multiversx-sc", + "pausable", + "permissions_module", + "simple-lock", + "token_send", + "utils", +] + +[[package]] +name = "pair-hooks-sample" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "pair", +] + +[[package]] +name = "pair-hooks-sample-wasm" +version = "0.0.0" +dependencies = [ + "multiversx-sc-wasm-adapter", + "pair-hooks-sample", +] + +[[package]] +name = "pausable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "permissions_module", +] + +[[package]] +name = "permissions_module" +version = "0.0.0" +dependencies = [ + "bitflags", + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "sc_whitelist_module" +version = "0.0.0" +dependencies = [ + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "simple-lock" +version = "0.0.0" +dependencies = [ + "common_structs", + "multiversx-sc", + "multiversx-sc-modules", +] + +[[package]] +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "token_send" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "multiversx-sc", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unwrappable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "utils" +version = "0.0.0" +dependencies = [ + "common_structs", + "fixed-supply-token", + "mergeable", + "multiversx-sc", +] + +[[package]] +name = "week-timekeeping" +version = "0.0.0" +dependencies = [ + "common-types", + "multiversx-sc", +] + +[[package]] +name = "weekly-rewards-splitting" +version = "0.0.0" +dependencies = [ + "common-types", + "energy-query", + "math", + "multiversx-sc", + "unwrappable", + "week-timekeeping", +] diff --git a/dex/sample-hooks/pair-hooks-sample/wasm/Cargo.toml b/dex/sample-hooks/pair-hooks-sample/wasm/Cargo.toml new file mode 100644 index 000000000..9ce799efc --- /dev/null +++ b/dex/sample-hooks/pair-hooks-sample/wasm/Cargo.toml @@ -0,0 +1,31 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "pair-hooks-sample-wasm" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[profile.release] +codegen-units = 1 +opt-level = "z" +lto = true +debug = false +panic = "abort" +overflow-checks = false + +[dependencies.pair-hooks-sample] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "=0.46.1" + +[workspace] +members = ["."] diff --git a/dex/sample-hooks/pair-hooks-sample/wasm/src/lib.rs b/dex/sample-hooks/pair-hooks-sample/wasm/src/lib.rs new file mode 100644 index 000000000..a059bba6b --- /dev/null +++ b/dex/sample-hooks/pair-hooks-sample/wasm/src/lib.rs @@ -0,0 +1,28 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 2 +// Async Callback (empty): 1 +// Total number of exported functions: 4 + +#![no_std] +#![allow(internal_features)] +#![feature(lang_items)] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + pair_hooks_sample + ( + init => init + beforeAddInitialLiqHook => before_add_initial_liq_hook + afterAddInitialLiqHook => after_add_initial_liq_hook + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {}