mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Dex improvements (#422)
* remove dex traits&balance types * remove liq tokens pallet in favor of coins-pallet instance * fix tests & benchmarks * remove liquidity tokens trait * fix CI * fix pr comments * Slight renamings * Add burn_with_instruction as a negative to LiquidityTokens CallFilter * Remove use of One, Zero, Saturating taits in dex pallet --------- Co-authored-by: Luke Parker <lukeparker5132@gmail.com>
This commit is contained in:
@@ -17,7 +17,6 @@ pub use pallet_timestamp as timestamp;
|
||||
pub use pallet_transaction_payment as transaction_payment;
|
||||
|
||||
pub use coins_pallet as coins;
|
||||
pub use liquidity_tokens_pallet as liquidity_tokens;
|
||||
pub use dex_pallet as dex;
|
||||
|
||||
pub use validator_sets_pallet as validator_sets;
|
||||
@@ -47,7 +46,7 @@ use sp_runtime::{
|
||||
ApplyExtrinsicResult, Perbill,
|
||||
};
|
||||
|
||||
use primitives::{PublicKey, SeraiAddress, Coin, AccountLookup, Signature, SubstrateAmount};
|
||||
use primitives::{PublicKey, SeraiAddress, AccountLookup, Signature, SubstrateAmount};
|
||||
|
||||
use support::{
|
||||
traits::{ConstU8, ConstU32, ConstU64, Contains},
|
||||
@@ -157,6 +156,12 @@ impl Contains<RuntimeCall> for CallFilter {
|
||||
|
||||
// All of these pallets are our own, and all of their written calls are intended to be called
|
||||
RuntimeCall::Coins(call) => !matches!(call, coins::Call::__Ignore(_, _)),
|
||||
RuntimeCall::LiquidityTokens(call) => match call {
|
||||
coins::Call::transfer { .. } => true,
|
||||
coins::Call::burn { .. } => true,
|
||||
coins::Call::burn_with_instruction { .. } => false,
|
||||
coins::Call::__Ignore(_, _) => false,
|
||||
},
|
||||
RuntimeCall::Dex(call) => !matches!(call, dex::Call::__Ignore(_, _)),
|
||||
RuntimeCall::ValidatorSets(call) => !matches!(call, validator_sets::Call::__Ignore(_, _)),
|
||||
RuntimeCall::InInstructions(call) => !matches!(call, in_instructions::Call::__Ignore(_, _)),
|
||||
@@ -234,25 +239,12 @@ impl coins::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
|
||||
impl liquidity_tokens::Config for Runtime {
|
||||
impl coins::Config<coins::Instance1> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
}
|
||||
|
||||
impl dex::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Coins;
|
||||
type Balance = SubstrateAmount;
|
||||
type CoinBalance = SubstrateAmount;
|
||||
// TODO: Review if this should be u64/u128 or u64/u256 (and rounding in general).
|
||||
type HigherPrecisionBalance = u128;
|
||||
|
||||
type CoinId = Coin;
|
||||
type MultiCoinId = Coin;
|
||||
type MultiCoinIdConverter = serai_dex_primitives::CoinConverter;
|
||||
type PoolCoinId = u32;
|
||||
|
||||
type Coins = Coins;
|
||||
type PoolCoins = LiquidityTokens;
|
||||
|
||||
type LPFee = ConstU32<3>; // 0.3%
|
||||
type MintMinLiquidity = ConstU64<10000>;
|
||||
@@ -260,9 +252,6 @@ impl dex::Config for Runtime {
|
||||
type MaxSwapPathLength = ConstU32<3>; // coin1 -> SRI -> coin2
|
||||
|
||||
type WeightInfo = dex::weights::SubstrateWeight<Runtime>;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type BenchmarkHelper = ();
|
||||
}
|
||||
|
||||
impl validator_sets::Config for Runtime {
|
||||
@@ -364,7 +353,7 @@ construct_runtime!(
|
||||
TransactionPayment: transaction_payment,
|
||||
|
||||
Coins: coins,
|
||||
LiquidityTokens: liquidity_tokens,
|
||||
LiquidityTokens: coins::<Instance1>::{Pallet, Call, Storage, Event<T>},
|
||||
Dex: dex,
|
||||
|
||||
ValidatorSets: validator_sets,
|
||||
|
||||
Reference in New Issue
Block a user