@gmx-io/sdk 1.5.0-alpha-17 → 1.6.0
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/build/cjs/scripts/subsquid-codegen.js +1 -1
- package/build/cjs/src/clients/v1/modules/orders/utils.js +1 -1
- package/build/cjs/src/clients/v1/modules/trades/trades.js +1 -0
- package/build/cjs/src/clients/v2/__tests__/multichain.spec.js +2 -2
- package/build/cjs/src/clients/v2/__tests__/multichainTestUtil.js +2 -1
- package/build/cjs/src/clients/v2/index.js +52 -48
- package/build/cjs/src/codegen/subsquid.js +6 -0
- package/build/cjs/src/configs/__tests__/markets.spec.js +11 -0
- package/build/cjs/src/configs/api.js +38 -18
- package/build/cjs/src/utils/__tests__/objects.spec.js +16 -0
- package/build/cjs/src/utils/__tests__/positions.spec.js +163 -0
- package/build/cjs/src/utils/__tests__/uiFeeReceiver.spec.js +5 -0
- package/build/cjs/src/utils/apy/api.js +1 -1
- package/build/cjs/src/utils/balances/api.js +2 -2
- package/build/cjs/src/utils/buyback/api.js +1 -1
- package/build/cjs/src/utils/express/utils/oracleParamsUtils.js +1 -4
- package/build/cjs/src/utils/express/utils/relayParamsUtils.js +0 -1
- package/build/cjs/src/utils/{multichainTransferApi → gmxAccountApi}/api.js +8 -4
- package/build/cjs/src/utils/jitLiquidity/api.js +12 -0
- package/build/cjs/src/utils/jitLiquidity/index.js +19 -0
- package/build/cjs/src/utils/jitLiquidity/types.js +2 -0
- package/build/cjs/src/utils/jitLiquidity/utils.js +108 -0
- package/build/cjs/src/utils/jitLiquidity/utils.spec.js +133 -0
- package/build/cjs/src/utils/markets/api.js +4 -4
- package/build/cjs/src/utils/markets/utils.js +4 -2
- package/build/cjs/src/utils/multichain/__tests__/api.spec.js +4 -4
- package/build/cjs/src/utils/multichain/api.js +3 -0
- package/build/cjs/src/utils/multichain/quotes.js +0 -1
- package/build/cjs/src/utils/numbers/utils.js +1 -1
- package/build/cjs/src/utils/objects/utils.js +13 -1
- package/build/cjs/src/utils/orderTransactions/api.js +6 -6
- package/build/cjs/src/utils/orders/api.js +1 -1
- package/build/cjs/src/utils/pairs/api.js +1 -1
- package/build/cjs/src/utils/performance/api.js +2 -2
- package/build/cjs/src/utils/positions/api.js +1 -1
- package/build/cjs/src/utils/positions/utils.js +29 -1
- package/build/cjs/src/utils/prices/api.js +1 -1
- package/build/cjs/src/utils/rates/api.js +1 -1
- package/build/cjs/src/utils/rpc/createViemRpc.js +1 -1
- package/build/cjs/src/utils/staking/api.js +1 -1
- package/build/cjs/src/utils/subaccount/api.js +2 -2
- package/build/cjs/src/utils/tokens/api.js +1 -1
- package/build/cjs/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.js +121 -0
- package/build/cjs/src/utils/trade/decrease.js +60 -3
- package/build/cjs/src/utils/trade/decreaseOutputs.js +47 -0
- package/build/cjs/src/utils/trade/index.js +1 -0
- package/build/cjs/src/utils/tradeHistory/utils.js +1 -0
- package/build/cjs/src/utils/trades/api.js +2 -2
- package/build/cjs/src/utils/twap/uiFeeReceiver.js +3 -0
- package/build/esm/scripts/subsquid-codegen.js +1 -1
- package/build/esm/src/clients/v1/modules/orders/utils.js +1 -1
- package/build/esm/src/clients/v1/modules/trades/trades.js +1 -0
- package/build/esm/src/clients/v2/__tests__/multichain.spec.js +3 -3
- package/build/esm/src/clients/v2/__tests__/multichainTestUtil.js +1 -0
- package/build/esm/src/clients/v2/index.js +5 -1
- package/build/esm/src/codegen/subsquid.js +6 -0
- package/build/esm/src/configs/__tests__/markets.spec.js +12 -1
- package/build/esm/src/configs/api.js +38 -18
- package/build/esm/src/utils/__tests__/objects.spec.js +17 -1
- package/build/esm/src/utils/__tests__/positions.spec.js +164 -1
- package/build/esm/src/utils/__tests__/uiFeeReceiver.spec.js +5 -0
- package/build/esm/src/utils/apy/api.js +1 -1
- package/build/esm/src/utils/balances/api.js +2 -2
- package/build/esm/src/utils/buyback/api.js +1 -1
- package/build/esm/src/utils/express/utils/oracleParamsUtils.js +1 -4
- package/build/esm/src/utils/express/utils/relayParamsUtils.js +0 -1
- package/build/esm/src/utils/{multichainTransferApi → gmxAccountApi}/api.js +8 -4
- package/build/esm/src/utils/jitLiquidity/api.js +8 -0
- package/build/esm/src/utils/jitLiquidity/index.js +3 -0
- package/build/esm/src/utils/jitLiquidity/types.js +1 -0
- package/build/esm/src/utils/jitLiquidity/utils.js +101 -0
- package/build/esm/src/utils/jitLiquidity/utils.spec.js +131 -0
- package/build/esm/src/utils/markets/api.js +4 -4
- package/build/esm/src/utils/markets/utils.js +4 -2
- package/build/esm/src/utils/multichain/__tests__/api.spec.js +4 -4
- package/build/esm/src/utils/multichain/api.js +3 -0
- package/build/esm/src/utils/multichain/quotes.js +0 -1
- package/build/esm/src/utils/numbers/utils.js +1 -1
- package/build/esm/src/utils/objects/utils.js +9 -0
- package/build/esm/src/utils/orderTransactions/api.js +6 -6
- package/build/esm/src/utils/orders/api.js +1 -1
- package/build/esm/src/utils/pairs/api.js +1 -1
- package/build/esm/src/utils/performance/api.js +2 -2
- package/build/esm/src/utils/positions/api.js +1 -1
- package/build/esm/src/utils/positions/utils.js +27 -0
- package/build/esm/src/utils/prices/api.js +1 -1
- package/build/esm/src/utils/rates/api.js +1 -1
- package/build/esm/src/utils/rpc/createViemRpc.js +1 -1
- package/build/esm/src/utils/staking/api.js +1 -1
- package/build/esm/src/utils/subaccount/api.js +2 -2
- package/build/esm/src/utils/tokens/api.js +1 -1
- package/build/esm/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.js +119 -0
- package/build/esm/src/utils/trade/decrease.js +59 -3
- package/build/esm/src/utils/trade/decreaseOutputs.js +40 -0
- package/build/esm/src/utils/trade/index.js +1 -0
- package/build/esm/src/utils/tradeHistory/utils.js +1 -0
- package/build/esm/src/utils/trades/api.js +2 -2
- package/build/esm/src/utils/twap/uiFeeReceiver.js +3 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build/types/src/clients/v2/__tests__/multichainTestUtil.d.ts +1 -0
- package/build/types/src/clients/v2/index.d.ts +5 -2
- package/build/types/src/codegen/subsquid.d.ts +16 -0
- package/build/types/src/configs/api.d.ts +4 -3
- package/build/types/src/utils/express/utils/oracleParamsUtils.d.ts +1 -3
- package/build/types/src/utils/jitLiquidity/api.d.ts +5 -0
- package/build/types/src/utils/jitLiquidity/index.d.ts +3 -0
- package/build/types/src/utils/jitLiquidity/types.d.ts +23 -0
- package/build/types/src/utils/jitLiquidity/utils.d.ts +5 -0
- package/build/types/src/utils/jitLiquidity/utils.spec.d.ts +1 -0
- package/build/types/src/utils/multichain/api.d.ts +3 -2
- package/build/types/src/utils/multichain/quotes.d.ts +0 -1
- package/build/types/src/utils/objects/utils.d.ts +3 -0
- package/build/types/src/utils/positions/utils.d.ts +10 -0
- package/build/types/src/utils/rpc/index.d.ts +2 -1
- package/build/types/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.d.ts +1 -0
- package/build/types/src/utils/trade/decrease.d.ts +8 -0
- package/build/types/src/utils/trade/decreaseOutputs.d.ts +16 -0
- package/build/types/src/utils/trade/index.d.ts +1 -0
- package/build/types/src/utils/tradeHistory/types.d.ts +1 -0
- package/build/types/src/utils/trades/types.d.ts +1 -0
- package/package.json +1 -1
- /package/build/cjs/src/utils/{multichainTransferApi → gmxAccountApi}/index.js +0 -0
- /package/build/esm/src/utils/{multichainTransferApi → gmxAccountApi}/index.js +0 -0
- /package/build/types/src/utils/{multichainTransferApi → gmxAccountApi}/api.d.ts +0 -0
- /package/build/types/src/utils/{multichainTransferApi → gmxAccountApi}/index.d.ts +0 -0
|
@@ -34,7 +34,9 @@ function parseWithdrawPrepareResponse(raw) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
async function prepareCrossChainDeposit(ctx, request) {
|
|
37
|
-
return ctx.api.postJson("/
|
|
37
|
+
return ctx.api.postJson("/v1/gmx-account/deposit/cross-chain/prepare", request, {
|
|
38
|
+
transform: parseDepositPrepareResponse,
|
|
39
|
+
});
|
|
38
40
|
}
|
|
39
41
|
exports.prepareCrossChainDeposit = prepareCrossChainDeposit;
|
|
40
42
|
async function executeCrossChainDeposit(ctx, signer, request) {
|
|
@@ -55,11 +57,13 @@ async function executeCrossChainDeposit(ctx, signer, request) {
|
|
|
55
57
|
}
|
|
56
58
|
exports.executeCrossChainDeposit = executeCrossChainDeposit;
|
|
57
59
|
async function prepareCrossChainWithdraw(ctx, request) {
|
|
58
|
-
return ctx.api.postJson("/
|
|
60
|
+
return ctx.api.postJson("/v1/gmx-account/withdraw/cross-chain/prepare", request, {
|
|
61
|
+
transform: parseWithdrawPrepareResponse,
|
|
62
|
+
});
|
|
59
63
|
}
|
|
60
64
|
exports.prepareCrossChainWithdraw = prepareCrossChainWithdraw;
|
|
61
65
|
async function submitCrossChainWithdraw(ctx, request) {
|
|
62
|
-
return ctx.api.postJson("/
|
|
66
|
+
return ctx.api.postJson("/v1/gmx-account/withdraw/cross-chain/submit", request);
|
|
63
67
|
}
|
|
64
68
|
exports.submitCrossChainWithdraw = submitCrossChainWithdraw;
|
|
65
69
|
async function signCrossChainWithdrawPrepared(prepared, signer) {
|
|
@@ -83,7 +87,7 @@ async function executeCrossChainWithdraw(ctx, signer, request) {
|
|
|
83
87
|
}
|
|
84
88
|
exports.executeCrossChainWithdraw = executeCrossChainWithdraw;
|
|
85
89
|
async function getCrossChainWithdrawStatus(ctx, requestId) {
|
|
86
|
-
return ctx.api.postJson("/
|
|
90
|
+
return ctx.api.postJson("/v1/gmx-account/withdraw/cross-chain/status", {
|
|
87
91
|
requestId,
|
|
88
92
|
});
|
|
89
93
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchApiJitLiquidityInfo = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
async function fetchApiJitLiquidityInfo(ctx, params) {
|
|
6
|
+
const response = await ctx.api.fetchJson(getJitLiquidityApiPath(params?.apiVersion ?? "v1"));
|
|
7
|
+
return (0, utils_1.parseJitLiquidityResponse)(response);
|
|
8
|
+
}
|
|
9
|
+
exports.fetchApiJitLiquidityInfo = fetchApiJitLiquidityInfo;
|
|
10
|
+
function getJitLiquidityApiPath(apiVersion) {
|
|
11
|
+
return `/${apiVersion}/jit/liquidity_info`;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseJitLiquidityResponse = exports.getJitGlvShiftParams = exports.getJitMaxReservedUsd = exports.getJitLiquidityInfo = void 0;
|
|
4
|
+
const objects_1 = require("../objects");
|
|
5
|
+
function getJitLiquidityInfo(jitLiquidityMap, marketTokenAddress) {
|
|
6
|
+
return jitLiquidityMap?.[marketTokenAddress];
|
|
7
|
+
}
|
|
8
|
+
exports.getJitLiquidityInfo = getJitLiquidityInfo;
|
|
9
|
+
function getJitMaxReservedUsd(jitLiquidityMap, marketTokenAddress, isLong) {
|
|
10
|
+
const info = getJitLiquidityInfo(jitLiquidityMap, marketTokenAddress);
|
|
11
|
+
return isLong ? info?.maxReservedUsdWithJitLong : info?.maxReservedUsdWithJitShort;
|
|
12
|
+
}
|
|
13
|
+
exports.getJitMaxReservedUsd = getJitMaxReservedUsd;
|
|
14
|
+
function getJitGlvShiftParams(jitLiquidityMap, marketTokenAddress, isLong) {
|
|
15
|
+
const info = getJitLiquidityInfo(jitLiquidityMap, marketTokenAddress);
|
|
16
|
+
if (!info) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return isLong ? info.glvShiftParamsLong : info.glvShiftParamsShort;
|
|
20
|
+
}
|
|
21
|
+
exports.getJitGlvShiftParams = getJitGlvShiftParams;
|
|
22
|
+
function parseJitLiquidityResponse(response, isV2JitLiquidityInfoEnabled) {
|
|
23
|
+
const liquidityInfos = getLiquidityInfos(response);
|
|
24
|
+
const result = {};
|
|
25
|
+
for (const rawInfo of liquidityInfos) {
|
|
26
|
+
if (!(0, objects_1.isRecord)(rawInfo)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const market = (0, objects_1.getString)(rawInfo.market);
|
|
30
|
+
if (!market) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const hasV2Shape = Boolean((0, objects_1.getRecord)(rawInfo.long) || (0, objects_1.getRecord)(rawInfo.short));
|
|
34
|
+
const shouldParseV2 = isV2JitLiquidityInfoEnabled ?? hasV2Shape;
|
|
35
|
+
result[market] = shouldParseV2 ? parseV2JitLiquidityInfo(rawInfo) : parseV1JitLiquidityInfo(rawInfo);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
exports.parseJitLiquidityResponse = parseJitLiquidityResponse;
|
|
40
|
+
function parseV1JitLiquidityInfo(rawInfo) {
|
|
41
|
+
const glvShiftParams = parseGlvShiftParams(rawInfo.glvShiftParams);
|
|
42
|
+
return {
|
|
43
|
+
maxReservedUsdWithJitLong: parseJitAmount(rawInfo.maxReservedUsdWithJitLong),
|
|
44
|
+
maxReservedUsdWithJitShort: parseJitAmount(rawInfo.maxReservedUsdWithJitShort),
|
|
45
|
+
glvShiftParamsLong: glvShiftParams,
|
|
46
|
+
glvShiftParamsShort: glvShiftParams,
|
|
47
|
+
glvShiftParams,
|
|
48
|
+
glv: (0, objects_1.getString)(rawInfo.glv) ?? "",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function parseV2JitLiquidityInfo(rawInfo) {
|
|
52
|
+
const longInfo = (0, objects_1.getRecord)(rawInfo.long);
|
|
53
|
+
const shortInfo = (0, objects_1.getRecord)(rawInfo.short);
|
|
54
|
+
if (!longInfo && !shortInfo) {
|
|
55
|
+
return parseV1JitLiquidityInfo(rawInfo);
|
|
56
|
+
}
|
|
57
|
+
const glvShiftParamsLong = parseGlvShiftParams(longInfo?.glvShiftParams ?? rawInfo.glvShiftParams);
|
|
58
|
+
const glvShiftParamsShort = parseGlvShiftParams(shortInfo?.glvShiftParams ?? rawInfo.glvShiftParams);
|
|
59
|
+
return {
|
|
60
|
+
maxReservedUsdWithJitLong: parseJitAmount(longInfo?.maxReservedUsd ?? rawInfo.maxReservedUsdWithJitLong),
|
|
61
|
+
maxReservedUsdWithJitShort: parseJitAmount(shortInfo?.maxReservedUsd ?? rawInfo.maxReservedUsdWithJitShort),
|
|
62
|
+
glvShiftParamsLong,
|
|
63
|
+
glvShiftParamsShort,
|
|
64
|
+
glvShiftParams: [...glvShiftParamsLong, ...glvShiftParamsShort],
|
|
65
|
+
glv: (0, objects_1.getString)(rawInfo.glv) ?? "",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function getLiquidityInfos(response) {
|
|
69
|
+
if (!(0, objects_1.isRecord)(response)) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const liquidityInfos = response.liquidityInfos ?? response.v2JitLiquidityInfos ?? response.v2JITLiquidityInfos;
|
|
73
|
+
return Array.isArray(liquidityInfos) ? liquidityInfos : [];
|
|
74
|
+
}
|
|
75
|
+
function parseGlvShiftParams(value) {
|
|
76
|
+
const rawParams = Array.isArray(value) ? value : value ? [value] : [];
|
|
77
|
+
return rawParams.map(parseGlvShiftParam).filter((param) => param !== undefined);
|
|
78
|
+
}
|
|
79
|
+
function parseGlvShiftParam(value) {
|
|
80
|
+
if (!(0, objects_1.isRecord)(value)) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const glv = (0, objects_1.getString)(value.glv);
|
|
84
|
+
const fromMarket = (0, objects_1.getString)(value.fromMarket);
|
|
85
|
+
const toMarket = (0, objects_1.getString)(value.toMarket);
|
|
86
|
+
if (!glv || !fromMarket || !toMarket) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
glv,
|
|
91
|
+
fromMarket,
|
|
92
|
+
toMarket,
|
|
93
|
+
marketTokenAmount: parseJitAmount(value.marketTokenAmount),
|
|
94
|
+
minMarketTokens: parseJitAmount(value.minMarketTokens),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function parseJitAmount(value) {
|
|
98
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "bigint") {
|
|
99
|
+
return 0n;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const amount = BigInt(value);
|
|
103
|
+
return amount < 0n ? 0n : amount;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return 0n;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
(0, vitest_1.describe)("parseJitLiquidityResponse", () => {
|
|
6
|
+
(0, vitest_1.it)("parses v1 JIT liquidity info", () => {
|
|
7
|
+
const result = (0, utils_1.parseJitLiquidityResponse)({
|
|
8
|
+
liquidityInfos: [
|
|
9
|
+
{
|
|
10
|
+
glv: "0xGlv",
|
|
11
|
+
market: "0xMarket",
|
|
12
|
+
maxReservedUsdWithJitLong: "100",
|
|
13
|
+
maxReservedUsdWithJitShort: "200",
|
|
14
|
+
glvShiftParams: [
|
|
15
|
+
{
|
|
16
|
+
glv: "0xGlv",
|
|
17
|
+
fromMarket: "0xFrom",
|
|
18
|
+
toMarket: "0xMarket",
|
|
19
|
+
marketTokenAmount: "10",
|
|
20
|
+
minMarketTokens: "9",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
}, false);
|
|
26
|
+
(0, vitest_1.expect)(result["0xMarket"]).toEqual({
|
|
27
|
+
glv: "0xGlv",
|
|
28
|
+
maxReservedUsdWithJitLong: 100n,
|
|
29
|
+
maxReservedUsdWithJitShort: 200n,
|
|
30
|
+
glvShiftParams: [
|
|
31
|
+
{
|
|
32
|
+
glv: "0xGlv",
|
|
33
|
+
fromMarket: "0xFrom",
|
|
34
|
+
toMarket: "0xMarket",
|
|
35
|
+
marketTokenAmount: 10n,
|
|
36
|
+
minMarketTokens: 9n,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
glvShiftParamsLong: [
|
|
40
|
+
{
|
|
41
|
+
glv: "0xGlv",
|
|
42
|
+
fromMarket: "0xFrom",
|
|
43
|
+
toMarket: "0xMarket",
|
|
44
|
+
marketTokenAmount: 10n,
|
|
45
|
+
minMarketTokens: 9n,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
glvShiftParamsShort: [
|
|
49
|
+
{
|
|
50
|
+
glv: "0xGlv",
|
|
51
|
+
fromMarket: "0xFrom",
|
|
52
|
+
toMarket: "0xMarket",
|
|
53
|
+
marketTokenAmount: 10n,
|
|
54
|
+
minMarketTokens: 9n,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
(0, vitest_1.it)("parses v2 JIT liquidity info with direction-specific shift params", () => {
|
|
60
|
+
const result = (0, utils_1.parseJitLiquidityResponse)({
|
|
61
|
+
liquidityInfos: [
|
|
62
|
+
{
|
|
63
|
+
glv: "0xGlv",
|
|
64
|
+
market: "0xMarket",
|
|
65
|
+
long: {
|
|
66
|
+
maxReservedUsd: "300",
|
|
67
|
+
glvShiftParams: {
|
|
68
|
+
glv: "0xGlv",
|
|
69
|
+
fromMarket: "0xLongFrom",
|
|
70
|
+
toMarket: "0xMarket",
|
|
71
|
+
marketTokenAmount: "30",
|
|
72
|
+
minMarketTokens: "29",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
short: {
|
|
76
|
+
maxReservedUsd: "400",
|
|
77
|
+
glvShiftParams: {
|
|
78
|
+
glv: "0xGlv",
|
|
79
|
+
fromMarket: "0xShortFrom",
|
|
80
|
+
toMarket: "0xMarket",
|
|
81
|
+
marketTokenAmount: "40",
|
|
82
|
+
minMarketTokens: "39",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
(0, vitest_1.expect)(result["0xMarket"].maxReservedUsdWithJitLong).toBe(300n);
|
|
89
|
+
(0, vitest_1.expect)(result["0xMarket"].maxReservedUsdWithJitShort).toBe(400n);
|
|
90
|
+
(0, vitest_1.expect)((0, utils_1.getJitGlvShiftParams)(result, "0xMarket", true)).toEqual([
|
|
91
|
+
{
|
|
92
|
+
glv: "0xGlv",
|
|
93
|
+
fromMarket: "0xLongFrom",
|
|
94
|
+
toMarket: "0xMarket",
|
|
95
|
+
marketTokenAmount: 30n,
|
|
96
|
+
minMarketTokens: 29n,
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
(0, vitest_1.expect)((0, utils_1.getJitGlvShiftParams)(result, "0xMarket", false)).toEqual([
|
|
100
|
+
{
|
|
101
|
+
glv: "0xGlv",
|
|
102
|
+
fromMarket: "0xShortFrom",
|
|
103
|
+
toMarket: "0xMarket",
|
|
104
|
+
marketTokenAmount: 40n,
|
|
105
|
+
minMarketTokens: 39n,
|
|
106
|
+
},
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
109
|
+
(0, vitest_1.it)("falls back to zero for invalid and negative amount values", () => {
|
|
110
|
+
const result = (0, utils_1.parseJitLiquidityResponse)({
|
|
111
|
+
liquidityInfos: [
|
|
112
|
+
{
|
|
113
|
+
market: "0xMarket",
|
|
114
|
+
maxReservedUsdWithJitLong: "-100",
|
|
115
|
+
maxReservedUsdWithJitShort: "invalid",
|
|
116
|
+
glvShiftParams: [
|
|
117
|
+
{
|
|
118
|
+
glv: "0xGlv",
|
|
119
|
+
fromMarket: "0xFrom",
|
|
120
|
+
toMarket: "0xMarket",
|
|
121
|
+
marketTokenAmount: "1.5",
|
|
122
|
+
minMarketTokens: "-9",
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
(0, vitest_1.expect)(result["0xMarket"].maxReservedUsdWithJitLong).toBe(0n);
|
|
129
|
+
(0, vitest_1.expect)(result["0xMarket"].maxReservedUsdWithJitShort).toBe(0n);
|
|
130
|
+
(0, vitest_1.expect)(result["0xMarket"].glvShiftParams[0].marketTokenAmount).toBe(0n);
|
|
131
|
+
(0, vitest_1.expect)(result["0xMarket"].glvShiftParams[0].minMarketTokens).toBe(0n);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -3,22 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchApiMarketsTickers = exports.fetchApiMarkets = exports.fetchApiTokensData = exports.fetchApiMarketsInfo = void 0;
|
|
4
4
|
const numbers_1 = require("../numbers");
|
|
5
5
|
async function fetchApiMarketsInfo(ctx) {
|
|
6
|
-
const mInfos = await ctx.api.fetchJson("/markets/info");
|
|
6
|
+
const mInfos = await ctx.api.fetchJson("/v1/markets/info");
|
|
7
7
|
return mInfos.map((mInfo) => (0, numbers_1.deserializeBigIntsInObject)(mInfo, { handleInts: true }));
|
|
8
8
|
}
|
|
9
9
|
exports.fetchApiMarketsInfo = fetchApiMarketsInfo;
|
|
10
10
|
async function fetchApiTokensData(ctx) {
|
|
11
|
-
const tInfos = await ctx.api.fetchJson("/tokens/info");
|
|
11
|
+
const tInfos = await ctx.api.fetchJson("/v1/tokens/info");
|
|
12
12
|
return tInfos.map((tInfo) => (0, numbers_1.deserializeBigIntsInObject)(tInfo, { handleInts: true }));
|
|
13
13
|
}
|
|
14
14
|
exports.fetchApiTokensData = fetchApiTokensData;
|
|
15
15
|
async function fetchApiMarkets(ctx) {
|
|
16
|
-
const markets = await ctx.api.fetchJson("/markets");
|
|
16
|
+
const markets = await ctx.api.fetchJson("/v1/markets");
|
|
17
17
|
return markets.map((m) => (0, numbers_1.deserializeBigIntsInObject)(m, { handleInts: true }));
|
|
18
18
|
}
|
|
19
19
|
exports.fetchApiMarkets = fetchApiMarkets;
|
|
20
20
|
async function fetchApiMarketsTickers(ctx, params) {
|
|
21
|
-
const tickers = await ctx.api.fetchJson("/markets/tickers", {
|
|
21
|
+
const tickers = await ctx.api.fetchJson("/v1/markets/tickers", {
|
|
22
22
|
query: {
|
|
23
23
|
addresses: params?.addresses,
|
|
24
24
|
symbols: params?.symbols,
|
|
@@ -59,10 +59,12 @@ function getTokenPoolType(marketInfo, tokenAddress) {
|
|
|
59
59
|
if (longToken.address === shortToken.address && tokenAddress === longToken.address) {
|
|
60
60
|
return "long";
|
|
61
61
|
}
|
|
62
|
-
if (tokenAddress === longToken.address ||
|
|
62
|
+
if (tokenAddress === longToken.address ||
|
|
63
|
+
(tokenAddress === tokens_1.NATIVE_TOKEN_ADDRESS && longToken.isWrapped)) {
|
|
63
64
|
return "long";
|
|
64
65
|
}
|
|
65
|
-
if (tokenAddress === shortToken.address ||
|
|
66
|
+
if (tokenAddress === shortToken.address ||
|
|
67
|
+
(tokenAddress === tokens_1.NATIVE_TOKEN_ADDRESS && shortToken.isWrapped)) {
|
|
66
68
|
return "short";
|
|
67
69
|
}
|
|
68
70
|
return undefined;
|
|
@@ -9,7 +9,7 @@ const multichain_1 = require("../../../configs/multichain");
|
|
|
9
9
|
const api_1 = require("../api");
|
|
10
10
|
const ACCOUNT = "0x1111111111111111111111111111111111111111";
|
|
11
11
|
const USDC_ARBITRUM = "0xaf88d065e77c8cC2239327C5EDb3A432268e5831";
|
|
12
|
-
const
|
|
12
|
+
const STARGATE_USDC_ARBITRUM = "0xe8CDF27AcD73a434D661C84887215F7598e7d0d3";
|
|
13
13
|
const ROUTER_ARBITRUM = (0, contracts_1.getContract)(chains_1.ARBITRUM, "MultichainTransferRouter");
|
|
14
14
|
const VAULT_ARBITRUM = (0, contracts_1.getContract)(chains_1.ARBITRUM, "MultichainVault");
|
|
15
15
|
const WETH_ARBITRUM = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
|
|
@@ -110,13 +110,13 @@ function decodeMulticall(data) {
|
|
|
110
110
|
tokenAddress: USDC_ARBITRUM,
|
|
111
111
|
amount: 1000000n,
|
|
112
112
|
dstChainId: chains_1.SOURCE_BASE_MAINNET,
|
|
113
|
-
stargateAddress:
|
|
113
|
+
stargateAddress: STARGATE_USDC_ARBITRUM,
|
|
114
114
|
slippageBps: 50,
|
|
115
115
|
});
|
|
116
116
|
(0, vitest_1.expect)(params.token).toBe(USDC_ARBITRUM);
|
|
117
117
|
(0, vitest_1.expect)(params.amount).toBe(1000000n);
|
|
118
118
|
(0, vitest_1.expect)(params.minAmountOut).toBe(995000n);
|
|
119
|
-
(0, vitest_1.expect)(params.provider).toBe(
|
|
119
|
+
(0, vitest_1.expect)(params.provider).toBe(STARGATE_USDC_ARBITRUM);
|
|
120
120
|
const [decodedDstEid] = (0, viem_1.decodeAbiParameters)([{ type: "uint32" }], params.data);
|
|
121
121
|
(0, vitest_1.expect)(decodedDstEid).toBe(multichain_1.CHAIN_ID_TO_ENDPOINT_ID[chains_1.SOURCE_BASE_MAINNET]);
|
|
122
122
|
});
|
|
@@ -125,7 +125,7 @@ function decodeMulticall(data) {
|
|
|
125
125
|
tokenAddress: USDC_ARBITRUM,
|
|
126
126
|
amount: 1000000n,
|
|
127
127
|
dstChainId: chains_1.SOURCE_BASE_MAINNET,
|
|
128
|
-
stargateAddress:
|
|
128
|
+
stargateAddress: STARGATE_USDC_ARBITRUM,
|
|
129
129
|
});
|
|
130
130
|
(0, vitest_1.expect)(params.minAmountOut).toBe(1000000n);
|
|
131
131
|
});
|
|
@@ -86,6 +86,9 @@ exports.buildSameChainWithdrawTxn = buildSameChainWithdrawTxn;
|
|
|
86
86
|
*/
|
|
87
87
|
function buildCrossChainWithdrawBridgeOutParams(params) {
|
|
88
88
|
const { tokenAddress, amount, dstChainId, stargateAddress, slippageBps = 0 } = params;
|
|
89
|
+
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps >= 10000) {
|
|
90
|
+
throw new Error(`slippageBps must be an integer in range [0, 10000), got ${slippageBps}`);
|
|
91
|
+
}
|
|
89
92
|
const dstEid = (0, multichain_1.getLayerZeroEndpointId)(dstChainId);
|
|
90
93
|
if (dstEid === undefined) {
|
|
91
94
|
throw new Error(`No LayerZero endpoint id for destination chain ${dstChainId}`);
|
|
@@ -603,6 +603,7 @@ function removeTrailingZeros(amount) {
|
|
|
603
603
|
return amountWithoutZeros;
|
|
604
604
|
}
|
|
605
605
|
exports.removeTrailingZeros = removeTrailingZeros;
|
|
606
|
+
const NUMERIC_STRING_REGEX = /^-?\d+$/;
|
|
606
607
|
function serializeBigIntsInObject(obj) {
|
|
607
608
|
const result = Array.isArray(obj) ? [] : {};
|
|
608
609
|
for (const key in obj) {
|
|
@@ -620,7 +621,6 @@ function serializeBigIntsInObject(obj) {
|
|
|
620
621
|
return result;
|
|
621
622
|
}
|
|
622
623
|
exports.serializeBigIntsInObject = serializeBigIntsInObject;
|
|
623
|
-
const NUMERIC_STRING_REGEX = /^-?\d+$/;
|
|
624
624
|
function deserializeBigIntsInObject(obj, opts) {
|
|
625
625
|
const handleInts = opts?.handleInts ?? false;
|
|
626
626
|
const result = Array.isArray(obj) ? [] : {};
|
|
@@ -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.toDict = exports.objectKeysDeep = exports.deleteByKey = exports.getByKey = exports.updateByKey = exports.setByKey = void 0;
|
|
6
|
+
exports.toDict = exports.objectKeysDeep = exports.deleteByKey = exports.getString = exports.getRecord = exports.isRecord = exports.getByKey = exports.updateByKey = exports.setByKey = void 0;
|
|
7
7
|
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
8
8
|
function setByKey(obj, key, data) {
|
|
9
9
|
return { ...obj, [key]: data };
|
|
@@ -21,6 +21,18 @@ function getByKey(obj, key) {
|
|
|
21
21
|
return obj[key];
|
|
22
22
|
}
|
|
23
23
|
exports.getByKey = getByKey;
|
|
24
|
+
function isRecord(value) {
|
|
25
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
exports.isRecord = isRecord;
|
|
28
|
+
function getRecord(value) {
|
|
29
|
+
return isRecord(value) ? value : undefined;
|
|
30
|
+
}
|
|
31
|
+
exports.getRecord = getRecord;
|
|
32
|
+
function getString(value) {
|
|
33
|
+
return typeof value === "string" ? value : undefined;
|
|
34
|
+
}
|
|
35
|
+
exports.getString = getString;
|
|
24
36
|
function deleteByKey(obj, key) {
|
|
25
37
|
const newObj = { ...obj };
|
|
26
38
|
delete newObj[key];
|
|
@@ -20,35 +20,35 @@ function parsePrepareResponse(raw) {
|
|
|
20
20
|
return { ...raw, estimates: parseEstimates(raw.estimates) };
|
|
21
21
|
}
|
|
22
22
|
async function prepareOrder(ctx, request) {
|
|
23
|
-
return ctx.api.postJson("/orders/txns/prepare", request, {
|
|
23
|
+
return ctx.api.postJson("/v1/orders/txns/prepare", request, {
|
|
24
24
|
transform: parsePrepareResponse,
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
exports.prepareOrder = prepareOrder;
|
|
28
28
|
async function submitOrder(ctx, request) {
|
|
29
|
-
return ctx.api.postJson("/orders/txns/submit", request);
|
|
29
|
+
return ctx.api.postJson("/v1/orders/txns/submit", request);
|
|
30
30
|
}
|
|
31
31
|
exports.submitOrder = submitOrder;
|
|
32
32
|
async function prepareEditOrder(ctx, request) {
|
|
33
|
-
return ctx.api.postJson("/orders/txns/edit/prepare", request, {
|
|
33
|
+
return ctx.api.postJson("/v1/orders/txns/edit/prepare", request, {
|
|
34
34
|
transform: parsePrepareResponse,
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
exports.prepareEditOrder = prepareEditOrder;
|
|
38
38
|
async function prepareCancelOrder(ctx, request) {
|
|
39
|
-
return ctx.api.postJson("/orders/txns/cancel/prepare", request, {
|
|
39
|
+
return ctx.api.postJson("/v1/orders/txns/cancel/prepare", request, {
|
|
40
40
|
transform: parsePrepareResponse,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
exports.prepareCancelOrder = prepareCancelOrder;
|
|
44
44
|
async function prepareCollateral(ctx, request) {
|
|
45
|
-
return ctx.api.postJson("/orders/txns/collateral/prepare", request, {
|
|
45
|
+
return ctx.api.postJson("/v1/orders/txns/collateral/prepare", request, {
|
|
46
46
|
transform: parsePrepareResponse,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
exports.prepareCollateral = prepareCollateral;
|
|
50
50
|
async function fetchOrderStatus(ctx, request) {
|
|
51
|
-
return ctx.api.postJson("/orders/txns/status", request);
|
|
51
|
+
return ctx.api.postJson("/v1/orders/txns/status", request);
|
|
52
52
|
}
|
|
53
53
|
exports.fetchOrderStatus = fetchOrderStatus;
|
|
54
54
|
async function signPreparedOrder(prepared, signer, chainId, accountAddress) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchApiOrders = void 0;
|
|
4
4
|
const numbers_1 = require("../numbers");
|
|
5
5
|
async function fetchApiOrders(ctx, params) {
|
|
6
|
-
const orders = await ctx.api.fetchJson("/orders", {
|
|
6
|
+
const orders = await ctx.api.fetchJson("/v1/orders", {
|
|
7
7
|
query: {
|
|
8
8
|
address: params.address,
|
|
9
9
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchApiPerformanceSnapshots = exports.fetchApiPerformanceAnnualized = void 0;
|
|
4
4
|
async function fetchApiPerformanceAnnualized(ctx, params) {
|
|
5
|
-
return ctx.api.fetchJson("/performance/annualized", {
|
|
5
|
+
return ctx.api.fetchJson("/v1/performance/annualized", {
|
|
6
6
|
query: {
|
|
7
7
|
period: params?.period,
|
|
8
8
|
address: params?.address,
|
|
@@ -11,7 +11,7 @@ async function fetchApiPerformanceAnnualized(ctx, params) {
|
|
|
11
11
|
}
|
|
12
12
|
exports.fetchApiPerformanceAnnualized = fetchApiPerformanceAnnualized;
|
|
13
13
|
async function fetchApiPerformanceSnapshots(ctx, params) {
|
|
14
|
-
return ctx.api.fetchJson("/performance/snapshots", {
|
|
14
|
+
return ctx.api.fetchJson("/v1/performance/snapshots", {
|
|
15
15
|
query: {
|
|
16
16
|
period: params?.period,
|
|
17
17
|
address: params?.address,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchApiPositionsInfo = void 0;
|
|
4
4
|
const numbers_1 = require("../numbers");
|
|
5
5
|
async function fetchApiPositionsInfo(ctx, params) {
|
|
6
|
-
const positions = await ctx.api.fetchJson("/positions", {
|
|
6
|
+
const positions = await ctx.api.fetchJson("/v1/positions", {
|
|
7
7
|
query: {
|
|
8
8
|
address: params.address,
|
|
9
9
|
includeRelatedOrders: params.includeRelatedOrders || undefined,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPositionInfo = exports.getContractPositionDynamicFees = exports.getMinCollateralFactorForPosition = exports.getPriceImpactDiffUsd = exports.getNetPriceImpactDeltaUsdForDecrease = exports.getLiquidationPrice = exports.getLeverage = exports.getPositionPnlAfterAllFees = exports.getPositionPnlAfterFees = exports.getPositionNetValueAfterAllFees = exports.getPositionNetValue = exports.getPositionPendingFeesUsd = exports.getPositionValueUsd = exports.getPositionPnlUsd = exports.getEntryPrice = exports.parsePositionKey = exports.getPositionKey = void 0;
|
|
3
|
+
exports.getPositionInfo = exports.getContractPositionDynamicFees = exports.getMinCollateralFactorForPosition = exports.getPriceImpactDiffUsd = exports.getNetPriceImpactDeltaUsdForDecrease = exports.getMinCollateralUsdForLiquidationPrice = exports.getLiquidationPrice = exports.getLeverage = exports.getPositionPnlAfterAllFees = exports.getPositionPnlAfterFees = exports.getPositionNetValueAfterAllFees = exports.getPositionNetValue = exports.getPositionPendingFeesUsd = exports.getPositionValueUsd = exports.getPositionPnlUsd = exports.getEntryPrice = exports.parsePositionKey = exports.getPositionKey = void 0;
|
|
4
4
|
const factors_1 = require("../../configs/factors");
|
|
5
5
|
const bigmath_1 = require("../bigmath");
|
|
6
6
|
const fees_1 = require("../fees");
|
|
@@ -163,6 +163,34 @@ function getLiquidationPrice(p) {
|
|
|
163
163
|
return liquidationPrice;
|
|
164
164
|
}
|
|
165
165
|
exports.getLiquidationPrice = getLiquidationPrice;
|
|
166
|
+
function getMinCollateralUsdForLiquidationPrice(p) {
|
|
167
|
+
const { sizeInUsd, sizeInTokens, marketInfo, pendingImpactAmount, minCollateralUsd, pnl, isLong, userReferralInfo } = p;
|
|
168
|
+
if (sizeInUsd <= 0 || sizeInTokens <= 0) {
|
|
169
|
+
return 0n;
|
|
170
|
+
}
|
|
171
|
+
const closingFeeUsd = (0, fees_1.getPositionFee)(marketInfo, sizeInUsd, false, userReferralInfo).positionFeeUsd;
|
|
172
|
+
const maxNegativePriceImpactUsd = -1n * (0, numbers_1.applyFactor)(sizeInUsd, marketInfo.maxPositionImpactFactorForLiquidations);
|
|
173
|
+
let priceImpactDeltaUsd = (0, fees_1.getPriceImpactForPosition)(marketInfo, -sizeInUsd, isLong, {
|
|
174
|
+
fallbackToZero: true,
|
|
175
|
+
}).priceImpactDeltaUsd;
|
|
176
|
+
if (priceImpactDeltaUsd > 0) {
|
|
177
|
+
priceImpactDeltaUsd = (0, fees_1.capPositionImpactUsdByMaxPriceImpactFactor)(marketInfo, sizeInUsd, priceImpactDeltaUsd);
|
|
178
|
+
}
|
|
179
|
+
const pendingImpactUsd = (0, tokens_1.convertToUsd)(pendingImpactAmount, marketInfo.indexToken.decimals, pendingImpactAmount > 0 ? marketInfo.indexToken.prices.minPrice : marketInfo.indexToken.prices.maxPrice);
|
|
180
|
+
priceImpactDeltaUsd = priceImpactDeltaUsd + pendingImpactUsd;
|
|
181
|
+
if (priceImpactDeltaUsd > 0) {
|
|
182
|
+
priceImpactDeltaUsd = 0n;
|
|
183
|
+
}
|
|
184
|
+
else if (priceImpactDeltaUsd < maxNegativePriceImpactUsd) {
|
|
185
|
+
priceImpactDeltaUsd = maxNegativePriceImpactUsd;
|
|
186
|
+
}
|
|
187
|
+
let liquidationCollateralUsd = (0, numbers_1.applyFactor)(sizeInUsd, marketInfo.minCollateralFactorForLiquidation);
|
|
188
|
+
if (liquidationCollateralUsd < minCollateralUsd) {
|
|
189
|
+
liquidationCollateralUsd = minCollateralUsd;
|
|
190
|
+
}
|
|
191
|
+
return liquidationCollateralUsd - pnl - priceImpactDeltaUsd + closingFeeUsd;
|
|
192
|
+
}
|
|
193
|
+
exports.getMinCollateralUsdForLiquidationPrice = getMinCollateralUsdForLiquidationPrice;
|
|
166
194
|
function getNetPriceImpactDeltaUsdForDecrease({ marketInfo, sizeInUsd, pendingImpactAmount, priceImpactDeltaUsd, sizeDeltaUsd, }) {
|
|
167
195
|
const { proportionalPendingImpactDeltaUsd } = (0, fees_1.getProportionalPendingImpactValues)({
|
|
168
196
|
sizeInUsd,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchApiOhlcv = void 0;
|
|
4
4
|
async function fetchApiOhlcv(ctx, params) {
|
|
5
|
-
return ctx.api.fetchJson("/prices/ohlcv", {
|
|
5
|
+
return ctx.api.fetchJson("/v1/prices/ohlcv", {
|
|
6
6
|
query: {
|
|
7
7
|
symbol: params.symbol,
|
|
8
8
|
timeframe: params.timeframe,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchApiRates = void 0;
|
|
4
4
|
async function fetchApiRates(ctx, params) {
|
|
5
|
-
return ctx.api.fetchJson("/rates", {
|
|
5
|
+
return ctx.api.fetchJson("/v1/rates", {
|
|
6
6
|
query: {
|
|
7
7
|
period: params?.period,
|
|
8
8
|
averageBy: params?.averageBy,
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchApiStakingPower = void 0;
|
|
4
4
|
const numbers_1 = require("../numbers");
|
|
5
5
|
async function fetchApiStakingPower(ctx, params) {
|
|
6
|
-
const data = await ctx.api.fetchJson("/staking/power", {
|
|
6
|
+
const data = await ctx.api.fetchJson("/v1/staking/power", {
|
|
7
7
|
query: { address: params.address },
|
|
8
8
|
});
|
|
9
9
|
return (0, numbers_1.deserializeBigIntsInObject)(data, { handleInts: true });
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.signSubaccountApproval = exports.prepareSubaccountApproval = exports.fetchSubaccountStatus = void 0;
|
|
4
4
|
const validateTypedData_1 = require("../orderTransactions/validateTypedData");
|
|
5
5
|
async function fetchSubaccountStatus(ctx, request) {
|
|
6
|
-
return ctx.api.postJson("/subaccounts/status", request);
|
|
6
|
+
return ctx.api.postJson("/v1/subaccounts/status", request);
|
|
7
7
|
}
|
|
8
8
|
exports.fetchSubaccountStatus = fetchSubaccountStatus;
|
|
9
9
|
async function prepareSubaccountApproval(ctx, request) {
|
|
10
|
-
return ctx.api.postJson("/subaccounts/approval/prepare", request);
|
|
10
|
+
return ctx.api.postJson("/v1/subaccounts/approval/prepare", request);
|
|
11
11
|
}
|
|
12
12
|
exports.prepareSubaccountApproval = prepareSubaccountApproval;
|
|
13
13
|
async function signSubaccountApproval(prepared, signer, options) {
|