@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
@@ -264,6 +264,13 @@ export function getMaxFeePerGas(chainId) {
264
264
  export function getGasPricePremium(chainId) {
265
265
  return CONTRACTS_CHAIN_CONFIGS[chainId]?.gasPricePremium;
266
266
  }
267
+ // Priority fee wallets may add, charged on Arbitrum One since 2026-09-23; express is relayed with a zero tip
268
+ const EXECUTION_FEE_PRIORITY_FEE_ALLOWANCE = {
269
+ [ARBITRUM]: 30000000n, // 0.03 gwei
270
+ };
271
+ export function getExecutionFeePriorityFeeAllowance(chainId) {
272
+ return EXECUTION_FEE_PRIORITY_FEE_ALLOWANCE[chainId] ?? 0n;
273
+ }
267
274
  export function getMaxPriorityFeePerGas(chainId) {
268
275
  return CONTRACTS_CHAIN_CONFIGS[chainId]?.maxPriorityFeePerGas;
269
276
  }
@@ -225,13 +225,6 @@ export const MARKETS = {
225
225
  longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
226
226
  shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
227
227
  },
228
- // SATS/USD [WBTC-USDC]
229
- "0x8ea4Fb801493DaD8724F90Fb2e279534fa591366": {
230
- marketTokenAddress: "0x8ea4Fb801493DaD8724F90Fb2e279534fa591366",
231
- indexTokenAddress: "0x2cD2eB61D17b78239Fcd19aafF72981B5D5eF319",
232
- longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
233
- shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
234
- },
235
228
  // POL/USD [ETH-USDC]
236
229
  "0xD0a1AFDDE31Eb51e8b53bdCE989EB8C2404828a4": {
237
230
  marketTokenAddress: "0xD0a1AFDDE31Eb51e8b53bdCE989EB8C2404828a4",
@@ -323,13 +316,6 @@ export const MARKETS = {
323
316
  longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
324
317
  shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
325
318
  },
326
- // BOME/USD [WBTC/USDC]
327
- "0x71237F8C3d1484495A136022E16840b70fF84a69": {
328
- marketTokenAddress: "0x71237F8C3d1484495A136022E16840b70fF84a69",
329
- indexTokenAddress: "0x3Eea56A1ccCdbfB70A26aD381C71Ee17E4c8A15F",
330
- longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
331
- shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
332
- },
333
319
  // FLOKI/USD [WBTC/USDC]
334
320
  "0xfD46a5702D4d97cE0164375744c65F0c31A3901b": {
335
321
  marketTokenAddress: "0xfD46a5702D4d97cE0164375744c65F0c31A3901b",
@@ -337,20 +323,6 @@ export const MARKETS = {
337
323
  longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
338
324
  shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
339
325
  },
340
- // MEME/USD [WBTC/USDC]
341
- "0x6CB901Cc64c024C3Fe4404c940FF9a3Acc229D2C": {
342
- marketTokenAddress: "0x6CB901Cc64c024C3Fe4404c940FF9a3Acc229D2C",
343
- indexTokenAddress: "0xaF770F03518686a365300ab35AD860e99967B2f0",
344
- longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
345
- shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
346
- },
347
- // MEW/USD [WBTC/USDC]
348
- "0x71B7fF592a974e2B501D8A7a11f5c42DcD365244": {
349
- marketTokenAddress: "0x71B7fF592a974e2B501D8A7a11f5c42DcD365244",
350
- indexTokenAddress: "0x5503CF72f54b6d692d36BBCD391516A7dE068687",
351
- longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
352
- shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
353
- },
354
326
  // GMX [GMX]
355
327
  "0xbD48149673724f9cAeE647bb4e9D9dDaF896Efeb": {
356
328
  marketTokenAddress: "0xbD48149673724f9cAeE647bb4e9D9dDaF896Efeb",
@@ -659,13 +631,6 @@ export const MARKETS = {
659
631
  longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
660
632
  shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
661
633
  },
662
- // BRETT/USD [WETH-USDC]
663
- "0x6EeE8098dBC106aEde99763FA5F955A5bBc42C50": {
664
- marketTokenAddress: "0x6EeE8098dBC106aEde99763FA5F955A5bBc42C50",
665
- indexTokenAddress: "0x4249F6e0808bEfF7368AaAD3F7A3Fd511F61Ee60",
666
- longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
667
- shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
668
- },
669
634
  // WLFI/USD [WETH-USDC]
670
635
  "0xb3588455858a49D3244237CEe00880CcB84b91Dd": {
671
636
  marketTokenAddress: "0xb3588455858a49D3244237CEe00880CcB84b91Dd",
@@ -997,13 +962,6 @@ export const MARKETS = {
997
962
  longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
998
963
  shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
999
964
  },
1000
- // MELANIA/USD [WAVAX-USDC]
1001
- "0xe19da27Bf9733c429445E289B662bECDCa6ce10b": {
1002
- marketTokenAddress: "0xe19da27Bf9733c429445E289B662bECDCa6ce10b",
1003
- indexTokenAddress: "0xd42C991a4FAb293C57a7bf25C2E2ec5aE1dB1714",
1004
- longTokenAddress: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
1005
- shortTokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
1006
- },
1007
965
  // PUMP/USD [WAVAX-USDC]
1008
966
  "0x94cE6F65188a92F297C7f0A5A7B3cAd9013450F8": {
1009
967
  marketTokenAddress: "0x94cE6F65188a92F297C7f0A5A7B3cAd9013450F8",
@@ -374,17 +374,6 @@ export const TOKENS = {
374
374
  isPermitSupported: false,
375
375
  contractVersion: "1",
376
376
  },
377
- {
378
- name: "Sats",
379
- symbol: "SATS",
380
- address: "0x2cD2eB61D17b78239Fcd19aafF72981B5D5eF319",
381
- decimals: 6,
382
- categories: ["meme"],
383
- imageUrl: "https://assets.coingecko.com/coins/images/30666/standard/_dD8qr3M_400x400.png?1702913020",
384
- isSynthetic: true,
385
- visualMultiplier: 1000000,
386
- visualPrefix: "m",
387
- },
388
377
  {
389
378
  name: "Polygon",
390
379
  symbol: "POL",
@@ -476,15 +465,6 @@ export const TOKENS = {
476
465
  imageUrl: "https://assets.coingecko.com/coins/images/28452/standard/ARUsPeNQ_400x400.jpeg?1696527447",
477
466
  isSynthetic: true,
478
467
  },
479
- {
480
- name: "BOME",
481
- symbol: "BOME",
482
- address: "0x3Eea56A1ccCdbfB70A26aD381C71Ee17E4c8A15F",
483
- decimals: 6,
484
- categories: ["meme"],
485
- imageUrl: "https://assets.coingecko.com/coins/images/36071/standard/bome.png?1710407255",
486
- isSynthetic: true,
487
- },
488
468
  {
489
469
  name: "FLOKI",
490
470
  symbol: "FLOKI",
@@ -496,24 +476,6 @@ export const TOKENS = {
496
476
  visualMultiplier: 1000,
497
477
  visualPrefix: "k",
498
478
  },
499
- {
500
- name: "MEME",
501
- symbol: "MEME",
502
- address: "0xaF770F03518686a365300ab35AD860e99967B2f0",
503
- decimals: 18,
504
- categories: ["meme"],
505
- imageUrl: "https://assets.coingecko.com/coins/images/32528/standard/memecoin_%282%29.png?1698912168",
506
- isSynthetic: true,
507
- },
508
- {
509
- name: "MEW",
510
- symbol: "MEW",
511
- address: "0x5503CF72f54b6d692d36BBCD391516A7dE068687",
512
- decimals: 5,
513
- categories: ["meme"],
514
- imageUrl: "https://assets.coingecko.com/coins/images/36440/standard/MEW.png?1711442286",
515
- isSynthetic: true,
516
- },
517
479
  {
518
480
  name: "PENDLE",
519
481
  symbol: "PENDLE",
@@ -893,15 +855,6 @@ export const TOKENS = {
893
855
  categories: ["defi"],
894
856
  imageUrl: "https://assets.coingecko.com/coins/images/31745/standard/token.png?1696530564",
895
857
  },
896
- {
897
- name: "Brett",
898
- symbol: "BRETT",
899
- address: "0x4249F6e0808bEfF7368AaAD3F7A3Fd511F61Ee60",
900
- decimals: 18,
901
- isSynthetic: true,
902
- categories: ["meme"],
903
- imageUrl: "https://assets.coingecko.com/coins/images/54317/standard/AERO.png?1728309870",
904
- },
905
858
  {
906
859
  name: "World Liberty Financial",
907
860
  symbol: "WLFI",
@@ -1392,15 +1345,6 @@ export const TOKENS = {
1392
1345
  imageUrl: "https://assets.coingecko.com/coins/images/53746/standard/trump.png?1737171561",
1393
1346
  isSynthetic: true,
1394
1347
  },
1395
- {
1396
- name: "Melania Meme",
1397
- symbol: "MELANIA",
1398
- address: "0xd42C991a4FAb293C57a7bf25C2E2ec5aE1dB1714",
1399
- decimals: 6,
1400
- categories: ["meme"],
1401
- imageUrl: "https://assets.coingecko.com/coins/images/53775/standard/melania-meme.png?1737329885",
1402
- isSynthetic: true,
1403
- },
1404
1348
  {
1405
1349
  name: "Pump",
1406
1350
  symbol: "PUMP",
@@ -1919,7 +1863,6 @@ export const TOKEN_COLOR_MAP = {
1919
1863
  ORDI: "#000000",
1920
1864
  MATIC: "#6f41d8",
1921
1865
  EIGEN: "#1A0C6D",
1922
- SATS: "#F7931A",
1923
1866
  XAU: "#D69A00",
1924
1867
  XAG: "#ADABB8",
1925
1868
  GOLD: "#D69A00",
@@ -342,15 +342,6 @@
342
342
  "isListed": true,
343
343
  "listingDate": "2023-08-08T00:00:00.000Z"
344
344
  },
345
- {
346
- "name": "MEME/USD [WBTC.b-USDC]",
347
- "marketToken": "0x6CB901Cc64c024C3Fe4404c940FF9a3Acc229D2C",
348
- "indexToken": "0xaF770F03518686a365300ab35AD860e99967B2f0",
349
- "longToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
350
- "shortToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
351
- "isListed": true,
352
- "listingDate": "2024-11-21T00:00:00.000Z"
353
- },
354
345
  {
355
346
  "name": "UNI/USD [UNI-USDC]",
356
347
  "marketToken": "0xc7Abb2C5f3BF3CEB389dF0Eecd6120D451170B50",
@@ -639,15 +630,6 @@
639
630
  "isListed": true,
640
631
  "listingDate": "2025-08-21T00:00:00.000Z"
641
632
  },
642
- {
643
- "name": "MEW/USD [WBTC.b-USDC]",
644
- "marketToken": "0x71B7fF592a974e2B501D8A7a11f5c42DcD365244",
645
- "indexToken": "0x5503CF72f54b6d692d36BBCD391516A7dE068687",
646
- "longToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
647
- "shortToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
648
- "isListed": true,
649
- "listingDate": "2024-11-21T00:00:00.000Z"
650
- },
651
633
  {
652
634
  "name": "CHZ/USD [ETH-USDC]",
653
635
  "marketToken": "0x3600592DdEd7e6E0B05029DfB637fFc5A85D6f6B",
@@ -882,15 +864,6 @@
882
864
  "isListed": true,
883
865
  "listingDate": "2024-11-07T00:00:00.000Z"
884
866
  },
885
- {
886
- "name": "BOME/USD [WBTC.b-USDC]",
887
- "marketToken": "0x71237F8C3d1484495A136022E16840b70fF84a69",
888
- "indexToken": "0x3Eea56A1ccCdbfB70A26aD381C71Ee17E4c8A15F",
889
- "longToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
890
- "shortToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
891
- "isListed": true,
892
- "listingDate": "2024-11-21T00:00:00.000Z"
893
- },
894
867
  {
895
868
  "name": "MOODENG/USD [WBTC.b-USDC]",
896
869
  "marketToken": "0x2523B89298908FEf4c5e5bd6F55F20926e22058f",
@@ -1044,15 +1017,6 @@
1044
1017
  "isListed": true,
1045
1018
  "listingDate": "2024-03-20T00:00:00.000Z"
1046
1019
  },
1047
- {
1048
- "name": "BRETT/USD [ETH-USDC]",
1049
- "marketToken": "0x6EeE8098dBC106aEde99763FA5F955A5bBc42C50",
1050
- "indexToken": "0x4249F6e0808bEfF7368AaAD3F7A3Fd511F61Ee60",
1051
- "longToken": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
1052
- "shortToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
1053
- "isListed": true,
1054
- "listingDate": "2025-08-27T00:00:00.000Z"
1055
- },
1056
1020
  {
1057
1021
  "name": "LDO/USD [ETH-USDC]",
1058
1022
  "marketToken": "0xE61e608Ba010fF48A7dcE8eDd8B906744263d33E",
@@ -1116,15 +1080,6 @@
1116
1080
  "isListed": true,
1117
1081
  "listingDate": "2023-08-08T00:00:00.000Z"
1118
1082
  },
1119
- {
1120
- "name": "SATS/USD [WBTC.b-USDC]",
1121
- "marketToken": "0x8ea4Fb801493DaD8724F90Fb2e279534fa591366",
1122
- "indexToken": "0x2cD2eB61D17b78239Fcd19aafF72981B5D5eF319",
1123
- "longToken": "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
1124
- "shortToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
1125
- "isListed": true,
1126
- "listingDate": "2024-10-10T00:00:00.000Z"
1127
- },
1128
1083
  {
1129
1084
  "name": "SWAP-ONLY [wstETH-ETH]",
1130
1085
  "marketToken": "0xb56E5E2eB50cf5383342914b0C85Fe62DbD861C8",
@@ -23,22 +23,6 @@
23
23
  "updatedAt": 1783345314888,
24
24
  "timestamp": 1783345314
25
25
  },
26
- {
27
- "tokenAddress": "0x3Eea56A1ccCdbfB70A26aD381C71Ee17E4c8A15F",
28
- "tokenSymbol": "BOME",
29
- "minPrice": "432090385071025750000",
30
- "maxPrice": "432348055213077250000",
31
- "updatedAt": 1783345314888,
32
- "timestamp": 1783345314
33
- },
34
- {
35
- "tokenAddress": "0xaF770F03518686a365300ab35AD860e99967B2f0",
36
- "tokenSymbol": "MEME",
37
- "minPrice": "586602668",
38
- "maxPrice": "587128946",
39
- "updatedAt": 1783345314888,
40
- "timestamp": 1783345314
41
- },
42
26
  {
43
27
  "tokenAddress": "0x6792c5B8962ffbDD020c6b6FD0Be7b182e0e33a3",
44
28
  "tokenSymbol": "FLOKI",
@@ -47,14 +31,6 @@
47
31
  "updatedAt": 1783345314888,
48
32
  "timestamp": 1783345314
49
33
  },
50
- {
51
- "tokenAddress": "0x5503CF72f54b6d692d36BBCD391516A7dE068687",
52
- "tokenSymbol": "MEW",
53
- "minPrice": "3783586749507750000000",
54
- "maxPrice": "3786285876407250000000",
55
- "updatedAt": 1783345314988,
56
- "timestamp": 1783345314
57
- },
58
34
  {
59
35
  "tokenAddress": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
60
36
  "tokenSymbol": "ETH",
@@ -367,14 +343,6 @@
367
343
  "updatedAt": 1783345314988,
368
344
  "timestamp": 1783345314
369
345
  },
370
- {
371
- "tokenAddress": "0x2cD2eB61D17b78239Fcd19aafF72981B5D5eF319",
372
- "tokenSymbol": "SATS",
373
- "minPrice": "9371077957250000",
374
- "maxPrice": "9373464871750000",
375
- "updatedAt": 1783345314888,
376
- "timestamp": 1783345314
377
- },
378
346
  {
379
347
  "tokenAddress": "0x9c74772b713a1B032aEB173E28683D937E51921c",
380
348
  "tokenSymbol": "POL",
@@ -727,14 +695,6 @@
727
695
  "updatedAt": 1783345314988,
728
696
  "timestamp": 1783345314
729
697
  },
730
- {
731
- "tokenAddress": "0x4249F6e0808bEfF7368AaAD3F7A3Fd511F61Ee60",
732
- "tokenSymbol": "BRETT",
733
- "minPrice": "5478890912",
734
- "maxPrice": "5482609279",
735
- "updatedAt": 1783345314888,
736
- "timestamp": 1783345314
737
- },
738
698
  {
739
699
  "tokenAddress": "0xC5799ab6E2818fD8d0788dB8D156B0c5db1Bf97b",
740
700
  "tokenSymbol": "WLFI",
@@ -3,10 +3,7 @@
3
3
  { "symbol": "APE", "address": "0x7f9FBf9bDd3F4105C478b996B648FE6e828a1e98", "decimals": 18 },
4
4
  { "symbol": "APE_deprecated", "address": "0x74885b4D524d497261259B38900f54e6dbAd2210", "decimals": 18 },
5
5
  { "symbol": "APT", "address": "0x3f8f0dCE4dCE4d0D1d0871941e79CDA82cA50d0B", "decimals": 8, "synthetic": true },
6
- { "symbol": "BOME", "address": "0x3Eea56A1ccCdbfB70A26aD381C71Ee17E4c8A15F", "decimals": 6, "synthetic": true },
7
- { "symbol": "MEME", "address": "0xaF770F03518686a365300ab35AD860e99967B2f0", "decimals": 18, "synthetic": true },
8
6
  { "symbol": "FLOKI", "address": "0x6792c5B8962ffbDD020c6b6FD0Be7b182e0e33a3", "decimals": 9, "synthetic": true },
9
- { "symbol": "MEW", "address": "0x5503CF72f54b6d692d36BBCD391516A7dE068687", "decimals": 5, "synthetic": true },
10
7
  { "symbol": "ETH", "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", "decimals": 18 },
11
8
  { "symbol": "TAO", "address": "0x938aef36CAaFbcB37815251B602168087eC14648", "decimals": 9, "synthetic": true },
12
9
  { "symbol": "BONK", "address": "0x1FD10E767187A92f0AB2ABDEEF4505e319cA06B2", "decimals": 5, "synthetic": true },
@@ -46,7 +43,6 @@
46
43
  { "symbol": "PENDLE", "address": "0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8", "decimals": 18 },
47
44
  { "symbol": "wstETH", "address": "0x5979D7b546E38E414F7E9822514be443A4800529", "decimals": 18 },
48
45
  { "symbol": "USDe", "address": "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34", "decimals": 18 },
49
- { "symbol": "SATS", "address": "0x2cD2eB61D17b78239Fcd19aafF72981B5D5eF319", "decimals": 6, "synthetic": true },
50
46
  { "symbol": "POL", "address": "0x9c74772b713a1B032aEB173E28683D937E51921c", "decimals": 18, "synthetic": true },
51
47
  { "symbol": "ADA", "address": "0x53186c8419BEB83fE4Da74F7875041a1287337ED", "decimals": 6, "synthetic": true },
52
48
  { "symbol": "XLM", "address": "0xc5dbD52Ae5a927Cf585B884011d0C7631C9974c6", "decimals": 7, "synthetic": true },
@@ -92,7 +88,6 @@
92
88
  { "symbol": "CVX", "address": "0x3B6f801C0052Dfe0Ac80287D611F31B7c47B9A6b", "decimals": 18, "synthetic": true },
93
89
  { "symbol": "KAS", "address": "0x91c6a8F6aFAC036F4ABf1bA55f4E76892E865E4a", "decimals": 8, "synthetic": true },
94
90
  { "symbol": "AERO", "address": "0xEcc5eb985Ddbb8335b175b0A2A1144E4c978F1f6", "decimals": 18, "synthetic": true },
95
- { "symbol": "BRETT", "address": "0x4249F6e0808bEfF7368AaAD3F7A3Fd511F61Ee60", "decimals": 18, "synthetic": true },
96
91
  { "symbol": "WLFI", "address": "0xC5799ab6E2818fD8d0788dB8D156B0c5db1Bf97b", "decimals": 18, "synthetic": true },
97
92
  { "symbol": "WELL", "address": "0x465A31E5bA29b8EAcC860d499D714a6f07e56E85", "decimals": 18, "synthetic": true },
98
93
  { "symbol": "VVV", "address": "0xB79Eb5BA64A167676694bB41bc1640F95d309a2F", "decimals": 18, "synthetic": true },
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { BASIS_POINTS_DIVISOR_BIGINT, USD_DECIMALS } from "../../configs/factors";
3
- import { applyFactor, basisPointsToFloat, bigintToNumber, BN_NEGATIVE_ONE, BN_ONE, BN_ZERO, expandDecimals, formatAmount, formatAmountHuman, formatBalanceAmount, formatBasisPoints, formatPriceImpactBps, formatFactor, formatNumberHuman, formatPercentage, formatTokenAmount, formatUsdPrice, getBasisPoints, isUint256, MaxUint256, numberToBigint, parseUint256DecimalString, PERCENT_PRECISION_DECIMALS, PRECISION, PRECISION_DECIMALS, parseValue, removeTrailingZeros, trimZeroDecimals, roundWithDecimals, roundUpMagnitudeDivision, roundsToZero, toBigNumberWithDecimals, } from "../numbers";
3
+ import { applyFactor, basisPointsToFloat, bigintToNumber, BN_NEGATIVE_ONE, BN_ONE, BN_ZERO, expandDecimals, formatAmount, formatAmountHuman, formatBalanceAmount, formatBasisPoints, formatPriceImpactBps, formatFactor, formatNumberHuman, formatPercentage, formatTokenAmount, formatUsdPrice, getBasisPoints, isUint256, MaxUint256, numberToBigint, parseUint256DecimalString, PERCENT_PRECISION_DECIMALS, PRECISION, PRECISION_DECIMALS, parseValue, removeTrailingZeros, trimZeroDecimals, roundWithDecimals, roundUpMagnitudeDivision, roundsToZero, toBigNumberWithDecimals, formatUsd, formatUsdParts, formatDeltaUsd, formatDeltaUsdParts, formatBigUsd, formatBigUsdParts, formatUsdPriceParts, formatAmountHumanParts, formatTokenAmountWithUsd, formatTokenAmountWithUsdParts, numberWithCommas, numberWithCommasParts, numberParts, joinNumberParts, isNumberParts, USD_PART, } from "../numbers";
4
4
  const ONE_USD = 1000000000000000000000000000000n;
5
5
  describe("numbers utils", () => {
6
6
  it("constants", () => {
@@ -544,3 +544,82 @@ describe("formatPriceImpactBps", () => {
544
544
  expect(formatPriceImpactBps(-81n, -10000n)).toBeUndefined();
545
545
  });
546
546
  });
547
+ describe("number parts", () => {
548
+ const usd = (amount) => expandDecimals(amount, USD_DECIMALS);
549
+ it("string formatters are the joined parts", () => {
550
+ const cases = [
551
+ [formatUsd(usd(1234)), formatUsdParts(usd(1234))],
552
+ [
553
+ formatUsd(-usd(1), { displayPlus: true, displayDecimals: 4 }),
554
+ formatUsdParts(-usd(1), { displayPlus: true, displayDecimals: 4 }),
555
+ ],
556
+ [formatUsd(usd(2000000000)), formatUsdParts(usd(2000000000))],
557
+ [formatUsd(1n), formatUsdParts(1n)],
558
+ [formatUsd(undefined, { fallbackToZero: true }), formatUsdParts(undefined, { fallbackToZero: true })],
559
+ [formatDeltaUsd(usd(5), expandDecimals(3, 2)), formatDeltaUsdParts(usd(5), expandDecimals(3, 2))],
560
+ [
561
+ formatDeltaUsd(0n, undefined, { showPlusForZero: true }),
562
+ formatDeltaUsdParts(0n, undefined, { showPlusForZero: true }),
563
+ ],
564
+ [formatBigUsd(usd(123456789)), formatBigUsdParts(usd(123456789))],
565
+ [formatUsdPrice(usd(3)), formatUsdPriceParts(usd(3))],
566
+ [formatUsdPrice(-1n), formatUsdPriceParts(-1n)],
567
+ [
568
+ formatAmountHuman(usd(1150000000), USD_DECIMALS, true),
569
+ formatAmountHumanParts(usd(1150000000), USD_DECIMALS, true),
570
+ ],
571
+ [
572
+ formatAmountHuman(-usd(12500), USD_DECIMALS, false, 2),
573
+ formatAmountHumanParts(-usd(12500), USD_DECIMALS, false, 2),
574
+ ],
575
+ [formatAmountHuman(undefined, USD_DECIMALS), formatAmountHumanParts(undefined, USD_DECIMALS)],
576
+ [numberWithCommas("1234.5", { showDollar: true }), numberWithCommasParts("1234.5", { showDollar: true })],
577
+ [
578
+ formatTokenAmountWithUsd(expandDecimals(1, 18), usd(2500), "ETH", 18),
579
+ formatTokenAmountWithUsdParts(expandDecimals(1, 18), usd(2500), "ETH", 18),
580
+ ],
581
+ ];
582
+ for (const [text, parts] of cases) {
583
+ expect(parts && joinNumberParts(parts)).toBe(text);
584
+ }
585
+ });
586
+ it("marks the currency affix and keeps magnitude suffixes as text", () => {
587
+ expect(formatUsdParts(-usd(1234))).toEqual([
588
+ { kind: "text", text: "-" },
589
+ { kind: "currency", text: "$ " },
590
+ { kind: "text", text: "1,234.00" },
591
+ ]);
592
+ expect(formatUsdParts(usd(2000000000))).toEqual([
593
+ { kind: "text", text: "> " },
594
+ { kind: "currency", text: "$ " },
595
+ { kind: "text", text: "1,000,000,000.00" },
596
+ ]);
597
+ expect(formatDeltaUsdParts(usd(5), expandDecimals(3, 2))).toEqual([
598
+ { kind: "text", text: "+" },
599
+ { kind: "currency", text: "$ " },
600
+ { kind: "text", text: "5.00 (+3.00%)" },
601
+ ]);
602
+ expect(formatAmountHumanParts(usd(1150000000), USD_DECIMALS, true)).toEqual([
603
+ { kind: "currency", text: "$ " },
604
+ { kind: "text", text: "1.1b" },
605
+ ]);
606
+ expect(formatAmountHumanParts(expandDecimals(12500, 18), 18)).toEqual([{ kind: "text", text: "12.5k" }]);
607
+ expect(formatAmountHumanParts(usd(999), USD_DECIMALS, true)).toEqual([
608
+ { kind: "currency", text: "$ " },
609
+ { kind: "text", text: "999.0" },
610
+ ]);
611
+ expect(formatUsdPriceParts(-1n)).toEqual([{ kind: "text", text: "NA" }]);
612
+ expect(formatUsdParts(undefined)).toBeUndefined();
613
+ });
614
+ it("numberParts merges adjacent text and skips empty inputs", () => {
615
+ expect(numberParts("> ", undefined, "", "-", USD_PART, "1.00", [{ kind: "multiplier", text: "x" }])).toEqual([
616
+ { kind: "text", text: "> -" },
617
+ { kind: "currency", text: "$ " },
618
+ { kind: "text", text: "1.00" },
619
+ { kind: "multiplier", text: "x" },
620
+ ]);
621
+ expect(isNumberParts(formatUsdParts(usd(1)))).toBe(true);
622
+ expect(isNumberParts(["$ 1.00"])).toBe(false);
623
+ expect(isNumberParts("$ 1.00")).toBe(false);
624
+ });
625
+ });
@@ -62,6 +62,7 @@ export var CustomErrorName;
62
62
  CustomErrorName["DisabledMarket"] = "DisabledMarket";
63
63
  CustomErrorName["EndOfOracleSimulation"] = "EndOfOracleSimulation";
64
64
  CustomErrorName["ExternalCallFailed"] = "ExternalCallFailed";
65
+ CustomErrorName["InsufficientBridgeOutputAmount"] = "InsufficientBridgeOutputAmount";
65
66
  CustomErrorName["InsufficientCollateralAmount"] = "InsufficientCollateralAmount";
66
67
  CustomErrorName["InsufficientCollateralUsd"] = "InsufficientCollateralUsd";
67
68
  CustomErrorName["InsufficientExecutionGas"] = "InsufficientExecutionGas";
@@ -1,2 +1,3 @@
1
1
  export * from "./utils";
2
+ export * from "./parts";
2
3
  export * from "./prbMath";
@@ -0,0 +1,41 @@
1
+ export const USD_SYMBOL = "$ ";
2
+ export const USD_PART = { kind: "currency", text: USD_SYMBOL };
3
+ export function multiplierPart(text) {
4
+ return { kind: "multiplier", text };
5
+ }
6
+ export function numberParts(...inputs) {
7
+ const parts = [];
8
+ const push = (part) => {
9
+ if (!part.text) {
10
+ return;
11
+ }
12
+ const last = parts[parts.length - 1];
13
+ if (part.kind === "text" && last?.kind === "text") {
14
+ parts[parts.length - 1] = { kind: "text", text: last.text + part.text };
15
+ return;
16
+ }
17
+ parts.push(part);
18
+ };
19
+ for (const input of inputs) {
20
+ if (input === undefined) {
21
+ continue;
22
+ }
23
+ if (typeof input === "string") {
24
+ push({ kind: "text", text: input });
25
+ }
26
+ else if (Array.isArray(input)) {
27
+ input.forEach(push);
28
+ }
29
+ else {
30
+ push(input);
31
+ }
32
+ }
33
+ return parts;
34
+ }
35
+ export function joinNumberParts(parts) {
36
+ return parts.map((part) => part.text).join("");
37
+ }
38
+ export function isNumberParts(value) {
39
+ return (Array.isArray(value) &&
40
+ value.every((item) => typeof item === "object" && item !== null && "kind" in item && "text" in item && typeof item.text === "string"));
41
+ }