@gmx-io/sdk 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/build/cjs/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +0 -48
  2. package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +0 -408
  3. package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +0 -90
  4. package/build/cjs/src/configs/chains.js +9 -1
  5. package/build/cjs/src/configs/markets.js +0 -42
  6. package/build/cjs/src/configs/tokens.js +0 -57
  7. package/build/cjs/src/test/fixtures/arbitrumMarkets.json +0 -45
  8. package/build/cjs/src/test/fixtures/arbitrumTickers.json +0 -40
  9. package/build/cjs/src/test/fixtures/arbitrumTokens.json +0 -5
  10. package/build/cjs/src/utils/__tests__/numbers.spec.js +79 -0
  11. package/build/cjs/src/utils/errors/transactionsErrors.js +1 -0
  12. package/build/cjs/src/utils/numbers/index.js +1 -0
  13. package/build/cjs/src/utils/numbers/parts.js +48 -0
  14. package/build/cjs/src/utils/numbers/utils.js +67 -26
  15. package/build/cjs/src/utils/orderTransactions/utils.js +55 -1
  16. package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +0 -48
  17. package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +0 -408
  18. package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +0 -90
  19. package/build/esm/src/configs/chains.js +7 -0
  20. package/build/esm/src/configs/markets.js +0 -42
  21. package/build/esm/src/configs/tokens.js +0 -57
  22. package/build/esm/src/test/fixtures/arbitrumMarkets.json +0 -45
  23. package/build/esm/src/test/fixtures/arbitrumTickers.json +0 -40
  24. package/build/esm/src/test/fixtures/arbitrumTokens.json +0 -5
  25. package/build/esm/src/utils/__tests__/numbers.spec.js +80 -1
  26. package/build/esm/src/utils/errors/transactionsErrors.js +1 -0
  27. package/build/esm/src/utils/numbers/index.js +1 -0
  28. package/build/esm/src/utils/numbers/parts.js +41 -0
  29. package/build/esm/src/utils/numbers/utils.js +57 -24
  30. package/build/esm/src/utils/orderTransactions/utils.js +53 -1
  31. package/build/tsconfig.tsbuildinfo +1 -1
  32. package/build/types/src/codegen/prebuilt/index.d.ts +42 -588
  33. package/build/types/src/configs/chains.d.ts +1 -0
  34. package/build/types/src/utils/errors/transactionsErrors.d.ts +1 -0
  35. package/build/types/src/utils/numbers/index.d.ts +1 -0
  36. package/build/types/src/utils/numbers/parts.d.ts +12 -0
  37. package/build/types/src/utils/numbers/utils.d.ts +25 -9
  38. package/build/types/src/utils/orderTransactions/utils.d.ts +7 -0
  39. package/package.json +1 -1
@@ -206,6 +206,7 @@ export declare function isContractsChain(chainId: number, dev?: boolean): chainI
206
206
  export declare function isTestnetChain(chainId: number): boolean;
207
207
  export declare function getMaxFeePerGas(chainId: ContractsChainId): bigint | undefined;
208
208
  export declare function getGasPricePremium(chainId: ContractsChainId): bigint | undefined;
209
+ export declare function getExecutionFeePriorityFeeAllowance(chainId: ContractsChainId): bigint;
209
210
  export declare function getMaxPriorityFeePerGas(chainId: ContractsChainId): 1500000000n | 500000n;
210
211
  export declare function getMinExecutionFeeUsd(chainId: ContractsChainId): undefined;
211
212
  export declare function getResidualGasUsdConfig(chainId: ContractsChainId): {
@@ -14,6 +14,7 @@ export declare enum CustomErrorName {
14
14
  DisabledMarket = "DisabledMarket",
15
15
  EndOfOracleSimulation = "EndOfOracleSimulation",
16
16
  ExternalCallFailed = "ExternalCallFailed",
17
+ InsufficientBridgeOutputAmount = "InsufficientBridgeOutputAmount",
17
18
  InsufficientCollateralAmount = "InsufficientCollateralAmount",
18
19
  InsufficientCollateralUsd = "InsufficientCollateralUsd",
19
20
  InsufficientExecutionGas = "InsufficientExecutionGas",
@@ -1,2 +1,3 @@
1
1
  export * from "./utils";
2
+ export * from "./parts";
2
3
  export * from "./prbMath";
@@ -0,0 +1,12 @@
1
+ export type NumberPartKind = "text" | "currency" | "multiplier";
2
+ export type NumberPart = {
3
+ kind: NumberPartKind;
4
+ text: string;
5
+ };
6
+ export type NumberPartInput = string | NumberPart | NumberPart[] | undefined;
7
+ export declare const USD_SYMBOL = "$\u200A";
8
+ export declare const USD_PART: NumberPart;
9
+ export declare function multiplierPart(text: string): NumberPart;
10
+ export declare function numberParts(...inputs: NumberPartInput[]): NumberPart[];
11
+ export declare function joinNumberParts(parts: NumberPart[]): string;
12
+ export declare function isNumberParts(value: unknown): value is NumberPart[];
@@ -1,3 +1,4 @@
1
+ import { NumberPart } from "./parts";
1
2
  export type Numeric = number | bigint;
2
3
  export type BigNumberish = string | Numeric;
3
4
  export declare const USD_DECIMALS = 30;
@@ -37,7 +38,7 @@ export declare function numberToBigint(value: number, decimals: number): bigint;
37
38
  export declare const trimZeroDecimals: (amount: string) => string;
38
39
  export declare function bigintToNumber(value: bigint, decimals: number): number;
39
40
  export declare function adjustForDecimals(amount: bigint, divDecimals: number, mulDecimals: number): bigint;
40
- export declare function formatUsd(usd?: bigint, opts?: {
41
+ export type FormatUsdOptions = {
41
42
  fallbackToZero?: boolean;
42
43
  displayDecimals?: number;
43
44
  maxThreshold?: string | null;
@@ -45,15 +46,22 @@ export declare function formatUsd(usd?: bigint, opts?: {
45
46
  displayPlus?: boolean;
46
47
  visualMultiplier?: number;
47
48
  roundMode?: "round" | "floor";
48
- }): string | undefined;
49
+ };
50
+ export declare function formatUsdParts(usd?: bigint, opts?: FormatUsdOptions): NumberPart[] | undefined;
51
+ export declare function formatUsd(usd?: bigint, opts?: FormatUsdOptions): string | undefined;
52
+ export declare function formatBigUsdParts(amount: bigint, opts?: {
53
+ displayDecimals?: number;
54
+ }): NumberPart[];
49
55
  export declare function formatBigUsd(amount: bigint, opts?: {
50
56
  displayDecimals?: number;
51
- }): string | undefined;
52
- export declare function formatDeltaUsd(deltaUsd?: bigint, percentage?: bigint, opts?: {
57
+ }): string;
58
+ export type FormatDeltaUsdOptions = {
53
59
  fallbackToZero?: boolean;
54
60
  showPlusForZero?: boolean;
55
61
  hidePercentage?: boolean;
56
- }): string | undefined;
62
+ };
63
+ export declare function formatDeltaUsdParts(deltaUsd?: bigint, percentage?: bigint, opts?: FormatDeltaUsdOptions): NumberPart[] | undefined;
64
+ export declare function formatDeltaUsd(deltaUsd?: bigint, percentage?: bigint, opts?: FormatDeltaUsdOptions): string | undefined;
57
65
  export declare function formatPercentage(percentage?: bigint, opts?: {
58
66
  fallbackToZero?: boolean;
59
67
  signed?: boolean;
@@ -72,12 +80,14 @@ export declare function formatTokenAmount(amount?: bigint, tokenDecimals?: numbe
72
80
  displayPlus?: boolean;
73
81
  isStable?: boolean;
74
82
  }): string | undefined;
75
- export declare function formatTokenAmountWithUsd(tokenAmount?: bigint, usdAmount?: bigint, tokenSymbol?: string, tokenDecimals?: number, opts?: {
83
+ export type FormatTokenAmountWithUsdOptions = {
76
84
  fallbackToZero?: boolean;
77
85
  displayDecimals?: number;
78
86
  displayPlus?: boolean;
79
87
  isStable?: boolean;
80
- }): string | undefined;
88
+ };
89
+ export declare function formatTokenAmountWithUsdParts(tokenAmount?: bigint, usdAmount?: bigint, tokenSymbol?: string, tokenDecimals?: number, opts?: FormatTokenAmountWithUsdOptions): NumberPart[] | undefined;
90
+ export declare function formatTokenAmountWithUsd(tokenAmount?: bigint, usdAmount?: bigint, tokenSymbol?: string, tokenDecimals?: number, opts?: FormatTokenAmountWithUsdOptions): string | undefined;
81
91
  /**
82
92
  *
83
93
  * @param opts.signed - Default `true`. whether to display a `+` or `-` sign for all non-zero values.
@@ -86,9 +96,12 @@ export declare function formatRatePercentage(rate?: bigint, opts?: {
86
96
  displayDecimals?: number;
87
97
  signed?: boolean;
88
98
  }): string;
89
- export declare function formatUsdPrice(price?: bigint, opts?: Parameters<typeof formatUsd>[1]): string | undefined;
99
+ export declare function formatUsdPriceParts(price?: bigint, opts?: FormatUsdOptions): NumberPart[] | undefined;
100
+ export declare function formatUsdPrice(price?: bigint, opts?: FormatUsdOptions): string | undefined;
90
101
  export declare function formatPercentageDisplay(percentage: number, hideThreshold?: number): string;
102
+ export declare function formatNumberHumanParts(n: number, showDollar?: boolean, displayDecimals?: number): NumberPart[];
91
103
  export declare function formatNumberHuman(n: number, showDollar?: boolean, displayDecimals?: number): string;
104
+ export declare function formatAmountHumanParts(amount: BigNumberish | undefined, tokenDecimals: number, showDollar?: boolean, displayDecimals?: number): NumberPart[];
92
105
  export declare function formatAmountHuman(amount: BigNumberish | undefined, tokenDecimals: number, showDollar?: boolean, displayDecimals?: number): string;
93
106
  export declare function formatBalanceAmount(amount: bigint, tokenDecimals: number, tokenSymbol?: string, { showZero, toExponential, isStable, signed, }?: {
94
107
  showZero?: boolean;
@@ -97,7 +110,10 @@ export declare function formatBalanceAmount(amount: bigint, tokenDecimals: numbe
97
110
  signed?: boolean;
98
111
  }): string;
99
112
  export declare function formatFactor(factor: bigint): string;
100
- export declare function numberWithCommas(x: BigNumberish, { showDollar }?: {
113
+ export declare function numberWithCommasParts(x: BigNumberish, { showDollar }?: {
114
+ showDollar?: boolean;
115
+ }): NumberPart[];
116
+ export declare function numberWithCommas(x: BigNumberish, opts?: {
101
117
  showDollar?: boolean;
102
118
  }): string;
103
119
  export declare const formatAmount: (amount: BigNumberish | undefined, tokenDecimals: number, displayDecimals?: number, useCommas?: boolean, defaultValue?: string, visualMultiplier?: number) => string;
@@ -70,6 +70,11 @@ export type UpdateOrderParams = {
70
70
  autoCancel: boolean;
71
71
  validFromTime: bigint;
72
72
  executionFeeTopUp: bigint;
73
+ executionGasLimit?: bigint;
74
+ };
75
+ export type ExecutionFeeEstimate = {
76
+ executionFee: bigint;
77
+ gasLimit: bigint;
73
78
  };
74
79
  export type UpdateOrderPayload = {
75
80
  orderKey: string;
@@ -169,6 +174,8 @@ export declare function getBatchTotalExecutionFee({ batchParams, tokensData, cha
169
174
  chainId: number;
170
175
  allowEmptyBatch?: boolean;
171
176
  }): ExecutionFee | undefined;
177
+ export declare function getBatchExecutionFeeEstimates(batchParams: BatchOrderTxnParams): ExecutionFeeEstimate[];
178
+ export declare function getExpressBatchOrderParams(chainId: ContractsChainId, batchParams: BatchOrderTxnParams): BatchOrderTxnParams;
172
179
  export declare function getBatchTotalPayCollateralAmount(batchParams: BatchOrderTxnParams): {
173
180
  [tokenAddress: string]: bigint;
174
181
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmx-io/sdk",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",