Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc/v3.0.1.5 #972

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1a27f49
dummy commit
dorin-iancu May 16, 2024
0458214
just some cleanup
dorin-iancu Nov 12, 2024
742664f
small fix
dorin-iancu Nov 12, 2024
9a4f4a8
setter
dorin-iancu Nov 12, 2024
e04a6f2
disable add liq for old proxy
dorin-iancu Nov 12, 2024
efb6797
common module + disable in simple lock
dorin-iancu Nov 12, 2024
2028bd6
remove useless dependency
dorin-iancu Nov 12, 2024
b5146b4
change undistributed rewards code
dorin-iancu Nov 12, 2024
a2f0007
Merge pull request #969 from multiversx/all-xmex-fees-to-users
dorin-iancu Nov 13, 2024
a1d02b0
Merge branch 'rc/v3.0.1.5' into no-more-add-liq-with-locked-tokens
dorin-iancu Nov 13, 2024
cca4b51
evil clippy
dorin-iancu Nov 13, 2024
94d6506
Merge pull request #970 from multiversx/no-more-add-liq-with-locked-t…
dorin-iancu Nov 13, 2024
64319c1
Merge branch 'rc/v3.0.1.5' into change-undistributed-rew-code
dorin-iancu Nov 13, 2024
b2beb0d
Merge pull request #971 from multiversx/change-undistributed-rew-code
dorin-iancu Nov 13, 2024
5258ca5
additional tests for add liq disabled
dorin-iancu Nov 14, 2024
4f70ada
evil clippy
dorin-iancu Nov 14, 2024
78df98b
Merge pull request #973 from multiversx/additional-tests-add-liq
dorin-iancu Nov 15, 2024
d3123dc
change disable add liq code
dorin-iancu Nov 15, 2024
12c7a3a
build
dorin-iancu Nov 15, 2024
3515201
Merge pull request #975 from multiversx/change-negative-storage
dorin-iancu Nov 27, 2024
95f6a63
Merge branch 'main' of https://github.com/multiversx/mx-exchange-sc
dorin-iancu Dec 2, 2024
7ff912d
Merge branch 'main' into merge-rc/v3.0.1.5-with-main
dorin-iancu Dec 2, 2024
bfc76cb
Merge pull request #981 from multiversx/merge-rc/v3.0.1.5-with-main
dorin-iancu Dec 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions common/modules/disable-add-liq/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "disable-add-liq"
version = "0.0.0"
authors = ["Dorin Iancu <[email protected]>"]
edition = "2021"

[lib]
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
32 changes: 32 additions & 0 deletions common/modules/disable-add-liq/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![no_std]

multiversx_sc::imports!();

pub const ADD_LIQ_ENABLED: bool = true;
pub const ADD_LIQ_DISABLED: bool = false;

#[multiversx_sc::module]
pub trait DisableAddLiqModule {
#[only_owner]
#[endpoint(enableAddLiq)]
fn enable_add_liq(&self) {
self.add_liq_enabled().set(ADD_LIQ_ENABLED);
}

#[only_owner]
#[endpoint(disableAddLiq)]
fn disable_add_liq(&self) {
self.add_liq_enabled().set(ADD_LIQ_DISABLED);
}

fn require_add_liq_enabled(&self) {
require!(
self.add_liq_enabled().get() == ADD_LIQ_ENABLED,
"Add Liquidity is disabled"
);
}

#[view(isAddLiqEnabled)]
#[storage_mapper("addLiqEnabled")]
fn add_liq_enabled(&self) -> SingleValueMapper<bool>;
}
8 changes: 8 additions & 0 deletions dex/farm-with-locked-rewards/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions dex/farm-with-locked-rewards/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

// Init: 1
// Upgrade: 1
// Endpoints: 66
// Endpoints: 65
// Async Callback: 1
// Total number of exported functions: 69
// Total number of exported functions: 68

#![no_std]

Expand Down Expand Up @@ -71,7 +71,6 @@ multiversx_sc_wasm_adapter::endpoints! {
getAccumulatedRewardsForWeek => accumulated_rewards_for_week
getFarmSupplyForWeek => farm_supply_for_week
getRemainingBoostedRewardsToDistribute => remaining_boosted_rewards_to_distribute
getUndistributedBoostedRewards => undistributed_boosted_rewards
setBoostedYieldsFactors => set_boosted_yields_factors
getBoostedYieldsFactors => get_boosted_yields_factors
getCurrentWeek => get_current_week
Expand Down
8 changes: 5 additions & 3 deletions dex/farm/tests/farm_multi_user_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,14 @@ fn farm_multiple_claim_weeks_with_collect_undistributed_rewards_test() {

farm_setup.check_error_collect_undistributed_boosted_rewards(
"Current week must be higher than the week offset",
1,
4,
);

// advance to week 6
farm_setup.b_mock.set_block_epoch(36);

farm_setup.collect_undistributed_boosted_rewards();
farm_setup.collect_undistributed_boosted_rewards(1, 1);
farm_setup.check_undistributed_boosted_rewards(1);
farm_setup.check_remaining_boosted_rewards_to_distribute(1, 0);
farm_setup.check_remaining_boosted_rewards_to_distribute(2, 1);
Expand All @@ -704,7 +706,7 @@ fn farm_multiple_claim_weeks_with_collect_undistributed_rewards_test() {
// advance to week 8
farm_setup.b_mock.set_block_epoch(50);

farm_setup.collect_undistributed_boosted_rewards();
farm_setup.collect_undistributed_boosted_rewards(1, 3);
farm_setup.check_undistributed_boosted_rewards(3);

farm_setup.check_remaining_boosted_rewards_to_distribute(1, 0);
Expand Down Expand Up @@ -966,7 +968,7 @@ fn farm_claim_with_minimum_tokens() {
let remaining_boosted_yields_rewards =
total_boosted_yields_rewards - first_boosted_amt - second_boosted_amt;
farm_setup.check_undistributed_boosted_rewards(0);
farm_setup.collect_undistributed_boosted_rewards();
farm_setup.collect_undistributed_boosted_rewards(1, 1);
farm_setup.check_undistributed_boosted_rewards(remaining_boosted_yields_rewards);
farm_setup.check_remaining_boosted_rewards_to_distribute(1, 0);
farm_setup.check_remaining_boosted_rewards_to_distribute(2, 0);
Expand Down
55 changes: 44 additions & 11 deletions dex/farm/tests/farm_setup/multi_user_farm_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ use farm_boosted_yields::FarmBoostedYieldsModule;
use farm_token::FarmTokenModule;
use pausable::{PausableModule, State};
use sc_whitelist_module::SCWhitelistModule;
use week_timekeeping::Epoch;
use week_timekeeping::{Epoch, Week};
use weekly_rewards_splitting::update_claim_progress_energy::UpdateClaimProgressEnergyModule;

use super::single_user_farm_setup::MEX_TOKEN_ID;

pub static REWARD_TOKEN_ID: &[u8] = b"REW-123456";
pub static FARMING_TOKEN_ID: &[u8] = b"LPTOK-123456";
pub static FARM_TOKEN_ID: &[u8] = b"FARM-123456";
Expand Down Expand Up @@ -65,6 +67,7 @@ where
pub first_user: Address,
pub second_user: Address,
pub third_user: Address,
pub undistributed_rew_dest: Address,
pub last_farm_token_nonce: u64,
pub farm_wrapper: ContractObjWrapper<farm::ContractObj<DebugApi>, FarmObjBuilder>,
pub energy_factory_wrapper:
Expand All @@ -91,6 +94,7 @@ where
let first_user = b_mock.create_user_account(&rust_zero);
let second_user = b_mock.create_user_account(&rust_zero);
let third_user = b_mock.create_user_account(&rust_zero);
let undistributed_rew_dest = b_mock.create_user_account(&rust_zero);
let farm_wrapper =
b_mock.create_sc_account(&rust_zero, Some(&owner), farm_builder, "farm.wasm");
let energy_factory_wrapper = b_mock.create_sc_account(
Expand All @@ -102,6 +106,20 @@ where
let eu_wrapper =
b_mock.create_sc_account(&rust_zero, Some(&owner), eu_builder, "energy update mock");

b_mock
.execute_tx(&owner, &energy_factory_wrapper, &rust_zero, |sc| {
sc.init();
sc.base_asset_token_id()
.set(managed_token_id!(MEX_TOKEN_ID));
})
.assert_ok();

b_mock.set_esdt_local_roles(
energy_factory_wrapper.address_ref(),
MEX_TOKEN_ID,
&[EsdtLocalRole::Mint],
);

b_mock
.execute_tx(&owner, &eu_wrapper, &rust_zero, |sc| {
sc.init();
Expand Down Expand Up @@ -185,6 +203,7 @@ where
first_user,
second_user,
third_user,
undistributed_rew_dest,
last_farm_token_nonce: 0,
farm_wrapper,
energy_factory_wrapper,
Expand Down Expand Up @@ -651,18 +670,33 @@ where
.assert_ok();
}

pub fn check_error_collect_undistributed_boosted_rewards(&mut self, expected_message: &str) {
pub fn check_error_collect_undistributed_boosted_rewards(
&mut self,
expected_message: &str,
start_week: Week,
end_week: Week,
) {
let dest_address = self.undistributed_rew_dest.clone();
self.b_mock
.execute_tx(&self.owner, &self.farm_wrapper, &rust_biguint!(0), |sc| {
sc.collect_undistributed_boosted_rewards();
sc.collect_undistributed_boosted_rewards(
start_week,
end_week,
managed_address!(&dest_address),
);
})
.assert_error(4, expected_message)
}

pub fn collect_undistributed_boosted_rewards(&mut self) {
pub fn collect_undistributed_boosted_rewards(&mut self, start_week: Week, end_week: Week) {
let dest_address = self.undistributed_rew_dest.clone();
self.b_mock
.execute_tx(&self.owner, &self.farm_wrapper, &rust_biguint!(0), |sc| {
sc.collect_undistributed_boosted_rewards();
sc.collect_undistributed_boosted_rewards(
start_week,
end_week,
managed_address!(&dest_address),
);
})
.assert_ok();
}
Expand All @@ -683,12 +717,11 @@ where
}

pub fn check_undistributed_boosted_rewards(&mut self, expected_amount: u64) {
self.b_mock
.execute_query(&self.farm_wrapper, |sc| {
let result_managed = sc.undistributed_boosted_rewards().get();
assert_eq!(result_managed, managed_biguint!(expected_amount));
})
.assert_ok();
self.b_mock.check_esdt_balance(
&self.undistributed_rew_dest,
MEX_TOKEN_ID,
&rust_biguint!(expected_amount),
);
}

pub fn check_farm_token_supply(&mut self, expected_farm_token_supply: u64) {
Expand Down
8 changes: 8 additions & 0 deletions dex/farm/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions dex/farm/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

// Init: 1
// Upgrade: 1
// Endpoints: 63
// Endpoints: 62
// Async Callback: 1
// Total number of exported functions: 66
// Total number of exported functions: 65

#![no_std]

Expand Down Expand Up @@ -68,7 +68,6 @@ multiversx_sc_wasm_adapter::endpoints! {
getAccumulatedRewardsForWeek => accumulated_rewards_for_week
getFarmSupplyForWeek => farm_supply_for_week
getRemainingBoostedRewardsToDistribute => remaining_boosted_rewards_to_distribute
getUndistributedBoostedRewards => undistributed_boosted_rewards
setBoostedYieldsFactors => set_boosted_yields_factors
getBoostedYieldsFactors => get_boosted_yields_factors
getCurrentWeek => get_current_week
Expand Down
3 changes: 3 additions & 0 deletions dex/pair/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ num-bigint = "0.4.2"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.53.2"

[dev-dependencies.disable-add-liq]
path = "../../common/modules/disable-add-liq"
1 change: 1 addition & 0 deletions dex/pair/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,4 @@ pub trait Pair<ContractReader>:
self.lp_token_identifier().set(&token_identifier);
}
}

Loading