Skip to content

Commit

Permalink
Merge pull request #662 from ElrondNetwork/fix-farm-staking-reserve
Browse files Browse the repository at this point in the history
fix farm staking reserve
  • Loading branch information
sasurobert authored Dec 14, 2022
2 parents ef9bf73 + c836ea7 commit f07a78f
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 365 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
<<<<<<< HEAD
=======
# See: https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container
container:
image: ${{ github.event.inputs.image }}
>>>>>>> main
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -71,15 +65,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
<<<<<<< HEAD
echo "Built using Docker image: **elrondnetwork/build-contract-rust:${{ github.event.inputs.image_tag }}**." >> notes.txt
echo "" >> notes.txt
echo "## Codehash (blake2b):" >> notes.txt
=======
echo "Built using Docker image: **${{ github.event.inputs.image }}**." >> notes.txt
echo "" >> notes.txt
echo "## Codehashes (SHA 256):" >> notes.txt
>>>>>>> main
echo "" >> notes.txt
for i in $(find ./assets -type f -name *.wasm); do
Expand Down
3 changes: 2 additions & 1 deletion common/common_structs/src/alias_types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
elrond_wasm::imports!();

use crate::{LockedAssetTokenAttributesEx, UnlockSchedule};
use crate::{LockedAssetTokenAttributes, LockedAssetTokenAttributesEx, UnlockSchedule};

pub type Nonce = u64;
pub type Epoch = u64;
Expand All @@ -9,3 +9,4 @@ pub type Percent = u64;
pub type PaymentsVec<M> = ManagedVec<M, EsdtTokenPayment<M>>;
pub type UnlockPeriod<M> = UnlockSchedule<M>;
pub type OldLockedTokenAttributes<M> = LockedAssetTokenAttributesEx<M>;
pub type InitialOldLockedTokenAttributes<M> = LockedAssetTokenAttributes<M>;
24 changes: 24 additions & 0 deletions common/common_structs/src/locked_token_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use crate::{Epoch, EpochAmountPair};
pub const MAX_MILESTONES_IN_SCHEDULE: usize = 64;
pub const PERCENTAGE_TOTAL_EX: u64 = 100_000u64;

pub const LOCKED_TOKEN_ACTIVATION_NONCE: u64 = 2_286_815u64;
pub const UPDATE_PERCENTAGE_CONST: u64 = 1_000u64;

#[derive(
ManagedVecItem,
TopEncode,
Expand Down Expand Up @@ -149,6 +152,27 @@ pub struct LockedAssetTokenAttributesEx<M: ManagedTypeApi> {
pub is_merged: bool,
}

impl<M: ManagedTypeApi> LockedAssetTokenAttributes<M> {
pub fn migrate_to_new_attributes(&self) -> LockedAssetTokenAttributesEx<M> {
let mut updated_unlock_milestones: ManagedVec<M, UnlockMilestoneEx> = ManagedVec::new();
for unlock_milestone in self.unlock_schedule.unlock_milestones.into_iter() {
let updated_milestone = UnlockMilestoneEx {
unlock_epoch: unlock_milestone.unlock_epoch,
unlock_percent: unlock_milestone.unlock_percent as u64 * UPDATE_PERCENTAGE_CONST,
};
updated_unlock_milestones.push(updated_milestone);
}
let updated_unlock_schedule = UnlockScheduleEx {
unlock_milestones: updated_unlock_milestones,
};

LockedAssetTokenAttributesEx {
unlock_schedule: updated_unlock_schedule,
is_merged: self.is_merged,
}
}
}

impl<M: ManagedTypeApi> LockedAssetTokenAttributesEx<M> {
pub fn get_unlock_amounts_per_epoch(
&self,
Expand Down
10 changes: 10 additions & 0 deletions common/modules/permissions_module/src/permissions_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ pub trait PermissionsModule {
self.remove_permissions(address, Permissions::ADMIN);
}

#[only_owner]
#[endpoint(updateOwnerOrAdmin)]
fn update_owner_or_admin_endpoint(&self, previous_owner: ManagedAddress) {
let caller = self.blockchain().get_caller();
let previous_owner_permissions = self.permissions(previous_owner.clone()).get();

self.permissions(previous_owner).clear();
self.permissions(caller).set(previous_owner_permissions);
}

fn set_permissions(&self, address: ManagedAddress, permissions: Permissions) {
self.permissions(address).set(permissions);
}
Expand Down
198 changes: 0 additions & 198 deletions dex/pair/src/bot_protection.rs

This file was deleted.

14 changes: 0 additions & 14 deletions dex/pair/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ pub const MAX_FEE_PERCENTAGE: u64 = 5_000;
pub trait ConfigModule:
token_send::TokenSendModule + permissions_module::PermissionsModule + pausable::PausableModule
{
#[endpoint(setExternSwapGasLimit)]
fn set_extern_swap_gas_limit(&self, gas_limit: u64) {
self.require_caller_has_owner_permissions();
self.extern_swap_gas_limit().set(gas_limit);
}

#[endpoint(setStateActiveNoSwaps)]
fn set_state_active_no_swaps(&self) {
self.require_caller_has_owner_permissions();
Expand Down Expand Up @@ -56,14 +50,6 @@ pub trait ConfigModule:
#[storage_mapper("router_address")]
fn router_address(&self) -> SingleValueMapper<ManagedAddress>;

#[view(getRouterOwnerManagedAddress)]
#[storage_mapper("router_owner_address")]
fn router_owner_address(&self) -> SingleValueMapper<ManagedAddress>;

#[view(getExternSwapGasLimit)]
#[storage_mapper("extern_swap_gas_limit")]
fn extern_swap_gas_limit(&self) -> SingleValueMapper<u64>;

#[storage_mapper("lpTokenIdentifier")]
fn lp_token_identifier(&self) -> SingleValueMapper<TokenIdentifier>;

Expand Down
Loading

0 comments on commit f07a78f

Please sign in to comment.