flash-sdk 11.8.1 → 11.8.2-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.
- package/dist/PerpetualsClient.d.ts +49 -14
- package/dist/PerpetualsClient.js +137 -65
- package/dist/PositionAccount.d.ts +2 -1
- package/dist/idl/perpetuals.d.ts +46 -304
- package/dist/idl/perpetuals.js +46 -304
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -1
- package/package.json +1 -1
package/dist/PerpetualsClient.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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:
|
|
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
|
};
|
|
@@ -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:
|
|
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.
|
|
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);
|
|
@@ -7593,8 +7631,42 @@ var PerpetualsClient = (function () {
|
|
|
7593
7631
|
}
|
|
7594
7632
|
});
|
|
7595
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
|
+
})
|
|
7652
|
+
.instruction()];
|
|
7653
|
+
case 2:
|
|
7654
|
+
setPositionPenaltyIx = _a.sent();
|
|
7655
|
+
instructions.push(setPositionPenaltyIx);
|
|
7656
|
+
return [3, 4];
|
|
7657
|
+
case 3:
|
|
7658
|
+
err_52 = _a.sent();
|
|
7659
|
+
console.log("perpClient setPositionPenalty error:: ", err_52);
|
|
7660
|
+
throw err_52;
|
|
7661
|
+
case 4: return [2, {
|
|
7662
|
+
instructions: __spreadArray([], instructions, true),
|
|
7663
|
+
additionalSigners: additionalSigners
|
|
7664
|
+
}];
|
|
7665
|
+
}
|
|
7666
|
+
});
|
|
7667
|
+
}); };
|
|
7596
7668
|
this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7597
|
-
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp,
|
|
7669
|
+
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_53;
|
|
7598
7670
|
return __generator(this, function (_a) {
|
|
7599
7671
|
switch (_a.label) {
|
|
7600
7672
|
case 0:
|
|
@@ -7632,8 +7704,8 @@ var PerpetualsClient = (function () {
|
|
|
7632
7704
|
instructions.push(renameFlp);
|
|
7633
7705
|
return [3, 4];
|
|
7634
7706
|
case 3:
|
|
7635
|
-
|
|
7636
|
-
console.log("perpClient renameFlp error:: ",
|
|
7707
|
+
err_53 = _a.sent();
|
|
7708
|
+
console.log("perpClient renameFlp error:: ", err_53);
|
|
7637
7709
|
return [3, 4];
|
|
7638
7710
|
case 4: return [2, {
|
|
7639
7711
|
instructions: __spreadArray([], instructions, true),
|
|
@@ -7643,7 +7715,7 @@ var PerpetualsClient = (function () {
|
|
|
7643
7715
|
});
|
|
7644
7716
|
}); };
|
|
7645
7717
|
this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7646
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction,
|
|
7718
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_54;
|
|
7647
7719
|
return __generator(this, function (_a) {
|
|
7648
7720
|
switch (_a.label) {
|
|
7649
7721
|
case 0:
|
|
@@ -7681,9 +7753,9 @@ var PerpetualsClient = (function () {
|
|
|
7681
7753
|
instructions.push(initStakeInstruction);
|
|
7682
7754
|
return [3, 4];
|
|
7683
7755
|
case 3:
|
|
7684
|
-
|
|
7685
|
-
console.log("perpClient InitStaking error:: ",
|
|
7686
|
-
throw
|
|
7756
|
+
err_54 = _a.sent();
|
|
7757
|
+
console.log("perpClient InitStaking error:: ", err_54);
|
|
7758
|
+
throw err_54;
|
|
7687
7759
|
case 4: return [2, {
|
|
7688
7760
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7689
7761
|
additionalSigners: additionalSigners
|
|
@@ -7692,7 +7764,7 @@ var PerpetualsClient = (function () {
|
|
|
7692
7764
|
});
|
|
7693
7765
|
}); };
|
|
7694
7766
|
this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7695
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction,
|
|
7767
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_55;
|
|
7696
7768
|
return __generator(this, function (_a) {
|
|
7697
7769
|
switch (_a.label) {
|
|
7698
7770
|
case 0:
|
|
@@ -7736,9 +7808,9 @@ var PerpetualsClient = (function () {
|
|
|
7736
7808
|
instructions.push(initCompoundingInstruction);
|
|
7737
7809
|
return [3, 4];
|
|
7738
7810
|
case 3:
|
|
7739
|
-
|
|
7740
|
-
console.log("perpClient initCompounding error:: ",
|
|
7741
|
-
throw
|
|
7811
|
+
err_55 = _a.sent();
|
|
7812
|
+
console.log("perpClient initCompounding error:: ", err_55);
|
|
7813
|
+
throw err_55;
|
|
7742
7814
|
case 4: return [2, {
|
|
7743
7815
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7744
7816
|
additionalSigners: additionalSigners
|
|
@@ -7747,7 +7819,7 @@ var PerpetualsClient = (function () {
|
|
|
7747
7819
|
});
|
|
7748
7820
|
}); };
|
|
7749
7821
|
this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7750
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction,
|
|
7822
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_56;
|
|
7751
7823
|
return __generator(this, function (_a) {
|
|
7752
7824
|
switch (_a.label) {
|
|
7753
7825
|
case 0:
|
|
@@ -7788,9 +7860,9 @@ var PerpetualsClient = (function () {
|
|
|
7788
7860
|
instructions.push(initTokenVaultInstruction);
|
|
7789
7861
|
return [3, 4];
|
|
7790
7862
|
case 3:
|
|
7791
|
-
|
|
7792
|
-
console.log("perpClient InitTokenVaultInstruction error:: ",
|
|
7793
|
-
throw
|
|
7863
|
+
err_56 = _a.sent();
|
|
7864
|
+
console.log("perpClient InitTokenVaultInstruction error:: ", err_56);
|
|
7865
|
+
throw err_56;
|
|
7794
7866
|
case 4: return [2, {
|
|
7795
7867
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7796
7868
|
additionalSigners: additionalSigners
|
|
@@ -7799,7 +7871,7 @@ var PerpetualsClient = (function () {
|
|
|
7799
7871
|
});
|
|
7800
7872
|
}); };
|
|
7801
7873
|
this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7802
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction,
|
|
7874
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_57;
|
|
7803
7875
|
return __generator(this, function (_a) {
|
|
7804
7876
|
switch (_a.label) {
|
|
7805
7877
|
case 0:
|
|
@@ -7830,9 +7902,9 @@ var PerpetualsClient = (function () {
|
|
|
7830
7902
|
instructions.push(setTokenVaultConfigInstruction);
|
|
7831
7903
|
return [3, 4];
|
|
7832
7904
|
case 3:
|
|
7833
|
-
|
|
7834
|
-
console.log("perpClient setTokenVaultConfigInstruction error:: ",
|
|
7835
|
-
throw
|
|
7905
|
+
err_57 = _a.sent();
|
|
7906
|
+
console.log("perpClient setTokenVaultConfigInstruction error:: ", err_57);
|
|
7907
|
+
throw err_57;
|
|
7836
7908
|
case 4: return [2, {
|
|
7837
7909
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7838
7910
|
additionalSigners: additionalSigners
|
|
@@ -7841,7 +7913,7 @@ var PerpetualsClient = (function () {
|
|
|
7841
7913
|
});
|
|
7842
7914
|
}); };
|
|
7843
7915
|
this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7844
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction,
|
|
7916
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_58;
|
|
7845
7917
|
return __generator(this, function (_a) {
|
|
7846
7918
|
switch (_a.label) {
|
|
7847
7919
|
case 0:
|
|
@@ -7880,9 +7952,9 @@ var PerpetualsClient = (function () {
|
|
|
7880
7952
|
instructions.push(withdrawInstantFeeInstruction);
|
|
7881
7953
|
return [3, 6];
|
|
7882
7954
|
case 5:
|
|
7883
|
-
|
|
7884
|
-
console.log("perpClient withdrawInstantFeeInstruction error:: ",
|
|
7885
|
-
throw
|
|
7955
|
+
err_58 = _a.sent();
|
|
7956
|
+
console.log("perpClient withdrawInstantFeeInstruction error:: ", err_58);
|
|
7957
|
+
throw err_58;
|
|
7886
7958
|
case 6: return [2, {
|
|
7887
7959
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7888
7960
|
additionalSigners: additionalSigners
|
|
@@ -7891,7 +7963,7 @@ var PerpetualsClient = (function () {
|
|
|
7891
7963
|
});
|
|
7892
7964
|
}); };
|
|
7893
7965
|
this.withdrawUnclaimedTokens = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7894
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction,
|
|
7966
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction, err_59;
|
|
7895
7967
|
return __generator(this, function (_a) {
|
|
7896
7968
|
switch (_a.label) {
|
|
7897
7969
|
case 0:
|
|
@@ -7930,9 +8002,9 @@ var PerpetualsClient = (function () {
|
|
|
7930
8002
|
instructions.push(withdrawUnclaimedTokensInstruction);
|
|
7931
8003
|
return [3, 6];
|
|
7932
8004
|
case 5:
|
|
7933
|
-
|
|
7934
|
-
console.log("perpClient withdrawUnclaimedTokensInstruction error:: ",
|
|
7935
|
-
throw
|
|
8005
|
+
err_59 = _a.sent();
|
|
8006
|
+
console.log("perpClient withdrawUnclaimedTokensInstruction error:: ", err_59);
|
|
8007
|
+
throw err_59;
|
|
7936
8008
|
case 6: return [2, {
|
|
7937
8009
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7938
8010
|
additionalSigners: additionalSigners
|
|
@@ -7941,7 +8013,7 @@ var PerpetualsClient = (function () {
|
|
|
7941
8013
|
});
|
|
7942
8014
|
}); };
|
|
7943
8015
|
this.initRevenueTokenAccount = function (feeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7944
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction,
|
|
8016
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_60;
|
|
7945
8017
|
return __generator(this, function (_a) {
|
|
7946
8018
|
switch (_a.label) {
|
|
7947
8019
|
case 0:
|
|
@@ -7978,9 +8050,9 @@ var PerpetualsClient = (function () {
|
|
|
7978
8050
|
instructions.push(initRevenueTokenAccountInstruction);
|
|
7979
8051
|
return [3, 4];
|
|
7980
8052
|
case 3:
|
|
7981
|
-
|
|
7982
|
-
console.log("perpClient initRevenueTokenAccountInstruction error:: ",
|
|
7983
|
-
throw
|
|
8053
|
+
err_60 = _a.sent();
|
|
8054
|
+
console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_60);
|
|
8055
|
+
throw err_60;
|
|
7984
8056
|
case 4: return [2, {
|
|
7985
8057
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7986
8058
|
additionalSigners: additionalSigners
|
|
@@ -7989,7 +8061,7 @@ var PerpetualsClient = (function () {
|
|
|
7989
8061
|
});
|
|
7990
8062
|
}); };
|
|
7991
8063
|
this.initRebateVault = function (allowRebatePayout, rebateSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7992
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction,
|
|
8064
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction, err_61;
|
|
7993
8065
|
return __generator(this, function (_a) {
|
|
7994
8066
|
switch (_a.label) {
|
|
7995
8067
|
case 0:
|
|
@@ -8024,9 +8096,9 @@ var PerpetualsClient = (function () {
|
|
|
8024
8096
|
instructions.push(initRebateVaultInstruction);
|
|
8025
8097
|
return [3, 4];
|
|
8026
8098
|
case 3:
|
|
8027
|
-
|
|
8028
|
-
console.log("perpClient initRebateVaultInstruction error:: ",
|
|
8029
|
-
throw
|
|
8099
|
+
err_61 = _a.sent();
|
|
8100
|
+
console.log("perpClient initRebateVaultInstruction error:: ", err_61);
|
|
8101
|
+
throw err_61;
|
|
8030
8102
|
case 4: return [2, {
|
|
8031
8103
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8032
8104
|
additionalSigners: additionalSigners
|
|
@@ -8035,7 +8107,7 @@ var PerpetualsClient = (function () {
|
|
|
8035
8107
|
});
|
|
8036
8108
|
}); };
|
|
8037
8109
|
this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
8038
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction,
|
|
8110
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_62;
|
|
8039
8111
|
return __generator(this, function (_a) {
|
|
8040
8112
|
switch (_a.label) {
|
|
8041
8113
|
case 0:
|
|
@@ -8074,9 +8146,9 @@ var PerpetualsClient = (function () {
|
|
|
8074
8146
|
instructions.push(distributeTokenRewardInstruction);
|
|
8075
8147
|
return [3, 4];
|
|
8076
8148
|
case 3:
|
|
8077
|
-
|
|
8078
|
-
console.log("perpClient distributeTokenRewardInstruction error:: ",
|
|
8079
|
-
throw
|
|
8149
|
+
err_62 = _a.sent();
|
|
8150
|
+
console.log("perpClient distributeTokenRewardInstruction error:: ", err_62);
|
|
8151
|
+
throw err_62;
|
|
8080
8152
|
case 4: return [2, {
|
|
8081
8153
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8082
8154
|
additionalSigners: additionalSigners
|
|
@@ -8085,7 +8157,7 @@ var PerpetualsClient = (function () {
|
|
|
8085
8157
|
});
|
|
8086
8158
|
}); };
|
|
8087
8159
|
this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
|
|
8088
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction,
|
|
8160
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_63;
|
|
8089
8161
|
return __generator(this, function (_a) {
|
|
8090
8162
|
switch (_a.label) {
|
|
8091
8163
|
case 0:
|
|
@@ -8113,9 +8185,9 @@ var PerpetualsClient = (function () {
|
|
|
8113
8185
|
instructions.push(setTokenStakeLevelInstruction);
|
|
8114
8186
|
return [3, 4];
|
|
8115
8187
|
case 3:
|
|
8116
|
-
|
|
8117
|
-
console.log("perpClient setTokenStakeLevelInstruction error:: ",
|
|
8118
|
-
throw
|
|
8188
|
+
err_63 = _a.sent();
|
|
8189
|
+
console.log("perpClient setTokenStakeLevelInstruction error:: ", err_63);
|
|
8190
|
+
throw err_63;
|
|
8119
8191
|
case 4: return [2, {
|
|
8120
8192
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8121
8193
|
additionalSigners: additionalSigners
|
|
@@ -8124,7 +8196,7 @@ var PerpetualsClient = (function () {
|
|
|
8124
8196
|
});
|
|
8125
8197
|
}); };
|
|
8126
8198
|
this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
8127
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction,
|
|
8199
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_64;
|
|
8128
8200
|
return __generator(this, function (_a) {
|
|
8129
8201
|
switch (_a.label) {
|
|
8130
8202
|
case 0:
|
|
@@ -8156,9 +8228,9 @@ var PerpetualsClient = (function () {
|
|
|
8156
8228
|
instructions.push(setTokenRewardInstruction);
|
|
8157
8229
|
return [3, 4];
|
|
8158
8230
|
case 3:
|
|
8159
|
-
|
|
8160
|
-
console.log("perpClient setTokenRewardInstruction error:: ",
|
|
8161
|
-
throw
|
|
8231
|
+
err_64 = _a.sent();
|
|
8232
|
+
console.log("perpClient setTokenRewardInstruction error:: ", err_64);
|
|
8233
|
+
throw err_64;
|
|
8162
8234
|
case 4: return [2, {
|
|
8163
8235
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8164
8236
|
additionalSigners: additionalSigners
|
|
@@ -8167,7 +8239,7 @@ var PerpetualsClient = (function () {
|
|
|
8167
8239
|
});
|
|
8168
8240
|
}); };
|
|
8169
8241
|
this.resizeInternalOracle = function (extOracle, tokenMint, intOracleAccount) { return __awaiter(_this, void 0, void 0, function () {
|
|
8170
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction,
|
|
8242
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_65;
|
|
8171
8243
|
return __generator(this, function (_a) {
|
|
8172
8244
|
switch (_a.label) {
|
|
8173
8245
|
case 0:
|
|
@@ -8196,9 +8268,9 @@ var PerpetualsClient = (function () {
|
|
|
8196
8268
|
instructions.push(resizeInternalOracleInstruction);
|
|
8197
8269
|
return [3, 4];
|
|
8198
8270
|
case 3:
|
|
8199
|
-
|
|
8200
|
-
console.log("perpClient resizeInternalOracleInstruction error:: ",
|
|
8201
|
-
throw
|
|
8271
|
+
err_65 = _a.sent();
|
|
8272
|
+
console.log("perpClient resizeInternalOracleInstruction error:: ", err_65);
|
|
8273
|
+
throw err_65;
|
|
8202
8274
|
case 4: return [2, {
|
|
8203
8275
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8204
8276
|
additionalSigners: additionalSigners
|
|
@@ -8207,7 +8279,7 @@ var PerpetualsClient = (function () {
|
|
|
8207
8279
|
});
|
|
8208
8280
|
}); };
|
|
8209
8281
|
this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8210
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction,
|
|
8282
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_66;
|
|
8211
8283
|
return __generator(this, function (_a) {
|
|
8212
8284
|
switch (_a.label) {
|
|
8213
8285
|
case 0:
|
|
@@ -8240,9 +8312,9 @@ var PerpetualsClient = (function () {
|
|
|
8240
8312
|
instructions.push(createWhitelistInstruction);
|
|
8241
8313
|
return [3, 4];
|
|
8242
8314
|
case 3:
|
|
8243
|
-
|
|
8244
|
-
console.log("perpClient createWhitelistInstruction error:: ",
|
|
8245
|
-
throw
|
|
8315
|
+
err_66 = _a.sent();
|
|
8316
|
+
console.log("perpClient createWhitelistInstruction error:: ", err_66);
|
|
8317
|
+
throw err_66;
|
|
8246
8318
|
case 4: return [2, {
|
|
8247
8319
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8248
8320
|
additionalSigners: additionalSigners
|
|
@@ -8251,7 +8323,7 @@ var PerpetualsClient = (function () {
|
|
|
8251
8323
|
});
|
|
8252
8324
|
}); };
|
|
8253
8325
|
this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8254
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction,
|
|
8326
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_67;
|
|
8255
8327
|
return __generator(this, function (_a) {
|
|
8256
8328
|
switch (_a.label) {
|
|
8257
8329
|
case 0:
|
|
@@ -8284,9 +8356,9 @@ var PerpetualsClient = (function () {
|
|
|
8284
8356
|
instructions.push(setWhitelistConfigInstruction);
|
|
8285
8357
|
return [3, 4];
|
|
8286
8358
|
case 3:
|
|
8287
|
-
|
|
8288
|
-
console.log("perpClient setWhitelistConfigInstruction error:: ",
|
|
8289
|
-
throw
|
|
8359
|
+
err_67 = _a.sent();
|
|
8360
|
+
console.log("perpClient setWhitelistConfigInstruction error:: ", err_67);
|
|
8361
|
+
throw err_67;
|
|
8290
8362
|
case 4: return [2, {
|
|
8291
8363
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8292
8364
|
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
|
-
|
|
24
|
+
oraclePenalty: number;
|
|
25
|
+
previousPenalty: number;
|
|
25
26
|
sizeDecimals: number;
|
|
26
27
|
lockedDecimals: number;
|
|
27
28
|
collateralDecimals: number;
|