@parchment-trade/sdk 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/README.md +192 -2
- package/REFERENCE.md +338 -0
- package/SECURITY.md +23 -0
- package/dist/general/providers/index.d.ts +2 -0
- package/dist/general/providers/index.js +2 -0
- package/dist/general/providers/parchment.d.ts +1 -0
- package/dist/general/providers/parchment.js +1 -0
- package/dist/general/providers/parchmentSdk.d.ts +23 -0
- package/dist/general/providers/parchmentSdk.js +11 -0
- package/dist/general/types/configTypes.d.ts +62 -0
- package/dist/general/types/configTypes.js +1 -0
- package/dist/general/types/index.d.ts +1 -0
- package/dist/general/types/index.js +1 -0
- package/dist/general/utils/address.d.ts +49 -0
- package/dist/general/utils/address.js +110 -0
- package/dist/general/utils/caller.d.ts +58 -0
- package/dist/general/utils/caller.js +182 -0
- package/dist/general/utils/errors.d.ts +16 -0
- package/dist/general/utils/errors.js +26 -0
- package/dist/general/utils/index.d.ts +4 -0
- package/dist/general/utils/index.js +4 -0
- package/dist/general/utils/jsBigInt.d.ts +26 -0
- package/dist/general/utils/jsBigInt.js +74 -0
- package/dist/general/utils/txShape.d.ts +8 -0
- package/dist/general/utils/txShape.js +39 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/packages/index.d.ts +11 -0
- package/dist/packages/index.js +5 -0
- package/dist/packages/parchment/abortCodes.d.ts +196 -0
- package/dist/packages/parchment/abortCodes.js +522 -0
- package/dist/packages/parchment/batchClose.d.ts +268 -0
- package/dist/packages/parchment/batchClose.js +524 -0
- package/dist/packages/parchment/eventGuard.d.ts +106 -0
- package/dist/packages/parchment/eventGuard.js +119 -0
- package/dist/packages/parchment/gameCounterEvents.d.ts +59 -0
- package/dist/packages/parchment/gameCounterEvents.js +56 -0
- package/dist/packages/parchment/index.d.ts +52 -0
- package/dist/packages/parchment/index.js +30 -0
- package/dist/packages/parchment/liquidationCredit.d.ts +28 -0
- package/dist/packages/parchment/liquidationCredit.js +25 -0
- package/dist/packages/parchment/lockedMintEvents.d.ts +42 -0
- package/dist/packages/parchment/lockedMintEvents.js +46 -0
- package/dist/packages/parchment/monitoring.d.ts +369 -0
- package/dist/packages/parchment/monitoring.js +259 -0
- package/dist/packages/parchment/notes.d.ts +6 -0
- package/dist/packages/parchment/notes.js +1 -0
- package/dist/packages/parchment/onboarding.d.ts +50 -0
- package/dist/packages/parchment/onboarding.js +48 -0
- package/dist/packages/parchment/orderEffects.d.ts +207 -0
- package/dist/packages/parchment/orderEffects.js +268 -0
- package/dist/packages/parchment/orderParams.d.ts +72 -0
- package/dist/packages/parchment/orderParams.js +71 -0
- package/dist/packages/parchment/packageIds.d.ts +53 -0
- package/dist/packages/parchment/packageIds.js +149 -0
- package/dist/packages/parchment/parchment.d.ts +442 -0
- package/dist/packages/parchment/parchment.js +975 -0
- package/dist/packages/parchment/parchmentAccount.d.ts +189 -0
- package/dist/packages/parchment/parchmentAccount.js +273 -0
- package/dist/packages/parchment/parchmentMarket.d.ts +58 -0
- package/dist/packages/parchment/parchmentMarket.js +86 -0
- package/dist/packages/parchment/parchmentTypes.d.ts +2031 -0
- package/dist/packages/parchment/parchmentTypes.js +65 -0
- package/dist/packages/parchment/publicInts.d.ts +45 -0
- package/dist/packages/parchment/publicInts.js +383 -0
- package/dist/packages/parchment/reconcileEvents.d.ts +24 -0
- package/dist/packages/parchment/reconcileEvents.js +30 -0
- package/dist/packages/parchment/retainedFee.d.ts +43 -0
- package/dist/packages/parchment/retainedFee.js +68 -0
- package/dist/packages/parchment/sessionClose.d.ts +68 -0
- package/dist/packages/parchment/sessionClose.js +50 -0
- package/dist/packages/parchment/sessionKey.d.ts +78 -0
- package/dist/packages/parchment/sessionKey.js +154 -0
- package/dist/packages/parchment/slippage.d.ts +23 -0
- package/dist/packages/parchment/slippage.js +27 -0
- package/dist/packages/parchment/sponsor.d.ts +39 -0
- package/dist/packages/parchment/sponsor.js +48 -0
- package/dist/packages/parchment/stakingCalls.d.ts +33 -0
- package/dist/packages/parchment/stakingCalls.js +21 -0
- package/dist/packages/parchment/stakingEvents.d.ts +53 -0
- package/dist/packages/parchment/stakingEvents.js +71 -0
- package/dist/packages/parchment/triggerCalls.d.ts +46 -0
- package/dist/packages/parchment/triggerCalls.js +36 -0
- package/dist/packages/parchment/triggerEvents.d.ts +22 -0
- package/dist/packages/parchment/triggerEvents.js +33 -0
- package/dist/packages/parchment/triggers.d.ts +113 -0
- package/dist/packages/parchment/triggers.js +183 -0
- package/dist/packages/parchment/txBodies.d.ts +111 -0
- package/dist/packages/parchment/txBodies.js +683 -0
- package/dist/packages/parchment/txIntent.d.ts +99 -0
- package/dist/packages/parchment/txIntent.js +611 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/package.json +55 -4
|
@@ -0,0 +1,2031 @@
|
|
|
1
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
/** Bytes of a signed Pyth Lazer update. The caller supplies them. */
|
|
3
|
+
export type SignedLazerUpdate = string | Uint8Array;
|
|
4
|
+
export type TxAction = "open-account" | "deposit" | "withdraw" | "request-open" | "request-open-as-delegate" | "request-close" | "request-close-as-delegate" | "cancel-order" | "cancel-order-as-delegate" | "expire-order" | "emergency-close" | "emergency-close-as-delegate" | "close-retired" | "close-retired-as-delegate" | "liquidate" | "liquidate-retired" | "sweep" | "sweep-surplus" | "claim-pending-mint" | "harvest" | "bind-referrer" | "bind-trading-referrer" | "transfer-account" | "stake" | "unstake" | "claim" | "grant-delegate" | "revoke-delegate" | "register-builder" | "set-builder-payout" | "create-builder" | "set-builder-fee" | "pause-builder" | "resume-builder" | "transfer-builder" | "approve-builder" | "revoke-builder-approval" | "set-builder-create-fee" | "install-treasury" | "auth-register" | "game-attach" | "claim-daily" | "open-crate" | "open-crates" | "claim-quest" | "collect-mint" | "release-unlocked" | "exit-early" | "exit-early-bounded" | "grant-close-delegate" | "grant-session-and-trigger" | "revoke-session-and-trigger";
|
|
5
|
+
export declare const TX_ACTIONS: readonly TxAction[];
|
|
6
|
+
export interface ApiParchmentCoinRef {
|
|
7
|
+
objectId: string;
|
|
8
|
+
version: string;
|
|
9
|
+
digest: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ApiParchmentSharedVersions {
|
|
12
|
+
[objectId: string]: string | bigint;
|
|
13
|
+
}
|
|
14
|
+
export interface ParchmentMoveCommand {
|
|
15
|
+
package: string;
|
|
16
|
+
module: string;
|
|
17
|
+
function: string;
|
|
18
|
+
typeArguments: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface ApiParchmentTxData {
|
|
21
|
+
txBytesBase64: string;
|
|
22
|
+
commands: ParchmentMoveCommand[];
|
|
23
|
+
note: string | null;
|
|
24
|
+
}
|
|
25
|
+
/** Transaction kind with its sender set. Gas is not included. */
|
|
26
|
+
export interface ParchmentBuiltTx {
|
|
27
|
+
/**
|
|
28
|
+
* The builder route (`request-close`, ...) and request body the kind was built and checked for.
|
|
29
|
+
* Pass it on with the kind as a Close All leg (`BatchCloseLeg.request`), so the batch re-checks it.
|
|
30
|
+
*/
|
|
31
|
+
request: ParchmentTxRequest;
|
|
32
|
+
tx: Transaction;
|
|
33
|
+
commands: ParchmentMoveCommand[];
|
|
34
|
+
note: string | null;
|
|
35
|
+
txBytesBase64: string;
|
|
36
|
+
}
|
|
37
|
+
/** A builder request: `transactions/<route>` and the JSON body posted to it. */
|
|
38
|
+
export interface ParchmentTxRequest {
|
|
39
|
+
route: string;
|
|
40
|
+
body: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/** The service has not read the market's pinned PriceFeedStorage, or cannot decode its feed. */
|
|
43
|
+
export interface ParchmentPriceUnavailable {
|
|
44
|
+
status: "price_unavailable";
|
|
45
|
+
storageId: string | null;
|
|
46
|
+
reason: string | null;
|
|
47
|
+
priceWad: null;
|
|
48
|
+
twapWad: null;
|
|
49
|
+
timestampMs: null;
|
|
50
|
+
spreadWad: null;
|
|
51
|
+
spreadSource: null;
|
|
52
|
+
ageMs?: null;
|
|
53
|
+
maxAgeMs?: null;
|
|
54
|
+
stale?: false;
|
|
55
|
+
confWad?: null;
|
|
56
|
+
indicative?: true;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Where a quoted spread came from: `floor` (the market's spread floor only) or `market-latest`
|
|
60
|
+
* (rebuilt from the market's latest indexed signed confidence, not the caller's own update).
|
|
61
|
+
*/
|
|
62
|
+
export type ParchmentSpreadSource = "floor" | "market-latest";
|
|
63
|
+
/** Served price fields shared by `live` and `stale` (`PriceView`). */
|
|
64
|
+
interface ParchmentPriceQuoted {
|
|
65
|
+
storageId: string | null;
|
|
66
|
+
reason: null;
|
|
67
|
+
priceWad: bigint;
|
|
68
|
+
twapWad: bigint | null;
|
|
69
|
+
timestampMs: bigint | null;
|
|
70
|
+
/**
|
|
71
|
+
* The one-step spread (emergency / retired / admin closes): `max(confidence or 0, price *
|
|
72
|
+
* one_step_spread_bps)`. Two-step fills settle at the plain mid with no spread (no bid/ask).
|
|
73
|
+
*/
|
|
74
|
+
spreadWad: bigint;
|
|
75
|
+
spreadSource: ParchmentSpreadSource;
|
|
76
|
+
/** `now - timestampMs` (negative when ahead). Absent on older services. */
|
|
77
|
+
ageMs?: bigint | null;
|
|
78
|
+
/** The market's `max_age_ms` the age is judged against. Absent on older services. */
|
|
79
|
+
maxAgeMs?: bigint | null;
|
|
80
|
+
/** True when `oracle::begin_price` would reject the observation; then `status` is `stale`. */
|
|
81
|
+
stale?: boolean;
|
|
82
|
+
/** The signed confidence the spread was built from (`market-latest` only). */
|
|
83
|
+
confWad?: bigint | null;
|
|
84
|
+
/** True when no fresh signed confidence is indexed: fills and payouts are an estimate. */
|
|
85
|
+
indicative?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Older than the market's `max_age_ms` or too far ahead: `oracle::begin_price` would abort, so a keeper fill or emergency close waits for a fresh price. */
|
|
88
|
+
export interface ParchmentPriceStale extends ParchmentPriceQuoted {
|
|
89
|
+
status: "stale";
|
|
90
|
+
}
|
|
91
|
+
export interface ParchmentPriceLive extends ParchmentPriceQuoted {
|
|
92
|
+
status: "live";
|
|
93
|
+
}
|
|
94
|
+
export type ParchmentPrice = ParchmentPriceLive | ParchmentPriceStale | ParchmentPriceUnavailable;
|
|
95
|
+
/** @deprecated Renamed to `ParchmentPriceUnavailable` (status `price_unavailable`). */
|
|
96
|
+
export type ParchmentPriceUnbound = ParchmentPriceUnavailable;
|
|
97
|
+
/**
|
|
98
|
+
* `TimingParamsV1` as the API serves it (camelCase). `minHoldMs` is a u64 (Move `min_hold_ms`);
|
|
99
|
+
* read it with `marketMinHoldMs`. Close fills use the hold snapshotted at request.
|
|
100
|
+
*/
|
|
101
|
+
export interface ParchmentMarketTiming {
|
|
102
|
+
minHoldMs?: bigint;
|
|
103
|
+
}
|
|
104
|
+
/** `OracleParamsV1` as the API serves it (camelCase). `minSpreadBps` is the floor of the one-step spread. */
|
|
105
|
+
export interface ParchmentMarketOracle {
|
|
106
|
+
storageId: string;
|
|
107
|
+
sourceId: bigint;
|
|
108
|
+
feedInfoId: string;
|
|
109
|
+
lazerFeedId: bigint;
|
|
110
|
+
maxAgeMs: bigint;
|
|
111
|
+
maxConfAgeMs: bigint;
|
|
112
|
+
maxFutureMs: bigint;
|
|
113
|
+
maxTwapDevBps: bigint;
|
|
114
|
+
minSpreadBps: bigint;
|
|
115
|
+
}
|
|
116
|
+
/** `RiskParamsV1` as the API serves it (camelCase; USDC base units, `bustBufferWad` a WAD fraction of entry). */
|
|
117
|
+
export interface ParchmentMarketRisk {
|
|
118
|
+
minLeverage: bigint;
|
|
119
|
+
maxLeverage: bigint;
|
|
120
|
+
bustBufferWad: bigint;
|
|
121
|
+
minMargin: bigint;
|
|
122
|
+
minNotional: bigint;
|
|
123
|
+
maxPositionNotional: bigint;
|
|
124
|
+
maxTxNotional: bigint;
|
|
125
|
+
maxBlockNotional: bigint;
|
|
126
|
+
maxAccountNotional: bigint;
|
|
127
|
+
liqBountyBps: bigint;
|
|
128
|
+
}
|
|
129
|
+
/** `ImpactParamsV1` as the API serves it (camelCase). */
|
|
130
|
+
export interface ParchmentMarketImpact {
|
|
131
|
+
cNum: bigint;
|
|
132
|
+
cDen: bigint;
|
|
133
|
+
deadbandDiv: bigint;
|
|
134
|
+
referenceNotional: bigint;
|
|
135
|
+
pNum: bigint;
|
|
136
|
+
pDen: bigint;
|
|
137
|
+
effectiveDepth: bigint;
|
|
138
|
+
deadbandPpm: bigint;
|
|
139
|
+
closeFeePpm: bigint;
|
|
140
|
+
}
|
|
141
|
+
export interface ParchmentMarketView {
|
|
142
|
+
marketId: string;
|
|
143
|
+
symbol: string | null;
|
|
144
|
+
kind: bigint | null;
|
|
145
|
+
/** `market::status`: 1 active, 2 reduce-only, 3 retired (`MARKET_STATUS_*`); null when unindexed. */
|
|
146
|
+
status: bigint | null;
|
|
147
|
+
enabled: boolean | null;
|
|
148
|
+
opensPaused: boolean | null;
|
|
149
|
+
/**
|
|
150
|
+
* While true new open requests abort `order::ERequestsPaused` (15) and a pending open's fill refunds with
|
|
151
|
+
* outcome 5 (`paused`, full escrow including the exec fee). Close requests, close fills (including
|
|
152
|
+
* liquidate-on-close), emergency close, close-retired, add-margin, liquidate and sweep all still run; a
|
|
153
|
+
* pending close that expires under it refunds with outcome 5.
|
|
154
|
+
*/
|
|
155
|
+
closesPaused: boolean | null;
|
|
156
|
+
/**
|
|
157
|
+
* While true, liquidation, sweep, emergency close and close-retired abort `trade::EOracleKilled` (20); requests
|
|
158
|
+
* abort `order::ERequestsPaused` (15); a pending order's fill refunds with outcome 6 (`killed`, full escrow
|
|
159
|
+
* including the exec fee). The only flag that stops liquidation and exits.
|
|
160
|
+
*/
|
|
161
|
+
oracleKilled: boolean | null;
|
|
162
|
+
/**
|
|
163
|
+
* True while liquidation on this market is stopped, which is only its oracle kill switch
|
|
164
|
+
* (`trade::EOracleKilled` 20), served on `/v1/markets` and `/v1/markets/{id}`.
|
|
165
|
+
* `null` when unindexed; older services omit it. `liquidationPaused(market)` honours it.
|
|
166
|
+
*/
|
|
167
|
+
liquidationPaused?: boolean | null;
|
|
168
|
+
takerFeeBps: bigint | null;
|
|
169
|
+
winFeeBps: bigint | null;
|
|
170
|
+
/** Null when the market has no indexed oracle / risk / impact params. */
|
|
171
|
+
oracle: ParchmentMarketOracle | null;
|
|
172
|
+
risk: ParchmentMarketRisk | null;
|
|
173
|
+
impact: ParchmentMarketImpact | null;
|
|
174
|
+
/** Null when the market has no indexed timing params. */
|
|
175
|
+
timing: ParchmentMarketTiming | null;
|
|
176
|
+
longOi: bigint;
|
|
177
|
+
shortOi: bigint;
|
|
178
|
+
longLockedExposure: bigint;
|
|
179
|
+
shortLockedExposure: bigint;
|
|
180
|
+
lastOracleTsMs: bigint | null;
|
|
181
|
+
lastOracleSequence: bigint | null;
|
|
182
|
+
lastOracleSlot: bigint | null;
|
|
183
|
+
paramsStale: boolean;
|
|
184
|
+
/** The exchange this market is bound to (`market::exchange_id`, fixed at `register_market`). */
|
|
185
|
+
exchangeId: string | null;
|
|
186
|
+
/**
|
|
187
|
+
* Per-side open-interest notional caps in micro-USDC (`market::max_long_oi` / `max_short_oi`).
|
|
188
|
+
* Opens past a cap abort `trade::EOiNotionalCap` (29).
|
|
189
|
+
*/
|
|
190
|
+
maxLongOi: bigint | null;
|
|
191
|
+
maxShortOi: bigint | null;
|
|
192
|
+
/** Per-side caps on locked winning exposure (`market::max_long_exposure` / `max_short_exposure`). Absent on older services. */
|
|
193
|
+
maxLongExposure?: bigint | null;
|
|
194
|
+
maxShortExposure?: bigint | null;
|
|
195
|
+
/**
|
|
196
|
+
* `OrderParamsV1.one_step_spread_bps` in bps: the spread floor that one-step exits
|
|
197
|
+
* (emergency close, `close_retired`) pay. Absent on services that predate it.
|
|
198
|
+
*/
|
|
199
|
+
oneStepSpreadBps?: bigint;
|
|
200
|
+
/**
|
|
201
|
+
* `OrderParamsV1.cancel_delay_ms`: how long after a request it can be cancelled when the order has
|
|
202
|
+
* no stored `cancelAfterMs`. Null while the market has no order params; absent on older services.
|
|
203
|
+
*/
|
|
204
|
+
cancelDelayMs?: bigint | null;
|
|
205
|
+
/**
|
|
206
|
+
* True when the service indexed the market but it is missing from the configured Registry's
|
|
207
|
+
* `market_ids` (the contract has no removal today; the chain still accepts requests on a market
|
|
208
|
+
* with status 1). The service keeps its row and history and still lists it, but stops polling its
|
|
209
|
+
* storage, so its price can go stale; the keeper still serves its open positions. Absent on
|
|
210
|
+
* services that predate it (read it with `marketIsDelisted`).
|
|
211
|
+
*/
|
|
212
|
+
delisted?: boolean;
|
|
213
|
+
/** `"equity"` for markets with trading sessions (force-closed at each session end). Absent on older services. */
|
|
214
|
+
hoursMode?: string | null;
|
|
215
|
+
/** `"draining"` while the on-chain session close is armed and positions are still being closed. */
|
|
216
|
+
sessionState?: ParchmentSessionState | null;
|
|
217
|
+
/** End of the current session (ms); every open position on the market is force-closed then. Null when not equity or closed. */
|
|
218
|
+
sessionEndsAtMs?: bigint | null;
|
|
219
|
+
/** Start of the next session (ms) while closed or draining. */
|
|
220
|
+
nextSessionOpenMs?: bigint | null;
|
|
221
|
+
price: ParchmentPrice;
|
|
222
|
+
}
|
|
223
|
+
/** Equity session state served on market reads. */
|
|
224
|
+
export type ParchmentSessionState = "open" | "closed" | "draining";
|
|
225
|
+
export interface ApiParchmentMarketsResponse {
|
|
226
|
+
markets: ParchmentMarketView[];
|
|
227
|
+
}
|
|
228
|
+
export interface ApiParchmentMarketResponse {
|
|
229
|
+
market: ParchmentMarketView;
|
|
230
|
+
}
|
|
231
|
+
export interface ParchmentPricePoint {
|
|
232
|
+
timestampMs: bigint;
|
|
233
|
+
priceWad: bigint;
|
|
234
|
+
twapWad: bigint | null;
|
|
235
|
+
source: string;
|
|
236
|
+
}
|
|
237
|
+
export interface ApiParchmentPriceHistoryBody {
|
|
238
|
+
marketId: string;
|
|
239
|
+
fromMs?: string | bigint;
|
|
240
|
+
toMs?: string | bigint;
|
|
241
|
+
/** 1..=u64::MAX (`bad_request` otherwise, no request); the service clamps to its max page. */
|
|
242
|
+
limit?: string | number | bigint;
|
|
243
|
+
}
|
|
244
|
+
export interface ApiParchmentPriceHistoryResponse {
|
|
245
|
+
points: ParchmentPricePoint[];
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* A candle's interval, aligned on the Unix epoch (UTC: `4h` buckets start at 00:00, 04:00, …, `1d` at midnight).
|
|
249
|
+
* `1s`, `5s` and `15s` are bucketed from the service's 1 s Lazer price bars (`price_bars_1s`); a service without
|
|
250
|
+
* them answers 400 for them. `1s` and `5s` fill a quiet slot of a live 15 s bucket with a flat candle at the
|
|
251
|
+
* previous close; a missing 15 s bucket (an outage) stays a gap. The day is lowercase on the wire (`1d`).
|
|
252
|
+
*/
|
|
253
|
+
export type ParchmentCandleResolution = "1s" | "5s" | "15s" | "1m" | "5m" | "15m" | "1h" | "4h" | "1d";
|
|
254
|
+
/** One candle: `timeMs` is its interval's start; the first, highest, lowest and last price point (WAD). */
|
|
255
|
+
export interface ParchmentCandle {
|
|
256
|
+
timeMs: bigint;
|
|
257
|
+
openWad: bigint;
|
|
258
|
+
highWad: bigint;
|
|
259
|
+
lowWad: bigint;
|
|
260
|
+
closeWad: bigint;
|
|
261
|
+
}
|
|
262
|
+
export interface ApiParchmentCandlesBody {
|
|
263
|
+
marketId: string;
|
|
264
|
+
resolution: ParchmentCandleResolution;
|
|
265
|
+
/** Inclusive; raised to the start of the `limit`th newest interval up to `toMs`. */
|
|
266
|
+
fromMs?: string | bigint;
|
|
267
|
+
/** Inclusive; default now. */
|
|
268
|
+
toMs?: string | bigint;
|
|
269
|
+
/** Newest intervals read, 1..=u64::MAX; the service serves at most 500 (its default). */
|
|
270
|
+
limit?: string | number | bigint;
|
|
271
|
+
}
|
|
272
|
+
/** `GET /markets/{id}/candles`: oldest first; an interval without a price point has no candle. */
|
|
273
|
+
export interface ApiParchmentCandlesResponse {
|
|
274
|
+
candles: ParchmentCandle[];
|
|
275
|
+
}
|
|
276
|
+
/** The most markets one `GET /markets/candles` reads (the service answers 400 `too_many_markets` past it). */
|
|
277
|
+
export declare const PARCHMENT_CANDLES_BATCH_MAX_MARKETS = 12;
|
|
278
|
+
/**
|
|
279
|
+
* `GET /markets/candles`: {@link ApiParchmentCandlesBody} for several markets at once. `resolution`, `fromMs`,
|
|
280
|
+
* `toMs` and `limit` apply to every market (one window for the batch).
|
|
281
|
+
*/
|
|
282
|
+
export interface ApiParchmentCandlesBatchBody {
|
|
283
|
+
/** 1..=12 market ids, counted after normalizing and dropping repeats (the first occurrence keeps its place). */
|
|
284
|
+
marketIds: readonly string[];
|
|
285
|
+
resolution: ParchmentCandleResolution;
|
|
286
|
+
/** Inclusive; raised, per market, to the start of the `limit`th newest interval up to `toMs`. */
|
|
287
|
+
fromMs?: string | bigint;
|
|
288
|
+
/** Inclusive; default now. */
|
|
289
|
+
toMs?: string | bigint;
|
|
290
|
+
/** Newest intervals read per market, 1..=u64::MAX; the service serves at most 500 (its default). */
|
|
291
|
+
limit?: string | number | bigint;
|
|
292
|
+
}
|
|
293
|
+
/** One market's candles in a batch: what `GET /markets/{id}/candles` answers for it. */
|
|
294
|
+
export interface ParchmentCandlesBatchCandles {
|
|
295
|
+
marketId: string;
|
|
296
|
+
candles: ParchmentCandle[];
|
|
297
|
+
error?: undefined;
|
|
298
|
+
}
|
|
299
|
+
/** One market's failure in a batch (e.g. an unknown market); the other markets are still served. */
|
|
300
|
+
export interface ParchmentCandlesBatchError {
|
|
301
|
+
marketId: string;
|
|
302
|
+
candles?: undefined;
|
|
303
|
+
error: {
|
|
304
|
+
code: string;
|
|
305
|
+
message: string;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
export type ParchmentCandlesBatchSeries = ParchmentCandlesBatchCandles | ParchmentCandlesBatchError;
|
|
309
|
+
/**
|
|
310
|
+
* `GET /markets/candles`: one entry per requested market, in request order; a market's failure is its own
|
|
311
|
+
* `error`, never the batch's. Each market's candles are oldest first, as from `GET /markets/{id}/candles`.
|
|
312
|
+
*/
|
|
313
|
+
export interface ApiParchmentCandlesBatchResponse {
|
|
314
|
+
resolution: ParchmentCandleResolution;
|
|
315
|
+
/** The service's clock when it answered (ms). */
|
|
316
|
+
serverTimeMs: bigint;
|
|
317
|
+
series: ParchmentCandlesBatchSeries[];
|
|
318
|
+
}
|
|
319
|
+
export interface ParchmentPinPrice {
|
|
320
|
+
symbol: string;
|
|
321
|
+
storageId: string;
|
|
322
|
+
sourceId: bigint;
|
|
323
|
+
lazerFeedId: bigint;
|
|
324
|
+
status: string;
|
|
325
|
+
reason: string | null;
|
|
326
|
+
priceWad: bigint | null;
|
|
327
|
+
twapWad: bigint | null;
|
|
328
|
+
timestampMs: bigint | null;
|
|
329
|
+
ageMs?: bigint | null;
|
|
330
|
+
stale?: boolean;
|
|
331
|
+
}
|
|
332
|
+
export interface ApiParchmentPricesResponse {
|
|
333
|
+
markets: Array<ParchmentPrice & {
|
|
334
|
+
marketId: string;
|
|
335
|
+
symbol: string | null;
|
|
336
|
+
}>;
|
|
337
|
+
pins: ParchmentPinPrice[];
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* One `price` event of `GET prices/stream` (Server-Sent Events): a market's live Pyth Lazer index
|
|
341
|
+
* price. Display only (charts): marks, fills, PnL and liquidation use the on-chain storage price
|
|
342
|
+
* of {@link ApiParchmentPricesResponse}, which can lag or differ.
|
|
343
|
+
*/
|
|
344
|
+
export interface ParchmentLivePrice {
|
|
345
|
+
marketId: string;
|
|
346
|
+
symbol: string | null;
|
|
347
|
+
/** 1e18-scaled. */
|
|
348
|
+
priceWad: bigint;
|
|
349
|
+
/** The Lazer `feed_update_timestamp` (ms). */
|
|
350
|
+
timestampMs: bigint;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* One `trade` event of `GET trades/stream` (Server-Sent Events): an open, close or liquidation by
|
|
354
|
+
* any trader, sent once the service has indexed it. Amounts are USDC base units.
|
|
355
|
+
*/
|
|
356
|
+
export interface ParchmentTrade {
|
|
357
|
+
/** Increases with every trade; resume a stream after it (`tradesStreamUrl({ after })`). */
|
|
358
|
+
id: bigint;
|
|
359
|
+
action: "open" | "close" | "liquidate";
|
|
360
|
+
marketId: string;
|
|
361
|
+
symbol: string | null;
|
|
362
|
+
side: "long" | "short" | null;
|
|
363
|
+
/** The position owner's address. */
|
|
364
|
+
owner: string;
|
|
365
|
+
positionId: bigint;
|
|
366
|
+
notional: bigint;
|
|
367
|
+
margin: bigint;
|
|
368
|
+
/** Realized PnL of a close or liquidation; null on opens. */
|
|
369
|
+
pnl: bigint | null;
|
|
370
|
+
timestampMs: bigint;
|
|
371
|
+
}
|
|
372
|
+
export interface ParchmentPosition {
|
|
373
|
+
positionId: bigint;
|
|
374
|
+
accountId: string | null;
|
|
375
|
+
owner: string;
|
|
376
|
+
marketId: string;
|
|
377
|
+
trader: string;
|
|
378
|
+
attribution: string;
|
|
379
|
+
isLong: boolean;
|
|
380
|
+
midWad: bigint | null;
|
|
381
|
+
confWad: bigint | null;
|
|
382
|
+
entryWad: bigint | null;
|
|
383
|
+
bustWad: bigint | null;
|
|
384
|
+
margin: bigint | null;
|
|
385
|
+
notional: bigint | null;
|
|
386
|
+
leverage: bigint | null;
|
|
387
|
+
factorBps: bigint | null;
|
|
388
|
+
winningExposure: bigint | null;
|
|
389
|
+
winFeeBps: bigint | null;
|
|
390
|
+
deadbandPpm: bigint | null;
|
|
391
|
+
closeFeePpm: bigint | null;
|
|
392
|
+
openedAtMs: bigint | null;
|
|
393
|
+
openTx: string | null;
|
|
394
|
+
status: string;
|
|
395
|
+
/** Equity markets: when this position is force-closed at session end (ms). Null otherwise; absent on older services. */
|
|
396
|
+
autoCloseAtMs?: bigint | null;
|
|
397
|
+
/** Take-profit price (1e18), set or closing the position. Null when unset. */
|
|
398
|
+
takeProfitWad: bigint | null;
|
|
399
|
+
/** Stop-loss price (1e18), set or closing the position. Null when unset. */
|
|
400
|
+
stopLossWad: bigint | null;
|
|
401
|
+
/** Why the stop signed with the open was not armed: past the filled position's liquidation. Null otherwise. */
|
|
402
|
+
slDroppedReason: "past_liquidation_at_fill" | null;
|
|
403
|
+
/** The filled position's liquidation (1e18) when its stop was dropped. Null otherwise. */
|
|
404
|
+
fillBustWad: bigint | null;
|
|
405
|
+
/** How a closed position exited (`PositionExitEventV1.kind`). Null while open; absent on older services. */
|
|
406
|
+
exitKind?: ParchmentExitKind | null;
|
|
407
|
+
}
|
|
408
|
+
/** `PositionView.exitKind`: plain close, liquidation, or equity session force close. */
|
|
409
|
+
export type ParchmentExitKind = "close" | "liquidation" | "session";
|
|
410
|
+
export interface ApiParchmentPositionsResponse {
|
|
411
|
+
positions: ParchmentPosition[];
|
|
412
|
+
/** Next page's `cursor` (position id); null on the last page. Older services omit it. */
|
|
413
|
+
nextCursor?: string | null;
|
|
414
|
+
}
|
|
415
|
+
/** Optional keyset page for paged reads (service default 50). Follow `nextCursor` until it is null; an exactly-full last page already returns null (the service limit+1 paging). */
|
|
416
|
+
export interface ParchmentPageQuery {
|
|
417
|
+
limit?: number | bigint;
|
|
418
|
+
cursor?: string | number | bigint | null;
|
|
419
|
+
}
|
|
420
|
+
/** History `deposit` / `withdraw` payload. */
|
|
421
|
+
export interface ParchmentAmountPayload {
|
|
422
|
+
amount: bigint;
|
|
423
|
+
}
|
|
424
|
+
/** History `open` payload (`OpenPositionEventV1`, camelCase). Opens pay a builder nothing. */
|
|
425
|
+
export interface ParchmentOpenPayload {
|
|
426
|
+
builderId: bigint | null;
|
|
427
|
+
positionId: bigint;
|
|
428
|
+
accountId: string;
|
|
429
|
+
marketId: string;
|
|
430
|
+
isLong: boolean;
|
|
431
|
+
midWad: bigint;
|
|
432
|
+
confWad: bigint;
|
|
433
|
+
entryWad: bigint;
|
|
434
|
+
bustWad: bigint;
|
|
435
|
+
margin: bigint;
|
|
436
|
+
notional: bigint;
|
|
437
|
+
factorBps: bigint;
|
|
438
|
+
winningExposure: bigint;
|
|
439
|
+
winFeeBps: bigint;
|
|
440
|
+
deadbandPpm: bigint;
|
|
441
|
+
closeFeePpm: bigint;
|
|
442
|
+
}
|
|
443
|
+
/** History `close` payload (`ClosePositionEventV1`, camelCase). Carries no close charge. */
|
|
444
|
+
export interface ParchmentClosePayload {
|
|
445
|
+
positionId: bigint;
|
|
446
|
+
accountId: string;
|
|
447
|
+
gross: bigint;
|
|
448
|
+
haircut: bigint;
|
|
449
|
+
fee: bigint;
|
|
450
|
+
net: bigint;
|
|
451
|
+
queued: boolean;
|
|
452
|
+
builderId: bigint | null;
|
|
453
|
+
/** The approved builder's on-top fee taken from this close's profit (paid now or queued). */
|
|
454
|
+
builderAmount: bigint;
|
|
455
|
+
exitWad: bigint | null;
|
|
456
|
+
exitKind: string | null;
|
|
457
|
+
}
|
|
458
|
+
/** History `liquidate` payload (`LiquidatePositionEventV1`, camelCase). */
|
|
459
|
+
export interface ParchmentLiquidatePayload {
|
|
460
|
+
positionId: bigint;
|
|
461
|
+
accountId: string;
|
|
462
|
+
bounty: bigint;
|
|
463
|
+
toLp: bigint;
|
|
464
|
+
exitWad: bigint | null;
|
|
465
|
+
exitKind: string | null;
|
|
466
|
+
liquidator: string;
|
|
467
|
+
swept?: boolean | null;
|
|
468
|
+
}
|
|
469
|
+
export interface ParchmentActivity {
|
|
470
|
+
id: bigint;
|
|
471
|
+
kind: string;
|
|
472
|
+
marketId: string | null;
|
|
473
|
+
positionId: bigint | null;
|
|
474
|
+
accountId: string | null;
|
|
475
|
+
txDigest: string;
|
|
476
|
+
timestampMs: bigint;
|
|
477
|
+
/** By `kind`: `ParchmentAmountPayload`, `ParchmentOpenPayload`, `ParchmentClosePayload` or `ParchmentLiquidatePayload`. */
|
|
478
|
+
payload: ParchmentAmountPayload | ParchmentOpenPayload | ParchmentClosePayload | ParchmentLiquidatePayload | null;
|
|
479
|
+
/** `tp` or `sl` when this close is the one a take-profit or stop-loss requested. Null otherwise. */
|
|
480
|
+
triggerKind: "tp" | "sl" | null;
|
|
481
|
+
/** That trigger's price (1e18). Null when `triggerKind` is null. */
|
|
482
|
+
triggerPriceWad: bigint | null;
|
|
483
|
+
}
|
|
484
|
+
export interface ApiParchmentHistoryBody {
|
|
485
|
+
walletAddress: string;
|
|
486
|
+
/** A page's `nextCursor`; null or blank is omitted. */
|
|
487
|
+
cursor?: string | number | bigint | null;
|
|
488
|
+
limit?: string | number | bigint;
|
|
489
|
+
}
|
|
490
|
+
export interface ApiParchmentHistoryResponse {
|
|
491
|
+
items: ParchmentActivity[];
|
|
492
|
+
nextCursor: string | null;
|
|
493
|
+
}
|
|
494
|
+
/** The windows `GET accounts/{owner}/equity` serves. */
|
|
495
|
+
export type ParchmentEquityRange = "24h" | "7d" | "30d" | "all";
|
|
496
|
+
export interface ApiParchmentEquityHistoryBody {
|
|
497
|
+
walletAddress: string;
|
|
498
|
+
range: ParchmentEquityRange;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* One hourly equity snapshot (USDC base units). `equity` = `free` + `margin` + `unrealizedPnl`
|
|
502
|
+
* summed over the owner's trading accounts, the open positions valued at what closing them at the
|
|
503
|
+
* indexed oracle mid would pay after fees; `unpricedPositions` were counted at their margin.
|
|
504
|
+
*/
|
|
505
|
+
export interface ParchmentEquityPoint {
|
|
506
|
+
tsMs: bigint;
|
|
507
|
+
equity: bigint;
|
|
508
|
+
free: bigint;
|
|
509
|
+
margin: bigint;
|
|
510
|
+
/** Negative while the open positions are under water. */
|
|
511
|
+
unrealizedPnl: bigint;
|
|
512
|
+
openPositions: bigint;
|
|
513
|
+
unpricedPositions: bigint;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* `GET accounts/{owner}/equity?range=`: oldest first, at most 500 points; the first point is the
|
|
517
|
+
* last snapshot at or before `fromMs` (null for `all`). Hourly rows, the hour's latest observation;
|
|
518
|
+
* an account with no open position has a row only when its equity changed.
|
|
519
|
+
*/
|
|
520
|
+
export interface ApiParchmentEquityHistoryResponse {
|
|
521
|
+
range: ParchmentEquityRange;
|
|
522
|
+
bucketMs: bigint;
|
|
523
|
+
fromMs: bigint | null;
|
|
524
|
+
toMs: bigint;
|
|
525
|
+
points: ParchmentEquityPoint[];
|
|
526
|
+
/** The equity now, from one read of balances, positions and prices; null without an account or while the indexer lags. */
|
|
527
|
+
current: ParchmentEquityPoint | null;
|
|
528
|
+
}
|
|
529
|
+
export interface ParchmentDelegate {
|
|
530
|
+
delegate: string;
|
|
531
|
+
expiryMs: bigint;
|
|
532
|
+
}
|
|
533
|
+
export interface ParchmentAccountRecord {
|
|
534
|
+
accountId: string;
|
|
535
|
+
owner: string;
|
|
536
|
+
exchangeId: string | null;
|
|
537
|
+
free: bigint;
|
|
538
|
+
openNotional: bigint;
|
|
539
|
+
delegates: ParchmentDelegate[];
|
|
540
|
+
/**
|
|
541
|
+
* Live order requests on this account (`Account.pending_orders`; open and close, still pending).
|
|
542
|
+
* Display only: closes are never capped. Absent on older services.
|
|
543
|
+
*/
|
|
544
|
+
pendingOrders?: bigint;
|
|
545
|
+
/**
|
|
546
|
+
* Live OPEN requests on this account (`order::pending_open_orders`: pending requests minus pending closes). Only opens count toward
|
|
547
|
+
* `getConfig().maxPendingOrders`: compare via `hasPendingOrderSlot`. Absent on older services.
|
|
548
|
+
*/
|
|
549
|
+
pendingOpenOrders?: bigint;
|
|
550
|
+
/**
|
|
551
|
+
* Parked mint basis (USDC base units) claimable with `claimPendingMintTxBody`: eligible trader losses from
|
|
552
|
+
* liquidations this account was not part of (a keeper's parks the forfeited margin including the bounty, an
|
|
553
|
+
* outsider's only the real price loss; the owner's or a delegate's parks nothing).
|
|
554
|
+
* Absent on older services.
|
|
555
|
+
*/
|
|
556
|
+
pendingMintBasis?: bigint;
|
|
557
|
+
/**
|
|
558
|
+
* UPPER-BOUND estimate of the PARCHMENT raw units (9 decimals) the parked basis mints, at the current
|
|
559
|
+
* mint rate (current H). The claim mints at the H and remaining reward supply at claim time, so it
|
|
560
|
+
* may mint less, including zero (the service does not index the remaining supply). No per-account
|
|
561
|
+
* time-window cap. Absent on older services.
|
|
562
|
+
*/
|
|
563
|
+
pendingMint?: bigint;
|
|
564
|
+
/** Total delegate count; `delegates` is capped at the page limit. Absent on older services. */
|
|
565
|
+
delegatesCount?: bigint;
|
|
566
|
+
/**
|
|
567
|
+
* The wallet that opened the account (the derivation key's `opener`); differs from `owner` after a
|
|
568
|
+
* `transfer-account`. Absent on older services.
|
|
569
|
+
*/
|
|
570
|
+
opener?: string | null;
|
|
571
|
+
/** The opener's derivation nonce for this account (`AccountKey { opener, nonce }`). Absent on older services. */
|
|
572
|
+
nonce?: bigint | null;
|
|
573
|
+
/**
|
|
574
|
+
* Close-only delegates (take-profit and stop-loss): they can only close this account's positions
|
|
575
|
+
* and never expire; `getRevokeDelegateTx` removes one.
|
|
576
|
+
*/
|
|
577
|
+
closeDelegates: string[];
|
|
578
|
+
}
|
|
579
|
+
export interface ParchmentClaim {
|
|
580
|
+
claimId: bigint;
|
|
581
|
+
positionId: bigint | null;
|
|
582
|
+
owner: string | null;
|
|
583
|
+
accountId: string | null;
|
|
584
|
+
net: bigint;
|
|
585
|
+
status: string;
|
|
586
|
+
enqueuedTx: string | null;
|
|
587
|
+
harvestedTx: string | null;
|
|
588
|
+
timestampMs: bigint | null;
|
|
589
|
+
/** Net still owed after partial harvests (service `remaining`); use it, not `net`, for what is owed. Absent on older services. */
|
|
590
|
+
remaining?: bigint;
|
|
591
|
+
/** Protocol fee still queued with the claim; null until its queue node is indexed. Absent on older services. */
|
|
592
|
+
feeRemaining?: bigint | null;
|
|
593
|
+
/** Builder on-top fee still queued with the claim (paid after the net); null until its queue node is indexed. */
|
|
594
|
+
onTopRemaining?: bigint | null;
|
|
595
|
+
}
|
|
596
|
+
export interface ApiParchmentAccountResponse {
|
|
597
|
+
owner: string;
|
|
598
|
+
/**
|
|
599
|
+
* The derivation nonce of the next account this wallet opens (`deriveAccountId({ ..., nonce })`): the number of
|
|
600
|
+
* accounts it opened before. 0 unless it transferred accounts away. Absent on older services.
|
|
601
|
+
*/
|
|
602
|
+
nextAccountNonce?: bigint;
|
|
603
|
+
accounts: ParchmentAccountRecord[];
|
|
604
|
+
/** Pass as `accountsCursor` for the next page; null on the last page. Older services omit it. */
|
|
605
|
+
accountsNextCursor?: string | null;
|
|
606
|
+
positions: ParchmentPosition[];
|
|
607
|
+
/** Pass as `positionsCursor` for the next page; null on the last page. */
|
|
608
|
+
positionsNextCursor?: string | null;
|
|
609
|
+
queue: {
|
|
610
|
+
claims: ParchmentClaim[];
|
|
611
|
+
/** Pass as `claimsCursor` for the next page; null on the last page. */
|
|
612
|
+
claimsNextCursor?: string | null;
|
|
613
|
+
aheadCount: bigint;
|
|
614
|
+
aheadNet: bigint;
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
/** Protocol FIFO queue. Amounts are base units. Cash fields are null until known. */
|
|
618
|
+
export interface ParchmentQueue {
|
|
619
|
+
length: bigint;
|
|
620
|
+
totalOwed: bigint;
|
|
621
|
+
lpCash: bigint | null;
|
|
622
|
+
instantlyPayable: bigint | null;
|
|
623
|
+
}
|
|
624
|
+
/** One wallet's place in the FIFO queue. `rank` is null when `hasClaim` is false. */
|
|
625
|
+
export interface ParchmentAccountQueue {
|
|
626
|
+
hasClaim: boolean;
|
|
627
|
+
net: bigint;
|
|
628
|
+
owner: string;
|
|
629
|
+
rank: bigint | null;
|
|
630
|
+
}
|
|
631
|
+
/** Live sweep settings from indexed Config and setter history. Cash is USDC base units (6 dp). */
|
|
632
|
+
export interface ParchmentSweepParams {
|
|
633
|
+
floorBps: bigint;
|
|
634
|
+
maxBps: bigint;
|
|
635
|
+
intervalMs: bigint;
|
|
636
|
+
capBps: bigint;
|
|
637
|
+
cashFloor: bigint;
|
|
638
|
+
stakerBps: bigint;
|
|
639
|
+
treasuryBps: bigint;
|
|
640
|
+
growthBps: bigint;
|
|
641
|
+
}
|
|
642
|
+
export interface ApiParchmentLpResponse {
|
|
643
|
+
/** Null before Config indexing; absent on older services. Display estimates, never tx gates. */
|
|
644
|
+
sweep?: ParchmentSweepParams | null;
|
|
645
|
+
lpCash: bigint | null;
|
|
646
|
+
trackedLp: bigint | null;
|
|
647
|
+
equity: bigint | null;
|
|
648
|
+
totalOwed: bigint;
|
|
649
|
+
totalOwedSource: string;
|
|
650
|
+
queueLength: bigint;
|
|
651
|
+
feeLp: bigint | null;
|
|
652
|
+
feeStaker: bigint | null;
|
|
653
|
+
feeDev: bigint | null;
|
|
654
|
+
userFree: bigint | null;
|
|
655
|
+
lockedMargin: bigint | null;
|
|
656
|
+
tailProgress: bigint | null;
|
|
657
|
+
/** Growth share of surplus sweeps. There is no insurance fund. */
|
|
658
|
+
feeGrowth: bigint | null;
|
|
659
|
+
/**
|
|
660
|
+
* Stakers' share (bps) of the next retained fee at the current coverage, and the curve it comes
|
|
661
|
+
* from (`config::set_retained_fee_curve`): `stakerShareMinBps` at coverage <= `stakerCovLowBps`,
|
|
662
|
+
* linear to `stakerShareMaxBps` at >= `stakerCovHighBps` (launch 30% -> 70% between 100% and 200%).
|
|
663
|
+
* Read the curve with `lpRetainedFeeCurve`. Null until indexed; absent on older services.
|
|
664
|
+
*/
|
|
665
|
+
stakerShareBps?: bigint | null;
|
|
666
|
+
stakerShareMinBps?: bigint | null;
|
|
667
|
+
stakerShareMaxBps?: bigint | null;
|
|
668
|
+
stakerCovLowBps?: bigint | null;
|
|
669
|
+
stakerCovHighBps?: bigint | null;
|
|
670
|
+
/** Positive open PnL across markets (last per-market snapshots). */
|
|
671
|
+
reserveUpnl: bigint | null;
|
|
672
|
+
/** Stress cushion across markets (larger side x stress bps x trim share). */
|
|
673
|
+
reserveStress: bigint | null;
|
|
674
|
+
/** totalOwed + reserveUpnl + reserveStress (the contract's `exchange::reserve`). */
|
|
675
|
+
reserve: bigint | null;
|
|
676
|
+
lastSurplusMs: bigint | null;
|
|
677
|
+
/**
|
|
678
|
+
* A `ReserveCheck` begun at an older epoch aborts `exchange::ECheckStale` (11). Nothing bumps it since the signed band was removed; the field stays in the Exchange layout.
|
|
679
|
+
*/
|
|
680
|
+
reserveEpoch: bigint | null;
|
|
681
|
+
/**
|
|
682
|
+
* Markets in the exchange's `oi_set` (snapshot covers open interest). A sweep-surplus
|
|
683
|
+
* transaction must re-price every one of them.
|
|
684
|
+
*/
|
|
685
|
+
oiMarkets: bigint | null;
|
|
686
|
+
paused: boolean | null;
|
|
687
|
+
/**
|
|
688
|
+
* Global close pause, on every market: open requests abort `order::ERequestsPaused` and pending open fills
|
|
689
|
+
* refund with outcome 5. Closes, emergency close, close-retired, liquidate and sweep still run.
|
|
690
|
+
*/
|
|
691
|
+
closesPaused: boolean | null;
|
|
692
|
+
head: ParchmentClaim | null;
|
|
693
|
+
claims: ParchmentClaim[];
|
|
694
|
+
note: string;
|
|
695
|
+
}
|
|
696
|
+
export interface ApiParchmentReferralBind {
|
|
697
|
+
address: string;
|
|
698
|
+
boundAtMs: bigint;
|
|
699
|
+
}
|
|
700
|
+
export interface ApiParchmentReferralsResponse {
|
|
701
|
+
address: string;
|
|
702
|
+
asReferee: {
|
|
703
|
+
referrer: string;
|
|
704
|
+
boundAtMs: bigint;
|
|
705
|
+
} | null;
|
|
706
|
+
asReferrer: {
|
|
707
|
+
direct: ApiParchmentReferralBind[];
|
|
708
|
+
/** Pass as `directCursor` for the next page; null on the last page. Older services omit it. */
|
|
709
|
+
directNextCursor?: string | null;
|
|
710
|
+
secondLevel: Array<ApiParchmentReferralBind & {
|
|
711
|
+
via: string;
|
|
712
|
+
}>;
|
|
713
|
+
/** Pass as `secondLevelCursor` for the next page; null on the last page. */
|
|
714
|
+
secondLevelNextCursor?: string | null;
|
|
715
|
+
/** Total direct / second-level referees (the lists are paged). Absent on older services. */
|
|
716
|
+
directCount?: bigint;
|
|
717
|
+
secondLevelCount?: bigint;
|
|
718
|
+
refereeClaimVolume: bigint;
|
|
719
|
+
/** Estimate of the bonus accrued to date, paid or still owed (a short treasury leaves the rest owed). Not `staking::referral_owed`. */
|
|
720
|
+
estimatedDirectBonus: bigint;
|
|
721
|
+
/** Estimate of the bonus accrued to date, paid or still owed (a short treasury leaves the rest owed). Not `staking::referral_owed`. */
|
|
722
|
+
estimatedSecondBonus: bigint;
|
|
723
|
+
};
|
|
724
|
+
/** Wording returned with the figures. These bonuses are not settled amounts. */
|
|
725
|
+
estimate: string;
|
|
726
|
+
}
|
|
727
|
+
export interface ApiParchmentProtocolResponse {
|
|
728
|
+
openPositions: bigint;
|
|
729
|
+
openNotional: bigint;
|
|
730
|
+
volumeNotional: bigint;
|
|
731
|
+
equity: bigint | null;
|
|
732
|
+
lpCash: bigint | null;
|
|
733
|
+
queueLength: bigint;
|
|
734
|
+
paused: boolean | null;
|
|
735
|
+
/**
|
|
736
|
+
* Exchange-wide close pause, same flag as `getLp().closesPaused`. The service serves it as
|
|
737
|
+
* a boolean (`false` until indexed); optional only for older services, which omit it. It does not stop
|
|
738
|
+
* liquidation or exits.
|
|
739
|
+
*/
|
|
740
|
+
closesPaused?: boolean | null;
|
|
741
|
+
}
|
|
742
|
+
export interface ParchmentPricePin {
|
|
743
|
+
symbol: string;
|
|
744
|
+
storageId: string;
|
|
745
|
+
sourceId: bigint;
|
|
746
|
+
lazerFeedId: bigint;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* `/v1/config` `gameRewards`: the minted game-reward knobs (indexed values, else the contract
|
|
750
|
+
* defaults). Amounts are PARCHMENT base units (`decimals`).
|
|
751
|
+
*/
|
|
752
|
+
export interface ParchmentGameRewardsConfig {
|
|
753
|
+
model: "minted";
|
|
754
|
+
decimals: bigint;
|
|
755
|
+
walletMintCapPerDay: bigint;
|
|
756
|
+
globalMintCapPerDay: bigint;
|
|
757
|
+
winMint: bigint;
|
|
758
|
+
achievementMintFractionBps: bigint;
|
|
759
|
+
dailyDrop: {
|
|
760
|
+
base: bigint;
|
|
761
|
+
step: bigint;
|
|
762
|
+
max: bigint;
|
|
763
|
+
streakCap: bigint;
|
|
764
|
+
};
|
|
765
|
+
dailyDropUnit: "XP";
|
|
766
|
+
treasuryInstalled: boolean;
|
|
767
|
+
note: string;
|
|
768
|
+
}
|
|
769
|
+
export interface ApiParchmentConfigResponse {
|
|
770
|
+
/** Latest core `parchment` package (account, config, exchange, market, lp, events, ...). */
|
|
771
|
+
packageId: string | null;
|
|
772
|
+
/** Every core `parchment` package version, original first. Absent on older services. */
|
|
773
|
+
packageIds?: string[];
|
|
774
|
+
/**
|
|
775
|
+
* Latest `parchment_trade` package (package split): `trade`, the `oracle` receipt entries,
|
|
776
|
+
* `game`, `referral`, `builder`, `fees`, `fee_mint`, `launch`, `keeper`, `auth`. Null on a
|
|
777
|
+
* service without `parchment.trade-packages`.
|
|
778
|
+
*/
|
|
779
|
+
tradePackageId: string | null;
|
|
780
|
+
/**
|
|
781
|
+
* Every `parchment_trade` version, original first. Its types (`oracle::PriceReceipt`,
|
|
782
|
+
* `fees::LossTicket`, ...) carry the original (first) id. Absent on older services.
|
|
783
|
+
*/
|
|
784
|
+
tradePackageIds?: string[];
|
|
785
|
+
/** Latest `parchment_base` package (`liq_book`, `builder_book`, `lp`, `position`, `safety`, `constants`). */
|
|
786
|
+
basePackageId?: string | null;
|
|
787
|
+
/** Every `parchment_base` version, original first. Absent on older services. */
|
|
788
|
+
basePackageIds?: string[];
|
|
789
|
+
/** Latest `parchment_game` package. `game_book` / `game_events` types use the original id. */
|
|
790
|
+
gamePackageId?: string | null;
|
|
791
|
+
/** Every `parchment_game` version, original first. Absent on older services. */
|
|
792
|
+
gamePackageIds?: string[];
|
|
793
|
+
/** Latest `parchment_mint` package. `locked_mint` / `mint_cap` types use the original id. */
|
|
794
|
+
mintPackageId?: string | null;
|
|
795
|
+
/** Every `parchment_mint` version, original first. Absent on older services. */
|
|
796
|
+
mintPackageIds?: string[];
|
|
797
|
+
oraclePackageId: string | null;
|
|
798
|
+
tokenPackageId: string | null;
|
|
799
|
+
/**
|
|
800
|
+
* the Pyth Lazer integration package. Not a Parchment package: clients may call only
|
|
801
|
+
* `price_feed_storage::update_price_feed` on it, ahead of a one-step `adapter::quote`.
|
|
802
|
+
* Absent on older services.
|
|
803
|
+
*/
|
|
804
|
+
lazerIntegrationPackageId?: string;
|
|
805
|
+
configId: string | null;
|
|
806
|
+
exchangeId: string | null;
|
|
807
|
+
registryId: string | null;
|
|
808
|
+
stakingPoolId: string | null;
|
|
809
|
+
/** The Sui `Random` object id the service passes to game txs. Null when unset; absent on older services. */
|
|
810
|
+
randomId?: string | null;
|
|
811
|
+
/**
|
|
812
|
+
* `<original token package>::parchment::PARCHMENT`, stable across token upgrades. Null without a
|
|
813
|
+
* token package; absent on older services.
|
|
814
|
+
*/
|
|
815
|
+
rewardCoinType?: string | null;
|
|
816
|
+
/** Removed from `/v1/config` by the service; older services sent it. */
|
|
817
|
+
treasuryId?: string | null;
|
|
818
|
+
usdcType: string;
|
|
819
|
+
storageType: string;
|
|
820
|
+
pins: ParchmentPricePin[];
|
|
821
|
+
graphqlUrl: string;
|
|
822
|
+
/**
|
|
823
|
+
* Admin-set per-account pending order cap (`ConfigStateV1.max_pending_orders`, 1..64; a
|
|
824
|
+
* js_bigint on the wire such as `"64n"`; contract default `64n` until indexed). A `request-open*` while the account already
|
|
825
|
+
* has this many pending opens aborts `order::ETooManyOrders` (11). Close requests are not counted. Absent on older services.
|
|
826
|
+
*/
|
|
827
|
+
maxPendingOrders?: bigint;
|
|
828
|
+
/** Minted game-reward knobs. Absent on older services. */
|
|
829
|
+
gameRewards?: ParchmentGameRewardsConfig;
|
|
830
|
+
/** Close-only delegate address for take-profit and stop-loss. Null when unset. */
|
|
831
|
+
triggerDelegate: string | null;
|
|
832
|
+
/** Builder-code limits. */
|
|
833
|
+
builders: ParchmentBuilderConfig;
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Builder codes charge only an on-top fee, in bps of the trader's profit, that the trader approves.
|
|
837
|
+
* `ownerFeeLimitBps` is the most an owner may set (above it is admin-only), `maxFeeBps` the live max
|
|
838
|
+
* and `hardCapBps` the 1% ceiling. `createFee` is the live, admin-set price of a code in USDC base
|
|
839
|
+
* units (default 1 USDC, 0 to 100 USDC); `create_builder` takes exactly this amount.
|
|
840
|
+
*/
|
|
841
|
+
export interface ParchmentBuilderConfig {
|
|
842
|
+
/** Whether new opens snapshot a builder at all. */
|
|
843
|
+
enabled: boolean;
|
|
844
|
+
ownerFeeLimitBps: bigint;
|
|
845
|
+
maxFeeBps: bigint;
|
|
846
|
+
hardCapBps: bigint;
|
|
847
|
+
createFee: bigint;
|
|
848
|
+
}
|
|
849
|
+
export interface ApiParchmentLimitsResponse {
|
|
850
|
+
priceFeedStorageGetter: string;
|
|
851
|
+
priceUnavailable: string;
|
|
852
|
+
tradeTransactions: string;
|
|
853
|
+
tradeTxNote: string;
|
|
854
|
+
/** Note on request-open / request-close bytes (service `tx::ORDER_NOTE`). */
|
|
855
|
+
orderTxNote: string;
|
|
856
|
+
referralBonuses: string;
|
|
857
|
+
referralEstimate: string;
|
|
858
|
+
orderBook: string;
|
|
859
|
+
sponsor: string;
|
|
860
|
+
incomingTxKind: string;
|
|
861
|
+
signedAuth: string;
|
|
862
|
+
moveAbortCatalog: string;
|
|
863
|
+
unseen: string[];
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Close-preview PnL as served by the service (`preview_close`). Amounts are unsigned
|
|
867
|
+
* USDC base units. The service always sends every field; the breakdown
|
|
868
|
+
* fields after `net` are optional so code typed against the original five fields (and older
|
|
869
|
+
* services) still compiles.
|
|
870
|
+
*/
|
|
871
|
+
export interface ParchmentPnl {
|
|
872
|
+
/** Loss charged to margin (capped at margin). 0 on a winning close. */
|
|
873
|
+
loss: bigint;
|
|
874
|
+
/** Exposure-adjusted profit past the deadband, before the trim. */
|
|
875
|
+
raw?: bigint;
|
|
876
|
+
/** `raw - adjusted`: profit removed by the trim. */
|
|
877
|
+
trimmed?: bigint;
|
|
878
|
+
/** `raw` after the trim (the base of the win fee). */
|
|
879
|
+
adjusted: bigint;
|
|
880
|
+
winFee: bigint;
|
|
881
|
+
closeToll: bigint;
|
|
882
|
+
/** Profit after win fee and close toll. */
|
|
883
|
+
net: bigint;
|
|
884
|
+
/** Close toll taken from profit / from margin (trade::apply_pnl order). */
|
|
885
|
+
closeTollFromProfit?: bigint;
|
|
886
|
+
closeTollFromMargin?: bigint;
|
|
887
|
+
userProfit?: bigint;
|
|
888
|
+
marginReturned?: bigint;
|
|
889
|
+
/** `payoutBeforeRefund + refereeRefund`. */
|
|
890
|
+
payout?: bigint;
|
|
891
|
+
payoutBeforeRefund?: bigint;
|
|
892
|
+
/** Referee discount on the fees collected now, credited back to free balance. */
|
|
893
|
+
refereeRefund?: bigint;
|
|
894
|
+
/** Fees collected at close (toll from margin, plus toll from profit and win fee when paid now). */
|
|
895
|
+
feesCollectedNow?: bigint;
|
|
896
|
+
/**
|
|
897
|
+
* The approved builder's on-top fee, taken from `userProfit` (already out of `payout`): the
|
|
898
|
+
* position's snapshotted bps clamped to the live max, 0 without a builder or after a revoke.
|
|
899
|
+
*/
|
|
900
|
+
builderFee?: bigint;
|
|
901
|
+
builderFeeBps?: bigint;
|
|
902
|
+
/** Profit paid at close: queue empty and LP cash covers it. */
|
|
903
|
+
paidNow?: boolean;
|
|
904
|
+
/** Profit waits in the claims queue; its fees are collected at harvest. */
|
|
905
|
+
queued?: boolean;
|
|
906
|
+
trimMaxShareBps?: bigint;
|
|
907
|
+
trimCPpm?: bigint;
|
|
908
|
+
}
|
|
909
|
+
export interface ApiParchmentOpenPreviewBody {
|
|
910
|
+
marketId: string;
|
|
911
|
+
margin: string | bigint;
|
|
912
|
+
leverage: string | bigint;
|
|
913
|
+
isLong: boolean;
|
|
914
|
+
/** 0..10000. When set, the preview returns `suggestedBoundWad` for this slippage. */
|
|
915
|
+
slippageBps?: string | bigint;
|
|
916
|
+
/** Check this entry bound (WAD) against the current fill; a miss adds an error. Preview only: the chain takes no price bound on fills. */
|
|
917
|
+
acceptableEntryWad?: string | bigint;
|
|
918
|
+
/**
|
|
919
|
+
* Alias of `acceptableEntryWad` (the request tx bodies' name). `acceptableEntryWad` wins when
|
|
920
|
+
* both are set; the SDK sends the value as `acceptableEntryWad`, so older services read it too.
|
|
921
|
+
*/
|
|
922
|
+
acceptablePriceWad?: string | bigint;
|
|
923
|
+
/**
|
|
924
|
+
* The account that will request the open. Without it the service skips every account check:
|
|
925
|
+
* the referral-discounted open fee, the exec-fee / free-balance check (`topUp` only counts
|
|
926
|
+
* here), the account notional cap and `account_not_found`. `ParchmentAccount.getPreviewOpen`
|
|
927
|
+
* fills it in when the owner has exactly one account.
|
|
928
|
+
*/
|
|
929
|
+
accountId?: string;
|
|
930
|
+
/** The request's `minFactorBps`; a payout factor below it adds `factor_worse`. */
|
|
931
|
+
minFactorBps?: string | bigint;
|
|
932
|
+
/**
|
|
933
|
+
* Wallet top-up for the exec-fee check, in base units (an integer, not a coin ref; the tx routes
|
|
934
|
+
* take a coin ref instead). Only read together with `accountId`. The service answers 400 to
|
|
935
|
+
* anything that is not a base-unit integer.
|
|
936
|
+
*/
|
|
937
|
+
topUp?: string | bigint;
|
|
938
|
+
}
|
|
939
|
+
/** Price-bound fields on open/close previews. */
|
|
940
|
+
export interface ApiParchmentBoundPreviewFields {
|
|
941
|
+
/**
|
|
942
|
+
* Current fill price (WAD): the oracle mid, which is what a two-step keeper fill pays (older
|
|
943
|
+
* services returned mid ± the spread). Treat it as an estimate;
|
|
944
|
+
* the bound check uses whatever the service sends.
|
|
945
|
+
*/
|
|
946
|
+
fillWad?: bigint | null;
|
|
947
|
+
/**
|
|
948
|
+
* The one-step price (WAD): mid + spread for long opens/short closes, else mid − spread, i.e. the
|
|
949
|
+
* price that emergency close and `close_retired` pay. Null when the price is not live; absent on
|
|
950
|
+
* services that predate it. Not the two-step fill price (that is `fillWad`).
|
|
951
|
+
*/
|
|
952
|
+
oneStepWad?: bigint | null;
|
|
953
|
+
/** Bound for the requested `slippageBps`; null when it was not given. */
|
|
954
|
+
suggestedBoundWad?: bigint | null;
|
|
955
|
+
}
|
|
956
|
+
export interface ApiParchmentOpenPreviewResponse extends ApiParchmentOrderPreviewFields, ApiParchmentBoundPreviewFields {
|
|
957
|
+
marketId: string;
|
|
958
|
+
isLong: boolean;
|
|
959
|
+
margin: bigint | null;
|
|
960
|
+
fee: bigint | null;
|
|
961
|
+
locked: bigint | null;
|
|
962
|
+
notional: bigint | null;
|
|
963
|
+
winningExposure: bigint | null;
|
|
964
|
+
factorBps: bigint | null;
|
|
965
|
+
entryWad: bigint | null;
|
|
966
|
+
bustWad: bigint | null;
|
|
967
|
+
spreadSource: ParchmentSpreadSource | null;
|
|
968
|
+
/** False when a fresh signed confidence priced the spread (`spreadSource: "market-latest"`). */
|
|
969
|
+
indicative?: boolean;
|
|
970
|
+
confWad?: bigint | null;
|
|
971
|
+
takerFeeBps?: bigint;
|
|
972
|
+
minPayoutFactorBps?: bigint;
|
|
973
|
+
errors: string[];
|
|
974
|
+
}
|
|
975
|
+
export interface ApiParchmentClosePreviewBody {
|
|
976
|
+
positionId: string | bigint;
|
|
977
|
+
nowMs?: string | bigint;
|
|
978
|
+
/** 0..10000. When set, the preview returns `suggestedBoundWad` for this slippage. */
|
|
979
|
+
slippageBps?: string | bigint;
|
|
980
|
+
/** Check this exit bound (WAD) against the current fill; a miss adds an error. Preview only: the chain takes no price bound on fills. */
|
|
981
|
+
acceptableExitWad?: string | bigint;
|
|
982
|
+
/**
|
|
983
|
+
* Alias of `acceptableExitWad` (the request tx bodies' name). `acceptableExitWad` wins when both
|
|
984
|
+
* are set; the SDK sends the value as `acceptableExitWad`, so older services read it too.
|
|
985
|
+
*/
|
|
986
|
+
acceptablePriceWad?: string | bigint;
|
|
987
|
+
/**
|
|
988
|
+
* Wallet top-up for the exec-fee check, in base units (an integer, not a coin ref; the tx routes
|
|
989
|
+
* take a coin ref instead). The service answers 400 to anything that is not a base-unit integer.
|
|
990
|
+
*/
|
|
991
|
+
topUp?: string | bigint;
|
|
992
|
+
}
|
|
993
|
+
export interface ApiParchmentClosePreviewResponse extends ApiParchmentOrderPreviewFields, ApiParchmentBoundPreviewFields {
|
|
994
|
+
/**
|
|
995
|
+
* Delay (ms) after a close request before emergency close is allowed (`OrderParamsV1`), not an
|
|
996
|
+
* absolute time. Exact up to u64::MAX (disabled). Test it with `isEmergencyAfterDisabled`, never
|
|
997
|
+
* `=== EMERGENCY_CLOSE_DISABLED_MS`.
|
|
998
|
+
*/
|
|
999
|
+
emergencyAfterMs?: bigint | null;
|
|
1000
|
+
/**
|
|
1001
|
+
* The part of `execFee` a close request would owe rather than escrow: 0 when free balance covers
|
|
1002
|
+
* the fee, else the shortfall, taken from the close payout on a fill (capped at it). A close never
|
|
1003
|
+
* reports `insufficient_free_balance` for the exec fee. Absent on services that predate it.
|
|
1004
|
+
*/
|
|
1005
|
+
feeOwed?: bigint | null;
|
|
1006
|
+
positionId: bigint;
|
|
1007
|
+
errors: string[];
|
|
1008
|
+
/** As on the open preview: false when a fresh signed confidence priced the spread. */
|
|
1009
|
+
indicative?: boolean;
|
|
1010
|
+
confWad?: bigint | null;
|
|
1011
|
+
pnl: ParchmentPnl | null;
|
|
1012
|
+
exitWad: bigint | null;
|
|
1013
|
+
/** Mid crossed bust; false while liquidation is paused (see `liquidationPaused`); null without a live price. */
|
|
1014
|
+
liquidatable: boolean | null;
|
|
1015
|
+
/**
|
|
1016
|
+
* True while liquidation of this position's market is stopped: only the market's oracle kill switch
|
|
1017
|
+
* (`trade::EOracleKilled`, 20; no pause stops liquidation); then
|
|
1018
|
+
* `liquidatable` is false. `null` when the market is not indexed; older services omit it.
|
|
1019
|
+
*/
|
|
1020
|
+
liquidationPaused?: boolean | null;
|
|
1021
|
+
spreadSource?: ParchmentSpreadSource | null;
|
|
1022
|
+
}
|
|
1023
|
+
export interface ApiParchmentOpenAccountTxBody {
|
|
1024
|
+
walletAddress: string;
|
|
1025
|
+
shared?: ApiParchmentSharedVersions;
|
|
1026
|
+
}
|
|
1027
|
+
/** Owned AccountCap. Version and digest are sent only when the caller provides them. */
|
|
1028
|
+
export interface ApiParchmentAccountCap {
|
|
1029
|
+
/** Object id of the owned AccountCap for this account. */
|
|
1030
|
+
accountCapId: string;
|
|
1031
|
+
accountCapVersion?: string;
|
|
1032
|
+
accountCapDigest?: string;
|
|
1033
|
+
}
|
|
1034
|
+
export interface ApiParchmentDepositTxBody extends ApiParchmentAccountCap {
|
|
1035
|
+
walletAddress: string;
|
|
1036
|
+
accountId: string;
|
|
1037
|
+
coin: ApiParchmentCoinRef;
|
|
1038
|
+
shared?: ApiParchmentSharedVersions;
|
|
1039
|
+
}
|
|
1040
|
+
export interface ApiParchmentWithdrawTxBody extends ApiParchmentAccountCap {
|
|
1041
|
+
walletAddress: string;
|
|
1042
|
+
accountId: string;
|
|
1043
|
+
amount: string | bigint;
|
|
1044
|
+
shared?: ApiParchmentSharedVersions;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Permissionless, account-free liquidation (v3): the record lives in the market's liquidation
|
|
1048
|
+
* book, the bounty coin goes to `walletAddress`, and the owner's account reconciles on its next
|
|
1049
|
+
* touch. `retired` targets `liquidate_retired` on a retired market. Priced with
|
|
1050
|
+
* `oracle::begin_price` like every other fill (there is no TWAP band check). Liquidation runs under every
|
|
1051
|
+
* pause, including `pause_all`; only the market's oracle kill switch stops it (`trade::EOracleKilled` 20; see
|
|
1052
|
+
* `liquidationPaused`).
|
|
1053
|
+
*/
|
|
1054
|
+
export interface ApiParchmentLiquidateTxBody {
|
|
1055
|
+
walletAddress: string;
|
|
1056
|
+
marketId: string;
|
|
1057
|
+
positionId: string | bigint;
|
|
1058
|
+
update: SignedLazerUpdate;
|
|
1059
|
+
retired?: boolean;
|
|
1060
|
+
shared?: ApiParchmentSharedVersions;
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Two-step open request (`order::request_open`). The keeper fills it at the plain oracle mid
|
|
1064
|
+
* (no spread) inside the fill window. No oracle update is needed at request time.
|
|
1065
|
+
*/
|
|
1066
|
+
export interface ApiParchmentRequestOpenTxBody extends ApiParchmentAccountCap {
|
|
1067
|
+
walletAddress: string;
|
|
1068
|
+
accountId: string;
|
|
1069
|
+
marketId: string;
|
|
1070
|
+
margin: string | bigint;
|
|
1071
|
+
leverage: string | bigint;
|
|
1072
|
+
isLong: boolean;
|
|
1073
|
+
/** Minimum winning-exposure factor in bps. Defaults to `0`. */
|
|
1074
|
+
minFactorBps?: string | bigint;
|
|
1075
|
+
/**
|
|
1076
|
+
* Requested worst fill (WAD u128); `0` is no bound.
|
|
1077
|
+
* On chain: stored and emitted only; two-step fills and emergency close take no price bound.
|
|
1078
|
+
*/
|
|
1079
|
+
acceptablePriceWad: string | bigint;
|
|
1080
|
+
/** Registered builder id (u32). Sent only when provided. */
|
|
1081
|
+
builderId?: string | bigint;
|
|
1082
|
+
/** Registered builder code (1 to 32 bytes of printable UTF-8, ASCII recommended; no NUL), resolved to its id by the service. Not with `builderId`. */
|
|
1083
|
+
builderCode?: string;
|
|
1084
|
+
/** USDC coin from the wallet deposited into free balance in the same PTB. Sent only when provided. */
|
|
1085
|
+
topUp?: ApiParchmentCoinRef;
|
|
1086
|
+
shared?: ApiParchmentSharedVersions;
|
|
1087
|
+
}
|
|
1088
|
+
/** Delegate open request. No AccountCap and no wallet top-up. */
|
|
1089
|
+
/**
|
|
1090
|
+
* Pre-flight for a delegate order request: the sender's delegation expiry and the
|
|
1091
|
+
* market's `fill_deadline_ms` (`OrderParams.fillDeadlineMs`). On chain a delegate request aborts
|
|
1092
|
+
* `EDelegateExpiresBeforeDeadline` (order 28) unless the delegation outlives `now + fill_deadline_ms`;
|
|
1093
|
+
* the SDK refuses before building unless it outlives that by `DELEGATE_FILL_MARGIN_MS` (60 s) more.
|
|
1094
|
+
* Omit it for a close-only delegate (no expiry).
|
|
1095
|
+
*/
|
|
1096
|
+
export interface ParchmentDelegateLiveness {
|
|
1097
|
+
/** The delegation's expiry (`grant_delegate` `expiry_ms`). */
|
|
1098
|
+
expiryMs: string | bigint | number;
|
|
1099
|
+
/** The market's `fill_deadline_ms` (relative ms). */
|
|
1100
|
+
fillDeadlineMs: string | bigint | number;
|
|
1101
|
+
/** Clock ms to check against; defaults to `Date.now()`. */
|
|
1102
|
+
nowMs?: string | bigint | number;
|
|
1103
|
+
}
|
|
1104
|
+
export interface ApiParchmentRequestOpenAsDelegateTxBody {
|
|
1105
|
+
/** Delegate-liveness pre-flight (not sent). See {@link ParchmentDelegateLiveness}. */
|
|
1106
|
+
delegation?: ParchmentDelegateLiveness;
|
|
1107
|
+
walletAddress: string;
|
|
1108
|
+
accountId: string;
|
|
1109
|
+
marketId: string;
|
|
1110
|
+
margin: string | bigint;
|
|
1111
|
+
leverage: string | bigint;
|
|
1112
|
+
isLong: boolean;
|
|
1113
|
+
minFactorBps?: string | bigint;
|
|
1114
|
+
acceptablePriceWad: string | bigint;
|
|
1115
|
+
builderId?: string | bigint;
|
|
1116
|
+
builderCode?: string;
|
|
1117
|
+
shared?: ApiParchmentSharedVersions;
|
|
1118
|
+
}
|
|
1119
|
+
/** Two-step close request (`order::request_close`). */
|
|
1120
|
+
export interface ApiParchmentRequestCloseTxBody extends ApiParchmentAccountCap {
|
|
1121
|
+
walletAddress: string;
|
|
1122
|
+
accountId: string;
|
|
1123
|
+
marketId: string;
|
|
1124
|
+
positionId: string | bigint;
|
|
1125
|
+
/**
|
|
1126
|
+
* Requested worst exit (WAD u128). Omit it, or pass `0`, for no bound. Only opens require a value.
|
|
1127
|
+
* On chain: stored and emitted only; two-step fills and emergency close take no price bound.
|
|
1128
|
+
*/
|
|
1129
|
+
acceptablePriceWad?: string | bigint;
|
|
1130
|
+
/** USDC coin from the wallet for the exec fee. Sent only when provided. */
|
|
1131
|
+
topUp?: ApiParchmentCoinRef;
|
|
1132
|
+
shared?: ApiParchmentSharedVersions;
|
|
1133
|
+
}
|
|
1134
|
+
/** Delegate close request. No AccountCap and no wallet top-up. */
|
|
1135
|
+
export interface ApiParchmentRequestCloseAsDelegateTxBody {
|
|
1136
|
+
/** Delegate-liveness pre-flight (not sent) for a trade delegate's close. Omit for a close-only delegate. */
|
|
1137
|
+
delegation?: ParchmentDelegateLiveness;
|
|
1138
|
+
walletAddress: string;
|
|
1139
|
+
accountId: string;
|
|
1140
|
+
marketId: string;
|
|
1141
|
+
positionId: string | bigint;
|
|
1142
|
+
/** Omit it, or pass `0`, for no bound. Only opens require a value. Not enforced at fill. */
|
|
1143
|
+
acceptablePriceWad?: string | bigint;
|
|
1144
|
+
shared?: ApiParchmentSharedVersions;
|
|
1145
|
+
}
|
|
1146
|
+
/** Order reference without a cap: `cancel-order-as-delegate` (and the base of `expire-order`). */
|
|
1147
|
+
export interface ApiParchmentOrderRefTxBody {
|
|
1148
|
+
walletAddress: string;
|
|
1149
|
+
accountId: string;
|
|
1150
|
+
orderId: string;
|
|
1151
|
+
shared?: ApiParchmentSharedVersions;
|
|
1152
|
+
}
|
|
1153
|
+
/** Owner cancel (`order::cancel`). Allowed at or after `effectiveCancelAfterMs(order)` = `max(cancelAfterMs, requestedMs + 5 s)`. */
|
|
1154
|
+
export interface ApiParchmentCancelOrderTxBody extends ApiParchmentAccountCap, ApiParchmentOrderRefTxBody {
|
|
1155
|
+
}
|
|
1156
|
+
/** Delegate cancel. No AccountCap. */
|
|
1157
|
+
export type ApiParchmentCancelOrderAsDelegateTxBody = ApiParchmentOrderRefTxBody;
|
|
1158
|
+
/**
|
|
1159
|
+
* Permissionless expiry. Allowed strictly after `orderExpiresAfterMs(order)`: `fillDeadlineMs`
|
|
1160
|
+
* for opens (and closes with emergency close disabled); for closes, `emergencyAfterMs` plus the
|
|
1161
|
+
* fill-deadline span (`fillDeadlineMs - requestedMs`), so the emergency-close path gets its turn first.
|
|
1162
|
+
*/
|
|
1163
|
+
export interface ApiParchmentExpireOrderTxBody extends ApiParchmentOrderRefTxBody {
|
|
1164
|
+
/**
|
|
1165
|
+
* The order's market. The service resolves it from the order and uses this only as the fallback
|
|
1166
|
+
* for an order its index has not seen; the chain asserts it is the order's market.
|
|
1167
|
+
*/
|
|
1168
|
+
marketId?: string;
|
|
1169
|
+
/**
|
|
1170
|
+
* Signed Lazer update for the expiry price (`oracle::begin_expiry_price`, which `order::expire` takes
|
|
1171
|
+
* on every market). When omitted, the service attaches a cached update that normalizes to the
|
|
1172
|
+
* storage print, not the latest message. The expiry refunds the exec fee unless the storage's
|
|
1173
|
+
* latest write is inside the order's fill window.
|
|
1174
|
+
*/
|
|
1175
|
+
update?: SignedLazerUpdate;
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Delegate emergency close. No AccountCap. Prices with a signed oracle update. There is no exit
|
|
1179
|
+
* bound field, and the close request's stored `acceptablePriceWad` is not checked (the contract
|
|
1180
|
+
* passes `trade::no_price_bound()`): the close fills at the one-step price whatever it is.
|
|
1181
|
+
*/
|
|
1182
|
+
export interface ApiParchmentEmergencyCloseAsDelegateTxBody {
|
|
1183
|
+
walletAddress: string;
|
|
1184
|
+
accountId: string;
|
|
1185
|
+
marketId: string;
|
|
1186
|
+
orderId: string;
|
|
1187
|
+
/** Signed Lazer update. When omitted, the service fetches the latest one for the market. */
|
|
1188
|
+
update?: SignedLazerUpdate;
|
|
1189
|
+
shared?: ApiParchmentSharedVersions;
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Emergency close of a pending close order after `emergencyAfterMs` (15 s by default), when the
|
|
1193
|
+
* keeper has not filled it. Priced with the caller's signed update, or the latest one the
|
|
1194
|
+
* service fetches when `update` is omitted.
|
|
1195
|
+
*/
|
|
1196
|
+
export interface ApiParchmentEmergencyCloseTxBody extends ApiParchmentAccountCap, ApiParchmentEmergencyCloseAsDelegateTxBody {
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* One-step `trade::close_retired_as_delegate`: closes a position on a retired market (orders
|
|
1200
|
+
* are refused there), with no price bound. No AccountCap.
|
|
1201
|
+
*/
|
|
1202
|
+
export interface ApiParchmentCloseRetiredAsDelegateTxBody {
|
|
1203
|
+
walletAddress: string;
|
|
1204
|
+
accountId: string;
|
|
1205
|
+
marketId: string;
|
|
1206
|
+
positionId: string | bigint;
|
|
1207
|
+
/** Signed Lazer update. When omitted, the service fetches the latest one for the market. */
|
|
1208
|
+
update?: SignedLazerUpdate;
|
|
1209
|
+
shared?: ApiParchmentSharedVersions;
|
|
1210
|
+
}
|
|
1211
|
+
/** Owner `trade::close_retired`. */
|
|
1212
|
+
export interface ApiParchmentCloseRetiredTxBody extends ApiParchmentAccountCap, ApiParchmentCloseRetiredAsDelegateTxBody {
|
|
1213
|
+
}
|
|
1214
|
+
export type OrderKind = "open" | "close";
|
|
1215
|
+
export type OrderStatus = "pending" | "filled" | "liquidated" | "cancelled" | "expired" | "refunded" | "void" | "emergency_closed"
|
|
1216
|
+
/** The service could not map the on-chain outcome (the retired outcome 4, or a newer contract outcome code). */
|
|
1217
|
+
| "unknown";
|
|
1218
|
+
/**
|
|
1219
|
+
* Why a `refunded` order was refunded. `band` (outcome 12, `OUTCOME_REFUND_BAND`) is reserved and never
|
|
1220
|
+
* emitted (the signed band is gone). `session` (outcome 13, `OUTCOME_SESSION_CLOSED`): filled while the equity market's session close was
|
|
1221
|
+
* pending, or a close whose position the session force close already settled. The retired outcome 4
|
|
1222
|
+
* (the old price refund) has no reason: it decodes as `unknown`. `retry` (outcome 14, `OUTCOME_REFUND_LIQ_PAUSED`;
|
|
1223
|
+
* no pause emits it): the liquidation backlog could not be drained in that fill; fully refunded, try again.
|
|
1224
|
+
* `revoked` (outcome 15, `OUTCOME_REFUND_REVOKED`): the delegate that submitted the request was no longer live
|
|
1225
|
+
* at the order's cancel point; the escrow is returned and the execution fee is kept like a cancel (* earlier contracts also returned the fee).
|
|
1226
|
+
*/
|
|
1227
|
+
export type OrderRefundReason = "paused" | "killed" | "closed" | "fee" | "risk" | "band" | "session" | "retry" | "revoked";
|
|
1228
|
+
export type OrderStatusFilter = "pending" | "final" | "all";
|
|
1229
|
+
/**
|
|
1230
|
+
* `GET /orders/{orderId}`. Integers are bigints.
|
|
1231
|
+
* Request-side fields are null when the indexer has seen the final event but not
|
|
1232
|
+
* yet the request event; `status` and the fill fields are then still accurate.
|
|
1233
|
+
*/
|
|
1234
|
+
export interface Order {
|
|
1235
|
+
orderId: string;
|
|
1236
|
+
accountId: string;
|
|
1237
|
+
owner: string;
|
|
1238
|
+
requester: string | null;
|
|
1239
|
+
marketId: string;
|
|
1240
|
+
kind: OrderKind;
|
|
1241
|
+
isLong: boolean | null;
|
|
1242
|
+
margin: bigint | null;
|
|
1243
|
+
leverage: bigint | null;
|
|
1244
|
+
positionId: bigint | null;
|
|
1245
|
+
acceptablePriceWad: bigint | null;
|
|
1246
|
+
minFactorBps: bigint | null;
|
|
1247
|
+
maxFeeBps: bigint | null;
|
|
1248
|
+
execFee: bigint | null;
|
|
1249
|
+
requestedMs: bigint | null;
|
|
1250
|
+
fillDeadlineMs: bigint | null;
|
|
1251
|
+
cancelAfterMs: bigint | null;
|
|
1252
|
+
/**
|
|
1253
|
+
* Chain u64::MAX (emergency close disabled; every open order) is served as `18446744073709551615n`.
|
|
1254
|
+
* Test it with `isEmergencyAfterDisabled` / `orderExpiresAfterMs`.
|
|
1255
|
+
*/
|
|
1256
|
+
emergencyAfterMs: bigint | null;
|
|
1257
|
+
/**
|
|
1258
|
+
* Close requests: the exec fee part not escrowed (free balance was short), taken from the close
|
|
1259
|
+
* payout on a fill; 0 for opens and fully funded closes. Null when the request event is not
|
|
1260
|
+
* indexed; absent on services that predate it.
|
|
1261
|
+
*/
|
|
1262
|
+
feeOwed?: bigint | null;
|
|
1263
|
+
status: OrderStatus;
|
|
1264
|
+
/** Set when `status` is `refunded`. */
|
|
1265
|
+
reason: OrderRefundReason | null;
|
|
1266
|
+
fillPriceWad: bigint | null;
|
|
1267
|
+
fillPriceTsMs: bigint | null;
|
|
1268
|
+
/** Milliseconds from request to fill; only for filled/liquidated orders. */
|
|
1269
|
+
fillLatencyMs: bigint | null;
|
|
1270
|
+
refund: bigint | null;
|
|
1271
|
+
/**
|
|
1272
|
+
* The escrowed exec fee returned to free balance (0 when paid). An `expired` order gets it back
|
|
1273
|
+
* unless a keeper missed a storage write inside the fill window. Null while pending; absent on
|
|
1274
|
+
* services that predate it.
|
|
1275
|
+
*/
|
|
1276
|
+
execFeeRefunded?: bigint | null;
|
|
1277
|
+
requestDigest: string | null;
|
|
1278
|
+
finalDigest: string | null;
|
|
1279
|
+
finalizedMs: bigint | null;
|
|
1280
|
+
}
|
|
1281
|
+
export interface ApiParchmentOrdersResponse {
|
|
1282
|
+
orders: Order[];
|
|
1283
|
+
nextCursor?: string | null;
|
|
1284
|
+
}
|
|
1285
|
+
export interface ApiParchmentOrdersQuery {
|
|
1286
|
+
status?: OrderStatusFilter;
|
|
1287
|
+
limit?: number | bigint;
|
|
1288
|
+
/** `nextCursor` from the previous page (`<sortMs>:<orderId>`); null or blank is omitted. */
|
|
1289
|
+
cursor?: string | null;
|
|
1290
|
+
}
|
|
1291
|
+
/** Two-step order fields on open/close previews. */
|
|
1292
|
+
export interface ApiParchmentOrderPreviewFields {
|
|
1293
|
+
suggestedAcceptablePriceWad?: bigint | null;
|
|
1294
|
+
maxFeeBps?: bigint | null;
|
|
1295
|
+
execFee?: bigint | null;
|
|
1296
|
+
/** The market's fill window and cancel delay (ms). */
|
|
1297
|
+
fillWindowMs?: bigint | null;
|
|
1298
|
+
/**
|
|
1299
|
+
* The market's signed fill window (ms, verify-in-fill): the fill price is the first signed Lazer
|
|
1300
|
+
* tick after the request, at most this much later.
|
|
1301
|
+
*/
|
|
1302
|
+
signedWindowMs?: bigint | null;
|
|
1303
|
+
cancelDelayMs?: bigint | null;
|
|
1304
|
+
/**
|
|
1305
|
+
* `OrderParamsV1.one_step_spread_bps`.
|
|
1306
|
+
* Absent on services that predate it.
|
|
1307
|
+
*/
|
|
1308
|
+
oneStepSpreadBps?: bigint | null;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Keeper crank: liquidate up to `maxEntries` (1..=8, default 8; clamped on chain) crossed positions.
|
|
1312
|
+
* Priced with `oracle::begin_price` (there is no TWAP band check). Like `liquidate`, it runs under every
|
|
1313
|
+
* pause; only the market's oracle kill switch stops it.
|
|
1314
|
+
*/
|
|
1315
|
+
export interface ApiParchmentSweepTxBody {
|
|
1316
|
+
walletAddress: string;
|
|
1317
|
+
marketId: string;
|
|
1318
|
+
update: SignedLazerUpdate;
|
|
1319
|
+
maxEntries?: string | bigint;
|
|
1320
|
+
shared?: ApiParchmentSharedVersions;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Permissionless surplus sweep (at most once per interval, only above the reserve floor). The
|
|
1324
|
+
* service re-prices every market with open interest in the same PTB (`ReserveCheck`), so the
|
|
1325
|
+
* floor uses a fresh reserve.
|
|
1326
|
+
*/
|
|
1327
|
+
export interface ApiParchmentSweepSurplusTxBody {
|
|
1328
|
+
walletAddress: string;
|
|
1329
|
+
shared?: ApiParchmentSharedVersions;
|
|
1330
|
+
}
|
|
1331
|
+
/** Owner mints PARCHMENT against fee-mint basis parked by account-free liquidations. */
|
|
1332
|
+
export interface ApiParchmentClaimPendingMintTxBody extends ApiParchmentAccountCap {
|
|
1333
|
+
walletAddress: string;
|
|
1334
|
+
accountId: string;
|
|
1335
|
+
shared?: ApiParchmentSharedVersions;
|
|
1336
|
+
}
|
|
1337
|
+
export interface ApiParchmentLpHarvestTxBody {
|
|
1338
|
+
walletAddress: string;
|
|
1339
|
+
maxEntries?: string | bigint;
|
|
1340
|
+
shared?: ApiParchmentSharedVersions;
|
|
1341
|
+
}
|
|
1342
|
+
export interface ApiParchmentBindReferrerTxBody {
|
|
1343
|
+
walletAddress: string;
|
|
1344
|
+
referrer: string;
|
|
1345
|
+
shared?: ApiParchmentSharedVersions;
|
|
1346
|
+
}
|
|
1347
|
+
/** Trading referral for one wallet. `referrer` is null when the wallet is unbound. */
|
|
1348
|
+
export interface ParchmentTradingReferral {
|
|
1349
|
+
referrer: string | null;
|
|
1350
|
+
refereeCount: bigint;
|
|
1351
|
+
totalEarned: bigint;
|
|
1352
|
+
pending: bigint;
|
|
1353
|
+
}
|
|
1354
|
+
/** Trading-referral bind. Version and digest are sent only when the caller provides them. */
|
|
1355
|
+
export interface ApiParchmentBindTradingReferrerTxBody extends ApiParchmentAccountCap {
|
|
1356
|
+
walletAddress: string;
|
|
1357
|
+
accountId: string;
|
|
1358
|
+
referrer: string;
|
|
1359
|
+
shared?: ApiParchmentSharedVersions;
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* `transfer-account`: `account_transfer::transfer_account` hands the whole account to `recipient` in one
|
|
1363
|
+
* step (no accept): the cap, the owner, the balance, open positions, queued claims and the referee
|
|
1364
|
+
* binding move. The game profile stays with the wallet that earned it (XP, crates, quests, cosmetics,
|
|
1365
|
+
* unminted game PARCH, the daily mint count). Every delegate (session keys, the TP/SL close delegate)
|
|
1366
|
+
* is cleared. The recipient must hold no account (`holder_book::ERecipientHasAccount`) and the account
|
|
1367
|
+
* no live two-step order (`account::EPendingOrders`).
|
|
1368
|
+
*/
|
|
1369
|
+
export interface ApiParchmentTransferAccountTxBody extends ApiParchmentAccountCap {
|
|
1370
|
+
walletAddress: string;
|
|
1371
|
+
accountId: string;
|
|
1372
|
+
recipient: string;
|
|
1373
|
+
shared?: ApiParchmentSharedVersions;
|
|
1374
|
+
}
|
|
1375
|
+
export interface ApiParchmentStakeTxBody {
|
|
1376
|
+
walletAddress: string;
|
|
1377
|
+
coin: ApiParchmentCoinRef;
|
|
1378
|
+
shared?: ApiParchmentSharedVersions;
|
|
1379
|
+
}
|
|
1380
|
+
export interface ApiParchmentUnstakeTxBody {
|
|
1381
|
+
walletAddress: string;
|
|
1382
|
+
amount: string | bigint;
|
|
1383
|
+
shared?: ApiParchmentSharedVersions;
|
|
1384
|
+
}
|
|
1385
|
+
export interface ApiParchmentClaimTxBody {
|
|
1386
|
+
walletAddress: string;
|
|
1387
|
+
shared?: ApiParchmentSharedVersions;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* `release-unlocked`: `locked_mint::release_unlocked` pays the vested part of `who`'s locked
|
|
1391
|
+
* PARCHMENT to `who` (default: the sender). Permissionless; it always pays the ledger owner.
|
|
1392
|
+
*/
|
|
1393
|
+
export interface ApiParchmentReleaseUnlockedTxBody {
|
|
1394
|
+
walletAddress: string;
|
|
1395
|
+
who?: string;
|
|
1396
|
+
/**
|
|
1397
|
+
* Append `staking::sync_locked` for the ledger's owner. The SDK adds it to `tx` itself (ids from
|
|
1398
|
+
* `/config`); it is not sent to the API, and `txBytesBase64` is the API's kind without it.
|
|
1399
|
+
*/
|
|
1400
|
+
syncLocked?: boolean;
|
|
1401
|
+
shared?: ApiParchmentSharedVersions;
|
|
1402
|
+
}
|
|
1403
|
+
/** `exit-early`: the sender leaves the vest now, forfeiting `earlyExitPenaltyNow`. Lock-window entries stay. */
|
|
1404
|
+
export interface ApiParchmentExitEarlyTxBody {
|
|
1405
|
+
walletAddress: string;
|
|
1406
|
+
/**
|
|
1407
|
+
* Append `staking::sync_locked` for the ledger's owner. The SDK adds it to `tx` itself (ids from
|
|
1408
|
+
* `/config`); it is not sent to the API, and `txBytesBase64` is the API's kind without it.
|
|
1409
|
+
*/
|
|
1410
|
+
syncLocked?: boolean;
|
|
1411
|
+
shared?: ApiParchmentSharedVersions;
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* `exit-early-bounded`: exit only the approved entries, at most `maxPenalty` forfeited.
|
|
1415
|
+
* Pass the profile's `earlyExitUnlocks` and `earlyExitPenaltyNow` the owner was shown. Entries that
|
|
1416
|
+
* unlock later stay, and the penalty only falls with time, so the quote stays valid until signed.
|
|
1417
|
+
*/
|
|
1418
|
+
export interface ApiParchmentExitEarlyBoundedTxBody {
|
|
1419
|
+
walletAddress: string;
|
|
1420
|
+
/** `unlock_ms` of each approved entry (`earlyExitUnlocks`). At least one, at most 244 (`max_buckets`). */
|
|
1421
|
+
unlocks: readonly bigint[];
|
|
1422
|
+
/** Most PARCHMENT base units the exit may forfeit (`earlyExitPenaltyNow`). */
|
|
1423
|
+
maxPenalty: bigint;
|
|
1424
|
+
/**
|
|
1425
|
+
* Append `staking::sync_locked` for the ledger's owner. The SDK adds it to `tx` itself (ids from
|
|
1426
|
+
* `/config`); it is not sent to the API, and `txBytesBase64` is the API's kind without it.
|
|
1427
|
+
*/
|
|
1428
|
+
syncLocked?: boolean;
|
|
1429
|
+
shared?: ApiParchmentSharedVersions;
|
|
1430
|
+
}
|
|
1431
|
+
export interface ApiParchmentGrantDelegateTxBody extends ApiParchmentAccountCap {
|
|
1432
|
+
walletAddress: string;
|
|
1433
|
+
accountId: string;
|
|
1434
|
+
delegate: string;
|
|
1435
|
+
expiryMs: string | bigint;
|
|
1436
|
+
/** @deprecated Ignored. Delegate expiry is checked against the shared on-chain Clock (0x6). */
|
|
1437
|
+
nowMs?: string | bigint;
|
|
1438
|
+
shared?: ApiParchmentSharedVersions;
|
|
1439
|
+
}
|
|
1440
|
+
export interface ApiParchmentRevokeDelegateTxBody extends ApiParchmentAccountCap {
|
|
1441
|
+
walletAddress: string;
|
|
1442
|
+
accountId: string;
|
|
1443
|
+
delegate: string;
|
|
1444
|
+
shared?: ApiParchmentSharedVersions;
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* `grant-close-delegate`: grants the service's configured close-only delegate (`config.triggerDelegate`).
|
|
1448
|
+
* The body names no delegate; the service picks it.
|
|
1449
|
+
*/
|
|
1450
|
+
export interface ApiParchmentGrantCloseDelegateTxBody extends ApiParchmentAccountCap {
|
|
1451
|
+
walletAddress: string;
|
|
1452
|
+
accountId: string;
|
|
1453
|
+
shared?: ApiParchmentSharedVersions;
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* One transaction that grants the browser session key (`sessionDelegate`, until `expiryMs`) and the service's
|
|
1457
|
+
* configured close-only delegate (`config.triggerDelegate`, no expiry; the body names no trigger delegate). The
|
|
1458
|
+
* owner can revoke both with {@link ApiParchmentRevokeSessionAndTriggerTxBody}.
|
|
1459
|
+
*/
|
|
1460
|
+
export interface ApiParchmentGrantSessionAndTriggerTxBody extends ApiParchmentAccountCap {
|
|
1461
|
+
walletAddress: string;
|
|
1462
|
+
accountId: string;
|
|
1463
|
+
sessionDelegate: string;
|
|
1464
|
+
expiryMs: string | bigint;
|
|
1465
|
+
shared?: ApiParchmentSharedVersions;
|
|
1466
|
+
}
|
|
1467
|
+
/** One transaction that revokes the browser session key and the close-only trigger delegate (only the grants held). */
|
|
1468
|
+
export interface ApiParchmentRevokeSessionAndTriggerTxBody extends ApiParchmentAccountCap {
|
|
1469
|
+
walletAddress: string;
|
|
1470
|
+
accountId: string;
|
|
1471
|
+
sessionDelegate: string;
|
|
1472
|
+
triggerDelegate: string;
|
|
1473
|
+
shared?: ApiParchmentSharedVersions;
|
|
1474
|
+
}
|
|
1475
|
+
export type ParchmentTriggerStatus = "pending" | "armed" | "idle" | "firing" | "submitted" | "fired" | "closed" | "attached" | "void";
|
|
1476
|
+
/**
|
|
1477
|
+
* The take-profit and stop-loss of one position (`positionId`), or of the position the open request in
|
|
1478
|
+
* transaction `openTxDigest` creates (status `pending` until it finalizes). `firing` and `submitted`: a
|
|
1479
|
+
* trigger's close is out (`firingKind`). `idle` rows are listed only with `stopLossDropped`.
|
|
1480
|
+
*/
|
|
1481
|
+
export interface ParchmentTrigger {
|
|
1482
|
+
accountId: string;
|
|
1483
|
+
owner: string;
|
|
1484
|
+
positionId: bigint | null;
|
|
1485
|
+
openTxDigest: string | null;
|
|
1486
|
+
marketId: string;
|
|
1487
|
+
isLong: boolean;
|
|
1488
|
+
takeProfitWad: bigint | null;
|
|
1489
|
+
stopLossWad: bigint | null;
|
|
1490
|
+
/** Present when the stop signed with the open was not armed (it was past the filled position's liquidation). */
|
|
1491
|
+
stopLossDropped?: ParchmentStopLossDropped;
|
|
1492
|
+
status: ParchmentTriggerStatus;
|
|
1493
|
+
firingKind: "tp" | "sl" | null;
|
|
1494
|
+
/**
|
|
1495
|
+
* Why a voided intent ended (`not_filled`, `not_in_transaction`, `ambiguous_open`, `aborted`, `over_cap`,
|
|
1496
|
+
* `expired`, `attach_impossible`); voids from the last seven days are listed. Null otherwise.
|
|
1497
|
+
*/
|
|
1498
|
+
voidReason?: string | null;
|
|
1499
|
+
/** A pending intent whose open was not seen in time: kept, and it still attaches if the open lands. */
|
|
1500
|
+
lapsed?: boolean;
|
|
1501
|
+
/** The account has no close-only grant: nothing fires until it is granted again (the legs stay). */
|
|
1502
|
+
paused?: boolean;
|
|
1503
|
+
}
|
|
1504
|
+
/** A stop signed with an open that the service dropped at the fill. */
|
|
1505
|
+
export interface ParchmentStopLossDropped {
|
|
1506
|
+
/** Stable code: `past_liquidation` (the stop was at or past the filled position's liquidation). */
|
|
1507
|
+
reason: string;
|
|
1508
|
+
/** When the service dropped it, unix ms. */
|
|
1509
|
+
ms: bigint;
|
|
1510
|
+
/** The requested stop, 1e18. */
|
|
1511
|
+
wad: bigint;
|
|
1512
|
+
}
|
|
1513
|
+
export interface ParchmentTriggers {
|
|
1514
|
+
triggers: ParchmentTrigger[];
|
|
1515
|
+
/** Next page's `cursor`; null on the last page. */
|
|
1516
|
+
nextCursor: string | null;
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* One builder code. Amounts are base units. Chain accepts any 1-32 bytes, but the
|
|
1520
|
+
* service indexes the exact bytes, yet takes codes as UTF-8 strings: use printable UTF-8 (ASCII recommended); a non-UTF-8 or
|
|
1521
|
+
* NUL-containing code cannot be resolved by the service.
|
|
1522
|
+
*/
|
|
1523
|
+
/**
|
|
1524
|
+
* A registered builder. It charges only an on-top fee (`feeBps` of the trader's profit) and only to
|
|
1525
|
+
* accounts that approved it. `code`, `payout` and `owner` are null when the API serves none.
|
|
1526
|
+
*/
|
|
1527
|
+
export interface ParchmentBuilder {
|
|
1528
|
+
id: bigint;
|
|
1529
|
+
code: string | null;
|
|
1530
|
+
payout: string | null;
|
|
1531
|
+
owner: string | null;
|
|
1532
|
+
active: boolean;
|
|
1533
|
+
/** `paused` by the owner, `suspended` by the admin, `tombstoned` when the code is retired. */
|
|
1534
|
+
status: "active" | "paused" | "suspended" | "tombstoned";
|
|
1535
|
+
/** Created by its owner rather than registered by the admin. */
|
|
1536
|
+
selfServe: boolean;
|
|
1537
|
+
feeBps: bigint;
|
|
1538
|
+
/** An admin suspend that also voided the fee on positions already open. */
|
|
1539
|
+
revokeOpen: boolean;
|
|
1540
|
+
pending: bigint;
|
|
1541
|
+
totalEarned: bigint;
|
|
1542
|
+
}
|
|
1543
|
+
/** An account's approval of one builder, up to `maxFeeBps` of its profit. */
|
|
1544
|
+
/**
|
|
1545
|
+
* A wallet's self-serve builder allowance, counted like `create_builder` on chain (* owner decision): `created` live (not tombstoned) self-serve codes it registered, whoever owns
|
|
1546
|
+
* them now. Codes transferred to the wallet do not count; codes it handed on still do.
|
|
1547
|
+
*/
|
|
1548
|
+
export interface ParchmentBuilderAllowance {
|
|
1549
|
+
created: bigint;
|
|
1550
|
+
limit: bigint;
|
|
1551
|
+
remaining: bigint;
|
|
1552
|
+
}
|
|
1553
|
+
export interface ParchmentBuilderApproval {
|
|
1554
|
+
accountId: string;
|
|
1555
|
+
builderId: bigint;
|
|
1556
|
+
maxFeeBps: bigint;
|
|
1557
|
+
}
|
|
1558
|
+
/** Admin register. Version and digest are sent only when the caller provides them. */
|
|
1559
|
+
export interface ApiParchmentRegisterBuilderTxBody {
|
|
1560
|
+
walletAddress: string;
|
|
1561
|
+
authorityCapId: string;
|
|
1562
|
+
authorityCapVersion?: string;
|
|
1563
|
+
authorityCapDigest?: string;
|
|
1564
|
+
code: string;
|
|
1565
|
+
payout: string;
|
|
1566
|
+
owner: string;
|
|
1567
|
+
/** On-top fee in bps of profit, 0 to 100. */
|
|
1568
|
+
feeBps: string | bigint;
|
|
1569
|
+
shared?: ApiParchmentSharedVersions;
|
|
1570
|
+
}
|
|
1571
|
+
/** Admin: set the self-serve creation price. Version and digest are sent only when the caller provides them. */
|
|
1572
|
+
export interface ApiParchmentSetBuilderCreateFeeTxBody {
|
|
1573
|
+
walletAddress: string;
|
|
1574
|
+
authorityCapId: string;
|
|
1575
|
+
authorityCapVersion?: string;
|
|
1576
|
+
authorityCapDigest?: string;
|
|
1577
|
+
/** USDC base units, 0 (free) to 100_000_000 ($100). */
|
|
1578
|
+
amount: string | bigint;
|
|
1579
|
+
shared?: ApiParchmentSharedVersions;
|
|
1580
|
+
}
|
|
1581
|
+
/** Create a code; the sender owns it. The service splits exactly `builders.createFee` from `coin`. */
|
|
1582
|
+
export interface ApiParchmentCreateBuilderTxBody {
|
|
1583
|
+
walletAddress: string;
|
|
1584
|
+
/** 3 to 32 bytes of `[a-z0-9_-]`. */
|
|
1585
|
+
code: string;
|
|
1586
|
+
payout: string;
|
|
1587
|
+
/** On-top fee in bps of profit, 0 up to the owner limit. */
|
|
1588
|
+
feeBps: string | bigint;
|
|
1589
|
+
coin: ApiParchmentCoinRef;
|
|
1590
|
+
shared?: ApiParchmentSharedVersions;
|
|
1591
|
+
}
|
|
1592
|
+
/** The owner's own code actions: `set-builder-fee` (with `feeBps`), `pause-builder`, `resume-builder`. */
|
|
1593
|
+
export interface ApiParchmentBuilderOwnerTxBody {
|
|
1594
|
+
walletAddress: string;
|
|
1595
|
+
builderId: string | bigint;
|
|
1596
|
+
shared?: ApiParchmentSharedVersions;
|
|
1597
|
+
}
|
|
1598
|
+
export interface ApiParchmentSetBuilderFeeTxBody extends ApiParchmentBuilderOwnerTxBody {
|
|
1599
|
+
feeBps: string | bigint;
|
|
1600
|
+
}
|
|
1601
|
+
/** One transaction: the new owner runs the code at once. The payout is unchanged. */
|
|
1602
|
+
export interface ApiParchmentTransferBuilderTxBody extends ApiParchmentBuilderOwnerTxBody {
|
|
1603
|
+
newOwner: string;
|
|
1604
|
+
}
|
|
1605
|
+
/** The account owner's approval (AccountCap, not a delegate) of a builder's fee, 1 to 100 bps. */
|
|
1606
|
+
export interface ApiParchmentApproveBuilderTxBody extends ApiParchmentAccountCap {
|
|
1607
|
+
walletAddress: string;
|
|
1608
|
+
accountId: string;
|
|
1609
|
+
builderId: string | bigint;
|
|
1610
|
+
maxFeeBps: string | bigint;
|
|
1611
|
+
shared?: ApiParchmentSharedVersions;
|
|
1612
|
+
}
|
|
1613
|
+
/** Stops a builder's fee on later opens. Works under every pause. */
|
|
1614
|
+
export interface ApiParchmentRevokeBuilderApprovalTxBody extends ApiParchmentAccountCap {
|
|
1615
|
+
walletAddress: string;
|
|
1616
|
+
accountId: string;
|
|
1617
|
+
builderId: string | bigint;
|
|
1618
|
+
shared?: ApiParchmentSharedVersions;
|
|
1619
|
+
}
|
|
1620
|
+
export interface ApiParchmentSetBuilderPayoutTxBody {
|
|
1621
|
+
walletAddress: string;
|
|
1622
|
+
builderId: string | bigint;
|
|
1623
|
+
newPayout: string;
|
|
1624
|
+
shared?: ApiParchmentSharedVersions;
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Install the single PARCHMENT treasury cap once.
|
|
1628
|
+
* Version and digest are sent only when the caller provides them.
|
|
1629
|
+
*/
|
|
1630
|
+
export interface ApiParchmentInstallTreasuryTxBody {
|
|
1631
|
+
walletAddress: string;
|
|
1632
|
+
authorityCapId: string;
|
|
1633
|
+
authorityCapVersion?: string;
|
|
1634
|
+
authorityCapDigest?: string;
|
|
1635
|
+
treasuryCap: ApiParchmentCoinRef;
|
|
1636
|
+
shared?: ApiParchmentSharedVersions;
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Admin package-split setup: `parchment_trade::auth::register<C>(config, exchange, admin_cap)`.
|
|
1640
|
+
* Run once per exchange after publishing `parchment_trade`; idempotent.
|
|
1641
|
+
* Version and digest are sent only when the caller provides them.
|
|
1642
|
+
*/
|
|
1643
|
+
export interface ApiParchmentAuthRegisterTxBody {
|
|
1644
|
+
walletAddress: string;
|
|
1645
|
+
authorityCapId: string;
|
|
1646
|
+
authorityCapVersion?: string;
|
|
1647
|
+
authorityCapDigest?: string;
|
|
1648
|
+
shared?: ApiParchmentSharedVersions;
|
|
1649
|
+
}
|
|
1650
|
+
export declare const LEADERBOARD_PERIODS: readonly ["daily", "weekly", "all", "season"];
|
|
1651
|
+
export declare const LEADERBOARD_METRICS: readonly ["pnl", "pnlPct", "volume", "winStreak", "xp"];
|
|
1652
|
+
export type ParchmentLeaderboardPeriod = (typeof LEADERBOARD_PERIODS)[number];
|
|
1653
|
+
export type ParchmentLeaderboardBy = (typeof LEADERBOARD_METRICS)[number];
|
|
1654
|
+
/** One wallet's game state. Amounts are base units. XP is notional. */
|
|
1655
|
+
export interface ParchmentGame {
|
|
1656
|
+
walletAddress: string;
|
|
1657
|
+
xp: bigint;
|
|
1658
|
+
seasonXp: bigint;
|
|
1659
|
+
seasonId: bigint;
|
|
1660
|
+
tier: bigint;
|
|
1661
|
+
streak: bigint;
|
|
1662
|
+
winStreak: bigint;
|
|
1663
|
+
crates: bigint;
|
|
1664
|
+
trades: bigint;
|
|
1665
|
+
/** Unlocked achievement ids, completed quest ids and owned cosmetic ids. */
|
|
1666
|
+
achievements?: bigint[];
|
|
1667
|
+
questsDone?: bigint[];
|
|
1668
|
+
cosmetics?: bigint[];
|
|
1669
|
+
/** Issued PARCHMENT (base units): all-time, today (UTC), and accrued-but-uncollected. */
|
|
1670
|
+
minted?: bigint;
|
|
1671
|
+
mintedToday?: bigint;
|
|
1672
|
+
pendingMint?: bigint;
|
|
1673
|
+
/** UTC day number of the last daily claim, or null. Daily claims grant XP only. */
|
|
1674
|
+
lastDailyDay?: bigint | null;
|
|
1675
|
+
dailyClaimedToday?: boolean;
|
|
1676
|
+
/** Retained-fee credit in USDC base units (wash/self trades excluded on-chain). */
|
|
1677
|
+
feeCredit?: bigint;
|
|
1678
|
+
feeCreditUsed?: bigint;
|
|
1679
|
+
achievementMintFractionBps?: bigint;
|
|
1680
|
+
feeAchievements?: ParchmentFeeAchievement[];
|
|
1681
|
+
/**
|
|
1682
|
+
* Locked mint + 30-day vest (`locked_mint`). `current` when the seven figures below come from
|
|
1683
|
+
* the wallet's current ledger; `rebuilding` / `failed` while the service reconstructs it, and then
|
|
1684
|
+
* every figure is null (unknown, not zero). Absent on older services.
|
|
1685
|
+
*/
|
|
1686
|
+
lockedLedgerStatus?: ParchmentLockedLedgerStatus;
|
|
1687
|
+
/** Everything held in the wallet's locked-mint ledger (`locked_mint::locked_balance`). */
|
|
1688
|
+
lockedBalance?: bigint | null;
|
|
1689
|
+
/** The part still inside the 7-day lock (cannot be released or exited). */
|
|
1690
|
+
lockWindowBalance?: bigint | null;
|
|
1691
|
+
/** `locked_mint::next_unlock_ms`; 0 when nothing is still inside the lock. */
|
|
1692
|
+
nextUnlockMs?: bigint | null;
|
|
1693
|
+
/** Unlocked and vesting. */
|
|
1694
|
+
vestingBalance?: bigint | null;
|
|
1695
|
+
/** Vested now: what `release-unlocked` pays the owner. */
|
|
1696
|
+
releasableNow?: bigint | null;
|
|
1697
|
+
/** What `exit-early` would pay now (vested in full plus unvested less the penalty). */
|
|
1698
|
+
earlyExitPaidNow?: bigint | null;
|
|
1699
|
+
/** What `exit-early` would forfeit now (dripped to stakers over 7 days). */
|
|
1700
|
+
earlyExitPenaltyNow?: bigint | null;
|
|
1701
|
+
/** `unlock_ms` of the entries that penalty covers: the `unlocks` for `exit-early-bounded`. */
|
|
1702
|
+
earlyExitUnlocks?: bigint[] | null;
|
|
1703
|
+
}
|
|
1704
|
+
export declare const LOCKED_LEDGER_STATUSES: readonly ["current", "rebuilding", "failed"];
|
|
1705
|
+
export type ParchmentLockedLedgerStatus = (typeof LOCKED_LEDGER_STATUSES)[number];
|
|
1706
|
+
/**
|
|
1707
|
+
* A FEES_PAID (kind-8) achievement: the only game path that can mint PARCHMENT. Full or wait
|
|
1708
|
+
*: active rungs are settled in `(feesRequired, id)` order, and a met rung pays its
|
|
1709
|
+
* full `mintAmount` only when the fee credit not yet consumed by earlier rungs covers
|
|
1710
|
+
* `ceil(mintAmount x 10000 / (100000 x fraction))` (USDC base units). Otherwise it stays locked
|
|
1711
|
+
* and pays nothing; it never pays part of its mint.
|
|
1712
|
+
*/
|
|
1713
|
+
export interface ParchmentFeeAchievement {
|
|
1714
|
+
id: bigint;
|
|
1715
|
+
name: string | null;
|
|
1716
|
+
/** Lifetime retained fees (USDC base units, `feeCredit`) the rung's criterion needs. */
|
|
1717
|
+
feesRequired: bigint;
|
|
1718
|
+
/**
|
|
1719
|
+
* More fee credit (USDC base units) after which a settle is guaranteed to pay this rung: 0 when
|
|
1720
|
+
* `eligibleMint` is set or once unlocked; otherwise max(feesRequired - feeCredit, the ceil cost
|
|
1721
|
+
* of this rung and every earlier locked active rung - (feeCredit - feeCreditUsed)). Can exceed
|
|
1722
|
+
* `feesRequired - feeCredit`. A zero-mint rung, or any rung at fraction 0 (no mint can pay),
|
|
1723
|
+
* reports only the threshold gap. Meaningless while `unlockable` is false.
|
|
1724
|
+
*/
|
|
1725
|
+
feesNeeded: bigint;
|
|
1726
|
+
xp: bigint;
|
|
1727
|
+
mintAmount: bigint;
|
|
1728
|
+
/** `mintAmount` when the next settle would pay this rung with no new fees, else 0; 0 once unlocked. */
|
|
1729
|
+
eligibleMint: bigint;
|
|
1730
|
+
/** What the rung pays when it unlocks: always the full `mintAmount`; 0 once unlocked. */
|
|
1731
|
+
mintAtUnlock: bigint;
|
|
1732
|
+
active: boolean;
|
|
1733
|
+
unlocked: boolean;
|
|
1734
|
+
/**
|
|
1735
|
+
* False when no fee top-up can unlock this locked rung under the current config (inactive, a
|
|
1736
|
+
* mint at fraction 0, or a threshold or own cost past the u64 fee-credit ceiling); true once unlocked. Optional:
|
|
1737
|
+
* older services don't serve it.
|
|
1738
|
+
*/
|
|
1739
|
+
unlockable?: boolean;
|
|
1740
|
+
}
|
|
1741
|
+
export interface ParchmentQuestDefinition {
|
|
1742
|
+
id: bigint;
|
|
1743
|
+
name: string | null;
|
|
1744
|
+
kind: bigint;
|
|
1745
|
+
param: bigint;
|
|
1746
|
+
xp: bigint;
|
|
1747
|
+
cosmetic: bigint | null;
|
|
1748
|
+
active: boolean;
|
|
1749
|
+
startMs: bigint;
|
|
1750
|
+
endMs: bigint;
|
|
1751
|
+
seasonId: bigint;
|
|
1752
|
+
}
|
|
1753
|
+
export interface ParchmentAchievementDefinition {
|
|
1754
|
+
id: bigint;
|
|
1755
|
+
name: string | null;
|
|
1756
|
+
kind: bigint;
|
|
1757
|
+
param: bigint;
|
|
1758
|
+
xp: bigint;
|
|
1759
|
+
mintAmount: bigint;
|
|
1760
|
+
cosmetic: bigint | null;
|
|
1761
|
+
active: boolean;
|
|
1762
|
+
}
|
|
1763
|
+
export interface ParchmentGameDefinitions {
|
|
1764
|
+
quests: ParchmentQuestDefinition[];
|
|
1765
|
+
achievements: ParchmentAchievementDefinition[];
|
|
1766
|
+
cosmetics: {
|
|
1767
|
+
id: bigint;
|
|
1768
|
+
name: string;
|
|
1769
|
+
}[];
|
|
1770
|
+
achievementMintFractionBps: bigint;
|
|
1771
|
+
}
|
|
1772
|
+
/** Per-row activity for the requested leaderboard period. */
|
|
1773
|
+
export interface ParchmentLeaderboardStats {
|
|
1774
|
+
trades: bigint;
|
|
1775
|
+
closes: bigint;
|
|
1776
|
+
wins: bigint;
|
|
1777
|
+
volume: bigint;
|
|
1778
|
+
pnl: bigint;
|
|
1779
|
+
winRateBps: bigint | null;
|
|
1780
|
+
xp: bigint;
|
|
1781
|
+
tier: bigint;
|
|
1782
|
+
winStreak: bigint;
|
|
1783
|
+
}
|
|
1784
|
+
export interface ParchmentLeaderboardRow {
|
|
1785
|
+
rank: bigint;
|
|
1786
|
+
walletAddress: string;
|
|
1787
|
+
value: bigint;
|
|
1788
|
+
stats?: ParchmentLeaderboardStats;
|
|
1789
|
+
}
|
|
1790
|
+
export interface ParchmentLeaderboard {
|
|
1791
|
+
period: ParchmentLeaderboardPeriod;
|
|
1792
|
+
by: ParchmentLeaderboardBy;
|
|
1793
|
+
rows: ParchmentLeaderboardRow[];
|
|
1794
|
+
viewer: ParchmentLeaderboardRow | null;
|
|
1795
|
+
/** Offset of the next page (pass it back as `cursor`); null on the last page. */
|
|
1796
|
+
nextCursor: bigint | null;
|
|
1797
|
+
}
|
|
1798
|
+
/** Arguments of `Parchment.getLeaderboard`. */
|
|
1799
|
+
export interface ParchmentLeaderboardQuery {
|
|
1800
|
+
period: ParchmentLeaderboardPeriod;
|
|
1801
|
+
by: ParchmentLeaderboardBy;
|
|
1802
|
+
/** Adds the wallet's own row as `viewer`. */
|
|
1803
|
+
walletAddress?: string;
|
|
1804
|
+
/** Row offset from a previous page's `nextCursor` (decimal). Omitted = first page. */
|
|
1805
|
+
cursor?: string | number | bigint | null;
|
|
1806
|
+
/** Page size, 1..=u64::MAX; the service defaults to 50 and caps at 200. */
|
|
1807
|
+
limit?: number | bigint;
|
|
1808
|
+
/** Window reference time in ms, 0..=i64::MAX (daily/weekly/season bounds). Omitted = now. */
|
|
1809
|
+
nowMs?: string | number | bigint;
|
|
1810
|
+
}
|
|
1811
|
+
export interface ParchmentFeedEntry {
|
|
1812
|
+
walletAddress: string;
|
|
1813
|
+
marketId: string;
|
|
1814
|
+
positionId: bigint;
|
|
1815
|
+
pnl: bigint;
|
|
1816
|
+
notional: bigint;
|
|
1817
|
+
atMs: bigint;
|
|
1818
|
+
side?: "long" | "short" | null;
|
|
1819
|
+
isLong?: boolean | null;
|
|
1820
|
+
leverage?: bigint | null;
|
|
1821
|
+
/** service `game_scores.kind`: "open" (whale opens), "close" or "liquidate" (rekt feed). */
|
|
1822
|
+
kind?: "open" | "close" | "liquidate" | (string & {});
|
|
1823
|
+
/** Exit price from PositionExitEventV1 (fill for a close, storage mid for a liquidation). */
|
|
1824
|
+
exitWad?: bigint | null;
|
|
1825
|
+
}
|
|
1826
|
+
/** One ticker row from `/positions/recent`. */
|
|
1827
|
+
export interface ParchmentRecentPosition {
|
|
1828
|
+
kind: "open" | "close" | "liquidate";
|
|
1829
|
+
walletAddress: string;
|
|
1830
|
+
marketId: string | null;
|
|
1831
|
+
symbol: string | null;
|
|
1832
|
+
positionId: bigint | null;
|
|
1833
|
+
atMs: bigint;
|
|
1834
|
+
txDigest: string;
|
|
1835
|
+
isLong: boolean | null;
|
|
1836
|
+
side: "long" | "short" | null;
|
|
1837
|
+
notional: bigint | null;
|
|
1838
|
+
margin: bigint | null;
|
|
1839
|
+
leverage: bigint | null;
|
|
1840
|
+
entryWad: bigint | null;
|
|
1841
|
+
exitWad: bigint | null;
|
|
1842
|
+
/** entryWad for an open, exitWad for a close or liquidation. */
|
|
1843
|
+
priceWad: bigint | null;
|
|
1844
|
+
}
|
|
1845
|
+
export interface ParchmentMarketStats {
|
|
1846
|
+
marketId: string;
|
|
1847
|
+
symbol: string | null;
|
|
1848
|
+
/** Opened plus closed/liquidated notional in the last 24h (USDC base units). */
|
|
1849
|
+
volume24h: bigint;
|
|
1850
|
+
openedNotional24h: bigint;
|
|
1851
|
+
closedNotional24h: bigint;
|
|
1852
|
+
opens24h: bigint;
|
|
1853
|
+
closes24h: bigint;
|
|
1854
|
+
openInterestLong: bigint;
|
|
1855
|
+
openInterestShort: bigint;
|
|
1856
|
+
/** The newest price point at or before `sinceMs` (WAD); null while the market's history is younger. */
|
|
1857
|
+
price24hAgoWad: bigint | null;
|
|
1858
|
+
price24hAgoTsMs: bigint | null;
|
|
1859
|
+
}
|
|
1860
|
+
export interface ParchmentMarketStatsResponse {
|
|
1861
|
+
sinceMs: bigint;
|
|
1862
|
+
untilMs: bigint;
|
|
1863
|
+
markets: ParchmentMarketStats[];
|
|
1864
|
+
}
|
|
1865
|
+
export interface ParchmentLpQueue {
|
|
1866
|
+
queueLength: bigint;
|
|
1867
|
+
totalOwed: bigint;
|
|
1868
|
+
/** Null until `exchange_state.lp_cash` is indexed (fresh deploy). */
|
|
1869
|
+
lpCash: bigint | null;
|
|
1870
|
+
head: unknown;
|
|
1871
|
+
claims: unknown;
|
|
1872
|
+
}
|
|
1873
|
+
export interface ParchmentFeed {
|
|
1874
|
+
entries: ParchmentFeedEntry[];
|
|
1875
|
+
}
|
|
1876
|
+
export interface ParchmentPnlCard {
|
|
1877
|
+
positionId: bigint;
|
|
1878
|
+
walletAddress: string;
|
|
1879
|
+
marketId: string;
|
|
1880
|
+
pnl: bigint;
|
|
1881
|
+
/** PnL over margin in basis points (`pnl * 10000 / margin`, integer): "1234" is 12.34%. */
|
|
1882
|
+
pnlPct: bigint;
|
|
1883
|
+
isLong: boolean;
|
|
1884
|
+
/**
|
|
1885
|
+
* Whether the service has indexed the position's close / liquidation (its `pnl` is then the
|
|
1886
|
+
* realized, fee-inclusive result; before that it serves 0). Undefined when the service doesn't
|
|
1887
|
+
* serve the flag (older deployments).
|
|
1888
|
+
*/
|
|
1889
|
+
settled?: boolean;
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Account-cap body for game actions. Only collect-mint issues PARCHMENT;
|
|
1893
|
+
* daily, quest and crate rewards are XP/cosmetics. No `questId` and no treasury cap.
|
|
1894
|
+
* Version and digest are sent only when provided.
|
|
1895
|
+
*/
|
|
1896
|
+
export interface ApiParchmentGameTxBody extends ApiParchmentAccountCap {
|
|
1897
|
+
walletAddress: string;
|
|
1898
|
+
accountId: string;
|
|
1899
|
+
shared?: ApiParchmentSharedVersions;
|
|
1900
|
+
}
|
|
1901
|
+
export interface ApiParchmentClaimQuestTxBody extends ApiParchmentGameTxBody {
|
|
1902
|
+
questId: string | bigint;
|
|
1903
|
+
}
|
|
1904
|
+
/** `open-crates` body: the game account-cap body plus the batch size. */
|
|
1905
|
+
export interface ApiParchmentOpenCratesTxBody extends ApiParchmentGameTxBody {
|
|
1906
|
+
/**
|
|
1907
|
+
* Crates to open in one transaction, a u64 of at least 1 (no app-level cap; the chain bounds it by
|
|
1908
|
+
* the crates owned and Sui's per-transaction limits): a safe integer, a bigint or a decimal digit string. Anything else is a local `count_required` (missing or empty) or `bad_count`.
|
|
1909
|
+
*/
|
|
1910
|
+
count: number | bigint | string;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* `GET /staking`: the `parchment_token::staking` pool. Staker rewards stream linearly
|
|
1914
|
+
* (`streamRemaining` vests until `streamEndMs`; each deposit re-streams the unvested remainder
|
|
1915
|
+
* plus the new amount over `rewardStreamMs`). Amounts are base units, times are Unix ms
|
|
1916
|
+
* strings. `null` from the API until the pool is indexed.
|
|
1917
|
+
*/
|
|
1918
|
+
export interface ParchmentStakingPool {
|
|
1919
|
+
poolId: string;
|
|
1920
|
+
configId: string | null;
|
|
1921
|
+
totalStaked: bigint;
|
|
1922
|
+
/** `acc_reward_per_share`, scaled by 1e27. */
|
|
1923
|
+
accRewardPerShare: string;
|
|
1924
|
+
/** Unvested staker rewards as of `streamLastMs` (`staking::stream_remaining`). */
|
|
1925
|
+
streamRemaining: bigint;
|
|
1926
|
+
streamLastMs: bigint;
|
|
1927
|
+
/** `stream_remaining` is fully vested at this time (`staking::stream_end_ms`). */
|
|
1928
|
+
streamEndMs: bigint;
|
|
1929
|
+
/** The part of `streamRemaining` vested by `nowMs` and not yet credited to the index. */
|
|
1930
|
+
streamVestedNow: bigint;
|
|
1931
|
+
/** Vesting window for the next deposit (default 7 days; maximum is admin-configurable). */
|
|
1932
|
+
rewardStreamMs: bigint;
|
|
1933
|
+
/** Stake lock after each stake increase (default 0; maximum is admin-configurable). */
|
|
1934
|
+
minStakeLockMs: bigint;
|
|
1935
|
+
rewards: bigint;
|
|
1936
|
+
/** Treasury-funded reserve for owed staking referral bonuses (`fund_referral_bonuses`); never above what is owed. */
|
|
1937
|
+
referralReserve: bigint;
|
|
1938
|
+
nowMs: bigint;
|
|
1939
|
+
/** Swept vest early-exit penalties (PARCHMENT) dripping to stakers, as of `parchDripLastMs`. Absent on older services. */
|
|
1940
|
+
parchDripRemaining?: bigint;
|
|
1941
|
+
/** `parchDripRemaining` projected to `nowMs`. */
|
|
1942
|
+
parchDripNow?: bigint;
|
|
1943
|
+
parchDripLastMs?: bigint;
|
|
1944
|
+
/** Projected end of the drip (moves forward while nobody stakes). */
|
|
1945
|
+
parchDripEndMs?: bigint;
|
|
1946
|
+
/**
|
|
1947
|
+
* Locked yield: the USDC index is per unit of `totalWeight` = `totalStaked` +
|
|
1948
|
+
* `lockedWeight` (all owners' locked weight as of their last sync). Absent on older services.
|
|
1949
|
+
*/
|
|
1950
|
+
totalWeight?: bigint;
|
|
1951
|
+
lockedWeight?: bigint;
|
|
1952
|
+
/** Locked weight per locked or vesting PARCHMENT, bps (default 5000); null on a pool without locked yield. */
|
|
1953
|
+
lockedWeightBps?: bigint | null;
|
|
1954
|
+
/** Locked yield banked by syncs and not yet paid, all owners (`staking::locked_owed_total`). */
|
|
1955
|
+
lockedOwedTotal?: bigint;
|
|
1956
|
+
}
|
|
1957
|
+
/** `GET /staking/{owner}`: one staker's position. */
|
|
1958
|
+
export interface ParchmentStaker {
|
|
1959
|
+
owner: string;
|
|
1960
|
+
staked: bigint;
|
|
1961
|
+
rewardDebt: string;
|
|
1962
|
+
stakedAtMs: bigint;
|
|
1963
|
+
/** `staking::unlock_at_ms`: unstake aborts `EStakeLocked` (11) before this time. "0" without a position. */
|
|
1964
|
+
unlockAtMs: bigint;
|
|
1965
|
+
locked: boolean;
|
|
1966
|
+
/** `staking::pending_now` at `nowMs`: includes the stream slice vested since the last accrual. */
|
|
1967
|
+
pendingReward: bigint;
|
|
1968
|
+
/**
|
|
1969
|
+
* PARCHMENT owed from the forfeit drip (`staking::parch_pending`, 9 dp base units), paid by
|
|
1970
|
+
* claim / stake / unstake. Absent on services that don't serve it yet (treat as 0).
|
|
1971
|
+
*/
|
|
1972
|
+
parchPending?: bigint;
|
|
1973
|
+
/**
|
|
1974
|
+
* False when the service cannot serve `pendingReward` exactly (e.g. its copy of the reward debt is
|
|
1975
|
+
* stale or unknown, or only a lower bound): `pendingReward` is then an estimate. Absent on services
|
|
1976
|
+
* that don't serve it yet (treat as exact).
|
|
1977
|
+
*/
|
|
1978
|
+
pendingRewardExact?: boolean;
|
|
1979
|
+
/**
|
|
1980
|
+
* Locked yield, absent on older services (treat as 0). `lockedWeight` is the weight as of
|
|
1981
|
+
* the owner's last `sync_locked`, set from `lockedSyncedBalance` (a later ledger change counts
|
|
1982
|
+
* after the next sync); `lockedPending` is `staking::locked_pending_now` at `nowMs`, of which
|
|
1983
|
+
* `lockedOwed` is already banked. A claim pays `pendingReward + lockedPending` (the locked part
|
|
1984
|
+
* books no referral bonus). `totalWeight` is `staked + lockedWeight`.
|
|
1985
|
+
*/
|
|
1986
|
+
lockedWeight?: bigint;
|
|
1987
|
+
lockedSyncedBalance?: bigint;
|
|
1988
|
+
lockedPending?: bigint;
|
|
1989
|
+
lockedOwed?: bigint;
|
|
1990
|
+
totalWeight?: bigint;
|
|
1991
|
+
nowMs: bigint;
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Actions the gas sponsor serves: only the
|
|
1995
|
+
* trade-only `*-as-delegate` kinds a session key signs. Owner (`AccountCap`) transactions, expire-order, deposit,
|
|
1996
|
+
* withdraw, delegate changes, liquidate, ... are never sponsored.
|
|
1997
|
+
*/
|
|
1998
|
+
export declare const PARCHMENT_SPONSORED_ACTIONS: readonly ["request-open-as-delegate", "request-close-as-delegate", "cancel-order-as-delegate", "emergency-close-as-delegate", "close-retired-as-delegate"];
|
|
1999
|
+
export type ParchmentSponsoredAction = (typeof PARCHMENT_SPONSORED_ACTIONS)[number];
|
|
2000
|
+
/** `POST /api/parchment/sponsor` body: a session key's `*-as-delegate` trade kind. The account is read from the kind. */
|
|
2001
|
+
export interface ApiParchmentSponsorBody {
|
|
2002
|
+
/** The session key's address (the delegate), sent as `sender`: the sender of the kind and of the sponsored tx. */
|
|
2003
|
+
walletAddress: string;
|
|
2004
|
+
/** Base64 BCS `TransactionKind`: {@link ParchmentBuiltTx.txBytesBase64}, or `tx.build({ onlyTransactionKind: true })`. */
|
|
2005
|
+
txKindBase64: string;
|
|
2006
|
+
/** The session key's personal-message signature of the proof (`signSponsorProof`). */
|
|
2007
|
+
senderSignature: string;
|
|
2008
|
+
/** Unix ms after which the service refuses the proof; at most 120 s ahead of its clock. */
|
|
2009
|
+
expiresAtMs: bigint;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* `POST /api/parchment/sponsor` 200 `data`. The session key signs `txBytesBase64` (full `TransactionData`, gas owner =
|
|
2013
|
+
* sponsor, address-balance gas) unchanged; execute with `[sessionSignature, sponsorSignature]` within `validEpoch`.
|
|
2014
|
+
* Amounts are MIST.
|
|
2015
|
+
*/
|
|
2016
|
+
export interface ParchmentSponsoredTx {
|
|
2017
|
+
txBytesBase64: string;
|
|
2018
|
+
sponsorSignature: string;
|
|
2019
|
+
digest: string;
|
|
2020
|
+
sender: string;
|
|
2021
|
+
sponsor: string;
|
|
2022
|
+
action: ParchmentSponsoredAction | string;
|
|
2023
|
+
gasMode: string;
|
|
2024
|
+
gasBudget: bigint;
|
|
2025
|
+
gasPrice: bigint;
|
|
2026
|
+
/** Simulated computation + storage (MIST), before the storage rebate. */
|
|
2027
|
+
estimatedGas: bigint;
|
|
2028
|
+
/** The only epoch the transaction can execute in. */
|
|
2029
|
+
validEpoch: bigint;
|
|
2030
|
+
}
|
|
2031
|
+
export {};
|