@circuitorg/agent-sdk 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -0
- package/index.d.ts +1116 -44
- package/index.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -286,7 +286,7 @@ declare const AgentLogSchema: z.ZodObject<{
|
|
|
286
286
|
reflect: "reflect";
|
|
287
287
|
warning: "warning";
|
|
288
288
|
}>;
|
|
289
|
-
|
|
289
|
+
message: z.ZodString;
|
|
290
290
|
}, z.core.$strip>;
|
|
291
291
|
type AgentLog = z.infer<typeof AgentLogSchema>;
|
|
292
292
|
/**
|
|
@@ -601,14 +601,14 @@ declare const SwidgeExecuteResponseWrapperSchema: z.ZodObject<{
|
|
|
601
601
|
success: z.ZodBoolean;
|
|
602
602
|
data: z.ZodOptional<z.ZodObject<{
|
|
603
603
|
status: z.ZodUnion<readonly [z.ZodLiteral<"success">, z.ZodLiteral<"failure">, z.ZodLiteral<"refund">, z.ZodLiteral<"delayed">]>;
|
|
604
|
-
in: z.ZodObject<{
|
|
604
|
+
in: z.ZodOptional<z.ZodObject<{
|
|
605
605
|
network: z.ZodString;
|
|
606
606
|
txs: z.ZodArray<z.ZodString>;
|
|
607
|
-
}, z.core.$strip
|
|
608
|
-
out: z.ZodObject<{
|
|
607
|
+
}, z.core.$strip>>;
|
|
608
|
+
out: z.ZodOptional<z.ZodObject<{
|
|
609
609
|
network: z.ZodString;
|
|
610
610
|
txs: z.ZodArray<z.ZodString>;
|
|
611
|
-
}, z.core.$strip
|
|
611
|
+
}, z.core.$strip>>;
|
|
612
612
|
lastUpdated: z.ZodNumber;
|
|
613
613
|
error: z.ZodOptional<z.ZodString>;
|
|
614
614
|
}, z.core.$strip>>;
|
|
@@ -640,15 +640,12 @@ declare const PolymarketRedeemPositionsRequestSchema: z.ZodObject<{
|
|
|
640
640
|
declare const PolymarketMarketOrderResponseSchema: z.ZodObject<{
|
|
641
641
|
success: z.ZodBoolean;
|
|
642
642
|
data: z.ZodOptional<z.ZodObject<{
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
totalPriceUsd: z.ZodString;
|
|
650
|
-
txHashes: z.ZodArray<z.ZodString>;
|
|
651
|
-
}, z.core.$strip>;
|
|
643
|
+
orderId: z.ZodString;
|
|
644
|
+
side: z.ZodString;
|
|
645
|
+
size: z.ZodString;
|
|
646
|
+
priceUsd: z.ZodString;
|
|
647
|
+
totalPriceUsd: z.ZodString;
|
|
648
|
+
txHashes: z.ZodArray<z.ZodString>;
|
|
652
649
|
}, z.core.$strip>>;
|
|
653
650
|
error: z.ZodOptional<z.ZodString>;
|
|
654
651
|
errorMessage: z.ZodOptional<z.ZodString>;
|
|
@@ -701,6 +698,236 @@ type PolymarketRedeemPositionsRequest = z.infer<typeof PolymarketRedeemPositions
|
|
|
701
698
|
type PolymarketMarketOrderResponse = z.infer<typeof PolymarketMarketOrderResponseSchema>;
|
|
702
699
|
type PolymarketRedeemPositionsResponse = z.infer<typeof PolymarketRedeemPositionsResponseSchema>;
|
|
703
700
|
|
|
701
|
+
/**
|
|
702
|
+
* Request to place an order on Hyperliquid
|
|
703
|
+
*/
|
|
704
|
+
declare const HyperliquidPlaceOrderRequestSchema: z.ZodObject<{
|
|
705
|
+
symbol: z.ZodString;
|
|
706
|
+
side: z.ZodEnum<{
|
|
707
|
+
buy: "buy";
|
|
708
|
+
sell: "sell";
|
|
709
|
+
}>;
|
|
710
|
+
size: z.ZodNumber;
|
|
711
|
+
price: z.ZodNumber;
|
|
712
|
+
market: z.ZodEnum<{
|
|
713
|
+
perp: "perp";
|
|
714
|
+
spot: "spot";
|
|
715
|
+
}>;
|
|
716
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
717
|
+
market: "market";
|
|
718
|
+
limit: "limit";
|
|
719
|
+
stop: "stop";
|
|
720
|
+
take_profit: "take_profit";
|
|
721
|
+
}>>;
|
|
722
|
+
triggerPrice: z.ZodOptional<z.ZodNumber>;
|
|
723
|
+
reduceOnly: z.ZodOptional<z.ZodBoolean>;
|
|
724
|
+
postOnly: z.ZodOptional<z.ZodBoolean>;
|
|
725
|
+
}, z.core.$strip>;
|
|
726
|
+
/**
|
|
727
|
+
* Request to transfer between spot and perp accounts on Hyperliquid
|
|
728
|
+
*/
|
|
729
|
+
declare const HyperliquidTransferRequestSchema: z.ZodObject<{
|
|
730
|
+
amount: z.ZodNumber;
|
|
731
|
+
toPerp: z.ZodBoolean;
|
|
732
|
+
}, z.core.$strip>;
|
|
733
|
+
declare const HyperliquidPlaceOrderResponseSchema: z.ZodObject<{
|
|
734
|
+
success: z.ZodBoolean;
|
|
735
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
736
|
+
orderId: z.ZodString;
|
|
737
|
+
symbol: z.ZodString;
|
|
738
|
+
side: z.ZodEnum<{
|
|
739
|
+
buy: "buy";
|
|
740
|
+
sell: "sell";
|
|
741
|
+
}>;
|
|
742
|
+
price: z.ZodNumber;
|
|
743
|
+
size: z.ZodNumber;
|
|
744
|
+
filled: z.ZodNumber;
|
|
745
|
+
status: z.ZodString;
|
|
746
|
+
market: z.ZodEnum<{
|
|
747
|
+
perp: "perp";
|
|
748
|
+
spot: "spot";
|
|
749
|
+
}>;
|
|
750
|
+
clientOrderId: z.ZodOptional<z.ZodString>;
|
|
751
|
+
}, z.core.$strip>>;
|
|
752
|
+
error: z.ZodOptional<z.ZodString>;
|
|
753
|
+
}, z.core.$strip>;
|
|
754
|
+
declare const HyperliquidOrderResponseSchema: z.ZodObject<{
|
|
755
|
+
success: z.ZodBoolean;
|
|
756
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
757
|
+
orderId: z.ZodString;
|
|
758
|
+
symbol: z.ZodString;
|
|
759
|
+
side: z.ZodEnum<{
|
|
760
|
+
buy: "buy";
|
|
761
|
+
sell: "sell";
|
|
762
|
+
}>;
|
|
763
|
+
price: z.ZodNumber;
|
|
764
|
+
size: z.ZodNumber;
|
|
765
|
+
filled: z.ZodNumber;
|
|
766
|
+
status: z.ZodString;
|
|
767
|
+
market: z.ZodEnum<{
|
|
768
|
+
perp: "perp";
|
|
769
|
+
spot: "spot";
|
|
770
|
+
}>;
|
|
771
|
+
clientOrderId: z.ZodOptional<z.ZodString>;
|
|
772
|
+
}, z.core.$strip>>;
|
|
773
|
+
error: z.ZodOptional<z.ZodString>;
|
|
774
|
+
}, z.core.$strip>;
|
|
775
|
+
declare const HyperliquidDeleteOrderResponseSchema: z.ZodObject<{
|
|
776
|
+
success: z.ZodBoolean;
|
|
777
|
+
data: z.ZodOptional<z.ZodUndefined>;
|
|
778
|
+
error: z.ZodOptional<z.ZodString>;
|
|
779
|
+
}, z.core.$strip>;
|
|
780
|
+
declare const HyperliquidBalancesResponseSchema: z.ZodObject<{
|
|
781
|
+
success: z.ZodBoolean;
|
|
782
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
783
|
+
perp: z.ZodObject<{
|
|
784
|
+
accountValue: z.ZodString;
|
|
785
|
+
totalMarginUsed: z.ZodString;
|
|
786
|
+
withdrawable: z.ZodString;
|
|
787
|
+
}, z.core.$strip>;
|
|
788
|
+
spot: z.ZodArray<z.ZodObject<{
|
|
789
|
+
coin: z.ZodString;
|
|
790
|
+
total: z.ZodString;
|
|
791
|
+
hold: z.ZodString;
|
|
792
|
+
}, z.core.$strip>>;
|
|
793
|
+
}, z.core.$strip>>;
|
|
794
|
+
error: z.ZodOptional<z.ZodString>;
|
|
795
|
+
}, z.core.$strip>;
|
|
796
|
+
declare const HyperliquidPositionsResponseSchema: z.ZodObject<{
|
|
797
|
+
success: z.ZodBoolean;
|
|
798
|
+
data: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
799
|
+
symbol: z.ZodString;
|
|
800
|
+
side: z.ZodEnum<{
|
|
801
|
+
long: "long";
|
|
802
|
+
short: "short";
|
|
803
|
+
}>;
|
|
804
|
+
size: z.ZodString;
|
|
805
|
+
entryPrice: z.ZodString;
|
|
806
|
+
markPrice: z.ZodString;
|
|
807
|
+
liquidationPrice: z.ZodNullable<z.ZodString>;
|
|
808
|
+
unrealizedPnl: z.ZodString;
|
|
809
|
+
leverage: z.ZodString;
|
|
810
|
+
marginUsed: z.ZodString;
|
|
811
|
+
}, z.core.$strip>>>;
|
|
812
|
+
error: z.ZodOptional<z.ZodString>;
|
|
813
|
+
}, z.core.$strip>;
|
|
814
|
+
declare const HyperliquidOpenOrdersResponseSchema: z.ZodObject<{
|
|
815
|
+
success: z.ZodBoolean;
|
|
816
|
+
data: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
817
|
+
orderId: z.ZodString;
|
|
818
|
+
symbol: z.ZodString;
|
|
819
|
+
side: z.ZodEnum<{
|
|
820
|
+
buy: "buy";
|
|
821
|
+
sell: "sell";
|
|
822
|
+
}>;
|
|
823
|
+
price: z.ZodNumber;
|
|
824
|
+
size: z.ZodNumber;
|
|
825
|
+
filled: z.ZodNumber;
|
|
826
|
+
status: z.ZodString;
|
|
827
|
+
market: z.ZodEnum<{
|
|
828
|
+
perp: "perp";
|
|
829
|
+
spot: "spot";
|
|
830
|
+
}>;
|
|
831
|
+
clientOrderId: z.ZodOptional<z.ZodString>;
|
|
832
|
+
}, z.core.$strip>>>;
|
|
833
|
+
error: z.ZodOptional<z.ZodString>;
|
|
834
|
+
}, z.core.$strip>;
|
|
835
|
+
declare const HyperliquidOrderFillsResponseSchema: z.ZodObject<{
|
|
836
|
+
success: z.ZodBoolean;
|
|
837
|
+
data: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
838
|
+
orderId: z.ZodString;
|
|
839
|
+
symbol: z.ZodString;
|
|
840
|
+
side: z.ZodEnum<{
|
|
841
|
+
buy: "buy";
|
|
842
|
+
sell: "sell";
|
|
843
|
+
}>;
|
|
844
|
+
price: z.ZodString;
|
|
845
|
+
size: z.ZodString;
|
|
846
|
+
fee: z.ZodString;
|
|
847
|
+
timestamp: z.ZodNumber;
|
|
848
|
+
isMaker: z.ZodBoolean;
|
|
849
|
+
}, z.core.$strip>>>;
|
|
850
|
+
error: z.ZodOptional<z.ZodString>;
|
|
851
|
+
}, z.core.$strip>;
|
|
852
|
+
declare const HyperliquidHistoricalOrdersResponseSchema: z.ZodObject<{
|
|
853
|
+
success: z.ZodBoolean;
|
|
854
|
+
data: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
855
|
+
orderId: z.ZodString;
|
|
856
|
+
symbol: z.ZodString;
|
|
857
|
+
side: z.ZodEnum<{
|
|
858
|
+
buy: "buy";
|
|
859
|
+
sell: "sell";
|
|
860
|
+
}>;
|
|
861
|
+
price: z.ZodNumber;
|
|
862
|
+
size: z.ZodNumber;
|
|
863
|
+
filled: z.ZodNumber;
|
|
864
|
+
status: z.ZodEnum<{
|
|
865
|
+
filled: "filled";
|
|
866
|
+
open: "open";
|
|
867
|
+
canceled: "canceled";
|
|
868
|
+
triggered: "triggered";
|
|
869
|
+
rejected: "rejected";
|
|
870
|
+
marginCanceled: "marginCanceled";
|
|
871
|
+
liquidatedCanceled: "liquidatedCanceled";
|
|
872
|
+
}>;
|
|
873
|
+
market: z.ZodEnum<{
|
|
874
|
+
perp: "perp";
|
|
875
|
+
spot: "spot";
|
|
876
|
+
}>;
|
|
877
|
+
timestamp: z.ZodNumber;
|
|
878
|
+
statusTimestamp: z.ZodNumber;
|
|
879
|
+
orderType: z.ZodEnum<{
|
|
880
|
+
Market: "Market";
|
|
881
|
+
Limit: "Limit";
|
|
882
|
+
"Stop Market": "Stop Market";
|
|
883
|
+
"Stop Limit": "Stop Limit";
|
|
884
|
+
"Take Profit Market": "Take Profit Market";
|
|
885
|
+
"Take Profit Limit": "Take Profit Limit";
|
|
886
|
+
}>;
|
|
887
|
+
clientOrderId: z.ZodOptional<z.ZodString>;
|
|
888
|
+
}, z.core.$strip>>>;
|
|
889
|
+
error: z.ZodOptional<z.ZodString>;
|
|
890
|
+
}, z.core.$strip>;
|
|
891
|
+
declare const HyperliquidTransferResponseSchema: z.ZodObject<{
|
|
892
|
+
success: z.ZodBoolean;
|
|
893
|
+
data: z.ZodOptional<z.ZodUndefined>;
|
|
894
|
+
error: z.ZodOptional<z.ZodString>;
|
|
895
|
+
}, z.core.$strip>;
|
|
896
|
+
declare const HyperliquidLiquidationsResponseSchema: z.ZodObject<{
|
|
897
|
+
success: z.ZodBoolean;
|
|
898
|
+
data: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
899
|
+
timestamp: z.ZodNumber;
|
|
900
|
+
liquidatedPositions: z.ZodArray<z.ZodObject<{
|
|
901
|
+
symbol: z.ZodString;
|
|
902
|
+
side: z.ZodEnum<{
|
|
903
|
+
long: "long";
|
|
904
|
+
short: "short";
|
|
905
|
+
}>;
|
|
906
|
+
size: z.ZodString;
|
|
907
|
+
}, z.core.$strip>>;
|
|
908
|
+
totalNotional: z.ZodString;
|
|
909
|
+
accountValue: z.ZodString;
|
|
910
|
+
leverageType: z.ZodEnum<{
|
|
911
|
+
Cross: "Cross";
|
|
912
|
+
Isolated: "Isolated";
|
|
913
|
+
}>;
|
|
914
|
+
txHash: z.ZodString;
|
|
915
|
+
}, z.core.$strip>>>;
|
|
916
|
+
error: z.ZodOptional<z.ZodString>;
|
|
917
|
+
}, z.core.$strip>;
|
|
918
|
+
type HyperliquidPlaceOrderRequest = z.infer<typeof HyperliquidPlaceOrderRequestSchema>;
|
|
919
|
+
type HyperliquidTransferRequest = z.infer<typeof HyperliquidTransferRequestSchema>;
|
|
920
|
+
type HyperliquidPlaceOrderResponse = z.infer<typeof HyperliquidPlaceOrderResponseSchema>;
|
|
921
|
+
type HyperliquidOrderResponse = z.infer<typeof HyperliquidOrderResponseSchema>;
|
|
922
|
+
type HyperliquidDeleteOrderResponse = z.infer<typeof HyperliquidDeleteOrderResponseSchema>;
|
|
923
|
+
type HyperliquidBalancesResponse = z.infer<typeof HyperliquidBalancesResponseSchema>;
|
|
924
|
+
type HyperliquidPositionsResponse = z.infer<typeof HyperliquidPositionsResponseSchema>;
|
|
925
|
+
type HyperliquidOpenOrdersResponse = z.infer<typeof HyperliquidOpenOrdersResponseSchema>;
|
|
926
|
+
type HyperliquidOrderFillsResponse = z.infer<typeof HyperliquidOrderFillsResponseSchema>;
|
|
927
|
+
type HyperliquidHistoricalOrdersResponse = z.infer<typeof HyperliquidHistoricalOrdersResponseSchema>;
|
|
928
|
+
type HyperliquidTransferResponse = z.infer<typeof HyperliquidTransferResponseSchema>;
|
|
929
|
+
type HyperliquidLiquidationsResponse = z.infer<typeof HyperliquidLiquidationsResponseSchema>;
|
|
930
|
+
|
|
704
931
|
/**
|
|
705
932
|
* Memory type definitions for agent session storage
|
|
706
933
|
*
|
|
@@ -804,7 +1031,7 @@ type MemoryListResponse = z.infer<typeof MemoryListResponseSchema>;
|
|
|
804
1031
|
* sessionId: 12345,
|
|
805
1032
|
* });
|
|
806
1033
|
*
|
|
807
|
-
* await sdk.sendLog({ type: "observe",
|
|
1034
|
+
* await sdk.sendLog({ type: "observe", message: "Starting" });
|
|
808
1035
|
* const tx = await sdk.signAndSend({
|
|
809
1036
|
* network: "ethereum:42161",
|
|
810
1037
|
* request: {
|
|
@@ -830,6 +1057,17 @@ declare class AgentSdk {
|
|
|
830
1057
|
* ```
|
|
831
1058
|
*/
|
|
832
1059
|
constructor(config: SDKConfig);
|
|
1060
|
+
/**
|
|
1061
|
+
* @internal
|
|
1062
|
+
*
|
|
1063
|
+
* **DO NOT USE - WILL BREAK YOUR AGENTS**
|
|
1064
|
+
*
|
|
1065
|
+
* ⚠️ **WARNING**: This method will cause issues and break your agents.
|
|
1066
|
+
* Do not use this method.
|
|
1067
|
+
*
|
|
1068
|
+
* @param baseUrl - New base URL to use for API requests
|
|
1069
|
+
*/
|
|
1070
|
+
setBaseUrl(baseUrl: string): void;
|
|
833
1071
|
/**
|
|
834
1072
|
* Internal method to send logs to the backend.
|
|
835
1073
|
* Used by AgentContext.log() method.
|
|
@@ -1044,7 +1282,7 @@ declare class AgentSdk {
|
|
|
1044
1282
|
* @returns SwidgeExecuteResponse or array of responses (matching input type) with transaction status and details
|
|
1045
1283
|
* - `success` (boolean): Whether the execution was successful
|
|
1046
1284
|
* - `data` (SwidgeExecuteData | undefined): Execution result containing:
|
|
1047
|
-
* - `status`: "success" | "failure" | "refund" | "delayed" - Final transaction status
|
|
1285
|
+
* - `status`: "success" | "failure" | "refund" | "delayed" | "error" - Final transaction status
|
|
1048
1286
|
* - `in`: Source transaction details with txs array (transaction hashes)
|
|
1049
1287
|
* - `out`: Destination transaction details with txs array (transaction hashes)
|
|
1050
1288
|
* - Additional metadata about the swap/bridge operation
|
|
@@ -1259,15 +1497,13 @@ declare class AgentSdk {
|
|
|
1259
1497
|
*
|
|
1260
1498
|
* **Output**: `PolymarketMarketOrderResponse`
|
|
1261
1499
|
* - `success` (boolean): Whether the operation was successful
|
|
1262
|
-
* - `data` (
|
|
1263
|
-
* - `
|
|
1264
|
-
* - `
|
|
1265
|
-
*
|
|
1266
|
-
*
|
|
1267
|
-
*
|
|
1268
|
-
*
|
|
1269
|
-
* - `totalPriceUsd` (string): Total order value in USD
|
|
1270
|
-
* - `txHashes` (string[]): List of transaction hashes
|
|
1500
|
+
* - `data` (PolymarketOrderInfo | undefined): Order information (only present on success)
|
|
1501
|
+
* - `orderId` (string): Unique order identifier
|
|
1502
|
+
* - `side` (string): Order side ("BUY" or "SELL")
|
|
1503
|
+
* - `size` (string): Order size
|
|
1504
|
+
* - `priceUsd` (string): Price per share in USD
|
|
1505
|
+
* - `totalPriceUsd` (string): Total order value in USD
|
|
1506
|
+
* - `txHashes` (string[]): List of transaction hashes
|
|
1271
1507
|
* - `error` (string | undefined): Error message (only present on failure)
|
|
1272
1508
|
* - `errorDetails` (object | undefined): Detailed error info
|
|
1273
1509
|
*
|
|
@@ -1296,9 +1532,8 @@ declare class AgentSdk {
|
|
|
1296
1532
|
* });
|
|
1297
1533
|
*
|
|
1298
1534
|
* if (buyResult.success && buyResult.data) {
|
|
1299
|
-
* console.log(`Order
|
|
1300
|
-
* console.log(`
|
|
1301
|
-
* console.log(`Total Price: $${buyResult.data.orderInfo.totalPriceUsd}`);
|
|
1535
|
+
* console.log(`Order ID: ${buyResult.data.orderId}`);
|
|
1536
|
+
* console.log(`Total Price: $${buyResult.data.totalPriceUsd}`);
|
|
1302
1537
|
* } else {
|
|
1303
1538
|
* console.error(`Error: ${buyResult.error}`);
|
|
1304
1539
|
* }
|
|
@@ -1309,17 +1544,13 @@ declare class AgentSdk {
|
|
|
1309
1544
|
* {
|
|
1310
1545
|
* "success": true,
|
|
1311
1546
|
* "data": {
|
|
1312
|
-
* "
|
|
1313
|
-
* "
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
* "txHashes": ["0xabc..."]
|
|
1320
|
-
* }
|
|
1321
|
-
* },
|
|
1322
|
-
* "error": undefined
|
|
1547
|
+
* "orderId": "abc123",
|
|
1548
|
+
* "side": "BUY",
|
|
1549
|
+
* "size": "10.0",
|
|
1550
|
+
* "priceUsd": "0.52",
|
|
1551
|
+
* "totalPriceUsd": "5.20",
|
|
1552
|
+
* "txHashes": ["0xabc..."]
|
|
1553
|
+
* }
|
|
1323
1554
|
* }
|
|
1324
1555
|
* ```
|
|
1325
1556
|
*
|
|
@@ -1327,7 +1558,6 @@ declare class AgentSdk {
|
|
|
1327
1558
|
* ```json
|
|
1328
1559
|
* {
|
|
1329
1560
|
* "success": false,
|
|
1330
|
-
* "data": undefined,
|
|
1331
1561
|
* "error": "Could not get order",
|
|
1332
1562
|
* "errorDetails": { "message": "Invalid request", "status": 400 }
|
|
1333
1563
|
* }
|
|
@@ -1432,6 +1662,400 @@ declare class AgentSdk {
|
|
|
1432
1662
|
*/
|
|
1433
1663
|
redeemPositions: (request?: PolymarketRedeemPositionsRequest) => Promise<PolymarketRedeemPositionsResponse>;
|
|
1434
1664
|
};
|
|
1665
|
+
/**
|
|
1666
|
+
* 🔄 Hyperliquid: Trade perpetuals on Hyperliquid DEX
|
|
1667
|
+
*
|
|
1668
|
+
* Access perpetuals trading operations including orders, positions, and transfers.
|
|
1669
|
+
* All operations are policy-checked and signed automatically.
|
|
1670
|
+
*/
|
|
1671
|
+
hyperliquid: {
|
|
1672
|
+
/**
|
|
1673
|
+
* Place an order on Hyperliquid
|
|
1674
|
+
*
|
|
1675
|
+
* Submit a market, limit, stop, or take-profit order for perpetuals or spot trading.
|
|
1676
|
+
*
|
|
1677
|
+
* **Input**: `HyperliquidPlaceOrderRequest`
|
|
1678
|
+
* - `symbol` (string): Trading pair symbol (e.g., "BTC-USD")
|
|
1679
|
+
* - `side` ("buy" | "sell"): Order side
|
|
1680
|
+
* - `size` (number): Order size
|
|
1681
|
+
* - `price` (number): Order price (for market orders, acts as slippage limit)
|
|
1682
|
+
* - `market` ("perp" | "spot"): Market type
|
|
1683
|
+
* - `type` (string, optional): Order type ("limit", "market", "stop", "take_profit")
|
|
1684
|
+
* - `triggerPrice` (number, optional): Trigger price for stop/take-profit orders
|
|
1685
|
+
* - `reduceOnly` (boolean, optional): Whether this is a reduce-only order
|
|
1686
|
+
* - `postOnly` (boolean, optional): Whether this is a post-only order
|
|
1687
|
+
*
|
|
1688
|
+
* **Output**: `HyperliquidPlaceOrderResponse`
|
|
1689
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1690
|
+
* - `data` (HyperliquidOrderInfo | undefined): Order information (only present on success)
|
|
1691
|
+
* - `data.orderId` (string): Order ID
|
|
1692
|
+
* - `data.symbol` (string): Trading pair symbol
|
|
1693
|
+
* - `data.side` ("buy" | "sell"): Order side
|
|
1694
|
+
* - `data.price` (number): Order price
|
|
1695
|
+
* - `data.size` (number): Order size
|
|
1696
|
+
* - `data.filled` (number): Filled amount
|
|
1697
|
+
* - `data.status` (string): Order status
|
|
1698
|
+
* - `data.market` ("perp" | "spot"): Market type
|
|
1699
|
+
* - `data.clientOrderId` (string | undefined): Client order ID
|
|
1700
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1701
|
+
*
|
|
1702
|
+
* @param request - Order parameters
|
|
1703
|
+
* @returns Promise resolving to HyperliquidPlaceOrderResponse
|
|
1704
|
+
*
|
|
1705
|
+
* @example
|
|
1706
|
+
* ```ts
|
|
1707
|
+
* // Market order
|
|
1708
|
+
* const result = await sdk.platforms.hyperliquid.placeOrder({
|
|
1709
|
+
* symbol: "BTC-USD",
|
|
1710
|
+
* side: "buy",
|
|
1711
|
+
* size: 0.0001,
|
|
1712
|
+
* price: 110000,
|
|
1713
|
+
* market: "perp",
|
|
1714
|
+
* type: "market",
|
|
1715
|
+
* });
|
|
1716
|
+
*
|
|
1717
|
+
* // Limit order
|
|
1718
|
+
* const result = await sdk.platforms.hyperliquid.placeOrder({
|
|
1719
|
+
* symbol: "BTC-USD",
|
|
1720
|
+
* side: "buy",
|
|
1721
|
+
* size: 0.0001,
|
|
1722
|
+
* price: 100000,
|
|
1723
|
+
* market: "perp",
|
|
1724
|
+
* type: "limit",
|
|
1725
|
+
* });
|
|
1726
|
+
*
|
|
1727
|
+
* if (result.success && result.data) {
|
|
1728
|
+
* console.log(`Order placed: ${result.data.orderId}`);
|
|
1729
|
+
* console.log(`Status: ${result.data.status}`);
|
|
1730
|
+
* } else {
|
|
1731
|
+
* console.error(`Error: ${result.error}`);
|
|
1732
|
+
* }
|
|
1733
|
+
* ```
|
|
1734
|
+
*/
|
|
1735
|
+
placeOrder: (request: HyperliquidPlaceOrderRequest) => Promise<HyperliquidPlaceOrderResponse>;
|
|
1736
|
+
/**
|
|
1737
|
+
* Get order information by order ID
|
|
1738
|
+
*
|
|
1739
|
+
* Retrieve details for a specific order including status, filled amount, and price.
|
|
1740
|
+
*
|
|
1741
|
+
* **Input**: `orderId` (string) - Unique order identifier
|
|
1742
|
+
*
|
|
1743
|
+
* **Output**: `HyperliquidOrderResponse`
|
|
1744
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1745
|
+
* - `data` (HyperliquidOrderInfo | undefined): Order details (only present on success)
|
|
1746
|
+
* - `data.orderId` (string): Order ID
|
|
1747
|
+
* - `data.symbol` (string): Trading pair symbol
|
|
1748
|
+
* - `data.side` ("buy" | "sell"): Order side
|
|
1749
|
+
* - `data.price` (number): Order price
|
|
1750
|
+
* - `data.size` (number): Order size
|
|
1751
|
+
* - `data.filled` (number): Filled amount
|
|
1752
|
+
* - `data.status` (string): Order status
|
|
1753
|
+
* - `data.market` ("perp" | "spot"): Market type
|
|
1754
|
+
* - `data.clientOrderId` (string | undefined): Client order ID
|
|
1755
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1756
|
+
*
|
|
1757
|
+
* @param orderId - Order ID to query
|
|
1758
|
+
* @returns Promise resolving to HyperliquidOrderResponse
|
|
1759
|
+
*
|
|
1760
|
+
* @example
|
|
1761
|
+
* ```ts
|
|
1762
|
+
* const result = await sdk.platforms.hyperliquid.order("12345");
|
|
1763
|
+
* if (result.success && result.data) {
|
|
1764
|
+
* console.log(`Order ${result.data.orderId}: ${result.data.status}`);
|
|
1765
|
+
* console.log(`Filled: ${result.data.filled}/${result.data.size}`);
|
|
1766
|
+
* } else {
|
|
1767
|
+
* console.error(`Error: ${result.error}`);
|
|
1768
|
+
* }
|
|
1769
|
+
* ```
|
|
1770
|
+
*/
|
|
1771
|
+
order: (orderId: string) => Promise<HyperliquidOrderResponse>;
|
|
1772
|
+
/**
|
|
1773
|
+
* Cancel an order
|
|
1774
|
+
*
|
|
1775
|
+
* Cancel an open order by order ID and symbol.
|
|
1776
|
+
*
|
|
1777
|
+
* **Input**:
|
|
1778
|
+
* - `orderId` (string): Order ID to cancel
|
|
1779
|
+
* - `symbol` (string): Trading symbol
|
|
1780
|
+
*
|
|
1781
|
+
* **Output**: `HyperliquidDeleteOrderResponse`
|
|
1782
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1783
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1784
|
+
*
|
|
1785
|
+
* Note: This operation returns no data on success (void response).
|
|
1786
|
+
*
|
|
1787
|
+
* @param orderId - Order ID to cancel
|
|
1788
|
+
* @param symbol - Trading symbol
|
|
1789
|
+
* @returns Promise resolving to HyperliquidDeleteOrderResponse
|
|
1790
|
+
*
|
|
1791
|
+
* @example
|
|
1792
|
+
* ```ts
|
|
1793
|
+
* const result = await sdk.platforms.hyperliquid.deleteOrder("12345", "BTC-USD");
|
|
1794
|
+
* if (result.success) {
|
|
1795
|
+
* console.log("Order cancelled successfully");
|
|
1796
|
+
* } else {
|
|
1797
|
+
* console.error(`Error: ${result.error}`);
|
|
1798
|
+
* }
|
|
1799
|
+
* ```
|
|
1800
|
+
*/
|
|
1801
|
+
deleteOrder: (orderId: string, symbol: string) => Promise<HyperliquidDeleteOrderResponse>;
|
|
1802
|
+
/**
|
|
1803
|
+
* Get account balances
|
|
1804
|
+
*
|
|
1805
|
+
* Retrieve perp and spot account balances.
|
|
1806
|
+
*
|
|
1807
|
+
* **Output**: `HyperliquidBalancesResponse`
|
|
1808
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1809
|
+
* - `data` (HyperliquidBalances | undefined): Balance data (only present on success)
|
|
1810
|
+
* - `data.perp` (HyperliquidPerpBalance): Perp account balance
|
|
1811
|
+
* - `data.perp.accountValue` (string): Total account value
|
|
1812
|
+
* - `data.perp.totalMarginUsed` (string): Total margin used
|
|
1813
|
+
* - `data.perp.withdrawable` (string): Withdrawable amount
|
|
1814
|
+
* - `data.spot` (HyperliquidSpotBalance[]): Spot token balances
|
|
1815
|
+
* - `data.spot[].coin` (string): Token symbol
|
|
1816
|
+
* - `data.spot[].total` (string): Total balance
|
|
1817
|
+
* - `data.spot[].hold` (string): Amount on hold
|
|
1818
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1819
|
+
*
|
|
1820
|
+
* @returns Promise resolving to HyperliquidBalancesResponse
|
|
1821
|
+
*
|
|
1822
|
+
* @example
|
|
1823
|
+
* ```ts
|
|
1824
|
+
* const result = await sdk.platforms.hyperliquid.balances();
|
|
1825
|
+
* if (result.success && result.data) {
|
|
1826
|
+
* console.log(`Account value: ${result.data.perp.accountValue}`);
|
|
1827
|
+
* console.log(`Withdrawable: ${result.data.perp.withdrawable}`);
|
|
1828
|
+
* for (const balance of result.data.spot) {
|
|
1829
|
+
* console.log(`${balance.coin}: ${balance.total}`);
|
|
1830
|
+
* }
|
|
1831
|
+
* } else {
|
|
1832
|
+
* console.error(`Error: ${result.error}`);
|
|
1833
|
+
* }
|
|
1834
|
+
* ```
|
|
1835
|
+
*/
|
|
1836
|
+
balances: () => Promise<HyperliquidBalancesResponse>;
|
|
1837
|
+
/**
|
|
1838
|
+
* Get open positions
|
|
1839
|
+
*
|
|
1840
|
+
* Retrieve all open perpetual positions with PnL and position details.
|
|
1841
|
+
*
|
|
1842
|
+
* **Output**: `HyperliquidPositionsResponse`
|
|
1843
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1844
|
+
* - `data` (HyperliquidPosition[] | undefined): Array of open positions (only present on success)
|
|
1845
|
+
* - `data[].symbol` (string): Trading pair symbol (e.g., "BTC-USD")
|
|
1846
|
+
* - `data[].side` ("long" | "short"): Position side
|
|
1847
|
+
* - `data[].size` (string): Position size
|
|
1848
|
+
* - `data[].entryPrice` (string): Average entry price
|
|
1849
|
+
* - `data[].markPrice` (string): Current mark price
|
|
1850
|
+
* - `data[].liquidationPrice` (string | null): Liquidation price (null if no risk)
|
|
1851
|
+
* - `data[].unrealizedPnl` (string): Unrealized profit/loss
|
|
1852
|
+
* - `data[].leverage` (string): Current leverage
|
|
1853
|
+
* - `data[].marginUsed` (string): Margin allocated to position
|
|
1854
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1855
|
+
*
|
|
1856
|
+
* @returns Promise resolving to HyperliquidPositionsResponse
|
|
1857
|
+
*
|
|
1858
|
+
* @example
|
|
1859
|
+
* ```ts
|
|
1860
|
+
* const result = await sdk.platforms.hyperliquid.positions();
|
|
1861
|
+
* if (result.success && result.data) {
|
|
1862
|
+
* for (const pos of result.data) {
|
|
1863
|
+
* console.log(`${pos.symbol}: ${pos.side} ${pos.size}`);
|
|
1864
|
+
* console.log(`Entry: ${pos.entryPrice}, Mark: ${pos.markPrice}`);
|
|
1865
|
+
* console.log(`Unrealized PnL: ${pos.unrealizedPnl}`);
|
|
1866
|
+
* }
|
|
1867
|
+
* } else {
|
|
1868
|
+
* console.error(`Error: ${result.error}`);
|
|
1869
|
+
* }
|
|
1870
|
+
* ```
|
|
1871
|
+
*/
|
|
1872
|
+
positions: () => Promise<HyperliquidPositionsResponse>;
|
|
1873
|
+
/**
|
|
1874
|
+
* Get open orders
|
|
1875
|
+
*
|
|
1876
|
+
* Retrieve all currently open orders.
|
|
1877
|
+
*
|
|
1878
|
+
* **Output**: `HyperliquidOpenOrdersResponse`
|
|
1879
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1880
|
+
* - `data` (HyperliquidOrderInfo[] | undefined): Array of open orders (only present on success)
|
|
1881
|
+
* - `data[].orderId` (string): Order ID
|
|
1882
|
+
* - `data[].symbol` (string): Trading pair symbol
|
|
1883
|
+
* - `data[].side` ("buy" | "sell"): Order side
|
|
1884
|
+
* - `data[].price` (number): Order price
|
|
1885
|
+
* - `data[].size` (number): Order size
|
|
1886
|
+
* - `data[].filled` (number): Filled amount
|
|
1887
|
+
* - `data[].status` (string): Order status
|
|
1888
|
+
* - `data[].market` ("perp" | "spot"): Market type
|
|
1889
|
+
* - `data[].clientOrderId` (string | undefined): Client order ID
|
|
1890
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1891
|
+
*
|
|
1892
|
+
* @returns Promise resolving to HyperliquidOpenOrdersResponse
|
|
1893
|
+
*
|
|
1894
|
+
* @example
|
|
1895
|
+
* ```ts
|
|
1896
|
+
* const result = await sdk.platforms.hyperliquid.openOrders();
|
|
1897
|
+
* if (result.success && result.data) {
|
|
1898
|
+
* console.log(`You have ${result.data.length} open orders`);
|
|
1899
|
+
* for (const order of result.data) {
|
|
1900
|
+
* console.log(`${order.symbol}: ${order.side} ${order.size} @ ${order.price}`);
|
|
1901
|
+
* }
|
|
1902
|
+
* } else {
|
|
1903
|
+
* console.error(`Error: ${result.error}`);
|
|
1904
|
+
* }
|
|
1905
|
+
* ```
|
|
1906
|
+
*/
|
|
1907
|
+
openOrders: () => Promise<HyperliquidOpenOrdersResponse>;
|
|
1908
|
+
/**
|
|
1909
|
+
* Get order fill history
|
|
1910
|
+
*
|
|
1911
|
+
* Retrieve order fill history including partial and complete fills.
|
|
1912
|
+
*
|
|
1913
|
+
* **Output**: `HyperliquidOrderFillsResponse`
|
|
1914
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1915
|
+
* - `data` (HyperliquidFill[] | undefined): Array of order fills (only present on success)
|
|
1916
|
+
* - `data[].orderId` (string): Order ID
|
|
1917
|
+
* - `data[].symbol` (string): Trading pair symbol
|
|
1918
|
+
* - `data[].side` ("buy" | "sell"): Fill side
|
|
1919
|
+
* - `data[].price` (string): Fill price
|
|
1920
|
+
* - `data[].size` (string): Fill size
|
|
1921
|
+
* - `data[].fee` (string): Trading fee paid
|
|
1922
|
+
* - `data[].timestamp` (number): Fill timestamp in milliseconds
|
|
1923
|
+
* - `data[].isMaker` (boolean): True if maker, false if taker
|
|
1924
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1925
|
+
*
|
|
1926
|
+
* @returns Promise resolving to HyperliquidOrderFillsResponse
|
|
1927
|
+
*
|
|
1928
|
+
* @example
|
|
1929
|
+
* ```ts
|
|
1930
|
+
* const result = await sdk.platforms.hyperliquid.orderFills();
|
|
1931
|
+
* if (result.success && result.data) {
|
|
1932
|
+
* console.log(`Total fills: ${result.data.length}`);
|
|
1933
|
+
* for (const fill of result.data) {
|
|
1934
|
+
* const fillType = fill.isMaker ? "maker" : "taker";
|
|
1935
|
+
* console.log(`${fill.symbol}: ${fill.size} @ ${fill.price} (${fillType}, fee: ${fill.fee})`);
|
|
1936
|
+
* }
|
|
1937
|
+
* } else {
|
|
1938
|
+
* console.error(`Error: ${result.error}`);
|
|
1939
|
+
* }
|
|
1940
|
+
* ```
|
|
1941
|
+
*/
|
|
1942
|
+
orderFills: () => Promise<HyperliquidOrderFillsResponse>;
|
|
1943
|
+
/**
|
|
1944
|
+
* Get historical orders
|
|
1945
|
+
*
|
|
1946
|
+
* Retrieve order history including filled, cancelled, and expired orders.
|
|
1947
|
+
*
|
|
1948
|
+
* **Output**: `HyperliquidHistoricalOrdersResponse`
|
|
1949
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1950
|
+
* - `data` (HyperliquidHistoricalOrder[] | undefined): Array of historical orders (only present on success)
|
|
1951
|
+
* - `data[].orderId` (string): Order ID
|
|
1952
|
+
* - `data[].symbol` (string): Trading pair symbol
|
|
1953
|
+
* - `data[].side` ("buy" | "sell"): Order side
|
|
1954
|
+
* - `data[].price` (number): Order price
|
|
1955
|
+
* - `data[].size` (number): Order size
|
|
1956
|
+
* - `data[].filled` (number): Filled amount
|
|
1957
|
+
* - `data[].status` ("open" | "filled" | "canceled" | "triggered" | "rejected" | "marginCanceled" | "liquidatedCanceled"): Order status
|
|
1958
|
+
* - `data[].market` ("perp" | "spot"): Market type
|
|
1959
|
+
* - `data[].timestamp` (number): Order creation timestamp in milliseconds
|
|
1960
|
+
* - `data[].statusTimestamp` (number): Status update timestamp in milliseconds
|
|
1961
|
+
* - `data[].orderType` ("Market" | "Limit" | "Stop Market" | "Stop Limit" | "Take Profit Market" | "Take Profit Limit"): Order type
|
|
1962
|
+
* - `data[].clientOrderId` (string | undefined): Client order ID
|
|
1963
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1964
|
+
*
|
|
1965
|
+
* @returns Promise resolving to HyperliquidHistoricalOrdersResponse
|
|
1966
|
+
*
|
|
1967
|
+
* @example
|
|
1968
|
+
* ```ts
|
|
1969
|
+
* const result = await sdk.platforms.hyperliquid.orders();
|
|
1970
|
+
* if (result.success && result.data) {
|
|
1971
|
+
* console.log(`Order history: ${result.data.length} orders`);
|
|
1972
|
+
* const filled = result.data.filter(o => o.status === "filled");
|
|
1973
|
+
* console.log(`Filled orders: ${filled.length}`);
|
|
1974
|
+
* } else {
|
|
1975
|
+
* console.error(`Error: ${result.error}`);
|
|
1976
|
+
* }
|
|
1977
|
+
* ```
|
|
1978
|
+
*/
|
|
1979
|
+
orders: () => Promise<HyperliquidHistoricalOrdersResponse>;
|
|
1980
|
+
/**
|
|
1981
|
+
* Transfer between spot and perp accounts
|
|
1982
|
+
*
|
|
1983
|
+
* Move funds between your spot wallet and perpetuals trading account.
|
|
1984
|
+
*
|
|
1985
|
+
* **Input**: `HyperliquidTransferRequest`
|
|
1986
|
+
* - `amount` (number): Amount to transfer
|
|
1987
|
+
* - `toPerp` (boolean): True to transfer to perp account, False to transfer to spot
|
|
1988
|
+
*
|
|
1989
|
+
* **Output**: `HyperliquidTransferResponse`
|
|
1990
|
+
* - `success` (boolean): Whether the operation was successful
|
|
1991
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
1992
|
+
*
|
|
1993
|
+
* Note: This operation returns no data on success (void response).
|
|
1994
|
+
*
|
|
1995
|
+
* @param request - Transfer parameters
|
|
1996
|
+
* @returns Promise resolving to HyperliquidTransferResponse
|
|
1997
|
+
*
|
|
1998
|
+
* @example
|
|
1999
|
+
* ```ts
|
|
2000
|
+
* // Transfer 1000 USDC to perp account
|
|
2001
|
+
* const result = await sdk.platforms.hyperliquid.transfer({
|
|
2002
|
+
* amount: 1000,
|
|
2003
|
+
* toPerp: true
|
|
2004
|
+
* });
|
|
2005
|
+
*
|
|
2006
|
+
* if (result.success) {
|
|
2007
|
+
* console.log("Transfer completed successfully");
|
|
2008
|
+
* } else {
|
|
2009
|
+
* console.error(`Error: ${result.error}`);
|
|
2010
|
+
* }
|
|
2011
|
+
* ```
|
|
2012
|
+
*/
|
|
2013
|
+
transfer: (request: HyperliquidTransferRequest) => Promise<HyperliquidTransferResponse>;
|
|
2014
|
+
/**
|
|
2015
|
+
* Get liquidation events
|
|
2016
|
+
*
|
|
2017
|
+
* Retrieve liquidation events for the account, optionally filtered by start time.
|
|
2018
|
+
*
|
|
2019
|
+
* **Input**: `startTime` (number, optional) - Unix timestamp in milliseconds to filter liquidations from
|
|
2020
|
+
*
|
|
2021
|
+
* **Output**: `HyperliquidLiquidationsResponse`
|
|
2022
|
+
* - `success` (boolean): Whether the operation was successful
|
|
2023
|
+
* - `data` (HyperliquidLiquidation[] | undefined): Array of liquidation events (only present on success)
|
|
2024
|
+
* - `data[].timestamp` (number): Liquidation timestamp in milliseconds
|
|
2025
|
+
* - `data[].liquidatedPositions` (HyperliquidLiquidatedPosition[]): Liquidated positions
|
|
2026
|
+
* - `data[].liquidatedPositions[].symbol` (string): Position symbol (e.g., "BTC-USD")
|
|
2027
|
+
* - `data[].liquidatedPositions[].side` ("long" | "short"): Position side
|
|
2028
|
+
* - `data[].liquidatedPositions[].size` (string): Position size that was liquidated
|
|
2029
|
+
* - `data[].totalNotional` (string): Total notional value liquidated
|
|
2030
|
+
* - `data[].accountValue` (string): Account value at liquidation
|
|
2031
|
+
* - `data[].leverageType` ("Cross" | "Isolated"): Leverage type
|
|
2032
|
+
* - `data[].txHash` (string): Transaction hash
|
|
2033
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
2034
|
+
*
|
|
2035
|
+
* @param startTime - Optional start time for filtering (Unix timestamp in milliseconds)
|
|
2036
|
+
* @returns Promise resolving to HyperliquidLiquidationsResponse
|
|
2037
|
+
*
|
|
2038
|
+
* @example
|
|
2039
|
+
* ```ts
|
|
2040
|
+
* // Get all liquidations (defaults to last 30 days)
|
|
2041
|
+
* const all = await sdk.platforms.hyperliquid.liquidations();
|
|
2042
|
+
*
|
|
2043
|
+
* // Get liquidations from last 24h
|
|
2044
|
+
* const yesterday = Date.now() - (24 * 60 * 60 * 1000);
|
|
2045
|
+
* const recent = await sdk.platforms.hyperliquid.liquidations(yesterday);
|
|
2046
|
+
*
|
|
2047
|
+
* if (recent.success && recent.data) {
|
|
2048
|
+
* console.log(`Liquidations in last 24h: ${recent.data.length}`);
|
|
2049
|
+
* for (const liq of recent.data) {
|
|
2050
|
+
* console.log(`Liquidated ${liq.liquidatedPositions.length} positions`);
|
|
2051
|
+
* }
|
|
2052
|
+
* } else {
|
|
2053
|
+
* console.error(`Error: ${recent.error}`);
|
|
2054
|
+
* }
|
|
2055
|
+
* ```
|
|
2056
|
+
*/
|
|
2057
|
+
liquidations: (startTime?: number) => Promise<HyperliquidLiquidationsResponse>;
|
|
2058
|
+
};
|
|
1435
2059
|
};
|
|
1436
2060
|
/**
|
|
1437
2061
|
* Handle EVM transaction signing and broadcasting
|
|
@@ -1463,6 +2087,46 @@ declare class AgentSdk {
|
|
|
1463
2087
|
private handleSwidgeExecute;
|
|
1464
2088
|
private handlePolymarketMarketOrder;
|
|
1465
2089
|
private handlePolymarketRedeemPositions;
|
|
2090
|
+
/**
|
|
2091
|
+
* Handle Hyperliquid place order requests
|
|
2092
|
+
*/
|
|
2093
|
+
private handleHyperliquidPlaceOrder;
|
|
2094
|
+
/**
|
|
2095
|
+
* Handle Hyperliquid get order requests
|
|
2096
|
+
*/
|
|
2097
|
+
private handleHyperliquidGetOrder;
|
|
2098
|
+
/**
|
|
2099
|
+
* Handle Hyperliquid delete order requests
|
|
2100
|
+
*/
|
|
2101
|
+
private handleHyperliquidDeleteOrder;
|
|
2102
|
+
/**
|
|
2103
|
+
* Handle Hyperliquid get balances requests
|
|
2104
|
+
*/
|
|
2105
|
+
private handleHyperliquidGetBalances;
|
|
2106
|
+
/**
|
|
2107
|
+
* Handle Hyperliquid get positions requests
|
|
2108
|
+
*/
|
|
2109
|
+
private handleHyperliquidGetPositions;
|
|
2110
|
+
/**
|
|
2111
|
+
* Handle Hyperliquid get open orders requests
|
|
2112
|
+
*/
|
|
2113
|
+
private handleHyperliquidGetOpenOrders;
|
|
2114
|
+
/**
|
|
2115
|
+
* Handle Hyperliquid get order fills requests
|
|
2116
|
+
*/
|
|
2117
|
+
private handleHyperliquidGetOrderFills;
|
|
2118
|
+
/**
|
|
2119
|
+
* Handle Hyperliquid get historical orders requests
|
|
2120
|
+
*/
|
|
2121
|
+
private handleHyperliquidGetHistoricalOrders;
|
|
2122
|
+
/**
|
|
2123
|
+
* Handle Hyperliquid transfer requests
|
|
2124
|
+
*/
|
|
2125
|
+
private handleHyperliquidTransfer;
|
|
2126
|
+
/**
|
|
2127
|
+
* Handle Hyperliquid get liquidations requests
|
|
2128
|
+
*/
|
|
2129
|
+
private handleHyperliquidGetLiquidations;
|
|
1466
2130
|
/**
|
|
1467
2131
|
* Handle memory set requests
|
|
1468
2132
|
*/
|
|
@@ -1703,7 +2367,7 @@ interface CurrentPosition {
|
|
|
1703
2367
|
* - **Request metadata**: `sessionId`, `sessionWalletAddress`, `currentPositions`
|
|
1704
2368
|
* - **Core methods**: `log()`, `signAndSend()`, `signMessage()`
|
|
1705
2369
|
* - **Memory operations**: `memory.set()`, `memory.get()`, `memory.delete()`, `memory.list()`
|
|
1706
|
-
* - **Platform integrations**: `platforms.polymarket.*` for prediction market trading
|
|
2370
|
+
* - **Platform integrations**: `platforms.polymarket.*` for prediction market trading, `platforms.hyperliquid.*` for perpetuals trading
|
|
1707
2371
|
* - **Cross-chain swaps**: `swidge.quote()`, `swidge.execute()`
|
|
1708
2372
|
*
|
|
1709
2373
|
* The agent developer's execution and stop functions receive this object:
|
|
@@ -1768,10 +2432,14 @@ interface CurrentPosition {
|
|
|
1768
2432
|
* @property memory.delete - Delete a key from session memory
|
|
1769
2433
|
* @property memory.list - List all keys in session memory
|
|
1770
2434
|
*
|
|
1771
|
-
* @property platforms - Platform integrations (Polymarket, etc.)
|
|
2435
|
+
* @property platforms - Platform integrations (Polymarket, Hyperliquid, etc.)
|
|
1772
2436
|
* @property platforms.polymarket - Prediction market trading operations
|
|
1773
2437
|
* @property platforms.polymarket.marketOrder - Execute a buy or sell market order on Polymarket
|
|
1774
2438
|
* @property platforms.polymarket.redeemPositions - Redeem settled positions and claim winnings
|
|
2439
|
+
* @property platforms.hyperliquid - Perpetuals trading operations on Hyperliquid DEX
|
|
2440
|
+
* @property platforms.hyperliquid.placeOrder - Place an order on Hyperliquid
|
|
2441
|
+
* @property platforms.hyperliquid.balances - Get account balances
|
|
2442
|
+
* @property platforms.hyperliquid.positions - Get open positions
|
|
1775
2443
|
*
|
|
1776
2444
|
* @property swidge - Cross-chain swap and bridge operations
|
|
1777
2445
|
* @property swidge.quote - Get a quote for swapping tokens between networks
|
|
@@ -1817,6 +2485,17 @@ declare class AgentContext {
|
|
|
1817
2485
|
baseUrl?: string;
|
|
1818
2486
|
authorizationHeader?: string;
|
|
1819
2487
|
});
|
|
2488
|
+
/**
|
|
2489
|
+
* @internal
|
|
2490
|
+
*
|
|
2491
|
+
* **DO NOT USE - WILL BREAK YOUR AGENTS**
|
|
2492
|
+
*
|
|
2493
|
+
* ⚠️ **WARNING**: This method will cause issues and break your agents.
|
|
2494
|
+
* Do not use this method.
|
|
2495
|
+
*
|
|
2496
|
+
* @param baseUrl - New base URL to use for API requests
|
|
2497
|
+
*/
|
|
2498
|
+
setBaseUrl(baseUrl: string): void;
|
|
1820
2499
|
/**
|
|
1821
2500
|
* Unified logging method that handles console output and backend messaging.
|
|
1822
2501
|
*
|
|
@@ -2113,7 +2792,7 @@ declare class AgentContext {
|
|
|
2113
2792
|
* Access platform integrations for trading and DeFi operations.
|
|
2114
2793
|
*
|
|
2115
2794
|
* Platform integrations provide seamless access to external services like
|
|
2116
|
-
* prediction markets,
|
|
2795
|
+
* prediction markets, perpetuals trading, and more.
|
|
2117
2796
|
*/
|
|
2118
2797
|
readonly platforms: {
|
|
2119
2798
|
/**
|
|
@@ -2205,6 +2884,399 @@ declare class AgentContext {
|
|
|
2205
2884
|
*/
|
|
2206
2885
|
redeemPositions: (request?: PolymarketRedeemPositionsRequest) => Promise<PolymarketRedeemPositionsResponse>;
|
|
2207
2886
|
};
|
|
2887
|
+
/**
|
|
2888
|
+
* Access Hyperliquid perpetuals trading operations.
|
|
2889
|
+
*
|
|
2890
|
+
* Trade perpetual contracts on Hyperliquid DEX using your session wallet.
|
|
2891
|
+
*/
|
|
2892
|
+
hyperliquid: {
|
|
2893
|
+
/**
|
|
2894
|
+
* Place an order on Hyperliquid
|
|
2895
|
+
*
|
|
2896
|
+
* Submit a market, limit, stop, or take-profit order for perpetuals or spot trading.
|
|
2897
|
+
*
|
|
2898
|
+
* **Input**: `HyperliquidPlaceOrderRequest`
|
|
2899
|
+
* - `symbol` (string): Trading pair symbol (e.g., "BTC-USD")
|
|
2900
|
+
* - `side` ("buy" | "sell"): Order side
|
|
2901
|
+
* - `size` (number): Order size
|
|
2902
|
+
* - `price` (number): Order price (for market orders, acts as slippage limit)
|
|
2903
|
+
* - `market` ("perp" | "spot"): Market type
|
|
2904
|
+
* - `type` (string, optional): Order type ("limit", "market", "stop", "take_profit")
|
|
2905
|
+
* - `triggerPrice` (number, optional): Trigger price for stop/take-profit orders
|
|
2906
|
+
* - `reduceOnly` (boolean, optional): Whether this is a reduce-only order
|
|
2907
|
+
* - `postOnly` (boolean, optional): Whether this is a post-only order
|
|
2908
|
+
*
|
|
2909
|
+
* **Output**: `HyperliquidPlaceOrderResponse`
|
|
2910
|
+
* - `success` (boolean): Whether the operation was successful
|
|
2911
|
+
* - `data` (HyperliquidOrderInfo | undefined): Order information (only present on success)
|
|
2912
|
+
* - `data.orderId` (string): Order ID
|
|
2913
|
+
* - `data.symbol` (string): Trading pair symbol
|
|
2914
|
+
* - `data.side` ("buy" | "sell"): Order side
|
|
2915
|
+
* - `data.price` (number): Order price
|
|
2916
|
+
* - `data.size` (number): Order size
|
|
2917
|
+
* - `data.filled` (number): Filled amount
|
|
2918
|
+
* - `data.status` (string): Order status
|
|
2919
|
+
* - `data.market` ("perp" | "spot"): Market type
|
|
2920
|
+
* - `data.clientOrderId` (string | undefined): Client order ID
|
|
2921
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
2922
|
+
*
|
|
2923
|
+
* @param request - Order parameters
|
|
2924
|
+
* @returns Promise resolving to HyperliquidPlaceOrderResponse
|
|
2925
|
+
*
|
|
2926
|
+
* @example
|
|
2927
|
+
* ```ts
|
|
2928
|
+
* // Market order
|
|
2929
|
+
* const result = await agent.platforms.hyperliquid.placeOrder({
|
|
2930
|
+
* symbol: "BTC-USD",
|
|
2931
|
+
* side: "buy",
|
|
2932
|
+
* size: 0.0001,
|
|
2933
|
+
* price: 110000,
|
|
2934
|
+
* market: "perp",
|
|
2935
|
+
* type: "market",
|
|
2936
|
+
* });
|
|
2937
|
+
*
|
|
2938
|
+
* // Limit order
|
|
2939
|
+
* const result = await agent.platforms.hyperliquid.placeOrder({
|
|
2940
|
+
* symbol: "BTC-USD",
|
|
2941
|
+
* side: "buy",
|
|
2942
|
+
* size: 0.0001,
|
|
2943
|
+
* price: 100000,
|
|
2944
|
+
* market: "perp",
|
|
2945
|
+
* type: "limit",
|
|
2946
|
+
* });
|
|
2947
|
+
*
|
|
2948
|
+
* if (result.success && result.data) {
|
|
2949
|
+
* await agent.log(`Order placed: ${result.data.orderId}`);
|
|
2950
|
+
* await agent.log(`Status: ${result.data.status}`);
|
|
2951
|
+
* } else {
|
|
2952
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
2953
|
+
* }
|
|
2954
|
+
* ```
|
|
2955
|
+
*/
|
|
2956
|
+
placeOrder: (request: HyperliquidPlaceOrderRequest) => Promise<HyperliquidPlaceOrderResponse>;
|
|
2957
|
+
/**
|
|
2958
|
+
* Get order information by order ID
|
|
2959
|
+
*
|
|
2960
|
+
* Retrieve details for a specific order including status, filled amount, and price.
|
|
2961
|
+
*
|
|
2962
|
+
* **Input**: `orderId` (string) - Unique order identifier
|
|
2963
|
+
*
|
|
2964
|
+
* **Output**: `HyperliquidOrderResponse`
|
|
2965
|
+
* - `success` (boolean): Whether the operation was successful
|
|
2966
|
+
* - `data` (HyperliquidOrderInfo | undefined): Order details (only present on success)
|
|
2967
|
+
* - `data.orderId` (string): Order ID
|
|
2968
|
+
* - `data.symbol` (string): Trading pair symbol
|
|
2969
|
+
* - `data.side` ("buy" | "sell"): Order side
|
|
2970
|
+
* - `data.price` (number): Order price
|
|
2971
|
+
* - `data.size` (number): Order size
|
|
2972
|
+
* - `data.filled` (number): Filled amount
|
|
2973
|
+
* - `data.status` (string): Order status
|
|
2974
|
+
* - `data.market` ("perp" | "spot"): Market type
|
|
2975
|
+
* - `data.clientOrderId` (string | undefined): Client order ID
|
|
2976
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
2977
|
+
*
|
|
2978
|
+
* @param orderId - Order ID to query
|
|
2979
|
+
* @returns Promise resolving to HyperliquidOrderResponse
|
|
2980
|
+
*
|
|
2981
|
+
* @example
|
|
2982
|
+
* ```ts
|
|
2983
|
+
* const result = await agent.platforms.hyperliquid.order("12345");
|
|
2984
|
+
* if (result.success && result.data) {
|
|
2985
|
+
* await agent.log(`Order ${result.data.orderId}: ${result.data.status}`);
|
|
2986
|
+
* await agent.log(`Filled: ${result.data.filled}/${result.data.size}`);
|
|
2987
|
+
* } else {
|
|
2988
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
2989
|
+
* }
|
|
2990
|
+
* ```
|
|
2991
|
+
*/
|
|
2992
|
+
order: (orderId: string) => Promise<HyperliquidOrderResponse>;
|
|
2993
|
+
/**
|
|
2994
|
+
* Cancel an order
|
|
2995
|
+
*
|
|
2996
|
+
* Cancel an open order by order ID and symbol.
|
|
2997
|
+
*
|
|
2998
|
+
* **Input**:
|
|
2999
|
+
* - `orderId` (string): Order ID to cancel
|
|
3000
|
+
* - `symbol` (string): Trading symbol
|
|
3001
|
+
*
|
|
3002
|
+
* **Output**: `HyperliquidDeleteOrderResponse`
|
|
3003
|
+
* - `success` (boolean): Whether the operation was successful
|
|
3004
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
3005
|
+
*
|
|
3006
|
+
* Note: This operation returns no data on success (void response).
|
|
3007
|
+
*
|
|
3008
|
+
* @param orderId - Order ID to cancel
|
|
3009
|
+
* @param symbol - Trading symbol
|
|
3010
|
+
* @returns Promise resolving to HyperliquidDeleteOrderResponse
|
|
3011
|
+
*
|
|
3012
|
+
* @example
|
|
3013
|
+
* ```ts
|
|
3014
|
+
* const result = await agent.platforms.hyperliquid.deleteOrder("12345", "BTC-USD");
|
|
3015
|
+
* if (result.success) {
|
|
3016
|
+
* await agent.log("Order cancelled successfully");
|
|
3017
|
+
* } else {
|
|
3018
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
3019
|
+
* }
|
|
3020
|
+
* ```
|
|
3021
|
+
*/
|
|
3022
|
+
deleteOrder: (orderId: string, symbol: string) => Promise<HyperliquidDeleteOrderResponse>;
|
|
3023
|
+
/**
|
|
3024
|
+
* Get account balances
|
|
3025
|
+
*
|
|
3026
|
+
* Retrieve perp and spot account balances.
|
|
3027
|
+
*
|
|
3028
|
+
* **Output**: `HyperliquidBalancesResponse`
|
|
3029
|
+
* - `success` (boolean): Whether the operation was successful
|
|
3030
|
+
* - `data` (HyperliquidBalances | undefined): Balance data (only present on success)
|
|
3031
|
+
* - `data.perp` (HyperliquidPerpBalance): Perp account balance
|
|
3032
|
+
* - `data.perp.accountValue` (string): Total account value
|
|
3033
|
+
* - `data.perp.totalMarginUsed` (string): Total margin used
|
|
3034
|
+
* - `data.perp.withdrawable` (string): Withdrawable amount
|
|
3035
|
+
* - `data.spot` (HyperliquidSpotBalance[]): Spot token balances
|
|
3036
|
+
* - `data.spot[].coin` (string): Token symbol
|
|
3037
|
+
* - `data.spot[].total` (string): Total balance
|
|
3038
|
+
* - `data.spot[].hold` (string): Amount on hold
|
|
3039
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
3040
|
+
*
|
|
3041
|
+
* @returns Promise resolving to HyperliquidBalancesResponse
|
|
3042
|
+
*
|
|
3043
|
+
* @example
|
|
3044
|
+
* ```ts
|
|
3045
|
+
* const result = await agent.platforms.hyperliquid.balances();
|
|
3046
|
+
* if (result.success && result.data) {
|
|
3047
|
+
* await agent.log(`Account value: ${result.data.perp.accountValue}`);
|
|
3048
|
+
* await agent.log(`Withdrawable: ${result.data.perp.withdrawable}`);
|
|
3049
|
+
* for (const balance of result.data.spot) {
|
|
3050
|
+
* await agent.log(`${balance.coin}: ${balance.total}`);
|
|
3051
|
+
* }
|
|
3052
|
+
* } else {
|
|
3053
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
3054
|
+
* }
|
|
3055
|
+
* ```
|
|
3056
|
+
*/
|
|
3057
|
+
balances: () => Promise<HyperliquidBalancesResponse>;
|
|
3058
|
+
/**
|
|
3059
|
+
* Get open positions
|
|
3060
|
+
*
|
|
3061
|
+
* Retrieve all open perpetual positions with PnL and position details.
|
|
3062
|
+
*
|
|
3063
|
+
* **Output**: `HyperliquidPositionsResponse`
|
|
3064
|
+
* - `success` (boolean): Whether the operation was successful
|
|
3065
|
+
* - `data` (HyperliquidPosition[] | undefined): Array of open positions (only present on success)
|
|
3066
|
+
* - `data[].symbol` (string): Trading pair symbol (e.g., "BTC-USD")
|
|
3067
|
+
* - `data[].side` ("long" | "short"): Position side
|
|
3068
|
+
* - `data[].size` (string): Position size
|
|
3069
|
+
* - `data[].entryPrice` (string): Average entry price
|
|
3070
|
+
* - `data[].markPrice` (string): Current mark price
|
|
3071
|
+
* - `data[].liquidationPrice` (string | null): Liquidation price (null if no risk)
|
|
3072
|
+
* - `data[].unrealizedPnl` (string): Unrealized profit/loss
|
|
3073
|
+
* - `data[].leverage` (string): Current leverage
|
|
3074
|
+
* - `data[].marginUsed` (string): Margin allocated to position
|
|
3075
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
3076
|
+
*
|
|
3077
|
+
* @returns Promise resolving to HyperliquidPositionsResponse
|
|
3078
|
+
*
|
|
3079
|
+
* @example
|
|
3080
|
+
* ```ts
|
|
3081
|
+
* const result = await agent.platforms.hyperliquid.positions();
|
|
3082
|
+
* if (result.success && result.data) {
|
|
3083
|
+
* for (const pos of result.data) {
|
|
3084
|
+
* await agent.log(`${pos.symbol}: ${pos.side} ${pos.size}`);
|
|
3085
|
+
* await agent.log(`Entry: ${pos.entryPrice}, Mark: ${pos.markPrice}`);
|
|
3086
|
+
* await agent.log(`Unrealized PnL: ${pos.unrealizedPnl}`);
|
|
3087
|
+
* }
|
|
3088
|
+
* } else {
|
|
3089
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
3090
|
+
* }
|
|
3091
|
+
* ```
|
|
3092
|
+
*/
|
|
3093
|
+
positions: () => Promise<HyperliquidPositionsResponse>;
|
|
3094
|
+
/**
|
|
3095
|
+
* Get open orders
|
|
3096
|
+
*
|
|
3097
|
+
* Retrieve all currently open orders.
|
|
3098
|
+
*
|
|
3099
|
+
* **Output**: `HyperliquidOpenOrdersResponse`
|
|
3100
|
+
* - `success` (boolean): Whether the operation was successful
|
|
3101
|
+
* - `data` (HyperliquidOrderInfo[] | undefined): Array of open orders (only present on success)
|
|
3102
|
+
* - `data[].orderId` (string): Order ID
|
|
3103
|
+
* - `data[].symbol` (string): Trading pair symbol
|
|
3104
|
+
* - `data[].side` ("buy" | "sell"): Order side
|
|
3105
|
+
* - `data[].price` (number): Order price
|
|
3106
|
+
* - `data[].size` (number): Order size
|
|
3107
|
+
* - `data[].filled` (number): Filled amount
|
|
3108
|
+
* - `data[].status` (string): Order status
|
|
3109
|
+
* - `data[].market` ("perp" | "spot"): Market type
|
|
3110
|
+
* - `data[].clientOrderId` (string | undefined): Client order ID
|
|
3111
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
3112
|
+
*
|
|
3113
|
+
* @returns Promise resolving to HyperliquidOpenOrdersResponse
|
|
3114
|
+
*
|
|
3115
|
+
* @example
|
|
3116
|
+
* ```ts
|
|
3117
|
+
* const result = await agent.platforms.hyperliquid.openOrders();
|
|
3118
|
+
* if (result.success && result.data) {
|
|
3119
|
+
* await agent.log(`You have ${result.data.length} open orders`);
|
|
3120
|
+
* for (const order of result.data) {
|
|
3121
|
+
* await agent.log(`${order.symbol}: ${order.side} ${order.size} @ ${order.price}`);
|
|
3122
|
+
* }
|
|
3123
|
+
* } else {
|
|
3124
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
3125
|
+
* }
|
|
3126
|
+
* ```
|
|
3127
|
+
*/
|
|
3128
|
+
openOrders: () => Promise<HyperliquidOpenOrdersResponse>;
|
|
3129
|
+
/**
|
|
3130
|
+
* Get order fill history
|
|
3131
|
+
*
|
|
3132
|
+
* Retrieve order fill history including partial and complete fills.
|
|
3133
|
+
*
|
|
3134
|
+
* **Output**: `HyperliquidOrderFillsResponse`
|
|
3135
|
+
* - `success` (boolean): Whether the operation was successful
|
|
3136
|
+
* - `data` (HyperliquidFill[] | undefined): Array of order fills (only present on success)
|
|
3137
|
+
* - `data[].orderId` (string): Order ID
|
|
3138
|
+
* - `data[].symbol` (string): Trading pair symbol
|
|
3139
|
+
* - `data[].side` ("buy" | "sell"): Fill side
|
|
3140
|
+
* - `data[].price` (string): Fill price
|
|
3141
|
+
* - `data[].size` (string): Fill size
|
|
3142
|
+
* - `data[].fee` (string): Trading fee paid
|
|
3143
|
+
* - `data[].timestamp` (number): Fill timestamp in milliseconds
|
|
3144
|
+
* - `data[].isMaker` (boolean): True if maker, false if taker
|
|
3145
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
3146
|
+
*
|
|
3147
|
+
* @returns Promise resolving to HyperliquidOrderFillsResponse
|
|
3148
|
+
*
|
|
3149
|
+
* @example
|
|
3150
|
+
* ```ts
|
|
3151
|
+
* const result = await agent.platforms.hyperliquid.orderFills();
|
|
3152
|
+
* if (result.success && result.data) {
|
|
3153
|
+
* await agent.log(`Total fills: ${result.data.length}`);
|
|
3154
|
+
* for (const fill of result.data) {
|
|
3155
|
+
* const fillType = fill.isMaker ? "maker" : "taker";
|
|
3156
|
+
* await agent.log(`${fill.symbol}: ${fill.size} @ ${fill.price} (${fillType}, fee: ${fill.fee})`);
|
|
3157
|
+
* }
|
|
3158
|
+
* } else {
|
|
3159
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
3160
|
+
* }
|
|
3161
|
+
* ```
|
|
3162
|
+
*/
|
|
3163
|
+
orderFills: () => Promise<HyperliquidOrderFillsResponse>;
|
|
3164
|
+
/**
|
|
3165
|
+
* Get historical orders
|
|
3166
|
+
*
|
|
3167
|
+
* Retrieve order history including filled, cancelled, and expired orders.
|
|
3168
|
+
*
|
|
3169
|
+
* **Output**: `HyperliquidHistoricalOrdersResponse`
|
|
3170
|
+
* - `success` (boolean): Whether the operation was successful
|
|
3171
|
+
* - `data` (HyperliquidHistoricalOrder[] | undefined): Array of historical orders (only present on success)
|
|
3172
|
+
* - `data[].orderId` (string): Order ID
|
|
3173
|
+
* - `data[].symbol` (string): Trading pair symbol
|
|
3174
|
+
* - `data[].side` ("buy" | "sell"): Order side
|
|
3175
|
+
* - `data[].price` (number): Order price
|
|
3176
|
+
* - `data[].size` (number): Order size
|
|
3177
|
+
* - `data[].filled` (number): Filled amount
|
|
3178
|
+
* - `data[].status` ("open" | "filled" | "canceled" | "triggered" | "rejected" | "marginCanceled" | "liquidatedCanceled"): Order status
|
|
3179
|
+
* - `data[].market` ("perp" | "spot"): Market type
|
|
3180
|
+
* - `data[].timestamp` (number): Order creation timestamp in milliseconds
|
|
3181
|
+
* - `data[].statusTimestamp` (number): Status update timestamp in milliseconds
|
|
3182
|
+
* - `data[].orderType` ("Market" | "Limit" | "Stop Market" | "Stop Limit" | "Take Profit Market" | "Take Profit Limit"): Order type
|
|
3183
|
+
* - `data[].clientOrderId` (string | undefined): Client order ID
|
|
3184
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
3185
|
+
*
|
|
3186
|
+
* @returns Promise resolving to HyperliquidHistoricalOrdersResponse
|
|
3187
|
+
*
|
|
3188
|
+
* @example
|
|
3189
|
+
* ```ts
|
|
3190
|
+
* const result = await agent.platforms.hyperliquid.orders();
|
|
3191
|
+
* if (result.success && result.data) {
|
|
3192
|
+
* await agent.log(`Order history: ${result.data.length} orders`);
|
|
3193
|
+
* const filled = result.data.filter(o => o.status === "filled");
|
|
3194
|
+
* await agent.log(`Filled orders: ${filled.length}`);
|
|
3195
|
+
* } else {
|
|
3196
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
3197
|
+
* }
|
|
3198
|
+
* ```
|
|
3199
|
+
*/
|
|
3200
|
+
orders: () => Promise<HyperliquidHistoricalOrdersResponse>;
|
|
3201
|
+
/**
|
|
3202
|
+
* Transfer between spot and perp accounts
|
|
3203
|
+
*
|
|
3204
|
+
* Move funds between your spot wallet and perpetuals trading account.
|
|
3205
|
+
*
|
|
3206
|
+
* **Input**: `HyperliquidTransferRequest`
|
|
3207
|
+
* - `amount` (number): Amount to transfer
|
|
3208
|
+
* - `toPerp` (boolean): True to transfer to perp account, False to transfer to spot
|
|
3209
|
+
*
|
|
3210
|
+
* **Output**: `HyperliquidTransferResponse`
|
|
3211
|
+
* - `success` (boolean): Whether the operation was successful
|
|
3212
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
3213
|
+
*
|
|
3214
|
+
* Note: This operation returns no data on success (void response).
|
|
3215
|
+
*
|
|
3216
|
+
* @param request - Transfer parameters
|
|
3217
|
+
* @returns Promise resolving to HyperliquidTransferResponse
|
|
3218
|
+
*
|
|
3219
|
+
* @example
|
|
3220
|
+
* ```ts
|
|
3221
|
+
* // Transfer 1000 USDC to perp account
|
|
3222
|
+
* const result = await agent.platforms.hyperliquid.transfer({
|
|
3223
|
+
* amount: 1000,
|
|
3224
|
+
* toPerp: true
|
|
3225
|
+
* });
|
|
3226
|
+
*
|
|
3227
|
+
* if (result.success) {
|
|
3228
|
+
* await agent.log("Transfer completed successfully");
|
|
3229
|
+
* } else {
|
|
3230
|
+
* await agent.log(`Error: ${result.error}`, { error: true });
|
|
3231
|
+
* }
|
|
3232
|
+
* ```
|
|
3233
|
+
*/
|
|
3234
|
+
transfer: (request: HyperliquidTransferRequest) => Promise<HyperliquidTransferResponse>;
|
|
3235
|
+
/**
|
|
3236
|
+
* Get liquidation events
|
|
3237
|
+
*
|
|
3238
|
+
* Retrieve liquidation events for the account, optionally filtered by start time.
|
|
3239
|
+
*
|
|
3240
|
+
* **Input**: `startTime` (number, optional) - Unix timestamp in milliseconds to filter liquidations from
|
|
3241
|
+
*
|
|
3242
|
+
* **Output**: `HyperliquidLiquidationsResponse`
|
|
3243
|
+
* - `success` (boolean): Whether the operation was successful
|
|
3244
|
+
* - `data` (HyperliquidLiquidation[] | undefined): Array of liquidation events (only present on success)
|
|
3245
|
+
* - `data[].timestamp` (number): Liquidation timestamp in milliseconds
|
|
3246
|
+
* - `data[].liquidatedPositions` (HyperliquidLiquidatedPosition[]): Liquidated positions
|
|
3247
|
+
* - `data[].liquidatedPositions[].symbol` (string): Position symbol (e.g., "BTC-USD")
|
|
3248
|
+
* - `data[].liquidatedPositions[].side` ("long" | "short"): Position side
|
|
3249
|
+
* - `data[].liquidatedPositions[].size` (string): Position size that was liquidated
|
|
3250
|
+
* - `data[].totalNotional` (string): Total notional value liquidated
|
|
3251
|
+
* - `data[].accountValue` (string): Account value at liquidation
|
|
3252
|
+
* - `data[].leverageType` ("Cross" | "Isolated"): Leverage type
|
|
3253
|
+
* - `data[].txHash` (string): Transaction hash
|
|
3254
|
+
* - `error` (string | undefined): Error message (only present on failure)
|
|
3255
|
+
*
|
|
3256
|
+
* @param startTime - Optional start time for filtering (Unix timestamp in milliseconds)
|
|
3257
|
+
* @returns Promise resolving to HyperliquidLiquidationsResponse
|
|
3258
|
+
*
|
|
3259
|
+
* @example
|
|
3260
|
+
* ```ts
|
|
3261
|
+
* // Get all liquidations (defaults to last 30 days)
|
|
3262
|
+
* const all = await agent.platforms.hyperliquid.liquidations();
|
|
3263
|
+
*
|
|
3264
|
+
* // Get liquidations from last 24h
|
|
3265
|
+
* const yesterday = Date.now() - (24 * 60 * 60 * 1000);
|
|
3266
|
+
* const recent = await agent.platforms.hyperliquid.liquidations(yesterday);
|
|
3267
|
+
*
|
|
3268
|
+
* if (recent.success && recent.data) {
|
|
3269
|
+
* await agent.log(`Liquidations in last 24h: ${recent.data.length}`);
|
|
3270
|
+
* for (const liq of recent.data) {
|
|
3271
|
+
* await agent.log(`Liquidated ${liq.liquidatedPositions.length} positions`);
|
|
3272
|
+
* }
|
|
3273
|
+
* } else {
|
|
3274
|
+
* await agent.log(`Error: ${recent.error}`, { error: true });
|
|
3275
|
+
* }
|
|
3276
|
+
* ```
|
|
3277
|
+
*/
|
|
3278
|
+
liquidations: (startTime?: number) => Promise<HyperliquidLiquidationsResponse>;
|
|
3279
|
+
};
|
|
2208
3280
|
};
|
|
2209
3281
|
/**
|
|
2210
3282
|
* Access cross-chain swap and bridge operations.
|
|
@@ -2560,4 +3632,4 @@ declare function isSolanaNetwork(network: Network): network is "solana";
|
|
|
2560
3632
|
*/
|
|
2561
3633
|
declare function getChainIdFromNetwork(network: `ethereum:${number}`): number;
|
|
2562
3634
|
|
|
2563
|
-
export { APIClient, Agent, AgentContext, AgentSdk, type AssetChange, type CurrentPosition, type CurrentPositionsData, type CurrentPositionsResponse, type EnrichedPosition, type LogResponse, type MemoryDeleteResponse, type MemoryGetResponse, type MemoryListResponse, type MemorySetResponse, type Network, type PolymarketMarketOrderRequest, type PolymarketMarketOrderResponse, type PolymarketRedeemPositionsRequest, type PolymarketRedeemPositionsResponse, QUOTE_RESULT, type SDKConfig, type SignAndSendRequest, type SignAndSendResponse, type SignMessageRequest, type SignMessageResponse, type StopFunctionContract, type SwidgeExecuteResponse, type SwidgeQuoteRequest, type SwidgeQuoteResponse, type SwidgeQuoteResult, type TransactionsResponse, getChainIdFromNetwork, isEthereumNetwork, isSolanaNetwork, type runFunctionContract };
|
|
3635
|
+
export { APIClient, Agent, AgentContext, AgentSdk, type AssetChange, type CurrentPosition, type CurrentPositionsData, type CurrentPositionsResponse, type EnrichedPosition, type HyperliquidBalancesResponse, type HyperliquidDeleteOrderResponse, type HyperliquidHistoricalOrdersResponse, type HyperliquidLiquidationsResponse, type HyperliquidOpenOrdersResponse, type HyperliquidOrderFillsResponse, type HyperliquidOrderResponse, type HyperliquidPlaceOrderRequest, type HyperliquidPlaceOrderResponse, type HyperliquidPositionsResponse, type HyperliquidTransferRequest, type HyperliquidTransferResponse, type LogResponse, type MemoryDeleteResponse, type MemoryGetResponse, type MemoryListResponse, type MemorySetResponse, type Network, type PolymarketMarketOrderRequest, type PolymarketMarketOrderResponse, type PolymarketRedeemPositionsRequest, type PolymarketRedeemPositionsResponse, QUOTE_RESULT, type SDKConfig, type SignAndSendRequest, type SignAndSendResponse, type SignMessageRequest, type SignMessageResponse, type StopFunctionContract, type SwidgeExecuteResponse, type SwidgeQuoteRequest, type SwidgeQuoteResponse, type SwidgeQuoteResult, type TransactionsResponse, getChainIdFromNetwork, isEthereumNetwork, isSolanaNetwork, type runFunctionContract };
|