@gmx-io/sdk 0.1.0 → 0.1.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 (69) hide show
  1. package/README.md +25 -7
  2. package/build/scripts/prebuild/index.js +2 -0
  3. package/build/scripts/prebuild/prebuildKinkModelMarketRatesKeys.d.ts +1 -0
  4. package/build/scripts/prebuild/prebuildKinkModelMarketRatesKeys.js +44 -0
  5. package/build/src/abis/ExchangeRouter.json +203 -0
  6. package/build/src/abis/GlvReader.json +0 -10
  7. package/build/src/abis/GlvRouter.json +96 -2
  8. package/build/src/abis/RewardRouter.json +323 -68
  9. package/build/src/abis/SubaccountRouter.json +10 -0
  10. package/build/src/abis/SyntheticsReader.json +196 -64
  11. package/build/src/configs/batch.js +1 -13
  12. package/build/src/configs/chains.d.ts +0 -1
  13. package/build/src/configs/chains.js +1 -7
  14. package/build/src/configs/contracts.d.ts +2 -1
  15. package/build/src/configs/contracts.js +27 -66
  16. package/build/src/configs/dataStore.d.ts +4 -1
  17. package/build/src/configs/dataStore.js +5 -2
  18. package/build/src/configs/factors.d.ts +0 -12
  19. package/build/src/configs/factors.js +0 -12
  20. package/build/src/configs/markets.js +147 -0
  21. package/build/src/configs/tokens.d.ts +5 -2
  22. package/build/src/configs/tokens.js +297 -221
  23. package/build/src/modules/markets/index.js +2 -3
  24. package/build/src/modules/markets/markets.spec.js +0 -6
  25. package/build/src/modules/markets/types.d.ts +8 -0
  26. package/build/src/modules/oracle.js +1 -16
  27. package/build/src/modules/orders/orders.d.ts +2 -1
  28. package/build/src/modules/orders/orders.js +4 -3
  29. package/build/src/modules/orders/transactions/cancelOrdersTxn.js +1 -1
  30. package/build/src/modules/orders/transactions/createDecreaseOrderTxn.js +1 -0
  31. package/build/src/modules/orders/transactions/createIncreaseOrderTxn.d.ts +1 -0
  32. package/build/src/modules/orders/transactions/createIncreaseOrderTxn.js +3 -1
  33. package/build/src/modules/orders/transactions/createSwapOrderTxn.js +1 -0
  34. package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.d.ts +1 -1
  35. package/build/src/modules/orders/transactions/updateOrderTxn.d.ts +3 -1
  36. package/build/src/modules/orders/transactions/updateOrderTxn.js +7 -5
  37. package/build/src/modules/orders/utils.js +1 -1
  38. package/build/src/modules/positions/positions.d.ts +1 -1
  39. package/build/src/modules/positions/positions.js +10 -86
  40. package/build/src/modules/trades/trades.js +1 -2
  41. package/build/src/modules/utils/utils.js +3 -8
  42. package/build/src/prebuilt/hashedKinkModelMarketRatesKeys.json +760 -0
  43. package/build/src/prebuilt/hashedMarketConfigKeys.json +1050 -0
  44. package/build/src/prebuilt/hashedMarketValuesKeys.json +315 -0
  45. package/build/src/prebuilt/index.d.ts +8 -2
  46. package/build/src/prebuilt/index.js +3 -1
  47. package/build/src/prebuilt/index.ts +19 -2
  48. package/build/src/types/amounts.d.ts +1 -1
  49. package/build/src/types/fees.d.ts +1 -2
  50. package/build/src/types/orders.d.ts +2 -2
  51. package/build/src/types/positions.d.ts +2 -2
  52. package/build/src/types/sdk.d.ts +4 -4
  53. package/build/src/types/syntheticsEvents.d.ts +3 -3
  54. package/build/src/types/tokens.d.ts +4 -0
  55. package/build/src/types/trade.d.ts +1 -1
  56. package/build/src/utils/fees/executionFee.d.ts +1 -5
  57. package/build/src/utils/fees/executionFee.js +3 -12
  58. package/build/src/utils/objects.d.ts +0 -5
  59. package/build/src/utils/objects.js +0 -17
  60. package/build/src/utils/orders.js +0 -8
  61. package/build/src/utils/simulateExecuteOrder.js +8 -21
  62. package/build/src/utils/testUtil.d.ts +2 -3
  63. package/build/src/utils/testUtil.js +2 -3
  64. package/build/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +1 -1
  66. package/build/src/configs/subgraph.d.ts +0 -3
  67. package/build/src/configs/subgraph.js +0 -3
  68. package/build/src/utils/slidingWindowFallbackSwitcher.d.ts +0 -24
  69. package/build/src/utils/slidingWindowFallbackSwitcher.js +0 -40
@@ -85,6 +85,9 @@ export const GLV_DEPOSIT_GAS_LIMIT = hashString("GLV_DEPOSIT_GAS_LIMIT");
85
85
  export const GLV_WITHDRAWAL_GAS_LIMIT = hashString("GLV_WITHDRAWAL_GAS_LIMIT");
86
86
  export const GLV_PER_MARKET_GAS_LIMIT = hashString("GLV_PER_MARKET_GAS_LIMIT");
87
87
  export const MAX_AUTO_CANCEL_ORDERS_KEY = hashString("MAX_AUTO_CANCEL_ORDERS");
88
+ export const OPTIMAL_USAGE_FACTOR = hashString("OPTIMAL_USAGE_FACTOR");
89
+ export const BASE_BORROWING_FACTOR = hashString("BASE_BORROWING_FACTOR");
90
+ export const ABOVE_OPTIMAL_USAGE_BORROWING_FACTOR = hashString("ABOVE_OPTIMAL_USAGE_BORROWING_FACTOR");
88
91
  export function glvShiftLastExecutedAtKey(glvAddress) {
89
92
  return hashData(["bytes32", "address"], [GLV_SHIFT_LAST_EXECUTED_AT, glvAddress]);
90
93
  }
@@ -196,8 +199,8 @@ export function swapImpactPoolAmountKey(market, token) {
196
199
  export function orderKey(dataStoreAddress, nonce) {
197
200
  return hashData(["address", "uint256"], [dataStoreAddress, nonce]);
198
201
  }
199
- export function depositGasLimitKey(singleToken) {
200
- return hashData(["bytes32", "bool"], [DEPOSIT_GAS_LIMIT_KEY, singleToken]);
202
+ export function depositGasLimitKey() {
203
+ return DEPOSIT_GAS_LIMIT_KEY;
201
204
  }
202
205
  export function withdrawalGasLimitKey() {
203
206
  return hashData(["bytes32"], [WITHDRAWAL_GAS_LIMIT_KEY]);
@@ -1,18 +1,6 @@
1
1
  export declare const USD_DECIMALS = 30;
2
2
  export declare const BASIS_POINTS_DIVISOR = 10000;
3
3
  export declare const BASIS_POINTS_DIVISOR_BIGINT = 10000n;
4
- /**
5
- * @deprecated for v2: calculate leverage based on marketInfo.minCollateralFactor
6
- */
7
- export declare const MAX_LEVERAGE: number;
8
- /**
9
- * @deprecated for v2: calculate leverage based on marketInfo.minCollateralFactor
10
- */
11
- export declare const MAX_ALLOWED_LEVERAGE: number;
12
- export declare const COLLATERAL_SPREAD_SHOW_AFTER_INITIAL_ZERO_THRESHOLD = 5;
13
- export declare const DEFAULT_SLIPPAGE_AMOUNT = 30;
14
- export declare const DEFAULT_HIGHER_SLIPPAGE_AMOUNT = 100;
15
- export declare const EXCESSIVE_SLIPPAGE_AMOUNT: number;
16
4
  export declare const HIGH_PRICE_IMPACT_BPS = 80;
17
5
  export declare const HIGH_POSITION_IMPACT_BPS = 50;
18
6
  export declare const HIGH_COLLATERAL_IMPACT_BPS = 500;
@@ -1,18 +1,6 @@
1
1
  export const USD_DECIMALS = 30;
2
2
  export const BASIS_POINTS_DIVISOR = 10000;
3
3
  export const BASIS_POINTS_DIVISOR_BIGINT = 10000n;
4
- /**
5
- * @deprecated for v2: calculate leverage based on marketInfo.minCollateralFactor
6
- */
7
- export const MAX_LEVERAGE = 100 * BASIS_POINTS_DIVISOR;
8
- /**
9
- * @deprecated for v2: calculate leverage based on marketInfo.minCollateralFactor
10
- */
11
- export const MAX_ALLOWED_LEVERAGE = 50 * BASIS_POINTS_DIVISOR;
12
- export const COLLATERAL_SPREAD_SHOW_AFTER_INITIAL_ZERO_THRESHOLD = 5; // 0.05%
13
- export const DEFAULT_SLIPPAGE_AMOUNT = 30; // 0.3%
14
- export const DEFAULT_HIGHER_SLIPPAGE_AMOUNT = 100; // 1%
15
- export const EXCESSIVE_SLIPPAGE_AMOUNT = 2 * 100; // 2%
16
4
  // V2
17
5
  export const HIGH_PRICE_IMPACT_BPS = 80; // 0.8%
18
6
  export const HIGH_POSITION_IMPACT_BPS = 50; // 0.5%
@@ -282,6 +282,153 @@ export const MARKETS = {
282
282
  longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
283
283
  shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
284
284
  },
285
+ // APT/USD [WETH-USDC]
286
+ "0x66A69c8eb98A7efE22A22611d1967dfec786a708": {
287
+ marketTokenAddress: "0x66A69c8eb98A7efE22A22611d1967dfec786a708",
288
+ indexTokenAddress: "0x3f8f0dCE4dCE4d0D1d0871941e79CDA82cA50d0B",
289
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
290
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
291
+ },
292
+ // TIA/USD [WETH-USDC]
293
+ "0xBeB1f4EBC9af627Ca1E5a75981CE1AE97eFeDA22": {
294
+ marketTokenAddress: "0xBeB1f4EBC9af627Ca1E5a75981CE1AE97eFeDA22",
295
+ indexTokenAddress: "0x38676f62d166f5CE7De8433F51c6B3D6D9d66C19",
296
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
297
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
298
+ },
299
+ // TRX/USD [WETH-USDC]
300
+ "0x3680D7bFE9260D3c5DE81AEB2194c119a59A99D1": {
301
+ marketTokenAddress: "0x3680D7bFE9260D3c5DE81AEB2194c119a59A99D1",
302
+ indexTokenAddress: "0xb06aa7E4af937C130dDade66f6ed7642716fe07A",
303
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
304
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
305
+ },
306
+ // TON/USD [WETH-USDC]
307
+ "0x15c6eBD4175ffF9EE3c2615c556fCf62D2d9499c": {
308
+ marketTokenAddress: "0x15c6eBD4175ffF9EE3c2615c556fCf62D2d9499c",
309
+ indexTokenAddress: "0xB2f7cefaeEb08Aa347705ac829a7b8bE2FB560f3",
310
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
311
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
312
+ },
313
+ // WLD/USD [WETH-USDC]
314
+ "0x872b5D567a2469Ed92D252eaCB0EB3BB0769e05b": {
315
+ marketTokenAddress: "0x872b5D567a2469Ed92D252eaCB0EB3BB0769e05b",
316
+ indexTokenAddress: "0x75B9AdD873641b253718810E6c65dB6d72311FD0",
317
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
318
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
319
+ },
320
+ // BONK/USD [WETH-USDC]
321
+ "0xFaC5fF56c269432706d47DC82Ab082E9AE7D989E": {
322
+ marketTokenAddress: "0xFaC5fF56c269432706d47DC82Ab082E9AE7D989E",
323
+ indexTokenAddress: "0x1FD10E767187A92f0AB2ABDEEF4505e319cA06B2",
324
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
325
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
326
+ },
327
+ // TAO/USD [WBTC-USDC]
328
+ "0xe55e1A29985488A2c8846a91E925c2B7C6564db1": {
329
+ marketTokenAddress: "0xe55e1A29985488A2c8846a91E925c2B7C6564db1",
330
+ indexTokenAddress: "0x938aef36CAaFbcB37815251B602168087eC14648",
331
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
332
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
333
+ },
334
+ // BOME/USD [WBTC/USDC]
335
+ "0x71237F8C3d1484495A136022E16840b70fF84a69": {
336
+ marketTokenAddress: "0x71237F8C3d1484495A136022E16840b70fF84a69",
337
+ indexTokenAddress: "0x3Eea56A1ccCdbfB70A26aD381C71Ee17E4c8A15F",
338
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
339
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
340
+ },
341
+ // FLOKI/USD [WBTC/USDC]
342
+ "0xfD46a5702D4d97cE0164375744c65F0c31A3901b": {
343
+ marketTokenAddress: "0xfD46a5702D4d97cE0164375744c65F0c31A3901b",
344
+ indexTokenAddress: "0x6792c5B8962ffbDD020c6b6FD0Be7b182e0e33a3",
345
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
346
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
347
+ },
348
+ // MEME/USD [WBTC/USDC]
349
+ "0x6CB901Cc64c024C3Fe4404c940FF9a3Acc229D2C": {
350
+ marketTokenAddress: "0x6CB901Cc64c024C3Fe4404c940FF9a3Acc229D2C",
351
+ indexTokenAddress: "0xaF770F03518686a365300ab35AD860e99967B2f0",
352
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
353
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
354
+ },
355
+ // MEW/USD [WBTC/USDC]
356
+ "0x71B7fF592a974e2B501D8A7a11f5c42DcD365244": {
357
+ marketTokenAddress: "0x71B7fF592a974e2B501D8A7a11f5c42DcD365244",
358
+ indexTokenAddress: "0x5503CF72f54b6d692d36BBCD391516A7dE068687",
359
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
360
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
361
+ },
362
+ // GMX [GMX]
363
+ "0xbD48149673724f9cAeE647bb4e9D9dDaF896Efeb": {
364
+ marketTokenAddress: "0xbD48149673724f9cAeE647bb4e9D9dDaF896Efeb",
365
+ indexTokenAddress: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
366
+ longTokenAddress: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
367
+ shortTokenAddress: "0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a",
368
+ },
369
+ // PENDLE/USD [PENDLE/USDC]
370
+ "0x784292E87715d93afD7cb8C941BacaFAAA9A5102": {
371
+ marketTokenAddress: "0x784292E87715d93afD7cb8C941BacaFAAA9A5102",
372
+ indexTokenAddress: "0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8",
373
+ longTokenAddress: "0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8",
374
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
375
+ },
376
+ // ADA/USD [WBTC/USDC]
377
+ "0xcaCb964144f9056A8f99447a303E60b4873Ca9B4": {
378
+ marketTokenAddress: "0xcaCb964144f9056A8f99447a303E60b4873Ca9B4",
379
+ indexTokenAddress: "0x53186c8419BEB83fE4Da74F7875041a1287337ED",
380
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
381
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
382
+ },
383
+ // BCH/USD [WBTC/USDC]
384
+ "0x62feB8Ec060A7dE5b32BbbF4AC70050f8a043C17": {
385
+ marketTokenAddress: "0x62feB8Ec060A7dE5b32BbbF4AC70050f8a043C17",
386
+ indexTokenAddress: "0xc33D9C096e74aa4f571E9417b69a19C4A1e72ef2",
387
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
388
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
389
+ },
390
+ // DOT/USD [WBTC/USDC]
391
+ "0x7B2D09fca2395713dcc2F67323e4876F27b9ecB2": {
392
+ marketTokenAddress: "0x7B2D09fca2395713dcc2F67323e4876F27b9ecB2",
393
+ indexTokenAddress: "0xE958f107b467d5172573F761d26931D658C1b436",
394
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
395
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
396
+ },
397
+ // ICP/USD [WBTC/USDC]
398
+ "0xdc4e96A251Ff43Eeac710462CD8A9D18Dc802F18": {
399
+ marketTokenAddress: "0xdc4e96A251Ff43Eeac710462CD8A9D18Dc802F18",
400
+ indexTokenAddress: "0xdaf0A71608938F762e37eC5F72F670Cc44703454",
401
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
402
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
403
+ },
404
+ // XLM/USD [WBTC/USDC]
405
+ "0xe902D1526c834D5001575b2d0Ef901dfD0aa097A": {
406
+ marketTokenAddress: "0xe902D1526c834D5001575b2d0Ef901dfD0aa097A",
407
+ indexTokenAddress: "0xc5dbD52Ae5a927Cf585B884011d0C7631C9974c6",
408
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
409
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
410
+ },
411
+ // RENDER/USD [WETH/USDC]
412
+ "0x4c505e0062459cf8F60FfF13279c92ea15aE6e2D": {
413
+ marketTokenAddress: "0x4c505e0062459cf8F60FfF13279c92ea15aE6e2D",
414
+ indexTokenAddress: "0x82BB89fcc64c5d4016C5Ed1AB016bB0D1C20D6C3",
415
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
416
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
417
+ },
418
+ // SOL/USD [SOL]
419
+ "0xf22CFFA7B4174554FF9dBf7B5A8c01FaaDceA722": {
420
+ marketTokenAddress: "0xf22CFFA7B4174554FF9dBf7B5A8c01FaaDceA722",
421
+ indexTokenAddress: "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",
422
+ longTokenAddress: "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",
423
+ shortTokenAddress: "0x2bcC6D6CdBbDC0a4071e48bb3B969b06B3330c07",
424
+ },
425
+ // FIL/USD [WBTC/USDC]
426
+ "0x262B5203f0fe00D9fe86ffecE01D0f54fC116180": {
427
+ marketTokenAddress: "0x262B5203f0fe00D9fe86ffecE01D0f54fC116180",
428
+ indexTokenAddress: "0x3AeBb98f57081DcBEb0B8EA823Cf84900A31e5D8",
429
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
430
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
431
+ },
285
432
  },
286
433
  [AVALANCHE]: {
287
434
  // BTC/USD [BTC-USDC]
@@ -1,4 +1,4 @@
1
- import { Token } from "../types/tokens";
1
+ import { Token, TokenCategory } from "../types/tokens";
2
2
  export declare const NATIVE_TOKEN_ADDRESS: "0x0000000000000000000000000000000000000000";
3
3
  export declare const TOKENS: {
4
4
  [chainId: number]: Token[];
@@ -81,9 +81,12 @@ export declare function getTokenBySymbol(chainId: number, symbol: string, { isSy
81
81
  }): Token;
82
82
  export declare function convertTokenAddress(chainId: number, address: string, convertTo?: "wrapped" | "native"): string;
83
83
  export declare function getNormalizedTokenSymbol(tokenSymbol: any): any;
84
- export declare function isChartAvailabeForToken(chainId: number, tokenSymbol: string): boolean;
84
+ export declare function isChartAvailableForToken(chainId: number, tokenSymbol: string): boolean;
85
85
  export declare function getPriceDecimals(chainId: number, tokenSymbol?: string): number;
86
86
  export declare function getTokenBySymbolSafe(chainId: number, symbol: string, params?: Parameters<typeof getTokenBySymbol>[2]): Token | undefined;
87
87
  export declare function isTokenInList(token: Token, tokenList: Token[]): boolean;
88
88
  export declare function isSimilarToken(tokenA: Token, tokenB: Token): boolean;
89
+ export declare function getTokenVisualMultiplier(token: Token): string;
90
+ export declare function getStableTokens(chainId: number): Token[];
91
+ export declare function getCategoryTokenAddresses(chainId: number, category: TokenCategory): string[];
89
92
  export declare const createTokensMap: (tokens: Token[]) => {};