Skip to content

Commit

Permalink
Merge branch 'rc/v3.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
psorinionut committed Oct 3, 2024
2 parents 3d3b44a + 58e2809 commit 2b0ec52
Show file tree
Hide file tree
Showing 181 changed files with 1,466 additions and 1,046 deletions.
405 changes: 224 additions & 181 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/common_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/common_structs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.mergeable]
Expand Down
2 changes: 1 addition & 1 deletion common/modules/farm/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
4 changes: 2 additions & 2 deletions common/modules/farm/contexts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.52.3"
version = "=0.53.2"
2 changes: 1 addition & 1 deletion common/modules/farm/events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ path = "../../../common_structs"
path = "../contexts"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
6 changes: 3 additions & 3 deletions common/modules/farm/farm_base_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ path = "../../../traits/mergeable"
path = "../../../traits/fixed-supply-token"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.52.3"
version = "=0.53.2"

[dev-dependencies.multiversx-sc-scenario]
version = "=0.52.3"
version = "=0.53.2"
4 changes: 2 additions & 2 deletions common/modules/farm/farm_token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.52.3"
version = "=0.53.2"
4 changes: 2 additions & 2 deletions common/modules/farm/farm_token_merge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ path = "../../token_merge_helper"
path = "../farm_token"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.52.3"
version = "=0.53.2"

[workspace]
members = ["."]
4 changes: 2 additions & 2 deletions common/modules/farm/rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ path = "../../pausable"
path = "../../permissions_module"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.52.3"
version = "=0.53.2"
2 changes: 1 addition & 1 deletion common/modules/legacy_token_decode_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.common_structs]
Expand Down
2 changes: 1 addition & 1 deletion common/modules/locking_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.simple-lock]
Expand Down
2 changes: 1 addition & 1 deletion common/modules/math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/pausable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ path = "src/pausable.rs"
path = "../permissions_module"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/permissions_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ bitflags = "2.4.1"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/sc_whitelist_module/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ path = "src/sc_whitelist_module.rs"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/token_merge_helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ path = "src/lib.rs"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/token_send/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ path = "../../common_structs"
path = "../../common_errors"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/modules/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.common_structs]
Expand Down
2 changes: 1 addition & 1 deletion common/traits/fixed-supply-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
2 changes: 1 addition & 1 deletion common/traits/mergeable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
2 changes: 1 addition & 1 deletion common/traits/unwrappable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
path = "src/lib.rs"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
6 changes: 3 additions & 3 deletions dex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ edition = "2021"
publish = false

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dev-dependencies]
num-bigint = "0.4.2"

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

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

[dev-dependencies.config]
path = "../common/modules/farm/config"
Expand Down
6 changes: 3 additions & 3 deletions dex/farm-with-locked-rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ path = "../../locked-asset/energy-factory"
path = "../../energy-integration/common-modules/energy-query"

[dependencies.multiversx-sc]
version = "=0.52.3"
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]

[dependencies.multiversx-sc-modules]
version = "=0.52.3"
version = "=0.53.2"

[dev-dependencies]
num-bigint = "0.4.2"

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

[dev-dependencies.simple-lock]
path = "../../locked-asset/simple-lock"
2 changes: 1 addition & 1 deletion dex/farm-with-locked-rewards/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ publish = false
path = ".."

[dependencies.multiversx-sc-meta]
version = "0.52.3"
version = "0.53.2"
default-features = false
6 changes: 5 additions & 1 deletion dex/farm-with-locked-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ pub trait Farm:
);
}

require!(
!self.user_total_farm_position(user).is_empty(),
"User total farm position is empty!"
);

let mut storage_cache = StorageCache::new(self);
self.validate_contract_state(storage_cache.contract_state, &storage_cache.farm_token_id);
NoMintWrapper::<Self>::generate_aggregated_rewards(self, &mut storage_cache);
Expand Down Expand Up @@ -266,7 +271,6 @@ pub trait Farm:
require!(percentage <= MAX_PERCENT, "Invalid percentage");

let mut storage_cache = StorageCache::new(self);
self.validate_contract_state(storage_cache.contract_state, &storage_cache.farm_token_id);
NoMintWrapper::<Self>::generate_aggregated_rewards(self, &mut storage_cache);

self.boosted_yields_rewards_percentage().set(percentage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![allow(deprecated)]

use common_structs::FarmTokenAttributes;
use multiversx_sc::codec::Empty;
use farm_with_locked_rewards::Farm;
use multiversx_sc::{codec::Empty, imports::OptionalValue};
use multiversx_sc_scenario::{managed_address, managed_biguint, rust_biguint, DebugApi};
use simple_lock::locked_token::LockedTokenAttributes;

Expand Down Expand Up @@ -503,11 +504,19 @@ fn claim_boosted_rewards_with_zero_position_test() {
farm_setup.b_mock.set_block_nonce(20);
farm_setup.b_mock.set_block_epoch(13);

let second_week_received_reward_amt =
farm_setup.claim_boosted_rewards_for_user(&temp_user, &temp_user, 0);
farm_setup
.b_mock
.execute_tx(
&temp_user,
&farm_setup.farm_wrapper,
&rust_biguint!(0),
|sc| {
sc.claim_boosted_rewards(OptionalValue::Some(managed_address!(&temp_user)));
},
)
.assert_error(4, "User total farm position is empty!");

assert_eq!(second_week_received_reward_amt, 0);
farm_setup.check_farm_rps(150_000_000u64);
farm_setup.check_farm_rps(75_000_000u64);

// advance 1 week
let boosted_rewards = 2_500;
Expand All @@ -517,14 +526,52 @@ fn claim_boosted_rewards_with_zero_position_test() {
let third_week_received_reward_amt =
farm_setup.claim_boosted_rewards_for_user(&first_user, &first_user, 1);

assert_eq!(third_week_received_reward_amt, boosted_rewards * 2); // user receives rewards for weeks 1 and 2)
assert_eq!(third_week_received_reward_amt, boosted_rewards);
farm_setup.check_farm_rps(225_000_000u64);

farm_setup.b_mock.check_nft_balance::<Empty>(
&first_user,
LOCKED_REWARD_TOKEN_ID,
1,
&rust_biguint!(boosted_rewards * 2),
&rust_biguint!(boosted_rewards),
None,
);
}

#[test]
fn claim_boosted_rewards_user_energy_not_registered_test() {
DebugApi::dummy();
let mut farm_setup = FarmSetup::new(
farm_with_locked_rewards::contract_obj,
energy_factory::contract_obj,
);

farm_setup.set_boosted_yields_rewards_percentage(BOOSTED_YIELDS_PERCENTAGE);
farm_setup.set_boosted_yields_factors();
farm_setup.b_mock.set_block_epoch(2);

let first_user = farm_setup.first_user.clone();
let farm_in_amount = 100_000_000;

farm_setup.set_user_energy(&first_user, 1_000, 2, 1);

// Attempt to claim boosted rewards without entering the farm
farm_setup
.b_mock
.execute_tx(
&first_user,
&farm_setup.farm_wrapper,
&rust_biguint!(0),
|sc| {
sc.claim_boosted_rewards(OptionalValue::Some(managed_address!(&first_user)));
},
)
.assert_error(4, "User total farm position is empty!");

// User enters the farm
farm_setup.enter_farm(&first_user, farm_in_amount);

// Now the user should be able to claim boosted rewards
// Rewards computation is out of scope
farm_setup.claim_boosted_rewards_for_user(&first_user, &first_user, 0);
}
Loading

0 comments on commit 2b0ec52

Please sign in to comment.