@@ -12,18 +12,18 @@ type IExchangeAPI interface {
12
12
IClient
13
13
14
14
// Open orders
15
- BulkOrders (requests []OrderRequest , grouping Grouping ) (* PlaceOrderResponse , error )
16
- Order (request OrderRequest , grouping Grouping ) (* PlaceOrderResponse , error )
17
- MarketOrder (coin string , size float64 , slippage * float64 , clientOID ... string ) (* PlaceOrderResponse , error )
18
- LimitOrder (orderType string , coin string , size float64 , px float64 , isBuy bool , reduceOnly bool , clientOID ... string ) (* PlaceOrderResponse , error )
15
+ BulkOrders (requests []OrderRequest , grouping Grouping ) (* OrderResponse , error )
16
+ Order (request OrderRequest , grouping Grouping ) (* OrderResponse , error )
17
+ MarketOrder (coin string , size float64 , slippage * float64 , clientOID ... string ) (* OrderResponse , error )
18
+ LimitOrder (orderType string , coin string , size float64 , px float64 , isBuy bool , reduceOnly bool , clientOID ... string ) (* OrderResponse , error )
19
19
20
20
// Order management
21
21
CancelOrderByOID (coin string , orderID int ) (any , error )
22
22
CancelOrderByCloid (coin string , clientOID string ) (any , error )
23
23
BulkCancelOrders (cancels []CancelOidWire ) (any , error )
24
24
CancelAllOrdersByCoin (coin string ) (any , error )
25
25
CancelAllOrders () (any , error )
26
- ClosePosition (coin string ) (* PlaceOrderResponse , error )
26
+ ClosePosition (coin string ) (* OrderResponse , error )
27
27
28
28
// Account management
29
29
Withdraw (destination string , amount float64 ) (* WithdrawResponse , error )
@@ -99,7 +99,7 @@ func (api *ExchangeAPI) SlippagePriceSpot(coin string, isBuy bool, slippage floa
99
99
// MarketOrder("BTC", 0.1, nil) // Buy 0.1 BTC
100
100
// MarketOrder("BTC", -0.1, nil) // Sell 0.1 BTC
101
101
// MarketOrder("BTC", 0.1, &slippage) // Buy 0.1 BTC with slippage
102
- func (api * ExchangeAPI ) MarketOrder (coin string , size float64 , slippage * float64 , clientOID ... string ) (* PlaceOrderResponse , error ) {
102
+ func (api * ExchangeAPI ) MarketOrder (coin string , size float64 , slippage * float64 , clientOID ... string ) (* OrderResponse , error ) {
103
103
slpg := GetSlippage (slippage )
104
104
isBuy := IsBuy (size )
105
105
finalPx := api .SlippagePrice (coin , isBuy , slpg )
@@ -130,7 +130,7 @@ func (api *ExchangeAPI) MarketOrder(coin string, size float64, slippage *float64
130
130
// MarketOrderSpot("HYPE", 0.1, nil) // Buy 0.1 HYPE
131
131
// MarketOrderSpot("HYPE", -0.1, nil) // Sell 0.1 HYPE
132
132
// MarketOrderSpot("HYPE", 0.1, &slippage) // Buy 0.1 HYPE with slippage
133
- func (api * ExchangeAPI ) MarketOrderSpot (coin string , size float64 , slippage * float64 ) (* PlaceOrderResponse , error ) {
133
+ func (api * ExchangeAPI ) MarketOrderSpot (coin string , size float64 , slippage * float64 ) (* OrderResponse , error ) {
134
134
slpg := GetSlippage (slippage )
135
135
isBuy := IsBuy (size )
136
136
finalPx := api .SlippagePriceSpot (coin , isBuy , slpg )
@@ -154,7 +154,7 @@ func (api *ExchangeAPI) MarketOrderSpot(coin string, size float64, slippage *flo
154
154
// Order type can be Gtc, Ioc, Alo.
155
155
// Size determines the amount of the coin to buy/sell.
156
156
// See the constants TifGtc, TifIoc, TifAlo.
157
- func (api * ExchangeAPI ) LimitOrder (orderType string , coin string , size float64 , px float64 , reduceOnly bool , clientOID ... string ) (* PlaceOrderResponse , error ) {
157
+ func (api * ExchangeAPI ) LimitOrder (orderType string , coin string , size float64 , px float64 , reduceOnly bool , clientOID ... string ) (* OrderResponse , error ) {
158
158
// check if the order type is valid
159
159
if orderType != TifGtc && orderType != TifIoc && orderType != TifAlo {
160
160
return nil , APIError {Message : fmt .Sprintf ("Invalid order type: %s. Available types: %s, %s, %s" , orderType , TifGtc , TifIoc , TifAlo )}
@@ -179,7 +179,7 @@ func (api *ExchangeAPI) LimitOrder(orderType string, coin string, size float64,
179
179
}
180
180
181
181
// Close all positions for a given coin. They are closing with a market order.
182
- func (api * ExchangeAPI ) ClosePosition (coin string ) (* PlaceOrderResponse , error ) {
182
+ func (api * ExchangeAPI ) ClosePosition (coin string ) (* OrderResponse , error ) {
183
183
// Get all positions and find the one for the coin
184
184
// Then just make MarketOpen with the reverse size
185
185
state , err := api .infoAPI .GetUserState (api .AccountAddress ())
@@ -219,18 +219,18 @@ func (api *ExchangeAPI) ClosePosition(coin string) (*PlaceOrderResponse, error)
219
219
}
220
220
221
221
// Place single order
222
- func (api * ExchangeAPI ) Order (request OrderRequest , grouping Grouping ) (* PlaceOrderResponse , error ) {
222
+ func (api * ExchangeAPI ) Order (request OrderRequest , grouping Grouping ) (* OrderResponse , error ) {
223
223
return api .BulkOrders ([]OrderRequest {request }, grouping , false )
224
224
}
225
225
226
226
// OrderSpot places a spot order
227
- func (api * ExchangeAPI ) OrderSpot (request OrderRequest , grouping Grouping ) (* PlaceOrderResponse , error ) {
227
+ func (api * ExchangeAPI ) OrderSpot (request OrderRequest , grouping Grouping ) (* OrderResponse , error ) {
228
228
return api .BulkOrders ([]OrderRequest {request }, grouping , true )
229
229
}
230
230
231
231
// Place orders in bulk
232
232
// https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#place-an-order
233
- func (api * ExchangeAPI ) BulkOrders (requests []OrderRequest , grouping Grouping , isSpot bool ) (* PlaceOrderResponse , error ) {
233
+ func (api * ExchangeAPI ) BulkOrders (requests []OrderRequest , grouping Grouping , isSpot bool ) (* OrderResponse , error ) {
234
234
var wires []OrderWire
235
235
var meta map [string ]AssetInfo
236
236
if isSpot {
@@ -254,12 +254,12 @@ func (api *ExchangeAPI) BulkOrders(requests []OrderRequest, grouping Grouping, i
254
254
Signature : ToTypedSig (r , s , v ),
255
255
VaultAddress : nil ,
256
256
}
257
- return MakeUniversalRequest [PlaceOrderResponse ](api , request )
257
+ return MakeUniversalRequest [OrderResponse ](api , request )
258
258
}
259
259
260
260
// Cancel order(s)
261
261
// https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s
262
- func (api * ExchangeAPI ) BulkCancelOrders (cancels []CancelOidWire ) (* CancelOrderResponse , error ) {
262
+ func (api * ExchangeAPI ) BulkCancelOrders (cancels []CancelOidWire ) (* OrderResponse , error ) {
263
263
timestamp := GetNonce ()
264
264
action := CancelOidOrderAction {
265
265
Type : "cancel" ,
@@ -276,12 +276,12 @@ func (api *ExchangeAPI) BulkCancelOrders(cancels []CancelOidWire) (*CancelOrderR
276
276
Signature : ToTypedSig (r , s , v ),
277
277
VaultAddress : nil ,
278
278
}
279
- return MakeUniversalRequest [CancelOrderResponse ](api , request )
279
+ return MakeUniversalRequest [OrderResponse ](api , request )
280
280
}
281
281
282
282
// Bulk modify orders
283
283
// https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#modify-multiple-orders
284
- func (api * ExchangeAPI ) BulkModifyOrders (modifyRequests []ModifyOrderRequest , isSpot bool ) (* PlaceOrderResponse , error ) {
284
+ func (api * ExchangeAPI ) BulkModifyOrders (modifyRequests []ModifyOrderRequest , isSpot bool ) (* OrderResponse , error ) {
285
285
wires := []ModifyOrderWire {}
286
286
287
287
for _ , req := range modifyRequests {
@@ -303,17 +303,17 @@ func (api *ExchangeAPI) BulkModifyOrders(modifyRequests []ModifyOrderRequest, is
303
303
Signature : ToTypedSig (rVal , sVal , vVal ),
304
304
VaultAddress : nil ,
305
305
}
306
- return MakeUniversalRequest [PlaceOrderResponse ](api , request )
306
+ return MakeUniversalRequest [OrderResponse ](api , request )
307
307
}
308
308
309
309
// Cancel exact order by OID
310
- func (api * ExchangeAPI ) CancelOrderByOID (coin string , orderID int64 ) (* CancelOrderResponse , error ) {
310
+ func (api * ExchangeAPI ) CancelOrderByOID (coin string , orderID int64 ) (* OrderResponse , error ) {
311
311
return api .BulkCancelOrders ([]CancelOidWire {{Asset : api .meta [coin ].AssetId , Oid : int (orderID )}})
312
312
}
313
313
314
314
// Cancel exact order by Client Order Id
315
315
// https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
316
- func (api * ExchangeAPI ) CancelOrderByCloid (coin string , clientOID string ) (* CancelOrderResponse , error ) {
316
+ func (api * ExchangeAPI ) CancelOrderByCloid (coin string , clientOID string ) (* OrderResponse , error ) {
317
317
timestamp := GetNonce ()
318
318
action := CancelCloidOrderAction {
319
319
Type : "cancelByCloid" ,
@@ -335,11 +335,11 @@ func (api *ExchangeAPI) CancelOrderByCloid(coin string, clientOID string) (*Canc
335
335
Signature : ToTypedSig (r , s , v ),
336
336
VaultAddress : nil ,
337
337
}
338
- return MakeUniversalRequest [CancelOrderResponse ](api , request )
338
+ return MakeUniversalRequest [OrderResponse ](api , request )
339
339
}
340
340
341
341
// Cancel all orders for a given coin
342
- func (api * ExchangeAPI ) CancelAllOrdersByCoin (coin string ) (* CancelOrderResponse , error ) {
342
+ func (api * ExchangeAPI ) CancelAllOrdersByCoin (coin string ) (* OrderResponse , error ) {
343
343
orders , err := api .infoAPI .GetOpenOrders (api .AccountAddress ())
344
344
if err != nil {
345
345
api .debug ("Error getting orders: %s" , err )
@@ -356,7 +356,7 @@ func (api *ExchangeAPI) CancelAllOrdersByCoin(coin string) (*CancelOrderResponse
356
356
}
357
357
358
358
// Cancel all open orders
359
- func (api * ExchangeAPI ) CancelAllOrders () (* CancelOrderResponse , error ) {
359
+ func (api * ExchangeAPI ) CancelAllOrders () (* OrderResponse , error ) {
360
360
orders , err := api .infoAPI .GetOpenOrders (api .AccountAddress ())
361
361
if err != nil {
362
362
api .debug ("Error getting orders: %s" , err )
0 commit comments