flash-sdk 11.8.0 → 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 +169 -73
- 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;
|
|
@@ -1631,8 +1633,14 @@ var PerpetualsClient = (function () {
|
|
|
1631
1633
|
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1632
1634
|
}
|
|
1633
1635
|
else {
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
+
if (positionAccount.referencePrice.price.gt(positionEntryPrice.price)) {
|
|
1637
|
+
priceDiffProfit = new OraclePrice_1.OraclePrice({ price: positionAccount.referencePrice.price.sub(positionEntryPrice.price), exponent: positionEntryPrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1638
|
+
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1639
|
+
}
|
|
1640
|
+
else {
|
|
1641
|
+
priceDiffProfit = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1642
|
+
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1643
|
+
}
|
|
1636
1644
|
}
|
|
1637
1645
|
}
|
|
1638
1646
|
else {
|
|
@@ -1647,8 +1655,14 @@ var PerpetualsClient = (function () {
|
|
|
1647
1655
|
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1648
1656
|
}
|
|
1649
1657
|
else {
|
|
1650
|
-
|
|
1651
|
-
|
|
1658
|
+
if (positionEntryPrice.price.gt(positionAccount.referencePrice.price)) {
|
|
1659
|
+
priceDiffProfit = new OraclePrice_1.OraclePrice({ price: positionEntryPrice.price.sub(positionAccount.referencePrice.price), exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1660
|
+
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1661
|
+
}
|
|
1662
|
+
else {
|
|
1663
|
+
priceDiffProfit = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1664
|
+
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1665
|
+
}
|
|
1652
1666
|
}
|
|
1653
1667
|
}
|
|
1654
1668
|
else {
|
|
@@ -1660,16 +1674,34 @@ var PerpetualsClient = (function () {
|
|
|
1660
1674
|
if (!priceDiffProfit.exponent.eq(priceDiffLoss.exponent)) {
|
|
1661
1675
|
throw new Error("exponent mistach");
|
|
1662
1676
|
}
|
|
1677
|
+
var totalPenaltyBps = positionAccount.oraclePenalty + positionAccount.previousPenalty;
|
|
1663
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
|
+
}
|
|
1664
1692
|
return {
|
|
1665
|
-
profitUsd:
|
|
1693
|
+
profitUsd: grossProfitUsd,
|
|
1666
1694
|
lossUsd: constants_1.BN_ZERO,
|
|
1695
|
+
penaltyUsd: penaltyUsd,
|
|
1696
|
+
finalProfitUsd: finalProfitUsd,
|
|
1667
1697
|
};
|
|
1668
1698
|
}
|
|
1669
1699
|
else {
|
|
1670
1700
|
return {
|
|
1671
1701
|
profitUsd: constants_1.BN_ZERO,
|
|
1672
1702
|
lossUsd: priceDiffLoss.getAssetAmountUsd(positionAccount.sizeAmount, positionAccount.sizeDecimals),
|
|
1703
|
+
penaltyUsd: constants_1.BN_ZERO,
|
|
1704
|
+
finalProfitUsd: constants_1.BN_ZERO,
|
|
1673
1705
|
};
|
|
1674
1706
|
}
|
|
1675
1707
|
};
|
|
@@ -1711,8 +1743,14 @@ var PerpetualsClient = (function () {
|
|
|
1711
1743
|
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1712
1744
|
}
|
|
1713
1745
|
else {
|
|
1714
|
-
|
|
1715
|
-
|
|
1746
|
+
if (positionAccount.referencePrice.price.gt(entryOraclePrice.price)) {
|
|
1747
|
+
priceDiffProfit = new OraclePrice_1.OraclePrice({ price: positionAccount.referencePrice.price.sub(entryOraclePrice.price), exponent: entryOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1748
|
+
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1749
|
+
}
|
|
1750
|
+
else {
|
|
1751
|
+
priceDiffProfit = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1752
|
+
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1753
|
+
}
|
|
1716
1754
|
}
|
|
1717
1755
|
}
|
|
1718
1756
|
else {
|
|
@@ -1727,8 +1765,14 @@ var PerpetualsClient = (function () {
|
|
|
1727
1765
|
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1728
1766
|
}
|
|
1729
1767
|
else {
|
|
1730
|
-
|
|
1731
|
-
|
|
1768
|
+
if (entryOraclePrice.price.gt(positionAccount.referencePrice.price)) {
|
|
1769
|
+
priceDiffProfit = new OraclePrice_1.OraclePrice({ price: entryOraclePrice.price.sub(positionAccount.referencePrice.price), exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1770
|
+
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1771
|
+
}
|
|
1772
|
+
else {
|
|
1773
|
+
priceDiffProfit = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1774
|
+
priceDiffLoss = new OraclePrice_1.OraclePrice({ price: constants_1.BN_ZERO, exponent: exitOraclePrice.exponent, confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
|
|
1775
|
+
}
|
|
1732
1776
|
}
|
|
1733
1777
|
}
|
|
1734
1778
|
else {
|
|
@@ -1736,22 +1780,40 @@ var PerpetualsClient = (function () {
|
|
|
1736
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 });
|
|
1737
1781
|
}
|
|
1738
1782
|
}
|
|
1783
|
+
var totalPenaltyBps = positionAccount.oraclePenalty + positionAccount.previousPenalty;
|
|
1739
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
|
+
}
|
|
1740
1798
|
pnl = {
|
|
1741
|
-
profitUsd:
|
|
1799
|
+
profitUsd: grossProfitUsd,
|
|
1742
1800
|
lossUsd: constants_1.BN_ZERO,
|
|
1801
|
+
penaltyUsd: penaltyUsd,
|
|
1802
|
+
finalProfitUsd: finalProfitUsd,
|
|
1743
1803
|
};
|
|
1744
1804
|
}
|
|
1745
1805
|
else {
|
|
1746
1806
|
pnl = {
|
|
1747
1807
|
profitUsd: constants_1.BN_ZERO,
|
|
1748
1808
|
lossUsd: priceDiffLoss.getAssetAmountUsd(positionAccount.sizeAmount, positionAccount.sizeDecimals),
|
|
1809
|
+
penaltyUsd: constants_1.BN_ZERO,
|
|
1810
|
+
finalProfitUsd: constants_1.BN_ZERO,
|
|
1749
1811
|
};
|
|
1750
1812
|
}
|
|
1751
1813
|
var liquidationPrice = _this.getLiquidationPriceContractHelper(entryOraclePrice, lockAndUnsettledFeeUsd, side, targetCustodyAccount, positionAccount);
|
|
1752
1814
|
var unsettledFeesUsd = exitFeeUsd.add(lockAndUnsettledFeeUsd);
|
|
1753
1815
|
var lossUsd = pnl.lossUsd.add(unsettledFeesUsd);
|
|
1754
|
-
var currentMarginUsd = positionAccount.collateralUsd.add(pnl.
|
|
1816
|
+
var currentMarginUsd = positionAccount.collateralUsd.add(pnl.finalProfitUsd).sub(lossUsd);
|
|
1755
1817
|
var leverage;
|
|
1756
1818
|
if (currentMarginUsd.gt(constants_1.BN_ZERO)) {
|
|
1757
1819
|
leverage = positionAccount.sizeUsd.mul(new anchor_1.BN(constants_1.BPS_POWER)).div(currentMarginUsd);
|
|
@@ -7569,8 +7631,42 @@ var PerpetualsClient = (function () {
|
|
|
7569
7631
|
}
|
|
7570
7632
|
});
|
|
7571
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
|
+
}); };
|
|
7572
7668
|
this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7573
|
-
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp,
|
|
7669
|
+
var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_53;
|
|
7574
7670
|
return __generator(this, function (_a) {
|
|
7575
7671
|
switch (_a.label) {
|
|
7576
7672
|
case 0:
|
|
@@ -7608,8 +7704,8 @@ var PerpetualsClient = (function () {
|
|
|
7608
7704
|
instructions.push(renameFlp);
|
|
7609
7705
|
return [3, 4];
|
|
7610
7706
|
case 3:
|
|
7611
|
-
|
|
7612
|
-
console.log("perpClient renameFlp error:: ",
|
|
7707
|
+
err_53 = _a.sent();
|
|
7708
|
+
console.log("perpClient renameFlp error:: ", err_53);
|
|
7613
7709
|
return [3, 4];
|
|
7614
7710
|
case 4: return [2, {
|
|
7615
7711
|
instructions: __spreadArray([], instructions, true),
|
|
@@ -7619,7 +7715,7 @@ var PerpetualsClient = (function () {
|
|
|
7619
7715
|
});
|
|
7620
7716
|
}); };
|
|
7621
7717
|
this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7622
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction,
|
|
7718
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_54;
|
|
7623
7719
|
return __generator(this, function (_a) {
|
|
7624
7720
|
switch (_a.label) {
|
|
7625
7721
|
case 0:
|
|
@@ -7657,9 +7753,9 @@ var PerpetualsClient = (function () {
|
|
|
7657
7753
|
instructions.push(initStakeInstruction);
|
|
7658
7754
|
return [3, 4];
|
|
7659
7755
|
case 3:
|
|
7660
|
-
|
|
7661
|
-
console.log("perpClient InitStaking error:: ",
|
|
7662
|
-
throw
|
|
7756
|
+
err_54 = _a.sent();
|
|
7757
|
+
console.log("perpClient InitStaking error:: ", err_54);
|
|
7758
|
+
throw err_54;
|
|
7663
7759
|
case 4: return [2, {
|
|
7664
7760
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7665
7761
|
additionalSigners: additionalSigners
|
|
@@ -7668,7 +7764,7 @@ var PerpetualsClient = (function () {
|
|
|
7668
7764
|
});
|
|
7669
7765
|
}); };
|
|
7670
7766
|
this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7671
|
-
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;
|
|
7672
7768
|
return __generator(this, function (_a) {
|
|
7673
7769
|
switch (_a.label) {
|
|
7674
7770
|
case 0:
|
|
@@ -7712,9 +7808,9 @@ var PerpetualsClient = (function () {
|
|
|
7712
7808
|
instructions.push(initCompoundingInstruction);
|
|
7713
7809
|
return [3, 4];
|
|
7714
7810
|
case 3:
|
|
7715
|
-
|
|
7716
|
-
console.log("perpClient initCompounding error:: ",
|
|
7717
|
-
throw
|
|
7811
|
+
err_55 = _a.sent();
|
|
7812
|
+
console.log("perpClient initCompounding error:: ", err_55);
|
|
7813
|
+
throw err_55;
|
|
7718
7814
|
case 4: return [2, {
|
|
7719
7815
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7720
7816
|
additionalSigners: additionalSigners
|
|
@@ -7723,7 +7819,7 @@ var PerpetualsClient = (function () {
|
|
|
7723
7819
|
});
|
|
7724
7820
|
}); };
|
|
7725
7821
|
this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7726
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction,
|
|
7822
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_56;
|
|
7727
7823
|
return __generator(this, function (_a) {
|
|
7728
7824
|
switch (_a.label) {
|
|
7729
7825
|
case 0:
|
|
@@ -7764,9 +7860,9 @@ var PerpetualsClient = (function () {
|
|
|
7764
7860
|
instructions.push(initTokenVaultInstruction);
|
|
7765
7861
|
return [3, 4];
|
|
7766
7862
|
case 3:
|
|
7767
|
-
|
|
7768
|
-
console.log("perpClient InitTokenVaultInstruction error:: ",
|
|
7769
|
-
throw
|
|
7863
|
+
err_56 = _a.sent();
|
|
7864
|
+
console.log("perpClient InitTokenVaultInstruction error:: ", err_56);
|
|
7865
|
+
throw err_56;
|
|
7770
7866
|
case 4: return [2, {
|
|
7771
7867
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7772
7868
|
additionalSigners: additionalSigners
|
|
@@ -7775,7 +7871,7 @@ var PerpetualsClient = (function () {
|
|
|
7775
7871
|
});
|
|
7776
7872
|
}); };
|
|
7777
7873
|
this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7778
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction,
|
|
7874
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_57;
|
|
7779
7875
|
return __generator(this, function (_a) {
|
|
7780
7876
|
switch (_a.label) {
|
|
7781
7877
|
case 0:
|
|
@@ -7806,9 +7902,9 @@ var PerpetualsClient = (function () {
|
|
|
7806
7902
|
instructions.push(setTokenVaultConfigInstruction);
|
|
7807
7903
|
return [3, 4];
|
|
7808
7904
|
case 3:
|
|
7809
|
-
|
|
7810
|
-
console.log("perpClient setTokenVaultConfigInstruction error:: ",
|
|
7811
|
-
throw
|
|
7905
|
+
err_57 = _a.sent();
|
|
7906
|
+
console.log("perpClient setTokenVaultConfigInstruction error:: ", err_57);
|
|
7907
|
+
throw err_57;
|
|
7812
7908
|
case 4: return [2, {
|
|
7813
7909
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7814
7910
|
additionalSigners: additionalSigners
|
|
@@ -7817,7 +7913,7 @@ var PerpetualsClient = (function () {
|
|
|
7817
7913
|
});
|
|
7818
7914
|
}); };
|
|
7819
7915
|
this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7820
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction,
|
|
7916
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_58;
|
|
7821
7917
|
return __generator(this, function (_a) {
|
|
7822
7918
|
switch (_a.label) {
|
|
7823
7919
|
case 0:
|
|
@@ -7856,9 +7952,9 @@ var PerpetualsClient = (function () {
|
|
|
7856
7952
|
instructions.push(withdrawInstantFeeInstruction);
|
|
7857
7953
|
return [3, 6];
|
|
7858
7954
|
case 5:
|
|
7859
|
-
|
|
7860
|
-
console.log("perpClient withdrawInstantFeeInstruction error:: ",
|
|
7861
|
-
throw
|
|
7955
|
+
err_58 = _a.sent();
|
|
7956
|
+
console.log("perpClient withdrawInstantFeeInstruction error:: ", err_58);
|
|
7957
|
+
throw err_58;
|
|
7862
7958
|
case 6: return [2, {
|
|
7863
7959
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7864
7960
|
additionalSigners: additionalSigners
|
|
@@ -7867,7 +7963,7 @@ var PerpetualsClient = (function () {
|
|
|
7867
7963
|
});
|
|
7868
7964
|
}); };
|
|
7869
7965
|
this.withdrawUnclaimedTokens = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7870
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction,
|
|
7966
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction, err_59;
|
|
7871
7967
|
return __generator(this, function (_a) {
|
|
7872
7968
|
switch (_a.label) {
|
|
7873
7969
|
case 0:
|
|
@@ -7906,9 +8002,9 @@ var PerpetualsClient = (function () {
|
|
|
7906
8002
|
instructions.push(withdrawUnclaimedTokensInstruction);
|
|
7907
8003
|
return [3, 6];
|
|
7908
8004
|
case 5:
|
|
7909
|
-
|
|
7910
|
-
console.log("perpClient withdrawUnclaimedTokensInstruction error:: ",
|
|
7911
|
-
throw
|
|
8005
|
+
err_59 = _a.sent();
|
|
8006
|
+
console.log("perpClient withdrawUnclaimedTokensInstruction error:: ", err_59);
|
|
8007
|
+
throw err_59;
|
|
7912
8008
|
case 6: return [2, {
|
|
7913
8009
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7914
8010
|
additionalSigners: additionalSigners
|
|
@@ -7917,7 +8013,7 @@ var PerpetualsClient = (function () {
|
|
|
7917
8013
|
});
|
|
7918
8014
|
}); };
|
|
7919
8015
|
this.initRevenueTokenAccount = function (feeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7920
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction,
|
|
8016
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_60;
|
|
7921
8017
|
return __generator(this, function (_a) {
|
|
7922
8018
|
switch (_a.label) {
|
|
7923
8019
|
case 0:
|
|
@@ -7954,9 +8050,9 @@ var PerpetualsClient = (function () {
|
|
|
7954
8050
|
instructions.push(initRevenueTokenAccountInstruction);
|
|
7955
8051
|
return [3, 4];
|
|
7956
8052
|
case 3:
|
|
7957
|
-
|
|
7958
|
-
console.log("perpClient initRevenueTokenAccountInstruction error:: ",
|
|
7959
|
-
throw
|
|
8053
|
+
err_60 = _a.sent();
|
|
8054
|
+
console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_60);
|
|
8055
|
+
throw err_60;
|
|
7960
8056
|
case 4: return [2, {
|
|
7961
8057
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
7962
8058
|
additionalSigners: additionalSigners
|
|
@@ -7965,7 +8061,7 @@ var PerpetualsClient = (function () {
|
|
|
7965
8061
|
});
|
|
7966
8062
|
}); };
|
|
7967
8063
|
this.initRebateVault = function (allowRebatePayout, rebateSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
7968
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction,
|
|
8064
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction, err_61;
|
|
7969
8065
|
return __generator(this, function (_a) {
|
|
7970
8066
|
switch (_a.label) {
|
|
7971
8067
|
case 0:
|
|
@@ -8000,9 +8096,9 @@ var PerpetualsClient = (function () {
|
|
|
8000
8096
|
instructions.push(initRebateVaultInstruction);
|
|
8001
8097
|
return [3, 4];
|
|
8002
8098
|
case 3:
|
|
8003
|
-
|
|
8004
|
-
console.log("perpClient initRebateVaultInstruction error:: ",
|
|
8005
|
-
throw
|
|
8099
|
+
err_61 = _a.sent();
|
|
8100
|
+
console.log("perpClient initRebateVaultInstruction error:: ", err_61);
|
|
8101
|
+
throw err_61;
|
|
8006
8102
|
case 4: return [2, {
|
|
8007
8103
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8008
8104
|
additionalSigners: additionalSigners
|
|
@@ -8011,7 +8107,7 @@ var PerpetualsClient = (function () {
|
|
|
8011
8107
|
});
|
|
8012
8108
|
}); };
|
|
8013
8109
|
this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
8014
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction,
|
|
8110
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_62;
|
|
8015
8111
|
return __generator(this, function (_a) {
|
|
8016
8112
|
switch (_a.label) {
|
|
8017
8113
|
case 0:
|
|
@@ -8050,9 +8146,9 @@ var PerpetualsClient = (function () {
|
|
|
8050
8146
|
instructions.push(distributeTokenRewardInstruction);
|
|
8051
8147
|
return [3, 4];
|
|
8052
8148
|
case 3:
|
|
8053
|
-
|
|
8054
|
-
console.log("perpClient distributeTokenRewardInstruction error:: ",
|
|
8055
|
-
throw
|
|
8149
|
+
err_62 = _a.sent();
|
|
8150
|
+
console.log("perpClient distributeTokenRewardInstruction error:: ", err_62);
|
|
8151
|
+
throw err_62;
|
|
8056
8152
|
case 4: return [2, {
|
|
8057
8153
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8058
8154
|
additionalSigners: additionalSigners
|
|
@@ -8061,7 +8157,7 @@ var PerpetualsClient = (function () {
|
|
|
8061
8157
|
});
|
|
8062
8158
|
}); };
|
|
8063
8159
|
this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
|
|
8064
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction,
|
|
8160
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_63;
|
|
8065
8161
|
return __generator(this, function (_a) {
|
|
8066
8162
|
switch (_a.label) {
|
|
8067
8163
|
case 0:
|
|
@@ -8089,9 +8185,9 @@ var PerpetualsClient = (function () {
|
|
|
8089
8185
|
instructions.push(setTokenStakeLevelInstruction);
|
|
8090
8186
|
return [3, 4];
|
|
8091
8187
|
case 3:
|
|
8092
|
-
|
|
8093
|
-
console.log("perpClient setTokenStakeLevelInstruction error:: ",
|
|
8094
|
-
throw
|
|
8188
|
+
err_63 = _a.sent();
|
|
8189
|
+
console.log("perpClient setTokenStakeLevelInstruction error:: ", err_63);
|
|
8190
|
+
throw err_63;
|
|
8095
8191
|
case 4: return [2, {
|
|
8096
8192
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8097
8193
|
additionalSigners: additionalSigners
|
|
@@ -8100,7 +8196,7 @@ var PerpetualsClient = (function () {
|
|
|
8100
8196
|
});
|
|
8101
8197
|
}); };
|
|
8102
8198
|
this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
8103
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction,
|
|
8199
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_64;
|
|
8104
8200
|
return __generator(this, function (_a) {
|
|
8105
8201
|
switch (_a.label) {
|
|
8106
8202
|
case 0:
|
|
@@ -8132,9 +8228,9 @@ var PerpetualsClient = (function () {
|
|
|
8132
8228
|
instructions.push(setTokenRewardInstruction);
|
|
8133
8229
|
return [3, 4];
|
|
8134
8230
|
case 3:
|
|
8135
|
-
|
|
8136
|
-
console.log("perpClient setTokenRewardInstruction error:: ",
|
|
8137
|
-
throw
|
|
8231
|
+
err_64 = _a.sent();
|
|
8232
|
+
console.log("perpClient setTokenRewardInstruction error:: ", err_64);
|
|
8233
|
+
throw err_64;
|
|
8138
8234
|
case 4: return [2, {
|
|
8139
8235
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8140
8236
|
additionalSigners: additionalSigners
|
|
@@ -8143,7 +8239,7 @@ var PerpetualsClient = (function () {
|
|
|
8143
8239
|
});
|
|
8144
8240
|
}); };
|
|
8145
8241
|
this.resizeInternalOracle = function (extOracle, tokenMint, intOracleAccount) { return __awaiter(_this, void 0, void 0, function () {
|
|
8146
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction,
|
|
8242
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_65;
|
|
8147
8243
|
return __generator(this, function (_a) {
|
|
8148
8244
|
switch (_a.label) {
|
|
8149
8245
|
case 0:
|
|
@@ -8172,9 +8268,9 @@ var PerpetualsClient = (function () {
|
|
|
8172
8268
|
instructions.push(resizeInternalOracleInstruction);
|
|
8173
8269
|
return [3, 4];
|
|
8174
8270
|
case 3:
|
|
8175
|
-
|
|
8176
|
-
console.log("perpClient resizeInternalOracleInstruction error:: ",
|
|
8177
|
-
throw
|
|
8271
|
+
err_65 = _a.sent();
|
|
8272
|
+
console.log("perpClient resizeInternalOracleInstruction error:: ", err_65);
|
|
8273
|
+
throw err_65;
|
|
8178
8274
|
case 4: return [2, {
|
|
8179
8275
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8180
8276
|
additionalSigners: additionalSigners
|
|
@@ -8183,7 +8279,7 @@ var PerpetualsClient = (function () {
|
|
|
8183
8279
|
});
|
|
8184
8280
|
}); };
|
|
8185
8281
|
this.createWhitelist = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8186
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction,
|
|
8282
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, createWhitelistInstruction, err_66;
|
|
8187
8283
|
return __generator(this, function (_a) {
|
|
8188
8284
|
switch (_a.label) {
|
|
8189
8285
|
case 0:
|
|
@@ -8216,9 +8312,9 @@ var PerpetualsClient = (function () {
|
|
|
8216
8312
|
instructions.push(createWhitelistInstruction);
|
|
8217
8313
|
return [3, 4];
|
|
8218
8314
|
case 3:
|
|
8219
|
-
|
|
8220
|
-
console.log("perpClient createWhitelistInstruction error:: ",
|
|
8221
|
-
throw
|
|
8315
|
+
err_66 = _a.sent();
|
|
8316
|
+
console.log("perpClient createWhitelistInstruction error:: ", err_66);
|
|
8317
|
+
throw err_66;
|
|
8222
8318
|
case 4: return [2, {
|
|
8223
8319
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8224
8320
|
additionalSigners: additionalSigners
|
|
@@ -8227,7 +8323,7 @@ var PerpetualsClient = (function () {
|
|
|
8227
8323
|
});
|
|
8228
8324
|
}); };
|
|
8229
8325
|
this.setWhitelistConfig = function (isSwapFeeExempt, isDepositFeeExempt, isWithdrawalFeeExempt, poolAddress, owner) { return __awaiter(_this, void 0, void 0, function () {
|
|
8230
|
-
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction,
|
|
8326
|
+
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, whitelist, setWhitelistConfigInstruction, err_67;
|
|
8231
8327
|
return __generator(this, function (_a) {
|
|
8232
8328
|
switch (_a.label) {
|
|
8233
8329
|
case 0:
|
|
@@ -8260,9 +8356,9 @@ var PerpetualsClient = (function () {
|
|
|
8260
8356
|
instructions.push(setWhitelistConfigInstruction);
|
|
8261
8357
|
return [3, 4];
|
|
8262
8358
|
case 3:
|
|
8263
|
-
|
|
8264
|
-
console.log("perpClient setWhitelistConfigInstruction error:: ",
|
|
8265
|
-
throw
|
|
8359
|
+
err_67 = _a.sent();
|
|
8360
|
+
console.log("perpClient setWhitelistConfigInstruction error:: ", err_67);
|
|
8361
|
+
throw err_67;
|
|
8266
8362
|
case 4: return [2, {
|
|
8267
8363
|
instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
|
|
8268
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;
|