From 2d829b63137170e29acf8800d6e6b28f0adf9b7f Mon Sep 17 00:00:00 2001 From: dmoka Date: Tue, 3 Dec 2024 17:27:10 +0100 Subject: [PATCH] add liquidty add and moreve to stableswap relevant swapped events --- pallets/stableswap/src/lib.rs | 8 ++++---- pallets/stableswap/src/tests/add_liquidity.rs | 4 ++-- pallets/stableswap/src/tests/remove_liquidity.rs | 4 ++-- traits/src/router.rs | 2 ++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pallets/stableswap/src/lib.rs b/pallets/stableswap/src/lib.rs index 61bb94f35..53445858a 100644 --- a/pallets/stableswap/src/lib.rs +++ b/pallets/stableswap/src/lib.rs @@ -632,7 +632,7 @@ pub mod pallet { who, pool_account.clone(), pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::TradeOperation::LiquidityRemove, vec![(AssetType::Fungible(pool_id.into()), share_amount)], vec![(AssetType::Fungible(asset_id.into()), amount)], vec![Fee { @@ -735,7 +735,7 @@ pub mod pallet { who, pool_account.clone(), pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::TradeOperation::LiquidityRemove, vec![(AssetType::Fungible(pool_id.into()), shares)], vec![(AssetType::Fungible(asset_id.into()), amount)], fees, @@ -1274,7 +1274,7 @@ impl Pallet { who.clone(), pool_account.clone(), pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactIn, + pallet_amm_support::TradeOperation::LiquidityAdd, inputs, vec![(AssetType::Fungible(pool_id.into()), share_amount)], fees, @@ -1339,7 +1339,7 @@ impl Pallet { who.clone(), pool_account.clone(), pallet_amm_support::Filler::Stableswap(pool_id.into()), - pallet_amm_support::TradeOperation::ExactOut, + pallet_amm_support::TradeOperation::LiquidityAdd, vec![(AssetType::Fungible(asset_id.into()), amount_in)], vec![(AssetType::Fungible(pool_id.into()), shares)], vec![Fee { diff --git a/pallets/stableswap/src/tests/add_liquidity.rs b/pallets/stableswap/src/tests/add_liquidity.rs index 29fe5ca80..da2ebba02 100644 --- a/pallets/stableswap/src/tests/add_liquidity.rs +++ b/pallets/stableswap/src/tests/add_liquidity.rs @@ -111,7 +111,7 @@ fn add_liquidity_should_emit_swapped_events() { swapper: BOB, filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::TradeOperation::LiquidityAdd, inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000000),], outputs: vec![(AssetType::Fungible(pool_id), 1947487201901031408)], fees: vec![ @@ -714,7 +714,7 @@ fn add_liquidity_should_work_correctly_when_providing_exact_amount_of_shares() { swapper: BOB, filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::ExactOut, + operation: pallet_amm_support::TradeOperation::LiquidityAdd, inputs: vec![(AssetType::Fungible(asset_a), 2000000000000000003),], outputs: vec![(AssetType::Fungible(pool_id), 1947597621401945851)], fees: vec![Fee::new(pool_id, 0, pool_account)], diff --git a/pallets/stableswap/src/tests/remove_liquidity.rs b/pallets/stableswap/src/tests/remove_liquidity.rs index 3e3992109..8b5c8f497 100644 --- a/pallets/stableswap/src/tests/remove_liquidity.rs +++ b/pallets/stableswap/src/tests/remove_liquidity.rs @@ -79,7 +79,7 @@ fn remove_liquidity_should_work_when_withdrawing_all_shares() { swapper: BOB, filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(pool_id), - operation: pallet_amm_support::TradeOperation::ExactIn, + operation: pallet_amm_support::TradeOperation::LiquidityRemove, inputs: vec![(AssetType::Fungible(pool_id), 200516043533380244763),], outputs: vec![(AssetType::Fungible(asset_c), 199999999999999)], fees: vec![Fee::new(pool_id, 0, pool_account)], @@ -1085,7 +1085,7 @@ fn removing_liquidity_with_exact_amount_should_emit_swapped_event() { swapper: BOB, filler: pool_account, filler_type: pallet_amm_support::Filler::Stableswap(4), - operation: pallet_amm_support::TradeOperation::ExactOut, + operation: pallet_amm_support::TradeOperation::LiquidityRemove, inputs: vec![(AssetType::Fungible(pool_id), 979387928052053203)], outputs: vec![(AssetType::Fungible(asset_a), 1000000000000000000),], fees: vec![ diff --git a/traits/src/router.rs b/traits/src/router.rs index 9d70e3812..b3dab0beb 100644 --- a/traits/src/router.rs +++ b/traits/src/router.rs @@ -92,6 +92,8 @@ pub enum TradeOperation { ExactIn, ExactOut, Limit, + LiquidityAdd, + LiquidityRemove, } #[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)]