@gmx-io/sdk 0.0.1-alpha-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/LICENSE +40 -0
- package/README.md +79 -0
- package/build/abis/CustomErrors.json +3254 -0
- package/build/abis/DataStore.json +1440 -0
- package/build/abis/ERC721.json +442 -0
- package/build/abis/EventEmitter.json +2065 -0
- package/build/abis/ExchangeRouter.json +1598 -0
- package/build/abis/GMT.json +522 -0
- package/build/abis/GlpManager.json +592 -0
- package/build/abis/GlvReader.json +1425 -0
- package/build/abis/GlvRouter.json +613 -0
- package/build/abis/GmxMigrator.json +657 -0
- package/build/abis/GovToken.json +1121 -0
- package/build/abis/MintableBaseToken.json +696 -0
- package/build/abis/Multicall.json +333 -0
- package/build/abis/OrderBook.json +1997 -0
- package/build/abis/OrderBookReader.json +111 -0
- package/build/abis/OrderExecutor.json +122 -0
- package/build/abis/PositionManager.json +1165 -0
- package/build/abis/PositionRouter.json +2030 -0
- package/build/abis/Reader.json +355 -0
- package/build/abis/ReaderV2.json +630 -0
- package/build/abis/ReferralStorage.json +507 -0
- package/build/abis/RewardReader.json +86 -0
- package/build/abis/RewardRouter.json +769 -0
- package/build/abis/RewardTracker.json +918 -0
- package/build/abis/Router-v2.json +605 -0
- package/build/abis/Router.json +605 -0
- package/build/abis/SubaccountRouter.json +648 -0
- package/build/abis/SyntheticsReader.json +4577 -0
- package/build/abis/SyntheticsRouter.json +77 -0
- package/build/abis/Timelock.json +1737 -0
- package/build/abis/Token.json +345 -0
- package/build/abis/Treasury.json +411 -0
- package/build/abis/UniPool.json +89 -0
- package/build/abis/UniswapV2.json +1 -0
- package/build/abis/Vault.json +3220 -0
- package/build/abis/VaultReader.json +87 -0
- package/build/abis/VaultV2.json +3019 -0
- package/build/abis/VaultV2b.json +3220 -0
- package/build/abis/Vester.json +1031 -0
- package/build/abis/WETH.json +320 -0
- package/build/abis/YieldFarm.json +599 -0
- package/build/abis/YieldToken.json +560 -0
- package/build/prebuilt/hashedMarketConfigKeys.json +3658 -0
- package/build/prebuilt/hashedMarketValuesKeys.json +1103 -0
- package/build/prebuilt/index.ts +28 -0
- package/build/src/abis/CustomErrors.json +3254 -0
- package/build/src/abis/DataStore.json +1440 -0
- package/build/src/abis/ERC721.json +442 -0
- package/build/src/abis/EventEmitter.json +2065 -0
- package/build/src/abis/ExchangeRouter.json +1598 -0
- package/build/src/abis/GMT.json +522 -0
- package/build/src/abis/GlpManager.json +591 -0
- package/build/src/abis/GlvReader.json +1424 -0
- package/build/src/abis/GlvRouter.json +612 -0
- package/build/src/abis/GmxMigrator.json +657 -0
- package/build/src/abis/GovToken.json +1121 -0
- package/build/src/abis/MintableBaseToken.json +696 -0
- package/build/src/abis/Multicall.json +333 -0
- package/build/src/abis/OrderBook.json +1997 -0
- package/build/src/abis/OrderBookReader.json +111 -0
- package/build/src/abis/OrderExecutor.json +122 -0
- package/build/src/abis/PositionManager.json +1165 -0
- package/build/src/abis/PositionRouter.json +2030 -0
- package/build/src/abis/Reader.json +355 -0
- package/build/src/abis/ReaderV2.json +630 -0
- package/build/src/abis/ReferralStorage.json +507 -0
- package/build/src/abis/RewardReader.json +86 -0
- package/build/src/abis/RewardRouter.json +769 -0
- package/build/src/abis/RewardTracker.json +918 -0
- package/build/src/abis/Router-v2.json +605 -0
- package/build/src/abis/Router.json +605 -0
- package/build/src/abis/SubaccountRouter.json +648 -0
- package/build/src/abis/SyntheticsReader.json +4577 -0
- package/build/src/abis/SyntheticsRouter.json +77 -0
- package/build/src/abis/Timelock.json +1737 -0
- package/build/src/abis/Token.json +345 -0
- package/build/src/abis/Treasury.json +411 -0
- package/build/src/abis/UniPool.json +89 -0
- package/build/src/abis/UniswapV2.json +1 -0
- package/build/src/abis/Vault.json +3220 -0
- package/build/src/abis/VaultReader.json +87 -0
- package/build/src/abis/VaultV2.json +3019 -0
- package/build/src/abis/VaultV2b.json +3220 -0
- package/build/src/abis/Vester.json +1031 -0
- package/build/src/abis/WETH.json +320 -0
- package/build/src/abis/YieldFarm.json +599 -0
- package/build/src/abis/YieldToken.json +560 -0
- package/build/src/configs/batch.d.ts +6 -0
- package/build/src/configs/batch.js +51 -0
- package/build/src/configs/chains.d.ts +37 -0
- package/build/src/configs/chains.js +90 -0
- package/build/src/configs/contracts.d.ts +2 -0
- package/build/src/configs/contracts.js +218 -0
- package/build/src/configs/dataStore.d.ts +149 -0
- package/build/src/configs/dataStore.js +276 -0
- package/build/src/configs/factors.d.ts +20 -0
- package/build/src/configs/factors.js +21 -0
- package/build/src/configs/markets.d.ts +8 -0
- package/build/src/configs/markets.js +528 -0
- package/build/src/configs/subgraph.d.ts +3 -0
- package/build/src/configs/subgraph.js +3 -0
- package/build/src/configs/tokens.d.ts +89 -0
- package/build/src/configs/tokens.js +1269 -0
- package/build/src/index.d.ts +44 -0
- package/build/src/index.js +245 -0
- package/build/src/modules/accounts/accounts.d.ts +5 -0
- package/build/src/modules/accounts/accounts.js +36 -0
- package/build/src/modules/accounts/accounts.spec.d.ts +1 -0
- package/build/src/modules/accounts/accounts.spec.js +7 -0
- package/build/src/modules/base.d.ts +9 -0
- package/build/src/modules/base.js +15 -0
- package/build/src/modules/markets/index.d.ts +26 -0
- package/build/src/modules/markets/index.js +339 -0
- package/build/src/modules/markets/markets.spec.d.ts +1 -0
- package/build/src/modules/markets/markets.spec.js +38 -0
- package/build/src/modules/markets/query-builders.d.ts +40 -0
- package/build/src/modules/markets/query-builders.js +379 -0
- package/build/src/modules/markets/types.d.ts +42 -0
- package/build/src/modules/markets/types.js +1 -0
- package/build/src/modules/oracle.d.ts +31 -0
- package/build/src/modules/oracle.js +53 -0
- package/build/src/modules/orders/orders.d.ts +60 -0
- package/build/src/modules/orders/orders.js +270 -0
- package/build/src/modules/orders/orders.spec.d.ts +1 -0
- package/build/src/modules/orders/orders.spec.js +16 -0
- package/build/src/modules/orders/transactions/cancelOrdersTxn.d.ts +6 -0
- package/build/src/modules/orders/transactions/cancelOrdersTxn.js +15 -0
- package/build/src/modules/orders/transactions/createDecreaseOrderTxn.d.ts +32 -0
- package/build/src/modules/orders/transactions/createDecreaseOrderTxn.js +98 -0
- package/build/src/modules/orders/transactions/createIncreaseOrderTxn.d.ts +77 -0
- package/build/src/modules/orders/transactions/createIncreaseOrderTxn.js +164 -0
- package/build/src/modules/orders/transactions/createSwapOrderTxn.d.ts +16 -0
- package/build/src/modules/orders/transactions/createSwapOrderTxn.js +97 -0
- package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.d.ts +6 -0
- package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.js +13 -0
- package/build/src/modules/orders/transactions/updateOrderTxn.d.ts +23 -0
- package/build/src/modules/orders/transactions/updateOrderTxn.js +44 -0
- package/build/src/modules/orders/utils.d.ts +248 -0
- package/build/src/modules/orders/utils.js +151 -0
- package/build/src/modules/positions/positions.d.ts +48 -0
- package/build/src/modules/positions/positions.js +563 -0
- package/build/src/modules/positions/positions.spec.d.ts +1 -0
- package/build/src/modules/positions/positions.spec.js +25 -0
- package/build/src/modules/tokens/tokens.d.ts +26 -0
- package/build/src/modules/tokens/tokens.js +132 -0
- package/build/src/modules/tokens/tokens.spec.d.ts +1 -0
- package/build/src/modules/tokens/tokens.spec.js +19 -0
- package/build/src/modules/trades/trades.d.ts +48 -0
- package/build/src/modules/trades/trades.js +390 -0
- package/build/src/modules/trades/trades.spec.d.ts +1 -0
- package/build/src/modules/trades/trades.spec.js +14 -0
- package/build/src/prebuilt/hashedMarketConfigKeys.json +3658 -0
- package/build/src/prebuilt/hashedMarketValuesKeys.json +1103 -0
- package/build/src/prebuilt/index.d.ts +14 -0
- package/build/src/prebuilt/index.js +9 -0
- package/build/src/types/amounts.d.ts +223 -0
- package/build/src/types/amounts.js +17 -0
- package/build/src/types/fees.d.ts +34 -0
- package/build/src/types/fees.js +1 -0
- package/build/src/types/markets.d.ts +143 -0
- package/build/src/types/markets.js +1 -0
- package/build/src/types/orders.d.ts +74 -0
- package/build/src/types/orders.js +33 -0
- package/build/src/types/positions.d.ts +53 -0
- package/build/src/types/positions.js +1 -0
- package/build/src/types/referrals.d.ts +124 -0
- package/build/src/types/referrals.js +9 -0
- package/build/src/types/sdk.d.ts +32 -0
- package/build/src/types/sdk.js +1 -0
- package/build/src/types/sidecarOrders.d.ts +54 -0
- package/build/src/types/sidecarOrders.js +1 -0
- package/build/src/types/syntheticsEvents.d.ts +88 -0
- package/build/src/types/syntheticsEvents.js +1 -0
- package/build/src/types/tokens.d.ts +89 -0
- package/build/src/types/tokens.js +1 -0
- package/build/src/types/trade.d.ts +223 -0
- package/build/src/types/trade.js +17 -0
- package/build/src/types/tradeHistory.d.ts +107 -0
- package/build/src/types/tradeHistory.js +8 -0
- package/build/src/utils/LruCache.d.ts +10 -0
- package/build/src/utils/LruCache.js +45 -0
- package/build/src/utils/bigmath.d.ts +7 -0
- package/build/src/utils/bigmath.js +23 -0
- package/build/src/utils/buildUrl.d.ts +1 -0
- package/build/src/utils/buildUrl.js +5 -0
- package/build/src/utils/callContract.d.ts +17 -0
- package/build/src/utils/callContract.js +133 -0
- package/build/src/utils/common.d.ts +2 -0
- package/build/src/utils/common.js +2 -0
- package/build/src/utils/fees/estimateOraclePriceCount.d.ts +6 -0
- package/build/src/utils/fees/estimateOraclePriceCount.js +19 -0
- package/build/src/utils/fees/executionFee.d.ts +59 -0
- package/build/src/utils/fees/executionFee.js +108 -0
- package/build/src/utils/fees/index.d.ts +29 -0
- package/build/src/utils/fees/index.js +89 -0
- package/build/src/utils/fees/priceImpact.d.ts +75 -0
- package/build/src/utils/fees/priceImpact.js +287 -0
- package/build/src/utils/graphqlFetcher.d.ts +1 -0
- package/build/src/utils/graphqlFetcher.js +18 -0
- package/build/src/utils/hash.d.ts +5 -0
- package/build/src/utils/hash.js +35 -0
- package/build/src/utils/marketKeysAndConfigs.d.ts +66 -0
- package/build/src/utils/marketKeysAndConfigs.js +257 -0
- package/build/src/utils/markets.d.ts +40 -0
- package/build/src/utils/markets.js +129 -0
- package/build/src/utils/multicall.d.ts +64 -0
- package/build/src/utils/multicall.js +116 -0
- package/build/src/utils/numbers.d.ts +9 -0
- package/build/src/utils/numbers.js +30 -0
- package/build/src/utils/objects.d.ts +18 -0
- package/build/src/utils/objects.js +30 -0
- package/build/src/utils/orders.d.ts +28 -0
- package/build/src/utils/orders.js +178 -0
- package/build/src/utils/positions.d.ts +60 -0
- package/build/src/utils/positions.js +133 -0
- package/build/src/utils/prices.d.ts +15 -0
- package/build/src/utils/prices.js +34 -0
- package/build/src/utils/referrals.d.ts +2 -0
- package/build/src/utils/referrals.js +27 -0
- package/build/src/utils/simulateExecuteOrder.d.ts +16 -0
- package/build/src/utils/simulateExecuteOrder.js +143 -0
- package/build/src/utils/slidingWindowFallbackSwitcher.d.ts +24 -0
- package/build/src/utils/slidingWindowFallbackSwitcher.js +40 -0
- package/build/src/utils/subgraph.d.ts +21 -0
- package/build/src/utils/subgraph.js +72 -0
- package/build/src/utils/swapStats.d.ts +35 -0
- package/build/src/utils/swapStats.js +197 -0
- package/build/src/utils/test.d.ts +2 -0
- package/build/src/utils/test.js +24 -0
- package/build/src/utils/tokens.d.ts +18 -0
- package/build/src/utils/tokens.js +64 -0
- package/build/src/utils/trade.d.ts +10 -0
- package/build/src/utils/trade.js +32 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import DataStore from "abis/DataStore.json";
|
|
2
|
+
import SyntheticsReader from "abis/SyntheticsReader.json";
|
|
3
|
+
import { getContract } from "configs/contracts";
|
|
4
|
+
import { accountOrderListKey } from "configs/dataStore";
|
|
5
|
+
import { getWrappedToken } from "configs/tokens";
|
|
6
|
+
import { estimateOrderOraclePriceCount } from "utils/fees/estimateOraclePriceCount";
|
|
7
|
+
import { estimateExecuteDecreaseOrderGasLimit, getExecutionFee } from "utils/fees/executionFee";
|
|
8
|
+
import { isIncreaseOrderType, isLimitOrderType, isSwapOrderType, isTriggerDecreaseOrderType } from "utils/orders";
|
|
9
|
+
import { getSwapPathOutputAddresses } from "utils/swapStats";
|
|
10
|
+
import { isAddressEqual } from "viem";
|
|
11
|
+
export const getOrderExecutionFee = (sdk, swapsCount, decreasePositionSwapType, gasLimits, tokensData, gasPrice) => {
|
|
12
|
+
if (!gasLimits || !tokensData || gasPrice === undefined)
|
|
13
|
+
return;
|
|
14
|
+
const estimatedGas = estimateExecuteDecreaseOrderGasLimit(gasLimits, {
|
|
15
|
+
decreaseSwapType: decreasePositionSwapType,
|
|
16
|
+
swapsCount: swapsCount ?? 0,
|
|
17
|
+
});
|
|
18
|
+
const oraclePriceCount = estimateOrderOraclePriceCount(swapsCount);
|
|
19
|
+
return getExecutionFee(sdk, gasLimits, tokensData, estimatedGas, gasPrice, oraclePriceCount);
|
|
20
|
+
};
|
|
21
|
+
export const getExecutionFeeAmountForEntry = (sdk, entry, gasLimits, tokensData, gasPrice) => {
|
|
22
|
+
if (!entry.txnType || entry.txnType === "cancel")
|
|
23
|
+
return undefined;
|
|
24
|
+
const securedExecutionFee = entry.order?.executionFee ?? 0n;
|
|
25
|
+
let swapsCount = 0;
|
|
26
|
+
const executionFee = getOrderExecutionFee(sdk, swapsCount, entry.decreaseAmounts?.decreaseSwapType, gasLimits, tokensData, gasPrice);
|
|
27
|
+
if (!executionFee || securedExecutionFee >= executionFee.feeTokenAmount)
|
|
28
|
+
return undefined;
|
|
29
|
+
return executionFee.feeTokenAmount - securedExecutionFee;
|
|
30
|
+
};
|
|
31
|
+
export function matchByMarket({ order, nonSwapRelevantDefinedFiltersLowercased, hasNonSwapRelevantDefinedMarkets, pureDirectionFilters, hasPureDirectionFilters, swapRelevantDefinedMarketsLowercased, hasSwapRelevantDefinedMarkets, marketsInfoData, chainId, }) {
|
|
32
|
+
if (!hasNonSwapRelevantDefinedMarkets && !hasSwapRelevantDefinedMarkets && !hasPureDirectionFilters) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const isSwapOrder = isSwapOrderType(order.orderType);
|
|
36
|
+
const matchesPureDirectionFilter = hasPureDirectionFilters &&
|
|
37
|
+
(isSwapOrder
|
|
38
|
+
? pureDirectionFilters.includes("swap")
|
|
39
|
+
: pureDirectionFilters.includes(order.isLong ? "long" : "short"));
|
|
40
|
+
if (hasPureDirectionFilters && !matchesPureDirectionFilter) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
if (!hasNonSwapRelevantDefinedMarkets && !hasSwapRelevantDefinedMarkets) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (isSwapOrder) {
|
|
47
|
+
const sourceMarketInSwapPath = swapRelevantDefinedMarketsLowercased.includes(order.swapPath.at(0).toLowerCase());
|
|
48
|
+
const destinationMarketInSwapPath = swapRelevantDefinedMarketsLowercased.includes(order.swapPath.at(-1).toLowerCase());
|
|
49
|
+
return sourceMarketInSwapPath || destinationMarketInSwapPath;
|
|
50
|
+
}
|
|
51
|
+
else if (!isSwapOrder) {
|
|
52
|
+
return nonSwapRelevantDefinedFiltersLowercased.some((filter) => {
|
|
53
|
+
const marketMatch = filter.marketAddress === "any" || filter.marketAddress === order.marketAddress.toLowerCase();
|
|
54
|
+
const directionMath = filter.direction === "any" || filter.direction === (order.isLong ? "long" : "short");
|
|
55
|
+
const initialCollateralAddress = order.initialCollateralTokenAddress.toLowerCase();
|
|
56
|
+
let collateralMatch = true;
|
|
57
|
+
if (!filter.collateralAddress) {
|
|
58
|
+
collateralMatch = true;
|
|
59
|
+
}
|
|
60
|
+
else if (isLimitOrderType(order.orderType)) {
|
|
61
|
+
const wrappedToken = getWrappedToken(chainId);
|
|
62
|
+
if (!marketsInfoData) {
|
|
63
|
+
collateralMatch = true;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const { outTokenAddress } = getSwapPathOutputAddresses({
|
|
67
|
+
marketsInfoData,
|
|
68
|
+
initialCollateralAddress,
|
|
69
|
+
isIncrease: isIncreaseOrderType(order.orderType),
|
|
70
|
+
shouldUnwrapNativeToken: order.shouldUnwrapNativeToken,
|
|
71
|
+
swapPath: order.swapPath,
|
|
72
|
+
wrappedNativeTokenAddress: wrappedToken.address,
|
|
73
|
+
});
|
|
74
|
+
collateralMatch =
|
|
75
|
+
outTokenAddress !== undefined && isAddressEqual(outTokenAddress, filter.collateralAddress);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (isTriggerDecreaseOrderType(order.orderType)) {
|
|
79
|
+
collateralMatch = isAddressEqual(order.initialCollateralTokenAddress, filter.collateralAddress);
|
|
80
|
+
}
|
|
81
|
+
return marketMatch && directionMath && collateralMatch;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
export const DEFAULT_COUNT = 1000;
|
|
87
|
+
export function buildGetOrdersMulticall(chainId, account) {
|
|
88
|
+
return {
|
|
89
|
+
dataStore: {
|
|
90
|
+
contractAddress: getContract(chainId, "DataStore"),
|
|
91
|
+
abi: DataStore.abi,
|
|
92
|
+
calls: {
|
|
93
|
+
count: {
|
|
94
|
+
methodName: "getBytes32Count",
|
|
95
|
+
params: [accountOrderListKey(account)],
|
|
96
|
+
},
|
|
97
|
+
keys: {
|
|
98
|
+
methodName: "getBytes32ValuesAt",
|
|
99
|
+
params: [accountOrderListKey(account), 0, DEFAULT_COUNT],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
reader: {
|
|
104
|
+
contractAddress: getContract(chainId, "SyntheticsReader"),
|
|
105
|
+
abi: SyntheticsReader.abi,
|
|
106
|
+
calls: {
|
|
107
|
+
orders: {
|
|
108
|
+
methodName: "getAccountOrders",
|
|
109
|
+
params: [getContract(chainId, "DataStore"), account, 0, DEFAULT_COUNT],
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function parseGetOrdersResponse(res) {
|
|
116
|
+
const count = Number(res.data.dataStore.count.returnValues[0]);
|
|
117
|
+
const orderKeys = res.data.dataStore.keys.returnValues;
|
|
118
|
+
const orders = res.data.reader.orders.returnValues;
|
|
119
|
+
return {
|
|
120
|
+
count,
|
|
121
|
+
orders: orders.map((order, i) => {
|
|
122
|
+
const key = orderKeys[i];
|
|
123
|
+
const { data } = order;
|
|
124
|
+
const orderData = {
|
|
125
|
+
key,
|
|
126
|
+
account: order.addresses.account,
|
|
127
|
+
receiver: order.addresses.receiver,
|
|
128
|
+
callbackContract: order.addresses.callbackContract,
|
|
129
|
+
marketAddress: order.addresses.market,
|
|
130
|
+
initialCollateralTokenAddress: order.addresses.initialCollateralToken,
|
|
131
|
+
swapPath: order.addresses.swapPath,
|
|
132
|
+
sizeDeltaUsd: BigInt(order.numbers.sizeDeltaUsd),
|
|
133
|
+
initialCollateralDeltaAmount: BigInt(order.numbers.initialCollateralDeltaAmount),
|
|
134
|
+
contractTriggerPrice: BigInt(order.numbers.triggerPrice),
|
|
135
|
+
contractAcceptablePrice: BigInt(order.numbers.acceptablePrice),
|
|
136
|
+
executionFee: BigInt(order.numbers.executionFee),
|
|
137
|
+
callbackGasLimit: BigInt(order.numbers.callbackGasLimit),
|
|
138
|
+
minOutputAmount: BigInt(order.numbers.minOutputAmount),
|
|
139
|
+
updatedAtBlock: BigInt(order.numbers.updatedAtBlock),
|
|
140
|
+
isLong: order.flags.isLong,
|
|
141
|
+
shouldUnwrapNativeToken: order.flags.shouldUnwrapNativeToken,
|
|
142
|
+
isFrozen: order.flags.isFrozen,
|
|
143
|
+
orderType: order.numbers.orderType,
|
|
144
|
+
decreasePositionSwapType: order.numbers.decreasePositionSwapType,
|
|
145
|
+
autoCancel: order.flags.autoCancel,
|
|
146
|
+
data,
|
|
147
|
+
};
|
|
148
|
+
return orderData;
|
|
149
|
+
}),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MarketsData, MarketsInfoData } from "types/markets";
|
|
2
|
+
import { PositionsData, PositionsInfoData } from "types/positions";
|
|
3
|
+
import { TokensData } from "types/tokens";
|
|
4
|
+
import { Module } from "../base";
|
|
5
|
+
import { OrderInfo } from "types/orders";
|
|
6
|
+
type PositionsResult = {
|
|
7
|
+
positionsData?: PositionsData;
|
|
8
|
+
allPossiblePositionsKeys?: string[];
|
|
9
|
+
error?: Error;
|
|
10
|
+
};
|
|
11
|
+
type PositionsConstantsResult = {
|
|
12
|
+
minCollateralUsd?: bigint;
|
|
13
|
+
minPositionSizeUsd?: bigint;
|
|
14
|
+
maxAutoCancelOrders?: bigint;
|
|
15
|
+
};
|
|
16
|
+
export declare class Positions extends Module {
|
|
17
|
+
static MAX_PENDING_UPDATE_AGE: number;
|
|
18
|
+
private getKeysAndPricesParams;
|
|
19
|
+
private getOptimisticPositions;
|
|
20
|
+
getPositions(p: {
|
|
21
|
+
marketsInfoData: MarketsData | undefined;
|
|
22
|
+
tokensData: TokensData | undefined;
|
|
23
|
+
start?: number;
|
|
24
|
+
end?: number;
|
|
25
|
+
}): Promise<PositionsResult>;
|
|
26
|
+
private getUiFeeFactorRequest;
|
|
27
|
+
private _positionsConstants;
|
|
28
|
+
getPositionsConstants(): Promise<PositionsConstantsResult>;
|
|
29
|
+
getMaxAutoCancelOrders({ draftOrdersCount, positionOrders, }: {
|
|
30
|
+
positionOrders?: OrderInfo[];
|
|
31
|
+
draftOrdersCount?: number;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
warning: boolean;
|
|
34
|
+
autoCancelOrdersLimit: number;
|
|
35
|
+
}>;
|
|
36
|
+
private getCodeOwner;
|
|
37
|
+
private getUserRefferalCode;
|
|
38
|
+
private getAffiliateTier;
|
|
39
|
+
private getTiers;
|
|
40
|
+
private getReferrerDiscountShare;
|
|
41
|
+
private getUserReferralInfo;
|
|
42
|
+
getPositionsInfo(p: {
|
|
43
|
+
marketsInfoData: MarketsInfoData;
|
|
44
|
+
tokensData: TokensData;
|
|
45
|
+
showPnlInLeverage: boolean;
|
|
46
|
+
}): Promise<PositionsInfoData>;
|
|
47
|
+
}
|
|
48
|
+
export {};
|