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:
akildemir
2023-11-12 14:37:31 +03:00
committed by GitHub
parent a43815f101
commit d015ee96a3
30 changed files with 1063 additions and 2162 deletions

View File

@@ -24,8 +24,8 @@ impl<'a> SeraiCoins<'a> {
self.0.events::<Coins, _>(|event| matches!(event, CoinsEvent::Mint { .. })).await
}
pub async fn burn_events(&self) -> Result<Vec<CoinsEvent>, SeraiError> {
self.0.events::<Coins, _>(|event| matches!(event, CoinsEvent::Burn { .. })).await
pub async fn burn_with_instruction_events(&self) -> Result<Vec<CoinsEvent>, SeraiError> {
self.0.events::<Coins, _>(|event| matches!(event, CoinsEvent::BurnWithInstruction { .. })).await
}
pub async fn coin_supply(&self, coin: Coin) -> Result<Amount, SeraiError> {
@@ -64,7 +64,15 @@ impl<'a> SeraiCoins<'a> {
)
}
pub fn burn(instruction: OutInstructionWithBalance) -> Payload<Composite<()>> {
Payload::new(PALLET, "burn", scale_composite(coins::Call::<Runtime>::burn { instruction }))
pub fn burn(balance: Balance) -> Payload<Composite<()>> {
Payload::new(PALLET, "burn", scale_composite(coins::Call::<Runtime>::burn { balance }))
}
pub fn burn_with_instruction(instruction: OutInstructionWithBalance) -> Payload<Composite<()>> {
Payload::new(
PALLET,
"burn_with_instruction",
scale_composite(coins::Call::<Runtime>::burn_with_instruction { instruction }),
)
}
}

View File

@@ -31,12 +31,11 @@ impl<'a> SeraiDex<'a> {
PALLET,
"add_liquidity",
scale_composite(dex::Call::<Runtime>::add_liquidity {
coin1: coin,
coin2: Coin::Serai,
amount1_desired: coin_amount.0,
amount2_desired: sri_amount.0,
amount1_min: min_coin_amount.0,
amount2_min: min_sri_amount.0,
coin,
coin_desired: coin_amount.0,
sri_desired: sri_amount.0,
coin_min: min_coin_amount.0,
sri_min: min_sri_amount.0,
mint_to: address.into(),
}),
)