@@ -2,10 +2,11 @@ use crate::signature::sign_typed_data;
2
2
use crate :: {
3
3
exchange:: {
4
4
actions:: {
5
- ApproveAgent , BulkCancel , BulkOrder , SetReferrer , UpdateIsolatedMargin , UpdateLeverage ,
6
- UsdSend ,
5
+ ApproveAgent , BulkCancel , BulkModify , BulkOrder , SetReferrer , UpdateIsolatedMargin ,
6
+ UpdateLeverage , UsdSend ,
7
7
} ,
8
8
cancel:: { CancelRequest , CancelRequestCloid } ,
9
+ modify:: { ClientModifyRequest , ModifyRequest } ,
9
10
ClientCancelRequest , ClientOrderRequest ,
10
11
} ,
11
12
helpers:: { generate_random_key, next_nonce, uuid_to_hex_string} ,
@@ -58,6 +59,8 @@ pub enum Actions {
58
59
Order ( BulkOrder ) ,
59
60
Cancel ( BulkCancel ) ,
60
61
CancelByCloid ( BulkCancelCloid ) ,
62
+ #[ serde( rename = "batchModify" ) ]
63
+ Modify ( BulkModify ) ,
61
64
ApproveAgent ( ApproveAgent ) ,
62
65
Withdraw3 ( Withdraw3 ) ,
63
66
SpotUser ( SpotUser ) ,
@@ -427,6 +430,42 @@ impl ExchangeClient {
427
430
self . post ( action, signature, timestamp) . await
428
431
}
429
432
433
+ pub async fn modify (
434
+ & self ,
435
+ modify : ClientModifyRequest ,
436
+ wallet : Option < & LocalWallet > ,
437
+ ) -> Result < ExchangeResponseStatus > {
438
+ self . bulk_modify ( vec ! [ modify] , wallet) . await
439
+ }
440
+
441
+ pub async fn bulk_modify (
442
+ & self ,
443
+ modifies : Vec < ClientModifyRequest > ,
444
+ wallet : Option < & LocalWallet > ,
445
+ ) -> Result < ExchangeResponseStatus > {
446
+ let wallet = wallet. unwrap_or ( & self . wallet ) ;
447
+ let timestamp = next_nonce ( ) ;
448
+
449
+ let mut transformed_modifies = Vec :: new ( ) ;
450
+ for modify in modifies. into_iter ( ) {
451
+ transformed_modifies. push ( ModifyRequest {
452
+ oid : modify. oid ,
453
+ order : modify. order . convert ( & self . coin_to_asset ) ?,
454
+ } ) ;
455
+ }
456
+
457
+ let action = Actions :: Modify ( BulkModify {
458
+ modifies : transformed_modifies,
459
+ } ) ;
460
+ let connection_id = action. hash ( timestamp, self . vault_address ) ?;
461
+
462
+ let action = serde_json:: to_value ( & action) . map_err ( |e| Error :: JsonParse ( e. to_string ( ) ) ) ?;
463
+ let is_mainnet = self . http_client . is_mainnet ( ) ;
464
+ let signature = sign_l1_action ( wallet, connection_id, is_mainnet) ?;
465
+
466
+ self . post ( action, signature, timestamp) . await
467
+ }
468
+
430
469
pub async fn cancel_by_cloid (
431
470
& self ,
432
471
cancel : ClientCancelRequestCloid ,
0 commit comments