Skip to content

Commit 210ce20

Browse files
authored
add pool id to position closed (#212)
* add pool id to position closed * fix test
1 parent ae0db41 commit 210ce20

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

modules/margin-protocol/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ decl_event! {
116116
{
117117
/// Position opened: (who, position_id, pool_id, trading_pair, leverage, leveraged_amount, market_price)
118118
PositionOpened(AccountId, PositionId, LiquidityPoolId, TradingPair, Leverage, Amount, Price),
119-
/// Position closed: (who, position_id, market_price)
120-
PositionClosed(AccountId, PositionId, Price),
119+
/// Position closed: (who, position_id, pool_id, market_price)
120+
PositionClosed(AccountId, PositionId, LiquidityPoolId, Price),
121121
/// Deposited: (who, pool_id, amount)
122122
Deposited(AccountId, LiquidityPoolId, Amount),
123123
/// Withdrew: (who, pool_id, amount)
@@ -446,6 +446,7 @@ impl<T: Trait> Module<T> {
446446
Self::deposit_event(RawEvent::PositionClosed(
447447
who.clone(),
448448
position_id,
449+
position.pool,
449450
FixedU128::from_parts(u128_from_fixed_128(market_price)),
450451
));
451452

modules/margin-protocol/src/tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,8 +1319,12 @@ fn close_loss_position_works() {
13191319
assert_eq!(MarginProtocol::positions_by_trader(ALICE, (MOCK_POOL, id)), None);
13201320
assert_eq!(MarginProtocol::positions_by_pool(MOCK_POOL, (EUR_USD_PAIR, id)), None);
13211321

1322-
let event =
1323-
TestEvent::margin_protocol(RawEvent::PositionClosed(ALICE, id, Price::from_rational(11988, 10000)));
1322+
let event = TestEvent::margin_protocol(RawEvent::PositionClosed(
1323+
ALICE,
1324+
id,
1325+
MOCK_POOL,
1326+
Price::from_rational(11988, 10000),
1327+
));
13241328
assert!(System::events().iter().any(|record| record.event == event));
13251329
});
13261330
}

0 commit comments

Comments
 (0)