flash-sdk 11.8.6-alpha.0 → 11.8.6

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.
@@ -701,7 +701,7 @@ var PerpetualsClient = (function () {
701
701
  currentMarginUsd = positionAccount.collateralUsd.sub(lossUsd);
702
702
  }
703
703
  else {
704
- currentMarginUsd = positionAccount.collateralUsd.add(pnl.finalProfitUsd).sub(lossUsd);
704
+ currentMarginUsd = positionAccount.collateralUsd.add(pnl.profitUsd).sub(lossUsd);
705
705
  }
706
706
  if (currentMarginUsd.gt(constants_1.BN_ZERO)) {
707
707
  return positionAccount.sizeUsd.mul(new anchor_1.BN(constants_1.BPS_POWER)).div(currentMarginUsd);
@@ -1056,7 +1056,7 @@ var PerpetualsClient = (function () {
1056
1056
  var totalFeesUsd = (exitFeeUsd.add(lockAndUnsettledFeeUsd));
1057
1057
  var currentCollateralUsd = positionDelta.collateralUsd;
1058
1058
  var liabilityUsd = newPnl.lossUsd.add(totalFeesUsd);
1059
- var assetsUsd = anchor_1.BN.min(newPnl.finalProfitUsd.add(currentCollateralUsd), collateralMinMaxPrice.max.getAssetAmountUsd(positionDelta.lockedAmount, collateralCustodyAccount.decimals));
1059
+ var assetsUsd = anchor_1.BN.min(newPnl.profitUsd.add(currentCollateralUsd), collateralMinMaxPrice.max.getAssetAmountUsd(positionDelta.lockedAmount, collateralCustodyAccount.decimals));
1060
1060
  if (debugLogs) {
1061
1061
  console.log("assetsUsd.sub(liabilityUsd):", collateralCustodyAccount.decimals, assetsUsd.toString(), liabilityUsd.toString(), assetsUsd.sub(liabilityUsd).toString());
1062
1062
  }
@@ -1193,7 +1193,7 @@ var PerpetualsClient = (function () {
1193
1193
  var exitPriceAndFee = _this.getExitPriceAndFeeSync(positionAccount, marketCorrelation, positionAccount.collateralAmount, positionAccount.sizeAmount, side, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp);
1194
1194
  var totalFeesUsd = (exitPriceAndFee.exitFeeUsd.add(exitPriceAndFee.borrowFeeUsd));
1195
1195
  var liabilityUsd = newPnl.lossUsd.add(totalFeesUsd);
1196
- var assetsUsd = anchor_1.BN.min(newPnl.finalProfitUsd.add(positionAccount.collateralUsd), collateralMinMaxPrice.max.getAssetAmountUsd(positionAccount.lockedAmount, collateralCustodyAccount.decimals));
1196
+ var assetsUsd = anchor_1.BN.min(newPnl.profitUsd.add(positionAccount.collateralUsd), collateralMinMaxPrice.max.getAssetAmountUsd(positionAccount.lockedAmount, collateralCustodyAccount.decimals));
1197
1197
  var closeAmountUsd, feesAmountUsd;
1198
1198
  if (assetsUsd.gt(liabilityUsd)) {
1199
1199
  closeAmountUsd = assetsUsd.sub(liabilityUsd);
@@ -1609,8 +1609,6 @@ var PerpetualsClient = (function () {
1609
1609
  return {
1610
1610
  profitUsd: constants_1.BN_ZERO,
1611
1611
  lossUsd: constants_1.BN_ZERO,
1612
- penaltyUsd: constants_1.BN_ZERO,
1613
- finalProfitUsd: constants_1.BN_ZERO,
1614
1612
  };
1615
1613
  }
1616
1614
  var side = poolConfig.getMarketConfigByPk(positionAccount.market).side;
@@ -1674,34 +1672,16 @@ var PerpetualsClient = (function () {
1674
1672
  if (!priceDiffProfit.exponent.eq(priceDiffLoss.exponent)) {
1675
1673
  throw new Error("exponent mistach");
1676
1674
  }
1677
- var totalPenaltyBps = positionAccount.oraclePenalty + positionAccount.previousPenalty;
1678
1675
  if (priceDiffProfit.price.gt(constants_1.BN_ZERO)) {
1679
- var grossProfitUsd = priceDiffProfit.getAssetAmountUsd(positionAccount.sizeAmount, positionAccount.sizeDecimals);
1680
- var penaltyUsd = constants_1.BN_ZERO;
1681
- var finalProfitUsd = grossProfitUsd;
1682
- if (totalPenaltyBps > 0 && grossProfitUsd.gt(constants_1.BN_ZERO)) {
1683
- penaltyUsd = grossProfitUsd.muln(totalPenaltyBps).divn(constants_1.BPS_POWER);
1684
- if (penaltyUsd.gte(grossProfitUsd)) {
1685
- penaltyUsd = grossProfitUsd;
1686
- finalProfitUsd = constants_1.BN_ZERO;
1687
- }
1688
- else {
1689
- finalProfitUsd = grossProfitUsd.sub(penaltyUsd);
1690
- }
1691
- }
1692
1676
  return {
1693
- profitUsd: grossProfitUsd,
1677
+ profitUsd: priceDiffProfit.getAssetAmountUsd(positionAccount.sizeAmount, positionAccount.sizeDecimals),
1694
1678
  lossUsd: constants_1.BN_ZERO,
1695
- penaltyUsd: penaltyUsd,
1696
- finalProfitUsd: finalProfitUsd,
1697
1679
  };
1698
1680
  }
1699
1681
  else {
1700
1682
  return {
1701
1683
  profitUsd: constants_1.BN_ZERO,
1702
1684
  lossUsd: priceDiffLoss.getAssetAmountUsd(positionAccount.sizeAmount, positionAccount.sizeDecimals),
1703
- penaltyUsd: constants_1.BN_ZERO,
1704
- finalProfitUsd: constants_1.BN_ZERO,
1705
1685
  };
1706
1686
  }
1707
1687
  };
@@ -1780,40 +1760,22 @@ var PerpetualsClient = (function () {
1780
1760
  priceDiffLoss = new OraclePrice_1.OraclePrice({ price: exitOraclePrice.price.sub(entryOraclePrice.price), exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
1781
1761
  }
1782
1762
  }
1783
- var totalPenaltyBps = positionAccount.oraclePenalty + positionAccount.previousPenalty;
1784
1763
  if (priceDiffProfit.price.gt(constants_1.BN_ZERO)) {
1785
- var grossProfitUsd = priceDiffProfit.getAssetAmountUsd(positionAccount.sizeAmount, positionAccount.sizeDecimals);
1786
- var penaltyUsd = constants_1.BN_ZERO;
1787
- var finalProfitUsd = grossProfitUsd;
1788
- if (totalPenaltyBps > 0 && grossProfitUsd.gt(constants_1.BN_ZERO)) {
1789
- penaltyUsd = grossProfitUsd.muln(totalPenaltyBps).divn(constants_1.BPS_POWER);
1790
- if (penaltyUsd.gte(grossProfitUsd)) {
1791
- penaltyUsd = grossProfitUsd;
1792
- finalProfitUsd = constants_1.BN_ZERO;
1793
- }
1794
- else {
1795
- finalProfitUsd = grossProfitUsd.sub(penaltyUsd);
1796
- }
1797
- }
1798
1764
  pnl = {
1799
- profitUsd: grossProfitUsd,
1765
+ profitUsd: priceDiffProfit.getAssetAmountUsd(positionAccount.sizeAmount, positionAccount.sizeDecimals),
1800
1766
  lossUsd: constants_1.BN_ZERO,
1801
- penaltyUsd: penaltyUsd,
1802
- finalProfitUsd: finalProfitUsd,
1803
1767
  };
1804
1768
  }
1805
1769
  else {
1806
1770
  pnl = {
1807
1771
  profitUsd: constants_1.BN_ZERO,
1808
1772
  lossUsd: priceDiffLoss.getAssetAmountUsd(positionAccount.sizeAmount, positionAccount.sizeDecimals),
1809
- penaltyUsd: constants_1.BN_ZERO,
1810
- finalProfitUsd: constants_1.BN_ZERO,
1811
1773
  };
1812
1774
  }
1813
1775
  var liquidationPrice = _this.getLiquidationPriceContractHelper(entryOraclePrice, lockAndUnsettledFeeUsd, side, targetCustodyAccount, positionAccount);
1814
1776
  var unsettledFeesUsd = exitFeeUsd.add(lockAndUnsettledFeeUsd);
1815
1777
  var lossUsd = pnl.lossUsd.add(unsettledFeesUsd);
1816
- var currentMarginUsd = positionAccount.collateralUsd.add(pnl.finalProfitUsd).sub(lossUsd);
1778
+ var currentMarginUsd = positionAccount.collateralUsd.add(pnl.profitUsd).sub(lossUsd);
1817
1779
  var leverage;
1818
1780
  if (currentMarginUsd.gt(constants_1.BN_ZERO)) {
1819
1781
  leverage = positionAccount.sizeUsd.mul(new anchor_1.BN(constants_1.BPS_POWER)).div(currentMarginUsd);
@@ -2060,7 +2022,7 @@ var PerpetualsClient = (function () {
2060
2022
  });
2061
2023
  };
2062
2024
  this.getStakedLpTokenPrice = function (poolKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
2063
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_1, token, _a, custodies_2, custody, _b, _c, market, transaction, backUpOracleInstruction, setCULimitIx, result, index, res;
2025
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_1, token, _a, custodies_2, custody, _b, _c, market, transaction, backUpOracleInstruction, setCULimitIx, addressLookupTables, result, index, res;
2064
2026
  var _d;
2065
2027
  return __generator(this, function (_e) {
2066
2028
  switch (_e.label) {
@@ -2111,8 +2073,11 @@ var PerpetualsClient = (function () {
2111
2073
  setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
2112
2074
  transaction.instructions.unshift(setCULimitIx);
2113
2075
  (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2114
- return [4, this.viewHelper.simulateTransaction(transaction)];
2076
+ return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
2115
2077
  case 3:
2078
+ addressLookupTables = (_e.sent()).addressLookupTables;
2079
+ return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables)];
2080
+ case 4:
2116
2081
  result = _e.sent();
2117
2082
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getLpTokenPrice'; });
2118
2083
  res = this.viewHelper.decodeLogs(result, index, 'getLpTokenPrice');
@@ -2176,7 +2141,7 @@ var PerpetualsClient = (function () {
2176
2141
  args_1[_i - 4] = arguments[_i];
2177
2142
  }
2178
2143
  return __awaiter(_this, __spreadArray([amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle, whitelist) {
2179
- var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, whitelistMeta, depositCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2144
+ var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, whitelistMeta, depositCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, addressLookupTables, result, index, res;
2180
2145
  var _e;
2181
2146
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2182
2147
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
@@ -2241,8 +2206,11 @@ var PerpetualsClient = (function () {
2241
2206
  backUpOracleInstruction = _f.sent();
2242
2207
  (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2243
2208
  _f.label = 3;
2244
- case 3: return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2209
+ case 3: return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
2245
2210
  case 4:
2211
+ addressLookupTables = (_f.sent()).addressLookupTables;
2212
+ return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables, userPublicKey)];
2213
+ case 5:
2246
2214
  result = _f.sent();
2247
2215
  if (result.value.err) {
2248
2216
  console.error('error Simulation failed:::', result);
@@ -2268,7 +2236,7 @@ var PerpetualsClient = (function () {
2268
2236
  args_1[_i - 4] = arguments[_i];
2269
2237
  }
2270
2238
  return __awaiter(_this, __spreadArray([amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle, whitelist) {
2271
- var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, whitelistMeta, removeCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2239
+ var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, whitelistMeta, removeCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, addressLookupTables, result, index, res;
2272
2240
  var _e;
2273
2241
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2274
2242
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
@@ -2333,8 +2301,11 @@ var PerpetualsClient = (function () {
2333
2301
  backUpOracleInstruction = _f.sent();
2334
2302
  (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2335
2303
  _f.label = 3;
2336
- case 3: return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2304
+ case 3: return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
2337
2305
  case 4:
2306
+ addressLookupTables = (_f.sent()).addressLookupTables;
2307
+ return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables, userPublicKey)];
2308
+ case 5:
2338
2309
  result = _f.sent();
2339
2310
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
2340
2311
  if (result.value.err) {
@@ -2355,7 +2326,7 @@ var PerpetualsClient = (function () {
2355
2326
  });
2356
2327
  };
2357
2328
  this.getCompoundingLPTokenPrice = function (poolKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
2358
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_9, token, _a, custodies_10, custody, _b, _c, market, backUpOracleInstruction, transaction, setCULimitIx, result, index, res;
2329
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_9, token, _a, custodies_10, custody, _b, _c, market, backUpOracleInstruction, transaction, setCULimitIx, addressLookupTables, result, index, res;
2359
2330
  var _d;
2360
2331
  return __generator(this, function (_e) {
2361
2332
  switch (_e.label) {
@@ -2406,8 +2377,11 @@ var PerpetualsClient = (function () {
2406
2377
  setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
2407
2378
  transaction.instructions.unshift(setCULimitIx);
2408
2379
  (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2409
- return [4, this.viewHelper.simulateTransaction(transaction)];
2380
+ return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
2410
2381
  case 3:
2382
+ addressLookupTables = (_e.sent()).addressLookupTables;
2383
+ return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables)];
2384
+ case 4:
2411
2385
  result = _e.sent();
2412
2386
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getCompoundingTokenPrice'; });
2413
2387
  res = this.viewHelper.decodeLogs(result, index, 'getCompoundingTokenPrice');
@@ -2421,7 +2395,7 @@ var PerpetualsClient = (function () {
2421
2395
  args_1[_i - 4] = arguments[_i];
2422
2396
  }
2423
2397
  return __awaiter(_this, __spreadArray([amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle, whitelist) {
2424
- var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, whitelistMeta, depositCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2398
+ var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, whitelistMeta, depositCustodyConfig, rewardCustody, transaction, setCULimitIx, addressLookupTables, backUpOracleInstruction, result, index, res;
2425
2399
  var _e;
2426
2400
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2427
2401
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
@@ -2484,14 +2458,17 @@ var PerpetualsClient = (function () {
2484
2458
  transaction = _f.sent();
2485
2459
  setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
2486
2460
  transaction.instructions.unshift(setCULimitIx);
2487
- if (!enableBackupOracle) return [3, 3];
2488
- return [4, (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true)];
2461
+ return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
2489
2462
  case 2:
2463
+ addressLookupTables = (_f.sent()).addressLookupTables;
2464
+ if (!enableBackupOracle) return [3, 4];
2465
+ return [4, (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true)];
2466
+ case 3:
2490
2467
  backUpOracleInstruction = _f.sent();
2491
2468
  (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2492
- _f.label = 3;
2493
- case 3: return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2494
- case 4:
2469
+ _f.label = 4;
2470
+ case 4: return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables, userPublicKey)];
2471
+ case 5:
2495
2472
  result = _f.sent();
2496
2473
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
2497
2474
  res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
@@ -2509,7 +2486,7 @@ var PerpetualsClient = (function () {
2509
2486
  args_1[_i - 4] = arguments[_i];
2510
2487
  }
2511
2488
  return __awaiter(_this, __spreadArray([amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle, whitelist) {
2512
- var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, whitelistMeta, removeCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2489
+ var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, whitelistMeta, removeCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, addressLookupTables, result, index, res;
2513
2490
  var _e;
2514
2491
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2515
2492
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
@@ -2578,8 +2555,12 @@ var PerpetualsClient = (function () {
2578
2555
  backUpOracleInstruction = _f.sent();
2579
2556
  (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2580
2557
  _f.label = 3;
2581
- case 3: return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2558
+ case 3: return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
2582
2559
  case 4:
2560
+ addressLookupTables = (_f.sent()).addressLookupTables;
2561
+ this.addressLookupTables = addressLookupTables;
2562
+ return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables, userPublicKey)];
2563
+ case 5:
2583
2564
  result = _f.sent();
2584
2565
  index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
2585
2566
  if (result.value.err) {
@@ -7631,44 +7612,8 @@ var PerpetualsClient = (function () {
7631
7612
  }
7632
7613
  });
7633
7614
  }); };
7634
- this.setPositionPenalty = function (positionPubkey, oraclePenalty, oracleAuthority) { return __awaiter(_this, void 0, void 0, function () {
7635
- var instructions, additionalSigners, setPositionPenaltyIx, err_52;
7636
- return __generator(this, function (_a) {
7637
- switch (_a.label) {
7638
- case 0:
7639
- instructions = [];
7640
- additionalSigners = [];
7641
- _a.label = 1;
7642
- case 1:
7643
- _a.trys.push([1, 3, , 4]);
7644
- return [4, this.program.methods
7645
- .setPositionPenalty({
7646
- oraclePenalty: oraclePenalty,
7647
- })
7648
- .accounts({
7649
- authority: oracleAuthority,
7650
- position: positionPubkey,
7651
- eventAuthority: this.eventAuthority.publicKey,
7652
- program: this.program.programId,
7653
- })
7654
- .instruction()];
7655
- case 2:
7656
- setPositionPenaltyIx = _a.sent();
7657
- instructions.push(setPositionPenaltyIx);
7658
- return [3, 4];
7659
- case 3:
7660
- err_52 = _a.sent();
7661
- console.log("perpClient setPositionPenalty error:: ", err_52);
7662
- throw err_52;
7663
- case 4: return [2, {
7664
- instructions: __spreadArray([], instructions, true),
7665
- additionalSigners: additionalSigners
7666
- }];
7667
- }
7668
- });
7669
- }); };
7670
7615
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7671
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_53;
7616
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_52;
7672
7617
  return __generator(this, function (_a) {
7673
7618
  switch (_a.label) {
7674
7619
  case 0:
@@ -7706,8 +7651,8 @@ var PerpetualsClient = (function () {
7706
7651
  instructions.push(renameFlp);
7707
7652
  return [3, 4];
7708
7653
  case 3:
7709
- err_53 = _a.sent();
7710
- console.log("perpClient renameFlp error:: ", err_53);
7654
+ err_52 = _a.sent();
7655
+ console.log("perpClient renameFlp error:: ", err_52);
7711
7656
  return [3, 4];
7712
7657
  case 4: return [2, {
7713
7658
  instructions: __spreadArray([], instructions, true),
@@ -7717,7 +7662,7 @@ var PerpetualsClient = (function () {
7717
7662
  });
7718
7663
  }); };
7719
7664
  this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7720
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_54;
7665
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_53;
7721
7666
  return __generator(this, function (_a) {
7722
7667
  switch (_a.label) {
7723
7668
  case 0:
@@ -7755,9 +7700,9 @@ var PerpetualsClient = (function () {
7755
7700
  instructions.push(initStakeInstruction);
7756
7701
  return [3, 4];
7757
7702
  case 3:
7758
- err_54 = _a.sent();
7759
- console.log("perpClient InitStaking error:: ", err_54);
7760
- throw err_54;
7703
+ err_53 = _a.sent();
7704
+ console.log("perpClient InitStaking error:: ", err_53);
7705
+ throw err_53;
7761
7706
  case 4: return [2, {
7762
7707
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7763
7708
  additionalSigners: additionalSigners
@@ -7766,7 +7711,7 @@ var PerpetualsClient = (function () {
7766
7711
  });
7767
7712
  }); };
7768
7713
  this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7769
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_55;
7714
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_54;
7770
7715
  return __generator(this, function (_a) {
7771
7716
  switch (_a.label) {
7772
7717
  case 0:
@@ -7810,9 +7755,9 @@ var PerpetualsClient = (function () {
7810
7755
  instructions.push(initCompoundingInstruction);
7811
7756
  return [3, 4];
7812
7757
  case 3:
7813
- err_55 = _a.sent();
7814
- console.log("perpClient initCompounding error:: ", err_55);
7815
- throw err_55;
7758
+ err_54 = _a.sent();
7759
+ console.log("perpClient initCompounding error:: ", err_54);
7760
+ throw err_54;
7816
7761
  case 4: return [2, {
7817
7762
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7818
7763
  additionalSigners: additionalSigners
@@ -7821,7 +7766,7 @@ var PerpetualsClient = (function () {
7821
7766
  });
7822
7767
  }); };
7823
7768
  this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7824
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_56;
7769
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_55;
7825
7770
  return __generator(this, function (_a) {
7826
7771
  switch (_a.label) {
7827
7772
  case 0:
@@ -7862,9 +7807,9 @@ var PerpetualsClient = (function () {
7862
7807
  instructions.push(initTokenVaultInstruction);
7863
7808
  return [3, 4];
7864
7809
  case 3:
7865
- err_56 = _a.sent();
7866
- console.log("perpClient InitTokenVaultInstruction error:: ", err_56);
7867
- throw err_56;
7810
+ err_55 = _a.sent();
7811
+ console.log("perpClient InitTokenVaultInstruction error:: ", err_55);
7812
+ throw err_55;
7868
7813
  case 4: return [2, {
7869
7814
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7870
7815
  additionalSigners: additionalSigners
@@ -7873,7 +7818,7 @@ var PerpetualsClient = (function () {
7873
7818
  });
7874
7819
  }); };
7875
7820
  this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7876
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_57;
7821
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_56;
7877
7822
  return __generator(this, function (_a) {
7878
7823
  switch (_a.label) {
7879
7824
  case 0:
@@ -7904,9 +7849,9 @@ var PerpetualsClient = (function () {
7904
7849
  instructions.push(setTokenVaultConfigInstruction);
7905
7850
  return [3, 4];
7906
7851
  case 3:
7907
- err_57 = _a.sent();
7908
- console.log("perpClient setTokenVaultConfigInstruction error:: ", err_57);
7909
- throw err_57;
7852
+ err_56 = _a.sent();
7853
+ console.log("perpClient setTokenVaultConfigInstruction error:: ", err_56);
7854
+ throw err_56;
7910
7855
  case 4: return [2, {
7911
7856
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7912
7857
  additionalSigners: additionalSigners
@@ -7915,7 +7860,7 @@ var PerpetualsClient = (function () {
7915
7860
  });
7916
7861
  }); };
7917
7862
  this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7918
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_58;
7863
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_57;
7919
7864
  return __generator(this, function (_a) {
7920
7865
  switch (_a.label) {
7921
7866
  case 0:
@@ -7954,9 +7899,9 @@ var PerpetualsClient = (function () {
7954
7899
  instructions.push(withdrawInstantFeeInstruction);
7955
7900
  return [3, 6];
7956
7901
  case 5:
7957
- err_58 = _a.sent();
7958
- console.log("perpClient withdrawInstantFeeInstruction error:: ", err_58);
7959
- throw err_58;
7902
+ err_57 = _a.sent();
7903
+ console.log("perpClient withdrawInstantFeeInstruction error:: ", err_57);
7904
+ throw err_57;
7960
7905
  case 6: return [2, {
7961
7906
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7962
7907
  additionalSigners: additionalSigners
@@ -7965,7 +7910,7 @@ var PerpetualsClient = (function () {
7965
7910
  });
7966
7911
  }); };
7967
7912
  this.withdrawUnclaimedTokens = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7968
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction, err_59;
7913
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction, err_58;
7969
7914
  return __generator(this, function (_a) {
7970
7915
  switch (_a.label) {
7971
7916
  case 0:
@@ -8004,9 +7949,9 @@ var PerpetualsClient = (function () {
8004
7949
  instructions.push(withdrawUnclaimedTokensInstruction);
8005
7950
  return [3, 6];
8006
7951
  case 5:
8007
- err_59 = _a.sent();
8008
- console.log("perpClient withdrawUnclaimedTokensInstruction error:: ", err_59);
8009
- throw err_59;
7952
+ err_58 = _a.sent();
7953
+ console.log("perpClient withdrawUnclaimedTokensInstruction error:: ", err_58);
7954
+ throw err_58;
8010
7955
  case 6: return [2, {
8011
7956
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8012
7957
  additionalSigners: additionalSigners
@@ -8015,7 +7960,7 @@ var PerpetualsClient = (function () {
8015
7960
  });
8016
7961
  }); };
8017
7962
  this.initRevenueTokenAccount = function (feeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8018
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_60;
7963
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_59;
8019
7964
  return __generator(this, function (_a) {
8020
7965
  switch (_a.label) {
8021
7966
  case 0:
@@ -8052,9 +7997,9 @@ var PerpetualsClient = (function () {
8052
7997
  instructions.push(initRevenueTokenAccountInstruction);
8053
7998
  return [3, 4];
8054
7999
  case 3:
8055
- err_60 = _a.sent();
8056
- console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_60);
8057
- throw err_60;
8000
+ err_59 = _a.sent();
8001
+ console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_59);
8002
+ throw err_59;
8058
8003
  case 4: return [2, {
8059
8004
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8060
8005
  additionalSigners: additionalSigners
@@ -8063,7 +8008,7 @@ var PerpetualsClient = (function () {
8063
8008
  });
8064
8009
  }); };
8065
8010
  this.initRebateVault = function (allowRebatePayout, rebateSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8066
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction, err_61;
8011
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction, err_60;
8067
8012
  return __generator(this, function (_a) {
8068
8013
  switch (_a.label) {
8069
8014
  case 0:
@@ -8098,9 +8043,9 @@ var PerpetualsClient = (function () {
8098
8043
  instructions.push(initRebateVaultInstruction);
8099
8044
  return [3, 4];
8100
8045
  case 3:
8101
- err_61 = _a.sent();
8102
- console.log("perpClient initRebateVaultInstruction error:: ", err_61);
8103
- throw err_61;
8046
+ err_60 = _a.sent();
8047
+ console.log("perpClient initRebateVaultInstruction error:: ", err_60);
8048
+ throw err_60;
8104
8049
  case 4: return [2, {
8105
8050
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8106
8051
  additionalSigners: additionalSigners
@@ -8109,7 +8054,7 @@ var PerpetualsClient = (function () {
8109
8054
  });
8110
8055
  }); };
8111
8056
  this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8112
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_62;
8057
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_61;
8113
8058
  return __generator(this, function (_a) {
8114
8059
  switch (_a.label) {
8115
8060
  case 0:
@@ -8148,9 +8093,9 @@ var PerpetualsClient = (function () {
8148
8093
  instructions.push(distributeTokenRewardInstruction);
8149
8094
  return [3, 4];
8150
8095
  case 3:
8151
- err_62 = _a.sent();
8152
- console.log("perpClient distributeTokenRewardInstruction error:: ", err_62);
8153
- throw err_62;
8096
+ err_61 = _a.sent();
8097
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_61);
8098
+ throw err_61;
8154
8099
  case 4: return [2, {
8155
8100
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8156
8101
  additionalSigners: additionalSigners
@@ -8159,7 +8104,7 @@ var PerpetualsClient = (function () {
8159
8104
  });
8160
8105
  }); };
8161
8106
  this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
8162
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_63;
8107
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_62;
8163
8108
  return __generator(this, function (_a) {
8164
8109
  switch (_a.label) {
8165
8110
  case 0:
@@ -8187,9 +8132,9 @@ var PerpetualsClient = (function () {
8187
8132
  instructions.push(setTokenStakeLevelInstruction);
8188
8133
  return [3, 4];
8189
8134
  case 3:
8190
- err_63 = _a.sent();
8191
- console.log("perpClient setTokenStakeLevelInstruction error:: ", err_63);
8192
- throw err_63;
8135
+ err_62 = _a.sent();
8136
+ console.log("perpClient setTokenStakeLevelInstruction error:: ", err_62);
8137
+ throw err_62;
8193
8138
  case 4: return [2, {
8194
8139
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8195
8140
  additionalSigners: additionalSigners
@@ -8198,7 +8143,7 @@ var PerpetualsClient = (function () {
8198
8143
  });
8199
8144
  }); };
8200
8145
  this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8201
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_64;
8146
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_63;
8202
8147
  return __generator(this, function (_a) {
8203
8148
  switch (_a.label) {
8204
8149
  case 0:
@@ -8230,9 +8175,9 @@ var PerpetualsClient = (function () {
8230
8175
  instructions.push(setTokenRewardInstruction);
8231
8176
  return [3, 4];
8232
8177
  case 3:
8233
- err_64 = _a.sent();
8234
- console.log("perpClient setTokenRewardInstruction error:: ", err_64);
8235
- throw err_64;
8178
+ err_63 = _a.sent();
8179
+ console.log("perpClient setTokenRewardInstruction error:: ", err_63);
8180
+ throw err_63;
8236
8181
  case 4: return [2, {
8237
8182
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8238
8183
  additionalSigners: additionalSigners
@@ -8241,7 +8186,7 @@ var PerpetualsClient = (function () {
8241
8186
  });
8242
8187
  }); };
8243
8188
  this.resizeInternalOracle = function (extOracle, tokenMint, intOracleAccount) { return __awaiter(_this, void 0, void 0, function () {
8244
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_65;
8189
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_64;
8245
8190
  return __generator(this, function (_a) {
8246
8191
  switch (_a.label) {
8247
8192
  case 0:
@@ -8270,9 +8215,9 @@ var PerpetualsClient = (function () {
8270
8215
  instructions.push(resizeInternalOracleInstruction);
8271
8216
  return [3, 4];
8272
8217
  case 3:
8273
- err_65 = _a.sent();
8274
- console.log("perpClient resizeInternalOracleInstruction error:: ", err_65);
8275
- throw err_65;
8218
+ err_64 = _a.sent();
8219
+ console.log("perpClient resizeInternalOracleInstruction error:: ", err_64);
8220
+ throw err_64;
8276
8221
  case 4: return [2, {
8277
8222
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8278
8223
  additionalSigners: additionalSigners
@@ -8281,7 +8226,7 @@ var PerpetualsClient = (function () {
8281
8226
  });
8282
8227
  }); };
8283
8228
  this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
8284
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_66;
8229
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_65;
8285
8230
  return __generator(this, function (_a) {
8286
8231
  switch (_a.label) {
8287
8232
  case 0:
@@ -8314,9 +8259,9 @@ var PerpetualsClient = (function () {
8314
8259
  instructions.push(createWhitelistInstruction);
8315
8260
  return [3, 4];
8316
8261
  case 3:
8317
- err_66 = _a.sent();
8318
- console.log("perpClient createWhitelistInstruction error:: ", err_66);
8319
- throw err_66;
8262
+ err_65 = _a.sent();
8263
+ console.log("perpClient createWhitelistInstruction error:: ", err_65);
8264
+ throw err_65;
8320
8265
  case 4: return [2, {
8321
8266
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8322
8267
  additionalSigners: additionalSigners
@@ -8325,7 +8270,7 @@ var PerpetualsClient = (function () {
8325
8270
  });
8326
8271
  }); };
8327
8272
  this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
8328
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_67;
8273
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_66;
8329
8274
  return __generator(this, function (_a) {
8330
8275
  switch (_a.label) {
8331
8276
  case 0:
@@ -8358,9 +8303,9 @@ var PerpetualsClient = (function () {
8358
8303
  instructions.push(setWhitelistConfigInstruction);
8359
8304
  return [3, 4];
8360
8305
  case 3:
8361
- err_67 = _a.sent();
8362
- console.log("perpClient setWhitelistConfigInstruction error:: ", err_67);
8363
- throw err_67;
8306
+ err_66 = _a.sent();
8307
+ console.log("perpClient setWhitelistConfigInstruction error:: ", err_66);
8308
+ throw err_66;
8364
8309
  case 4: return [2, {
8365
8310
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8366
8311
  additionalSigners: additionalSigners
@@ -21,8 +21,7 @@ export declare class PositionAccount implements Position {
21
21
  cumulativeLockFeeSnapshot: BN;
22
22
  degenSizeUsd: BN;
23
23
  referencePrice: ContractOraclePrice;
24
- oraclePenalty: number;
25
- previousPenalty: number;
24
+ buffer: number;
26
25
  sizeDecimals: number;
27
26
  lockedDecimals: number;
28
27
  collateralDecimals: number;
@@ -1,8 +1,9 @@
1
1
  import { PublicKey, RpcResponseAndContext, SimulatedTransactionResponse, Transaction } from "@solana/web3.js";
2
2
  import { PerpetualsClient } from "./PerpetualsClient";
3
+ import { AddressLookupTableAccount } from "@solana/web3.js";
3
4
  export declare class ViewHelper {
4
5
  private perpetualsClient;
5
6
  constructor(client: PerpetualsClient);
6
7
  decodeLogs<T>(data: RpcResponseAndContext<SimulatedTransactionResponse>, instructionNumber: number, instructionName?: string): T | undefined;
7
- simulateTransaction(transaction: Transaction, userPublicKey?: PublicKey | undefined): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
8
+ simulateTransaction(transaction: Transaction, AddressLookupTableAccount?: AddressLookupTableAccount[], userPublicKey?: PublicKey | undefined): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
8
9
  }