Skip to content

Commit

Permalink
add liquidty add and moreve to stableswap relevant swapped events
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoka committed Dec 3, 2024
1 parent 04c1942 commit 2d829b6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pallets/stableswap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1274,7 +1274,7 @@ impl<T: Config> Pallet<T> {
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,
Expand Down Expand Up @@ -1339,7 +1339,7 @@ impl<T: Config> Pallet<T> {
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 {
Expand Down
4 changes: 2 additions & 2 deletions pallets/stableswap/src/tests/add_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![
Expand Down Expand Up @@ -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)],
Expand Down
4 changes: 2 additions & 2 deletions pallets/stableswap/src/tests/remove_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down Expand Up @@ -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![
Expand Down
2 changes: 2 additions & 0 deletions traits/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ pub enum TradeOperation {
ExactIn,
ExactOut,
Limit,
LiquidityAdd,
LiquidityRemove,
}

#[derive(Encode, Decode, Clone, Copy, Debug, Eq, PartialEq, TypeInfo, MaxEncodedLen)]
Expand Down

0 comments on commit 2d829b6

Please sign in to comment.