@arca-network/sdk 1.8.0 → 1.10.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/dist/arca.d.ts +115 -36
- package/dist/arca.d.ts.map +1 -1
- package/dist/arca.js +174 -65
- package/dist/arca.js.map +1 -1
- package/dist/cosign.d.ts +36 -1
- package/dist/cosign.d.ts.map +1 -1
- package/dist/cosign.js +55 -0
- package/dist/cosign.js.map +1 -1
- package/dist/fixtures/cosign-vectors.json +144 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/operation-handle.d.ts +7 -0
- package/dist/operation-handle.d.ts.map +1 -1
- package/dist/operation-handle.js +40 -9
- package/dist/operation-handle.js.map +1 -1
- package/dist/recovery.d.ts +96 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +186 -0
- package/dist/recovery.js.map +1 -1
- package/dist/types.d.ts +94 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-handle.js","sourceRoot":"","sources":["../src/operation-handle.ts"],"names":[],"mappings":";;;AAiBA;;;;;;;;;;GAUG;AACH,MAAa,eAAe;IAC1B,iEAAiE;IACxD,SAAS,CAAqB;IAEvC;;;;;OAKG;IACM,SAAS,CAAmB;IAE7B,OAAO,CAAuD;IAC9D,iBAAiB,GAA8B,IAAI,CAAC;IAE5D,YACE,QAA4B,EAC5B,MAA4D,EAC5D,SAA2B;QAE3B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEO,OAAO,CAAC,SAAkB;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACpC,IAAI,C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.recoveryClosePosition`, in basis
|
|
3
|
+
* points (`RECOVERY_CLOSE_PX_BAND_BPS`). One-sided: a SELL must be at or above
|
|
4
|
+
* `oracle × (1 - band)`, a BUY at or below `oracle × (1 + band)`. The far side
|
|
5
|
+
* is unbounded — selling above or buying below oracle only improves the close.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RECOVERY_CLOSE_PX_BAND_BPS = 200;
|
|
8
|
+
export interface RecoveryCloseOrderInput {
|
|
9
|
+
/** Limit price in human decimal USD, e.g. `"63512.4"`. */
|
|
10
|
+
limitPx: number | string;
|
|
11
|
+
/** Order size in human base-asset units, e.g. `"0.0123"`. */
|
|
12
|
+
size: number | string;
|
|
13
|
+
/** The market's `szDecimals`, from `getMarketMeta()` or HL's `meta.universe`. */
|
|
14
|
+
szDecimals: number;
|
|
15
|
+
/** `true` when closing a short (a BUY), `false` when closing a long (a SELL). */
|
|
16
|
+
isBuy: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The full open position size. When `size` rounds to exactly this, the order
|
|
19
|
+
* closes the position and HL waives its minimum notional; otherwise the
|
|
20
|
+
* minimum applies and a sub-minimum order is dropped without a trace. Omit
|
|
21
|
+
* only if you have independently established the order clears the minimum.
|
|
22
|
+
*/
|
|
23
|
+
positionSize?: number | string;
|
|
24
|
+
/**
|
|
25
|
+
* The asset's oracle price, from the same precompile the contract reads
|
|
26
|
+
* (`perpAssetInfo` / `oraclePx`). Supplying it moves the band check off chain,
|
|
27
|
+
* where the failure is a thrown error instead of a reverted transaction during
|
|
28
|
+
* a liquidation race.
|
|
29
|
+
*/
|
|
30
|
+
oraclePx?: number | string;
|
|
31
|
+
}
|
|
32
|
+
export interface RecoveryCloseOrder {
|
|
33
|
+
/** `limitPx` argument for `recoveryClosePosition` (human value × 10^8). */
|
|
34
|
+
limitPx: bigint;
|
|
35
|
+
/** `sz` argument for `recoveryClosePosition` (human value × 10^8). */
|
|
36
|
+
sz: bigint;
|
|
37
|
+
/** The rounded human price actually encoded — may differ from the input. */
|
|
38
|
+
limitPxDecimal: string;
|
|
39
|
+
/** The floored human size actually encoded — may differ from the input. */
|
|
40
|
+
sizeDecimal: string;
|
|
41
|
+
/** `sizeDecimal × limitPxDecimal`. */
|
|
42
|
+
notionalUsd: string;
|
|
43
|
+
/** Whether `sizeDecimal` closes the position exactly (so the notional minimum is waived). */
|
|
44
|
+
closesPosition: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Round a reduce-only close to Hyperliquid's tick/lot rules and encode it as
|
|
48
|
+
* the `limitPx` / `sz` arguments of `HyperliquidVenueModule.recoveryClosePosition`.
|
|
49
|
+
*
|
|
50
|
+
* **Why this exists.** `recoveryClosePosition` reaches HL through CoreWriter,
|
|
51
|
+
* which does not report venue-side rejection: an order violating HL's price,
|
|
52
|
+
* size, or notional rules produces a successful transaction and a
|
|
53
|
+
* `VaultRecoveryCloseEnqueued` event, and then nothing happens on L1. That
|
|
54
|
+
* failure lands during a liquidation race, under a recovery claim, and reports
|
|
55
|
+
* success — so the rounding is not a nicety, it is the difference between a
|
|
56
|
+
* close and a silent no-op. This function applies the rules HL actually
|
|
57
|
+
* enforces:
|
|
58
|
+
*
|
|
59
|
+
* - **Price**: at most {@link MAX_PRICE_SIG_FIGS} significant figures, then at
|
|
60
|
+
* most `6 - szDecimals` decimal places, rounding half-away-from-zero (the
|
|
61
|
+
* same order and direction as HL's own Python SDK, so a price this produces
|
|
62
|
+
* matches what every other correct client produces).
|
|
63
|
+
* - **Size**: floor-truncated to `szDecimals` decimal places. Floor, not round,
|
|
64
|
+
* because rounding up can exceed the position and HL rejects a reduce-only
|
|
65
|
+
* order that would increase exposure.
|
|
66
|
+
* - **Notional**: `size × price` must clear ${@link MIN_ORDER_NOTIONAL_USD}
|
|
67
|
+
* unless the order closes the position exactly, which is HL's documented
|
|
68
|
+
* exemption (a *partial* close below the minimum is not exempt). Pass
|
|
69
|
+
* `positionSize` so this can be decided rather than assumed; the result's
|
|
70
|
+
* `closesPosition` reports which branch applied, so a caller who wants to
|
|
71
|
+
* enforce the minimum unconditionally can still refuse.
|
|
72
|
+
* - **Oracle band**: when `oraclePx` is given, the contract's one-sided band is
|
|
73
|
+
* checked here, turning an on-chain revert into a local error.
|
|
74
|
+
*
|
|
75
|
+
* Anything that would be dropped or reverted throws. A returned value is an
|
|
76
|
+
* order HL will act on.
|
|
77
|
+
*
|
|
78
|
+
* The event is still not evidence of execution — CoreWriter is asynchronous and
|
|
79
|
+
* the order can rest unfilled. Confirm by polling the position (HL
|
|
80
|
+
* `clearinghouseState`, or the vault's `l1Position` read passthrough), never by
|
|
81
|
+
* observing the event.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const { limitPx, sz } = encodeRecoveryCloseOrder({
|
|
86
|
+
* limitPx: oraclePx * 0.995, // sell a long slightly below oracle to cross
|
|
87
|
+
* size: positionSize,
|
|
88
|
+
* positionSize,
|
|
89
|
+
* szDecimals: market.szDecimals,
|
|
90
|
+
* isBuy: false,
|
|
91
|
+
* oraclePx,
|
|
92
|
+
* });
|
|
93
|
+
* // hlModule.recoveryClosePosition(arcaId, asset, false, limitPx, sz, 3) // 3 = IOC
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function encodeRecoveryCloseOrder(input: RecoveryCloseOrderInput): RecoveryCloseOrder;
|
|
1
97
|
export interface GeneratedRecoveryKeyResult {
|
|
2
98
|
mnemonic: string;
|
|
3
99
|
address: string;
|
package/dist/recovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAkIA;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAW9C,MAAM,WAAW,uBAAuB;IACtC,0DAA0D;IAC1D,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,KAAK,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,6FAA6F;IAC7F,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,uBAAuB,GAAG,kBAAkB,CA2D3F;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,IAAI,0BAA0B,CA4BpE"}
|
package/dist/recovery.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RECOVERY_CLOSE_PX_BAND_BPS = void 0;
|
|
4
|
+
exports.encodeRecoveryCloseOrder = encodeRecoveryCloseOrder;
|
|
3
5
|
exports.generateRecoveryKeyPair = generateRecoveryKeyPair;
|
|
4
6
|
const bip39_1 = require("@scure/bip39");
|
|
5
7
|
const english_js_1 = require("@scure/bip39/wordlists/english.js");
|
|
@@ -41,6 +43,190 @@ function privateKeyToAddress(privateKey) {
|
|
|
41
43
|
uncompressed.fill(0);
|
|
42
44
|
return address;
|
|
43
45
|
}
|
|
46
|
+
const DECIMAL_RE = /^([+-]?)(\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/;
|
|
47
|
+
function parseDec(value, label) {
|
|
48
|
+
const raw = typeof value === 'number' ? (Number.isFinite(value) ? String(value) : '') : value.trim();
|
|
49
|
+
const match = DECIMAL_RE.exec(raw);
|
|
50
|
+
if (!match)
|
|
51
|
+
throw new Error(`${label}: not a finite decimal number (got ${JSON.stringify(value)})`);
|
|
52
|
+
const [, sign, int, frac = '', exp = '0'] = match;
|
|
53
|
+
let m = BigInt(int + frac);
|
|
54
|
+
if (sign === '-')
|
|
55
|
+
m = -m;
|
|
56
|
+
let s = frac.length - Number(exp);
|
|
57
|
+
if (s < 0) {
|
|
58
|
+
m *= 10n ** BigInt(-s);
|
|
59
|
+
s = 0;
|
|
60
|
+
}
|
|
61
|
+
return { m, s };
|
|
62
|
+
}
|
|
63
|
+
/** Re-scale to exactly `target` decimal places, rounding half-away-from-zero. */
|
|
64
|
+
function rescale({ m, s }, target) {
|
|
65
|
+
if (target === s)
|
|
66
|
+
return { m, s };
|
|
67
|
+
if (target > s)
|
|
68
|
+
return { m: m * 10n ** BigInt(target - s), s: target };
|
|
69
|
+
const div = 10n ** BigInt(s - target);
|
|
70
|
+
const neg = m < 0n;
|
|
71
|
+
const abs = neg ? -m : m;
|
|
72
|
+
let q = abs / div;
|
|
73
|
+
if ((abs % div) * 2n >= div)
|
|
74
|
+
q += 1n;
|
|
75
|
+
return { m: neg ? -q : q, s: target };
|
|
76
|
+
}
|
|
77
|
+
/** Count of significant digits — the digits of |m|, since BigInt has no leading zeros. */
|
|
78
|
+
function sigDigits(m) {
|
|
79
|
+
const abs = m < 0n ? -m : m;
|
|
80
|
+
return abs === 0n ? 0 : abs.toString().length;
|
|
81
|
+
}
|
|
82
|
+
function formatDec({ m, s }) {
|
|
83
|
+
const neg = m < 0n;
|
|
84
|
+
let digits = (neg ? -m : m).toString();
|
|
85
|
+
if (s > 0) {
|
|
86
|
+
digits = digits.padStart(s + 1, '0');
|
|
87
|
+
const int = digits.slice(0, digits.length - s);
|
|
88
|
+
const frac = digits.slice(digits.length - s).replace(/0+$/, '');
|
|
89
|
+
digits = frac ? `${int}.${frac}` : int;
|
|
90
|
+
}
|
|
91
|
+
return (neg ? '-' : '') + digits;
|
|
92
|
+
}
|
|
93
|
+
/** Exact ×10^8 CoreWriter wire value; throws rather than truncating. */
|
|
94
|
+
function toWire(d, label) {
|
|
95
|
+
const scaled = rescale(d, 8);
|
|
96
|
+
if (scaled.m < 0n)
|
|
97
|
+
throw new Error(`${label}: must be positive`);
|
|
98
|
+
if (rescale(scaled, d.s).m !== d.m) {
|
|
99
|
+
throw new Error(`${label}: needs more than 8 decimal places, which CoreWriter cannot encode`);
|
|
100
|
+
}
|
|
101
|
+
return scaled.m;
|
|
102
|
+
}
|
|
103
|
+
function mulDec(a, b) {
|
|
104
|
+
return { m: a.m * b.m, s: a.s + b.s };
|
|
105
|
+
}
|
|
106
|
+
function cmpDec(a, b) {
|
|
107
|
+
const s = Math.max(a.s, b.s);
|
|
108
|
+
const am = rescale(a, s).m;
|
|
109
|
+
const bm = rescale(b, s).m;
|
|
110
|
+
return am < bm ? -1 : am > bm ? 1 : 0;
|
|
111
|
+
}
|
|
112
|
+
// --- Sovereign reduce-only close encoding ---
|
|
113
|
+
/**
|
|
114
|
+
* HL's oracle band on `HyperliquidVenueModule.recoveryClosePosition`, in basis
|
|
115
|
+
* points (`RECOVERY_CLOSE_PX_BAND_BPS`). One-sided: a SELL must be at or above
|
|
116
|
+
* `oracle × (1 - band)`, a BUY at or below `oracle × (1 + band)`. The far side
|
|
117
|
+
* is unbounded — selling above or buying below oracle only improves the close.
|
|
118
|
+
*/
|
|
119
|
+
exports.RECOVERY_CLOSE_PX_BAND_BPS = 200;
|
|
120
|
+
/** HL's minimum order notional. Exempt only for an order that closes a position exactly. */
|
|
121
|
+
const MIN_ORDER_NOTIONAL_USD = 10;
|
|
122
|
+
/** HL perp price rule: at most `MAX_PRICE_DECIMALS - szDecimals` decimal places. */
|
|
123
|
+
const MAX_PRICE_DECIMALS = 6;
|
|
124
|
+
/** HL perp price rule: at most this many significant figures (integers exempt). */
|
|
125
|
+
const MAX_PRICE_SIG_FIGS = 5;
|
|
126
|
+
/**
|
|
127
|
+
* Round a reduce-only close to Hyperliquid's tick/lot rules and encode it as
|
|
128
|
+
* the `limitPx` / `sz` arguments of `HyperliquidVenueModule.recoveryClosePosition`.
|
|
129
|
+
*
|
|
130
|
+
* **Why this exists.** `recoveryClosePosition` reaches HL through CoreWriter,
|
|
131
|
+
* which does not report venue-side rejection: an order violating HL's price,
|
|
132
|
+
* size, or notional rules produces a successful transaction and a
|
|
133
|
+
* `VaultRecoveryCloseEnqueued` event, and then nothing happens on L1. That
|
|
134
|
+
* failure lands during a liquidation race, under a recovery claim, and reports
|
|
135
|
+
* success — so the rounding is not a nicety, it is the difference between a
|
|
136
|
+
* close and a silent no-op. This function applies the rules HL actually
|
|
137
|
+
* enforces:
|
|
138
|
+
*
|
|
139
|
+
* - **Price**: at most {@link MAX_PRICE_SIG_FIGS} significant figures, then at
|
|
140
|
+
* most `6 - szDecimals` decimal places, rounding half-away-from-zero (the
|
|
141
|
+
* same order and direction as HL's own Python SDK, so a price this produces
|
|
142
|
+
* matches what every other correct client produces).
|
|
143
|
+
* - **Size**: floor-truncated to `szDecimals` decimal places. Floor, not round,
|
|
144
|
+
* because rounding up can exceed the position and HL rejects a reduce-only
|
|
145
|
+
* order that would increase exposure.
|
|
146
|
+
* - **Notional**: `size × price` must clear ${@link MIN_ORDER_NOTIONAL_USD}
|
|
147
|
+
* unless the order closes the position exactly, which is HL's documented
|
|
148
|
+
* exemption (a *partial* close below the minimum is not exempt). Pass
|
|
149
|
+
* `positionSize` so this can be decided rather than assumed; the result's
|
|
150
|
+
* `closesPosition` reports which branch applied, so a caller who wants to
|
|
151
|
+
* enforce the minimum unconditionally can still refuse.
|
|
152
|
+
* - **Oracle band**: when `oraclePx` is given, the contract's one-sided band is
|
|
153
|
+
* checked here, turning an on-chain revert into a local error.
|
|
154
|
+
*
|
|
155
|
+
* Anything that would be dropped or reverted throws. A returned value is an
|
|
156
|
+
* order HL will act on.
|
|
157
|
+
*
|
|
158
|
+
* The event is still not evidence of execution — CoreWriter is asynchronous and
|
|
159
|
+
* the order can rest unfilled. Confirm by polling the position (HL
|
|
160
|
+
* `clearinghouseState`, or the vault's `l1Position` read passthrough), never by
|
|
161
|
+
* observing the event.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* const { limitPx, sz } = encodeRecoveryCloseOrder({
|
|
166
|
+
* limitPx: oraclePx * 0.995, // sell a long slightly below oracle to cross
|
|
167
|
+
* size: positionSize,
|
|
168
|
+
* positionSize,
|
|
169
|
+
* szDecimals: market.szDecimals,
|
|
170
|
+
* isBuy: false,
|
|
171
|
+
* oraclePx,
|
|
172
|
+
* });
|
|
173
|
+
* // hlModule.recoveryClosePosition(arcaId, asset, false, limitPx, sz, 3) // 3 = IOC
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
function encodeRecoveryCloseOrder(input) {
|
|
177
|
+
const { szDecimals, isBuy } = input;
|
|
178
|
+
if (!Number.isInteger(szDecimals) || szDecimals < 0 || szDecimals > MAX_PRICE_DECIMALS) {
|
|
179
|
+
throw new Error(`szDecimals: expected an integer in [0, ${MAX_PRICE_DECIMALS}], got ${szDecimals}`);
|
|
180
|
+
}
|
|
181
|
+
// Price: significant figures first, then decimal places — HL's order, and the
|
|
182
|
+
// one that makes integer prices fall out correctly (an integer price is always
|
|
183
|
+
// a valid tick, and the decimal-place cap cannot reintroduce a fraction).
|
|
184
|
+
let px = parseDec(input.limitPx, 'limitPx');
|
|
185
|
+
if (px.m <= 0n)
|
|
186
|
+
throw new Error('limitPx: must be positive');
|
|
187
|
+
const excessSigFigs = sigDigits(px.m) - MAX_PRICE_SIG_FIGS;
|
|
188
|
+
if (excessSigFigs > 0)
|
|
189
|
+
px = rescale(px, px.s - excessSigFigs);
|
|
190
|
+
if (px.s > MAX_PRICE_DECIMALS - szDecimals)
|
|
191
|
+
px = rescale(px, MAX_PRICE_DECIMALS - szDecimals);
|
|
192
|
+
if (px.m <= 0n)
|
|
193
|
+
throw new Error('limitPx: rounded to zero at this market’s price precision');
|
|
194
|
+
// Size: floor, so a full-position close can never round into an increase.
|
|
195
|
+
const rawSize = parseDec(input.size, 'size');
|
|
196
|
+
if (rawSize.m <= 0n)
|
|
197
|
+
throw new Error('size: must be positive');
|
|
198
|
+
let size = rescale(rawSize, szDecimals);
|
|
199
|
+
if (cmpDec(size, rawSize) > 0)
|
|
200
|
+
size = { m: size.m - 1n, s: size.s };
|
|
201
|
+
if (size.m <= 0n) {
|
|
202
|
+
throw new Error(`size: ${formatDec(rawSize)} floors to zero at szDecimals=${szDecimals}; the position is below one lot and cannot be closed through this surface`);
|
|
203
|
+
}
|
|
204
|
+
const closesPosition = input.positionSize !== undefined && cmpDec(size, parseDec(input.positionSize, 'positionSize')) === 0;
|
|
205
|
+
const notional = mulDec(size, px);
|
|
206
|
+
if (!closesPosition && cmpDec(notional, { m: BigInt(MIN_ORDER_NOTIONAL_USD), s: 0 }) < 0) {
|
|
207
|
+
throw new Error(`notional ${formatDec(notional)} is below Hyperliquid's $${MIN_ORDER_NOTIONAL_USD} minimum and this order does not close the position exactly, so the venue would drop it silently — close the full position, or raise the size`);
|
|
208
|
+
}
|
|
209
|
+
if (input.oraclePx !== undefined) {
|
|
210
|
+
const oracle = parseDec(input.oraclePx, 'oraclePx');
|
|
211
|
+
if (oracle.m <= 0n)
|
|
212
|
+
throw new Error('oraclePx: must be positive');
|
|
213
|
+
const bps = BigInt(10_000 + (isBuy ? exports.RECOVERY_CLOSE_PX_BAND_BPS : -exports.RECOVERY_CLOSE_PX_BAND_BPS));
|
|
214
|
+
const bound = mulDec(oracle, { m: bps, s: 4 });
|
|
215
|
+
// The contract's band is one-sided: a BUY may not exceed the upper bound, a
|
|
216
|
+
// SELL may not fall below the lower one.
|
|
217
|
+
if (isBuy ? cmpDec(px, bound) > 0 : cmpDec(px, bound) < 0) {
|
|
218
|
+
throw new Error(`limitPx ${formatDec(px)} is outside the contract's ${exports.RECOVERY_CLOSE_PX_BAND_BPS}bp oracle band (${isBuy ? 'max' : 'min'} ${formatDec(bound)} against oracle ${formatDec(oracle)}); the transaction would revert`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
limitPx: toWire(px, 'limitPx'),
|
|
223
|
+
sz: toWire(size, 'size'),
|
|
224
|
+
limitPxDecimal: formatDec(px),
|
|
225
|
+
sizeDecimal: formatDec(size),
|
|
226
|
+
notionalUsd: formatDec(notional),
|
|
227
|
+
closesPosition,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
44
230
|
/**
|
|
45
231
|
* Generate a BIP-39 mnemonic and derive the Ethereum address at the standard
|
|
46
232
|
* BIP-44 path (m/44'/60'/0'/0/0).
|
package/dist/recovery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.js","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recovery.js","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":";;;AA6OA,4DA2DC;AAqBD,0DA4BC;AAzVD,wCAAoE;AACpE,kEAA6D;AAC7D,wCAAqC;AACrC,mDAAmD;AACnD,6DAAuD;AAEvD,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAE1C,SAAS,UAAU,CAAC,KAAiB;IACnC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,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,CAAC,CAAC;IACpE,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2253,8 +2253,17 @@ export type LeverageType = 'cross' | 'isolated';
|
|
|
2253
2253
|
* reduce-only closer can no longer reduce it.
|
|
2254
2254
|
* - `liquidated` — the position (or account) was liquidated.
|
|
2255
2255
|
* - `position_gone` — an unsized TP/SL fired but the position was already gone.
|
|
2256
|
+
* - `market_delisted` — the venue delisted the market, so the order's book no
|
|
2257
|
+
* longer exists and it could never fill.
|
|
2258
|
+
* - `insufficient_margin` — a resting limit order repeatedly reached its price
|
|
2259
|
+
* but the account could not afford the fill. Placing an order checks margin
|
|
2260
|
+
* but does not reserve it, so an order that was affordable when placed can
|
|
2261
|
+
* become unaffordable while it rests (a loss on another position, a fill
|
|
2262
|
+
* elsewhere, funding). A brief dip is tolerated; the venue only retires the
|
|
2263
|
+
* order once it has stayed unaffordable across repeated attempts over
|
|
2264
|
+
* several minutes. Free up margin before re-placing it.
|
|
2256
2265
|
*/
|
|
2257
|
-
export type OrderCancelReason = 'user_requested' | 'sibling_filled' | 'position_closed' | 'position_flipped' | 'liquidated' | 'position_gone';
|
|
2266
|
+
export type OrderCancelReason = 'user_requested' | 'sibling_filled' | 'position_closed' | 'position_flipped' | 'liquidated' | 'position_gone' | 'market_delisted' | 'insufficient_margin';
|
|
2258
2267
|
export interface SimPosition {
|
|
2259
2268
|
id: SimPositionId;
|
|
2260
2269
|
accountId: SimAccountId;
|
|
@@ -2306,6 +2315,16 @@ export interface SimPosition {
|
|
|
2306
2315
|
cumulativeBuilderFee?: string | null;
|
|
2307
2316
|
/** Present when computed fields (unrealizedPnl, positionValue, returnOnEquity) could not be calculated. */
|
|
2308
2317
|
error?: string | null;
|
|
2318
|
+
/**
|
|
2319
|
+
* When the position's *current open lot* began — the same lot boundary the
|
|
2320
|
+
* `cumulative*` fields use. Survives increases, partial reduces, and
|
|
2321
|
+
* leverage / margin-mode changes; resets on a flip-through-zero and on a
|
|
2322
|
+
* reopen after a full close.
|
|
2323
|
+
*
|
|
2324
|
+
* Derived from the platform's own fill history rather than reported by the
|
|
2325
|
+
* venue, so it means the same thing on every exchange. Empty string when no
|
|
2326
|
+
* history exists to derive it from.
|
|
2327
|
+
*/
|
|
2309
2328
|
createdAt: string;
|
|
2310
2329
|
updatedAt: string;
|
|
2311
2330
|
}
|
|
@@ -2602,8 +2621,11 @@ export type OrderBreakdownAmountType = 'spend' | 'notional' | 'tokens';
|
|
|
2602
2621
|
* cross-margin liquidation estimate. The estimate matches the formula the
|
|
2603
2622
|
* sim-exchange backend uses at read time
|
|
2604
2623
|
* (`marginAvailable = equity - maintenanceMargin`, then
|
|
2605
|
-
* `liq = mid -/+ marginAvailable / size`), so the preview
|
|
2606
|
-
* liquidation price the position will actually have once the
|
|
2624
|
+
* `liq = mid -/+ marginAvailable / (size * (1 -/+ mmr))`), so the preview
|
|
2625
|
+
* reflects the liquidation price the position will actually have once the
|
|
2626
|
+
* order fills. The `(1 -/+ mmr)` term is maintenance relief: the position's
|
|
2627
|
+
* own requirement is a percentage of notional, so it moves with the mark and
|
|
2628
|
+
* equity closes on it at `size * (1 -/+ mmr)` per unit rather than `size`. */
|
|
2607
2629
|
export interface OrderBreakdownAccountContext {
|
|
2608
2630
|
/** Account equity in USD. From `ExchangeState.marginSummary.equity`. */
|
|
2609
2631
|
equity: string;
|
|
@@ -2965,6 +2987,27 @@ export interface OIHistoryResponse {
|
|
|
2965
2987
|
interval: string;
|
|
2966
2988
|
bars: OIBar[];
|
|
2967
2989
|
}
|
|
2990
|
+
/**
|
|
2991
|
+
* A single SETTLED funding-rate observation for a market. Unlike {@link OIBar}
|
|
2992
|
+
* / {@link Candle} this is not interval-bucketed — it is a raw event at the
|
|
2993
|
+
* venue's real settlement timestamp, so a market's true funding schedule is
|
|
2994
|
+
* preserved. Values are settled historical rates, never predicted (use the
|
|
2995
|
+
* ticker's `funding` + `nextFundingTime` for the current/predicted rate).
|
|
2996
|
+
*/
|
|
2997
|
+
export interface FundingObservation {
|
|
2998
|
+
/** Settlement time as Unix epoch milliseconds (UTC). */
|
|
2999
|
+
t: number;
|
|
3000
|
+
/** Settled funding rate for the period (decimal string, e.g. "0.0000125"). */
|
|
3001
|
+
fundingRate: string;
|
|
3002
|
+
/** Premium component at settlement (decimal string). May be absent. */
|
|
3003
|
+
premium?: string;
|
|
3004
|
+
/** Data source (e.g. "hl"). Absent/empty for legacy rows. */
|
|
3005
|
+
s?: string;
|
|
3006
|
+
}
|
|
3007
|
+
export interface FundingHistoryResponse {
|
|
3008
|
+
market: string;
|
|
3009
|
+
funding: FundingObservation[];
|
|
3010
|
+
}
|
|
2968
3011
|
/** Emitted by {@link OIWatchStream} on each live OI bar update. */
|
|
2969
3012
|
export interface OIEvent {
|
|
2970
3013
|
market: string;
|
|
@@ -3140,6 +3183,52 @@ export interface CustodyRealmHalt {
|
|
|
3140
3183
|
type: CustodyRealmHaltType;
|
|
3141
3184
|
expiresAt: string;
|
|
3142
3185
|
}
|
|
3186
|
+
/**
|
|
3187
|
+
* A resolved custody implementation address and the version marker read off it.
|
|
3188
|
+
*
|
|
3189
|
+
* A proxy address is stable across upgrades and says nothing about the surface
|
|
3190
|
+
* it currently delegates to, so both halves are needed: the address identifies
|
|
3191
|
+
* *which* implementation, the marker identifies *what surface*.
|
|
3192
|
+
*/
|
|
3193
|
+
export interface CustodyImplRef {
|
|
3194
|
+
/** The implementation address, resolved live from the chain. */
|
|
3195
|
+
address: string;
|
|
3196
|
+
/**
|
|
3197
|
+
* The version marker read off that implementation, or `null` when the read
|
|
3198
|
+
* failed. Never `0` for an unread marker — a client gating on
|
|
3199
|
+
* `version >= 5` must be able to tell "reports 4" from "could not read".
|
|
3200
|
+
*/
|
|
3201
|
+
version: number | null;
|
|
3202
|
+
/**
|
|
3203
|
+
* Which getter `version` came from. `moduleVersion` and
|
|
3204
|
+
* `exchangeArcaVaultVersion` promise *surface* semantics (they bump on
|
|
3205
|
+
* meaningful public-surface changes, so gate feature checks on them);
|
|
3206
|
+
* `arcaKernelVersion` and `arcaCoordinatorVersion` promise *storage layout*
|
|
3207
|
+
* and will not move for a surface addition.
|
|
3208
|
+
*/
|
|
3209
|
+
marker: string;
|
|
3210
|
+
}
|
|
3211
|
+
/**
|
|
3212
|
+
* The implementation set behind a realm's custody proxies. Assert compatibility
|
|
3213
|
+
* against this before moving money, rather than scanning runtime bytecode.
|
|
3214
|
+
*
|
|
3215
|
+
* Entries are omitted when the address cannot be resolved (a degraded RPC, or a
|
|
3216
|
+
* realm that predates the proxy), so treat a missing entry as "unknown", not as
|
|
3217
|
+
* "absent from the deployment".
|
|
3218
|
+
*/
|
|
3219
|
+
export interface CustodyImplementations {
|
|
3220
|
+
kernel?: CustodyImplRef;
|
|
3221
|
+
coordinator?: CustodyImplRef;
|
|
3222
|
+
hlModule?: CustodyImplRef;
|
|
3223
|
+
simModule?: CustodyImplRef;
|
|
3224
|
+
/**
|
|
3225
|
+
* Resolved through the live chain path (`module.vaultBeacon()` →
|
|
3226
|
+
* `beacon.implementation()`), so it reflects the vault implementation the
|
|
3227
|
+
* module actually governs.
|
|
3228
|
+
*/
|
|
3229
|
+
vault?: CustodyImplRef;
|
|
3230
|
+
vaultBeacon?: string;
|
|
3231
|
+
}
|
|
3143
3232
|
export interface CustodyStatus {
|
|
3144
3233
|
contractAddress: string;
|
|
3145
3234
|
chainId: number;
|
|
@@ -3147,6 +3236,8 @@ export interface CustodyStatus {
|
|
|
3147
3236
|
boundaries: CustodyBoundary[];
|
|
3148
3237
|
exchangeArcas: CustodyExchangeArca[];
|
|
3149
3238
|
realmHalt: CustodyRealmHalt | null;
|
|
3239
|
+
/** Omitted when no implementation could be resolved. */
|
|
3240
|
+
implementations?: CustodyImplementations;
|
|
3150
3241
|
}
|
|
3151
3242
|
export interface CustodyBoundaryListResponse {
|
|
3152
3243
|
boundaries: CustodyBoundary[];
|