@drift-labs/sdk 2.108.0-beta.12 → 2.108.0-beta.14
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/browser/constants/spotMarkets.js +12 -0
- package/lib/browser/math/market.d.ts +1 -0
- package/lib/browser/math/market.js +12 -1
- package/lib/node/constants/spotMarkets.js +12 -0
- package/lib/node/math/market.d.ts +1 -0
- package/lib/node/math/market.js +12 -1
- package/package.json +1 -1
- package/src/constants/spotMarkets.ts +13 -0
- package/src/math/market.ts +16 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.108.0-beta.
|
|
1
|
+
2.108.0-beta.14
|
|
@@ -568,6 +568,18 @@ exports.MainnetSpotMarkets = [
|
|
|
568
568
|
pythFeedId: '0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
569
569
|
launchTs: 1737360280000,
|
|
570
570
|
},
|
|
571
|
+
{
|
|
572
|
+
symbol: 'AUSD',
|
|
573
|
+
marketIndex: 38,
|
|
574
|
+
poolId: 0,
|
|
575
|
+
oracle: new web3_js_1.PublicKey('8FZhpiM8n3mpgvENWLcEvHsKB1bBhYBAyL4Ypr4gptLZ'),
|
|
576
|
+
oracleSource: __1.OracleSource.PYTH_STABLE_COIN_PULL,
|
|
577
|
+
mint: new web3_js_1.PublicKey('AUSD1jCcCyPLybk1YnvPWsHQSrZ46dxwoMniN4N2UEB9'),
|
|
578
|
+
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
579
|
+
precisionExp: numericConstants_1.SIX,
|
|
580
|
+
pythFeedId: '0xd9912df360b5b7f21a122f15bdd5e27f62ce5e72bd316c291f7c86620e07fb2a',
|
|
581
|
+
launchTs: 1738255943000,
|
|
582
|
+
},
|
|
571
583
|
];
|
|
572
584
|
exports.SpotMarkets = {
|
|
573
585
|
devnet: exports.DevnetSpotMarkets,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateAvailablePerpLiquidity = exports.calculateNetUserPnlImbalance = exports.calculateNetUserPnl = exports.calculateMarketMaxAvailableInsurance = exports.calculateMarketAvailablePNL = exports.calculateUnrealizedAssetWeight = exports.calculateMarketMarginRatio = exports.calculateOracleSpread = exports.calculateOracleReserveSpread = exports.calculateNewMarketAfterTrade = exports.calculateAskPrice = exports.calculateBidPrice = exports.calculateReservePrice = void 0;
|
|
3
|
+
exports.calculatePerpMarketBaseLiquidatorFee = exports.calculateAvailablePerpLiquidity = exports.calculateNetUserPnlImbalance = exports.calculateNetUserPnl = exports.calculateMarketMaxAvailableInsurance = exports.calculateMarketAvailablePNL = exports.calculateUnrealizedAssetWeight = exports.calculateMarketMarginRatio = exports.calculateOracleSpread = exports.calculateOracleReserveSpread = exports.calculateNewMarketAfterTrade = exports.calculateAskPrice = exports.calculateBidPrice = exports.calculateReservePrice = void 0;
|
|
4
4
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const amm_1 = require("./amm");
|
|
@@ -161,3 +161,14 @@ function calculateAvailablePerpLiquidity(market, oraclePriceData, dlob, slot) {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
exports.calculateAvailablePerpLiquidity = calculateAvailablePerpLiquidity;
|
|
164
|
+
function calculatePerpMarketBaseLiquidatorFee(market, userHighLeverageMode) {
|
|
165
|
+
if (userHighLeverageMode && market.highLeverageMarginRatioMaintenance > 0) {
|
|
166
|
+
// min(liquidator_fee, .8 * high_leverage_margin_ratio_maintenance)
|
|
167
|
+
return Math.min(market.liquidatorFee, market.highLeverageMarginRatioMaintenance -
|
|
168
|
+
Math.floor(market.highLeverageMarginRatioMaintenance / 5));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return market.liquidatorFee;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.calculatePerpMarketBaseLiquidatorFee = calculatePerpMarketBaseLiquidatorFee;
|
|
@@ -568,6 +568,18 @@ exports.MainnetSpotMarkets = [
|
|
|
568
568
|
pythFeedId: '0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
569
569
|
launchTs: 1737360280000,
|
|
570
570
|
},
|
|
571
|
+
{
|
|
572
|
+
symbol: 'AUSD',
|
|
573
|
+
marketIndex: 38,
|
|
574
|
+
poolId: 0,
|
|
575
|
+
oracle: new web3_js_1.PublicKey('8FZhpiM8n3mpgvENWLcEvHsKB1bBhYBAyL4Ypr4gptLZ'),
|
|
576
|
+
oracleSource: __1.OracleSource.PYTH_STABLE_COIN_PULL,
|
|
577
|
+
mint: new web3_js_1.PublicKey('AUSD1jCcCyPLybk1YnvPWsHQSrZ46dxwoMniN4N2UEB9'),
|
|
578
|
+
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
579
|
+
precisionExp: numericConstants_1.SIX,
|
|
580
|
+
pythFeedId: '0xd9912df360b5b7f21a122f15bdd5e27f62ce5e72bd316c291f7c86620e07fb2a',
|
|
581
|
+
launchTs: 1738255943000,
|
|
582
|
+
},
|
|
571
583
|
];
|
|
572
584
|
exports.SpotMarkets = {
|
|
573
585
|
devnet: exports.DevnetSpotMarkets,
|
package/lib/node/math/market.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateAvailablePerpLiquidity = exports.calculateNetUserPnlImbalance = exports.calculateNetUserPnl = exports.calculateMarketMaxAvailableInsurance = exports.calculateMarketAvailablePNL = exports.calculateUnrealizedAssetWeight = exports.calculateMarketMarginRatio = exports.calculateOracleSpread = exports.calculateOracleReserveSpread = exports.calculateNewMarketAfterTrade = exports.calculateAskPrice = exports.calculateBidPrice = exports.calculateReservePrice = void 0;
|
|
3
|
+
exports.calculatePerpMarketBaseLiquidatorFee = exports.calculateAvailablePerpLiquidity = exports.calculateNetUserPnlImbalance = exports.calculateNetUserPnl = exports.calculateMarketMaxAvailableInsurance = exports.calculateMarketAvailablePNL = exports.calculateUnrealizedAssetWeight = exports.calculateMarketMarginRatio = exports.calculateOracleSpread = exports.calculateOracleReserveSpread = exports.calculateNewMarketAfterTrade = exports.calculateAskPrice = exports.calculateBidPrice = exports.calculateReservePrice = void 0;
|
|
4
4
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const amm_1 = require("./amm");
|
|
@@ -161,3 +161,14 @@ function calculateAvailablePerpLiquidity(market, oraclePriceData, dlob, slot) {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
exports.calculateAvailablePerpLiquidity = calculateAvailablePerpLiquidity;
|
|
164
|
+
function calculatePerpMarketBaseLiquidatorFee(market, userHighLeverageMode) {
|
|
165
|
+
if (userHighLeverageMode && market.highLeverageMarginRatioMaintenance > 0) {
|
|
166
|
+
// min(liquidator_fee, .8 * high_leverage_margin_ratio_maintenance)
|
|
167
|
+
return Math.min(market.liquidatorFee, market.highLeverageMarginRatioMaintenance -
|
|
168
|
+
Math.floor(market.highLeverageMarginRatioMaintenance / 5));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return market.liquidatorFee;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.calculatePerpMarketBaseLiquidatorFee = calculatePerpMarketBaseLiquidatorFee;
|
package/package.json
CHANGED
|
@@ -673,6 +673,19 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
|
|
|
673
673
|
'0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
674
674
|
launchTs: 1737360280000,
|
|
675
675
|
},
|
|
676
|
+
{
|
|
677
|
+
symbol: 'AUSD',
|
|
678
|
+
marketIndex: 38,
|
|
679
|
+
poolId: 0,
|
|
680
|
+
oracle: new PublicKey('8FZhpiM8n3mpgvENWLcEvHsKB1bBhYBAyL4Ypr4gptLZ'),
|
|
681
|
+
oracleSource: OracleSource.PYTH_STABLE_COIN_PULL,
|
|
682
|
+
mint: new PublicKey('AUSD1jCcCyPLybk1YnvPWsHQSrZ46dxwoMniN4N2UEB9'),
|
|
683
|
+
precision: new BN(10).pow(SIX),
|
|
684
|
+
precisionExp: SIX,
|
|
685
|
+
pythFeedId:
|
|
686
|
+
'0xd9912df360b5b7f21a122f15bdd5e27f62ce5e72bd316c291f7c86620e07fb2a',
|
|
687
|
+
launchTs: 1738255943000,
|
|
688
|
+
},
|
|
676
689
|
];
|
|
677
690
|
|
|
678
691
|
export const SpotMarkets: { [key in DriftEnv]: SpotMarketConfig[] } = {
|
package/src/math/market.ts
CHANGED
|
@@ -334,3 +334,19 @@ export function calculateAvailablePerpLiquidity(
|
|
|
334
334
|
asks: asks,
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
|
+
|
|
338
|
+
export function calculatePerpMarketBaseLiquidatorFee(
|
|
339
|
+
market: PerpMarketAccount,
|
|
340
|
+
userHighLeverageMode: boolean
|
|
341
|
+
): number {
|
|
342
|
+
if (userHighLeverageMode && market.highLeverageMarginRatioMaintenance > 0) {
|
|
343
|
+
// min(liquidator_fee, .8 * high_leverage_margin_ratio_maintenance)
|
|
344
|
+
return Math.min(
|
|
345
|
+
market.liquidatorFee,
|
|
346
|
+
market.highLeverageMarginRatioMaintenance -
|
|
347
|
+
Math.floor(market.highLeverageMarginRatioMaintenance / 5)
|
|
348
|
+
);
|
|
349
|
+
} else {
|
|
350
|
+
return market.liquidatorFee;
|
|
351
|
+
}
|
|
352
|
+
}
|