@parchment-trade/sdk 0.0.0-stage → 1.0.1
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 +193 -2
- package/REFERENCE.md +338 -0
- package/SECURITY.md +25 -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 +58 -4
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `GET stats/monitoring?days=N` : protocol monitoring indexed from on-chain events and
|
|
3
|
+
* objects. Days are UTC day numbers (`ms / 86_400_000`); every `days` series runs `fromDay` to
|
|
4
|
+
* `toDay`, oldest first. Amounts are USDC base units unless noted (PARCHMENT ones are named so).
|
|
5
|
+
*
|
|
6
|
+
* Not carried: the API's `queue.lossFeeOff` (the loss fee is carved even with a queue, so it
|
|
7
|
+
* no longer reports anything) and the referral reserve flow / balance (the staking referral
|
|
8
|
+
* bonus is paid from the treasury side, there is no shared reserve).
|
|
9
|
+
*/
|
|
10
|
+
export interface ParchmentMonitoring {
|
|
11
|
+
nowMs: bigint;
|
|
12
|
+
fromDay: bigint;
|
|
13
|
+
toDay: bigint;
|
|
14
|
+
/** False while the service is still folding history indexed before these stats existed. */
|
|
15
|
+
complete: boolean;
|
|
16
|
+
mintCap: ParchmentMintCapStats;
|
|
17
|
+
queue: ParchmentQueueStats;
|
|
18
|
+
exposure: ParchmentMarketExposure[];
|
|
19
|
+
fees: ParchmentFeeStats;
|
|
20
|
+
fillLag: ParchmentMarketFillLag[];
|
|
21
|
+
shortHolds: ParchmentShortHoldStats;
|
|
22
|
+
}
|
|
23
|
+
/** One finalized daily mint-cap epoch. */
|
|
24
|
+
export interface ParchmentMintEpoch {
|
|
25
|
+
epoch: bigint;
|
|
26
|
+
/** The pool's net trading gain as two sums (fees excluded). */
|
|
27
|
+
gainUp: bigint;
|
|
28
|
+
gainDown: bigint;
|
|
29
|
+
/** PARCHMENT mint room: `k x max(gain, 0)`. */
|
|
30
|
+
room: bigint;
|
|
31
|
+
carryIn: bigint;
|
|
32
|
+
/** Gross loss mints requested (PARCHMENT). */
|
|
33
|
+
provisional: bigint;
|
|
34
|
+
used: bigint;
|
|
35
|
+
/** `provisional - used`: PARCHMENT burned by the scale. */
|
|
36
|
+
excess: bigint;
|
|
37
|
+
scalePpm: bigint;
|
|
38
|
+
carryOut: bigint;
|
|
39
|
+
}
|
|
40
|
+
/** Loss mints settled on one day. */
|
|
41
|
+
export interface ParchmentMintDay {
|
|
42
|
+
day: bigint;
|
|
43
|
+
/** Trader losses that created mint basis. */
|
|
44
|
+
mintedLoss: bigint;
|
|
45
|
+
mintedCount: bigint;
|
|
46
|
+
/** Trader losses the contract flagged (wash or self-liquidation: no mint basis). */
|
|
47
|
+
flaggedLoss: bigint;
|
|
48
|
+
flaggedCount: bigint;
|
|
49
|
+
/** PARCHMENT locked by loss mints. */
|
|
50
|
+
minted: bigint;
|
|
51
|
+
/** PARCHMENT burned by the cap scale. */
|
|
52
|
+
scaleBurned: bigint;
|
|
53
|
+
}
|
|
54
|
+
export interface ParchmentMintCapStats {
|
|
55
|
+
lastEpoch: ParchmentMintEpoch | null;
|
|
56
|
+
epochs: ParchmentMintEpoch[];
|
|
57
|
+
days: ParchmentMintDay[];
|
|
58
|
+
/** Flagged share of the window's losses. */
|
|
59
|
+
flaggedShareBps: bigint | null;
|
|
60
|
+
/** Curve H. */
|
|
61
|
+
tailProgress: bigint | null;
|
|
62
|
+
}
|
|
63
|
+
/** The payout queue on one day; `entries` / `owedNet` / `oldestAgeMs` are end of day (now, today). */
|
|
64
|
+
export interface ParchmentQueueDay {
|
|
65
|
+
day: bigint;
|
|
66
|
+
enqueuedCount: bigint;
|
|
67
|
+
enqueuedNet: bigint;
|
|
68
|
+
payments: bigint;
|
|
69
|
+
paidNet: bigint;
|
|
70
|
+
completedCount: bigint;
|
|
71
|
+
entries: bigint;
|
|
72
|
+
owedNet: bigint;
|
|
73
|
+
oldestAgeMs: bigint | null;
|
|
74
|
+
}
|
|
75
|
+
export interface ParchmentQueueStats {
|
|
76
|
+
/** Claims with unpaid net, and that net. */
|
|
77
|
+
entries: bigint;
|
|
78
|
+
owedNet: bigint;
|
|
79
|
+
/** Queue nodes, including claims with only a fee left. */
|
|
80
|
+
nodes: bigint;
|
|
81
|
+
/** The exchange's `total_owed` (nets and queued fees). */
|
|
82
|
+
totalOwed: bigint;
|
|
83
|
+
oldestEnqueuedMs: bigint | null;
|
|
84
|
+
oldestAgeMs: bigint | null;
|
|
85
|
+
days: ParchmentQueueDay[];
|
|
86
|
+
}
|
|
87
|
+
/** One side of a market against its caps; null where the market has no such cap. */
|
|
88
|
+
export interface ParchmentSideExposure {
|
|
89
|
+
oi: bigint;
|
|
90
|
+
lockedExposure: bigint;
|
|
91
|
+
oiCap: bigint | null;
|
|
92
|
+
exposureCap: bigint | null;
|
|
93
|
+
/** Largest side OI at which a minimum-notional open still meets the payout-factor floor. */
|
|
94
|
+
depthCapacity: bigint | null;
|
|
95
|
+
oiUtilBps: bigint | null;
|
|
96
|
+
exposureUtilBps: bigint | null;
|
|
97
|
+
depthUtilBps: bigint | null;
|
|
98
|
+
/** Thin depth, not the OI cap, bounds this side. */
|
|
99
|
+
depthBound: boolean | null;
|
|
100
|
+
}
|
|
101
|
+
export interface ParchmentExposureDay {
|
|
102
|
+
day: bigint;
|
|
103
|
+
longOi: bigint;
|
|
104
|
+
shortOi: bigint;
|
|
105
|
+
longLocked: bigint;
|
|
106
|
+
shortLocked: bigint;
|
|
107
|
+
}
|
|
108
|
+
export interface ParchmentMarketExposure {
|
|
109
|
+
marketId: string;
|
|
110
|
+
symbol: string | null;
|
|
111
|
+
effectiveDepth: bigint | null;
|
|
112
|
+
long: ParchmentSideExposure;
|
|
113
|
+
short: ParchmentSideExposure;
|
|
114
|
+
days: ParchmentExposureDay[];
|
|
115
|
+
}
|
|
116
|
+
/** Fee and redistribution flows (USDC; `vestPenalty` and the forfeits are PARCHMENT). */
|
|
117
|
+
export interface ParchmentFeeFlows {
|
|
118
|
+
retained: bigint;
|
|
119
|
+
retainedStakers: bigint;
|
|
120
|
+
retainedTreasury: bigint;
|
|
121
|
+
winFee: bigint;
|
|
122
|
+
lossFee: bigint;
|
|
123
|
+
closeToll: bigint;
|
|
124
|
+
sweep: bigint;
|
|
125
|
+
sweepStakers: bigint;
|
|
126
|
+
sweepTreasury: bigint;
|
|
127
|
+
sweepGrowth: bigint;
|
|
128
|
+
stakerDeposit: bigint;
|
|
129
|
+
treasuryWithdrawn: bigint;
|
|
130
|
+
growthWithdrawn: bigint;
|
|
131
|
+
vestPenalty: bigint;
|
|
132
|
+
forfeitsSwept: bigint;
|
|
133
|
+
forfeitsClaimed: bigint;
|
|
134
|
+
}
|
|
135
|
+
export interface ParchmentFeeDay {
|
|
136
|
+
day: bigint;
|
|
137
|
+
flows: ParchmentFeeFlows;
|
|
138
|
+
}
|
|
139
|
+
export interface ParchmentFeeStats {
|
|
140
|
+
/** Every indexed flow since launch. */
|
|
141
|
+
totals: ParchmentFeeFlows;
|
|
142
|
+
days: ParchmentFeeDay[];
|
|
143
|
+
/** Pool coverage `lpCash / reserve`. */
|
|
144
|
+
coverageBps: bigint | null;
|
|
145
|
+
/** Stakers' share of the next retained fee at that coverage. */
|
|
146
|
+
stakerShareBps: bigint | null;
|
|
147
|
+
lpCash: bigint | null;
|
|
148
|
+
reserve: bigint | null;
|
|
149
|
+
treasuryBalance: bigint | null;
|
|
150
|
+
stakerBalance: bigint | null;
|
|
151
|
+
growthBalance: bigint | null;
|
|
152
|
+
}
|
|
153
|
+
/** Price age at two-step fills (ms): fill Clock less the storage price's timestamp (0 when ahead). */
|
|
154
|
+
export interface ParchmentLagStats {
|
|
155
|
+
count: bigint;
|
|
156
|
+
p50Ms: bigint | null;
|
|
157
|
+
p95Ms: bigint | null;
|
|
158
|
+
maxMs: bigint | null;
|
|
159
|
+
}
|
|
160
|
+
/** A signed gap (ms) over two-step fills; `missing` fills had no observation. */
|
|
161
|
+
export interface ParchmentGapStats {
|
|
162
|
+
count: bigint;
|
|
163
|
+
missing: bigint;
|
|
164
|
+
p50Ms: bigint | null;
|
|
165
|
+
p95Ms: bigint | null;
|
|
166
|
+
minMs: bigint | null;
|
|
167
|
+
maxMs: bigint | null;
|
|
168
|
+
}
|
|
169
|
+
/** Timing of two-step fills (opens and closes). */
|
|
170
|
+
export interface ParchmentFillLags {
|
|
171
|
+
priceAge: ParchmentLagStats;
|
|
172
|
+
/** The storage price's timestamp less the signed Lazer update's the fill submitted. */
|
|
173
|
+
lazerToStorage: ParchmentGapStats;
|
|
174
|
+
/** The signed Lazer update's timestamp less the order's request time. */
|
|
175
|
+
requestToLazer: ParchmentGapStats;
|
|
176
|
+
}
|
|
177
|
+
export interface ParchmentFillLagDay {
|
|
178
|
+
day: bigint;
|
|
179
|
+
lags: ParchmentFillLags;
|
|
180
|
+
}
|
|
181
|
+
export interface ParchmentMarketFillLag {
|
|
182
|
+
marketId: string;
|
|
183
|
+
symbol: string | null;
|
|
184
|
+
/** Over the window. */
|
|
185
|
+
window: ParchmentFillLags;
|
|
186
|
+
days: ParchmentFillLagDay[];
|
|
187
|
+
}
|
|
188
|
+
/** Settlements held under `thresholdMs`: `profit` sums the wins' net, `loss` the price-move losses. */
|
|
189
|
+
export interface ParchmentShortHolds {
|
|
190
|
+
positions: bigint;
|
|
191
|
+
/** Distinct wallets (account owners). */
|
|
192
|
+
wallets: bigint;
|
|
193
|
+
profit: bigint;
|
|
194
|
+
loss: bigint;
|
|
195
|
+
}
|
|
196
|
+
export interface ParchmentShortHoldDay {
|
|
197
|
+
/** The settlement day. */
|
|
198
|
+
day: bigint;
|
|
199
|
+
holds: ParchmentShortHolds;
|
|
200
|
+
}
|
|
201
|
+
export interface ParchmentMarketShortHolds {
|
|
202
|
+
marketId: string;
|
|
203
|
+
symbol: string | null;
|
|
204
|
+
window: ParchmentShortHolds;
|
|
205
|
+
days: ParchmentShortHoldDay[];
|
|
206
|
+
}
|
|
207
|
+
export interface ParchmentShortHoldStats {
|
|
208
|
+
/** A hold shorter than this (ms) is short. */
|
|
209
|
+
thresholdMs: bigint;
|
|
210
|
+
/** Every market over the window (wallets counted once). */
|
|
211
|
+
window: ParchmentShortHolds;
|
|
212
|
+
days: ParchmentShortHoldDay[];
|
|
213
|
+
markets: ParchmentMarketShortHolds[];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The `data` of `GET stats/monitoring` as it is served (integers still `"123n"` literals) to
|
|
217
|
+
* {@link ParchmentMonitoring}. Strict: a missing key, a wrong type, a non-canonical or
|
|
218
|
+
* out-of-range integer is `bad_body` naming its path. Other served keys are not carried.
|
|
219
|
+
*/
|
|
220
|
+
export declare function monitoringView(data: unknown): ParchmentMonitoring;
|
|
221
|
+
/** The service serves at most this many days (`days` above it is clamped there). */
|
|
222
|
+
export declare const MONITORING_MAX_DAYS = 366;
|
|
223
|
+
/** `stats/monitoring` with an optional `days` (a positive integer; the service defaults to 90). */
|
|
224
|
+
export declare function monitoringPath(days?: number | bigint): string;
|
|
225
|
+
/**
|
|
226
|
+
* One market's trading on one UTC day (or since launch, `allTime`). USDC base units.
|
|
227
|
+
* `volume` = `openedNotional + closedNotional`: the notional opened plus the notional of the
|
|
228
|
+
* positions closed or liquidated (at their open notional), the same definition as
|
|
229
|
+
* `markets/stats` `volume24h`. `liquidatedNotional` is the part of `closedNotional` that was
|
|
230
|
+
* liquidated; `fills` counts two-step order fills.
|
|
231
|
+
*/
|
|
232
|
+
export interface ParchmentMarketFlow {
|
|
233
|
+
volume: bigint;
|
|
234
|
+
openedNotional: bigint;
|
|
235
|
+
closedNotional: bigint;
|
|
236
|
+
liquidatedNotional: bigint;
|
|
237
|
+
liquidations: bigint;
|
|
238
|
+
fills: bigint;
|
|
239
|
+
}
|
|
240
|
+
export interface ParchmentMarketFlowDay extends ParchmentMarketFlow {
|
|
241
|
+
day: bigint;
|
|
242
|
+
}
|
|
243
|
+
export interface ParchmentMarketActivity {
|
|
244
|
+
marketId: string;
|
|
245
|
+
symbol: string | null;
|
|
246
|
+
/** Every indexed flow since launch. */
|
|
247
|
+
allTime: ParchmentMarketFlow;
|
|
248
|
+
/** One row per day, `fromDay` to `toDay` (zeros on a quiet day). */
|
|
249
|
+
days: ParchmentMarketFlowDay[];
|
|
250
|
+
}
|
|
251
|
+
/** USDC moved into (`DepositEventV1`) and out of (`WithdrawEventV1`) trading accounts. */
|
|
252
|
+
export interface ParchmentCollateralFlow {
|
|
253
|
+
deposits: bigint;
|
|
254
|
+
depositCount: bigint;
|
|
255
|
+
withdrawals: bigint;
|
|
256
|
+
withdrawalCount: bigint;
|
|
257
|
+
}
|
|
258
|
+
export interface ParchmentCollateralFlowDay extends ParchmentCollateralFlow {
|
|
259
|
+
day: bigint;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* `GET stats/activity?days=N`: daily per-market volume, liquidations and fills, and daily
|
|
263
|
+
* collateral deposits vs withdrawals, each with its since-launch total (so a chart can draw the
|
|
264
|
+
* all-time running total under any window: the total less the days after each day).
|
|
265
|
+
*/
|
|
266
|
+
export interface ParchmentStatsActivity {
|
|
267
|
+
nowMs: bigint;
|
|
268
|
+
fromDay: bigint;
|
|
269
|
+
toDay: bigint;
|
|
270
|
+
/** False while the service is still folding history indexed before these stats existed. */
|
|
271
|
+
complete: boolean;
|
|
272
|
+
markets: ParchmentMarketActivity[];
|
|
273
|
+
collateral: {
|
|
274
|
+
allTime: ParchmentCollateralFlow;
|
|
275
|
+
days: ParchmentCollateralFlowDay[];
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* The `data` of `GET stats/activity` as served (integers `"123n"` literals) to
|
|
280
|
+
* {@link ParchmentStatsActivity}. Strict like {@link monitoringView}: a missing key, a wrong type or a
|
|
281
|
+
* bad integer is `bad_body` naming its path.
|
|
282
|
+
*/
|
|
283
|
+
export declare function statsActivityView(data: unknown): ParchmentStatsActivity;
|
|
284
|
+
/** `stats/activity` with an optional `days` (a positive integer; the service defaults to 90, at most {@link MONITORING_MAX_DAYS}). */
|
|
285
|
+
export declare function statsActivityPath(days?: number | bigint): string;
|
|
286
|
+
/** The windows `GET stats/staking-history` serves. */
|
|
287
|
+
export declare const STAKING_HISTORY_WINDOWS: readonly ["7", "30", "90", "all"];
|
|
288
|
+
export type ParchmentStakingHistoryDays = (typeof STAKING_HISTORY_WINDOWS)[number];
|
|
289
|
+
/**
|
|
290
|
+
* One staking pool snapshot (the service records one every 15 minutes). Cumulative since the
|
|
291
|
+
* service's baseline: `rewardsVestedUsdc` (USDC base units, 6 decimals) and `parchDripVested`
|
|
292
|
+
* (PARCHMENT base units, 9 decimals) only grow; `totalStaked` is the pool's stake then (PARCHMENT
|
|
293
|
+
* base units). `parchmentUsdWad` is the PARCHMENT/USD quote at that snapshot (1e18 = $1), null
|
|
294
|
+
* when the snapshot had none.
|
|
295
|
+
*/
|
|
296
|
+
export interface ParchmentStakingHistoryPoint {
|
|
297
|
+
tsMs: bigint;
|
|
298
|
+
totalStaked: bigint;
|
|
299
|
+
rewardsVestedUsdc: bigint;
|
|
300
|
+
parchDripVested: bigint;
|
|
301
|
+
parchmentUsdWad: bigint | null;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* `GET stats/staking-history?days=7|30|90|all`: the pool's realized staking rate over the window
|
|
305
|
+
* and the snapshots behind it. `aprWad` (1e18 = 100%) is the USD value of the rewards vested in the
|
|
306
|
+
* observed span (USDC plus the PARCHMENT drip at the current quote) over the time-weighted average
|
|
307
|
+
* stake at that quote, annualized; null when there is no quote or no observed span. `apyWad` is that
|
|
308
|
+
* APR compounded once per observed span, null when the APR is or when the APY is past the
|
|
309
|
+
* representable range (never the APR in its place). `partial` is a window the snapshots do not
|
|
310
|
+
* cover (or whose last snapshot is over an hour old); `annualized` is a partial window that still
|
|
311
|
+
* produced an APR. Points are oldest first, at most 500 (the service thins longer windows).
|
|
312
|
+
*/
|
|
313
|
+
export interface ParchmentStakingHistory {
|
|
314
|
+
days: ParchmentStakingHistoryDays;
|
|
315
|
+
partial: boolean;
|
|
316
|
+
annualized: boolean;
|
|
317
|
+
fromMs: bigint;
|
|
318
|
+
toMs: bigint;
|
|
319
|
+
observedMs: bigint;
|
|
320
|
+
/** Null for `all`. */
|
|
321
|
+
windowMs: bigint | null;
|
|
322
|
+
aprWad: bigint | null;
|
|
323
|
+
apyWad: bigint | null;
|
|
324
|
+
rewardUsdc: bigint;
|
|
325
|
+
rewardParchment: bigint;
|
|
326
|
+
avgStake: bigint;
|
|
327
|
+
parchmentUsdWad: bigint | null;
|
|
328
|
+
parchmentUsdTsMs: bigint | null;
|
|
329
|
+
parchmentUsdSource: string | null;
|
|
330
|
+
points: ParchmentStakingHistoryPoint[];
|
|
331
|
+
/**
|
|
332
|
+
* The exact per-UTC-day aggregate (parchment-service `staking_daily`), oldest first: every day
|
|
333
|
+
* overlapping the window (for `all`, every day, merged into runs of consecutive days past 500).
|
|
334
|
+
* Absent (`undefined`) from a service that predates it; `[]` while the service has not built it.
|
|
335
|
+
*/
|
|
336
|
+
daily?: ParchmentStakingDay[];
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* One UTC day of the exact daily staking aggregate. The service replays every indexed stake,
|
|
340
|
+
* unstake, reward deposit and forfeit sweep through the contract's accrual, so `rewardUsdc` (USDC
|
|
341
|
+
* base units) and `rewardParchment` (PARCHMENT base units) are exactly what vested to stakers in
|
|
342
|
+
* `[fromMs, toMs]`, and `avgStake` is the stake integrated over every change in that span, divided
|
|
343
|
+
* by `observedMs`. `aprWad` (1e18 = 100%) is the USD value of those rewards (PARCHMENT at
|
|
344
|
+
* `parchmentUsdWad`: the day's last snapshot quote, else the current one) over the time-weighted
|
|
345
|
+
* stake at the same quote, annualized over `observedMs`; null without a quote or without stake.
|
|
346
|
+
* `dayMs` is the day's UTC midnight (the first day of a merged run); `final` is a closed day (the
|
|
347
|
+
* open day runs to the indexer's clock). A partial day (`observedMs` under a day) is the pool's
|
|
348
|
+
* first day, the open day, or a span the service could not verify.
|
|
349
|
+
*/
|
|
350
|
+
export interface ParchmentStakingDay {
|
|
351
|
+
dayMs: bigint;
|
|
352
|
+
fromMs: bigint;
|
|
353
|
+
toMs: bigint;
|
|
354
|
+
observedMs: bigint;
|
|
355
|
+
final: boolean;
|
|
356
|
+
rewardUsdc: bigint;
|
|
357
|
+
rewardParchment: bigint;
|
|
358
|
+
avgStake: bigint;
|
|
359
|
+
parchmentUsdWad: bigint | null;
|
|
360
|
+
aprWad: bigint | null;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* The `data` of `GET stats/staking-history` as served (integers `"123n"` literals) to
|
|
364
|
+
* {@link ParchmentStakingHistory}. Strict like {@link monitoringView}: a missing key, a wrong type or
|
|
365
|
+
* a bad integer is `bad_body` naming its path.
|
|
366
|
+
*/
|
|
367
|
+
export declare function stakingHistoryView(data: unknown): ParchmentStakingHistory;
|
|
368
|
+
/** `stats/staking-history?days=` for one of {@link STAKING_HISTORY_WINDOWS}; anything else is `bad_request`. */
|
|
369
|
+
export declare function stakingHistoryPath(days: ParchmentStakingHistoryDays): string;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { normalizeAddress } from "../../general/utils/address.js";
|
|
2
|
+
import { ParchmentApiError } from "../../general/utils/errors.js";
|
|
3
|
+
import { parseJsBigInt } from "../../general/utils/jsBigInt.js";
|
|
4
|
+
const bad = (message) => new ParchmentApiError(0, "bad_body", message);
|
|
5
|
+
function obj(value, path) {
|
|
6
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
7
|
+
throw bad(`${path}: expected an object`);
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
function field(o, key, path) {
|
|
11
|
+
if (!(key in o))
|
|
12
|
+
throw bad(`${path}.${key} is missing`);
|
|
13
|
+
return o[key];
|
|
14
|
+
}
|
|
15
|
+
function int(o, key, path, kind = "u64") {
|
|
16
|
+
return parseJsBigInt(field(o, key, path), `${path}.${key}`, kind);
|
|
17
|
+
}
|
|
18
|
+
function intOrNull(o, key, path, kind = "u64") {
|
|
19
|
+
const value = field(o, key, path);
|
|
20
|
+
return value === null ? null : parseJsBigInt(value, `${path}.${key}`, kind);
|
|
21
|
+
}
|
|
22
|
+
function bool(o, key, path) {
|
|
23
|
+
const value = field(o, key, path);
|
|
24
|
+
if (typeof value !== "boolean")
|
|
25
|
+
throw bad(`${path}.${key} must be a boolean`);
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
function boolOrNull(o, key, path) {
|
|
29
|
+
return field(o, key, path) === null ? null : bool(o, key, path);
|
|
30
|
+
}
|
|
31
|
+
function textOrNull(o, key, path) {
|
|
32
|
+
const value = field(o, key, path);
|
|
33
|
+
if (value !== null && typeof value !== "string")
|
|
34
|
+
throw bad(`${path}.${key} must be a string`);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function marketId(o, path) {
|
|
38
|
+
const value = field(o, "marketId", path);
|
|
39
|
+
try {
|
|
40
|
+
if (typeof value === "string")
|
|
41
|
+
return normalizeAddress(value);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
}
|
|
45
|
+
throw bad(`${path}.marketId is not an object id`);
|
|
46
|
+
}
|
|
47
|
+
function list(o, key, path, item) {
|
|
48
|
+
const value = field(o, key, path);
|
|
49
|
+
if (!Array.isArray(value))
|
|
50
|
+
throw bad(`${path}.${key}: expected a list`);
|
|
51
|
+
return value.map((v, i) => {
|
|
52
|
+
const at = `${path}.${key}[${i}]`;
|
|
53
|
+
return item(obj(v, at), at);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function child(o, key, path, read) {
|
|
57
|
+
return read(obj(field(o, key, path), `${path}.${key}`), `${path}.${key}`);
|
|
58
|
+
}
|
|
59
|
+
function ints(o, path, keys, kind) {
|
|
60
|
+
return Object.fromEntries(keys.map((k) => [k, int(o, k, path, kind)]));
|
|
61
|
+
}
|
|
62
|
+
function nullableInts(o, path, keys, kind) {
|
|
63
|
+
return Object.fromEntries(keys.map((k) => [k, intOrNull(o, k, path, kind)]));
|
|
64
|
+
}
|
|
65
|
+
const mintEpoch = (o, p) => ({
|
|
66
|
+
...ints(o, p, ["epoch", "room", "provisional", "used", "excess", "scalePpm"], "u64"),
|
|
67
|
+
...ints(o, p, ["gainUp", "gainDown", "carryIn", "carryOut"], "u128"),
|
|
68
|
+
});
|
|
69
|
+
const mintDay = (o, p) => ({
|
|
70
|
+
...ints(o, p, ["day", "mintedCount", "flaggedCount"], "u64"),
|
|
71
|
+
...ints(o, p, ["mintedLoss", "flaggedLoss", "minted", "scaleBurned"], "u128"),
|
|
72
|
+
});
|
|
73
|
+
const mintCap = (o, p) => ({
|
|
74
|
+
lastEpoch: field(o, "lastEpoch", p) === null ? null : child(o, "lastEpoch", p, mintEpoch),
|
|
75
|
+
epochs: list(o, "epochs", p, mintEpoch),
|
|
76
|
+
days: list(o, "days", p, mintDay),
|
|
77
|
+
...nullableInts(o, p, ["flaggedShareBps", "tailProgress"], "u64"),
|
|
78
|
+
});
|
|
79
|
+
const queueDay = (o, p) => ({
|
|
80
|
+
...ints(o, p, ["day", "enqueuedCount", "payments", "completedCount", "entries"], "u64"),
|
|
81
|
+
...ints(o, p, ["enqueuedNet", "paidNet", "owedNet"], "u128"),
|
|
82
|
+
oldestAgeMs: intOrNull(o, "oldestAgeMs", p),
|
|
83
|
+
});
|
|
84
|
+
const queue = (o, p) => ({
|
|
85
|
+
...ints(o, p, ["entries", "nodes"], "u64"),
|
|
86
|
+
...ints(o, p, ["owedNet", "totalOwed"], "u128"),
|
|
87
|
+
...nullableInts(o, p, ["oldestEnqueuedMs", "oldestAgeMs"], "u64"),
|
|
88
|
+
days: list(o, "days", p, queueDay),
|
|
89
|
+
});
|
|
90
|
+
const side = (o, p) => ({
|
|
91
|
+
...ints(o, p, ["oi", "lockedExposure"], "u64"),
|
|
92
|
+
...nullableInts(o, p, ["oiCap", "exposureCap", "depthCapacity", "oiUtilBps", "exposureUtilBps", "depthUtilBps"], "u64"),
|
|
93
|
+
depthBound: boolOrNull(o, "depthBound", p),
|
|
94
|
+
});
|
|
95
|
+
const exposureDay = (o, p) => ints(o, p, ["day", "longOi", "shortOi", "longLocked", "shortLocked"], "u64");
|
|
96
|
+
const marketExposure = (o, p) => ({
|
|
97
|
+
marketId: marketId(o, p),
|
|
98
|
+
symbol: textOrNull(o, "symbol", p),
|
|
99
|
+
effectiveDepth: intOrNull(o, "effectiveDepth", p),
|
|
100
|
+
long: child(o, "long", p, side),
|
|
101
|
+
short: child(o, "short", p, side),
|
|
102
|
+
days: list(o, "days", p, exposureDay),
|
|
103
|
+
});
|
|
104
|
+
const FEE_FLOW_KEYS = [
|
|
105
|
+
"retained",
|
|
106
|
+
"retainedStakers",
|
|
107
|
+
"retainedTreasury",
|
|
108
|
+
"winFee",
|
|
109
|
+
"lossFee",
|
|
110
|
+
"closeToll",
|
|
111
|
+
"sweep",
|
|
112
|
+
"sweepStakers",
|
|
113
|
+
"sweepTreasury",
|
|
114
|
+
"sweepGrowth",
|
|
115
|
+
"stakerDeposit",
|
|
116
|
+
"treasuryWithdrawn",
|
|
117
|
+
"growthWithdrawn",
|
|
118
|
+
"vestPenalty",
|
|
119
|
+
"forfeitsSwept",
|
|
120
|
+
"forfeitsClaimed",
|
|
121
|
+
];
|
|
122
|
+
const feeFlows = (o, p) => ints(o, p, FEE_FLOW_KEYS, "u128");
|
|
123
|
+
const fees = (o, p) => ({
|
|
124
|
+
totals: child(o, "totals", p, feeFlows),
|
|
125
|
+
days: list(o, "days", p, (d, dp) => ({ day: int(d, "day", dp), flows: child(d, "flows", dp, feeFlows) })),
|
|
126
|
+
...nullableInts(o, p, ["coverageBps", "stakerShareBps", "lpCash", "treasuryBalance", "stakerBalance", "growthBalance"], "u64"),
|
|
127
|
+
reserve: intOrNull(o, "reserve", p, "u128"),
|
|
128
|
+
});
|
|
129
|
+
const lag = (o, p) => ({
|
|
130
|
+
count: int(o, "count", p),
|
|
131
|
+
...nullableInts(o, p, ["p50Ms", "p95Ms", "maxMs"], "u64"),
|
|
132
|
+
});
|
|
133
|
+
const gap = (o, p) => ({
|
|
134
|
+
...ints(o, p, ["count", "missing"], "u64"),
|
|
135
|
+
...nullableInts(o, p, ["p50Ms", "p95Ms", "minMs", "maxMs"], "i64"),
|
|
136
|
+
});
|
|
137
|
+
const fillLags = (o, p) => ({
|
|
138
|
+
priceAge: child(o, "priceAge", p, lag),
|
|
139
|
+
lazerToStorage: child(o, "lazerToStorage", p, gap),
|
|
140
|
+
requestToLazer: child(o, "requestToLazer", p, gap),
|
|
141
|
+
});
|
|
142
|
+
const marketFillLag = (o, p) => ({
|
|
143
|
+
marketId: marketId(o, p),
|
|
144
|
+
symbol: textOrNull(o, "symbol", p),
|
|
145
|
+
window: child(o, "window", p, fillLags),
|
|
146
|
+
days: list(o, "days", p, (d, dp) => ({ day: int(d, "day", dp), lags: child(d, "lags", dp, fillLags) })),
|
|
147
|
+
});
|
|
148
|
+
const holds = (o, p) => ({
|
|
149
|
+
...ints(o, p, ["positions", "wallets"], "u64"),
|
|
150
|
+
...ints(o, p, ["profit", "loss"], "u128"),
|
|
151
|
+
});
|
|
152
|
+
const holdDay = (o, p) => ({ day: int(o, "day", p), holds: child(o, "holds", p, holds) });
|
|
153
|
+
const shortHolds = (o, p) => ({
|
|
154
|
+
thresholdMs: int(o, "thresholdMs", p),
|
|
155
|
+
window: child(o, "window", p, holds),
|
|
156
|
+
days: list(o, "days", p, holdDay),
|
|
157
|
+
markets: list(o, "markets", p, (m, mp) => ({
|
|
158
|
+
marketId: marketId(m, mp),
|
|
159
|
+
symbol: textOrNull(m, "symbol", mp),
|
|
160
|
+
window: child(m, "window", mp, holds),
|
|
161
|
+
days: list(m, "days", mp, holdDay),
|
|
162
|
+
})),
|
|
163
|
+
});
|
|
164
|
+
export function monitoringView(data) {
|
|
165
|
+
const p = "data";
|
|
166
|
+
const o = obj(data, p);
|
|
167
|
+
return {
|
|
168
|
+
...ints(o, p, ["nowMs", "fromDay", "toDay"], "u64"),
|
|
169
|
+
complete: bool(o, "complete", p),
|
|
170
|
+
mintCap: child(o, "mintCap", p, mintCap),
|
|
171
|
+
queue: child(o, "queue", p, queue),
|
|
172
|
+
exposure: list(o, "exposure", p, marketExposure),
|
|
173
|
+
fees: child(o, "fees", p, fees),
|
|
174
|
+
fillLag: list(o, "fillLag", p, marketFillLag),
|
|
175
|
+
shortHolds: child(o, "shortHolds", p, shortHolds),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export const MONITORING_MAX_DAYS = 366;
|
|
179
|
+
export function monitoringPath(days) {
|
|
180
|
+
if (days === undefined)
|
|
181
|
+
return "stats/monitoring";
|
|
182
|
+
const ok = typeof days === "bigint" ? days > 0n : Number.isSafeInteger(days) && days > 0;
|
|
183
|
+
if (!ok)
|
|
184
|
+
throw new ParchmentApiError(0, "bad_request", "days must be a positive integer");
|
|
185
|
+
return `stats/monitoring?days=${days}`;
|
|
186
|
+
}
|
|
187
|
+
const marketFlow = (o, p) => ({
|
|
188
|
+
...ints(o, p, ["volume", "openedNotional", "closedNotional", "liquidatedNotional"], "u128"),
|
|
189
|
+
...ints(o, p, ["liquidations", "fills"], "u64"),
|
|
190
|
+
});
|
|
191
|
+
const collateralFlow = (o, p) => ({
|
|
192
|
+
...ints(o, p, ["deposits", "withdrawals"], "u128"),
|
|
193
|
+
...ints(o, p, ["depositCount", "withdrawalCount"], "u64"),
|
|
194
|
+
});
|
|
195
|
+
export function statsActivityView(data) {
|
|
196
|
+
const p = "data";
|
|
197
|
+
const o = obj(data, p);
|
|
198
|
+
return {
|
|
199
|
+
...ints(o, p, ["nowMs", "fromDay", "toDay"], "u64"),
|
|
200
|
+
complete: bool(o, "complete", p),
|
|
201
|
+
markets: list(o, "markets", p, (m, mp) => ({
|
|
202
|
+
marketId: marketId(m, mp),
|
|
203
|
+
symbol: textOrNull(m, "symbol", mp),
|
|
204
|
+
allTime: child(m, "allTime", mp, marketFlow),
|
|
205
|
+
days: list(m, "days", mp, (d, dp) => ({ day: int(d, "day", dp), ...marketFlow(d, dp) })),
|
|
206
|
+
})),
|
|
207
|
+
collateral: child(o, "collateral", p, (c, cp) => ({
|
|
208
|
+
allTime: child(c, "allTime", cp, collateralFlow),
|
|
209
|
+
days: list(c, "days", cp, (d, dp) => ({ day: int(d, "day", dp), ...collateralFlow(d, dp) })),
|
|
210
|
+
})),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
export function statsActivityPath(days) {
|
|
214
|
+
return monitoringPath(days).replace(/^stats\/monitoring/, "stats/activity");
|
|
215
|
+
}
|
|
216
|
+
export const STAKING_HISTORY_WINDOWS = ["7", "30", "90", "all"];
|
|
217
|
+
function stakingDays(o, path) {
|
|
218
|
+
const value = field(o, "days", path);
|
|
219
|
+
const hit = STAKING_HISTORY_WINDOWS.find((d) => d === value);
|
|
220
|
+
if (hit === undefined)
|
|
221
|
+
throw bad(`${path}.days must be one of ${STAKING_HISTORY_WINDOWS.join(", ")}`);
|
|
222
|
+
return hit;
|
|
223
|
+
}
|
|
224
|
+
const stakingPoint = (o, p) => ({
|
|
225
|
+
tsMs: int(o, "tsMs", p, "i64"),
|
|
226
|
+
...ints(o, p, ["totalStaked", "rewardsVestedUsdc", "parchDripVested"], "u128"),
|
|
227
|
+
parchmentUsdWad: intOrNull(o, "parchmentUsdWad", p, "u128"),
|
|
228
|
+
});
|
|
229
|
+
const stakingDay = (o, p) => ({
|
|
230
|
+
...ints(o, p, ["dayMs", "fromMs", "toMs"], "i64"),
|
|
231
|
+
observedMs: int(o, "observedMs", p, "u128"),
|
|
232
|
+
final: bool(o, "final", p),
|
|
233
|
+
...ints(o, p, ["rewardUsdc", "rewardParchment", "avgStake"], "u128"),
|
|
234
|
+
...nullableInts(o, p, ["parchmentUsdWad", "aprWad"], "u128"),
|
|
235
|
+
});
|
|
236
|
+
export function stakingHistoryView(data) {
|
|
237
|
+
const p = "data";
|
|
238
|
+
const o = obj(data, p);
|
|
239
|
+
return {
|
|
240
|
+
days: stakingDays(o, p),
|
|
241
|
+
partial: bool(o, "partial", p),
|
|
242
|
+
annualized: bool(o, "annualized", p),
|
|
243
|
+
...ints(o, p, ["fromMs", "toMs"], "i64"),
|
|
244
|
+
observedMs: int(o, "observedMs", p, "u128"),
|
|
245
|
+
windowMs: intOrNull(o, "windowMs", p, "i64"),
|
|
246
|
+
...nullableInts(o, p, ["aprWad", "apyWad"], "u128"),
|
|
247
|
+
...ints(o, p, ["rewardUsdc", "rewardParchment", "avgStake"], "u128"),
|
|
248
|
+
parchmentUsdWad: intOrNull(o, "parchmentUsdWad", p, "u128"),
|
|
249
|
+
parchmentUsdTsMs: intOrNull(o, "parchmentUsdTsMs", p, "i64"),
|
|
250
|
+
parchmentUsdSource: textOrNull(o, "parchmentUsdSource", p),
|
|
251
|
+
points: list(o, "points", p, stakingPoint),
|
|
252
|
+
...(o.daily === undefined ? {} : { daily: list(o, "daily", p, stakingDay) }),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export function stakingHistoryPath(days) {
|
|
256
|
+
if (!STAKING_HISTORY_WINDOWS.includes(days))
|
|
257
|
+
throw new ParchmentApiError(0, "bad_request", "days must be 7, 30, 90, or all");
|
|
258
|
+
return `stats/staking-history?days=${days}`;
|
|
259
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Note parchment-service attaches to request-open / request-close (and `-as-delegate`) tx bytes,
|
|
3
|
+
* byte-for-byte the service `tx::ORDER_NOTE` and the legacy API `ORDER_TX_NOTE`. Also served as
|
|
4
|
+
* `orderTxNote` by `GET /api/parchment/limits`. These requests carry no price.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ORDER_TX_NOTE = "Two-step order: the request escrows margin plus the execution fee; a keeper fills it at the first signed mid after the request (no spread) or refunds it. Poll GET /v1/orders/{orderId}.";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ORDER_TX_NOTE = "Two-step order: the request escrows margin plus the execution fee; a keeper fills it at the first signed mid after the request (no spread) or refunds it. Poll GET /v1/orders/{orderId}.";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
+
type ObjectInput = string | TransactionObjectArgument;
|
|
3
|
+
export interface OneSignatureOnboardingCalls {
|
|
4
|
+
/** Core `parchment` package id (call target; the `exchange` module). */
|
|
5
|
+
packageId: string;
|
|
6
|
+
/** Collateral coin type `C` (USDC; `new_account` aborts `exchange::ENotUsdc` otherwise). */
|
|
7
|
+
coinType: string;
|
|
8
|
+
exchange: ObjectInput;
|
|
9
|
+
config: ObjectInput;
|
|
10
|
+
/** `Coin<C>` to deposit into the new account (a non-zero coin, `exchange::EZero` otherwise). Omit to skip the deposit. */
|
|
11
|
+
deposit?: ObjectInput;
|
|
12
|
+
/** Session key and optional close delegate to authorize on the new account. Omit to skip the grant. */
|
|
13
|
+
delegate?: {
|
|
14
|
+
address: string;
|
|
15
|
+
expiryMs: bigint | number;
|
|
16
|
+
closeDelegate?: string;
|
|
17
|
+
};
|
|
18
|
+
/** Transaction sender; `share_account` sends it the `AccountCap`. */
|
|
19
|
+
sender: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One-signature onboarding (Option A) in one PTB: `exchange::new_account<C>(exchange, config)` returns
|
|
23
|
+
* `(Account, AccountCap, AccountReceipt)`; then `exchange::deposit<C>(exchange, config, account, cap, coin)`
|
|
24
|
+
* when `deposit` is given, `exchange::grant_delegate<C>(exchange, account, config, cap, delegate, expiry_ms, clock)`
|
|
25
|
+
* when `delegate` is given (or `grant_session_and_close_delegate` when it has a `closeDelegate`), and `exchange::share_account<C>(account, cap, receipt)` (the receipt is a hot potato,
|
|
26
|
+
* so the account is always shared in this transaction; `exchange::EReceiptMismatch` 12 for another account's
|
|
27
|
+
* receipt). `share_account` also sends the cap to the transaction sender: `AccountCap` is key-only, so a PTB
|
|
28
|
+
* `TransferObjects` cannot move it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function addOneSignatureOnboardingCalls(tx: Transaction, input: OneSignatureOnboardingCalls): void;
|
|
31
|
+
export interface AccountIdInput {
|
|
32
|
+
/** The `Exchange<C>` the account is derived from. */
|
|
33
|
+
exchangeId: string;
|
|
34
|
+
/** The ORIGINAL `parchment` package id (the one that defines `account::AccountKey`), not a later version. */
|
|
35
|
+
originalPackageId: string;
|
|
36
|
+
owner: string;
|
|
37
|
+
/**
|
|
38
|
+
* The opener's derivation nonce: 0 for a wallet's first account; after it transferred accounts away
|
|
39
|
+
* (`account_transfer::transfer_account`), the number of accounts it opened before (the service's
|
|
40
|
+
* `nextAccountNonce`). Default 0.
|
|
41
|
+
*/
|
|
42
|
+
nonce?: bigint | number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The id of `owner`'s `Account` on `exchangeId`, known before it exists: `account::create` claims it with
|
|
46
|
+
* `derived_object::claim(exchange, AccountKey { owner, nonce })`, for `open_account` and `new_account` alike. Lets a
|
|
47
|
+
* client key per-account state (e.g. a session key granted in the onboarding PTB) before the index serves the account.
|
|
48
|
+
*/
|
|
49
|
+
export declare function deriveAccountId(input: AccountIdInput): string;
|
|
50
|
+
export {};
|