Skip to content

Commit

Permalink
Add marketIndex,marketType to fill event
Browse files Browse the repository at this point in the history
  • Loading branch information
jordy25519 committed Feb 22, 2024
1 parent 5e61bc0 commit c639aac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ event payloads can be distinguished by "channel" field and the "data" payload is
"fee": "0.002581",
"amount": "0.1",
"price": "103.22087",
"marketIndex": 0,
"marketType": "perp",
"orderId": 157,
"ts": 1704777355,
"signature": "2Cdo5Xgxj6uWY6dnWmuU5a8tH5fKC2K6YUqzVYKgnm8KkMVhPczBZrNEs4VGwEBMhgosifmNjBXSjFMWbGKJiqSz"
Expand Down
11 changes: 11 additions & 0 deletions src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ enum AccountEvent {
amount: Decimal,
price: Decimal,
order_id: u32,
market_index: u16,
#[serde(serialize_with = "ser_market_type")]
market_type: MarketType,
ts: u64,
signature: String,
},
Expand Down Expand Up @@ -239,6 +242,8 @@ impl AccountEvent {
ts: u64,
decimals: u32,
signature: &String,
market_index: u16,
market_type: MarketType,
) -> Self {
let base_amount = Decimal::new(base_amount as i64, decimals);
let price = Decimal::new(quote_amount as i64, PRICE_DECIMALS) / base_amount;
Expand All @@ -254,6 +259,8 @@ impl AccountEvent {
amount: base_amount.normalize(),
ts,
signature: signature.to_string(),
market_index,
market_type,
}
}
}
Expand Down Expand Up @@ -409,6 +416,8 @@ fn map_drift_event(
*ts,
decimals,
signature,
*market_index,
*market_type,
)
} else {
AccountEvent::fill(
Expand All @@ -420,6 +429,8 @@ fn map_drift_event(
*ts,
decimals,
signature,
*market_index,
*market_type,
)
};

Expand Down

0 comments on commit c639aac

Please sign in to comment.