@percolatorct/sdk 1.0.0-beta.25 → 1.0.0-beta.26

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.
@@ -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,70 @@ 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;
package/dist/index.js CHANGED
@@ -226,7 +226,15 @@ 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
230
238
  // 78: removed (keeper fund)
231
239
  };
232
240
  Object.freeze(IX_TAG);
@@ -742,6 +750,41 @@ function encodeDepositInsuranceLP(args) {
742
750
  function encodeWithdrawInsuranceLP(args) {
743
751
  return encodeLpVaultWithdraw({ lpAmount: args.lpAmount });
744
752
  }
753
+ function encodeSetMaxPnlCap(args) {
754
+ return concatBytes(encU8(IX_TAG.SetMaxPnlCap), encU64(args.cap));
755
+ }
756
+ function encodeSetOiCapMultiplier(args) {
757
+ return concatBytes(encU8(IX_TAG.SetOiCapMultiplier), encU64(args.packed));
758
+ }
759
+ function packOiCap(multiplierBps, softCapBps) {
760
+ if (multiplierBps < 0 || multiplierBps > 4294967295) {
761
+ throw new Error(`packOiCap: multiplier_bps out of u32 range: ${multiplierBps}`);
762
+ }
763
+ if (softCapBps < 0 || softCapBps > 4294967295) {
764
+ throw new Error(`packOiCap: soft_cap_bps out of u32 range: ${softCapBps}`);
765
+ }
766
+ return BigInt(multiplierBps) | BigInt(softCapBps) << 32n;
767
+ }
768
+ function encodeSetDisputeParams(args) {
769
+ return concatBytes(
770
+ encU8(IX_TAG.SetDisputeParams),
771
+ encU64(args.windowSlots),
772
+ encU64(args.bondAmount)
773
+ );
774
+ }
775
+ function encodeSetLpCollateralParams(args) {
776
+ if (args.enabled !== 0 && args.enabled !== 1) {
777
+ throw new Error(`encodeSetLpCollateralParams: enabled must be 0 or 1, got ${args.enabled}`);
778
+ }
779
+ if (args.ltvBps < 0 || args.ltvBps > 1e4) {
780
+ throw new Error(`encodeSetLpCollateralParams: ltvBps ${args.ltvBps} out of range [0, 10000]`);
781
+ }
782
+ return concatBytes(
783
+ encU8(IX_TAG.SetLpCollateralParams),
784
+ encU8(args.enabled),
785
+ encU16(args.ltvBps)
786
+ );
787
+ }
745
788
 
746
789
  // src/abi/accounts.ts
747
790
  import {
@@ -6596,10 +6639,14 @@ export {
6596
6639
  encodeResolveMarket,
6597
6640
  encodeResolvePermissionless,
6598
6641
  encodeSetDexPool,
6642
+ encodeSetDisputeParams,
6599
6643
  encodeSetInsuranceIsolation,
6600
6644
  encodeSetInsuranceWithdrawPolicy,
6645
+ encodeSetLpCollateralParams,
6601
6646
  encodeSetMaintenanceFee,
6647
+ encodeSetMaxPnlCap,
6602
6648
  encodeSetOffsetPair,
6649
+ encodeSetOiCapMultiplier,
6603
6650
  encodeSetOiImbalanceHardBlock,
6604
6651
  encodeSetOracleAuthority,
6605
6652
  encodeSetOraclePriceCap,
@@ -6670,6 +6717,7 @@ export {
6670
6717
  isToken2022,
6671
6718
  isValidChainlinkOracle,
6672
6719
  maxAccountIndex,
6720
+ packOiCap,
6673
6721
  parseAccount,
6674
6722
  parseAdlEvent,
6675
6723
  parseAllAccounts,