File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88print (f"Closing { COIN } position for { address } \n " )
99
10+ # Optional: custom slippage (default 3%, range 0.1%-10%)
11+ # res = exchange({"action": {...}, "slippage": 0.05}) # 5% slippage
12+
1013res = exchange ({
1114 "action" : {
1215 "type" : "closePosition" ,
Original file line number Diff line number Diff line change 88
99print (f"Market BUY { SIZE } { COIN } \n " )
1010
11+ # Optional: custom slippage (default 3%, range 0.1%-10%)
12+ # res = exchange({"action": {...}, "slippage": 0.05}) # 5% slippage
13+
1114res = exchange ({
1215 "action" : {
1316 "type" : "order" ,
2124})
2225
2326computed_price = res ["action" ]["orders" ][0 ]["p" ]
24- print (f"Computed price (mid + 3% slippage ): { computed_price } " )
27+ print (f"Computed price (mid + slippage, default 3% ): { computed_price } " )
2528print (f"Builder fee: { res ['builderFee' ]} " )
2629
2730sig = sign_hash (res ["hash" ])
Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ async fn main() {
99
1010 println ! ( "Closing {COIN} position for {}\n " , client. address) ;
1111
12+ // Optional: custom slippage (default 3%, range 0.1%-10%)
13+ // .exchange(&json!({"action": {...}, "slippage": 0.05})) // 5% slippage
14+
1215 let res = client
1316 . exchange ( & json ! ( {
1417 "action" : {
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ async fn main() {
1010
1111 println ! ( "Market BUY {SIZE} {COIN}\n " ) ;
1212
13+ // Optional: custom slippage (default 3%, range 0.1%-10%)
14+ // .exchange(&json!({"action": {...}, "slippage": 0.05})) // 5% slippage
15+
1316 let res = client
1417 . exchange ( & json ! ( {
1518 "action" : {
@@ -20,7 +23,7 @@ async fn main() {
2023 . await ;
2124
2225 let computed_price = res[ "action" ] [ "orders" ] [ 0 ] [ "p" ] . as_str ( ) . unwrap_or ( "?" ) ;
23- println ! ( "Computed price (mid + 3% slippage ): {computed_price}" ) ;
26+ println ! ( "Computed price (mid + slippage, default 3% ): {computed_price}" ) ;
2427 println ! ( "Builder fee: {}" , res[ "builderFee" ] ) ;
2528
2629 let hash = res[ "hash" ] . as_str ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ const COIN = "HYPE";
55async function main ( ) {
66 console . log ( `Closing ${ COIN } position for ${ address } \n` ) ;
77
8+ // Optional: custom slippage (default 3%, range 0.1%-10%)
9+ // const res = await exchange({ action: {...}, slippage: 0.05 }); // 5% slippage
10+
811 const res = await exchange ( {
912 action : {
1013 type : "closePosition" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ const SIZE = "0.00011";
66async function main ( ) {
77 console . log ( `Market BUY ${ SIZE } ${ COIN } \n` ) ;
88
9+ // Optional: custom slippage (default 3%, range 0.1%-10%)
10+ // const res = await exchange({ action: {...}, slippage: 0.05 }); // 5% slippage
11+
912 const res = await exchange ( {
1013 action : {
1114 type : "order" ,
@@ -14,7 +17,7 @@ async function main() {
1417 } ) ;
1518
1619 const computedPrice = res . action . orders [ 0 ] . p ;
17- console . log ( `Computed price (mid + 3% slippage ): ${ computedPrice } ` ) ;
20+ console . log ( `Computed price (mid + slippage, default 3% ): ${ computedPrice } ` ) ;
1821 console . log ( `Builder fee: ${ res . builderFee } ` ) ;
1922
2023 const sig = await signHash ( res . hash ) ;
You can’t perform that action at this time.
0 commit comments