@drift-labs/sdk 2.31.1-beta.20 → 2.31.1-beta.21
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/VERSION +1 -1
- package/lib/idl/drift.json +1 -1
- package/lib/math/superStake.d.ts +1 -0
- package/lib/math/superStake.js +9 -1
- package/package.json +1 -1
- package/src/idl/drift.json +1 -1
- package/src/math/superStake.ts +15 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.31.1-beta.
|
|
1
|
+
2.31.1-beta.21
|
package/lib/idl/drift.json
CHANGED
package/lib/math/superStake.d.ts
CHANGED
|
@@ -19,3 +19,4 @@ export declare function calculateSolEarned({ user, depositRecords, }: {
|
|
|
19
19
|
user: User;
|
|
20
20
|
depositRecords: DepositRecord[];
|
|
21
21
|
}): Promise<BN>;
|
|
22
|
+
export declare function calculateEstimatedSuperStakeLiquidationPrice(msolDepositAmount: number, msolMaintenanceAssetWeight: number, solBorrowAmount: number, solMaintenanceLiabilityWeight: number, msolPriceRatio: number): number;
|
package/lib/math/superStake.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.calculateSolEarned = exports.findBestSuperStakeIxs = void 0;
|
|
6
|
+
exports.calculateEstimatedSuperStakeLiquidationPrice = exports.calculateSolEarned = exports.findBestSuperStakeIxs = void 0;
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
8
|
const marinade_1 = require("../marinade");
|
|
9
9
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
@@ -98,3 +98,11 @@ async function calculateSolEarned({ user, depositRecords, }) {
|
|
|
98
98
|
return solEarned;
|
|
99
99
|
}
|
|
100
100
|
exports.calculateSolEarned = calculateSolEarned;
|
|
101
|
+
// calculate estimated liquidation price (in mSOL/SOL) based on target amounts
|
|
102
|
+
function calculateEstimatedSuperStakeLiquidationPrice(msolDepositAmount, msolMaintenanceAssetWeight, solBorrowAmount, solMaintenanceLiabilityWeight, msolPriceRatio) {
|
|
103
|
+
const liquidationDivergence = (solMaintenanceLiabilityWeight * solBorrowAmount) /
|
|
104
|
+
(msolMaintenanceAssetWeight * msolDepositAmount * msolPriceRatio);
|
|
105
|
+
const liquidationPrice = msolPriceRatio * liquidationDivergence;
|
|
106
|
+
return liquidationPrice;
|
|
107
|
+
}
|
|
108
|
+
exports.calculateEstimatedSuperStakeLiquidationPrice = calculateEstimatedSuperStakeLiquidationPrice;
|
package/package.json
CHANGED
package/src/idl/drift.json
CHANGED
package/src/math/superStake.ts
CHANGED
|
@@ -131,3 +131,18 @@ export async function calculateSolEarned({
|
|
|
131
131
|
|
|
132
132
|
return solEarned;
|
|
133
133
|
}
|
|
134
|
+
|
|
135
|
+
// calculate estimated liquidation price (in mSOL/SOL) based on target amounts
|
|
136
|
+
export function calculateEstimatedSuperStakeLiquidationPrice(
|
|
137
|
+
msolDepositAmount: number,
|
|
138
|
+
msolMaintenanceAssetWeight: number,
|
|
139
|
+
solBorrowAmount: number,
|
|
140
|
+
solMaintenanceLiabilityWeight: number,
|
|
141
|
+
msolPriceRatio: number
|
|
142
|
+
): number {
|
|
143
|
+
const liquidationDivergence =
|
|
144
|
+
(solMaintenanceLiabilityWeight * solBorrowAmount) /
|
|
145
|
+
(msolMaintenanceAssetWeight * msolDepositAmount * msolPriceRatio);
|
|
146
|
+
const liquidationPrice = msolPriceRatio * liquidationDivergence;
|
|
147
|
+
return liquidationPrice;
|
|
148
|
+
}
|