Skip to content

Commit 5930f15

Browse files
authored
swift max margin ratio (#88)
1 parent f0bcbaa commit 5930f15

File tree

5 files changed

+172
-16
lines changed

5 files changed

+172
-16
lines changed

Cargo.lock

Lines changed: 95 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bincode = "1"
2626
clap = { version = "4.0", features = ["derive"] }
2727
dashmap = "6.1.0"
2828
dotenv = "0.15.0"
29-
drift-rs = { git = "https://github.com/drift-labs/drift-rs.git" , rev = "004cf7c" }
29+
drift-rs = { git = "https://github.com/drift-labs/drift-rs.git" , rev = "cbc476e2" }
3030
ed25519-dalek = "1.0.1"
3131
env_logger = "0.11"
3232
faster-hex = "0.10.0"

src/swift_server.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub async fn process_order_wrapper(
124124
State(server_params): State<&'static ServerParams>,
125125
Json(incoming_message): Json<IncomingSignedMessage>,
126126
) -> impl axum::response::IntoResponse {
127-
let uuid_raw = extract_uuid(&incoming_message.message);
127+
let uuid_raw = extract_uuid(&incoming_message.order());
128128
let uuid = core::str::from_utf8(&uuid_raw).unwrap_or("00000000");
129129
let context = RequestContext::from_incoming_message(&incoming_message);
130130

@@ -385,7 +385,7 @@ pub async fn deposit_trade(
385385
) -> impl axum::response::IntoResponse {
386386
let signed_order_info = req
387387
.swift_order
388-
.message
388+
.order()
389389
.info(&req.swift_order.taker_authority);
390390

391391
let uuid = core::str::from_utf8(&signed_order_info.uuid).unwrap_or("<bad uuid>");
@@ -1638,6 +1638,7 @@ mod tests {
16381638
slot: current_slot,
16391639
stop_loss_order_params: None,
16401640
take_profit_order_params: None,
1641+
max_margin_ratio: None,
16411642
});
16421643

16431644
let result = extract_signed_message_info(&delegated_msg, &taker_authority, current_slot);
@@ -1666,6 +1667,7 @@ mod tests {
16661667
..Default::default()
16671668
}),
16681669
take_profit_order_params: None,
1670+
max_margin_ratio: None,
16691671
});
16701672

16711673
let result = extract_signed_message_info(&delegated_msg, &taker_authority, current_slot);
@@ -1698,6 +1700,7 @@ mod tests {
16981700
slot: current_slot,
16991701
stop_loss_order_params: None,
17001702
take_profit_order_params: None,
1703+
max_margin_ratio: None,
17011704
});
17021705

17031706
let result = extract_signed_message_info(&authority_msg, &taker_authority, current_slot);
@@ -1728,6 +1731,7 @@ mod tests {
17281731
base_asset_amount: 0,
17291732
..Default::default()
17301733
}),
1734+
max_margin_ratio: None,
17311735
});
17321736

17331737
let result = extract_signed_message_info(&authority_msg, &taker_authority, current_slot);
@@ -1759,6 +1763,7 @@ mod tests {
17591763
slot: current_slot - 501, // Slot too old
17601764
stop_loss_order_params: None,
17611765
take_profit_order_params: None,
1766+
max_margin_ratio: None,
17621767
});
17631768

17641769
let result = extract_signed_message_info(&delegated_msg, &taker_authority, current_slot);

0 commit comments

Comments
 (0)