@gmx-io/sdk 1.4.0 → 1.4.2
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/src/abis/GlvReader.js +940 -940
- package/build/cjs/src/abis/IStargate.js +603 -0
- package/build/cjs/src/abis/LayerZeroProvider.js +273 -46
- package/build/cjs/src/abis/index.js +2 -2
- package/build/cjs/src/configs/batch.js +29 -103
- package/build/cjs/src/configs/chainIds.js +2 -2
- package/build/cjs/src/configs/chains.js +230 -151
- package/build/cjs/src/configs/contracts.js +1 -5
- package/build/cjs/src/configs/dataStore.js +5 -4
- package/build/cjs/src/configs/express.js +1 -1
- package/build/cjs/src/configs/gasLimits.js +41 -0
- package/build/cjs/src/configs/markets.js +102 -1
- package/build/cjs/src/configs/multichain.js +1 -0
- package/build/cjs/src/configs/oracleKeeper.js +18 -20
- package/build/cjs/src/configs/tokens.js +98 -180
- package/build/cjs/src/modules/markets/index.js +6 -2
- package/build/cjs/src/modules/markets/markets.spec.js +5 -5
- package/build/cjs/src/modules/markets/query-builders.js +8 -0
- package/build/cjs/src/modules/orders/helpers.js +4 -2
- package/build/cjs/src/modules/orders/helpers.spec.js +1 -1
- package/build/cjs/src/modules/orders/orders.spec.js +1 -1
- package/build/cjs/src/modules/positions/positions.spec.js +2 -2
- package/build/cjs/src/modules/tokens/tokens.spec.js +2 -2
- package/build/cjs/src/modules/trades/trades.spec.js +1 -1
- package/build/cjs/src/modules/utils/utils.js +7 -6
- package/build/cjs/src/prebuilt/hashedKinkModelMarketRatesKeys.json +64 -0
- package/build/cjs/src/prebuilt/hashedMarketConfigKeys.json +780 -0
- package/build/cjs/src/prebuilt/hashedMarketValuesKeys.json +120 -0
- package/build/cjs/src/test/mock.js +2 -0
- package/build/cjs/src/types/chains.js +2 -0
- package/build/cjs/src/types/orders.js +8 -2
- package/build/cjs/src/types/subsquid.js +241 -1
- package/build/cjs/src/types/tokens.js +7 -0
- package/build/cjs/src/utils/__tests__/abort.spec.js +122 -0
- package/build/cjs/src/utils/__tests__/numbers.spec.js +94 -14
- package/build/cjs/src/utils/abort.js +31 -0
- package/build/cjs/src/utils/callContract.js +4 -4
- package/build/cjs/src/utils/fees/executionFee.js +14 -11
- package/build/cjs/src/utils/fees/index.js +8 -2
- package/build/cjs/src/utils/marketKeysAndConfigs.js +8 -0
- package/build/cjs/src/utils/markets.js +7 -1
- package/build/cjs/src/utils/multicall.js +54 -17
- package/build/cjs/src/utils/numbers.js +25 -14
- package/build/cjs/src/utils/orders.js +2 -2
- package/build/cjs/src/utils/swap/__tests__/findSwapPathsBetweenTokens.spec.js +22 -0
- package/build/cjs/src/utils/swap/__tests__/mockRouting.spec.js +264 -6
- package/build/cjs/src/utils/swap/__tests__/swapRouting.spec.js +5 -4
- package/build/cjs/src/utils/swap/__tests__/swapStats.spec.js +10 -9
- package/build/cjs/src/utils/swap/buildSwapStrategy.js +20 -11
- package/build/cjs/src/utils/swap/findSwapPathsBetweenTokens.js +8 -4
- package/build/cjs/src/utils/swap/swapPath.js +6 -6
- package/build/cjs/src/utils/swap/swapRouting.js +8 -4
- package/build/cjs/src/utils/swap/swapStats.js +6 -6
- package/build/cjs/src/utils/swap/swapValues.js +17 -6
- package/build/cjs/src/utils/tokens.js +17 -1
- package/build/cjs/src/utils/trade/decrease.js +1 -1
- package/build/cjs/src/utils/trade/increase.js +3 -0
- package/build/esm/src/abis/GlvReader.js +940 -940
- package/build/esm/src/abis/IStargate.js +601 -0
- package/build/esm/src/abis/LayerZeroProvider.js +273 -46
- package/build/esm/src/abis/index.js +2 -2
- package/build/esm/src/configs/batch.js +30 -104
- package/build/esm/src/configs/chainIds.js +1 -1
- package/build/esm/src/configs/chains.js +212 -147
- package/build/esm/src/configs/contracts.js +1 -5
- package/build/esm/src/configs/dataStore.js +1 -0
- package/build/esm/src/configs/express.js +1 -1
- package/build/esm/src/configs/gasLimits.js +38 -0
- package/build/esm/src/configs/markets.js +95 -1
- package/build/esm/src/configs/multichain.js +2 -1
- package/build/esm/src/configs/oracleKeeper.js +17 -19
- package/build/esm/src/configs/tokens.js +97 -179
- package/build/esm/src/modules/markets/index.js +6 -2
- package/build/esm/src/modules/markets/markets.spec.js +5 -5
- package/build/esm/src/modules/markets/query-builders.js +8 -0
- package/build/esm/src/modules/orders/helpers.js +5 -3
- package/build/esm/src/modules/orders/helpers.spec.js +1 -1
- package/build/esm/src/modules/orders/orders.spec.js +1 -1
- package/build/esm/src/modules/positions/positions.spec.js +2 -2
- package/build/esm/src/modules/tokens/tokens.spec.js +2 -2
- package/build/esm/src/modules/trades/trades.spec.js +1 -1
- package/build/esm/src/modules/utils/utils.js +7 -6
- package/build/esm/src/prebuilt/hashedKinkModelMarketRatesKeys.json +64 -0
- package/build/esm/src/prebuilt/hashedMarketConfigKeys.json +780 -0
- package/build/esm/src/prebuilt/hashedMarketValuesKeys.json +120 -0
- package/build/esm/src/test/mock.js +2 -0
- package/build/esm/src/types/chains.js +1 -0
- package/build/esm/src/types/orders.js +8 -2
- package/build/esm/src/types/subsquid.js +240 -0
- package/build/esm/src/types/tokens.js +6 -1
- package/build/esm/src/utils/__tests__/abort.spec.js +120 -0
- package/build/esm/src/utils/__tests__/numbers.spec.js +95 -15
- package/build/esm/src/utils/abort.js +27 -0
- package/build/esm/src/utils/callContract.js +5 -5
- package/build/esm/src/utils/fees/executionFee.js +15 -12
- package/build/esm/src/utils/fees/index.js +8 -2
- package/build/esm/src/utils/marketKeysAndConfigs.js +9 -1
- package/build/esm/src/utils/markets.js +5 -0
- package/build/esm/src/utils/multicall.js +53 -16
- package/build/esm/src/utils/numbers.js +21 -12
- package/build/esm/src/utils/orders.js +3 -3
- package/build/esm/src/utils/swap/__tests__/findSwapPathsBetweenTokens.spec.js +22 -0
- package/build/esm/src/utils/swap/__tests__/mockRouting.spec.js +264 -6
- package/build/esm/src/utils/swap/__tests__/swapRouting.spec.js +5 -4
- package/build/esm/src/utils/swap/__tests__/swapStats.spec.js +10 -9
- package/build/esm/src/utils/swap/buildSwapStrategy.js +21 -12
- package/build/esm/src/utils/swap/findSwapPathsBetweenTokens.js +8 -4
- package/build/esm/src/utils/swap/swapPath.js +6 -6
- package/build/esm/src/utils/swap/swapRouting.js +8 -4
- package/build/esm/src/utils/swap/swapStats.js +6 -6
- package/build/esm/src/utils/swap/swapValues.js +18 -7
- package/build/esm/src/utils/tokens.js +15 -1
- package/build/esm/src/utils/trade/decrease.js +2 -2
- package/build/esm/src/utils/trade/increase.js +3 -0
- package/build/types/src/abis/IStargate.d.ts +464 -0
- package/build/types/src/abis/LayerZeroProvider.d.ts +12 -0
- package/build/types/src/abis/index.d.ts +475 -99
- package/build/types/src/configs/chainIds.d.ts +1 -1
- package/build/types/src/configs/chains.d.ts +170 -27
- package/build/types/src/configs/contracts.d.ts +0 -4
- package/build/types/src/configs/dataStore.d.ts +1 -0
- package/build/types/src/configs/express.d.ts +1 -1
- package/build/types/src/configs/gasLimits.d.ts +4 -0
- package/build/types/src/configs/markets.d.ts +10 -1
- package/build/types/src/configs/oracleKeeper.d.ts +13 -0
- package/build/types/src/configs/tokens.d.ts +3 -0
- package/build/types/src/index.d.ts +1 -1
- package/build/types/src/modules/base.d.ts +1 -1
- package/build/types/src/modules/markets/index.d.ts +2 -0
- package/build/types/src/modules/markets/query-builders.d.ts +1 -1
- package/build/types/src/modules/markets/types.d.ts +2 -2
- package/build/types/src/modules/utils/utils.d.ts +2 -3
- package/build/types/src/types/chains.d.ts +57 -0
- package/build/types/src/types/markets.d.ts +2 -0
- package/build/types/src/types/orders.d.ts +8 -2
- package/build/types/src/types/subsquid.d.ts +5987 -5172
- package/build/types/src/types/tokens.d.ts +11 -6
- package/build/types/src/types/trade.d.ts +5 -0
- package/build/types/src/utils/__tests__/abort.spec.d.ts +1 -0
- package/build/types/src/utils/abort.d.ts +1 -0
- package/build/types/src/utils/fees/estimateOraclePriceCount.d.ts +2 -2
- package/build/types/src/utils/fees/executionFee.d.ts +6 -6
- package/build/types/src/utils/fees/index.d.ts +2 -1
- package/build/types/src/utils/marketKeysAndConfigs.d.ts +2 -0
- package/build/types/src/utils/markets.d.ts +4 -2
- package/build/types/src/utils/multicall.d.ts +4 -2
- package/build/types/src/utils/numbers.d.ts +8 -1
- package/build/types/src/utils/swap/buildSwapStrategy.d.ts +8 -3
- package/build/types/src/utils/swap/swapPath.d.ts +2 -1
- package/build/types/src/utils/swap/swapRouting.d.ts +7 -2
- package/build/types/src/utils/swap/swapStats.d.ts +3 -2
- package/build/types/src/utils/swap/swapValues.d.ts +3 -1
- package/build/types/src/utils/tokens.d.ts +3 -0
- package/package.json +17 -5
- package/build/cjs/src/abis/MultichainUtils.js +0 -133
- package/build/esm/src/abis/MultichainUtils.js +0 -131
- package/build/types/src/abis/MultichainUtils.d.ts +0 -100
|
@@ -1,91 +1,157 @@
|
|
|
1
1
|
import { defineChain } from "viem";
|
|
2
|
-
import { arbitrum, arbitrumSepolia, avalanche, avalancheFuji, base, optimismSepolia, sepolia,
|
|
3
|
-
import { AVALANCHE, AVALANCHE_FUJI,
|
|
4
|
-
export { AVALANCHE, AVALANCHE_FUJI,
|
|
2
|
+
import { arbitrum, arbitrumSepolia, avalanche, avalancheFuji, base, bsc, mainnet, optimismSepolia, sepolia, } from "viem/chains";
|
|
3
|
+
import { ARBITRUM, ARBITRUM_SEPOLIA, AVALANCHE, AVALANCHE_FUJI, BOTANIX, SOURCE_ETHEREUM_MAINNET, SOURCE_BASE_MAINNET, SOURCE_BSC_MAINNET, SOURCE_OPTIMISM_SEPOLIA, SOURCE_SEPOLIA, } from "./chainIds";
|
|
4
|
+
export { ARBITRUM, AVALANCHE, AVALANCHE_FUJI, BOTANIX, ARBITRUM_SEPOLIA, SOURCE_ETHEREUM_MAINNET, SOURCE_BASE_MAINNET, SOURCE_BSC_MAINNET, SOURCE_OPTIMISM_SEPOLIA, SOURCE_SEPOLIA, };
|
|
5
5
|
export const CONTRACTS_CHAIN_IDS = [ARBITRUM, AVALANCHE, BOTANIX];
|
|
6
6
|
export const CONTRACTS_CHAIN_IDS_DEV = [...CONTRACTS_CHAIN_IDS, AVALANCHE_FUJI, ARBITRUM_SEPOLIA];
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
7
|
+
export const SETTLEMENT_CHAIN_IDS = [ARBITRUM, AVALANCHE];
|
|
8
|
+
export const SETTLEMENT_CHAIN_IDS_DEV = [...SETTLEMENT_CHAIN_IDS, ARBITRUM_SEPOLIA];
|
|
9
|
+
export const SOURCE_CHAIN_IDS = [
|
|
10
|
+
SOURCE_OPTIMISM_SEPOLIA,
|
|
11
|
+
SOURCE_SEPOLIA,
|
|
12
|
+
SOURCE_BASE_MAINNET,
|
|
13
|
+
SOURCE_BSC_MAINNET,
|
|
14
|
+
SOURCE_ETHEREUM_MAINNET,
|
|
15
|
+
];
|
|
16
|
+
export const GMX_ACCOUNT_PSEUDO_CHAIN_ID = 0;
|
|
17
|
+
const CONTRACTS_CHAIN_CONFIGS = {
|
|
18
|
+
[ARBITRUM]: {
|
|
19
|
+
chainId: ARBITRUM,
|
|
20
|
+
name: "Arbitrum",
|
|
21
|
+
slug: "arbitrum",
|
|
22
|
+
explorerUrl: "https://arbiscan.io/",
|
|
23
|
+
nativeTokenSymbol: "ETH",
|
|
24
|
+
wrappedTokenSymbol: "WETH",
|
|
25
|
+
defaultCollateralSymbol: "USDC.e",
|
|
26
|
+
highExecutionFee: 5,
|
|
27
|
+
shouldUseMaxPriorityFeePerGas: false,
|
|
28
|
+
defaultExecutionFeeBufferBps: 3000, // 30%
|
|
29
|
+
maxFeePerGas: undefined,
|
|
30
|
+
gasPricePremium: 0n,
|
|
31
|
+
maxPriorityFeePerGas: 1500000000n, // 1.5 gwei
|
|
32
|
+
excessiveExecutionFee: 10, // 10 USD
|
|
33
|
+
minExecutionFee: undefined,
|
|
34
|
+
gasPriceBuffer: 2000n, // 20%
|
|
35
|
+
isDisabled: false,
|
|
36
|
+
},
|
|
37
|
+
[AVALANCHE]: {
|
|
38
|
+
chainId: AVALANCHE,
|
|
39
|
+
name: "Avalanche",
|
|
40
|
+
slug: "avalanche",
|
|
41
|
+
explorerUrl: "https://snowtrace.io/",
|
|
42
|
+
nativeTokenSymbol: "AVAX",
|
|
43
|
+
wrappedTokenSymbol: "WAVAX",
|
|
44
|
+
defaultCollateralSymbol: "USDC",
|
|
45
|
+
highExecutionFee: 5,
|
|
46
|
+
shouldUseMaxPriorityFeePerGas: true,
|
|
47
|
+
defaultExecutionFeeBufferBps: 1000, // 10%
|
|
48
|
+
maxFeePerGas: 200000000000n, // 200 gwei
|
|
49
|
+
gasPricePremium: 6000000000n, // 6 gwei
|
|
50
|
+
maxPriorityFeePerGas: 1500000000n, // 1.5 gwei
|
|
51
|
+
excessiveExecutionFee: 10, // 10 USD
|
|
52
|
+
minExecutionFee: undefined,
|
|
53
|
+
gasPriceBuffer: undefined,
|
|
54
|
+
isDisabled: false,
|
|
55
|
+
},
|
|
56
|
+
[AVALANCHE_FUJI]: {
|
|
57
|
+
chainId: AVALANCHE_FUJI,
|
|
58
|
+
name: "Avalanche Fuji",
|
|
59
|
+
slug: "fuji",
|
|
60
|
+
explorerUrl: "https://testnet.snowtrace.io/",
|
|
61
|
+
nativeTokenSymbol: "AVAX",
|
|
62
|
+
wrappedTokenSymbol: "WAVAX",
|
|
63
|
+
defaultCollateralSymbol: "USDC",
|
|
64
|
+
highExecutionFee: 5,
|
|
65
|
+
shouldUseMaxPriorityFeePerGas: true,
|
|
66
|
+
defaultExecutionFeeBufferBps: 1000, // 10%
|
|
67
|
+
maxFeePerGas: undefined,
|
|
68
|
+
gasPricePremium: undefined,
|
|
69
|
+
maxPriorityFeePerGas: 1500000000n,
|
|
70
|
+
excessiveExecutionFee: 10, // 10 USD
|
|
71
|
+
minExecutionFee: undefined,
|
|
72
|
+
gasPriceBuffer: undefined,
|
|
73
|
+
isDisabled: false,
|
|
74
|
+
},
|
|
75
|
+
[ARBITRUM_SEPOLIA]: {
|
|
76
|
+
chainId: ARBITRUM_SEPOLIA,
|
|
77
|
+
name: "Arbitrum Sepolia",
|
|
78
|
+
slug: "arbitrum-sepolia",
|
|
79
|
+
explorerUrl: "https://sepolia.arbiscan.io/",
|
|
80
|
+
nativeTokenSymbol: "ETH",
|
|
81
|
+
wrappedTokenSymbol: "WETH",
|
|
82
|
+
defaultCollateralSymbol: "USDC",
|
|
83
|
+
highExecutionFee: 5,
|
|
84
|
+
shouldUseMaxPriorityFeePerGas: false,
|
|
85
|
+
defaultExecutionFeeBufferBps: 1000, // 10%
|
|
86
|
+
maxFeePerGas: undefined,
|
|
87
|
+
gasPricePremium: undefined,
|
|
88
|
+
maxPriorityFeePerGas: 1500000000n,
|
|
89
|
+
excessiveExecutionFee: 10, // 10 USD
|
|
90
|
+
minExecutionFee: undefined,
|
|
91
|
+
gasPriceBuffer: undefined,
|
|
92
|
+
isDisabled: false,
|
|
93
|
+
},
|
|
94
|
+
[BOTANIX]: {
|
|
95
|
+
chainId: BOTANIX,
|
|
96
|
+
name: "Botanix",
|
|
97
|
+
slug: "botanix",
|
|
98
|
+
explorerUrl: "https://botanixscan.io/",
|
|
99
|
+
nativeTokenSymbol: "BTC",
|
|
100
|
+
wrappedTokenSymbol: "PBTC",
|
|
101
|
+
defaultCollateralSymbol: "USDC.E",
|
|
102
|
+
highExecutionFee: 5,
|
|
103
|
+
shouldUseMaxPriorityFeePerGas: true,
|
|
104
|
+
defaultExecutionFeeBufferBps: 3000, // 30%
|
|
105
|
+
maxFeePerGas: 20n,
|
|
106
|
+
gasPricePremium: undefined,
|
|
107
|
+
maxPriorityFeePerGas: 7n,
|
|
108
|
+
excessiveExecutionFee: 10, // 10 USD
|
|
109
|
+
/**
|
|
110
|
+
* avoid botanix gas spikes when chain is not actively used
|
|
111
|
+
* if set, execution fee value should not be less than this in USD equivalent
|
|
112
|
+
*/
|
|
113
|
+
minExecutionFee: 1000000000000000000000000000n, // 1e27 $0.001
|
|
114
|
+
gasPriceBuffer: undefined,
|
|
115
|
+
isDisabled: false,
|
|
116
|
+
},
|
|
117
|
+
// Use this notation to correctly infer chain names, etc. from config
|
|
61
118
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
119
|
+
const SOURCE_CHAIN_CONFIGS = {
|
|
120
|
+
[SOURCE_OPTIMISM_SEPOLIA]: {
|
|
121
|
+
chainId: SOURCE_OPTIMISM_SEPOLIA,
|
|
122
|
+
name: "Optimism Sepolia",
|
|
123
|
+
slug: "optimism-sepolia",
|
|
124
|
+
explorerUrl: "https://sepolia-optimism.etherscan.io/",
|
|
125
|
+
},
|
|
126
|
+
[SOURCE_SEPOLIA]: {
|
|
127
|
+
chainId: SOURCE_SEPOLIA,
|
|
128
|
+
name: "Sepolia",
|
|
129
|
+
slug: "sepolia",
|
|
130
|
+
explorerUrl: "https://sepolia.etherscan.io/",
|
|
131
|
+
},
|
|
132
|
+
[SOURCE_BASE_MAINNET]: {
|
|
133
|
+
chainId: SOURCE_BASE_MAINNET,
|
|
134
|
+
name: "Base",
|
|
135
|
+
slug: "base-mainnet",
|
|
136
|
+
explorerUrl: "https://basescan.org/",
|
|
137
|
+
},
|
|
138
|
+
[SOURCE_BSC_MAINNET]: {
|
|
139
|
+
chainId: SOURCE_BSC_MAINNET,
|
|
140
|
+
name: "BNB",
|
|
141
|
+
slug: "bnb-mainnet",
|
|
142
|
+
explorerUrl: "https://bscscan.com/",
|
|
143
|
+
},
|
|
144
|
+
[SOURCE_ETHEREUM_MAINNET]: {
|
|
145
|
+
chainId: SOURCE_ETHEREUM_MAINNET,
|
|
146
|
+
name: "Ethereum",
|
|
147
|
+
slug: "ethereum-mainnet",
|
|
148
|
+
explorerUrl: "https://etherscan.io/",
|
|
149
|
+
},
|
|
150
|
+
// Use this notation to correctly infer chain names, etc. from config
|
|
69
151
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// it is *not* applied to the execution fee calculation, and in theory it could cause issues
|
|
74
|
-
// if gas price used in the execution fee calculation is lower
|
|
75
|
-
// than the gas price used in the transaction (e.g. create order transaction)
|
|
76
|
-
// then the transaction will fail with InsufficientExecutionFee error.
|
|
77
|
-
// it is not an issue on Arbitrum though because the passed gas price does not affect the paid gas price.
|
|
78
|
-
// for example if current gas price is 0.1 gwei and UI passes 0.5 gwei the transaction
|
|
79
|
-
// Arbitrum will still charge 0.1 gwei per gas
|
|
80
|
-
//
|
|
81
|
-
// it doesn't make much sense to set this buffer higher than the execution fee buffer
|
|
82
|
-
// because if the paid gas price is higher than the gas price used in the execution fee calculation
|
|
83
|
-
// and the transaction will still fail with InsufficientExecutionFee
|
|
84
|
-
//
|
|
85
|
-
// this buffer could also cause issues on a blockchain that uses passed gas price
|
|
86
|
-
// especially if execution fee buffer and lower than gas price buffer defined bellow
|
|
87
|
-
export const GAS_PRICE_BUFFER_MAP = {
|
|
88
|
-
[ARBITRUM]: 2000n, // 20%
|
|
152
|
+
const ALL_CHAIN_CONFIGS = {
|
|
153
|
+
...CONTRACTS_CHAIN_CONFIGS,
|
|
154
|
+
...SOURCE_CHAIN_CONFIGS,
|
|
89
155
|
};
|
|
90
156
|
export const botanix = defineChain({
|
|
91
157
|
id: BOTANIX,
|
|
@@ -116,91 +182,90 @@ export const botanix = defineChain({
|
|
|
116
182
|
},
|
|
117
183
|
},
|
|
118
184
|
});
|
|
119
|
-
const VIEM_CHAIN_BY_CHAIN_ID = {
|
|
185
|
+
export const VIEM_CHAIN_BY_CHAIN_ID = {
|
|
120
186
|
[AVALANCHE_FUJI]: avalancheFuji,
|
|
121
187
|
[ARBITRUM]: arbitrum,
|
|
122
188
|
[AVALANCHE]: avalanche,
|
|
123
189
|
[ARBITRUM_SEPOLIA]: arbitrumSepolia,
|
|
124
190
|
[BOTANIX]: botanix,
|
|
191
|
+
[SOURCE_ETHEREUM_MAINNET]: mainnet,
|
|
125
192
|
[SOURCE_OPTIMISM_SEPOLIA]: optimismSepolia,
|
|
126
193
|
[SOURCE_SEPOLIA]: sepolia,
|
|
127
194
|
[SOURCE_BASE_MAINNET]: base,
|
|
128
195
|
[SOURCE_BSC_MAINNET]: bsc,
|
|
129
196
|
};
|
|
130
197
|
export function getChainName(chainId) {
|
|
131
|
-
return
|
|
198
|
+
return ALL_CHAIN_CONFIGS[chainId]?.name ?? "Unknown";
|
|
199
|
+
}
|
|
200
|
+
export function getChainSlug(chainId) {
|
|
201
|
+
return ALL_CHAIN_CONFIGS[chainId]?.slug ?? "unknown";
|
|
202
|
+
}
|
|
203
|
+
export function getChainIdBySlug(slug) {
|
|
204
|
+
const chainId = Object.values(ALL_CHAIN_CONFIGS).find((config) => config.slug === slug)?.chainId;
|
|
205
|
+
return chainId;
|
|
132
206
|
}
|
|
133
207
|
export const getViemChain = (chainId) => {
|
|
134
208
|
return VIEM_CHAIN_BY_CHAIN_ID[chainId];
|
|
135
209
|
};
|
|
136
210
|
export function getHighExecutionFee(chainId) {
|
|
137
|
-
return
|
|
211
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.highExecutionFee ?? 5;
|
|
138
212
|
}
|
|
139
213
|
export function getExcessiveExecutionFee(chainId) {
|
|
140
|
-
return
|
|
214
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.excessiveExecutionFee ?? 10;
|
|
141
215
|
}
|
|
142
216
|
export function isContractsChain(chainId, dev = false) {
|
|
143
217
|
return (dev ? CONTRACTS_CHAIN_IDS_DEV : CONTRACTS_CHAIN_IDS).includes(chainId);
|
|
144
218
|
}
|
|
145
219
|
export function isTestnetChain(chainId) {
|
|
146
|
-
return [AVALANCHE_FUJI, ARBITRUM_SEPOLIA].includes(chainId);
|
|
220
|
+
return [AVALANCHE_FUJI, ARBITRUM_SEPOLIA, SOURCE_SEPOLIA, SOURCE_OPTIMISM_SEPOLIA].includes(chainId);
|
|
221
|
+
}
|
|
222
|
+
export function getMaxFeePerGas(chainId) {
|
|
223
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.maxFeePerGas;
|
|
224
|
+
}
|
|
225
|
+
export function getGasPricePremium(chainId) {
|
|
226
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.gasPricePremium;
|
|
227
|
+
}
|
|
228
|
+
export function getMaxPriorityFeePerGas(chainId) {
|
|
229
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.maxPriorityFeePerGas;
|
|
230
|
+
}
|
|
231
|
+
export function getMinExecutionFeeUsd(chainId) {
|
|
232
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.minExecutionFee;
|
|
233
|
+
}
|
|
234
|
+
export function getGasPriceBuffer(chainId) {
|
|
235
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.gasPriceBuffer;
|
|
236
|
+
}
|
|
237
|
+
export function isChainDisabled(chainId) {
|
|
238
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.isDisabled ?? false;
|
|
239
|
+
}
|
|
240
|
+
export function getChainNativeTokenSymbol(chainId) {
|
|
241
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.nativeTokenSymbol;
|
|
242
|
+
}
|
|
243
|
+
export function getChainWrappedTokenSymbol(chainId) {
|
|
244
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.wrappedTokenSymbol;
|
|
245
|
+
}
|
|
246
|
+
export function getChainDefaultCollateralSymbol(chainId) {
|
|
247
|
+
return CONTRACTS_CHAIN_CONFIGS[chainId]?.defaultCollateralSymbol;
|
|
248
|
+
}
|
|
249
|
+
export function getExplorerUrl(chainId) {
|
|
250
|
+
switch (chainId) {
|
|
251
|
+
case "layerzero":
|
|
252
|
+
return "https://layerzeroscan.com/";
|
|
253
|
+
case "layerzero-testnet":
|
|
254
|
+
return "https://testnet.layerzeroscan.com/";
|
|
255
|
+
default:
|
|
256
|
+
return ALL_CHAIN_CONFIGS[chainId]?.explorerUrl ?? "";
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
export function getTokenExplorerUrl(chainId, tokenAddress) {
|
|
260
|
+
return `${getExplorerUrl(chainId)}token/${tokenAddress}`;
|
|
261
|
+
}
|
|
262
|
+
export function getExecutionFeeConfig(chainId) {
|
|
263
|
+
const config = CONTRACTS_CHAIN_CONFIGS[chainId];
|
|
264
|
+
if (!config) {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
return {
|
|
268
|
+
shouldUseMaxPriorityFeePerGas: config.shouldUseMaxPriorityFeePerGas,
|
|
269
|
+
defaultBufferBps: config.defaultExecutionFeeBufferBps,
|
|
270
|
+
};
|
|
147
271
|
}
|
|
148
|
-
export const EXECUTION_FEE_CONFIG_V2 = {
|
|
149
|
-
[AVALANCHE]: {
|
|
150
|
-
shouldUseMaxPriorityFeePerGas: true,
|
|
151
|
-
defaultBufferBps: 1000, // 10%
|
|
152
|
-
},
|
|
153
|
-
[AVALANCHE_FUJI]: {
|
|
154
|
-
shouldUseMaxPriorityFeePerGas: true,
|
|
155
|
-
defaultBufferBps: 1000, // 10%
|
|
156
|
-
},
|
|
157
|
-
[ARBITRUM]: {
|
|
158
|
-
shouldUseMaxPriorityFeePerGas: false,
|
|
159
|
-
defaultBufferBps: 3000, // 30%
|
|
160
|
-
},
|
|
161
|
-
[ARBITRUM_SEPOLIA]: {
|
|
162
|
-
shouldUseMaxPriorityFeePerGas: false,
|
|
163
|
-
defaultBufferBps: 1000, // 10%
|
|
164
|
-
},
|
|
165
|
-
[BOTANIX]: {
|
|
166
|
-
shouldUseMaxPriorityFeePerGas: true,
|
|
167
|
-
defaultBufferBps: 3000, // 30%
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
export const GAS_LIMITS_STATIC_CONFIG = {
|
|
171
|
-
[ARBITRUM]: {
|
|
172
|
-
createOrderGasLimit: 1000000n,
|
|
173
|
-
updateOrderGasLimit: 800000n,
|
|
174
|
-
cancelOrderGasLimit: 700000n,
|
|
175
|
-
tokenPermitGasLimit: 90000n,
|
|
176
|
-
gmxAccountCollateralGasLimit: 0n,
|
|
177
|
-
},
|
|
178
|
-
[AVALANCHE]: {
|
|
179
|
-
createOrderGasLimit: 1000000n,
|
|
180
|
-
updateOrderGasLimit: 800000n,
|
|
181
|
-
cancelOrderGasLimit: 700000n,
|
|
182
|
-
tokenPermitGasLimit: 90000n,
|
|
183
|
-
gmxAccountCollateralGasLimit: 0n,
|
|
184
|
-
},
|
|
185
|
-
[AVALANCHE_FUJI]: {
|
|
186
|
-
createOrderGasLimit: 1000000n,
|
|
187
|
-
updateOrderGasLimit: 800000n,
|
|
188
|
-
cancelOrderGasLimit: 700000n,
|
|
189
|
-
tokenPermitGasLimit: 90000n,
|
|
190
|
-
gmxAccountCollateralGasLimit: 0n,
|
|
191
|
-
},
|
|
192
|
-
[ARBITRUM_SEPOLIA]: {
|
|
193
|
-
createOrderGasLimit: 1000000n,
|
|
194
|
-
updateOrderGasLimit: 800000n,
|
|
195
|
-
cancelOrderGasLimit: 1500000n,
|
|
196
|
-
tokenPermitGasLimit: 90000n,
|
|
197
|
-
gmxAccountCollateralGasLimit: 400000n,
|
|
198
|
-
},
|
|
199
|
-
[BOTANIX]: {
|
|
200
|
-
createOrderGasLimit: 1000000n,
|
|
201
|
-
updateOrderGasLimit: 800000n,
|
|
202
|
-
cancelOrderGasLimit: 700000n,
|
|
203
|
-
tokenPermitGasLimit: 90000n,
|
|
204
|
-
gmxAccountCollateralGasLimit: 0n,
|
|
205
|
-
},
|
|
206
|
-
};
|
|
@@ -32,7 +32,6 @@ export const CONTRACTS = {
|
|
|
32
32
|
PositionRouter: "0xb87a436B93fFE9D75c5cFA7bAcFff96430b09868",
|
|
33
33
|
UniswapGmxEthPool: "0x80A9ae39310abf666A87C743d6ebBD0E8C42158E",
|
|
34
34
|
ReferralStorage: "0xe6fab3f0c7199b0d34d7fbe83394fc0e0d06e99d",
|
|
35
|
-
Timelock: "0xaa50bD556CE0Fe61D4A57718BA43177a3aB6A597",
|
|
36
35
|
// Synthetics
|
|
37
36
|
DataStore: "0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8",
|
|
38
37
|
EventEmitter: "0xC8ee91A54287DB53897056e12D9819156D3822Fb",
|
|
@@ -56,7 +55,7 @@ export const CONTRACTS = {
|
|
|
56
55
|
MultichainSubaccountRouter: "0x70AaAd50d53732b2D5534bb57332D00aE20cAd36",
|
|
57
56
|
MultichainTransferRouter: "0xfaBEb65bB877600be3A2C2a03aA56a95F9f845B9",
|
|
58
57
|
MultichainVault: "0xCeaadFAf6A8C489B250e407987877c5fDfcDBE6E",
|
|
59
|
-
LayerZeroProvider: "
|
|
58
|
+
LayerZeroProvider: "0xB6DE222dAef5029f31b8fABE498D34f3c491Ef85",
|
|
60
59
|
ChainlinkPriceFeedProvider: "0x38B8dB61b724b51e42A88Cb8eC564CD685a0f53B",
|
|
61
60
|
ClaimHandler: "0x8a83F2a71A53d3860a60C9F2E68AB2C46Ff9624e",
|
|
62
61
|
// External
|
|
@@ -98,7 +97,6 @@ export const CONTRACTS = {
|
|
|
98
97
|
PositionRouter: "0xffF6D276Bc37c61A23f06410Dce4A400f66420f8",
|
|
99
98
|
TraderJoeGmxAvaxPool: "0x0c91a070f862666bbcce281346be45766d874d98",
|
|
100
99
|
ReferralStorage: "0x827ed045002ecdabeb6e2b0d1604cf5fc3d322f8",
|
|
101
|
-
Timelock: "0x8A68a039D555599Fd745f9343e8dE20C9eaFca75",
|
|
102
100
|
// Synthetics
|
|
103
101
|
DataStore: "0x2F0b22339414ADeD7D5F06f9D604c7fF5b2fe3f6",
|
|
104
102
|
EventEmitter: "0xDb17B211c34240B014ab6d61d4A31FA0C0e20c26",
|
|
@@ -244,7 +242,6 @@ export const CONTRACTS = {
|
|
|
244
242
|
ShiftVault: "0x257D0EA0B040E2Cd1D456fB4C66d7814102aD346",
|
|
245
243
|
SyntheticsReader: "0xf82Cc6EB57F8FF86bc5c5e90B8BA83DbBFB517eE",
|
|
246
244
|
SyntheticsRouter: "0x5e7d61e4C52123ADF651961e4833aCc349b61491",
|
|
247
|
-
Timelock: zeroAddress,
|
|
248
245
|
GlvReader: "0xdeaC9ea3c72C102f2a9654b8E1A14Ef86Cdd3146",
|
|
249
246
|
GlvRouter: "0x6B6595389A0196F882C0f66CB1F401f1D24afEdC",
|
|
250
247
|
GlvVault: "0x76f93b5240DF811a3fc32bEDd58daA5784e46C96",
|
|
@@ -329,7 +326,6 @@ export const CONTRACTS = {
|
|
|
329
326
|
GlpManager: zeroAddress,
|
|
330
327
|
RewardReader: zeroAddress,
|
|
331
328
|
GlpRewardRouter: zeroAddress,
|
|
332
|
-
Timelock: zeroAddress,
|
|
333
329
|
},
|
|
334
330
|
};
|
|
335
331
|
export function getContract(chainId, name) {
|
|
@@ -7,6 +7,7 @@ export const SWAP_IMPACT_FACTOR_KEY = hashString("SWAP_IMPACT_FACTOR");
|
|
|
7
7
|
export const SWAP_IMPACT_EXPONENT_FACTOR_KEY = hashString("SWAP_IMPACT_EXPONENT_FACTOR");
|
|
8
8
|
export const SWAP_FEE_FACTOR_KEY = hashString("SWAP_FEE_FACTOR");
|
|
9
9
|
export const ATOMIC_SWAP_FEE_FACTOR_KEY = hashString("ATOMIC_SWAP_FEE_FACTOR");
|
|
10
|
+
export const WITHDRAWAL_FEE_FACTOR_KEY = hashString("WITHDRAWAL_FEE_FACTOR");
|
|
10
11
|
export const FEE_RECEIVER_DEPOSIT_FACTOR_KEY = hashString("FEE_RECEIVER_DEPOSIT_FACTOR");
|
|
11
12
|
export const BORROWING_FEE_RECEIVER_FACTOR_KEY = hashString("BORROWING_FEE_RECEIVER_FACTOR");
|
|
12
13
|
export const FEE_RECEIVER_WITHDRAWAL_FACTOR_KEY = hashString("FEE_RECEIVER_WITHDRAWAL_FACTOR");
|
|
@@ -3,7 +3,7 @@ import { periodToSeconds } from "../utils/time";
|
|
|
3
3
|
import { ARBITRUM, ARBITRUM_SEPOLIA, AVALANCHE, AVALANCHE_FUJI, BOTANIX } from "./chains";
|
|
4
4
|
import { getTokenBySymbol, getWrappedToken } from "./tokens";
|
|
5
5
|
export const SUBACCOUNT_MESSAGE = "Generate a GMX 1CT (One-Click Trading) session. Only sign this message on a trusted website.";
|
|
6
|
-
export const SUBACCOUNT_DOCS_URL = "https://docs.gmx.io/docs/trading
|
|
6
|
+
export const SUBACCOUNT_DOCS_URL = "https://docs.gmx.io/docs/trading/#one-click-trading";
|
|
7
7
|
export const DEFAULT_SUBACCOUNT_EXPIRY_DURATION = periodToSeconds(7, "1d"); // 1 week
|
|
8
8
|
export const DEFAULT_SUBACCOUNT_MAX_ALLOWED_COUNT = 90;
|
|
9
9
|
export const DEFAULT_PERMIT_DEADLINE_DURATION = periodToSeconds(1, "1h");
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ARBITRUM, AVALANCHE, AVALANCHE_FUJI, ARBITRUM_SEPOLIA, BOTANIX } from "./chainIds";
|
|
2
|
+
export const GAS_LIMITS_STATIC_CONFIG = {
|
|
3
|
+
[ARBITRUM]: {
|
|
4
|
+
createOrderGasLimit: 1000000n,
|
|
5
|
+
updateOrderGasLimit: 800000n,
|
|
6
|
+
cancelOrderGasLimit: 700000n,
|
|
7
|
+
tokenPermitGasLimit: 90000n,
|
|
8
|
+
gmxAccountCollateralGasLimit: 0n,
|
|
9
|
+
},
|
|
10
|
+
[AVALANCHE]: {
|
|
11
|
+
createOrderGasLimit: 1000000n,
|
|
12
|
+
updateOrderGasLimit: 800000n,
|
|
13
|
+
cancelOrderGasLimit: 700000n,
|
|
14
|
+
tokenPermitGasLimit: 90000n,
|
|
15
|
+
gmxAccountCollateralGasLimit: 0n,
|
|
16
|
+
},
|
|
17
|
+
[AVALANCHE_FUJI]: {
|
|
18
|
+
createOrderGasLimit: 1000000n,
|
|
19
|
+
updateOrderGasLimit: 800000n,
|
|
20
|
+
cancelOrderGasLimit: 700000n,
|
|
21
|
+
tokenPermitGasLimit: 90000n,
|
|
22
|
+
gmxAccountCollateralGasLimit: 0n,
|
|
23
|
+
},
|
|
24
|
+
[ARBITRUM_SEPOLIA]: {
|
|
25
|
+
createOrderGasLimit: 1000000n,
|
|
26
|
+
updateOrderGasLimit: 800000n,
|
|
27
|
+
cancelOrderGasLimit: 1500000n,
|
|
28
|
+
tokenPermitGasLimit: 90000n,
|
|
29
|
+
gmxAccountCollateralGasLimit: 400000n,
|
|
30
|
+
},
|
|
31
|
+
[BOTANIX]: {
|
|
32
|
+
createOrderGasLimit: 1000000n,
|
|
33
|
+
updateOrderGasLimit: 800000n,
|
|
34
|
+
cancelOrderGasLimit: 700000n,
|
|
35
|
+
tokenPermitGasLimit: 90000n,
|
|
36
|
+
gmxAccountCollateralGasLimit: 0n,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
This files is used to pre-build data during the build process.
|
|
3
3
|
Avoid adding client-side code here, as it can break the build process.
|
|
4
4
|
*/
|
|
5
|
+
import { zeroAddress } from "viem";
|
|
5
6
|
import { ARBITRUM, ARBITRUM_SEPOLIA, AVALANCHE, AVALANCHE_FUJI, BOTANIX } from "./chains";
|
|
6
|
-
import { getTokenBySymbol } from "./tokens";
|
|
7
|
+
import { convertTokenAddress, getToken, getTokenBySymbol } from "./tokens";
|
|
7
8
|
export const SWAP_GRAPH_MAX_MARKETS_PER_TOKEN = 5;
|
|
8
9
|
/*
|
|
9
10
|
ATTENTION
|
|
@@ -809,6 +810,62 @@ export const MARKETS = {
|
|
|
809
810
|
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
|
|
810
811
|
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
811
812
|
},
|
|
813
|
+
// MON/USD [WETH-USDC]
|
|
814
|
+
"0x66AB9D61A0124b61C8892A4ac687Ac48DbA8ff2c": {
|
|
815
|
+
marketTokenAddress: "0x66AB9D61A0124b61C8892A4ac687Ac48DbA8ff2c",
|
|
816
|
+
indexTokenAddress: "0xB96e60CA3a7677b29f1e10dd109E952B275038Be",
|
|
817
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
818
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
819
|
+
},
|
|
820
|
+
// ZEC/USD [WBTC.e-USDC]
|
|
821
|
+
"0x587759c237acCa739bCE3911647BacF56C876E60": {
|
|
822
|
+
marketTokenAddress: "0x587759c237acCa739bCE3911647BacF56C876E60",
|
|
823
|
+
indexTokenAddress: "0x6eAbbaA3278556Dc5b19c034dc26c0eaB60d65B5",
|
|
824
|
+
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
|
|
825
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
826
|
+
},
|
|
827
|
+
// SKY/USD [WETH-USDC]
|
|
828
|
+
"0x00310c6d8A9F821e3FE991f4835f2cA4d87034Cf": {
|
|
829
|
+
marketTokenAddress: "0x00310c6d8A9F821e3FE991f4835f2cA4d87034Cf",
|
|
830
|
+
indexTokenAddress: "0xeeA41ceA2204D1156De1BDF2CF4ab6184d17f90B",
|
|
831
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
832
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
833
|
+
},
|
|
834
|
+
// AR/USD [WBTC-USDC]
|
|
835
|
+
"0xfa19f7d23a475575BD0270AE7de4FC6852442945": {
|
|
836
|
+
marketTokenAddress: "0xfa19f7d23a475575BD0270AE7de4FC6852442945",
|
|
837
|
+
indexTokenAddress: "0x4b9a2b862E1a30e6E844c991D31Dc6387c9d65D5",
|
|
838
|
+
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
|
|
839
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
840
|
+
},
|
|
841
|
+
// DASH/USD [WBTC-USDC]
|
|
842
|
+
"0x728Ff0679c89267434D6EF1824c8C8eED4aC3DBC": {
|
|
843
|
+
marketTokenAddress: "0x728Ff0679c89267434D6EF1824c8C8eED4aC3DBC",
|
|
844
|
+
indexTokenAddress: "0x426FE015a5F4E6Ad4E6497ad79265D07EA9F121e",
|
|
845
|
+
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
|
|
846
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
847
|
+
},
|
|
848
|
+
// JTO/USD [WBTC-USDC]
|
|
849
|
+
"0x3B4689d69516b9D4b1aaf7545c6fC4d3ED70b70b": {
|
|
850
|
+
marketTokenAddress: "0x3B4689d69516b9D4b1aaf7545c6fC4d3ED70b70b",
|
|
851
|
+
indexTokenAddress: "0xF01D2AA2f3f903A93D57c4Bf672C8096DE485FA7",
|
|
852
|
+
longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
|
|
853
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
854
|
+
},
|
|
855
|
+
// SYRUP/USD [WETH-USDC]
|
|
856
|
+
"0x8965e821c7C8c09c6eB3Cb9cCf7Eb6f386441EA2": {
|
|
857
|
+
marketTokenAddress: "0x8965e821c7C8c09c6eB3Cb9cCf7Eb6f386441EA2",
|
|
858
|
+
indexTokenAddress: "0x9759C297fb6C91e252c7292cECa30a509558E5De",
|
|
859
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
860
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
861
|
+
},
|
|
862
|
+
// CHZ/USD [WETH-USDC]
|
|
863
|
+
"0x3600592DdEd7e6E0B05029DfB637fFc5A85D6f6B": {
|
|
864
|
+
marketTokenAddress: "0x3600592DdEd7e6E0B05029DfB637fFc5A85D6f6B",
|
|
865
|
+
indexTokenAddress: "0x5dB4692926C8ceebF6Da0995358Bbc438F3fd80C",
|
|
866
|
+
longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
867
|
+
shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
868
|
+
},
|
|
812
869
|
},
|
|
813
870
|
[AVALANCHE]: {
|
|
814
871
|
// BTC/USD [BTC-USDC]
|
|
@@ -1155,6 +1212,12 @@ export const MARKETS = {
|
|
|
1155
1212
|
},
|
|
1156
1213
|
},
|
|
1157
1214
|
};
|
|
1215
|
+
export function getMarketsByChainId(chainId) {
|
|
1216
|
+
if (!MARKETS[chainId]) {
|
|
1217
|
+
throw new Error(`Markets not found for chainId ${chainId}`);
|
|
1218
|
+
}
|
|
1219
|
+
return MARKETS[chainId];
|
|
1220
|
+
}
|
|
1158
1221
|
export function getMarketByLabel(chainId, label) {
|
|
1159
1222
|
const marketsByAddress = MARKETS[chainId];
|
|
1160
1223
|
if (!marketsByAddress) {
|
|
@@ -1201,3 +1264,34 @@ export const fixTokenSymbolFromMarketLabel = (chainId, symbol) => {
|
|
|
1201
1264
|
}
|
|
1202
1265
|
return symbol;
|
|
1203
1266
|
};
|
|
1267
|
+
export function isMarketTokenAddress(chainId, marketTokenAddress) {
|
|
1268
|
+
return Boolean(MARKETS[chainId]?.[marketTokenAddress]);
|
|
1269
|
+
}
|
|
1270
|
+
export function getTokenAddressByMarket(chainId, marketTokenAddress, tokenType) {
|
|
1271
|
+
const market = MARKETS[chainId][marketTokenAddress];
|
|
1272
|
+
if (tokenType === "index") {
|
|
1273
|
+
return convertTokenAddress(chainId, market.indexTokenAddress, "native");
|
|
1274
|
+
}
|
|
1275
|
+
if (tokenType === "long") {
|
|
1276
|
+
return market.longTokenAddress;
|
|
1277
|
+
}
|
|
1278
|
+
return market.shortTokenAddress;
|
|
1279
|
+
}
|
|
1280
|
+
export function getMarketIndexToken(chainId, marketTokenAddress) {
|
|
1281
|
+
const indexTokenAddress = getTokenAddressByMarket(chainId, marketTokenAddress, "index");
|
|
1282
|
+
return getToken(chainId, indexTokenAddress);
|
|
1283
|
+
}
|
|
1284
|
+
export function getTokenSymbolByMarket(chainId, marketTokenAddress, tokenType) {
|
|
1285
|
+
const tokenAddress = getTokenAddressByMarket(chainId, marketTokenAddress, tokenType);
|
|
1286
|
+
return getToken(chainId, tokenAddress).symbol;
|
|
1287
|
+
}
|
|
1288
|
+
export function getIsSpotOnlyMarket(chainId, marketTokenAddress) {
|
|
1289
|
+
return MARKETS[chainId][marketTokenAddress].indexTokenAddress === zeroAddress;
|
|
1290
|
+
}
|
|
1291
|
+
export function getMarketIsSameCollaterals(chainId, marketTokenAddress) {
|
|
1292
|
+
const market = MARKETS[chainId][marketTokenAddress];
|
|
1293
|
+
if (!market) {
|
|
1294
|
+
return false;
|
|
1295
|
+
}
|
|
1296
|
+
return market.longTokenAddress === market.shortTokenAddress;
|
|
1297
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ARBITRUM_SEPOLIA, ARBITRUM, AVALANCHE, SOURCE_OPTIMISM_SEPOLIA, SOURCE_SEPOLIA, SOURCE_BASE_MAINNET, SOURCE_BSC_MAINNET, } from "./chainIds";
|
|
1
|
+
import { ARBITRUM_SEPOLIA, ARBITRUM, AVALANCHE, SOURCE_OPTIMISM_SEPOLIA, SOURCE_SEPOLIA, SOURCE_BASE_MAINNET, SOURCE_BSC_MAINNET, SOURCE_ETHEREUM_MAINNET, } from "./chainIds";
|
|
2
2
|
function ensureExhaustive(value) {
|
|
3
3
|
return Object.keys(value).map(Number);
|
|
4
4
|
}
|
|
@@ -12,6 +12,7 @@ export const SOURCE_CHAINS = ensureExhaustive({
|
|
|
12
12
|
[SOURCE_SEPOLIA]: true,
|
|
13
13
|
[SOURCE_BASE_MAINNET]: true,
|
|
14
14
|
[SOURCE_BSC_MAINNET]: true,
|
|
15
|
+
[SOURCE_ETHEREUM_MAINNET]: true,
|
|
15
16
|
});
|
|
16
17
|
export function isSettlementChain(chainId) {
|
|
17
18
|
return SETTLEMENT_CHAINS.includes(chainId);
|