@percolatorct/sdk 1.0.0-beta.25 → 1.0.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abi/instructions.d.ts +95 -1
- package/dist/index.js +55 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ export declare const IX_TAG: {
|
|
|
40
40
|
readonly DepositFeeCredits: 27;
|
|
41
41
|
readonly ConvertReleasedPnl: 28;
|
|
42
42
|
readonly ResolvePermissionless: 29;
|
|
43
|
-
/** @deprecated Use ResolvePermissionless */ readonly AcceptAdmin:
|
|
43
|
+
/** @deprecated Use ResolvePermissionless */ readonly AcceptAdmin: 82;
|
|
44
44
|
readonly ForceCloseResolved: 30;
|
|
45
45
|
readonly SetPythOracle: 32;
|
|
46
46
|
readonly UpdateMarkPrice: 33;
|
|
@@ -123,6 +123,14 @@ export declare const IX_TAG: {
|
|
|
123
123
|
readonly PauseMarket: 76;
|
|
124
124
|
/** UnpauseMarket (tag 77): admin unpause. Re-enables all operations. */
|
|
125
125
|
readonly UnpauseMarket: 77;
|
|
126
|
+
/** PERC-305 / SECURITY(H-4): Set PnL cap for ADL pre-check (admin only). */
|
|
127
|
+
readonly SetMaxPnlCap: 78;
|
|
128
|
+
/** PERC-309: Set OI cap multiplier for LP withdrawal limits (admin only). Packed u64. */
|
|
129
|
+
readonly SetOiCapMultiplier: 79;
|
|
130
|
+
/** PERC-314: Set dispute params (window_slots + bond_amount, admin only). */
|
|
131
|
+
readonly SetDisputeParams: 80;
|
|
132
|
+
/** PERC-315: Set LP collateral params (enabled + ltv_bps, admin only). */
|
|
133
|
+
readonly SetLpCollateralParams: 81;
|
|
126
134
|
};
|
|
127
135
|
/**
|
|
128
136
|
* InitMarket instruction data (256 bytes total)
|
|
@@ -1119,3 +1127,89 @@ export declare function encodeDepositInsuranceLP(args: {
|
|
|
1119
1127
|
export declare function encodeWithdrawInsuranceLP(args: {
|
|
1120
1128
|
lpAmount: bigint | string;
|
|
1121
1129
|
}): Uint8Array;
|
|
1130
|
+
/**
|
|
1131
|
+
* SetMaxPnlCap (Tag 78, PERC-305 / SECURITY(H-4)) — set the PnL cap for ADL
|
|
1132
|
+
* pre-check (admin only). When `pnl_pos_tot <= max_pnl_cap`, ADL returns
|
|
1133
|
+
* early (no deleveraging needed).
|
|
1134
|
+
*
|
|
1135
|
+
* `capE6 = 0` disables the cap (ADL always runs when insurance is depleted).
|
|
1136
|
+
*
|
|
1137
|
+
* Instruction data: tag(1) + cap(u64, 8) = 9 bytes
|
|
1138
|
+
*/
|
|
1139
|
+
export interface SetMaxPnlCapArgs {
|
|
1140
|
+
/** PnL cap in engine quote units (e.g., 1_000_000 = $1 e6). 0 = cap disabled. */
|
|
1141
|
+
cap: bigint | string;
|
|
1142
|
+
}
|
|
1143
|
+
export declare function encodeSetMaxPnlCap(args: SetMaxPnlCapArgs): Uint8Array;
|
|
1144
|
+
/**
|
|
1145
|
+
* SetOiCapMultiplier (Tag 79, PERC-309) — set the OI cap multiplier for LP
|
|
1146
|
+
* withdrawal limits (admin only). Packed u64:
|
|
1147
|
+
* lo 32 bits: multiplier_bps (e.g., 15000 = 1.5× soft cap in stressed state)
|
|
1148
|
+
* hi 32 bits: soft_cap_bps (e.g., 8000 = 80% base cap)
|
|
1149
|
+
*
|
|
1150
|
+
* `packed = 0` disables enforcement (no cap on LP withdrawals).
|
|
1151
|
+
*
|
|
1152
|
+
* Instruction data: tag(1) + packed(u64, 8) = 9 bytes
|
|
1153
|
+
*/
|
|
1154
|
+
export interface SetOiCapMultiplierArgs {
|
|
1155
|
+
/** Packed u64: lo32 = multiplier_bps, hi32 = soft_cap_bps. 0 = disabled. */
|
|
1156
|
+
packed: bigint | string;
|
|
1157
|
+
}
|
|
1158
|
+
export declare function encodeSetOiCapMultiplier(args: SetOiCapMultiplierArgs): Uint8Array;
|
|
1159
|
+
/** Convenience: pack (multiplier_bps, soft_cap_bps) into the u64 expected by SetOiCapMultiplier. */
|
|
1160
|
+
export declare function packOiCap(multiplierBps: number, softCapBps: number): bigint;
|
|
1161
|
+
/**
|
|
1162
|
+
* SetDisputeParams (Tag 80, PERC-314) — configure settlement dispute window
|
|
1163
|
+
* and bond (admin only).
|
|
1164
|
+
*
|
|
1165
|
+
* - `windowSlots = 0` disables disputes (ChallengeSettlement returns
|
|
1166
|
+
* DisputeWindowClosed). Max: 2_000_000 slots (≈ 8 days at 400ms slots) to
|
|
1167
|
+
* prevent DoS via absurd freezes.
|
|
1168
|
+
* - `bondAmount` (collateral tokens): refunded on dispute upheld, forfeited
|
|
1169
|
+
* on reject. 0 = no bond required.
|
|
1170
|
+
*
|
|
1171
|
+
* Instruction data: tag(1) + window_slots(u64, 8) + bond_amount(u64, 8) = 17 bytes
|
|
1172
|
+
*/
|
|
1173
|
+
export interface SetDisputeParamsArgs {
|
|
1174
|
+
/** Dispute window in slots. 0 = disputes disabled. Max 2_000_000. */
|
|
1175
|
+
windowSlots: bigint | string;
|
|
1176
|
+
/** Bond required to open a dispute (collateral units). 0 = no bond. */
|
|
1177
|
+
bondAmount: bigint | string;
|
|
1178
|
+
}
|
|
1179
|
+
export declare function encodeSetDisputeParams(args: SetDisputeParamsArgs): Uint8Array;
|
|
1180
|
+
/**
|
|
1181
|
+
* SetLpCollateralParams (Tag 81, PERC-315) — configure LP token collateral
|
|
1182
|
+
* acceptance (admin only).
|
|
1183
|
+
*
|
|
1184
|
+
* - `enabled = 0`: DepositLpCollateral rejects all new deposits.
|
|
1185
|
+
* - `enabled = 1`: deposits allowed, subject to `ltvBps` haircut on value.
|
|
1186
|
+
* - `ltvBps` max 10_000 (100%). Typical: 5000 (50% LTV).
|
|
1187
|
+
*
|
|
1188
|
+
* Instruction data: tag(1) + enabled(u8, 1) + ltv_bps(u16, 2) = 4 bytes
|
|
1189
|
+
*/
|
|
1190
|
+
export interface SetLpCollateralParamsArgs {
|
|
1191
|
+
/** 0 = disabled (blocks new deposits), 1 = enabled. */
|
|
1192
|
+
enabled: number;
|
|
1193
|
+
/** LTV in bps (0-10000). 5000 = 50% LTV. */
|
|
1194
|
+
ltvBps: number;
|
|
1195
|
+
}
|
|
1196
|
+
export declare function encodeSetLpCollateralParams(args: SetLpCollateralParamsArgs): Uint8Array;
|
|
1197
|
+
/**
|
|
1198
|
+
* AcceptAdmin (Tag 82, Phase E 2026-04-17) — complete a two-step admin transfer.
|
|
1199
|
+
*
|
|
1200
|
+
* Called by the PROPOSED new admin (the pubkey passed to UpdateAdmin with
|
|
1201
|
+
* `new_admin != default()`). The signer must match config.pending_admin
|
|
1202
|
+
* exactly. On success, header.admin is swapped to pending_admin and
|
|
1203
|
+
* pending_admin is cleared.
|
|
1204
|
+
*
|
|
1205
|
+
* Use `try_update_admin` then `try_accept_admin` for a full rotation, or
|
|
1206
|
+
* skip AcceptAdmin entirely to leave a pending transfer that the old
|
|
1207
|
+
* admin can overwrite (propose-again) or the new admin can never accept.
|
|
1208
|
+
*
|
|
1209
|
+
* Accounts:
|
|
1210
|
+
* [0] new admin (signer, must match pending_admin)
|
|
1211
|
+
* [1] slab (writable)
|
|
1212
|
+
*
|
|
1213
|
+
* Instruction data: tag(1) = 1 byte. No payload.
|
|
1214
|
+
*/
|
|
1215
|
+
export declare function encodeAcceptAdmin(): Uint8Array;
|
package/dist/index.js
CHANGED
|
@@ -226,7 +226,17 @@ var IX_TAG = {
|
|
|
226
226
|
/** PauseMarket (tag 76): admin emergency pause. Blocks Trade/Deposit/Withdraw/InitUser. */
|
|
227
227
|
PauseMarket: 76,
|
|
228
228
|
/** UnpauseMarket (tag 77): admin unpause. Re-enables all operations. */
|
|
229
|
-
UnpauseMarket: 77
|
|
229
|
+
UnpauseMarket: 77,
|
|
230
|
+
/** PERC-305 / SECURITY(H-4): Set PnL cap for ADL pre-check (admin only). */
|
|
231
|
+
SetMaxPnlCap: 78,
|
|
232
|
+
/** PERC-309: Set OI cap multiplier for LP withdrawal limits (admin only). Packed u64. */
|
|
233
|
+
SetOiCapMultiplier: 79,
|
|
234
|
+
/** PERC-314: Set dispute params (window_slots + bond_amount, admin only). */
|
|
235
|
+
SetDisputeParams: 80,
|
|
236
|
+
/** PERC-315: Set LP collateral params (enabled + ltv_bps, admin only). */
|
|
237
|
+
SetLpCollateralParams: 81,
|
|
238
|
+
/** Phase E (2026-04-17): Accept a pending admin transfer. Signer must match pending_admin. */
|
|
239
|
+
AcceptAdmin: 82
|
|
230
240
|
// 78: removed (keeper fund)
|
|
231
241
|
};
|
|
232
242
|
Object.freeze(IX_TAG);
|
|
@@ -742,6 +752,44 @@ function encodeDepositInsuranceLP(args) {
|
|
|
742
752
|
function encodeWithdrawInsuranceLP(args) {
|
|
743
753
|
return encodeLpVaultWithdraw({ lpAmount: args.lpAmount });
|
|
744
754
|
}
|
|
755
|
+
function encodeSetMaxPnlCap(args) {
|
|
756
|
+
return concatBytes(encU8(IX_TAG.SetMaxPnlCap), encU64(args.cap));
|
|
757
|
+
}
|
|
758
|
+
function encodeSetOiCapMultiplier(args) {
|
|
759
|
+
return concatBytes(encU8(IX_TAG.SetOiCapMultiplier), encU64(args.packed));
|
|
760
|
+
}
|
|
761
|
+
function packOiCap(multiplierBps, softCapBps) {
|
|
762
|
+
if (multiplierBps < 0 || multiplierBps > 4294967295) {
|
|
763
|
+
throw new Error(`packOiCap: multiplier_bps out of u32 range: ${multiplierBps}`);
|
|
764
|
+
}
|
|
765
|
+
if (softCapBps < 0 || softCapBps > 4294967295) {
|
|
766
|
+
throw new Error(`packOiCap: soft_cap_bps out of u32 range: ${softCapBps}`);
|
|
767
|
+
}
|
|
768
|
+
return BigInt(multiplierBps) | BigInt(softCapBps) << 32n;
|
|
769
|
+
}
|
|
770
|
+
function encodeSetDisputeParams(args) {
|
|
771
|
+
return concatBytes(
|
|
772
|
+
encU8(IX_TAG.SetDisputeParams),
|
|
773
|
+
encU64(args.windowSlots),
|
|
774
|
+
encU64(args.bondAmount)
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
function encodeSetLpCollateralParams(args) {
|
|
778
|
+
if (args.enabled !== 0 && args.enabled !== 1) {
|
|
779
|
+
throw new Error(`encodeSetLpCollateralParams: enabled must be 0 or 1, got ${args.enabled}`);
|
|
780
|
+
}
|
|
781
|
+
if (args.ltvBps < 0 || args.ltvBps > 1e4) {
|
|
782
|
+
throw new Error(`encodeSetLpCollateralParams: ltvBps ${args.ltvBps} out of range [0, 10000]`);
|
|
783
|
+
}
|
|
784
|
+
return concatBytes(
|
|
785
|
+
encU8(IX_TAG.SetLpCollateralParams),
|
|
786
|
+
encU8(args.enabled),
|
|
787
|
+
encU16(args.ltvBps)
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
function encodeAcceptAdmin() {
|
|
791
|
+
return encU8(IX_TAG.AcceptAdmin);
|
|
792
|
+
}
|
|
745
793
|
|
|
746
794
|
// src/abi/accounts.ts
|
|
747
795
|
import {
|
|
@@ -6546,6 +6594,7 @@ export {
|
|
|
6546
6594
|
encU32,
|
|
6547
6595
|
encU64,
|
|
6548
6596
|
encU8,
|
|
6597
|
+
encodeAcceptAdmin,
|
|
6549
6598
|
encodeAdminForceClose,
|
|
6550
6599
|
encodeAdvanceEpoch,
|
|
6551
6600
|
encodeAdvanceOraclePhase,
|
|
@@ -6596,10 +6645,14 @@ export {
|
|
|
6596
6645
|
encodeResolveMarket,
|
|
6597
6646
|
encodeResolvePermissionless,
|
|
6598
6647
|
encodeSetDexPool,
|
|
6648
|
+
encodeSetDisputeParams,
|
|
6599
6649
|
encodeSetInsuranceIsolation,
|
|
6600
6650
|
encodeSetInsuranceWithdrawPolicy,
|
|
6651
|
+
encodeSetLpCollateralParams,
|
|
6601
6652
|
encodeSetMaintenanceFee,
|
|
6653
|
+
encodeSetMaxPnlCap,
|
|
6602
6654
|
encodeSetOffsetPair,
|
|
6655
|
+
encodeSetOiCapMultiplier,
|
|
6603
6656
|
encodeSetOiImbalanceHardBlock,
|
|
6604
6657
|
encodeSetOracleAuthority,
|
|
6605
6658
|
encodeSetOraclePriceCap,
|
|
@@ -6670,6 +6723,7 @@ export {
|
|
|
6670
6723
|
isToken2022,
|
|
6671
6724
|
isValidChainlinkOracle,
|
|
6672
6725
|
maxAccountIndex,
|
|
6726
|
+
packOiCap,
|
|
6673
6727
|
parseAccount,
|
|
6674
6728
|
parseAdlEvent,
|
|
6675
6729
|
parseAllAccounts,
|