mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 04:39:24 +00:00
Tidy the DEX pallet
This commit is contained in:
@@ -53,6 +53,7 @@ serai-core-pallet = { path = "../core", default-features = false }
|
||||
serai-coins-pallet = { path = "../coins", default-features = false }
|
||||
serai-validator-sets-pallet = { path = "../validator-sets", default-features = false }
|
||||
serai-signals-pallet = { path = "../signals", default-features = false }
|
||||
serai-dex-pallet = { path = "../dex", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder = { git = "https://github.com/serai-dex/patch-polkadot-sdk", rev = "8c36534bb0bd5a02979f94bb913d11d55fe7eadc" }
|
||||
@@ -88,6 +89,7 @@ std = [
|
||||
"serai-coins-pallet/std",
|
||||
"serai-validator-sets-pallet/std",
|
||||
"serai-signals-pallet/std",
|
||||
"serai-dex-pallet/std",
|
||||
]
|
||||
|
||||
try-runtime = [
|
||||
@@ -107,6 +109,7 @@ try-runtime = [
|
||||
"serai-coins-pallet/try-runtime",
|
||||
"serai-validator-sets-pallet/try-runtime",
|
||||
"serai-signals-pallet/try-runtime",
|
||||
"serai-dex-pallet/try-runtime",
|
||||
]
|
||||
|
||||
runtime-benchmarks = [
|
||||
@@ -123,6 +126,7 @@ runtime-benchmarks = [
|
||||
"serai-coins-pallet/runtime-benchmarks",
|
||||
"serai-validator-sets-pallet/runtime-benchmarks",
|
||||
"serai-signals-pallet/runtime-benchmarks",
|
||||
"serai-dex-pallet/runtime-benchmarks",
|
||||
]
|
||||
|
||||
default = ["std"]
|
||||
|
||||
@@ -93,6 +93,9 @@ mod runtime {
|
||||
#[runtime::pallet_index(5)]
|
||||
pub type LiquidityTokens = serai_coins_pallet::Pallet<Runtime, LiquidityTokensInstance>;
|
||||
|
||||
#[runtime::pallet_index(6)]
|
||||
pub type Dex = serai_dex_pallet::Pallet<Runtime>;
|
||||
|
||||
#[runtime::pallet_index(0xfd)]
|
||||
#[runtime::disable_inherent]
|
||||
pub type Timestamp = pallet_timestamp::Pallet<Runtime>;
|
||||
@@ -171,6 +174,7 @@ impl serai_signals_pallet::Config for Runtime {
|
||||
impl serai_coins_pallet::Config<LiquidityTokensInstance> for Runtime {
|
||||
type AllowMint = serai_coins_pallet::AlwaysAllowMint;
|
||||
}
|
||||
impl serai_dex_pallet::Config for Runtime {}
|
||||
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
type Moment = u64;
|
||||
@@ -292,16 +296,35 @@ impl From<serai_abi::Call> for RuntimeCall {
|
||||
serai_abi::Call::Dex(call) => {
|
||||
use serai_abi::dex::Call;
|
||||
match call {
|
||||
Call::add_liquidity {
|
||||
external_coin,
|
||||
sri_intended,
|
||||
external_coin_intended,
|
||||
sri_minimum,
|
||||
external_coin_minimum,
|
||||
} => RuntimeCall::Dex(serai_dex_pallet::Call::add_liquidity {
|
||||
external_coin,
|
||||
sri_intended,
|
||||
external_coin_intended,
|
||||
sri_minimum,
|
||||
external_coin_minimum,
|
||||
}),
|
||||
Call::transfer_liquidity { to, liquidity_tokens } => {
|
||||
RuntimeCall::LiquidityTokens(serai_coins_pallet::Call::transfer {
|
||||
to: to.into(),
|
||||
coins: liquidity_tokens.into(),
|
||||
RuntimeCall::Dex(serai_dex_pallet::Call::transfer_liquidity { to, liquidity_tokens })
|
||||
}
|
||||
Call::remove_liquidity { liquidity_tokens, sri_minimum, external_coin_minimum } => {
|
||||
RuntimeCall::Dex(serai_dex_pallet::Call::remove_liquidity {
|
||||
liquidity_tokens,
|
||||
sri_minimum,
|
||||
external_coin_minimum,
|
||||
})
|
||||
}
|
||||
Call::add_liquidity { .. } |
|
||||
Call::remove_liquidity { .. } |
|
||||
Call::swap_exact { .. } |
|
||||
Call::swap_for_exact { .. } => todo!("TODO"),
|
||||
Call::swap { coins_to_swap, minimum_to_receive } => {
|
||||
RuntimeCall::Dex(serai_dex_pallet::Call::swap { coins_to_swap, minimum_to_receive })
|
||||
}
|
||||
Call::swap_for { coins_to_receive, maximum_to_swap } => {
|
||||
RuntimeCall::Dex(serai_dex_pallet::Call::swap_for { coins_to_receive, maximum_to_swap })
|
||||
}
|
||||
}
|
||||
}
|
||||
serai_abi::Call::GenesisLiquidity(call) => {
|
||||
|
||||
Reference in New Issue
Block a user