Skip to content

Commit 6e0bc3f

Browse files
committed
small framework syntax updates
1 parent 3c22d9a commit 6e0bc3f

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

dex/pair/src/pair_actions/remove_liq.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
contexts::remove_liquidity::RemoveLiquidityContext, StorageCache, SwapTokensOrder,
33
ERROR_BAD_PAYMENT_TOKENS, ERROR_INVALID_ARGS, ERROR_K_INVARIANT_FAILED,
4-
ERROR_LP_TOKEN_NOT_ISSUED, ERROR_NOT_ACTIVE, ERROR_NOT_WHITELISTED, ERROR_SLIPPAGE_ON_REMOVE,
4+
ERROR_LP_TOKEN_NOT_ISSUED, ERROR_NOT_ACTIVE, ERROR_NOT_WHITELISTED,
55
};
66

77
use super::common_result_types::RemoveLiquidityResultType;
@@ -86,15 +86,6 @@ pub trait RemoveLiquidityModule:
8686
let output_payments =
8787
self.build_remove_liq_output_payments(&storage_cache, &remove_liq_context);
8888

89-
require!(
90-
output_payments.get(0).amount >= remove_liq_context.first_token_amount_min,
91-
ERROR_SLIPPAGE_ON_REMOVE
92-
);
93-
require!(
94-
output_payments.get(1).amount >= remove_liq_context.second_token_amount_min,
95-
ERROR_SLIPPAGE_ON_REMOVE
96-
);
97-
9889
self.send_multiple_tokens_if_not_zero(&caller, &output_payments);
9990

10091
self.emit_remove_liquidity_event(&storage_cache, remove_liq_context);

dex/pair/src/safe_price.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,10 @@ pub trait SafePriceModule:
268268
observation.lp_supply_accumulated += BigUint::from(weight) * lp_supply;
269269
observation.weight_accumulated += weight;
270270
observation.recording_round = current_round;
271-
observation.recording_timestamp = self.blockchain().get_block_timestamp();
271+
observation.recording_timestamp = self
272+
.blockchain()
273+
.get_block_timestamp_seconds()
274+
.as_u64_seconds();
272275
}
273276

274277
fn compute_new_observation(

farm-staking/farm-staking/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ pub trait FarmStaking:
9797
let current_epoch = self.blockchain().get_block_epoch();
9898
self.first_week_start_epoch().set_if_empty(current_epoch);
9999

100-
// Initialize last_reward_timestamp
101-
let current_timestamp = self.blockchain().get_block_timestamp_seconds();
102-
self.last_reward_timestamp().set_if_empty(current_timestamp);
103-
104100
// Farm position migration code
105101
let farm_token_mapper = self.farm_token();
106102
self.try_set_farm_position_migration_nonce(farm_token_mapper);
@@ -128,7 +124,7 @@ pub trait FarmStaking:
128124
let per_block_reward = per_block_reward_amount_mapper.take();
129125

130126
let block_nonce_diff = current_block_nonce - last_reward_nonce;
131-
if per_block_reward > 0 {
127+
if self.produces_per_second_rewards() {
132128
// CALCULATE PER BLOCK REWARDS
133129
let extra_rewards_unbounded = if current_block_nonce <= last_reward_nonce {
134130
BigUint::zero()
@@ -138,8 +134,9 @@ pub trait FarmStaking:
138134

139135
let farm_token_supply = self.farm_token_supply().get();
140136
let max_apr = self.max_annual_percentage_rewards().get();
141-
let extra_rewards_apr_bounded_per_block =
142-
farm_token_supply * &max_apr / MAX_PERCENT / (SECONDS_IN_YEAR.as_u64_seconds() / 6u64);
137+
let extra_rewards_apr_bounded_per_block = farm_token_supply * &max_apr
138+
/ MAX_PERCENT
139+
/ (SECONDS_IN_YEAR.as_u64_seconds() / 6u64);
143140

144141
let extra_rewards_apr_bounded = extra_rewards_apr_bounded_per_block * block_nonce_diff;
145142

0 commit comments

Comments
 (0)