@gainsnetwork/sdk 0.2.12-rc12 → 0.2.12-rc14
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/lib/constants.d.ts +2 -0
- package/lib/constants.js +4 -1
- package/lib/contracts/utils/pairs.js +2 -0
- package/lib/markets/forex.js +2 -2
- package/lib/trade/fees/index.d.ts +1 -1
- package/lib/trade/fees/index.js +2 -1
- package/lib/trade/pnl.d.ts +1 -0
- package/lib/trade/pnl.js +1 -1
- package/lib/trade/types.d.ts +3 -1
- package/lib/trade/types.js +2 -0
- package/package.json +1 -1
package/lib/constants.d.ts
CHANGED
|
@@ -254,6 +254,8 @@ export declare const pairs: {
|
|
|
254
254
|
"DEGEN/USD": string;
|
|
255
255
|
"SLERF/USD": string;
|
|
256
256
|
"UXLINK/USD": string;
|
|
257
|
+
"AVAIL/USD": string;
|
|
258
|
+
"BANANA/USD": string;
|
|
257
259
|
};
|
|
258
260
|
export declare const getAssetClassFromGroupIndex: (groupIndex: number) => string | undefined;
|
|
259
261
|
export declare const tickerChanges: {
|
package/lib/constants.js
CHANGED
|
@@ -262,10 +262,13 @@ exports.pairs = {
|
|
|
262
262
|
"DEGEN/USD": CRYPTO,
|
|
263
263
|
"SLERF/USD": CRYPTO,
|
|
264
264
|
"UXLINK/USD": CRYPTO,
|
|
265
|
+
"AVAIL/USD": CRYPTO,
|
|
266
|
+
"BANANA/USD": CRYPTO,
|
|
265
267
|
};
|
|
266
268
|
const getAssetClassFromGroupIndex = (groupIndex) => {
|
|
267
269
|
switch (groupIndex) {
|
|
268
270
|
case 0:
|
|
271
|
+
case 10:
|
|
269
272
|
return CRYPTO;
|
|
270
273
|
case 1:
|
|
271
274
|
case 8:
|
|
@@ -296,7 +299,7 @@ exports.delistedPairIxs = new Set([
|
|
|
296
299
|
6, 31, 36, 42, 45, 48, 51, 54, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
|
|
297
300
|
70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
|
|
298
301
|
89, 97, 99, 101, 106, 108, 52, 131, 147, 160, 179, 182, 183, 190, 229, 163,
|
|
299
|
-
155, 15, 170, 239,
|
|
302
|
+
155, 15, 170, 239, 254, 230,
|
|
300
303
|
]);
|
|
301
304
|
exports.delistedGroupsIxs = new Set([6, 7]);
|
|
302
305
|
exports.DEFAULT_PROTECTION_CLOSE_FACTOR = 1;
|
|
@@ -360,4 +360,6 @@ const PAIR_INDEX_TO_DESCRIPTION = {
|
|
|
360
360
|
[types_1.PairIndex.DEGENUSD]: "Degen to US Dollar",
|
|
361
361
|
[types_1.PairIndex.SLERFUSD]: "Slerf to US Dollar",
|
|
362
362
|
[types_1.PairIndex.UXLINKUSD]: "UXLINK to US Dollar",
|
|
363
|
+
[types_1.PairIndex.AVAILUSD]: "Avail to US Dollar",
|
|
364
|
+
[types_1.PairIndex.BANANAUSD]: "Banana Gun to US Dollar",
|
|
363
365
|
};
|
package/lib/markets/forex.js
CHANGED
|
@@ -36,8 +36,8 @@ const isForexLowLiquidity = (timestampToCheck, pair) => {
|
|
|
36
36
|
const groupIndex = pair === null || pair === void 0 ? void 0 : pair.groupIndex;
|
|
37
37
|
if (groupIndex && extendedLowLiqGroupIds.includes(+groupIndex)) {
|
|
38
38
|
return ((isInDST &&
|
|
39
|
-
((hour ==
|
|
40
|
-
(!isInDST && ((hour ==
|
|
39
|
+
((hour == 14 && minute >= 45) || (hour >= 15 && hour < 21))) ||
|
|
40
|
+
(!isInDST && ((hour == 15 && minute >= 45) || (hour >= 16 && hour < 22))));
|
|
41
41
|
}
|
|
42
42
|
return ((isInDST && ((hour == 15 && minute >= 45) || (hour >= 16 && hour < 19))) ||
|
|
43
43
|
(!isInDST && ((hour == 16 && minute >= 45) || (hour >= 17 && hour < 20))));
|
|
@@ -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) => 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) => {
|
|
18
|
+
const getClosingFee = (posDai, leverage, pairIndex, pairFee, collateralPriceUsd = 0, feeMultiplier = 1) => {
|
|
19
19
|
if (posDai === undefined ||
|
|
20
20
|
leverage === undefined ||
|
|
21
21
|
pairIndex === undefined ||
|
|
@@ -24,6 +24,7 @@ const getClosingFee = (posDai, leverage, pairIndex, pairFee, collateralPriceUsd)
|
|
|
24
24
|
}
|
|
25
25
|
const { closeFeeP, triggerOrderFeeP, minPositionSizeUsd } = pairFee;
|
|
26
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/pnl.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export type GetPnlContext = GetBorrowingFeeContext & {
|
|
|
6
6
|
maxGainP: number | undefined;
|
|
7
7
|
collateralPriceUsd: number | undefined;
|
|
8
8
|
contractsVersion: ContractsVersion | undefined;
|
|
9
|
+
feeMultiplier: number | undefined;
|
|
9
10
|
};
|
|
10
11
|
export declare const getPnl: (price: number | undefined, trade: Trade, tradeInfo: TradeInfo, initialAccFees: TradeInitialAccFees, liquidationParams: LiquidationParams, useFees: boolean, context: GetPnlContext) => number[] | undefined;
|
package/lib/trade/pnl.js
CHANGED
|
@@ -26,7 +26,7 @@ const getPnl = (price, trade, tradeInfo, initialAccFees, liquidationParams, useF
|
|
|
26
26
|
pnlPercentage = -100;
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
pnlCollat -= (0, fees_1.getClosingFee)(posCollat, trade.leverage, trade.pairIndex, fee, context.collateralPriceUsd);
|
|
29
|
+
pnlCollat -= (0, fees_1.getClosingFee)(posCollat, trade.leverage, trade.pairIndex, fee, context.collateralPriceUsd, context.feeMultiplier);
|
|
30
30
|
pnlPercentage = (pnlCollat / posCollat) * 100;
|
|
31
31
|
}
|
|
32
32
|
pnlPercentage = pnlPercentage < -100 ? -100 : pnlPercentage;
|
package/lib/trade/types.d.ts
CHANGED
package/lib/trade/types.js
CHANGED
|
@@ -284,4 +284,6 @@ var PairIndex;
|
|
|
284
284
|
PairIndex[PairIndex["DEGENUSD"] = 252] = "DEGENUSD";
|
|
285
285
|
PairIndex[PairIndex["SLERFUSD"] = 253] = "SLERFUSD";
|
|
286
286
|
PairIndex[PairIndex["UXLINKUSD"] = 254] = "UXLINKUSD";
|
|
287
|
+
PairIndex[PairIndex["AVAILUSD"] = 255] = "AVAILUSD";
|
|
288
|
+
PairIndex[PairIndex["BANANAUSD"] = 256] = "BANANAUSD";
|
|
287
289
|
})(PairIndex = exports.PairIndex || (exports.PairIndex = {}));
|