@strobelabs/perpcity-sdk 0.6.0 → 0.6.1
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/index.cjs +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4291,19 +4291,20 @@ function calculateLeverage(positionValue, effectiveMargin) {
|
|
|
4291
4291
|
}
|
|
4292
4292
|
return positionValue / effectiveMargin;
|
|
4293
4293
|
}
|
|
4294
|
-
function calculateLiquidationPrice(rawData, isLong) {
|
|
4294
|
+
function calculateLiquidationPrice(rawData, isLong, effectiveMargin) {
|
|
4295
4295
|
const entryPrice = calculateEntryPrice(rawData);
|
|
4296
4296
|
const positionSize = Math.abs(calculatePositionSize(rawData));
|
|
4297
|
-
|
|
4297
|
+
const margin = effectiveMargin ?? rawData.margin;
|
|
4298
|
+
if (positionSize === 0 || margin <= 0) {
|
|
4298
4299
|
return null;
|
|
4299
4300
|
}
|
|
4300
4301
|
const liqMarginRatio = rawData.marginRatios.liq / 1e6;
|
|
4301
4302
|
const entryNotional = positionSize * entryPrice;
|
|
4302
4303
|
if (isLong) {
|
|
4303
|
-
const liqPrice = entryPrice - (
|
|
4304
|
+
const liqPrice = entryPrice - (margin - liqMarginRatio * entryNotional) / positionSize;
|
|
4304
4305
|
return Math.max(0, liqPrice);
|
|
4305
4306
|
} else {
|
|
4306
|
-
const liqPrice = entryPrice + (
|
|
4307
|
+
const liqPrice = entryPrice + (margin - liqMarginRatio * entryNotional) / positionSize;
|
|
4307
4308
|
return liqPrice;
|
|
4308
4309
|
}
|
|
4309
4310
|
}
|