@candledottv/agent-sdk 0.6.2 → 0.6.3
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 +8 -0
- package/dist/client.d.ts +393 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/hyperliquid-manage.d.ts +137 -0
- package/dist/hyperliquid-manage.d.ts.map +1 -0
- package/dist/hyperliquid-markets.d.ts +179 -0
- package/dist/hyperliquid-markets.d.ts.map +1 -0
- package/dist/hyperliquid-risk.d.ts +425 -0
- package/dist/hyperliquid-risk.d.ts.map +1 -0
- package/dist/hyperliquid-withdraw.d.ts +172 -0
- package/dist/hyperliquid-withdraw.d.ts.map +1 -0
- package/dist/hyperliquid.d.ts +199 -7
- package/dist/hyperliquid.d.ts.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3141 -87
- package/dist/perps-history.d.ts +126 -0
- package/dist/perps-history.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export type PerpsHistoryKind = "fills" | "funding";
|
|
2
|
+
export type PerpsHistoryNetwork = "mainnet" | "testnet";
|
|
3
|
+
/** Hyperliquid's public `/info` endpoint per network. Mirrors `HYPERLIQUID_INFO_URLS`. */
|
|
4
|
+
export declare const PERPS_HISTORY_INFO_URLS: Readonly<Record<PerpsHistoryNetwork, string>>;
|
|
5
|
+
/** Rows a page holds when the caller names no limit. */
|
|
6
|
+
export declare const PERPS_HISTORY_DEFAULT_LIMIT = 100;
|
|
7
|
+
/** The most rows one upstream response carries, and so the largest page: 2,000 fills, 500 funding rows. */
|
|
8
|
+
export declare const PERPS_HISTORY_MAX_LIMIT: Readonly<Record<PerpsHistoryKind, number>>;
|
|
9
|
+
/** The default window: the seven days before `endTime`. */
|
|
10
|
+
export declare const PERPS_HISTORY_DEFAULT_WINDOW_MS: number;
|
|
11
|
+
/** Upstream history requests one call may make before it stops with a resumable cursor. */
|
|
12
|
+
export declare const PERPS_HISTORY_REQUEST_BUDGET = 10;
|
|
13
|
+
/** Hyperliquid serves only an account's 10,000 most recent fills; a cursor chain scans no more. */
|
|
14
|
+
export declare const PERPS_HISTORY_FILL_RETENTION = 10000;
|
|
15
|
+
/** The longest cursor accepted, in characters. */
|
|
16
|
+
export declare const PERPS_HISTORY_MAX_CURSOR_LENGTH = 200000;
|
|
17
|
+
/** How long one upstream request may take. */
|
|
18
|
+
export declare const PERPS_HISTORY_TIMEOUT_MS = 15000;
|
|
19
|
+
export interface PerpsHistoryOptions {
|
|
20
|
+
/** Inclusive epoch milliseconds. Default: seven days before `endTime`. */
|
|
21
|
+
startTime?: number;
|
|
22
|
+
/** Inclusive epoch milliseconds. Default: the first call's clock. */
|
|
23
|
+
endTime?: number;
|
|
24
|
+
/** Rows per page. Default 100; at most 2,000 for fills and 500 for funding. */
|
|
25
|
+
limit?: number;
|
|
26
|
+
/** `nextCursor` from the previous page. Other options, when given, must match it. */
|
|
27
|
+
cursor?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PerpsHistoryWarning {
|
|
30
|
+
code: "PERPS_HISTORY_RETENTION_LIMIT" | "PERPS_HISTORY_PAGE_BUDGET" | "PERPS_HISTORY_BOUNDARY_LIMIT";
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
/** One fill exactly as Hyperliquid reports it; decimal values stay strings. */
|
|
34
|
+
export type PerpsFillRow = Record<string, unknown> & {
|
|
35
|
+
coin: string;
|
|
36
|
+
time: number;
|
|
37
|
+
tid: number;
|
|
38
|
+
oid: number;
|
|
39
|
+
px: string;
|
|
40
|
+
sz: string;
|
|
41
|
+
side: string;
|
|
42
|
+
dir?: string;
|
|
43
|
+
closedPnl: string;
|
|
44
|
+
/** Already includes `builderFee`; never subtract the builder fee again. */
|
|
45
|
+
fee: string;
|
|
46
|
+
feeToken?: string;
|
|
47
|
+
builderFee?: string;
|
|
48
|
+
};
|
|
49
|
+
/** One funding payment exactly as Hyperliquid reports it. `delta.usdc` is signed: negative is paid. */
|
|
50
|
+
export type PerpsFundingRow = Record<string, unknown> & {
|
|
51
|
+
time: number;
|
|
52
|
+
hash: string;
|
|
53
|
+
delta: Record<string, unknown> & {
|
|
54
|
+
coin: string;
|
|
55
|
+
usdc: string;
|
|
56
|
+
fundingRate: string;
|
|
57
|
+
szi: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
interface PageBase {
|
|
61
|
+
success: true;
|
|
62
|
+
walletId: string;
|
|
63
|
+
address: string;
|
|
64
|
+
network: PerpsHistoryNetwork;
|
|
65
|
+
source: "hyperliquid";
|
|
66
|
+
/** When this page was read, epoch milliseconds. */
|
|
67
|
+
readAt: number;
|
|
68
|
+
startTime: number;
|
|
69
|
+
endTime: number;
|
|
70
|
+
/** Pass back as `cursor` for the next page; null when the window is read to its end. */
|
|
71
|
+
nextCursor: string | null;
|
|
72
|
+
hasMore: boolean;
|
|
73
|
+
/** True when coverage stopped short of the window for a venue or budget limit, not for paging. */
|
|
74
|
+
truncated: boolean;
|
|
75
|
+
warnings: PerpsHistoryWarning[];
|
|
76
|
+
}
|
|
77
|
+
export type PerpsFillsPage = PageBase & {
|
|
78
|
+
fills: PerpsFillRow[];
|
|
79
|
+
};
|
|
80
|
+
export type PerpsFundingPage = PageBase & {
|
|
81
|
+
funding: PerpsFundingRow[];
|
|
82
|
+
};
|
|
83
|
+
/** A refusal or an upstream failure. `code` is `VALIDATION_FAILED` or `PERPS_UNAVAILABLE`. */
|
|
84
|
+
export declare class PerpsHistoryError extends Error {
|
|
85
|
+
readonly code: "VALIDATION_FAILED" | "PERPS_UNAVAILABLE";
|
|
86
|
+
readonly extra: {
|
|
87
|
+
field?: string;
|
|
88
|
+
retryable?: boolean;
|
|
89
|
+
retryAfterMs?: number;
|
|
90
|
+
};
|
|
91
|
+
constructor(code: "VALIDATION_FAILED" | "PERPS_UNAVAILABLE", message: string, extra?: {
|
|
92
|
+
field?: string;
|
|
93
|
+
retryable?: boolean;
|
|
94
|
+
retryAfterMs?: number;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
export type PerpsHistoryFetch = (url: string, init?: RequestInit) => Promise<{
|
|
98
|
+
ok: boolean;
|
|
99
|
+
status: number;
|
|
100
|
+
headers?: {
|
|
101
|
+
get(name: string): string | null;
|
|
102
|
+
};
|
|
103
|
+
text(): Promise<string>;
|
|
104
|
+
}>;
|
|
105
|
+
export interface PerpsHistoryRequest {
|
|
106
|
+
kind: PerpsHistoryKind;
|
|
107
|
+
network: PerpsHistoryNetwork;
|
|
108
|
+
walletId: string;
|
|
109
|
+
/** The wallet's EVM address: the Hyperliquid account. */
|
|
110
|
+
address: string;
|
|
111
|
+
options?: PerpsHistoryOptions;
|
|
112
|
+
fetch: PerpsHistoryFetch;
|
|
113
|
+
now: () => number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Read one page. Validation runs before any request, so a bad bound, limit or cursor makes no I/O.
|
|
117
|
+
* A rate limit, a timeout, a malformed answer or an unreadable market list throws `PERPS_UNAVAILABLE`
|
|
118
|
+
* and the caller's cursor stays good for a retry; nothing is ever reported as an empty success.
|
|
119
|
+
*/
|
|
120
|
+
export declare function readPerpsHistoryPage(req: PerpsHistoryRequest): Promise<PerpsFillsPage | PerpsFundingPage>;
|
|
121
|
+
/** Money for a table: two decimals, sign kept. JSON keeps the venue's exact strings. */
|
|
122
|
+
export declare function perpsHistoryMoney(value: unknown): string;
|
|
123
|
+
/** The human lines for one page: wallet, UTC window, rows, then how to read the next page. */
|
|
124
|
+
export declare function perpsHistoryLines(page: PerpsFillsPage | PerpsFundingPage, nextHint: (cursor: string) => string): string[];
|
|
125
|
+
export {};
|
|
126
|
+
//# sourceMappingURL=perps-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perps-history.d.ts","sourceRoot":"","sources":["../src/perps-history.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,gBAAgB,GAAG,OAAO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