flash-sdk 11.8.6 → 11.10.1-alpha.0

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