@gmx-io/sdk 1.4.0 → 1.4.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/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 +67 -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 +53 -14
- 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 +2 -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 +24 -0
- package/build/cjs/src/prebuilt/hashedMarketConfigKeys.json +495 -0
- package/build/cjs/src/prebuilt/hashedMarketValuesKeys.json +45 -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__/mockRouting.spec.js +7 -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 +10 -9
- 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 +4 -0
- package/build/cjs/src/utils/tokens.js +17 -1
- package/build/cjs/src/utils/trade/decrease.js +1 -1
- 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 +60 -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 +52 -13
- 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 +3 -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 +24 -0
- package/build/esm/src/prebuilt/hashedMarketConfigKeys.json +495 -0
- package/build/esm/src/prebuilt/hashedMarketValuesKeys.json +45 -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__/mockRouting.spec.js +7 -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 +10 -9
- 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 +4 -0
- package/build/esm/src/utils/tokens.js +15 -1
- package/build/esm/src/utils/trade/decrease.js +2 -2
- 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 -3
- 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 +6 -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 +1 -1
- package/build/types/src/utils/tokens.d.ts +3 -0
- package/package.json +8 -2
- 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
|
@@ -2,6 +2,11 @@ import { zeroAddress } from "viem";
|
|
|
2
2
|
import { ARBITRUM, ARBITRUM_SEPOLIA, AVALANCHE, AVALANCHE_FUJI, BOTANIX } from "./chains";
|
|
3
3
|
import { getContract } from "./contracts";
|
|
4
4
|
export const NATIVE_TOKEN_ADDRESS = zeroAddress;
|
|
5
|
+
export const GM_STUB_ADDRESS = "<GM-ADDRESS>";
|
|
6
|
+
export const GLV_STUB_ADDRESS = "<GLV-ADDRESS>";
|
|
7
|
+
const GMX_STUB_ADDRESS = "<GMX-ADDRESS>";
|
|
8
|
+
const ESGMX_STUB_ADDRESS = "<ESGMX-ADDRESS>";
|
|
9
|
+
const GLP_STUB_ADDRESS = "<GLP-ADDRESS>";
|
|
5
10
|
export const TOKENS = {
|
|
6
11
|
[ARBITRUM]: [
|
|
7
12
|
{
|
|
@@ -1023,7 +1028,7 @@ export const TOKENS = {
|
|
|
1023
1028
|
{
|
|
1024
1029
|
name: "GMX Market tokens",
|
|
1025
1030
|
symbol: "GM",
|
|
1026
|
-
address:
|
|
1031
|
+
address: GM_STUB_ADDRESS,
|
|
1027
1032
|
decimals: 18,
|
|
1028
1033
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GM_LOGO.png",
|
|
1029
1034
|
isPlatformToken: true,
|
|
@@ -1031,7 +1036,7 @@ export const TOKENS = {
|
|
|
1031
1036
|
{
|
|
1032
1037
|
name: "GLV Market tokens",
|
|
1033
1038
|
symbol: "GLV",
|
|
1034
|
-
address:
|
|
1039
|
+
address: GLV_STUB_ADDRESS,
|
|
1035
1040
|
decimals: 18,
|
|
1036
1041
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GLV_LOGO.png",
|
|
1037
1042
|
isPlatformToken: true,
|
|
@@ -1245,6 +1250,39 @@ export const TOKENS = {
|
|
|
1245
1250
|
coingeckoUrl: "https://www.coingecko.com/en/coins/linea",
|
|
1246
1251
|
isSynthetic: true,
|
|
1247
1252
|
},
|
|
1253
|
+
{
|
|
1254
|
+
name: "Monad",
|
|
1255
|
+
symbol: "MON",
|
|
1256
|
+
address: "0xB96e60CA3a7677b29f1e10dd109E952B275038Be",
|
|
1257
|
+
decimals: 18,
|
|
1258
|
+
priceDecimals: 6,
|
|
1259
|
+
categories: ["layer1", "defi"],
|
|
1260
|
+
imageUrl: "https://assets.coingecko.com/coins/images/38927/standard/mon.png?1766029057",
|
|
1261
|
+
coingeckoUrl: "https://www.coingecko.com/en/coins/monad",
|
|
1262
|
+
isSynthetic: true,
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
name: "Sky",
|
|
1266
|
+
symbol: "SKY",
|
|
1267
|
+
address: "0xeeA41ceA2204D1156De1BDF2CF4ab6184d17f90B",
|
|
1268
|
+
decimals: 18,
|
|
1269
|
+
priceDecimals: 6,
|
|
1270
|
+
categories: ["defi"],
|
|
1271
|
+
imageUrl: "https://assets.coingecko.com/coins/images/39925/standard/sky.jpg?1724827980",
|
|
1272
|
+
coingeckoUrl: "https://www.coingecko.com/en/coins/sky",
|
|
1273
|
+
isSynthetic: true,
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
name: "Zcash",
|
|
1277
|
+
symbol: "ZEC",
|
|
1278
|
+
address: "0x6eAbbaA3278556Dc5b19c034dc26c0eaB60d65B5",
|
|
1279
|
+
decimals: 8,
|
|
1280
|
+
priceDecimals: 3,
|
|
1281
|
+
categories: ["layer1"],
|
|
1282
|
+
imageUrl: "https://assets.coingecko.com/coins/images/486/standard/circle-zcash-color.png?1696501740",
|
|
1283
|
+
coingeckoUrl: "https://www.coingecko.com/en/coins/zcash",
|
|
1284
|
+
isSynthetic: true,
|
|
1285
|
+
},
|
|
1248
1286
|
],
|
|
1249
1287
|
[AVALANCHE]: [
|
|
1250
1288
|
{
|
|
@@ -1532,7 +1570,7 @@ export const TOKENS = {
|
|
|
1532
1570
|
{
|
|
1533
1571
|
name: "GMX Market tokens",
|
|
1534
1572
|
symbol: "GM",
|
|
1535
|
-
address:
|
|
1573
|
+
address: GM_STUB_ADDRESS,
|
|
1536
1574
|
decimals: 18,
|
|
1537
1575
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GM_LOGO.png",
|
|
1538
1576
|
isPlatformToken: true,
|
|
@@ -1540,7 +1578,7 @@ export const TOKENS = {
|
|
|
1540
1578
|
{
|
|
1541
1579
|
name: "GLV Market tokens",
|
|
1542
1580
|
symbol: "GLV",
|
|
1543
|
-
address:
|
|
1581
|
+
address: GLV_STUB_ADDRESS,
|
|
1544
1582
|
decimals: 18,
|
|
1545
1583
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GLV_LOGO.png",
|
|
1546
1584
|
isPlatformToken: true,
|
|
@@ -1762,7 +1800,7 @@ export const TOKENS = {
|
|
|
1762
1800
|
{
|
|
1763
1801
|
name: "GMX Market tokens",
|
|
1764
1802
|
symbol: "GM",
|
|
1765
|
-
address:
|
|
1803
|
+
address: GM_STUB_ADDRESS,
|
|
1766
1804
|
decimals: 18,
|
|
1767
1805
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GM_LOGO.png",
|
|
1768
1806
|
isPlatformToken: true,
|
|
@@ -1770,7 +1808,7 @@ export const TOKENS = {
|
|
|
1770
1808
|
{
|
|
1771
1809
|
name: "GLV Market tokens",
|
|
1772
1810
|
symbol: "GLV",
|
|
1773
|
-
address:
|
|
1811
|
+
address: GLV_STUB_ADDRESS,
|
|
1774
1812
|
decimals: 18,
|
|
1775
1813
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GLV_LOGO.png",
|
|
1776
1814
|
isPlatformToken: true,
|
|
@@ -1849,7 +1887,7 @@ export const TOKENS = {
|
|
|
1849
1887
|
{
|
|
1850
1888
|
name: "GMX",
|
|
1851
1889
|
symbol: "GMX",
|
|
1852
|
-
address:
|
|
1890
|
+
address: GMX_STUB_ADDRESS,
|
|
1853
1891
|
decimals: 18,
|
|
1854
1892
|
imageUrl: "https://assets.coingecko.com/coins/images/18323/small/arbit.png?1631532468",
|
|
1855
1893
|
isPlatformToken: true,
|
|
@@ -1857,14 +1895,14 @@ export const TOKENS = {
|
|
|
1857
1895
|
{
|
|
1858
1896
|
name: "Escrowed GMX",
|
|
1859
1897
|
symbol: "ESGMX",
|
|
1860
|
-
address:
|
|
1898
|
+
address: ESGMX_STUB_ADDRESS,
|
|
1861
1899
|
decimals: 18,
|
|
1862
1900
|
isPlatformToken: true,
|
|
1863
1901
|
},
|
|
1864
1902
|
{
|
|
1865
1903
|
name: "GMX LP",
|
|
1866
1904
|
symbol: "GLP",
|
|
1867
|
-
address:
|
|
1905
|
+
address: GLP_STUB_ADDRESS,
|
|
1868
1906
|
decimals: 18,
|
|
1869
1907
|
imageUrl: "https://github.com/gmx-io/gmx-assets/blob/main/GMX-Assets/PNG/GLP_LOGO%20ONLY.png?raw=true",
|
|
1870
1908
|
isPlatformToken: true,
|
|
@@ -1872,7 +1910,7 @@ export const TOKENS = {
|
|
|
1872
1910
|
{
|
|
1873
1911
|
name: "GMX Market tokens",
|
|
1874
1912
|
symbol: "GM",
|
|
1875
|
-
address:
|
|
1913
|
+
address: GM_STUB_ADDRESS,
|
|
1876
1914
|
decimals: 18,
|
|
1877
1915
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GM_LOGO.png",
|
|
1878
1916
|
isPlatformToken: true,
|
|
@@ -1880,7 +1918,7 @@ export const TOKENS = {
|
|
|
1880
1918
|
{
|
|
1881
1919
|
name: "GLV Market tokens",
|
|
1882
1920
|
symbol: "GLV",
|
|
1883
|
-
address:
|
|
1921
|
+
address: GLV_STUB_ADDRESS,
|
|
1884
1922
|
decimals: 18,
|
|
1885
1923
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GLV_LOGO.png",
|
|
1886
1924
|
isPlatformToken: true,
|
|
@@ -1975,7 +2013,7 @@ export const TOKENS = {
|
|
|
1975
2013
|
{
|
|
1976
2014
|
name: "GMX Market tokens",
|
|
1977
2015
|
symbol: "GM",
|
|
1978
|
-
address:
|
|
2016
|
+
address: GM_STUB_ADDRESS,
|
|
1979
2017
|
decimals: 18,
|
|
1980
2018
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GM_LOGO.png",
|
|
1981
2019
|
isPlatformToken: true,
|
|
@@ -1983,7 +2021,7 @@ export const TOKENS = {
|
|
|
1983
2021
|
{
|
|
1984
2022
|
name: "GLV Market tokens",
|
|
1985
2023
|
symbol: "GLV",
|
|
1986
|
-
address:
|
|
2024
|
+
address: GLV_STUB_ADDRESS,
|
|
1987
2025
|
decimals: 18,
|
|
1988
2026
|
imageUrl: "https://raw.githubusercontent.com/gmx-io/gmx-assets/main/GMX-Assets/PNG/GLV_LOGO.png",
|
|
1989
2027
|
isPlatformToken: true,
|
|
@@ -1997,6 +2035,7 @@ export const TOKEN_COLOR_MAP = {
|
|
|
1997
2035
|
PBTC: "#F7931A",
|
|
1998
2036
|
USDC: "#2775CA",
|
|
1999
2037
|
"USDC.E": "#2A5ADA",
|
|
2038
|
+
"USDC.SG": "#2775CA",
|
|
2000
2039
|
USDT: "#67B18A",
|
|
2001
2040
|
MIM: "#9695F8",
|
|
2002
2041
|
FRAX: "#000",
|
|
@@ -170,6 +170,8 @@ export class Markets extends Module {
|
|
|
170
170
|
atomicSwapFeeFactor: dataStoreValues.atomicSwapFeeFactor.returnValues[0],
|
|
171
171
|
swapImpactFactorNegative: dataStoreValues.swapImpactFactorNegative.returnValues[0],
|
|
172
172
|
swapImpactExponentFactor: dataStoreValues.swapImpactExponentFactor.returnValues[0],
|
|
173
|
+
withdrawalFeeFactorBalanceWasImproved: dataStoreValues.withdrawalFeeFactorBalanceWasImproved.returnValues[0],
|
|
174
|
+
withdrawalFeeFactorBalanceWasNotImproved: dataStoreValues.withdrawalFeeFactorBalanceWasNotImproved.returnValues[0],
|
|
173
175
|
virtualMarketId: dataStoreValues.virtualMarketId.returnValues[0],
|
|
174
176
|
virtualLongTokenId: dataStoreValues.virtualLongTokenId.returnValues[0],
|
|
175
177
|
virtualShortTokenId: dataStoreValues.virtualShortTokenId.returnValues[0],
|
|
@@ -205,8 +207,8 @@ export class Markets extends Module {
|
|
|
205
207
|
};
|
|
206
208
|
});
|
|
207
209
|
}
|
|
208
|
-
async getMarkets(offset = 0n, limit =
|
|
209
|
-
if (this._marketsData) {
|
|
210
|
+
async getMarkets(offset = 0n, limit = 300n) {
|
|
211
|
+
if (this._marketsData && this._marketsDataOffset === offset && this._marketsDataLimit === limit) {
|
|
210
212
|
return this._marketsData;
|
|
211
213
|
}
|
|
212
214
|
const readerAddress = getContract(this.chainId, "SyntheticsReader");
|
|
@@ -273,6 +275,8 @@ export class Markets extends Module {
|
|
|
273
275
|
return acc;
|
|
274
276
|
}, { marketsData: {}, marketsAddresses: [] });
|
|
275
277
|
this._marketsData = marketsResult;
|
|
278
|
+
this._marketsDataOffset = offset;
|
|
279
|
+
this._marketsDataLimit = limit;
|
|
276
280
|
return marketsResult;
|
|
277
281
|
}
|
|
278
282
|
async getMarketsInfo() {
|
|
@@ -3,12 +3,12 @@ import { arbitrumSdk, arbitrumSdkConfig } from "../../utils/testUtil";
|
|
|
3
3
|
import { GmxSdk } from "../../index";
|
|
4
4
|
describe("Markets", () => {
|
|
5
5
|
describe("getMarkets", () => {
|
|
6
|
-
it("should be able to get markets data", async () => {
|
|
6
|
+
it("should be able to get markets data", { timeout: 90000 }, async () => {
|
|
7
7
|
const marketsData = await arbitrumSdk.markets.getMarkets();
|
|
8
8
|
expect(marketsData.marketsAddresses).toBeDefined();
|
|
9
9
|
expect(marketsData.marketsData).toBeDefined();
|
|
10
10
|
});
|
|
11
|
-
it("should respect config filters", async () => {
|
|
11
|
+
it("should respect config filters", { timeout: 90000 }, async () => {
|
|
12
12
|
const sdk = new GmxSdk({
|
|
13
13
|
...arbitrumSdkConfig,
|
|
14
14
|
markets: {
|
|
@@ -24,15 +24,15 @@ describe("Markets", () => {
|
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
describe("getMarketsInfo", () => {
|
|
27
|
-
it("should be able to get markets info", async () => {
|
|
27
|
+
it("should be able to get markets info", { timeout: 90000 }, async () => {
|
|
28
28
|
const response = await arbitrumSdk.markets.getMarketsInfo();
|
|
29
29
|
expect(response).toBeDefined();
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
describe("getDailyVolumes", () => {
|
|
33
|
-
it("should be able to get daily volumes", async () => {
|
|
33
|
+
it("should be able to get daily volumes", { timeout: 90000 }, async () => {
|
|
34
34
|
const response = await arbitrumSdk.markets.getDailyVolumes();
|
|
35
35
|
expect(response).toBeDefined();
|
|
36
|
-
}
|
|
36
|
+
});
|
|
37
37
|
});
|
|
38
38
|
});
|
|
@@ -385,6 +385,14 @@ export async function buildMarketsConfigsRequest(chainId, { marketsData, markets
|
|
|
385
385
|
methodName: "getUint",
|
|
386
386
|
params: [prebuiltHashedKeys.swapImpactExponentFactor],
|
|
387
387
|
},
|
|
388
|
+
withdrawalFeeFactorBalanceWasImproved: {
|
|
389
|
+
methodName: "getUint",
|
|
390
|
+
params: [prebuiltHashedKeys.withdrawalFeeFactorBalanceWasImproved],
|
|
391
|
+
},
|
|
392
|
+
withdrawalFeeFactorBalanceWasNotImproved: {
|
|
393
|
+
methodName: "getUint",
|
|
394
|
+
params: [prebuiltHashedKeys.withdrawalFeeFactorBalanceWasNotImproved],
|
|
395
|
+
},
|
|
388
396
|
virtualMarketId: {
|
|
389
397
|
methodName: "getBytes32",
|
|
390
398
|
params: [prebuiltHashedKeys.virtualMarketId],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OrderType } from "../../types/orders";
|
|
1
|
+
import { OrderType, SwapPricingType } from "../../types/orders";
|
|
2
2
|
import { getByKey } from "../../utils/objects";
|
|
3
3
|
import { getSwapAmountsByFromValue, getSwapAmountsByToValue } from "../../utils/swap";
|
|
4
4
|
import { createFindSwapPath } from "../../utils/swap/swapPath";
|
|
@@ -76,7 +76,7 @@ export async function increaseOrderHelper(sdk, params) {
|
|
|
76
76
|
gasPrice,
|
|
77
77
|
tokensData,
|
|
78
78
|
},
|
|
79
|
-
|
|
79
|
+
swapPricingType: SwapPricingType.Swap,
|
|
80
80
|
});
|
|
81
81
|
const payOrSizeAmount = "payAmount" in params ? params.payAmount : params.sizeAmount;
|
|
82
82
|
const increaseAmounts = getIncreasePositionAmounts({
|
|
@@ -166,7 +166,7 @@ export async function swap(sdk, params) {
|
|
|
166
166
|
gasPrice,
|
|
167
167
|
tokensData,
|
|
168
168
|
},
|
|
169
|
-
|
|
169
|
+
swapPricingType: SwapPricingType.Swap,
|
|
170
170
|
});
|
|
171
171
|
const isWrapOrUnwrap = Boolean(fromToken && toToken && (getIsWrap(fromToken, toToken) || getIsUnwrap(fromToken, toToken)));
|
|
172
172
|
if (isWrapOrUnwrap) {
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import { arbitrumSdk } from "../../utils/testUtil";
|
|
3
3
|
describe("Positions", () => {
|
|
4
4
|
describe("read", () => {
|
|
5
|
-
it("should be able to get orders", async () => {
|
|
5
|
+
it("should be able to get orders", { timeout: 90000 }, async () => {
|
|
6
6
|
const { marketsInfoData, tokensData } = (await arbitrumSdk.markets.getMarketsInfo()) ?? {};
|
|
7
7
|
if (!tokensData || !marketsInfoData) {
|
|
8
8
|
throw new Error("Tokens data or markets info is not available");
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import { arbitrumSdk } from "../../utils/testUtil";
|
|
3
3
|
describe("Positions", () => {
|
|
4
4
|
describe("getPositions", () => {
|
|
5
|
-
it("should be able to get positions data", async () => {
|
|
5
|
+
it("should be able to get positions data", { timeout: 90000 }, async () => {
|
|
6
6
|
const { marketsInfoData, tokensData } = (await arbitrumSdk.markets.getMarketsInfo()) ?? {};
|
|
7
7
|
if (!tokensData || !marketsInfoData) {
|
|
8
8
|
throw new Error("Tokens data or markets info is not available");
|
|
@@ -10,7 +10,7 @@ describe("Positions", () => {
|
|
|
10
10
|
const positions = await arbitrumSdk.positions.getPositions({ tokensData, marketsData: marketsInfoData });
|
|
11
11
|
expect(positions).toBeDefined();
|
|
12
12
|
});
|
|
13
|
-
it("should be able to get positions info", async () => {
|
|
13
|
+
it("should be able to get positions info", { timeout: 90000 }, async () => {
|
|
14
14
|
const { marketsInfoData, tokensData } = (await arbitrumSdk.markets.getMarketsInfo()) ?? {};
|
|
15
15
|
if (!tokensData || !marketsInfoData) {
|
|
16
16
|
throw new Error("Tokens data or markets info is not available");
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import { arbitrumSdk, arbitrumSdkConfig } from "../../utils/testUtil";
|
|
3
3
|
import { GmxSdk } from "../..";
|
|
4
4
|
describe("Tokens", () => {
|
|
5
|
-
it("should be able to fetch tokens", async () => {
|
|
5
|
+
it("should be able to fetch tokens", { timeout: 90000 }, async () => {
|
|
6
6
|
const response = await arbitrumSdk.oracle.getTokens();
|
|
7
7
|
expect(response).toBeDefined();
|
|
8
8
|
});
|
|
@@ -20,7 +20,7 @@ describe("Tokens", () => {
|
|
|
20
20
|
expect(sdk.tokens.tokensConfig[ARB]?.symbol).toBe("testARB");
|
|
21
21
|
expect(data.tokensData?.[ARB].symbol).toBe("testARB");
|
|
22
22
|
});
|
|
23
|
-
it("should be able to get tokens data", async () => {
|
|
23
|
+
it("should be able to get tokens data", { timeout: 90000 }, async () => {
|
|
24
24
|
const response = await arbitrumSdk.tokens.getTokensData();
|
|
25
25
|
expect(response).toBeDefined();
|
|
26
26
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { arbitrumSdk } from "../../utils/testUtil";
|
|
3
3
|
describe("Trades", () => {
|
|
4
|
-
it("should be able to get positions", async () => {
|
|
4
|
+
it("should be able to get positions", { timeout: 90000 }, async () => {
|
|
5
5
|
const { marketsInfoData, tokensData } = await arbitrumSdk.markets.getMarketsInfo();
|
|
6
6
|
const trades = await arbitrumSdk.trades.getTradeHistory({
|
|
7
7
|
forAllAccounts: false,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { withRetry } from "viem";
|
|
2
|
-
import {
|
|
2
|
+
import { getExecutionFeeConfig, getGasPricePremium, getMaxPriorityFeePerGas, getViemChain, } from "../../configs/chains";
|
|
3
3
|
import { getContract } from "../../configs/contracts";
|
|
4
4
|
import { decreaseOrderGasLimitKey, depositGasLimitKey, ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1, ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR, ESTIMATED_GAS_FEE_PER_ORACLE_PRICE, GELATO_RELAY_FEE_MULTIPLIER_FACTOR_KEY, GLV_DEPOSIT_GAS_LIMIT, GLV_PER_MARKET_GAS_LIMIT, GLV_WITHDRAWAL_GAS_LIMIT, increaseOrderGasLimitKey, shiftGasLimitKey, singleSwapGasLimitKey, swapOrderGasLimitKey, uiFeeFactorKey, withdrawalGasLimitKey, } from "../../configs/dataStore";
|
|
5
|
+
import { GAS_LIMITS_STATIC_CONFIG } from "../../configs/gasLimits";
|
|
5
6
|
import { bigMath } from "../../utils/bigmath";
|
|
6
7
|
import { estimateOrderOraclePriceCount } from "../../utils/fees/estimateOraclePriceCount";
|
|
7
8
|
import { estimateExecuteDecreaseOrderGasLimit, estimateExecuteIncreaseOrderGasLimit, estimateExecuteSwapOrderGasLimit, getExecutionFee, } from "../../utils/fees/executionFee";
|
|
@@ -172,7 +173,7 @@ export class Utils extends Module {
|
|
|
172
173
|
return getExecutionFee(this.chainId, gasLimits, tokensData, estimatedGas, gasPrice, oraclePriceCount);
|
|
173
174
|
}
|
|
174
175
|
async getGasPrice() {
|
|
175
|
-
const executionFeeConfig =
|
|
176
|
+
const executionFeeConfig = getExecutionFeeConfig(this.chainId);
|
|
176
177
|
const feeData = await withRetry(() => this.sdk.publicClient.estimateFeesPerGas({
|
|
177
178
|
chain: getViemChain(this.chainId),
|
|
178
179
|
type: "legacy",
|
|
@@ -184,13 +185,13 @@ export class Utils extends Module {
|
|
|
184
185
|
},
|
|
185
186
|
});
|
|
186
187
|
let gasPrice = feeData.gasPrice ?? 0n;
|
|
187
|
-
if (executionFeeConfig
|
|
188
|
-
const maxPriorityFeePerGas = bigMath.max(feeData?.maxPriorityFeePerGas ?? 0n,
|
|
188
|
+
if (executionFeeConfig?.shouldUseMaxPriorityFeePerGas) {
|
|
189
|
+
const maxPriorityFeePerGas = bigMath.max(feeData?.maxPriorityFeePerGas ?? 0n, getMaxPriorityFeePerGas(this.chainId) || 0n);
|
|
189
190
|
gasPrice = gasPrice + maxPriorityFeePerGas;
|
|
190
191
|
}
|
|
191
|
-
const premium =
|
|
192
|
+
const premium = getGasPricePremium(this.chainId) || 0n;
|
|
192
193
|
const price = gasPrice + premium;
|
|
193
|
-
return
|
|
194
|
+
return BigInt(price);
|
|
194
195
|
}
|
|
195
196
|
async getUiFeeFactor() {
|
|
196
197
|
if (this._uiFeeFactor) {
|
|
@@ -937,6 +937,30 @@
|
|
|
937
937
|
"baseBorrowingFactorShort": "0x420abcc48ffb985a690715aa2b538b95a3f63030f25937dc92d929503644ac74",
|
|
938
938
|
"aboveOptimalUsageBorrowingFactorLong": "0x357d8148aa930b7242653068b7a92fe6430b13a2461daaef913357788d198154",
|
|
939
939
|
"aboveOptimalUsageBorrowingFactorShort": "0x30441063c794feabe17080369a2b2ed756b28c18440a4e95d99242656014e524"
|
|
940
|
+
},
|
|
941
|
+
"0x66AB9D61A0124b61C8892A4ac687Ac48DbA8ff2c": {
|
|
942
|
+
"optimalUsageFactorLong": "0x2cad24e20c277d7f5d15e1ad883481451a46795ee99fcc06daf76114fa3f4ea4",
|
|
943
|
+
"optimalUsageFactorShort": "0x85950d6dae75c22c28212d750531eac58910d63e0d6e0b7968e6aed46a883d8b",
|
|
944
|
+
"baseBorrowingFactorLong": "0x5544458f656bfdf07463e02d9f37a9d124c03e5bb7c40b58d63ca0dc5711739d",
|
|
945
|
+
"baseBorrowingFactorShort": "0x60a57fe035177054d68dc68eb42e1b1560af301cc7d6bba51308167307b529b3",
|
|
946
|
+
"aboveOptimalUsageBorrowingFactorLong": "0xbcb0f4cf170454232e15621cf6bb2e15df23885305f1e4dd42c0d190009445ae",
|
|
947
|
+
"aboveOptimalUsageBorrowingFactorShort": "0x9aad04a946bbc2cf52b78cc92c6acb5c9c1980532e2444f5881a569f7efed575"
|
|
948
|
+
},
|
|
949
|
+
"0x587759c237acCa739bCE3911647BacF56C876E60": {
|
|
950
|
+
"optimalUsageFactorLong": "0x891b86b566f2c8bb0e8c45bcb976fb0f810122c022eac16ff9c579d195a73441",
|
|
951
|
+
"optimalUsageFactorShort": "0x8c236450ac9ff8ccbdb245613178845b9546fcd78869e1d490b5cbe8632cd731",
|
|
952
|
+
"baseBorrowingFactorLong": "0x6f55990e6024b64971d5b0c5f52611fcd80c730731298b1a1cc07996a71357fa",
|
|
953
|
+
"baseBorrowingFactorShort": "0xd66969b8ace1317938aee497955951a451b98cad7007b8108874a312e8c7723a",
|
|
954
|
+
"aboveOptimalUsageBorrowingFactorLong": "0xee2488d7e15a8cf6864f9ed2e82d1fba5dccef82b0c27639a460a169e5931ff0",
|
|
955
|
+
"aboveOptimalUsageBorrowingFactorShort": "0xecc81ea6500775be76e5b9f46a1d6bb62d01a63b8d027c6b8f0de46b5938eb2b"
|
|
956
|
+
},
|
|
957
|
+
"0x00310c6d8A9F821e3FE991f4835f2cA4d87034Cf": {
|
|
958
|
+
"optimalUsageFactorLong": "0x67907416cf716a8ab58e27f24dcf1cb2d5d2c42c3fe8c72018c67e96fa681892",
|
|
959
|
+
"optimalUsageFactorShort": "0xb88c05d1ecbacb28b55b268be130d519f1b85996e7bd78980dbefdeaec357ba5",
|
|
960
|
+
"baseBorrowingFactorLong": "0x1f5cc0e47162ceb52a4376ba4144358dc22d9f4ec8e608dc43ac6e7e9ed8b0b8",
|
|
961
|
+
"baseBorrowingFactorShort": "0x751c8941b4092c9a3ad24fed4204fd80472691e95370bd1fbef865e86da75d77",
|
|
962
|
+
"aboveOptimalUsageBorrowingFactorLong": "0x55e15ee294aa6f6b23491893e6b067805930a7fe5e98629675738761cf1d1f6f",
|
|
963
|
+
"aboveOptimalUsageBorrowingFactorShort": "0xcc46958a3873436f86a9484b826b92d81745e593f5550b125002610d7fd431b1"
|
|
940
964
|
}
|
|
941
965
|
},
|
|
942
966
|
"43113": {
|