@percolatorct/sdk 1.0.0-beta.3 → 1.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -4
- package/dist/abi/accounts.d.ts +31 -16
- package/dist/abi/errors.d.ts +0 -11
- package/dist/abi/index.d.ts +1 -0
- package/dist/abi/instructions.d.ts +297 -146
- package/dist/abi/nft.d.ts +134 -0
- package/dist/config/program-ids.d.ts +2 -2
- package/dist/index.js +1473 -597
- package/dist/index.js.map +1 -1
- package/dist/math/trading.d.ts +1 -116
- package/dist/math/warmup.d.ts +0 -50
- package/dist/runtime/lighthouse.d.ts +1 -1
- package/dist/solana/discovery.d.ts +2 -13
- package/dist/solana/oracle.d.ts +2 -10
- package/dist/solana/pda.d.ts +5 -5
- package/dist/solana/slab.d.ts +132 -5
- package/dist/solana/stake.d.ts +27 -2
- package/dist/validation.d.ts +1 -26
- package/package.json +2 -1
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
/**
|
|
3
|
-
* Oracle price constraints.
|
|
4
|
-
* Maximum oracle price that can be pushed to the on-chain oracle authority.
|
|
5
|
-
*/
|
|
6
|
-
export declare const MAX_ORACLE_PRICE = 1000000000000n;
|
|
7
2
|
/**
|
|
8
3
|
* Instruction tags - exact match to Rust ix::Instruction::decode
|
|
9
4
|
*/
|
|
@@ -24,19 +19,21 @@ export declare const IX_TAG: {
|
|
|
24
19
|
readonly CloseSlab: 13;
|
|
25
20
|
readonly UpdateConfig: 14;
|
|
26
21
|
readonly SetMaintenanceFee: 15;
|
|
27
|
-
readonly SetOracleAuthority: 16;
|
|
28
|
-
readonly PushOraclePrice: 17;
|
|
29
22
|
readonly SetOraclePriceCap: 18;
|
|
30
23
|
readonly ResolveMarket: 19;
|
|
31
24
|
readonly WithdrawInsurance: 20;
|
|
32
25
|
readonly AdminForceClose: 21;
|
|
33
|
-
readonly
|
|
34
|
-
readonly
|
|
35
|
-
readonly
|
|
36
|
-
readonly
|
|
37
|
-
readonly
|
|
38
|
-
readonly
|
|
39
|
-
readonly
|
|
26
|
+
readonly SetInsuranceWithdrawPolicy: 22;
|
|
27
|
+
/** @deprecated Use SetInsuranceWithdrawPolicy */ readonly UpdateRiskParams: 22;
|
|
28
|
+
readonly WithdrawInsuranceLimited: 23;
|
|
29
|
+
/** @deprecated Use WithdrawInsuranceLimited */ readonly RenounceAdmin: 23;
|
|
30
|
+
readonly QueryLpFees: 24;
|
|
31
|
+
readonly ReclaimEmptyAccount: 25;
|
|
32
|
+
readonly SettleAccount: 26;
|
|
33
|
+
readonly DepositFeeCredits: 27;
|
|
34
|
+
readonly ConvertReleasedPnl: 28;
|
|
35
|
+
readonly ResolvePermissionless: 29;
|
|
36
|
+
readonly ForceCloseResolved: 30;
|
|
40
37
|
readonly SetPythOracle: 32;
|
|
41
38
|
readonly UpdateMarkPrice: 33;
|
|
42
39
|
readonly UpdateHyperpMark: 34;
|
|
@@ -78,8 +75,6 @@ export declare const IX_TAG: {
|
|
|
78
75
|
readonly AttestCrossMargin: 55;
|
|
79
76
|
/** PERC-622: Advance oracle phase (permissionless crank) */
|
|
80
77
|
readonly AdvanceOraclePhase: 56;
|
|
81
|
-
/** PERC-623: Top up a market's keeper fund (permissionless) */
|
|
82
|
-
readonly TopUpKeeperFund: 57;
|
|
83
78
|
/** PERC-629: Slash a market creator's deposit (permissionless) */
|
|
84
79
|
readonly SlashCreationDeposit: 58;
|
|
85
80
|
/** PERC-628: Initialize the global shared vault (admin) */
|
|
@@ -116,6 +111,20 @@ export declare const IX_TAG: {
|
|
|
116
111
|
readonly SetDexPool: 74;
|
|
117
112
|
/** CPI to the matcher program to initialize a matcher context account for an LP slot. Admin-only. */
|
|
118
113
|
readonly InitMatcherCtx: 75;
|
|
114
|
+
/** PauseMarket (tag 76): admin emergency pause. Blocks Trade/Deposit/Withdraw/InitUser. */
|
|
115
|
+
readonly PauseMarket: 76;
|
|
116
|
+
/** UnpauseMarket (tag 77): admin unpause. Re-enables all operations. */
|
|
117
|
+
readonly UnpauseMarket: 77;
|
|
118
|
+
/** PERC-305 / SECURITY(H-4): Set PnL cap for ADL pre-check (admin only). */
|
|
119
|
+
readonly SetMaxPnlCap: 78;
|
|
120
|
+
/** PERC-309: Set OI cap multiplier for LP withdrawal limits (admin only). Packed u64. */
|
|
121
|
+
readonly SetOiCapMultiplier: 79;
|
|
122
|
+
/** PERC-314: Set dispute params (window_slots + bond_amount, admin only). */
|
|
123
|
+
readonly SetDisputeParams: 80;
|
|
124
|
+
/** PERC-315: Set LP collateral params (enabled + ltv_bps, admin only). */
|
|
125
|
+
readonly SetLpCollateralParams: 81;
|
|
126
|
+
/** Phase E (2026-04-17): Accept a pending admin transfer. Signer must match pending_admin. */
|
|
127
|
+
readonly AcceptAdmin: 82;
|
|
119
128
|
};
|
|
120
129
|
/**
|
|
121
130
|
* InitMarket instruction data (256 bytes total)
|
|
@@ -135,19 +144,33 @@ export interface InitMarketArgs {
|
|
|
135
144
|
invert: number;
|
|
136
145
|
unitScale: number;
|
|
137
146
|
initialMarkPriceE6: bigint | string;
|
|
138
|
-
|
|
147
|
+
maxMaintenanceFeePerSlot?: bigint | string;
|
|
148
|
+
maxInsuranceFloor?: bigint | string;
|
|
149
|
+
minOraclePriceCap?: bigint | string;
|
|
150
|
+
/**
|
|
151
|
+
* @deprecated Use hMin and hMax instead (v12.15+). Accepted as fallback for both hMin and hMax
|
|
152
|
+
* when hMin/hMax are not provided.
|
|
153
|
+
*/
|
|
154
|
+
warmupPeriodSlots?: bigint | string;
|
|
155
|
+
/** Minimum horizon slots (v12.15+). Falls back to warmupPeriodSlots if not provided. */
|
|
156
|
+
hMin?: bigint | string;
|
|
157
|
+
/** Maximum horizon slots (v12.15+). Falls back to warmupPeriodSlots if not provided. */
|
|
158
|
+
hMax?: bigint | string;
|
|
139
159
|
maintenanceMarginBps: bigint | string;
|
|
140
160
|
initialMarginBps: bigint | string;
|
|
141
161
|
tradingFeeBps: bigint | string;
|
|
142
162
|
maxAccounts: bigint | string;
|
|
143
163
|
newAccountFee: bigint | string;
|
|
144
|
-
|
|
164
|
+
insuranceFloor?: bigint | string;
|
|
145
165
|
maintenanceFeePerSlot: bigint | string;
|
|
146
166
|
maxCrankStalenessSlots: bigint | string;
|
|
147
167
|
liquidationFeeBps: bigint | string;
|
|
148
168
|
liquidationFeeCap: bigint | string;
|
|
149
|
-
liquidationBufferBps
|
|
169
|
+
liquidationBufferBps?: bigint | string;
|
|
150
170
|
minLiquidationAbs: bigint | string;
|
|
171
|
+
minInitialDeposit: bigint | string;
|
|
172
|
+
minNonzeroMmReq: bigint | string;
|
|
173
|
+
minNonzeroImReq: bigint | string;
|
|
151
174
|
}
|
|
152
175
|
export declare function encodeInitMarket(args: InitMarketArgs): Uint8Array;
|
|
153
176
|
/**
|
|
@@ -183,12 +206,41 @@ export interface WithdrawCollateralArgs {
|
|
|
183
206
|
}
|
|
184
207
|
export declare function encodeWithdrawCollateral(args: WithdrawCollateralArgs): Uint8Array;
|
|
185
208
|
/**
|
|
186
|
-
* KeeperCrank
|
|
187
|
-
*
|
|
209
|
+
* Liquidation policy for KeeperCrank candidates (v12.17 two-phase crank).
|
|
210
|
+
*
|
|
211
|
+
* On-chain wire tags:
|
|
212
|
+
* 0x00 = FullClose — liquidate the entire position
|
|
213
|
+
* 0x01 = ExactPartial(u128) — reduce position by exactly `quantity` units
|
|
214
|
+
* 0xFF = TouchOnly — accrue fees / sweep dust, do NOT liquidate
|
|
215
|
+
*/
|
|
216
|
+
export declare const LiquidationPolicyTag: {
|
|
217
|
+
readonly FullClose: 0;
|
|
218
|
+
readonly ExactPartial: 1;
|
|
219
|
+
readonly TouchOnly: 255;
|
|
220
|
+
};
|
|
221
|
+
export type KeeperCrankCandidate = {
|
|
222
|
+
policy: typeof LiquidationPolicyTag.FullClose;
|
|
223
|
+
idx: number;
|
|
224
|
+
} | {
|
|
225
|
+
policy: typeof LiquidationPolicyTag.ExactPartial;
|
|
226
|
+
idx: number;
|
|
227
|
+
quantity: bigint | string;
|
|
228
|
+
} | {
|
|
229
|
+
policy: typeof LiquidationPolicyTag.TouchOnly;
|
|
230
|
+
idx: number;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* KeeperCrank instruction data (v12.17 two-phase crank).
|
|
234
|
+
*
|
|
235
|
+
* Wire format: tag(1) + caller_idx(u16) + format_version=1(u8) +
|
|
236
|
+
* candidates: [ idx(u16) + policy_tag(u8) [+ quantity(u128) if ExactPartial] ]*
|
|
237
|
+
*
|
|
238
|
+
* Empty candidates list = simple crank (accrue funding, sweep dust).
|
|
239
|
+
* With candidates = targeted liquidation/touch pass.
|
|
188
240
|
*/
|
|
189
241
|
export interface KeeperCrankArgs {
|
|
190
242
|
callerIdx: number;
|
|
191
|
-
|
|
243
|
+
candidates?: KeeperCrankCandidate[];
|
|
192
244
|
}
|
|
193
245
|
export declare function encodeKeeperCrank(args: KeeperCrankArgs): Uint8Array;
|
|
194
246
|
/**
|
|
@@ -222,21 +274,24 @@ export interface TopUpInsuranceArgs {
|
|
|
222
274
|
}
|
|
223
275
|
export declare function encodeTopUpInsurance(args: TopUpInsuranceArgs): Uint8Array;
|
|
224
276
|
/**
|
|
225
|
-
* TradeCpi instruction data (
|
|
277
|
+
* TradeCpi instruction data (29 bytes)
|
|
278
|
+
*
|
|
279
|
+
* v12.17: limit_price_e6 is now REQUIRED (slippage protection).
|
|
280
|
+
* Set to 0 to accept any price (no slippage protection).
|
|
281
|
+
* For buys: tx reverts if execution price > limitPriceE6.
|
|
282
|
+
* For sells: tx reverts if execution price < limitPriceE6.
|
|
226
283
|
*/
|
|
227
284
|
export interface TradeCpiArgs {
|
|
228
285
|
lpIdx: number;
|
|
229
286
|
userIdx: number;
|
|
230
287
|
size: bigint | string;
|
|
288
|
+
/** Limit price in e6 units. 0 = no limit (accept any price). */
|
|
289
|
+
limitPriceE6: bigint | string;
|
|
231
290
|
}
|
|
232
291
|
export declare function encodeTradeCpi(args: TradeCpiArgs): Uint8Array;
|
|
233
292
|
/**
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* Same as TradeCpi but includes a caller-provided PDA bump byte.
|
|
237
|
-
* Uses create_program_address instead of find_program_address,
|
|
238
|
-
* saving ~1500 CU per trade. The bump should be obtained once via
|
|
239
|
-
* deriveLpPda() and cached for the lifetime of the market.
|
|
293
|
+
* @deprecated Tag 35 removed in v12.17. Use TradeCpi (tag 10) with limitPriceE6 instead.
|
|
294
|
+
* TradeCpi now handles PDA bump internally. Sending tag 35 will fail with InvalidInstructionData.
|
|
240
295
|
*/
|
|
241
296
|
export interface TradeCpiV2Args {
|
|
242
297
|
lpIdx: number;
|
|
@@ -244,13 +299,24 @@ export interface TradeCpiV2Args {
|
|
|
244
299
|
size: bigint | string;
|
|
245
300
|
bump: number;
|
|
246
301
|
}
|
|
302
|
+
/** @deprecated Tag 35 removed in v12.17. Use encodeTradeCpi with limitPriceE6 instead. */
|
|
247
303
|
export declare function encodeTradeCpiV2(args: TradeCpiV2Args): Uint8Array;
|
|
248
304
|
/**
|
|
249
|
-
*
|
|
305
|
+
* @deprecated Tag 36 removed in v12.17. Will fail on-chain with InvalidInstructionData.
|
|
306
|
+
*/
|
|
307
|
+
export interface UnresolveMarketArgs {
|
|
308
|
+
confirmation: bigint | string;
|
|
309
|
+
}
|
|
310
|
+
/** @deprecated Tag 36 removed in v12.17. Will fail on-chain. */
|
|
311
|
+
export declare function encodeUnresolveMarket(args: UnresolveMarketArgs): Uint8Array;
|
|
312
|
+
/**
|
|
313
|
+
* @deprecated Tag 11 removed in v12.17. Insurance floor is now set at InitMarket.
|
|
314
|
+
* Sending this instruction will fail with InvalidInstructionData.
|
|
250
315
|
*/
|
|
251
316
|
export interface SetRiskThresholdArgs {
|
|
252
317
|
newThreshold: bigint | string;
|
|
253
318
|
}
|
|
319
|
+
/** @deprecated Tag 11 removed in v12.17. Will fail on-chain. */
|
|
254
320
|
export declare function encodeSetRiskThreshold(args: SetRiskThresholdArgs): Uint8Array;
|
|
255
321
|
/**
|
|
256
322
|
* UpdateAdmin instruction data (33 bytes)
|
|
@@ -264,61 +330,28 @@ export declare function encodeUpdateAdmin(args: UpdateAdminArgs): Uint8Array;
|
|
|
264
330
|
*/
|
|
265
331
|
export declare function encodeCloseSlab(): Uint8Array;
|
|
266
332
|
/**
|
|
267
|
-
* UpdateConfig instruction data
|
|
268
|
-
*
|
|
333
|
+
* UpdateConfig instruction data (33 bytes)
|
|
334
|
+
*
|
|
335
|
+
* v12.17: Only 4 funding parameters. Threshold/insurance parameters are set
|
|
336
|
+
* at InitMarket and updated via dedicated instructions (SetRiskThreshold removed).
|
|
337
|
+
* fundingInvScaleNotionalE6 removed (now computed on-chain from LP state).
|
|
269
338
|
*/
|
|
270
339
|
export interface UpdateConfigArgs {
|
|
271
340
|
fundingHorizonSlots: bigint | string;
|
|
272
341
|
fundingKBps: bigint | string;
|
|
273
|
-
fundingInvScaleNotionalE6: bigint | string;
|
|
274
342
|
fundingMaxPremiumBps: bigint | string;
|
|
275
343
|
fundingMaxBpsPerSlot: bigint | string;
|
|
276
|
-
threshFloor: bigint | string;
|
|
277
|
-
threshRiskBps: bigint | string;
|
|
278
|
-
threshUpdateIntervalSlots: bigint | string;
|
|
279
|
-
threshStepBps: bigint | string;
|
|
280
|
-
threshAlphaBps: bigint | string;
|
|
281
|
-
threshMin: bigint | string;
|
|
282
|
-
threshMax: bigint | string;
|
|
283
|
-
threshMinStep: bigint | string;
|
|
284
344
|
}
|
|
285
345
|
export declare function encodeUpdateConfig(args: UpdateConfigArgs): Uint8Array;
|
|
286
346
|
/**
|
|
287
|
-
*
|
|
347
|
+
* @deprecated Tag 15 removed in v12.17. Maintenance fee is set at InitMarket only.
|
|
348
|
+
* Sending this instruction will fail with InvalidInstructionData.
|
|
288
349
|
*/
|
|
289
350
|
export interface SetMaintenanceFeeArgs {
|
|
290
351
|
newFee: bigint | string;
|
|
291
352
|
}
|
|
353
|
+
/** @deprecated Tag 15 removed in v12.17. Will fail on-chain. */
|
|
292
354
|
export declare function encodeSetMaintenanceFee(args: SetMaintenanceFeeArgs): Uint8Array;
|
|
293
|
-
/**
|
|
294
|
-
* SetOracleAuthority instruction data (33 bytes)
|
|
295
|
-
* Sets the oracle price authority. Pass zero pubkey to disable and require Pyth/Chainlink.
|
|
296
|
-
*/
|
|
297
|
-
export interface SetOracleAuthorityArgs {
|
|
298
|
-
newAuthority: PublicKey | string;
|
|
299
|
-
}
|
|
300
|
-
export declare function encodeSetOracleAuthority(args: SetOracleAuthorityArgs): Uint8Array;
|
|
301
|
-
/**
|
|
302
|
-
* PushOraclePrice instruction data (17 bytes)
|
|
303
|
-
* Push a new oracle price (oracle authority only).
|
|
304
|
-
* The price should be in e6 format and already include any inversion/scaling.
|
|
305
|
-
*/
|
|
306
|
-
export interface PushOraclePriceArgs {
|
|
307
|
-
priceE6: bigint | string;
|
|
308
|
-
timestamp: bigint | string;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Encode PushOraclePrice instruction data with validation.
|
|
312
|
-
*
|
|
313
|
-
* Validates oracle price constraints:
|
|
314
|
-
* - Price cannot be zero (division by zero in on-chain engine)
|
|
315
|
-
* - Price cannot exceed MAX_ORACLE_PRICE (prevents overflow in price math)
|
|
316
|
-
*
|
|
317
|
-
* @param args - PushOraclePrice arguments
|
|
318
|
-
* @returns Encoded instruction data (17 bytes)
|
|
319
|
-
* @throws Error if price is 0 or exceeds MAX_ORACLE_PRICE
|
|
320
|
-
*/
|
|
321
|
-
export declare function encodePushOraclePrice(args: PushOraclePriceArgs): Uint8Array;
|
|
322
355
|
/**
|
|
323
356
|
* SetOraclePriceCap instruction data (9 bytes)
|
|
324
357
|
* Set oracle price circuit breaker cap (admin only).
|
|
@@ -357,18 +390,16 @@ export interface AdminForceCloseArgs {
|
|
|
357
390
|
}
|
|
358
391
|
export declare function encodeAdminForceClose(args: AdminForceCloseArgs): Uint8Array;
|
|
359
392
|
/**
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
* R2-S13: The Rust program uses `data.len() >= 25` to detect the optional
|
|
364
|
-
* tradingFeeBps field, so variable-length encoding is safe. When tradingFeeBps
|
|
365
|
-
* is omitted, the data is 17 bytes (tag + 2×u64). When included, 25 bytes.
|
|
393
|
+
* @deprecated Tag 22 is now SetInsuranceWithdrawPolicy in v12.17.
|
|
394
|
+
* This encoder sends the WRONG wire format (u64+u64 instead of pubkey+u64+u16+u64).
|
|
395
|
+
* Use encodeSetInsuranceWithdrawPolicy instead.
|
|
366
396
|
*/
|
|
367
397
|
export interface UpdateRiskParamsArgs {
|
|
368
398
|
initialMarginBps: bigint | string;
|
|
369
399
|
maintenanceMarginBps: bigint | string;
|
|
370
400
|
tradingFeeBps?: bigint | string;
|
|
371
401
|
}
|
|
402
|
+
/** @deprecated Use encodeSetInsuranceWithdrawPolicy (tag 22). This sends wrong wire format. */
|
|
372
403
|
export declare function encodeUpdateRiskParams(args: UpdateRiskParamsArgs): Uint8Array;
|
|
373
404
|
/**
|
|
374
405
|
* On-chain confirmation code for RenounceAdmin (must match program constant).
|
|
@@ -380,11 +411,9 @@ export declare const RENOUNCE_ADMIN_CONFIRMATION = 5928230587143701317n;
|
|
|
380
411
|
*/
|
|
381
412
|
export declare const UNRESOLVE_CONFIRMATION = 16045690984503054900n;
|
|
382
413
|
/**
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
* Requires the confirmation code 0x52454E4F554E4345 ("RENOUNCE" as u64 LE)
|
|
387
|
-
* to prevent accidental invocation.
|
|
414
|
+
* @deprecated Tag 23 is now WithdrawInsuranceLimited in v12.17.
|
|
415
|
+
* This encoder sends the confirmation code as a withdrawal amount — DANGEROUS.
|
|
416
|
+
* Use encodeWithdrawInsuranceLimited instead.
|
|
388
417
|
*/
|
|
389
418
|
export declare function encodeRenounceAdmin(): Uint8Array;
|
|
390
419
|
/**
|
|
@@ -443,29 +472,15 @@ export declare function encodePauseMarket(): Uint8Array;
|
|
|
443
472
|
*/
|
|
444
473
|
export declare function encodeUnpauseMarket(): Uint8Array;
|
|
445
474
|
/**
|
|
446
|
-
*
|
|
447
|
-
*
|
|
448
|
-
* After this instruction:
|
|
449
|
-
* - oracle_authority is cleared → PushOraclePrice is disabled
|
|
450
|
-
* - index_feed_id is set to feed_id → validated on every price read
|
|
451
|
-
* - max_staleness_secs and conf_filter_bps are updated
|
|
452
|
-
* - All price reads go directly to read_pyth_price_e6() with on-chain
|
|
453
|
-
* staleness + confidence + feed-ID validation (no silent fallback)
|
|
454
|
-
*
|
|
455
|
-
* Instruction data: tag(1) + feed_id(32) + max_staleness_secs(8) + conf_filter_bps(2) = 43 bytes
|
|
456
|
-
*
|
|
457
|
-
* Accounts:
|
|
458
|
-
* 0. [signer, writable] Admin
|
|
459
|
-
* 1. [writable] Slab
|
|
475
|
+
* @deprecated Tag 32 removed in v12.17. Pyth oracle is configured at InitMarket via indexFeedId.
|
|
476
|
+
* Sending this instruction will fail with InvalidInstructionData.
|
|
460
477
|
*/
|
|
461
478
|
export interface SetPythOracleArgs {
|
|
462
|
-
/** 32-byte Pyth feed ID. All zeros is invalid (reserved for Hyperp mode). */
|
|
463
479
|
feedId: Uint8Array;
|
|
464
|
-
/** Maximum age of Pyth price in seconds before OracleStale is returned. Must be > 0. */
|
|
465
480
|
maxStalenessSecs: bigint;
|
|
466
|
-
/** Max confidence/price ratio in bps (0 = no confidence check). */
|
|
467
481
|
confFilterBps: number;
|
|
468
482
|
}
|
|
483
|
+
/** @deprecated Tag 32 removed in v12.17. Pyth is configured at InitMarket. */
|
|
469
484
|
export declare function encodeSetPythOracle(args: SetPythOracleArgs): Uint8Array;
|
|
470
485
|
/**
|
|
471
486
|
* Derive the expected Pyth PriceUpdateV2 account address for a given feed ID.
|
|
@@ -477,18 +492,8 @@ export declare function encodeSetPythOracle(args: SetPythOracleArgs): Uint8Array
|
|
|
477
492
|
export declare const PYTH_RECEIVER_PROGRAM_ID = "rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ";
|
|
478
493
|
export declare function derivePythPriceUpdateAccount(feedId: Uint8Array, shardId?: number): Promise<string>;
|
|
479
494
|
/**
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
* Reads the current oracle price on-chain, applies 8-hour EMA smoothing
|
|
483
|
-
* with circuit breaker, and writes result to authority_price_e6.
|
|
484
|
-
*
|
|
485
|
-
* Instruction data: 1 byte (tag only — all params read from on-chain state)
|
|
486
|
-
*
|
|
487
|
-
* Accounts:
|
|
488
|
-
* 0. [writable] Slab
|
|
489
|
-
* 1. [] Oracle account (Pyth PriceUpdateV2 / Chainlink / DEX AMM)
|
|
490
|
-
* 2. [] Clock sysvar (SysvarC1ock11111111111111111111111111111111)
|
|
491
|
-
* 3..N [] Remaining accounts (PumpSwap vaults, etc. if needed)
|
|
495
|
+
* @deprecated Tag 33 removed in v12.17. Use UpdateHyperpMark (tag 34) for DEX-oracle markets.
|
|
496
|
+
* Sending this instruction will fail with InvalidInstructionData.
|
|
492
497
|
*/
|
|
493
498
|
export declare function encodeUpdateMarkPrice(): Uint8Array;
|
|
494
499
|
/**
|
|
@@ -677,21 +682,6 @@ export declare const PHASE2_MATURITY_SLOTS = 3024000n;
|
|
|
677
682
|
* @returns [newPhase, shouldTransition]
|
|
678
683
|
*/
|
|
679
684
|
export declare function checkPhaseTransition(currentSlot: bigint, marketCreatedSlot: bigint, oraclePhase: number, cumulativeVolumeE6: bigint, phase2DeltaSlots: number, hasMatureOracle: boolean): [number, boolean];
|
|
680
|
-
/**
|
|
681
|
-
* TopUpKeeperFund (Tag 57) — permissionless keeper fund top-up.
|
|
682
|
-
*
|
|
683
|
-
* Instruction data: tag(1) + amount(8) = 9 bytes
|
|
684
|
-
*
|
|
685
|
-
* Accounts:
|
|
686
|
-
* 0. [signer, writable] Funder
|
|
687
|
-
* 1. [writable] Slab
|
|
688
|
-
* 2. [writable] Keeper fund PDA
|
|
689
|
-
* 3. [] System program
|
|
690
|
-
*/
|
|
691
|
-
export interface TopUpKeeperFundArgs {
|
|
692
|
-
amount: bigint | string;
|
|
693
|
-
}
|
|
694
|
-
export declare function encodeTopUpKeeperFund(args: TopUpKeeperFundArgs): Uint8Array;
|
|
695
685
|
/**
|
|
696
686
|
* SlashCreationDeposit (Tag 58) — permissionless: slash a market creator's deposit
|
|
697
687
|
* after the spam grace period has elapsed (PERC-629).
|
|
@@ -823,28 +813,24 @@ export declare function encodeSetOiImbalanceHardBlock(args: {
|
|
|
823
813
|
* Creates a PositionNft PDA + Token-2022 mint with metadata, then mints 1 NFT to the
|
|
824
814
|
* position owner's ATA. The NFT represents ownership of `user_idx` in the slab.
|
|
825
815
|
*
|
|
826
|
-
*
|
|
816
|
+
* The program creates the ATA internally via CPI when the 11th account (Associated Token
|
|
817
|
+
* Program) is provided. This is required because the NFT mint PDA doesn't exist until the
|
|
818
|
+
* program creates it, so the ATA can't be created in a preceding instruction.
|
|
827
819
|
*
|
|
828
|
-
*
|
|
829
|
-
* 0. [signer, writable] payer
|
|
830
|
-
* 1. [writable] slab
|
|
831
|
-
* 2. [writable] position_nft PDA (created — seeds: ["position_nft", slab, user_idx])
|
|
832
|
-
* 3. [writable] nft_mint PDA (created)
|
|
833
|
-
* 4. [writable] owner_ata (Token-2022 ATA for owner)
|
|
834
|
-
* 5. [signer] owner (must match engine account owner)
|
|
835
|
-
* 6. [] vault_authority PDA
|
|
836
|
-
* 7. [] token_2022_program
|
|
837
|
-
* 8. [] system_program
|
|
838
|
-
* 9. [] rent sysvar
|
|
820
|
+
* Instruction data layout: tag(1) + user_idx(2) = 3 bytes
|
|
839
821
|
*
|
|
840
|
-
*
|
|
841
|
-
*
|
|
842
|
-
*
|
|
843
|
-
*
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
*
|
|
847
|
-
*
|
|
822
|
+
* Accounts (11):
|
|
823
|
+
* 0. [signer, writable] payer
|
|
824
|
+
* 1. [writable] slab
|
|
825
|
+
* 2. [writable] position_nft PDA (created — seeds: ["position_nft", slab, user_idx_u16_le])
|
|
826
|
+
* 3. [writable] nft_mint PDA (created — seeds: ["position_nft_mint", slab, user_idx_u16_le])
|
|
827
|
+
* 4. [writable] owner_ata (Token-2022 ATA for nft_mint — created by program if absent)
|
|
828
|
+
* 5. [signer] owner (must match engine account owner)
|
|
829
|
+
* 6. [] vault_authority PDA (seeds: ["vault", slab])
|
|
830
|
+
* 7. [] token_2022_program (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb)
|
|
831
|
+
* 8. [] system_program
|
|
832
|
+
* 9. [] rent sysvar
|
|
833
|
+
* 10. [] associated_token_program (ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL)
|
|
848
834
|
*/
|
|
849
835
|
export interface MintPositionNftArgs {
|
|
850
836
|
userIdx: number;
|
|
@@ -1032,3 +1018,168 @@ export interface InitMatcherCtxArgs {
|
|
|
1032
1018
|
skewSpreadMultBps: number;
|
|
1033
1019
|
}
|
|
1034
1020
|
export declare function encodeInitMatcherCtx(args: InitMatcherCtxArgs): Uint8Array;
|
|
1021
|
+
/** SetInsuranceWithdrawPolicy (tag 22): authority + min_withdraw_base + max_withdraw_bps + cooldown_slots */
|
|
1022
|
+
export interface SetInsuranceWithdrawPolicyArgs {
|
|
1023
|
+
authority: PublicKey | string;
|
|
1024
|
+
minWithdrawBase: bigint | string;
|
|
1025
|
+
maxWithdrawBps: number;
|
|
1026
|
+
cooldownSlots: bigint | string;
|
|
1027
|
+
}
|
|
1028
|
+
export declare function encodeSetInsuranceWithdrawPolicy(args: SetInsuranceWithdrawPolicyArgs): Uint8Array;
|
|
1029
|
+
/**
|
|
1030
|
+
* WithdrawInsuranceLimited (tag 23): amount.
|
|
1031
|
+
* Account count is 7 (resolved markets) or 8 (live markets — oracle required
|
|
1032
|
+
* for same-instruction accrue_market_to per upstream 8ce8d54).
|
|
1033
|
+
* See ACCOUNTS_WITHDRAW_INSURANCE_LIMITED_LIVE / _RESOLVED in accounts.ts.
|
|
1034
|
+
*/
|
|
1035
|
+
export declare function encodeWithdrawInsuranceLimited(args: {
|
|
1036
|
+
amount: bigint | string;
|
|
1037
|
+
}): Uint8Array;
|
|
1038
|
+
/** ResolvePermissionless (tag 29): no args */
|
|
1039
|
+
export declare function encodeResolvePermissionless(): Uint8Array;
|
|
1040
|
+
/** ForceCloseResolved (tag 30): user_idx */
|
|
1041
|
+
export declare function encodeForceCloseResolved(args: {
|
|
1042
|
+
userIdx: number;
|
|
1043
|
+
}): Uint8Array;
|
|
1044
|
+
/** CreateLpVault (tag 37): fee_share_bps + util_curve_enabled */
|
|
1045
|
+
export declare function encodeCreateLpVault(args: {
|
|
1046
|
+
feeShareBps: bigint | string;
|
|
1047
|
+
utilCurveEnabled?: boolean;
|
|
1048
|
+
}): Uint8Array;
|
|
1049
|
+
/** LpVaultDeposit (tag 38): amount */
|
|
1050
|
+
export declare function encodeLpVaultDeposit(args: {
|
|
1051
|
+
amount: bigint | string;
|
|
1052
|
+
}): Uint8Array;
|
|
1053
|
+
/** LpVaultCrankFees (tag 40): no args */
|
|
1054
|
+
export declare function encodeLpVaultCrankFees(): Uint8Array;
|
|
1055
|
+
/** ChallengeSettlement (tag 43): proposed_price_e6 */
|
|
1056
|
+
export declare function encodeChallengeSettlement(args: {
|
|
1057
|
+
proposedPriceE6: bigint | string;
|
|
1058
|
+
}): Uint8Array;
|
|
1059
|
+
/** ResolveDispute (tag 44): accept (0 = reject, 1 = accept) */
|
|
1060
|
+
export declare function encodeResolveDispute(args: {
|
|
1061
|
+
accept: number;
|
|
1062
|
+
}): Uint8Array;
|
|
1063
|
+
/** DepositLpCollateral (tag 45): user_idx + lp_amount */
|
|
1064
|
+
export declare function encodeDepositLpCollateral(args: {
|
|
1065
|
+
userIdx: number;
|
|
1066
|
+
lpAmount: bigint | string;
|
|
1067
|
+
}): Uint8Array;
|
|
1068
|
+
/** WithdrawLpCollateral (tag 46): user_idx + lp_amount */
|
|
1069
|
+
export declare function encodeWithdrawLpCollateral(args: {
|
|
1070
|
+
userIdx: number;
|
|
1071
|
+
lpAmount: bigint | string;
|
|
1072
|
+
}): Uint8Array;
|
|
1073
|
+
/** SetOffsetPair (tag 54): offset_bps */
|
|
1074
|
+
export declare function encodeSetOffsetPair(args: {
|
|
1075
|
+
offsetBps: number;
|
|
1076
|
+
}): Uint8Array;
|
|
1077
|
+
/** AttestCrossMargin (tag 55): user_idx_a + user_idx_b */
|
|
1078
|
+
export declare function encodeAttestCrossMargin(args: {
|
|
1079
|
+
userIdxA: number;
|
|
1080
|
+
userIdxB: number;
|
|
1081
|
+
}): Uint8Array;
|
|
1082
|
+
/** RescueOrphanVault (tag 72): no args */
|
|
1083
|
+
export declare function encodeRescueOrphanVault(): Uint8Array;
|
|
1084
|
+
/** CloseOrphanSlab (tag 73): no args */
|
|
1085
|
+
export declare function encodeCloseOrphanSlab(): Uint8Array;
|
|
1086
|
+
/** SetDexPool (tag 74): pool pubkey */
|
|
1087
|
+
export declare function encodeSetDexPool(args: {
|
|
1088
|
+
pool: PublicKey | string;
|
|
1089
|
+
}): Uint8Array;
|
|
1090
|
+
/** CreateInsuranceMint: creates the insurance LP mint PDA (tag 37, same as CreateLpVault) */
|
|
1091
|
+
export declare function encodeCreateInsuranceMint(): Uint8Array;
|
|
1092
|
+
/** DepositInsuranceLP: deposit collateral, receive LP tokens (tag 38, same as LpVaultDeposit) */
|
|
1093
|
+
export declare function encodeDepositInsuranceLP(args: {
|
|
1094
|
+
amount: bigint | string;
|
|
1095
|
+
}): Uint8Array;
|
|
1096
|
+
/** WithdrawInsuranceLP: burn LP tokens, withdraw collateral (tag 39, same as LpVaultWithdraw) */
|
|
1097
|
+
export declare function encodeWithdrawInsuranceLP(args: {
|
|
1098
|
+
lpAmount: bigint | string;
|
|
1099
|
+
}): Uint8Array;
|
|
1100
|
+
/**
|
|
1101
|
+
* SetMaxPnlCap (Tag 78, PERC-305 / SECURITY(H-4)) — set the PnL cap for ADL
|
|
1102
|
+
* pre-check (admin only). When `pnl_pos_tot <= max_pnl_cap`, ADL returns
|
|
1103
|
+
* early (no deleveraging needed).
|
|
1104
|
+
*
|
|
1105
|
+
* `capE6 = 0` disables the cap (ADL always runs when insurance is depleted).
|
|
1106
|
+
*
|
|
1107
|
+
* Instruction data: tag(1) + cap(u64, 8) = 9 bytes
|
|
1108
|
+
*/
|
|
1109
|
+
export interface SetMaxPnlCapArgs {
|
|
1110
|
+
/** PnL cap in engine quote units (e.g., 1_000_000 = $1 e6). 0 = cap disabled. */
|
|
1111
|
+
cap: bigint | string;
|
|
1112
|
+
}
|
|
1113
|
+
export declare function encodeSetMaxPnlCap(args: SetMaxPnlCapArgs): Uint8Array;
|
|
1114
|
+
/**
|
|
1115
|
+
* SetOiCapMultiplier (Tag 79, PERC-309) — set the OI cap multiplier for LP
|
|
1116
|
+
* withdrawal limits (admin only). Packed u64:
|
|
1117
|
+
* lo 32 bits: multiplier_bps (e.g., 15000 = 1.5× soft cap in stressed state)
|
|
1118
|
+
* hi 32 bits: soft_cap_bps (e.g., 8000 = 80% base cap)
|
|
1119
|
+
*
|
|
1120
|
+
* `packed = 0` disables enforcement (no cap on LP withdrawals).
|
|
1121
|
+
*
|
|
1122
|
+
* Instruction data: tag(1) + packed(u64, 8) = 9 bytes
|
|
1123
|
+
*/
|
|
1124
|
+
export interface SetOiCapMultiplierArgs {
|
|
1125
|
+
/** Packed u64: lo32 = multiplier_bps, hi32 = soft_cap_bps. 0 = disabled. */
|
|
1126
|
+
packed: bigint | string;
|
|
1127
|
+
}
|
|
1128
|
+
export declare function encodeSetOiCapMultiplier(args: SetOiCapMultiplierArgs): Uint8Array;
|
|
1129
|
+
/** Convenience: pack (multiplier_bps, soft_cap_bps) into the u64 expected by SetOiCapMultiplier. */
|
|
1130
|
+
export declare function packOiCap(multiplierBps: number, softCapBps: number): bigint;
|
|
1131
|
+
/**
|
|
1132
|
+
* SetDisputeParams (Tag 80, PERC-314) — configure settlement dispute window
|
|
1133
|
+
* and bond (admin only).
|
|
1134
|
+
*
|
|
1135
|
+
* - `windowSlots = 0` disables disputes (ChallengeSettlement returns
|
|
1136
|
+
* DisputeWindowClosed). Max: 2_000_000 slots (≈ 8 days at 400ms slots) to
|
|
1137
|
+
* prevent DoS via absurd freezes.
|
|
1138
|
+
* - `bondAmount` (collateral tokens): refunded on dispute upheld, forfeited
|
|
1139
|
+
* on reject. 0 = no bond required.
|
|
1140
|
+
*
|
|
1141
|
+
* Instruction data: tag(1) + window_slots(u64, 8) + bond_amount(u64, 8) = 17 bytes
|
|
1142
|
+
*/
|
|
1143
|
+
export interface SetDisputeParamsArgs {
|
|
1144
|
+
/** Dispute window in slots. 0 = disputes disabled. Max 2_000_000. */
|
|
1145
|
+
windowSlots: bigint | string;
|
|
1146
|
+
/** Bond required to open a dispute (collateral units). 0 = no bond. */
|
|
1147
|
+
bondAmount: bigint | string;
|
|
1148
|
+
}
|
|
1149
|
+
export declare function encodeSetDisputeParams(args: SetDisputeParamsArgs): Uint8Array;
|
|
1150
|
+
/**
|
|
1151
|
+
* SetLpCollateralParams (Tag 81, PERC-315) — configure LP token collateral
|
|
1152
|
+
* acceptance (admin only).
|
|
1153
|
+
*
|
|
1154
|
+
* - `enabled = 0`: DepositLpCollateral rejects all new deposits.
|
|
1155
|
+
* - `enabled = 1`: deposits allowed, subject to `ltvBps` haircut on value.
|
|
1156
|
+
* - `ltvBps` max 10_000 (100%). Typical: 5000 (50% LTV).
|
|
1157
|
+
*
|
|
1158
|
+
* Instruction data: tag(1) + enabled(u8, 1) + ltv_bps(u16, 2) = 4 bytes
|
|
1159
|
+
*/
|
|
1160
|
+
export interface SetLpCollateralParamsArgs {
|
|
1161
|
+
/** 0 = disabled (blocks new deposits), 1 = enabled. */
|
|
1162
|
+
enabled: number;
|
|
1163
|
+
/** LTV in bps (0-10000). 5000 = 50% LTV. */
|
|
1164
|
+
ltvBps: number;
|
|
1165
|
+
}
|
|
1166
|
+
export declare function encodeSetLpCollateralParams(args: SetLpCollateralParamsArgs): Uint8Array;
|
|
1167
|
+
/**
|
|
1168
|
+
* AcceptAdmin (Tag 82, Phase E 2026-04-17) — complete a two-step admin transfer.
|
|
1169
|
+
*
|
|
1170
|
+
* Called by the PROPOSED new admin (the pubkey passed to UpdateAdmin with
|
|
1171
|
+
* `new_admin != default()`). The signer must match config.pending_admin
|
|
1172
|
+
* exactly. On success, header.admin is swapped to pending_admin and
|
|
1173
|
+
* pending_admin is cleared.
|
|
1174
|
+
*
|
|
1175
|
+
* Use `try_update_admin` then `try_accept_admin` for a full rotation, or
|
|
1176
|
+
* skip AcceptAdmin entirely to leave a pending transfer that the old
|
|
1177
|
+
* admin can overwrite (propose-again) or the new admin can never accept.
|
|
1178
|
+
*
|
|
1179
|
+
* Accounts:
|
|
1180
|
+
* [0] new admin (signer, must match pending_admin)
|
|
1181
|
+
* [1] slab (writable)
|
|
1182
|
+
*
|
|
1183
|
+
* Instruction data: tag(1) = 1 byte. No payload.
|
|
1184
|
+
*/
|
|
1185
|
+
export declare function encodeAcceptAdmin(): Uint8Array;
|