Skip to content

Commit

Permalink
Merge branch 'main' into fees-collector-claim-boosted-rewards-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
psorinionut authored Dec 14, 2023
2 parents 26607bd + a49c37f commit 928ade7
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 161 deletions.
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 @@ -82,7 +82,11 @@ pub trait Farm:
}

#[endpoint]
fn upgrade(&self) {}
fn upgrade(&self) {
// Farm position migration code
let farm_token_mapper = self.farm_token();
self.try_set_farm_position_migration_nonce(farm_token_mapper);
}

#[payable("*")]
#[endpoint(enterFarm)]
Expand Down
6 changes: 5 additions & 1 deletion dex/farm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ pub trait Farm:
}

#[endpoint]
fn upgrade(&self) {}
fn upgrade(&self) {
// Farm position migration code
let farm_token_mapper = self.farm_token();
self.try_set_farm_position_migration_nonce(farm_token_mapper);
}

#[payable("*")]
#[endpoint(enterFarm)]
Expand Down
30 changes: 14 additions & 16 deletions energy-integration/governance-v2/src/configurable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub trait ConfigurablePropertiesModule:

#[only_owner]
#[endpoint(changeQuorumPercentage)]
fn change_quorum_percentage(&self, new_value: BigUint) {
fn change_quorum_percentage(&self, new_value: u64) {
self.try_change_quorum_percentage(new_value);
}

Expand All @@ -86,8 +86,6 @@ pub trait ConfigurablePropertiesModule:
}

fn try_change_min_energy_for_propose(&self, new_value: BigUint) {
require!(new_value != 0, "Min energy for proposal can't be set to 0");

self.min_energy_for_propose().set(&new_value);
}

Expand All @@ -104,40 +102,40 @@ pub trait ConfigurablePropertiesModule:
self.min_fee_for_propose().set(&new_value);
}

fn try_change_quorum_percentage(&self, new_value: BigUint) {
fn try_change_quorum_percentage(&self, new_quorum_percentage: u64) {
require!(
new_value > MIN_QUORUM && new_value < MAX_QUORUM,
(MIN_QUORUM..MAX_QUORUM).contains(&new_quorum_percentage),
"Not valid value for Quorum!"
);

self.quorum_percentage().set(&new_value);
self.quorum_percentage().set(new_quorum_percentage);
}

fn try_change_voting_delay_in_blocks(&self, new_value: u64) {
fn try_change_voting_delay_in_blocks(&self, new_voting_delay: u64) {
require!(
new_value > MIN_VOTING_DELAY && new_value < MAX_VOTING_DELAY,
(MIN_VOTING_DELAY..MAX_VOTING_DELAY).contains(&new_voting_delay),
"Not valid value for voting delay!"
);

self.voting_delay_in_blocks().set(new_value);
self.voting_delay_in_blocks().set(new_voting_delay);
}

fn try_change_voting_period_in_blocks(&self, new_value: u64) {
fn try_change_voting_period_in_blocks(&self, new_voting_period: u64) {
require!(
new_value > MIN_VOTING_PERIOD && new_value < MAX_VOTING_PERIOD,
(MIN_VOTING_PERIOD..MAX_VOTING_PERIOD).contains(&new_voting_period),
"Not valid value for voting period!"
);

self.voting_period_in_blocks().set(new_value);
self.voting_period_in_blocks().set(new_voting_period);
}

fn try_change_withdraw_percentage_defeated(&self, new_value: u64) {
fn try_change_withdraw_percentage_defeated(&self, new_withdraw_percentage: u64) {
require!(
new_value <= FULL_PERCENTAGE,
new_withdraw_percentage <= FULL_PERCENTAGE,
"Not valid value for withdraw percentage if defeated!"
);

self.withdraw_percentage_defeated().set(new_value);
self.withdraw_percentage_defeated().set(new_withdraw_percentage);
}

fn try_change_fee_token_id(&self, fee_token_id: TokenIdentifier) {
Expand All @@ -159,7 +157,7 @@ pub trait ConfigurablePropertiesModule:

#[view(getQuorum)]
#[storage_mapper("quorumPercentage")]
fn quorum_percentage(&self) -> SingleValueMapper<BigUint>;
fn quorum_percentage(&self) -> SingleValueMapper<u64>;

#[view(getVotingDelayInBlocks)]
#[storage_mapper("votingDelayInBlocks")]
Expand Down
4 changes: 2 additions & 2 deletions energy-integration/governance-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub trait GovernanceV2:
&self,
min_energy_for_propose: BigUint,
min_fee_for_propose: BigUint,
quorum_percentage: BigUint,
quorum_percentage: u64,
voting_delay_in_blocks: u64,
voting_period_in_blocks: u64,
withdraw_percentage_defeated: u64,
Expand Down Expand Up @@ -88,7 +88,7 @@ pub trait GovernanceV2:
EXEEDED_MAX_ACTIONS
);

let user_energy = self.get_energy_amount_non_zero(&proposer);
let user_energy = self.get_energy_amount(&proposer);
let min_energy_for_propose = self.min_energy_for_propose().get();
require!(user_energy >= min_energy_for_propose, NOT_ENOUGH_ENERGY);

Expand Down
4 changes: 2 additions & 2 deletions energy-integration/governance-v2/src/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub struct GovernanceProposal<M: ManagedTypeApi> {
pub actions: ArrayVec<GovernanceAction<M>, MAX_GOVERNANCE_PROPOSAL_ACTIONS>,
pub description: ManagedBuffer<M>,
pub fee_payment: EsdtTokenPayment<M>,
pub minimum_quorum: BigUint<M>,
pub minimum_quorum: u64,
pub voting_delay_in_blocks: u64,
pub voting_period_in_blocks: u64,
pub withdraw_percentage_defeated: u64,
Expand Down Expand Up @@ -100,7 +100,7 @@ impl<M: ManagedTypeApi> GovernanceProposal<M> {
token_nonce: 0,
amount: BigUint::zero(),
},
minimum_quorum: BigUint::default(),
minimum_quorum: 0,
voting_delay_in_blocks: 0,
voting_period_in_blocks: 0,
withdraw_percentage_defeated: 0,
Expand Down
2 changes: 1 addition & 1 deletion energy-integration/governance-v2/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub trait ViewsModule:
fn quorum_reached(&self, proposal_id: ProposalId) -> bool {
let proposal = self.proposals().get(proposal_id);
let total_quorum_for_proposal = proposal.total_quorum;
let required_minimum_percentage = proposal.minimum_quorum;
let required_minimum_percentage = BigUint::from(proposal.minimum_quorum);
let current_quorum = self.proposal_votes(proposal_id).get().quorum;

current_quorum * FULL_PERCENTAGE >= required_minimum_percentage * total_quorum_for_proposal
Expand Down
Loading

0 comments on commit 928ade7

Please sign in to comment.