@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmx-io/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "build/src/index.js",
6
6
  "exports": {
@@ -1,3 +0,0 @@
1
- import type { GmxSdk } from "..";
2
- export type SubgraphType = "stats" | "referrals" | "nissohVault" | "syntheticsStats" | "subsquid";
3
- export declare function getSubgraphUrl(sdk: GmxSdk, subgraph: SubgraphType): string | undefined;
@@ -1,3 +0,0 @@
1
- export function getSubgraphUrl(sdk, subgraph) {
2
- return sdk.config.subgraph[subgraph];
3
- }
@@ -1,24 +0,0 @@
1
- type SlidingWindowFallbackSwitcherOptions = {
2
- fallbackTimeout: number;
3
- restoreTimeout: number;
4
- eventsThreshold: number;
5
- onFallback?: () => void;
6
- onRestore?: () => void;
7
- };
8
- export declare class SlidingWindowFallbackSwitcher {
9
- private fallbackTimeout;
10
- private restoreTimeout;
11
- private eventsThreshold;
12
- private onFallback?;
13
- private onRestore?;
14
- private eventTimestamps;
15
- isFallbackMode: boolean;
16
- private fallbackTimerId;
17
- private restoreTimerId;
18
- constructor(options: SlidingWindowFallbackSwitcherOptions);
19
- trigger(): void;
20
- private cleanupOldEvents;
21
- private switchToFallback;
22
- private switchToMain;
23
- }
24
- export {};
@@ -1,40 +0,0 @@
1
- export class SlidingWindowFallbackSwitcher {
2
- constructor(options) {
3
- this.eventTimestamps = [];
4
- this.isFallbackMode = false;
5
- this.fallbackTimerId = null;
6
- this.restoreTimerId = null;
7
- this.fallbackTimeout = options.fallbackTimeout;
8
- this.restoreTimeout = options.restoreTimeout;
9
- this.eventsThreshold = options.eventsThreshold;
10
- this.onFallback = options.onFallback;
11
- this.onRestore = options.onRestore;
12
- }
13
- trigger() {
14
- const now = Date.now();
15
- this.eventTimestamps.push(now);
16
- this.cleanupOldEvents();
17
- if (!this.isFallbackMode && this.eventTimestamps.length >= this.eventsThreshold) {
18
- this.switchToFallback();
19
- }
20
- }
21
- cleanupOldEvents() {
22
- const windowStart = Date.now() - this.fallbackTimeout;
23
- this.eventTimestamps = this.eventTimestamps.filter((timestamp) => timestamp >= windowStart);
24
- }
25
- switchToFallback() {
26
- this.onFallback?.();
27
- this.isFallbackMode = true;
28
- if (this.restoreTimerId) {
29
- clearTimeout(this.restoreTimerId);
30
- }
31
- this.fallbackTimerId = setTimeout(() => this.switchToMain(), this.restoreTimeout);
32
- }
33
- switchToMain() {
34
- this.onRestore?.();
35
- this.isFallbackMode = false;
36
- if (this.fallbackTimerId) {
37
- clearTimeout(this.fallbackTimerId);
38
- }
39
- }
40
- }