@candledottv/agent-sdk 0.6.2 → 0.6.4
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 +10 -1
- package/dist/client.d.ts +508 -30
- 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 +164 -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 +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3348 -78
- package/dist/perps-history.d.ts +126 -0
- package/dist/perps-history.d.ts.map +1 -0
- package/dist/quant.d.ts +118 -0
- package/dist/quant.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -39,8 +39,13 @@
|
|
|
39
39
|
* The README's "Retrying a write that failed or timed out" is the caller-facing procedure.
|
|
40
40
|
*/
|
|
41
41
|
import { type SignedTradeLeg } from "./errors";
|
|
42
|
-
import { type HyperliquidNetwork, type HyperliquidTypedData } from "./hyperliquid";
|
|
42
|
+
import { type HyperliquidNetwork, type HyperliquidSubmitOutcome, type HyperliquidTypedData } from "./hyperliquid";
|
|
43
|
+
import { type PerpsTpslParams, type PerpsWorkflowResult } from "./hyperliquid-manage";
|
|
44
|
+
import { type PerpsBookOptions, type PerpsBookResult, type PerpsCandlesOptions, type PerpsCandlesResult, type PerpsMarketResult, type PerpsMarketsOptions, type PerpsMarketsResult } from "./hyperliquid-markets";
|
|
43
45
|
import type { HyperliquidPnlSection } from "./hyperliquid-pnl";
|
|
46
|
+
import { type PerpsAccountLine, type PerpsAccountReport, type PerpsPortfolioSection, type PerpsPositionRow, type PerpsRiskReport, type PerpsRiskSettings, type PerpsRiskThresholds, type PerpsRiskThresholdsReport, type PerpsWatchEvent } from "./hyperliquid-risk";
|
|
47
|
+
import { type PerpsWithdrawAuthorization, type PerpsWithdrawBuild, type PerpsWithdrawPins } from "./hyperliquid-withdraw";
|
|
48
|
+
import { type PerpsFillsPage, type PerpsFundingPage, type PerpsHistoryOptions } from "./perps-history";
|
|
44
49
|
import type { AgentPlansResult, PlanPrice, PlanTable } from "./plans";
|
|
45
50
|
import type { SecretStore } from "./secret-store";
|
|
46
51
|
import type { CandleStaking } from "./staking";
|
|
@@ -108,13 +113,20 @@ export interface CandleClientOptions {
|
|
|
108
113
|
/**
|
|
109
114
|
* Candle's Hyperliquid builder address, pinned by the caller. Every perps build is checked
|
|
110
115
|
* against it before signing: an order must name exactly this builder (or none, on a Max order),
|
|
111
|
-
* and setup must approve exactly it.
|
|
112
|
-
*
|
|
113
|
-
*
|
|
116
|
+
* and setup must approve exactly it. This deliberately replaces the release trust anchor and
|
|
117
|
+
* is shown as `preview.builderTrust.source: "override"`. Must be a nonzero EVM address; an
|
|
118
|
+
* invalid override refuses setup/signing. Unset uses the release pin, never `/perps/config`.
|
|
114
119
|
*/
|
|
115
120
|
hyperliquidBuilder?: string;
|
|
116
121
|
/** The Hyperliquid network this client trades on. Default mainnet; a build for another is refused. */
|
|
117
122
|
hyperliquidNetwork?: HyperliquidNetwork;
|
|
123
|
+
/**
|
|
124
|
+
* The withdrawal pins every withdrawal is checked against before anything is signed: the
|
|
125
|
+
* perps-USDC `token`, `destinationDex`, Relay's depository allow-list and the amount's string
|
|
126
|
+
* form. Unset, this release's `CANDLE_PERPS_WITHDRAW_PINS` applies (the values V-A recorded on
|
|
127
|
+
* 2026-10-18). Pins of null would refuse every withdrawal with nothing signed.
|
|
128
|
+
*/
|
|
129
|
+
perpsWithdrawPins?: PerpsWithdrawPins;
|
|
118
130
|
}
|
|
119
131
|
/** The bonding-curve terms of one (chain, quote asset, tier) cell. */
|
|
120
132
|
export interface CurveTerms {
|
|
@@ -1718,7 +1730,7 @@ export interface EvmSignTransactionParams {
|
|
|
1718
1730
|
*
|
|
1719
1731
|
* A TEE payer (Ember Phase 4c) may also start from USDC, and needs `clientTradeId`: the server
|
|
1720
1732
|
* then resolves the destination to this key's own TEE wallet on Hood (`toWalletId` names one when
|
|
1721
|
-
* the key has several),
|
|
1733
|
+
* the key has several), honours any cap on the origin asset (none is required), and charges no fee. That bridge is
|
|
1722
1734
|
* gated by the server's `TEE_BRIDGE_ENABLED`; with it off the build answers `PAIR_UNSUPPORTED`.
|
|
1723
1735
|
* A Hood-origin bridge signs one leg at a time and is not this call; `candle swap` runs it.
|
|
1724
1736
|
*/
|
|
@@ -1799,12 +1811,29 @@ export interface PerpsOpenParams extends PerpsWalletRef {
|
|
|
1799
1811
|
takeProfit?: string;
|
|
1800
1812
|
/** Optional reduce-only stop-loss trigger price. */
|
|
1801
1813
|
stopLoss?: string;
|
|
1814
|
+
/**
|
|
1815
|
+
* Optional client order id: `0x` and 32 hex digits, chosen by the caller and used as the order's
|
|
1816
|
+
* cloid. A retry with the same id and the same request returns the original operation
|
|
1817
|
+
* (`replayed: true`) instead of placing another order; the same id with a different request is
|
|
1818
|
+
* refused (`PERPS_CLIENT_ID_CONFLICT`). It deduplicates, it does not resume: a retry never signs or
|
|
1819
|
+
* submits, so a build-only first call stays unsubmitted. Use a new id for a genuinely new order.
|
|
1820
|
+
*/
|
|
1821
|
+
clientId?: string;
|
|
1802
1822
|
}
|
|
1803
1823
|
export interface PerpsCloseParams extends PerpsWalletRef {
|
|
1804
1824
|
coin: string;
|
|
1805
1825
|
/** Part of the position to close; the whole position when omitted. */
|
|
1806
1826
|
size?: string;
|
|
1827
|
+
/**
|
|
1828
|
+
* Phase 1 D (spec 2026-10-17 D, section 8): a percentage of the position instead of a size, a
|
|
1829
|
+
* decimal string above 0 and at most 100 with at most four decimals. Sized by both the server and
|
|
1830
|
+
* this client from a direct position read: `floor(|szi| * pct / 100)` at the market's size step,
|
|
1831
|
+
* never rounded up. Exclusive with `size`.
|
|
1832
|
+
*/
|
|
1833
|
+
pct?: string;
|
|
1807
1834
|
slippageBps?: number;
|
|
1835
|
+
/** Optional client order id, as on `PerpsOpenParams.clientId`. */
|
|
1836
|
+
clientId?: string;
|
|
1808
1837
|
}
|
|
1809
1838
|
export interface PerpsCancelParams extends PerpsWalletRef {
|
|
1810
1839
|
/** The cloid of an order Candle built (an open, or one of its take-profit / stop-loss legs). */
|
|
@@ -1818,7 +1847,12 @@ export interface PerpsModifyParams extends PerpsWalletRef {
|
|
|
1818
1847
|
}
|
|
1819
1848
|
export interface PerpsLeverageParams extends PerpsWalletRef {
|
|
1820
1849
|
coin: string;
|
|
1821
|
-
|
|
1850
|
+
/**
|
|
1851
|
+
* Whole-number leverage. Phase 1 D (spec D, section 5): may be omitted when `mode` is named, and
|
|
1852
|
+
* then the account's current leverage is kept (read from Hyperliquid), never defaulted to 1. A
|
|
1853
|
+
* mode change needs no position and no resting order in the coin.
|
|
1854
|
+
*/
|
|
1855
|
+
leverage?: number;
|
|
1822
1856
|
mode?: "cross" | "isolated";
|
|
1823
1857
|
}
|
|
1824
1858
|
export interface PerpsMarginParams extends PerpsWalletRef {
|
|
@@ -1826,11 +1860,19 @@ export interface PerpsMarginParams extends PerpsWalletRef {
|
|
|
1826
1860
|
/** USD, up to 6 decimals; negative removes isolated margin. */
|
|
1827
1861
|
amount: string;
|
|
1828
1862
|
}
|
|
1863
|
+
/** BE-1584: a scheduled cancel (spec D, section 7). `seconds` sets the venue's timer; `clear` disarms it. */
|
|
1864
|
+
export type PerpsScheduleCancelParams = PerpsWalletRef & ({
|
|
1865
|
+
seconds: number;
|
|
1866
|
+
clear?: undefined;
|
|
1867
|
+
} | {
|
|
1868
|
+
clear: true;
|
|
1869
|
+
seconds?: undefined;
|
|
1870
|
+
});
|
|
1829
1871
|
/** What a perps build route returns: the plaintext action, its nonce, and the stamped typed data. */
|
|
1830
1872
|
export interface PerpsBuild {
|
|
1831
1873
|
success: true;
|
|
1832
1874
|
perpOrderId: string;
|
|
1833
|
-
kind: "open" | "close" | "modify" | "cancel" | "leverage" | "margin" | "setup";
|
|
1875
|
+
kind: "open" | "close" | "modify" | "cancel" | "leverage" | "margin" | "setup" | "tpsl" | "scheduleCancel";
|
|
1834
1876
|
network: HyperliquidNetwork;
|
|
1835
1877
|
walletId: string;
|
|
1836
1878
|
address: string;
|
|
@@ -1849,6 +1891,9 @@ export interface PerpsBuild {
|
|
|
1849
1891
|
feeTenthsBps: number;
|
|
1850
1892
|
} | null;
|
|
1851
1893
|
exchangeUrl: string;
|
|
1894
|
+
/** BE-1584: the key's reduce-only setting and policy version this build was judged under. Absent from an older API. */
|
|
1895
|
+
perpsReduceOnly?: boolean;
|
|
1896
|
+
perpsPolicyVersion?: number;
|
|
1852
1897
|
preview: Record<string, unknown>;
|
|
1853
1898
|
}
|
|
1854
1899
|
/**
|
|
@@ -1858,11 +1903,152 @@ export interface PerpsBuild {
|
|
|
1858
1903
|
* statuses for an order).
|
|
1859
1904
|
*/
|
|
1860
1905
|
export interface PerpsActionResult {
|
|
1906
|
+
replayed?: false;
|
|
1861
1907
|
build: PerpsBuild;
|
|
1862
1908
|
signature: string | null;
|
|
1863
1909
|
submitted: boolean;
|
|
1864
1910
|
exchange: unknown | null;
|
|
1865
1911
|
submitError?: string;
|
|
1912
|
+
/**
|
|
1913
|
+
* BE-1584 (spec D, section 3): Hyperliquid's answer judged per leg. `confirmed` only when the venue
|
|
1914
|
+
* said ok and no leg carries an error; HTTP 200 alone is not confirmation. Absent when nothing was
|
|
1915
|
+
* submitted.
|
|
1916
|
+
*/
|
|
1917
|
+
outcome?: HyperliquidSubmitOutcome;
|
|
1918
|
+
/** A scheduled cancel: Candle recorded the venue's acknowledgement (not proof the timer will fire). */
|
|
1919
|
+
acknowledged?: boolean;
|
|
1920
|
+
/** A margin-mode change: the mode asked for, and the one Hyperliquid shows after the submit (null when unread). */
|
|
1921
|
+
requestedMode?: "cross" | "isolated";
|
|
1922
|
+
confirmedMode?: "cross" | "isolated" | null;
|
|
1923
|
+
}
|
|
1924
|
+
/** BE-1584 (spec D, section 9): the key's reduce-only setting. */
|
|
1925
|
+
export interface PerpsReduceOnlyResult {
|
|
1926
|
+
success: true;
|
|
1927
|
+
keyPrefix: string;
|
|
1928
|
+
perpsReduceOnly: boolean;
|
|
1929
|
+
perpsPolicyVersion: number;
|
|
1930
|
+
changed?: boolean;
|
|
1931
|
+
/** On enabling: what the setting does not do (no cancel, no revocation of signed actions, no other keys). */
|
|
1932
|
+
limits?: string[];
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* The original operation a client order id already names, as `POST /perps/open` or `/perps/close`
|
|
1936
|
+
* returns it for a retry (spec 2026-10-17 C, section 8). Nothing signable: `status` is Candle's
|
|
1937
|
+
* record (`building` / `built` mean not yet seen on the venue), `venueStatus` what reconcile observed.
|
|
1938
|
+
*/
|
|
1939
|
+
export interface PerpsReplay {
|
|
1940
|
+
success: true;
|
|
1941
|
+
replayed: true;
|
|
1942
|
+
perpOrderId: string;
|
|
1943
|
+
kind: "open" | "close";
|
|
1944
|
+
network: HyperliquidNetwork;
|
|
1945
|
+
walletId: string;
|
|
1946
|
+
address: string;
|
|
1947
|
+
clientId: string;
|
|
1948
|
+
cloid: string;
|
|
1949
|
+
childCloids: string[];
|
|
1950
|
+
nonce: number;
|
|
1951
|
+
status: string;
|
|
1952
|
+
venueStatus: string | null;
|
|
1953
|
+
filledSz: string | null;
|
|
1954
|
+
notionalUsdMicros: number | null;
|
|
1955
|
+
builtAt: number;
|
|
1956
|
+
settledAt: number | null;
|
|
1957
|
+
preview: Record<string, unknown> | null;
|
|
1958
|
+
}
|
|
1959
|
+
/** A retry under a client order id: the original operation, and nothing signed, submitted or charged. */
|
|
1960
|
+
export interface PerpsReplayResult {
|
|
1961
|
+
replayed: true;
|
|
1962
|
+
replay: PerpsReplay;
|
|
1963
|
+
build: null;
|
|
1964
|
+
signature: null;
|
|
1965
|
+
submitted: false;
|
|
1966
|
+
exchange: null;
|
|
1967
|
+
}
|
|
1968
|
+
/** `POST /agent/perps/withdraw`: a quote for a withdrawal to this key's own Solana or Hood TEE wallet. */
|
|
1969
|
+
export interface PerpsWithdrawBuildRequest {
|
|
1970
|
+
clientWithdrawalId: string;
|
|
1971
|
+
/**
|
|
1972
|
+
* USDC, a decimal string with at most 6 decimals, at least 10 USDC. The server refuses
|
|
1973
|
+
* `PERPS_WITHDRAW_BELOW_MINIMUM` under 10 USDC (`limit: "minimumAmount"`), and when Relay guarantees
|
|
1974
|
+
* under 5 USDC or its fees are above 5% of the amount (`limit: "minimum"`); Hyperliquid's one-time
|
|
1975
|
+
* 1 USDC activation fee on the account's first withdrawal or transfer does not count toward the 5%.
|
|
1976
|
+
*/
|
|
1977
|
+
amountUsdc: string;
|
|
1978
|
+
to: "solana" | "hood";
|
|
1979
|
+
/** The key's EVM TEE wallet row id; the key's only one when omitted. */
|
|
1980
|
+
wallet?: string;
|
|
1981
|
+
}
|
|
1982
|
+
/** One withdrawal as the server records it, with Relay's live status on a read. */
|
|
1983
|
+
export interface PerpsWithdrawStatus {
|
|
1984
|
+
success: true;
|
|
1985
|
+
id: string;
|
|
1986
|
+
status: "quoted" | "authorized" | "submitted" | "settled" | "refunded" | "failed";
|
|
1987
|
+
from: {
|
|
1988
|
+
walletId: string;
|
|
1989
|
+
address: string;
|
|
1990
|
+
network: string;
|
|
1991
|
+
};
|
|
1992
|
+
to: {
|
|
1993
|
+
chain: "solana" | "hood";
|
|
1994
|
+
walletId: string;
|
|
1995
|
+
address: string;
|
|
1996
|
+
};
|
|
1997
|
+
amountUsdc: string;
|
|
1998
|
+
feesUsdc: string;
|
|
1999
|
+
netUsdc: string;
|
|
2000
|
+
minimumOutUsdc: string;
|
|
2001
|
+
relayRequestId: string;
|
|
2002
|
+
/** Relay `protocol.v2.orderId`, when the quote stored one. Status reads still use `relayRequestId`. */
|
|
2003
|
+
relayOrderId?: string;
|
|
2004
|
+
nonce: number;
|
|
2005
|
+
failureReason: string | null;
|
|
2006
|
+
relay?: {
|
|
2007
|
+
status: string | null;
|
|
2008
|
+
txHashes: string[];
|
|
2009
|
+
} | null;
|
|
2010
|
+
[key: string]: unknown;
|
|
2011
|
+
}
|
|
2012
|
+
/** The four withdraw routes, one call each. No check runs here: `perpsWithdraw()` runs them. */
|
|
2013
|
+
export interface CandlePerpsWithdraw {
|
|
2014
|
+
build(request: PerpsWithdrawBuildRequest): Promise<PerpsWithdrawBuild>;
|
|
2015
|
+
authorize(request: {
|
|
2016
|
+
clientWithdrawalId: string;
|
|
2017
|
+
signature: string;
|
|
2018
|
+
}): Promise<PerpsWithdrawAuthorization>;
|
|
2019
|
+
reportSubmitted(request: {
|
|
2020
|
+
clientWithdrawalId: string;
|
|
2021
|
+
exchangeResponse: unknown;
|
|
2022
|
+
}): Promise<PerpsWithdrawStatus>;
|
|
2023
|
+
get(clientWithdrawalId: string): Promise<PerpsWithdrawStatus>;
|
|
2024
|
+
}
|
|
2025
|
+
export interface CandlePerps {
|
|
2026
|
+
withdraw: CandlePerpsWithdraw;
|
|
2027
|
+
}
|
|
2028
|
+
export interface PerpsWithdrawParams extends Omit<PerpsWalletRef, "submit"> {
|
|
2029
|
+
amountUsdc: string;
|
|
2030
|
+
to: "solana" | "hood";
|
|
2031
|
+
/** Reuse on retry. A new id is generated when omitted. */
|
|
2032
|
+
clientWithdrawalId?: string;
|
|
2033
|
+
/** This key's EVM TEE wallet address: the HyperCore account the USDC leaves. */
|
|
2034
|
+
account: string;
|
|
2035
|
+
/**
|
|
2036
|
+
* This key's own wallet addresses on the chain asked for: its Solana TEE wallet for `solana`,
|
|
2037
|
+
* the EVM TEE wallet itself for `hood`. A build landing anywhere else is refused.
|
|
2038
|
+
*/
|
|
2039
|
+
ownDestinations: string[];
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* The outcome of `perpsWithdraw()`. `signature` is the SendAsset's, valid for resubmission until
|
|
2043
|
+
* its nonce leaves Hyperliquid's two-day window; a failed submit keeps it.
|
|
2044
|
+
*/
|
|
2045
|
+
export interface PerpsWithdrawResult {
|
|
2046
|
+
build: PerpsWithdrawBuild;
|
|
2047
|
+
authorization: PerpsWithdrawAuthorization;
|
|
2048
|
+
signature: string;
|
|
2049
|
+
submitted: boolean;
|
|
2050
|
+
exchange: unknown | null;
|
|
2051
|
+
submitError?: string;
|
|
1866
2052
|
}
|
|
1867
2053
|
export interface PerpsAccountStatus {
|
|
1868
2054
|
walletId: string;
|
|
@@ -1879,6 +2065,7 @@ export interface PerpsAccountStatus {
|
|
|
1879
2065
|
export type PerpsSetupResult = PerpsAccountStatus & {
|
|
1880
2066
|
ready: boolean;
|
|
1881
2067
|
action?: PerpsActionResult;
|
|
2068
|
+
preview?: Record<string, unknown>;
|
|
1882
2069
|
};
|
|
1883
2070
|
export interface PerpsConfig {
|
|
1884
2071
|
success: true;
|
|
@@ -1900,7 +2087,34 @@ export interface PerpsPositions {
|
|
|
1900
2087
|
account: Record<string, string>;
|
|
1901
2088
|
withdrawable: string;
|
|
1902
2089
|
positions: Record<string, unknown>[];
|
|
2090
|
+
/**
|
|
2091
|
+
* BE-1582 (spec A-3): the section 4 table, account line and risk report, from a direct read of
|
|
2092
|
+
* Hyperliquid on this machine (the fields above are Candle's server read, unchanged). `rows` is
|
|
2093
|
+
* empty and `accountLine` null when that read failed or no level could be computed, and `risk`
|
|
2094
|
+
* then says why (`level: "unknown"`).
|
|
2095
|
+
*/
|
|
2096
|
+
rows: PerpsPositionRow[];
|
|
2097
|
+
accountLine: PerpsAccountLine | null;
|
|
2098
|
+
risk: Omit<PerpsRiskReport, "positions">;
|
|
2099
|
+
}
|
|
2100
|
+
/** `GET /keys/self/limits`'s risk thresholds for the calling key (BE-1582, spec A-4). */
|
|
2101
|
+
export interface PerpsRiskSettingsResult {
|
|
2102
|
+
/** What the key stores, or null. */
|
|
2103
|
+
perpsRisk: PerpsRiskSettings | null;
|
|
2104
|
+
/** What the engine applies, and where it came from (`defaults (server did not report)` on an older API). */
|
|
2105
|
+
effective: PerpsRiskThresholdsReport;
|
|
1903
2106
|
}
|
|
2107
|
+
/** `PUT /keys/self/perps-risk` or `/keys/:prefix/perps-risk`. */
|
|
2108
|
+
export interface PerpsRiskWriteResult {
|
|
2109
|
+
success: true;
|
|
2110
|
+
keyPrefix: string;
|
|
2111
|
+
perpsRisk: PerpsRiskSettings | null;
|
|
2112
|
+
effective: PerpsRiskThresholds;
|
|
2113
|
+
}
|
|
2114
|
+
/** A threshold write: each named field set (`null` clears that field), or `null` to clear them all. */
|
|
2115
|
+
export type PerpsRiskWrite = {
|
|
2116
|
+
[K in keyof PerpsRiskThresholds]?: number | null;
|
|
2117
|
+
} | null;
|
|
1904
2118
|
export interface PerpsOrderRecord {
|
|
1905
2119
|
perpOrderId: string;
|
|
1906
2120
|
kind: PerpsBuild["kind"];
|
|
@@ -1908,6 +2122,8 @@ export interface PerpsOrderRecord {
|
|
|
1908
2122
|
coin: string | null;
|
|
1909
2123
|
nonce: number;
|
|
1910
2124
|
cloid: string | null;
|
|
2125
|
+
/** The caller's client order id, on rows built with one (absent from an older API). */
|
|
2126
|
+
clientId?: string | null;
|
|
1911
2127
|
childCloids: string[];
|
|
1912
2128
|
targetCloid: string | null;
|
|
1913
2129
|
status: string;
|
|
@@ -1939,7 +2155,7 @@ export interface PerpsOrders {
|
|
|
1939
2155
|
* Perps C (BE-647, HL-ED-8): `perpsDeposit()`. Relay moves funds from the key's Hood or Solana TEE
|
|
1940
2156
|
* wallet onto Hyperliquid perps USDC at the key's EVM TEE wallet's own address. The asset decides
|
|
1941
2157
|
* the paying chain: SOL or USDC from the Solana TEE wallet, ETH or USDG from the Hood one. Needs
|
|
1942
|
-
* `swap:write
|
|
2158
|
+
* `swap:write`; any cap on the asset still applies. There is no withdrawal yet.
|
|
1943
2159
|
*/
|
|
1944
2160
|
export interface PerpsDepositParams {
|
|
1945
2161
|
/** Idempotency id, 1 to 128 of `A-Za-z0-9._:-`. Rebuilding under the same id answers its job. */
|
|
@@ -1957,15 +2173,25 @@ export interface PerpsDepositParams {
|
|
|
1957
2173
|
perpsWalletId?: string;
|
|
1958
2174
|
/** Relay slippage, 1 to 1000 bps (default 100). */
|
|
1959
2175
|
maxSlippageBps?: number;
|
|
1960
|
-
/**
|
|
2176
|
+
/**
|
|
2177
|
+
* Sign and submit (default), or `false` for a dry run: the API previews the deposit (`preview:
|
|
2178
|
+
* true`), locking no wallet, reserving no USD window and recording no id, and nothing is signed.
|
|
2179
|
+
*/
|
|
1961
2180
|
submit?: boolean;
|
|
1962
2181
|
}
|
|
1963
|
-
/**
|
|
2182
|
+
/**
|
|
2183
|
+
* What `POST /agent/perps/deposit` builds. A Hood build also carries the first sequenced leg. A
|
|
2184
|
+
* preview (`status: "preview"`, from `submit: false`) has no `depositId`, `expiresAt` or sequenced
|
|
2185
|
+
* leg; from Hood it carries `plannedLegs` instead.
|
|
2186
|
+
*/
|
|
1964
2187
|
export interface PerpsDepositBuild {
|
|
1965
2188
|
success: true;
|
|
1966
|
-
status: "built";
|
|
2189
|
+
status: "built" | "preview";
|
|
2190
|
+
/** A dry run: nothing is held, and the same id still builds a new deposit. */
|
|
2191
|
+
preview?: true;
|
|
1967
2192
|
clientDepositId: string;
|
|
1968
|
-
|
|
2193
|
+
/** Absent on a preview. */
|
|
2194
|
+
depositId?: string;
|
|
1969
2195
|
chain: "solana" | "hood";
|
|
1970
2196
|
venue: "relay";
|
|
1971
2197
|
network: HyperliquidNetwork;
|
|
@@ -1991,9 +2217,17 @@ export interface PerpsDepositBuild {
|
|
|
1991
2217
|
};
|
|
1992
2218
|
statusChecks: string[];
|
|
1993
2219
|
requestId: string | null;
|
|
1994
|
-
|
|
2220
|
+
/** Absent on a preview. */
|
|
2221
|
+
expiresAt?: number;
|
|
1995
2222
|
/** Solana: the one unsigned deposit. */
|
|
1996
2223
|
transactionsBase64?: string[];
|
|
2224
|
+
/** A Hood preview: the legs' calldata, nothing sequenced. */
|
|
2225
|
+
plannedLegs?: Array<{
|
|
2226
|
+
kind: string;
|
|
2227
|
+
to: string;
|
|
2228
|
+
data: string;
|
|
2229
|
+
value: string;
|
|
2230
|
+
}>;
|
|
1997
2231
|
/** Hood: the sequenced leg protocol's first body. */
|
|
1998
2232
|
mode?: "sequenced";
|
|
1999
2233
|
operationId?: string;
|
|
@@ -2016,7 +2250,6 @@ export interface PerpsDepositResult {
|
|
|
2016
2250
|
/** `/perps/deposit/submit`'s final answer: `status: "submitted"` and the chain hashes. */
|
|
2017
2251
|
result: Record<string, unknown> | null;
|
|
2018
2252
|
}
|
|
2019
|
-
/** Why a deposit build must not be signed, or null. */
|
|
2020
2253
|
export declare function perpsDepositProblem(build: PerpsDepositBuild, params: PerpsDepositParams): string | null;
|
|
2021
2254
|
/**
|
|
2022
2255
|
* The base assets `swap()` converts between. Inlined rather than imported from `@candle/shared`'s
|
|
@@ -2256,11 +2489,18 @@ export interface SkippedEmptyTokenAccount extends EmptyTokenAccount {
|
|
|
2256
2489
|
export interface PreviewCloseEmptyAccountsRequest {
|
|
2257
2490
|
/** Mints whose empty accounts stay open, e.g. the pair token a held holder-reward coin pays in. */
|
|
2258
2491
|
keep?: string[];
|
|
2492
|
+
/**
|
|
2493
|
+
* A Solana TEE wallet's linked-wallet id, to preview that wallet instead of the embedded one
|
|
2494
|
+
* (BE-1687). Any key bound to the wallet may preview it.
|
|
2495
|
+
*/
|
|
2496
|
+
wallet?: string;
|
|
2259
2497
|
}
|
|
2260
2498
|
/** previewCloseEmptyAccounts()'s result. Nothing was built, signed or written to produce it. */
|
|
2261
2499
|
export interface CloseEmptyAccountsPreview {
|
|
2262
2500
|
success: true;
|
|
2263
2501
|
wallet: string;
|
|
2502
|
+
/** The TEE wallet's linked-wallet id, on a TEE wallet's preview. */
|
|
2503
|
+
linkedWalletId?: string;
|
|
2264
2504
|
keep: string[];
|
|
2265
2505
|
accounts: EmptyTokenAccount[];
|
|
2266
2506
|
accountCount: number;
|
|
@@ -2284,9 +2524,18 @@ export interface CloseEmptyAccountsRequest {
|
|
|
2284
2524
|
keep?: string[];
|
|
2285
2525
|
/** The preview's `accounts[].account`, to close only what was shown. Omit to close every qualifying account. */
|
|
2286
2526
|
accounts?: string[];
|
|
2527
|
+
/**
|
|
2528
|
+
* A Solana TEE wallet's linked-wallet id, to close that wallet's accounts instead of the embedded
|
|
2529
|
+
* wallet's (BE-1687). Needs `swap:write`, `privyWalletId`, and the wallet's signer in `secretStore`.
|
|
2530
|
+
*/
|
|
2531
|
+
wallet?: string;
|
|
2532
|
+
/** The TEE wallet's Privy wallet id, which signLinkedTransaction() signs for. Required with `wallet`. */
|
|
2533
|
+
privyWalletId?: string;
|
|
2287
2534
|
}
|
|
2288
2535
|
/** A close transaction that landed. */
|
|
2289
2536
|
export interface CloseEmptyAccountsBatch {
|
|
2537
|
+
/** The transaction's place in a TEE wallet's built batch. */
|
|
2538
|
+
index?: number;
|
|
2290
2539
|
signature: string;
|
|
2291
2540
|
accounts: string[];
|
|
2292
2541
|
lamports: string;
|
|
@@ -2297,18 +2546,37 @@ export interface CloseEmptyAccountsBatch {
|
|
|
2297
2546
|
* re-preview before re-running.
|
|
2298
2547
|
*/
|
|
2299
2548
|
export interface CloseEmptyAccountsFailure {
|
|
2549
|
+
/** The transaction's place in a TEE wallet's built batch. */
|
|
2550
|
+
index?: number;
|
|
2300
2551
|
accounts: string[];
|
|
2301
2552
|
code: string;
|
|
2302
2553
|
message: string;
|
|
2303
2554
|
signature?: string;
|
|
2304
2555
|
}
|
|
2556
|
+
/**
|
|
2557
|
+
* A TEE wallet's close transaction the chain has not settled yet (BE-1687). Its rent is not counted,
|
|
2558
|
+
* and the operation stays `recovering` until every one is settled.
|
|
2559
|
+
*/
|
|
2560
|
+
export interface CloseEmptyAccountsUnresolved {
|
|
2561
|
+
index: number;
|
|
2562
|
+
accounts: string[];
|
|
2563
|
+
/** Known once the transaction was signed and recorded. */
|
|
2564
|
+
signature?: string;
|
|
2565
|
+
reason: string;
|
|
2566
|
+
}
|
|
2305
2567
|
/** closeEmptyAccounts()'s result. A run in which nothing landed throws a CandleApiError instead. */
|
|
2306
2568
|
export interface CloseEmptyAccountsResult {
|
|
2307
2569
|
success: true;
|
|
2308
|
-
/**
|
|
2309
|
-
|
|
2570
|
+
/**
|
|
2571
|
+
* `partial`: some batch failed, or more accounts remain than one call closes. `recovering`, a TEE
|
|
2572
|
+
* wallet's close only: a transaction may still land. Nothing is sent again; read
|
|
2573
|
+
* getCloseEmptyAccountsJob(clientTradeId, { wallet }) until it settles.
|
|
2574
|
+
*/
|
|
2575
|
+
status: "completed" | "partial" | "nothing_to_close" | "recovering";
|
|
2310
2576
|
clientTradeId: string;
|
|
2311
2577
|
wallet: string;
|
|
2578
|
+
/** The TEE wallet's linked-wallet id, on a TEE wallet's close. */
|
|
2579
|
+
linkedWalletId?: string;
|
|
2312
2580
|
keep: string[];
|
|
2313
2581
|
closed: EmptyTokenAccount[];
|
|
2314
2582
|
transactions: CloseEmptyAccountsBatch[];
|
|
@@ -2317,8 +2585,11 @@ export interface CloseEmptyAccountsResult {
|
|
|
2317
2585
|
solRecovered: string;
|
|
2318
2586
|
/** The base network fee of the transactions that landed, reverted ones included, 5,000 lamports each. */
|
|
2319
2587
|
feeLamports: string;
|
|
2320
|
-
|
|
2321
|
-
|
|
2588
|
+
/** Absent while `status` is `recovering`: no net is final until every transaction settles. */
|
|
2589
|
+
netLamports?: string;
|
|
2590
|
+
netSol?: string;
|
|
2591
|
+
/** A TEE close that landed before its fee could be read: `feeLamports` does not count it yet. */
|
|
2592
|
+
feeUnresolved?: true;
|
|
2322
2593
|
failed: CloseEmptyAccountsFailure[];
|
|
2323
2594
|
/** Accounts in batches never sent, after a failure that stops the run. */
|
|
2324
2595
|
unattempted: string[];
|
|
@@ -2331,15 +2602,35 @@ export interface CloseEmptyAccountsResult {
|
|
|
2331
2602
|
remaining: number;
|
|
2332
2603
|
/** Present when this is the stored report of an earlier call under the same id. */
|
|
2333
2604
|
replayed?: true;
|
|
2605
|
+
/** `recovering` only: what the server says to do next. */
|
|
2606
|
+
message?: string;
|
|
2607
|
+
/** `recovering` only: the TEE close transactions not settled yet. */
|
|
2608
|
+
unresolved?: CloseEmptyAccountsUnresolved[];
|
|
2609
|
+
}
|
|
2610
|
+
/** Which wallet getCloseEmptyAccountsJob() reads: the embedded wallet's runs, or a TEE wallet's. */
|
|
2611
|
+
export interface CloseEmptyAccountsJobOptions {
|
|
2612
|
+
/** A Solana TEE wallet's linked-wallet id (BE-1687). Omit for the embedded wallet. */
|
|
2613
|
+
wallet?: string;
|
|
2334
2614
|
}
|
|
2335
2615
|
export interface CloseEmptyAccountsJob {
|
|
2336
2616
|
clientTradeId: string;
|
|
2337
2617
|
kind: "close-empty";
|
|
2338
|
-
|
|
2618
|
+
/** `built`, a TEE wallet's only: the transactions await their signatures, or are being sent or recovered. */
|
|
2619
|
+
status: "running" | "built" | "completed" | "failed";
|
|
2620
|
+
/** On a TEE wallet's job. */
|
|
2621
|
+
walletKind?: "tee";
|
|
2622
|
+
linkedWalletId?: string;
|
|
2623
|
+
/** A TEE wallet's send state: `idle` before submit, then `submitting`, `recovering` or `done`. */
|
|
2624
|
+
submitState?: "idle" | "submitting" | "recovering" | "done";
|
|
2625
|
+
/** On a TEE wallet's job: whether this read reconciled the row against the chain. */
|
|
2626
|
+
reconciled?: boolean;
|
|
2339
2627
|
createdAt: number;
|
|
2340
2628
|
finishedAt?: number;
|
|
2341
2629
|
httpStatus?: number;
|
|
2342
|
-
/**
|
|
2630
|
+
/**
|
|
2631
|
+
* The report the close call returned, once it finished. On a TEE wallet's job, the build while
|
|
2632
|
+
* its signatures are awaited, the report (`recovering` until the chain settles), or the stored error.
|
|
2633
|
+
*/
|
|
2343
2634
|
result?: CloseEmptyAccountsResult | Record<string, unknown>;
|
|
2344
2635
|
}
|
|
2345
2636
|
/** trade()'s one-call request: mirrors BuildTradeRequest minus clientTradeId/payer, plus who signs. */
|
|
@@ -2537,7 +2828,14 @@ export declare class CandleClient {
|
|
|
2537
2828
|
private readonly solanaRpcUrl?;
|
|
2538
2829
|
private readonly evmRpcUrl?;
|
|
2539
2830
|
private readonly hyperliquidNetwork;
|
|
2831
|
+
private perpsMarketReader?;
|
|
2540
2832
|
private hyperliquidBuilder?;
|
|
2833
|
+
private readonly perpsWithdrawPins;
|
|
2834
|
+
/**
|
|
2835
|
+
* Hyperliquid withdrawals (spec 2026-10-17-hyperliquid-withdrawals-design.md): the routes, one call
|
|
2836
|
+
* each. Needs `perps:withdraw` on the key. `perpsWithdraw()` is the checked flow.
|
|
2837
|
+
*/
|
|
2838
|
+
readonly perps: CandlePerps;
|
|
2541
2839
|
/** Reads scoped to what this key may spend: a one-shot swap's receipt, and spendable balances. */
|
|
2542
2840
|
readonly wallets: CandleWallets;
|
|
2543
2841
|
/** The creator fees this account's launched tokens can pay, and the claim (FE-438). */
|
|
@@ -2791,6 +3089,10 @@ export declare class CandleClient {
|
|
|
2791
3089
|
* Lists the embedded Solana wallet's empty token accounts that a close would reclaim, on both
|
|
2792
3090
|
* token programs, and the SOL their rent returns (BE-418). Read-only: nothing is built, signed or
|
|
2793
3091
|
* written, and any key scope may call it.
|
|
3092
|
+
*
|
|
3093
|
+
* With `wallet` (a Solana TEE wallet's linked-wallet id, BE-1687), the same preview for that TEE
|
|
3094
|
+
* wallet, by any key bound to it. Off on a deployment until it is enabled
|
|
3095
|
+
* (`AGENT_TEE_CLOSE_EMPTY_ENABLED`): until then it throws LAUNCH_DISABLED.
|
|
2794
3096
|
*/
|
|
2795
3097
|
previewCloseEmptyAccounts(req?: PreviewCloseEmptyAccountsRequest): Promise<CloseEmptyAccountsPreview>;
|
|
2796
3098
|
/**
|
|
@@ -2803,10 +3105,27 @@ export declare class CandleClient {
|
|
|
2803
3105
|
* returns its stored report (`replayed: true`), a repeat while it runs throws CLOSE_IN_PROGRESS,
|
|
2804
3106
|
* and the same id with a different request throws IDEMPOTENCY_CONFLICT. So a retry under the
|
|
2805
3107
|
* same id is safe, and this method still never retries on its own.
|
|
3108
|
+
*
|
|
3109
|
+
* With `wallet` (a Solana TEE wallet's linked-wallet id bound to this key, BE-1687), the TEE
|
|
3110
|
+
* wallet's close instead. Needs `swap:write`, `privyWalletId`, and that wallet's signer in
|
|
3111
|
+
* `secretStore`. Three steps: `POST /agent/wallets/:id/close-empty/build` (the server builds
|
|
3112
|
+
* the close transactions, every one CloseAccount with the TEE wallet as fee payer, rent
|
|
3113
|
+
* destination and owner, and stamps them for the relay), `signLinkedTransaction()` per
|
|
3114
|
+
* transaction, then `POST .../close-empty/submit` with the whole signed batch, which the server
|
|
3115
|
+
* checks against the build before it sends anything. A build with nothing to close returns
|
|
3116
|
+
* `nothing_to_close` without signing. A `recovering` result means a transaction may still land:
|
|
3117
|
+
* nothing is sent again, and getCloseEmptyAccountsJob(clientTradeId, { wallet }) reads it until
|
|
3118
|
+
* it settles. A TEE wallet's build is signable once: after a lost answer, read the job rather
|
|
3119
|
+
* than calling this again. Off on a deployment until it is enabled
|
|
3120
|
+
* (`AGENT_TEE_CLOSE_EMPTY_ENABLED`): until then it throws LAUNCH_DISABLED.
|
|
2806
3121
|
*/
|
|
2807
3122
|
closeEmptyAccounts(req: CloseEmptyAccountsRequest): Promise<CloseEmptyAccountsResult>;
|
|
2808
|
-
/**
|
|
2809
|
-
|
|
3123
|
+
/**
|
|
3124
|
+
* Reads a closeEmptyAccounts() run by its clientTradeId, without sending anything (BE-418). With
|
|
3125
|
+
* `wallet`, a TEE wallet's run (BE-1687, `swap:write`): that read also reconciles the run against
|
|
3126
|
+
* the chain, so a `recovering` close settles by reading it again. It never signs or sends.
|
|
3127
|
+
*/
|
|
3128
|
+
getCloseEmptyAccountsJob(clientTradeId: string, opts?: CloseEmptyAccountsJobOptions): Promise<CloseEmptyAccountsJob>;
|
|
2810
3129
|
/**
|
|
2811
3130
|
* Imports an existing wallet via Candle's ciphertext-only flow (PR3): calls
|
|
2812
3131
|
* `/agent/wallets/import/init` for Privy's HPKE receiver public key, encrypts `privateKey`
|
|
@@ -3246,6 +3565,14 @@ export declare class CandleClient {
|
|
|
3246
3565
|
*/
|
|
3247
3566
|
private signBroadcastAndWaitEvmLeg;
|
|
3248
3567
|
private broadcastAndWaitEvmLeg;
|
|
3568
|
+
/** Public Hyperliquid reads on this machine. A Candle key of any scope is required.
|
|
3569
|
+
* The only Candle call is perpsConfig(), once per client; market data is cached for 5 seconds.
|
|
3570
|
+
*/
|
|
3571
|
+
private marketReader;
|
|
3572
|
+
perpsMarkets(opts?: PerpsMarketsOptions): Promise<PerpsMarketsResult>;
|
|
3573
|
+
perpsMarket(coin: string): Promise<PerpsMarketResult>;
|
|
3574
|
+
perpsBook(coin: string, opts?: PerpsBookOptions): Promise<PerpsBookResult>;
|
|
3575
|
+
perpsCandles(coin: string, opts?: PerpsCandlesOptions): Promise<PerpsCandlesResult>;
|
|
3249
3576
|
/** The server's perps settings: network, Candle's builder, this key's fee, and its limits. */
|
|
3250
3577
|
perpsConfig(): Promise<PerpsConfig>;
|
|
3251
3578
|
/**
|
|
@@ -3253,24 +3580,56 @@ export declare class CandleClient {
|
|
|
3253
3580
|
* it, and reports the account's mode and balance. Idempotent.
|
|
3254
3581
|
*/
|
|
3255
3582
|
perpsSetup(params: PerpsWalletRef): Promise<PerpsSetupResult>;
|
|
3256
|
-
/**
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3583
|
+
/**
|
|
3584
|
+
* Open (or add to) a position: build, check, sign through the relay, submit to Hyperliquid. With
|
|
3585
|
+
* `clientId`, a retry of the same request returns the original operation (`replayed: true`).
|
|
3586
|
+
*/
|
|
3587
|
+
perpsOpen(params: PerpsOpenParams & {
|
|
3588
|
+
clientId?: undefined;
|
|
3589
|
+
}): Promise<PerpsActionResult>;
|
|
3590
|
+
perpsOpen(params: PerpsOpenParams): Promise<PerpsActionResult | PerpsReplayResult>;
|
|
3591
|
+
/** Close all or part of a position with a reduce-only IOC order. Reserves nothing. Takes `clientId` as open does. */
|
|
3592
|
+
perpsClose(params: PerpsCloseParams & {
|
|
3593
|
+
clientId?: undefined;
|
|
3594
|
+
}): Promise<PerpsActionResult>;
|
|
3595
|
+
perpsClose(params: PerpsCloseParams): Promise<PerpsActionResult | PerpsReplayResult>;
|
|
3260
3596
|
/** Cancel an order Candle built, by its cloid. */
|
|
3261
3597
|
perpsCancel(params: PerpsCancelParams): Promise<PerpsActionResult>;
|
|
3262
3598
|
/** Change a resting order's price or size. The replacement gets a new cloid. */
|
|
3263
3599
|
perpsModify(params: PerpsModifyParams): Promise<PerpsActionResult>;
|
|
3264
|
-
/**
|
|
3600
|
+
/**
|
|
3601
|
+
* Set a market's leverage and margin mode on the account, within the key's maxLeverage. With
|
|
3602
|
+
* `mode` and no `leverage`, the current leverage is kept (spec D, section 5); a mode change needs
|
|
3603
|
+
* no position and no resting order in the coin. The answer reports the mode asked for and the one
|
|
3604
|
+
* Hyperliquid shows after the submit, separately.
|
|
3605
|
+
*/
|
|
3265
3606
|
perpsLeverage(params: PerpsLeverageParams): Promise<PerpsActionResult>;
|
|
3266
3607
|
/** Add (positive) or remove (negative) isolated margin on an isolated position. */
|
|
3267
3608
|
perpsMargin(params: PerpsMarginParams): Promise<PerpsActionResult>;
|
|
3268
|
-
/**
|
|
3609
|
+
/**
|
|
3610
|
+
* Positions and account value, read live from Hyperliquid by the wallet's address. The server's
|
|
3611
|
+
* fields are unchanged; `rows`, `accountLine` and `risk` (BE-1582, spec A-3) come from a direct
|
|
3612
|
+
* read on this machine at the key's thresholds.
|
|
3613
|
+
*/
|
|
3269
3614
|
perpsPositions(walletId: string): Promise<PerpsPositions>;
|
|
3270
3615
|
/** Open orders on Hyperliquid, and Candle's record of every action it built, settled first. */
|
|
3271
3616
|
perpsOrders(walletId: string, opts?: {
|
|
3272
3617
|
limit?: number;
|
|
3273
3618
|
}): Promise<PerpsOrders>;
|
|
3619
|
+
/**
|
|
3620
|
+
* One page of the wallet's fills, read directly from Hyperliquid's `/info` (spec 2026-10-17 C,
|
|
3621
|
+
* sections 3 and 4). Candle resolves only the wallet's address; no Candle credential reaches
|
|
3622
|
+
* Hyperliquid, and a read-capable key is enough. Default window: the last seven days, fixed on the
|
|
3623
|
+
* first page; pass `nextCursor` back as `cursor` for the next one. Live venue data for this wallet,
|
|
3624
|
+
* not Candle's ledger and not an all-time total: Hyperliquid serves only the 10,000 most recent
|
|
3625
|
+
* fills. `closedPnl` is gross and `fee` already includes `builderFee`. Throws `PerpsHistoryError`.
|
|
3626
|
+
*/
|
|
3627
|
+
perpsFillsPage(walletId: string, options?: PerpsHistoryOptions): Promise<PerpsFillsPage>;
|
|
3628
|
+
/** One page of the wallet's funding payments, as `perpsFillsPage()` reads fills. `delta.usdc` is signed: negative was paid. */
|
|
3629
|
+
perpsFundingPage(walletId: string, options?: PerpsHistoryOptions): Promise<PerpsFundingPage>;
|
|
3630
|
+
private perpsHistoryPage;
|
|
3631
|
+
/** The address of an EVM TEE wallet bound to this key, from Candle's own list of the key's wallets. */
|
|
3632
|
+
private perpsWalletAddress;
|
|
3274
3633
|
/** Fills, read live from Hyperliquid by the wallet's address. */
|
|
3275
3634
|
perpsFills(walletId: string): Promise<{
|
|
3276
3635
|
success: true;
|
|
@@ -3282,6 +3641,70 @@ export declare class CandleClient {
|
|
|
3282
3641
|
startTime: number;
|
|
3283
3642
|
funding: Record<string, unknown>[];
|
|
3284
3643
|
}>;
|
|
3644
|
+
/** The key's risk thresholds: stored and effective. An older API reports none: the defaults, sourced so. */
|
|
3645
|
+
getPerpsRisk(): Promise<PerpsRiskSettingsResult>;
|
|
3646
|
+
/**
|
|
3647
|
+
* Tighten the calling key's own thresholds (`PUT /keys/self/perps-risk`). Anything looser than
|
|
3648
|
+
* the effective set, including clearing a field stored stricter than its default, is refused with
|
|
3649
|
+
* 403 LOOSEN_REQUIRES_SESSION: the owner loosens with `setKeyPerpsRisk()`.
|
|
3650
|
+
*/
|
|
3651
|
+
setPerpsRisk(fields: PerpsRiskWrite): Promise<PerpsRiskWriteResult>;
|
|
3652
|
+
/**
|
|
3653
|
+
* The owner's write on any of the account's keys (`PUT /keys/:prefix/perps-risk`): may loosen or
|
|
3654
|
+
* clear. Needs an owner credential, the CLI's device token or a Privy session token, sent as a
|
|
3655
|
+
* bearer token; the client's API key is not sent and would be refused.
|
|
3656
|
+
*/
|
|
3657
|
+
setKeyPerpsRisk(keyPrefix: string, fields: PerpsRiskWrite, owner: {
|
|
3658
|
+
bearerToken: string;
|
|
3659
|
+
}): Promise<PerpsRiskWriteResult>;
|
|
3660
|
+
/**
|
|
3661
|
+
* One-shot risk (spec A-8): `ok`, `warn` or `critical` with its drivers, from a direct read of
|
|
3662
|
+
* Hyperliquid at the key's thresholds. `unknown` for a non-standard account mode or a stale read.
|
|
3663
|
+
* A failed venue read throws `HyperliquidReadError` (`code: "PERPS_READ_FAILED"`). Stateless: no
|
|
3664
|
+
* hysteresis (that is `watchPerpsRisk()`).
|
|
3665
|
+
*/
|
|
3666
|
+
perpsRisk(params: {
|
|
3667
|
+
walletId: string;
|
|
3668
|
+
address?: string;
|
|
3669
|
+
}): Promise<PerpsRiskReport>;
|
|
3670
|
+
/**
|
|
3671
|
+
* The account line (spec A-10): account value, margin, free margin, withdrawable, the margin
|
|
3672
|
+
* ratio, and realized P&L, fees and funding over a recent window (`since`, epoch ms; default the
|
|
3673
|
+
* last 24 hours, at most 30 days).
|
|
3674
|
+
*/
|
|
3675
|
+
perpsAccount(params: {
|
|
3676
|
+
walletId: string;
|
|
3677
|
+
address?: string;
|
|
3678
|
+
since?: number;
|
|
3679
|
+
}): Promise<PerpsAccountReport>;
|
|
3680
|
+
/**
|
|
3681
|
+
* The loop `candle perps watch` runs (spec A-9): polls Hyperliquid every `intervalMs` (default
|
|
3682
|
+
* 10 s), calls `onEvent` with a start event, one event per level change (rising immediately,
|
|
3683
|
+
* falling past the clear band), heartbeats and errors, and resolves with the last level when
|
|
3684
|
+
* `signal` aborts. Candle is asked for thresholds at start and every 5 minutes only.
|
|
3685
|
+
*/
|
|
3686
|
+
watchPerpsRisk(params: {
|
|
3687
|
+
walletId: string;
|
|
3688
|
+
address?: string;
|
|
3689
|
+
intervalMs?: number;
|
|
3690
|
+
heartbeatMs?: number;
|
|
3691
|
+
signal?: AbortSignal;
|
|
3692
|
+
onceLevelChange?: boolean;
|
|
3693
|
+
onEvent: (event: PerpsWatchEvent) => void | Promise<void>;
|
|
3694
|
+
}): Promise<{
|
|
3695
|
+
level: PerpsRiskReport["level"];
|
|
3696
|
+
}>;
|
|
3697
|
+
/**
|
|
3698
|
+
* The portfolio's Hyperliquid section (spec A-11) for EVM TEE addresses: account value, unrealized
|
|
3699
|
+
* P&L, positions and level at the default thresholds per account, and a subtotal. Live from
|
|
3700
|
+
* Hyperliquid and never part of any portfolio total.
|
|
3701
|
+
*/
|
|
3702
|
+
perpsPortfolioSection(wallets: readonly {
|
|
3703
|
+
address: string;
|
|
3704
|
+
label?: string;
|
|
3705
|
+
walletId?: string;
|
|
3706
|
+
}[]): Promise<PerpsPortfolioSection>;
|
|
3707
|
+
private perpsThresholdsOrDefaults;
|
|
3285
3708
|
/**
|
|
3286
3709
|
* Deposit onto the key's Hyperliquid account through Relay (Perps C, HL-ED-8): build, check the
|
|
3287
3710
|
* build names `account` on chain 1337 with no Candle fee, then sign through the relay and submit.
|
|
@@ -3298,11 +3721,66 @@ export declare class CandleClient {
|
|
|
3298
3721
|
}>;
|
|
3299
3722
|
/** The builder every perps build is checked against (see `hyperliquidBuilder` in the options). */
|
|
3300
3723
|
private perpsBuilder;
|
|
3724
|
+
private perpsBuilderTrust;
|
|
3301
3725
|
/**
|
|
3302
3726
|
* Check, sign, submit (HL-ED-2, HL-ED-5). The check runs before the relay is called; a build
|
|
3303
|
-
* that fails it is refused with nothing signed.
|
|
3727
|
+
* that fails it is refused with nothing signed. BE-1584: every method is checked against this
|
|
3728
|
+
* machine's own read of Hyperliquid (`verifyPerpsBuildAgainstVenue`), and the venue's answer is
|
|
3729
|
+
* judged per leg (`outcome`).
|
|
3304
3730
|
*/
|
|
3305
3731
|
private perpsComplete;
|
|
3732
|
+
/**
|
|
3733
|
+
* Schedule Hyperliquid's cancel-all timer `seconds` from now (at least 5), or clear it. The timer
|
|
3734
|
+
* is wallet-wide: it cancels every open order on the account, protection included, and no
|
|
3735
|
+
* positions. Candle fixes the time at build and this client refuses to sign one less than five
|
|
3736
|
+
* seconds ahead. An acknowledged set is recorded on Candle (`acknowledged`); no public read can
|
|
3737
|
+
* confirm the timer, and Hyperliquid's 10 triggers per UTC day are never counted here.
|
|
3738
|
+
*/
|
|
3739
|
+
perpsScheduleCancel(params: PerpsScheduleCancelParams): Promise<PerpsActionResult>;
|
|
3740
|
+
/**
|
|
3741
|
+
* Attach, change or remove the position's take-profit and stop-loss (spec D, section 6): each leg
|
|
3742
|
+
* a reducing market trigger sized to the position now. A change cancels the old leg first (a
|
|
3743
|
+
* protection gap, named in `warnings`), confirms it gone, re-reads, then places the new one; a
|
|
3744
|
+
* partial result is reported as `complete: false`. Legs Candle did not build are listed in
|
|
3745
|
+
* `unowned` and never touched. Calling this is the caller's intent; there is no prompt.
|
|
3746
|
+
*/
|
|
3747
|
+
perpsTpsl(params: PerpsWalletRef & PerpsTpslParams): Promise<PerpsWorkflowResult>;
|
|
3748
|
+
/**
|
|
3749
|
+
* Cancel every open main-perp order on the wallet, then close every main-perp position (spec D,
|
|
3750
|
+
* section 8). At most 100 signed steps per call; `complete` only when a final read shows nothing
|
|
3751
|
+
* left. Spot, HIP-3 and vault exposure is out of scope (`scope: "main-perps"`).
|
|
3752
|
+
*/
|
|
3753
|
+
perpsFlatten(params: PerpsWalletRef): Promise<PerpsWorkflowResult>;
|
|
3754
|
+
private perpsWorkflowIo;
|
|
3755
|
+
/** The calling key's perps reduce-only setting (`GET /keys/self/perps-reduce-only`). Throws on a failed read. */
|
|
3756
|
+
getPerpsReduceOnly(): Promise<PerpsReduceOnlyResult>;
|
|
3757
|
+
/**
|
|
3758
|
+
* Turn the calling key's perps reduce-only on (`PUT /keys/self/perps-reduce-only`). The key can
|
|
3759
|
+
* never turn it off (403 LOOSEN_REQUIRES_SESSION): the owner does that with `setKeyPerpsReduceOnly()`.
|
|
3760
|
+
* It constrains future Candle builds only: resting orders stay, signed actions stay valid.
|
|
3761
|
+
*/
|
|
3762
|
+
setPerpsReduceOnly(perpsReduceOnly: true): Promise<PerpsReduceOnlyResult>;
|
|
3763
|
+
/**
|
|
3764
|
+
* The owner's write on any of the account's keys (`PUT /keys/:prefix/perps-reduce-only`): on or
|
|
3765
|
+
* off. Needs an owner credential (the CLI's device token or a Privy session token), sent as a
|
|
3766
|
+
* bearer token; the client's API key is not sent and would be refused.
|
|
3767
|
+
*/
|
|
3768
|
+
setKeyPerpsReduceOnly(keyPrefix: string, perpsReduceOnly: boolean, owner: {
|
|
3769
|
+
bearerToken: string;
|
|
3770
|
+
}): Promise<PerpsReduceOnlyResult>;
|
|
3771
|
+
/**
|
|
3772
|
+
* Withdraw USDC from the key's Hyperliquid account to the same key's own Solana or Hood TEE wallet
|
|
3773
|
+
* through Relay (spec 2026-10-17, route A). MOVES REAL FUNDS. Needs `perps:withdraw`.
|
|
3774
|
+
*
|
|
3775
|
+
* Every signature is checked first, and a mismatch throws with nothing signed: the NonceMapping
|
|
3776
|
+
* names this key's account and the build's Relay order id (`relayOrderId`, never the step
|
|
3777
|
+
* `relayRequestId`), and the build lands on one of `ownDestinations` (the recipient check: Relay's
|
|
3778
|
+
* own record of the request is not read, BE-1777); then the SendAsset carries the mapping's nonce,
|
|
3779
|
+
* the exact amount asked for, and the pinned token, dex and depository. The client posts the
|
|
3780
|
+
* SendAsset to Hyperliquid itself and reports the answer. There is no confirmation gate here: the
|
|
3781
|
+
* CLI has one (`candle perps withdraw`).
|
|
3782
|
+
*/
|
|
3783
|
+
perpsWithdraw(params: PerpsWithdrawParams): Promise<PerpsWithdrawResult>;
|
|
3306
3784
|
/**
|
|
3307
3785
|
* Sign EIP-712 typed data with a linked EVM TEE wallet through the relay
|
|
3308
3786
|
* (`eth_signTypedData_v4`). The relay signs only typed data a perps build stamped.
|
|
@@ -3351,7 +3829,7 @@ export declare function __setEvmReceiptWaitForTest(opts: {
|
|
|
3351
3829
|
pollMs?: number;
|
|
3352
3830
|
} | null): void;
|
|
3353
3831
|
/** This build's own version. Kept in lockstep with package.json by the release-bump CI guard. */
|
|
3354
|
-
export declare const SDK_VERSION = "0.6.
|
|
3832
|
+
export declare const SDK_VERSION = "0.6.4";
|
|
3355
3833
|
/** Test seam: the once-per-process latch would otherwise weld the suite's first case to the rest. */
|
|
3356
3834
|
export declare function __resetSdkUpdateNoticeForTest(): void;
|
|
3357
3835
|
//# sourceMappingURL=client.d.ts.map
|