@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.
Files changed (151) hide show
  1. package/build/cjs/src/abis/GlvReader.js +940 -940
  2. package/build/cjs/src/abis/IStargate.js +603 -0
  3. package/build/cjs/src/abis/LayerZeroProvider.js +273 -46
  4. package/build/cjs/src/abis/index.js +2 -2
  5. package/build/cjs/src/configs/batch.js +29 -103
  6. package/build/cjs/src/configs/chainIds.js +2 -2
  7. package/build/cjs/src/configs/chains.js +230 -151
  8. package/build/cjs/src/configs/contracts.js +1 -5
  9. package/build/cjs/src/configs/dataStore.js +5 -4
  10. package/build/cjs/src/configs/express.js +1 -1
  11. package/build/cjs/src/configs/gasLimits.js +41 -0
  12. package/build/cjs/src/configs/markets.js +67 -1
  13. package/build/cjs/src/configs/multichain.js +1 -0
  14. package/build/cjs/src/configs/oracleKeeper.js +18 -20
  15. package/build/cjs/src/configs/tokens.js +53 -14
  16. package/build/cjs/src/modules/markets/index.js +6 -2
  17. package/build/cjs/src/modules/markets/markets.spec.js +5 -5
  18. package/build/cjs/src/modules/markets/query-builders.js +8 -0
  19. package/build/cjs/src/modules/orders/helpers.js +2 -2
  20. package/build/cjs/src/modules/orders/helpers.spec.js +1 -1
  21. package/build/cjs/src/modules/orders/orders.spec.js +1 -1
  22. package/build/cjs/src/modules/positions/positions.spec.js +2 -2
  23. package/build/cjs/src/modules/tokens/tokens.spec.js +2 -2
  24. package/build/cjs/src/modules/trades/trades.spec.js +1 -1
  25. package/build/cjs/src/modules/utils/utils.js +7 -6
  26. package/build/cjs/src/prebuilt/hashedKinkModelMarketRatesKeys.json +24 -0
  27. package/build/cjs/src/prebuilt/hashedMarketConfigKeys.json +495 -0
  28. package/build/cjs/src/prebuilt/hashedMarketValuesKeys.json +45 -0
  29. package/build/cjs/src/test/mock.js +2 -0
  30. package/build/cjs/src/types/chains.js +2 -0
  31. package/build/cjs/src/types/orders.js +8 -2
  32. package/build/cjs/src/types/subsquid.js +241 -1
  33. package/build/cjs/src/types/tokens.js +7 -0
  34. package/build/cjs/src/utils/__tests__/abort.spec.js +122 -0
  35. package/build/cjs/src/utils/__tests__/numbers.spec.js +94 -14
  36. package/build/cjs/src/utils/abort.js +31 -0
  37. package/build/cjs/src/utils/callContract.js +4 -4
  38. package/build/cjs/src/utils/fees/executionFee.js +14 -11
  39. package/build/cjs/src/utils/fees/index.js +8 -2
  40. package/build/cjs/src/utils/marketKeysAndConfigs.js +8 -0
  41. package/build/cjs/src/utils/markets.js +7 -1
  42. package/build/cjs/src/utils/multicall.js +54 -17
  43. package/build/cjs/src/utils/numbers.js +25 -14
  44. package/build/cjs/src/utils/orders.js +2 -2
  45. package/build/cjs/src/utils/swap/__tests__/mockRouting.spec.js +7 -6
  46. package/build/cjs/src/utils/swap/__tests__/swapRouting.spec.js +5 -4
  47. package/build/cjs/src/utils/swap/__tests__/swapStats.spec.js +10 -9
  48. package/build/cjs/src/utils/swap/buildSwapStrategy.js +10 -9
  49. package/build/cjs/src/utils/swap/swapPath.js +6 -6
  50. package/build/cjs/src/utils/swap/swapRouting.js +8 -4
  51. package/build/cjs/src/utils/swap/swapStats.js +6 -6
  52. package/build/cjs/src/utils/swap/swapValues.js +4 -0
  53. package/build/cjs/src/utils/tokens.js +17 -1
  54. package/build/cjs/src/utils/trade/decrease.js +1 -1
  55. package/build/esm/src/abis/GlvReader.js +940 -940
  56. package/build/esm/src/abis/IStargate.js +601 -0
  57. package/build/esm/src/abis/LayerZeroProvider.js +273 -46
  58. package/build/esm/src/abis/index.js +2 -2
  59. package/build/esm/src/configs/batch.js +30 -104
  60. package/build/esm/src/configs/chainIds.js +1 -1
  61. package/build/esm/src/configs/chains.js +212 -147
  62. package/build/esm/src/configs/contracts.js +1 -5
  63. package/build/esm/src/configs/dataStore.js +1 -0
  64. package/build/esm/src/configs/express.js +1 -1
  65. package/build/esm/src/configs/gasLimits.js +38 -0
  66. package/build/esm/src/configs/markets.js +60 -1
  67. package/build/esm/src/configs/multichain.js +2 -1
  68. package/build/esm/src/configs/oracleKeeper.js +17 -19
  69. package/build/esm/src/configs/tokens.js +52 -13
  70. package/build/esm/src/modules/markets/index.js +6 -2
  71. package/build/esm/src/modules/markets/markets.spec.js +5 -5
  72. package/build/esm/src/modules/markets/query-builders.js +8 -0
  73. package/build/esm/src/modules/orders/helpers.js +3 -3
  74. package/build/esm/src/modules/orders/helpers.spec.js +1 -1
  75. package/build/esm/src/modules/orders/orders.spec.js +1 -1
  76. package/build/esm/src/modules/positions/positions.spec.js +2 -2
  77. package/build/esm/src/modules/tokens/tokens.spec.js +2 -2
  78. package/build/esm/src/modules/trades/trades.spec.js +1 -1
  79. package/build/esm/src/modules/utils/utils.js +7 -6
  80. package/build/esm/src/prebuilt/hashedKinkModelMarketRatesKeys.json +24 -0
  81. package/build/esm/src/prebuilt/hashedMarketConfigKeys.json +495 -0
  82. package/build/esm/src/prebuilt/hashedMarketValuesKeys.json +45 -0
  83. package/build/esm/src/test/mock.js +2 -0
  84. package/build/esm/src/types/chains.js +1 -0
  85. package/build/esm/src/types/orders.js +8 -2
  86. package/build/esm/src/types/subsquid.js +240 -0
  87. package/build/esm/src/types/tokens.js +6 -1
  88. package/build/esm/src/utils/__tests__/abort.spec.js +120 -0
  89. package/build/esm/src/utils/__tests__/numbers.spec.js +95 -15
  90. package/build/esm/src/utils/abort.js +27 -0
  91. package/build/esm/src/utils/callContract.js +5 -5
  92. package/build/esm/src/utils/fees/executionFee.js +15 -12
  93. package/build/esm/src/utils/fees/index.js +8 -2
  94. package/build/esm/src/utils/marketKeysAndConfigs.js +9 -1
  95. package/build/esm/src/utils/markets.js +5 -0
  96. package/build/esm/src/utils/multicall.js +53 -16
  97. package/build/esm/src/utils/numbers.js +21 -12
  98. package/build/esm/src/utils/orders.js +3 -3
  99. package/build/esm/src/utils/swap/__tests__/mockRouting.spec.js +7 -6
  100. package/build/esm/src/utils/swap/__tests__/swapRouting.spec.js +5 -4
  101. package/build/esm/src/utils/swap/__tests__/swapStats.spec.js +10 -9
  102. package/build/esm/src/utils/swap/buildSwapStrategy.js +10 -9
  103. package/build/esm/src/utils/swap/swapPath.js +6 -6
  104. package/build/esm/src/utils/swap/swapRouting.js +8 -4
  105. package/build/esm/src/utils/swap/swapStats.js +6 -6
  106. package/build/esm/src/utils/swap/swapValues.js +4 -0
  107. package/build/esm/src/utils/tokens.js +15 -1
  108. package/build/esm/src/utils/trade/decrease.js +2 -2
  109. package/build/types/src/abis/IStargate.d.ts +464 -0
  110. package/build/types/src/abis/LayerZeroProvider.d.ts +12 -0
  111. package/build/types/src/abis/index.d.ts +475 -99
  112. package/build/types/src/configs/chainIds.d.ts +1 -1
  113. package/build/types/src/configs/chains.d.ts +170 -27
  114. package/build/types/src/configs/contracts.d.ts +0 -4
  115. package/build/types/src/configs/dataStore.d.ts +1 -0
  116. package/build/types/src/configs/express.d.ts +1 -1
  117. package/build/types/src/configs/gasLimits.d.ts +4 -0
  118. package/build/types/src/configs/markets.d.ts +10 -1
  119. package/build/types/src/configs/oracleKeeper.d.ts +13 -0
  120. package/build/types/src/configs/tokens.d.ts +3 -0
  121. package/build/types/src/index.d.ts +1 -1
  122. package/build/types/src/modules/base.d.ts +1 -1
  123. package/build/types/src/modules/markets/index.d.ts +2 -0
  124. package/build/types/src/modules/markets/query-builders.d.ts +1 -1
  125. package/build/types/src/modules/markets/types.d.ts +2 -2
  126. package/build/types/src/modules/utils/utils.d.ts +2 -3
  127. package/build/types/src/types/chains.d.ts +57 -0
  128. package/build/types/src/types/markets.d.ts +2 -0
  129. package/build/types/src/types/orders.d.ts +8 -2
  130. package/build/types/src/types/subsquid.d.ts +5987 -5172
  131. package/build/types/src/types/tokens.d.ts +11 -3
  132. package/build/types/src/types/trade.d.ts +5 -0
  133. package/build/types/src/utils/__tests__/abort.spec.d.ts +1 -0
  134. package/build/types/src/utils/abort.d.ts +1 -0
  135. package/build/types/src/utils/fees/estimateOraclePriceCount.d.ts +2 -2
  136. package/build/types/src/utils/fees/executionFee.d.ts +6 -6
  137. package/build/types/src/utils/fees/index.d.ts +2 -1
  138. package/build/types/src/utils/marketKeysAndConfigs.d.ts +2 -0
  139. package/build/types/src/utils/markets.d.ts +4 -2
  140. package/build/types/src/utils/multicall.d.ts +4 -2
  141. package/build/types/src/utils/numbers.d.ts +8 -1
  142. package/build/types/src/utils/swap/buildSwapStrategy.d.ts +6 -3
  143. package/build/types/src/utils/swap/swapPath.d.ts +2 -1
  144. package/build/types/src/utils/swap/swapRouting.d.ts +7 -2
  145. package/build/types/src/utils/swap/swapStats.d.ts +3 -2
  146. package/build/types/src/utils/swap/swapValues.d.ts +1 -1
  147. package/build/types/src/utils/tokens.d.ts +3 -0
  148. package/package.json +8 -2
  149. package/build/cjs/src/abis/MultichainUtils.js +0 -133
  150. package/build/esm/src/abis/MultichainUtils.js +0 -131
  151. package/build/types/src/abis/MultichainUtils.d.ts +0 -100
@@ -102,14 +102,22 @@ export type TokenPrices = {
102
102
  minPrice: bigint;
103
103
  maxPrice: bigint;
104
104
  };
105
+ export declare enum TokenBalanceType {
106
+ Wallet = 0,
107
+ GmxAccount = 1,
108
+ SourceChain = 2
109
+ }
105
110
  export type TokenAsyncData = {
106
111
  prices: TokenPrices;
107
- isGmxAccount?: boolean;
108
112
  walletBalance?: bigint;
109
113
  gmxAccountBalance?: bigint;
110
114
  /**
111
- * If isGmxAccount is true, then this is the gmx account balance
112
- * If isGmxAccount is false, then this is the wallet balance
115
+ * In source chain decimals, use `getMappedTokenId` to get the decimals
116
+ */
117
+ sourceChainBalance?: bigint;
118
+ balanceType?: TokenBalanceType;
119
+ /**
120
+ * Balance according to the balanceType
113
121
  */
114
122
  balance?: bigint;
115
123
  totalSupply?: bigint;
@@ -126,10 +126,14 @@ export type DepositAmounts = {
126
126
  export type WithdrawalAmounts = {
127
127
  marketTokenAmount: bigint;
128
128
  marketTokenUsd: bigint;
129
+ longTokenBeforeSwapAmount: bigint;
129
130
  longTokenAmount: bigint;
131
+ longTokenSwapPathStats: SwapPathStats | undefined;
130
132
  shortTokenAmount: bigint;
133
+ shortTokenBeforeSwapAmount: bigint;
131
134
  longTokenUsd: bigint;
132
135
  shortTokenUsd: bigint;
136
+ shortTokenSwapPathStats: SwapPathStats | undefined;
133
137
  glvTokenAmount: bigint;
134
138
  glvTokenUsd: bigint;
135
139
  swapFeeUsd: bigint;
@@ -298,6 +302,7 @@ export type GmSwapFees = {
298
302
  swapPriceImpact?: FeeItem;
299
303
  uiFee?: FeeItem;
300
304
  shiftFee?: FeeItem;
305
+ logicalNetworkFee?: FeeItem;
301
306
  };
302
307
  export type TradeSearchParams = {
303
308
  from?: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function combineAbortSignals(...signals: AbortSignal[]): AbortController;
@@ -1,5 +1,5 @@
1
- export declare function estimateDepositOraclePriceCount(swapsCount: number): bigint;
2
- export declare function estimateWithdrawalOraclePriceCount(swapsCount: number): bigint;
1
+ export declare function estimateDepositOraclePriceCount(swapsCount: number | bigint): bigint;
2
+ export declare function estimateWithdrawalOraclePriceCount(swapsCount: bigint): bigint;
3
3
  export declare function estimateOrderOraclePriceCount(swapsCount: number): bigint;
4
4
  export declare function estimateShiftOraclePriceCount(): bigint;
5
5
  export declare function estimateGlvDepositOraclePriceCount(marketCount: bigint, swapsCount?: bigint): bigint;
@@ -63,18 +63,17 @@ export declare function estimateExecuteSwapOrderGasLimit(gasLimits: GasLimitsCon
63
63
  * Copy from contract: `estimateExecuteDepositGasLimit`
64
64
  */
65
65
  export declare function estimateExecuteDepositGasLimit(gasLimits: GasLimitsConfig, deposit: {
66
- longTokenSwapsCount?: number;
67
- shortTokenSwapsCount?: number;
66
+ swapsCount?: number | bigint;
68
67
  callbackGasLimit?: bigint;
69
68
  }): bigint;
70
- export declare function estimateExecuteGlvDepositGasLimit(gasLimits: GasLimitsConfig, { marketsCount, isMarketTokenDeposit, }: {
69
+ export declare function estimateExecuteGlvDepositGasLimit(gasLimits: GasLimitsConfig, { marketsCount, isMarketTokenDeposit, swapsCount, }: {
71
70
  isMarketTokenDeposit: boolean;
72
71
  marketsCount: bigint;
73
- initialLongTokenAmount: bigint;
74
- initialShortTokenAmount: bigint;
72
+ swapsCount: bigint;
75
73
  }): bigint;
76
- export declare function estimateExecuteGlvWithdrawalGasLimit(gasLimits: GasLimitsConfig, { marketsCount, }: {
74
+ export declare function estimateExecuteGlvWithdrawalGasLimit(gasLimits: GasLimitsConfig, { marketsCount, swapsCount, }: {
77
75
  marketsCount: bigint;
76
+ swapsCount: bigint;
78
77
  }): bigint;
79
78
  /**
80
79
  * Only GM withdrawals. Do not confuse with decrease with zero delta size.
@@ -83,6 +82,7 @@ export declare function estimateExecuteGlvWithdrawalGasLimit(gasLimits: GasLimit
83
82
  */
84
83
  export declare function estimateExecuteWithdrawalGasLimit(gasLimits: GasLimitsConfig, withdrawal: {
85
84
  callbackGasLimit?: bigint;
85
+ swapsCount?: bigint;
86
86
  }): bigint;
87
87
  /**
88
88
  * Copy from contract: `estimateExecuteShiftGasLimit`
@@ -1,10 +1,11 @@
1
1
  import { FeeItem } from "../../types/fees";
2
2
  import { MarketInfo } from "../../types/markets";
3
+ import { SwapPricingType } from "../../types/orders";
3
4
  import { SwapStats } from "../../types/trade";
4
5
  export * from "./estimateOraclePriceCount";
5
6
  export * from "./executionFee";
6
7
  export * from "./priceImpact";
7
- export declare function getSwapFee(marketInfo: MarketInfo, swapAmount: bigint, balanceWasImproved: boolean, isAtomicSwap: boolean): bigint;
8
+ export declare function getSwapFee(marketInfo: MarketInfo, swapAmount: bigint, balanceWasImproved: boolean, swapPricingType: SwapPricingType): bigint;
8
9
  export declare function getPositionFee(marketInfo: MarketInfo, sizeDeltaUsd: bigint, balanceWasImproved: boolean, referralInfo: {
9
10
  totalRebateFactor: bigint;
10
11
  discountFactor: bigint;
@@ -50,6 +50,8 @@ export declare function hashMarketConfigKeys(market: MarketConfig): {
50
50
  swapImpactFactorPositive: string;
51
51
  swapImpactFactorNegative: string;
52
52
  swapImpactExponentFactor: string;
53
+ withdrawalFeeFactorBalanceWasImproved: string;
54
+ withdrawalFeeFactorBalanceWasNotImproved: string;
53
55
  virtualMarketId: string;
54
56
  virtualLongTokenId: string;
55
57
  virtualShortTokenId: string;
@@ -1,5 +1,6 @@
1
- import { ContractMarketPrices, Market, MarketInfo } from "../types/markets";
2
- import { Token, TokenPrices, TokensData } from "../types/tokens";
1
+ import type { MarketConfig } from "../configs/markets";
2
+ import type { ContractMarketPrices, Market, MarketInfo } from "../types/markets";
3
+ import type { Token, TokenPrices, TokensData } from "../types/tokens";
3
4
  export declare function getMarketFullName(p: {
4
5
  longToken: Token;
5
6
  shortToken: Token;
@@ -42,6 +43,7 @@ export declare function getCappedPoolPnl(p: {
42
43
  export declare function getMaxLeverageByMinCollateralFactor(minCollateralFactor: bigint | undefined): number;
43
44
  export declare function getMaxAllowedLeverageByMinCollateralFactor(minCollateralFactor: bigint | undefined): number;
44
45
  export declare function getOppositeCollateral(marketInfo: MarketInfo, tokenAddress: string): import("../types/tokens").TokenData | undefined;
46
+ export declare function getOppositeCollateralFromConfig(marketConfig: MarketConfig, tokenAddress: string): string;
45
47
  export declare function getAvailableUsdLiquidityForCollateral(marketInfo: MarketInfo, isLong: boolean): bigint;
46
48
  export declare function getReservedUsd(marketInfo: MarketInfo, isLong: boolean): bigint;
47
49
  export declare function getMarketDivisor({ longTokenAddress, shortTokenAddress, }: {
@@ -1,6 +1,8 @@
1
1
  import { AbiId } from "../abis";
2
2
  import type { GmxSdk } from "index";
3
- export declare const MAX_TIMEOUT = 20000;
3
+ export declare const MAX_TIMEOUT = 40000;
4
+ export declare const MAX_CALLS_PER_BATCH = 500;
5
+ export declare const MAX_CONCURRENT_BATCHES = 3;
4
6
  export type MulticallProviderUrls = {
5
7
  primary: string;
6
8
  secondary: string;
@@ -12,7 +14,7 @@ export declare class Multicall {
12
14
  };
13
15
  static getInstance(sdk: GmxSdk): Promise<Multicall>;
14
16
  constructor(sdk: GmxSdk);
15
- get chainId(): import("../configs/chains").ContractsChainId;
17
+ get chainId(): 43114 | 42161 | 3637 | 43113 | 421614;
16
18
  call(request: MulticallRequestConfig<any>, maxTimeout: number): Promise<MulticallResult<any>>;
17
19
  }
18
20
  export type SkipKey = null | undefined | false;
@@ -10,9 +10,16 @@ export declare const BN_ZERO = 0n;
10
10
  export declare const BN_ONE = 1n;
11
11
  export declare const BN_NEGATIVE_ONE = -1n;
12
12
  export declare const MaxUint256: bigint;
13
+ export declare const MaxInt256: bigint;
13
14
  export declare const PERCENT_PRECISION_DECIMALS: number;
14
15
  export declare const TRIGGER_PREFIX_ABOVE = ">";
15
16
  export declare const TRIGGER_PREFIX_BELOW = "<";
17
+ declare const __nonZero: unique symbol;
18
+ export type NonZero<T extends number | bigint> = T & {
19
+ readonly [__nonZero]: true;
20
+ };
21
+ export declare function isNonZero<T extends number | bigint>(value: T): value is NonZero<T>;
22
+ export declare function safeDivide<T extends number | bigint>(a: T, b: NonZero<T>): T;
16
23
  export declare function expandDecimals(n: BigNumberish, decimals: number): bigint;
17
24
  export declare function basisPointsToFloat(basisPoints: bigint): bigint;
18
25
  export declare function getBasisPoints(numerator: bigint, denominator: bigint, shouldRoundUp?: boolean): bigint;
@@ -129,7 +136,7 @@ type DeserializeBigIntInObject<T> = {
129
136
  };
130
137
  export declare function serializeBigIntsInObject<T extends object>(obj: T): SerializedBigIntsInObject<T>;
131
138
  export declare function deserializeBigIntsInObject<T extends object>(obj: T): DeserializeBigIntInObject<T>;
132
- export declare function calculateDisplayDecimals(price?: bigint, decimals?: number, visualMultiplier?: number, isStable?: boolean): 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
139
+ export declare function calculateDisplayDecimals(price?: bigint, decimals?: number, visualMultiplier?: number, isStable?: boolean): 5 | 2 | 3 | 4 | 6 | 7 | 8 | 9;
133
140
  export declare function clamp(value: number, min: number, max: number): number;
134
141
  export declare function absDiffBps(value: bigint, base: bigint): bigint;
135
142
  export {};
@@ -1,8 +1,9 @@
1
1
  import { MarketsInfoData } from "../../types/markets";
2
+ import { SwapPricingType } from "../../types/orders";
2
3
  import { SwapStrategyForSwapOrders } from "../../types/swapStrategy";
3
4
  import { TokenData } from "../../types/tokens";
4
5
  import { ExternalSwapQuoteParams, SwapOptimizationOrderArray } from "../../types/trade";
5
- export declare function buildSwapStrategy({ amountIn, tokenIn, tokenOut, marketsInfoData, chainId, swapOptimizationOrder, externalSwapQuoteParams, }: {
6
+ export declare function buildSwapStrategy({ amountIn, tokenIn, tokenOut, marketsInfoData, chainId, swapOptimizationOrder, externalSwapQuoteParams, swapPricingType, }: {
6
7
  chainId: number;
7
8
  amountIn: bigint;
8
9
  tokenIn: TokenData;
@@ -10,13 +11,15 @@ export declare function buildSwapStrategy({ amountIn, tokenIn, tokenOut, markets
10
11
  marketsInfoData: MarketsInfoData | undefined;
11
12
  swapOptimizationOrder: SwapOptimizationOrderArray | undefined;
12
13
  externalSwapQuoteParams: ExternalSwapQuoteParams;
14
+ swapPricingType: SwapPricingType;
13
15
  }): SwapStrategyForSwapOrders;
14
- export declare function buildReverseSwapStrategy({ amountOut, tokenIn, tokenOut, marketsInfoData, chainId, externalSwapQuoteParams, swapOptimizationOrder, }: {
16
+ export declare function buildReverseSwapStrategy({ amountOut, tokenIn, tokenOut, marketsInfoData, chainId, externalSwapQuoteParams, swapOptimizationOrder, swapPricingType, }: {
15
17
  chainId: number;
16
18
  amountOut: bigint;
17
19
  tokenIn: TokenData;
18
20
  tokenOut: TokenData;
19
21
  marketsInfoData: MarketsInfoData | undefined;
20
- externalSwapQuoteParams: ExternalSwapQuoteParams;
22
+ externalSwapQuoteParams: ExternalSwapQuoteParams | undefined;
21
23
  swapOptimizationOrder: SwapOptimizationOrderArray | undefined;
24
+ swapPricingType: SwapPricingType;
22
25
  }): SwapStrategyForSwapOrders;
@@ -1,5 +1,6 @@
1
1
  import { GasLimitsConfig } from "../../types/fees";
2
2
  import { MarketsInfoData } from "../../types/markets";
3
+ import { SwapPricingType } from "../../types/orders";
3
4
  import { TokensData } from "../../types/tokens";
4
5
  import { FindSwapPath } from "../../types/trade";
5
6
  export declare const getWrappedAddress: (chainId: number, address: string | undefined) => import("../../types/tokens").ERC20Address | undefined;
@@ -16,7 +17,7 @@ export declare const createFindSwapPath: (params: {
16
17
  gasLimits: GasLimitsConfig;
17
18
  tokensData: TokensData;
18
19
  } | undefined;
19
- isExpressFeeSwap: boolean | undefined;
20
+ swapPricingType: SwapPricingType | undefined;
20
21
  disabledMarkets?: string[] | undefined;
21
22
  manualPath?: string[] | undefined;
22
23
  }) => FindSwapPath;
@@ -1,11 +1,16 @@
1
1
  import { GasLimitsConfig } from "../../types/fees";
2
2
  import { MarketsInfoData } from "../../types/markets";
3
+ import { SwapPricingType } from "../../types/orders";
3
4
  import { TokensData } from "../../types/tokens";
4
5
  import { MarketEdge, MarketEdgeLiquidityGetter, NaiveNetworkEstimator, NaiveSwapEstimator, SwapEstimator, SwapPaths } from "../../types/trade";
5
6
  import { MarketsGraph } from "./buildMarketsAdjacencyGraph";
6
- export declare const createSwapEstimator: (marketsInfoData: MarketsInfoData, isAtomicSwap: boolean) => SwapEstimator;
7
+ export declare const createSwapEstimator: (marketsInfoData: MarketsInfoData, swapPricingType: SwapPricingType) => SwapEstimator;
7
8
  export declare const createMarketEdgeLiquidityGetter: (marketsInfoData: MarketsInfoData) => MarketEdgeLiquidityGetter;
8
- export declare const createNaiveSwapEstimator: (marketsInfoData: MarketsInfoData, isAtomicSwap: boolean) => NaiveSwapEstimator;
9
+ /**
10
+ TODO MLTCH does naive estimator need to know about swap pricing type?
11
+ Its naive for a reason and i think it would work the same without knowing about it
12
+ */
13
+ export declare const createNaiveSwapEstimator: (marketsInfoData: MarketsInfoData, swapPricingType: SwapPricingType) => NaiveSwapEstimator;
9
14
  export declare const createNaiveNetworkEstimator: ({ gasLimits, tokensData, gasPrice, chainId, }: {
10
15
  gasLimits: GasLimitsConfig;
11
16
  tokensData: TokensData;
@@ -1,4 +1,5 @@
1
1
  import { MarketInfo, MarketsInfoData } from "../../types/markets";
2
+ import { SwapPricingType } from "../../types/orders";
2
3
  import { SwapPathStats, SwapStats } from "../../types/trade";
3
4
  export declare function getSwapCapacityUsd(marketInfo: MarketInfo, isLong: boolean): bigint;
4
5
  export declare function getSwapPathOutputAddresses(p: {
@@ -26,7 +27,7 @@ export declare function getSwapPathStats(p: {
26
27
  usdIn: bigint;
27
28
  shouldUnwrapNativeToken: boolean;
28
29
  shouldApplyPriceImpact: boolean;
29
- isAtomicSwap: boolean;
30
+ swapPricingType: SwapPricingType;
30
31
  }): SwapPathStats | undefined;
31
32
  export declare function getSwapStats(p: {
32
33
  marketInfo: MarketInfo;
@@ -34,7 +35,7 @@ export declare function getSwapStats(p: {
34
35
  tokenOutAddress: string;
35
36
  usdIn: bigint;
36
37
  shouldApplyPriceImpact: boolean;
37
- isAtomicSwap: boolean;
38
+ swapPricingType: SwapPricingType;
38
39
  }): SwapStats;
39
40
  export declare function getMaxSwapPathLiquidity(p: {
40
41
  marketsInfoData: MarketsInfoData;
@@ -30,4 +30,4 @@ export declare function getSwapAmountsByToValue(p: {
30
30
  externalSwapQuoteParams: ExternalSwapQuoteParams | undefined;
31
31
  findSwapPath: FindSwapPath;
32
32
  }): SwapAmounts;
33
- export declare function getSwapPathComparator(order?: SwapOptimizationOrderArray | undefined): (a: SwapRoute, b: SwapRoute) => 0 | 1 | -1;
33
+ export declare function getSwapPathComparator(order?: SwapOptimizationOrderArray | undefined): (a: SwapRoute, b: SwapRoute) => 1 | 0 | -1;
@@ -1,3 +1,4 @@
1
+ import { ContractsChainId } from "../configs/chains";
1
2
  import { ContractPrice, Token, TokenData, TokenPrices, TokensData, TokensRatio, TokensRatioAndSlippage } from "../types/tokens";
2
3
  export declare function parseContractPrice(price: bigint, tokenDecimals: number): bigint;
3
4
  export declare function convertToContractPrice(price: bigint, tokenDecimals: number): ContractPrice;
@@ -47,3 +48,5 @@ export declare function getTokensRatioByPrice(p: {
47
48
  fromPrice: bigint;
48
49
  toPrice: bigint;
49
50
  }): TokensRatio;
51
+ export declare function getGmToken(chainId: ContractsChainId, marketTokenAddress: string): Token;
52
+ export declare function getGlvToken(chainId: ContractsChainId, glvTokenAddress: string): Token;
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@gmx-io/sdk",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/gmx-io/gmx-interface",
8
+ "directory": "sdk"
9
+ },
5
10
  "main": "./build/cjs/src/index.js",
6
11
  "module": "./build/esm/src/index.js",
7
12
  "types": "./build/types/src/index.d.ts",
@@ -48,10 +53,11 @@
48
53
  "prepare": "ts-patch install -s",
49
54
  "test": "vitest",
50
55
  "test:ci": "vitest run",
56
+ "test:multicall": "vitest run --config vitest.multicall.config.ts",
51
57
  "build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > build/cjs/src/package.json",
52
58
  "build:esm": "tsc -p tsconfig.esm.json && echo '{\"type\": \"module\"}' > build/esm/src/package.json",
53
59
  "build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
54
- "build:subsquid": "./node_modules/@graphql-codegen/cli/cjs/bin.js -c subsquid-codegen.ts",
60
+ "build:subsquid": "./node_modules/@graphql-codegen/cli/cjs/bin.js -c subsquid-codegen.ts && npx prettier --write src/types/subsquid.ts",
55
61
  "tscheck": "tsc -p tsconfig.json --noEmit",
56
62
  "clean": "rm -rf build/**/*.tsbuildinfo",
57
63
  "build": "rm -rf build && yarn build:subsquid && yarn build:types && yarn build:cjs && yarn build:esm && yarn clean"
@@ -1,133 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = [
4
- {
5
- inputs: [
6
- {
7
- internalType: "address",
8
- name: "account",
9
- type: "address",
10
- },
11
- {
12
- internalType: "address",
13
- name: "token",
14
- type: "address",
15
- },
16
- ],
17
- name: "EmptyMultichainTransferInAmount",
18
- type: "error",
19
- },
20
- {
21
- inputs: [
22
- {
23
- internalType: "address",
24
- name: "account",
25
- type: "address",
26
- },
27
- {
28
- internalType: "address",
29
- name: "token",
30
- type: "address",
31
- },
32
- {
33
- internalType: "uint256",
34
- name: "balance",
35
- type: "uint256",
36
- },
37
- {
38
- internalType: "uint256",
39
- name: "amount",
40
- type: "uint256",
41
- },
42
- ],
43
- name: "InsufficientMultichainBalance",
44
- type: "error",
45
- },
46
- {
47
- inputs: [
48
- {
49
- internalType: "address",
50
- name: "endpoint",
51
- type: "address",
52
- },
53
- ],
54
- name: "InvalidMultichainEndpoint",
55
- type: "error",
56
- },
57
- {
58
- inputs: [
59
- {
60
- internalType: "address",
61
- name: "provider",
62
- type: "address",
63
- },
64
- ],
65
- name: "InvalidMultichainProvider",
66
- type: "error",
67
- },
68
- {
69
- inputs: [
70
- {
71
- internalType: "contract DataStore",
72
- name: "dataStore",
73
- type: "DataStore",
74
- },
75
- {
76
- internalType: "address",
77
- name: "account",
78
- type: "address",
79
- },
80
- {
81
- internalType: "address",
82
- name: "token",
83
- type: "address",
84
- },
85
- ],
86
- name: "getMultichainBalanceAmount",
87
- outputs: [
88
- {
89
- internalType: "uint256",
90
- name: "",
91
- type: "uint256",
92
- },
93
- ],
94
- stateMutability: "view",
95
- type: "function",
96
- },
97
- {
98
- inputs: [
99
- {
100
- internalType: "contract DataStore",
101
- name: "dataStore",
102
- type: "DataStore",
103
- },
104
- {
105
- internalType: "address",
106
- name: "endpoint",
107
- type: "address",
108
- },
109
- ],
110
- name: "validateMultichainEndpoint",
111
- outputs: [],
112
- stateMutability: "view",
113
- type: "function",
114
- },
115
- {
116
- inputs: [
117
- {
118
- internalType: "contract DataStore",
119
- name: "dataStore",
120
- type: "DataStore",
121
- },
122
- {
123
- internalType: "address",
124
- name: "provider",
125
- type: "address",
126
- },
127
- ],
128
- name: "validateMultichainProvider",
129
- outputs: [],
130
- stateMutability: "view",
131
- type: "function",
132
- },
133
- ];
@@ -1,131 +0,0 @@
1
- export default [
2
- {
3
- inputs: [
4
- {
5
- internalType: "address",
6
- name: "account",
7
- type: "address",
8
- },
9
- {
10
- internalType: "address",
11
- name: "token",
12
- type: "address",
13
- },
14
- ],
15
- name: "EmptyMultichainTransferInAmount",
16
- type: "error",
17
- },
18
- {
19
- inputs: [
20
- {
21
- internalType: "address",
22
- name: "account",
23
- type: "address",
24
- },
25
- {
26
- internalType: "address",
27
- name: "token",
28
- type: "address",
29
- },
30
- {
31
- internalType: "uint256",
32
- name: "balance",
33
- type: "uint256",
34
- },
35
- {
36
- internalType: "uint256",
37
- name: "amount",
38
- type: "uint256",
39
- },
40
- ],
41
- name: "InsufficientMultichainBalance",
42
- type: "error",
43
- },
44
- {
45
- inputs: [
46
- {
47
- internalType: "address",
48
- name: "endpoint",
49
- type: "address",
50
- },
51
- ],
52
- name: "InvalidMultichainEndpoint",
53
- type: "error",
54
- },
55
- {
56
- inputs: [
57
- {
58
- internalType: "address",
59
- name: "provider",
60
- type: "address",
61
- },
62
- ],
63
- name: "InvalidMultichainProvider",
64
- type: "error",
65
- },
66
- {
67
- inputs: [
68
- {
69
- internalType: "contract DataStore",
70
- name: "dataStore",
71
- type: "DataStore",
72
- },
73
- {
74
- internalType: "address",
75
- name: "account",
76
- type: "address",
77
- },
78
- {
79
- internalType: "address",
80
- name: "token",
81
- type: "address",
82
- },
83
- ],
84
- name: "getMultichainBalanceAmount",
85
- outputs: [
86
- {
87
- internalType: "uint256",
88
- name: "",
89
- type: "uint256",
90
- },
91
- ],
92
- stateMutability: "view",
93
- type: "function",
94
- },
95
- {
96
- inputs: [
97
- {
98
- internalType: "contract DataStore",
99
- name: "dataStore",
100
- type: "DataStore",
101
- },
102
- {
103
- internalType: "address",
104
- name: "endpoint",
105
- type: "address",
106
- },
107
- ],
108
- name: "validateMultichainEndpoint",
109
- outputs: [],
110
- stateMutability: "view",
111
- type: "function",
112
- },
113
- {
114
- inputs: [
115
- {
116
- internalType: "contract DataStore",
117
- name: "dataStore",
118
- type: "DataStore",
119
- },
120
- {
121
- internalType: "address",
122
- name: "provider",
123
- type: "address",
124
- },
125
- ],
126
- name: "validateMultichainProvider",
127
- outputs: [],
128
- stateMutability: "view",
129
- type: "function",
130
- },
131
- ];