@gainsnetwork/sdk 0.2.17-rc3 → 0.2.17-rc4
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.
|
@@ -5,7 +5,6 @@ export type GetBorrowingFeeContext = {
|
|
|
5
5
|
groups: BorrowingFee.Group[];
|
|
6
6
|
pairs: BorrowingFee.Pair[];
|
|
7
7
|
openInterest: OpenInterest;
|
|
8
|
-
feeMultiplier: number | undefined;
|
|
9
8
|
};
|
|
10
9
|
export declare const getBorrowingFee: (posDai: number, pairIndex: PairIndex, long: boolean, initialAccFees: BorrowingFee.InitialAccFees, context: GetBorrowingFeeContext) => number;
|
|
11
10
|
export declare const withinMaxGroupOi: (pairIndex: PairIndex, long: boolean, positionSizeCollateral: number, context: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Fee, PairIndex } from "../types";
|
|
2
|
-
export declare const getClosingFee: (posDai: number, leverage: number, pairIndex: PairIndex, pairFee: Fee | undefined, collateralPriceUsd?: number, feeMultiplier?: number) => number;
|
|
2
|
+
export declare const getClosingFee: (posDai: number, leverage: number, pairIndex: PairIndex, pairFee: Fee | undefined, collateralPriceUsd?: number | undefined, feeMultiplier?: number | undefined) => number;
|
|
3
3
|
export * from "./borrowing";
|
|
4
4
|
export * from "./tiers";
|
package/lib/trade/fees/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.getClosingFee = void 0;
|
|
18
|
-
const getClosingFee = (posDai, leverage, pairIndex, pairFee, collateralPriceUsd, feeMultiplier = 1) => {
|
|
18
|
+
const getClosingFee = (posDai, leverage, pairIndex, pairFee, collateralPriceUsd = 0, feeMultiplier = 1) => {
|
|
19
19
|
if (posDai === undefined ||
|
|
20
20
|
leverage === undefined ||
|
|
21
21
|
pairIndex === undefined ||
|
|
@@ -23,7 +23,8 @@ const getClosingFee = (posDai, leverage, pairIndex, pairFee, collateralPriceUsd,
|
|
|
23
23
|
return 0;
|
|
24
24
|
}
|
|
25
25
|
const { closeFeeP, triggerOrderFeeP, minPositionSizeUsd } = pairFee;
|
|
26
|
-
return ((closeFeeP + triggerOrderFeeP) *
|
|
26
|
+
return ((closeFeeP + triggerOrderFeeP) *
|
|
27
|
+
feeMultiplier *
|
|
27
28
|
Math.max(collateralPriceUsd && collateralPriceUsd > 0
|
|
28
29
|
? minPositionSizeUsd / collateralPriceUsd
|
|
29
30
|
: 0, posDai * leverage));
|
package/lib/trade/liquidation.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getLiquidationPrice = void 0;
|
|
4
4
|
const fees_1 = require("./fees");
|
|
5
5
|
const getLiquidationPrice = (trade, fee, initialAccFees, context) => {
|
|
6
|
-
const closingFee = (0, fees_1.getClosingFee)(trade.collateralAmount, trade.leverage, trade.pairIndex, fee, context.collateralPriceUsd
|
|
6
|
+
const closingFee = (0, fees_1.getClosingFee)(trade.collateralAmount, trade.leverage, trade.pairIndex, fee, context.collateralPriceUsd);
|
|
7
7
|
const borrowingFee = (0, fees_1.getBorrowingFee)(trade.collateralAmount * trade.leverage, trade.pairIndex, trade.long, initialAccFees, context);
|
|
8
8
|
const liqPriceDistance = (trade.openPrice *
|
|
9
9
|
(trade.collateralAmount * 0.9 - (borrowingFee + closingFee))) /
|
package/lib/trade/pnl.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export type GetPnlContext = GetBorrowingFeeContext & {
|
|
|
4
4
|
fee: Fee | undefined;
|
|
5
5
|
maxGainP: number | undefined;
|
|
6
6
|
collateralPriceUsd: number | undefined;
|
|
7
|
+
feeMultiplier: number | undefined;
|
|
7
8
|
};
|
|
8
9
|
export declare const getPnl: (price: number | undefined, trade: Trade, tradeInfo: TradeInfo, initialAccFees: TradeInitialAccFees, useFees: boolean, context: GetPnlContext) => number[] | undefined;
|