Skip to content

Commit

Permalink
Remove Moya, LSEE & LEDF
Browse files Browse the repository at this point in the history
  • Loading branch information
balqaasem committed May 4, 2024
1 parent 7646cbf commit 8956e5a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 108 deletions.
5 changes: 0 additions & 5 deletions blockchain/modules/support/src/incentives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use sp_std::prelude::*;
// 1. EcdpSetrLiquidityRewards: record the shares and rewards for Setter (SETR)) ECDP users who are staking LP tokens.
// 2. EcdpUssdLiquidityRewards: record the shares and rewards for Slick USD (USSD) ECDP users who are staking LP tokens.
// 3. EdfisLiquidityRewards: record the shares and rewards for Edfis makers who are staking LP token.
// 4. EdfisXLiquidityRewards: record the shares and rewards for Edfis X (Cross-chain) makers who are staking LP token.
// 5. MoyaEarnRewards: record the shares and rewards for users of Moya Earn (Moya Liquid Staking Protocol).
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)]
pub enum PoolId {
/// Rewards and shares pool for Setter (SETR)) ECDP users who are staking LP token(LPCurrencyId)
Expand All @@ -43,9 +41,6 @@ pub enum PoolId {
/// Rewards and shares pool for Edfis market makers who stake LP token(LPCurrencyId)
EdfisLiquidityRewards(CurrencyId),

/// Rewards and shares pool for Edfis X (Cross-chain) market makers who stake LP token(LPCurrencyId)
EdfisXLiquidityRewards(CurrencyId),

/// Rewards and shares pool for Moya Earn
MoyaEarnRewards(CurrencyId),
}
Expand Down
2 changes: 0 additions & 2 deletions blockchain/modules/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub mod edfis_mining;
pub mod edfis_swap;
pub mod edfis_swap_legacy;
pub mod evm;
pub mod liquid_staking;
pub mod migration;
pub mod mocks;

Expand All @@ -59,7 +58,6 @@ pub use crate::edfis_mining::*;
pub use crate::edfis_swap::*;
pub use crate::edfis_swap_legacy::*;
pub use crate::evm::*;
pub use crate::liquid_staking::*;
pub use crate::migration::*;

pub type Price = FixedU128;
Expand Down
38 changes: 0 additions & 38 deletions blockchain/modules/support/src/liquid_staking.rs

This file was deleted.

5 changes: 1 addition & 4 deletions blockchain/modules/transaction-payment/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ pub const SEE: CurrencyId = CurrencyId::Token(TokenSymbol::SEE);
pub const SETR: CurrencyId = CurrencyId::Token(TokenSymbol::SETR);
pub const USSD: CurrencyId = CurrencyId::Token(TokenSymbol::USSD);
pub const EDF: CurrencyId = CurrencyId::Token(TokenSymbol::EDF);
pub const LSEE: CurrencyId = CurrencyId::Token(TokenSymbol::LSEE);

parameter_types! {
static ExtrinsicBaseWeight: Weight = Weight::zero();
Expand Down Expand Up @@ -91,7 +90,7 @@ parameter_type_with_key! {
match *currency_id {
USSD => 100,
SETR => 100,
EDF | LSEE => 1,
EDF => 1,
_ => Default::default(),
}
};
Expand Down Expand Up @@ -165,7 +164,6 @@ parameter_types! {
TradingPair::from_currency_ids(USSD, SETR).unwrap(),
TradingPair::from_currency_ids(SETR, SEE).unwrap(),
TradingPair::from_currency_ids(USSD, EDF).unwrap(),
TradingPair::from_currency_ids(SEE, LSEE).unwrap(),
];
pub const TradingPathLimit: u32 = 4;
}
Expand Down Expand Up @@ -332,7 +330,6 @@ impl Default for ExtBuilder {
(ALICE, USSD, 10000),
(ALICE, SETR, 10000),
(ALICE, EDF, 1000),
(ALICE, LSEE, 1000)
],
base_weight: Weight::zero(),
byte_fee: 2,
Expand Down
62 changes: 17 additions & 45 deletions blockchain/modules/transaction-payment/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use frame_support::{
use mock::{
AccountId, BlockWeights, Currencies, EdfisSwapLegacyModule, ExtBuilder, FeePoolSize, MockPriceSource, Runtime, RuntimeCall,
RuntimeOrigin, System, TransactionPayment, ALICE, BOB, CHARLIE, DAVE, FEE_UNBALANCED_AMOUNT, TIP_UNBALANCED_AMOUNT,
SEE, USSD, EDF, LSEE,
SEE, USSD, EDF,
};
use module_support::{BuyWeightRate, SwapManager, Price, TransactionPayment as TransactionPaymentT};
use orml_traits::{MultiCurrency, MultiLockableCurrency};
Expand Down Expand Up @@ -114,7 +114,7 @@ fn enable_dex_and_tx_fee_pool() {
SEE,
(init_balance * 100).unique_saturated_into(),
));
vec![USSD, SETR, EDF, LSEE].iter().for_each(|token| {
vec![USSD, SETR, EDF].iter().for_each(|token| {
let ed = (<Currencies as MultiCurrency<AccountId>>::minimum_balance(token.clone())).unique_saturated_into();
assert_ok!(Currencies::update_balance(
RuntimeOrigin::root(),
Expand Down Expand Up @@ -153,18 +153,8 @@ fn enable_dex_and_tx_fee_pool() {
0,
false
));
assert_ok!(EdfisSwapLegacyModule::add_liquidity(
RuntimeOrigin::signed(ALICE),
LSEE,
SEE,
100,
1000,
0,
false
));
assert_eq!(EdfisSwapLegacyModule::get_liquidity_pool(SEE, USSD), (10000, 1000));
assert_eq!(EdfisSwapLegacyModule::get_liquidity_pool(EDF, USSD), (100, 1000));
assert_eq!(EdfisSwapLegacyModule::get_liquidity_pool(LSEE, SEE), (100, 1000));
assert_eq!(EdfisSwapLegacyModule::get_liquidity_pool(EDF, SEE), (0, 0));

// enable tx fee pool for USSD and EDF token.
Expand Down Expand Up @@ -534,16 +524,16 @@ fn pre_post_dispatch_and_refund_with_fee_currency_call(token: CurrencyId, surplu

#[test]
fn pre_post_dispatch_and_refund_with_fee_currency_call_use_dex() {
pre_post_dispatch_and_refund_with_fee_call_use_dex(with_fee_currency_call(LSEE));
pre_post_dispatch_and_refund_with_fee_call_use_dex(with_fee_currency_call(EDF));
}

#[test]
fn pre_post_dispatch_and_refund_with_fee_path_call_use_dex() {
pre_post_dispatch_and_refund_with_fee_call_use_dex(with_fee_path_call(vec![LSEE, SEE]));
pre_post_dispatch_and_refund_with_fee_call_use_dex(with_fee_path_call(vec![EDF, SEE]));
}

fn pre_post_dispatch_and_refund_with_fee_call_use_dex(with_fee_call: <Runtime as Config>::RuntimeCall) {
let (token, surplus_percent) = (LSEE, CustomFeeSurplus::get());
let (token, surplus_percent) = (EDF, CustomFeeSurplus::get());
builder_with_dex_and_fee_pool(true).execute_with(|| {
// without tip
let dex_acc: AccountId = PalletId(*b"set/edfis").into_account_truncating();
Expand All @@ -561,7 +551,7 @@ fn pre_post_dispatch_and_refund_with_fee_call_use_dex(with_fee_call: <Runtime as
assert_eq!(pre.3, fee_surplus);
System::assert_has_event(crate::mock::RuntimeEvent::EdfisSwapLegacyModule(edfis_swap_legacy_module::Event::Swap {
trader: ALICE,
path: vec![LSEE, SEE],
path: vec![EDF, SEE],
liquidity_changes: vec![43, 300],
}));
assert_eq!(dex_see - 300, Currencies::free_balance(SEE, &dex_acc));
Expand Down Expand Up @@ -771,12 +761,12 @@ fn refund_should_not_works() {

#[test]
fn charges_fee_when_validate_with_fee_currency_call_use_swap() {
charges_fee_when_validate_with_fee_call_use_swap(with_fee_currency_call(LSEE));
charges_fee_when_validate_with_fee_call_use_swap(with_fee_currency_call(EDF));
}

#[test]
fn charges_fee_when_validate_with_fee_path_call_use_swap() {
charges_fee_when_validate_with_fee_call_use_swap(with_fee_path_call(vec![LSEE, SEE]));
charges_fee_when_validate_with_fee_call_use_swap(with_fee_path_call(vec![EDF, SEE]));
}

fn charges_fee_when_validate_with_fee_call_use_swap(with_fee_call: <Runtime as Config>::RuntimeCall) {
Expand All @@ -786,19 +776,19 @@ fn charges_fee_when_validate_with_fee_call_use_swap(with_fee_call: <Runtime as C
let dex_see = Currencies::free_balance(SEE, &dex_acc);

// first tx consider existential deposit.
// LSEE is not enabled charge fee pool, so use dex swap.
// EDF is not enabled charge fee pool, so use dex swap.
let fee: Balance = 50 * 2 + 100 + 10;
let fee_surplus = fee + CustomFeeSurplus::get().mul_ceil(fee);
assert_eq!(315, fee_surplus);
assert_ok!(Currencies::update_balance(RuntimeOrigin::root(), BOB, LSEE, 1000));
assert_ok!(Currencies::update_balance(RuntimeOrigin::root(), BOB, EDF, 1000));

assert_ok!(ChargeTransactionPayment::<Runtime>::from(0).validate(&BOB, &with_fee_call, &INFO2, 50));
System::assert_has_event(crate::mock::RuntimeEvent::EdfisSwapLegacyModule(edfis_swap_legacy_module::Event::Swap {
trader: BOB,
path: vec![LSEE, SEE],
path: vec![EDF, SEE],
liquidity_changes: vec![46, 315],
}));
assert_eq!(1000 - 46, Currencies::free_balance(LSEE, &BOB));
assert_eq!(1000 - 46, Currencies::free_balance(EDF, &BOB));
assert_eq!(10, Currencies::free_balance(SEE, &BOB));
assert_eq!(dex_see - 315, Currencies::free_balance(SEE, &dex_acc));

Expand All @@ -810,10 +800,10 @@ fn charges_fee_when_validate_with_fee_call_use_swap(with_fee_call: <Runtime as C
assert_ok!(ChargeTransactionPayment::<Runtime>::from(0).validate(&BOB, &with_fee_call, &INFO2, 50));
System::assert_has_event(crate::mock::RuntimeEvent::EdfisSwapLegacyModule(edfis_swap_legacy_module::Event::Swap {
trader: BOB,
path: vec![LSEE, SEE],
path: vec![EDF, SEE],
liquidity_changes: vec![114, 300],
}));
assert_eq!(1000 - 46 - 114, Currencies::free_balance(LSEE, &BOB));
assert_eq!(1000 - 46 - 114, Currencies::free_balance(EDF, &BOB));
assert_eq!(10, Currencies::free_balance(SEE, &BOB));
assert_eq!(dex_see - 315 - 300, Currencies::free_balance(SEE, &dex_acc));
});
Expand Down Expand Up @@ -1630,7 +1620,7 @@ fn buy_weight_transaction_fee_pool_works() {
assert_eq!(rate, None);

// Token not in charge fee pool
let currency_id = CurrencyId::Token(TokenSymbol::LSEE);
let currency_id = CurrencyId::Token(TokenSymbol::EDF);

let location = MultiLocation::new(
1,
Expand Down Expand Up @@ -2113,11 +2103,11 @@ fn charge_fee_pool_operation_works() {
);

assert_noop!(
Pallet::<Runtime>::enable_charge_fee_pool(RuntimeOrigin::signed(ALICE), LEDF, pool_size, swap_threshold),
Pallet::<Runtime>::enable_charge_fee_pool(RuntimeOrigin::signed(ALICE), EDF, pool_size, swap_threshold),
Error::<Runtime>::DexNotAvailable
);
assert_noop!(
Pallet::<Runtime>::disable_charge_fee_pool(RuntimeOrigin::signed(ALICE), LEDF),
Pallet::<Runtime>::disable_charge_fee_pool(RuntimeOrigin::signed(ALICE), EDF),
Error::<Runtime>::InvalidToken
);

Expand Down Expand Up @@ -2162,15 +2152,8 @@ fn with_fee_call_validation_works() {
1000000,
));
assert_ok!(Currencies::update_balance(RuntimeOrigin::root(), CHARLIE, EDF, 1000000,));
assert_ok!(Currencies::update_balance(
RuntimeOrigin::root(),
CHARLIE,
LSEE,
1000000,
));
assert_eq!(1000000, Currencies::free_balance(USSD, &CHARLIE));
assert_eq!(1000000, Currencies::free_balance(EDF, &CHARLIE));
assert_eq!(1000000, Currencies::free_balance(LSEE, &CHARLIE));

assert_eq!(OverrideChargeFeeMethod::<Runtime>::get(), None);

Expand Down Expand Up @@ -2302,17 +2285,6 @@ fn with_fee_call_validation_works() {
);
}

// LSEE is not enabled fee pool, cannot charge fee by with_fee_currency
assert_noop!(
ChargeTransactionPayment::<Runtime>::from(0).pre_dispatch(
&CHARLIE,
&with_fee_currency_call(LSEE),
&INFO,
10
),
TransactionValidityError::Invalid(InvalidTransaction::Payment)
);

for path in vec![vec![EDF, USSD, SEE], vec![USSD, SEE]] {
assert_ok!(ChargeTransactionPayment::<Runtime>::from(0).pre_dispatch(
&CHARLIE,
Expand Down
17 changes: 3 additions & 14 deletions primitives/src/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,6 @@ macro_rules! create_currency_id {
symbol: "LP_EDF_SETR".to_string(),
address: EvmAddress::try_from(TradingPair::from_currency_ids(CurrencyId::Token(SETR), CurrencyId::Token(EDF)).unwrap().dex_share_currency_id()).unwrap(),
},
Token {
symbol: "LP_LSEE_SETR".to_string(),
address: EvmAddress::try_from(TradingPair::from_currency_ids(CurrencyId::Token(SETR), CurrencyId::Token(LSEE)).unwrap().dex_share_currency_id()).unwrap(),
},
Token {
symbol: "LP_LEDF_SETR".to_string(),
address: EvmAddress::try_from(TradingPair::from_currency_ids(CurrencyId::Token(SETR), CurrencyId::Token(LEDF)).unwrap().dex_share_currency_id()).unwrap(),
},
Token {
symbol: "LP_USSD_SETR".to_string(),
address: EvmAddress::try_from(TradingPair::from_currency_ids(CurrencyId::Token(SETR), CurrencyId::Token(USSD)).unwrap().dex_share_currency_id()).unwrap(),
Expand Down Expand Up @@ -180,17 +172,14 @@ create_currency_id! {
#[repr(u8)]
pub enum TokenSymbol {
// 0 - 100: Reserved for Setheum Native Assets
// Primary Protocol Tokens
// Primary Protocol Tokens
SEE("Setheum", 12) = 0,
EDF("Ethical DeFi", 12) = 1,
// Liquid Staking Tokens
LSEE("Liquid SEE", 12) = 2,
LEDF("Liquid EDF", 12) = 3,
// ECDP Stablecoin Tokens
// ECDP Stablecoin Tokens
SETR("Setter", 12) = 4,
USSD("Slick USD", 12) = 5,

// 101-255: Reserved for Fiat Currencies
// 101-255: Reserved for Fiat Currencies represented on EdfisPay
AED("UAE Dirham", 2) = 101,
AMD("Armenian Dram", 2) = 102,
AOA("Angolan Kwanza", 2) = 103,
Expand Down

0 comments on commit 8956e5a

Please sign in to comment.