@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 CHANGED
@@ -1 +1 @@
1
- 2.31.1-beta.20
1
+ 2.31.1-beta.21
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.31.1-beta.19",
2
+ "version": "2.31.1-beta.20",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -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;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.31.1-beta.20",
3
+ "version": "2.31.1-beta.21",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.31.1-beta.20",
2
+ "version": "2.31.1-beta.21",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -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
+ }