@gmx-io/sdk 1.0.0-alpha.1 → 1.0.0-alpha.3
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.
- package/README.md +5 -3
- package/build/cjs/src/configs/markets.js +7 -0
- package/build/cjs/src/configs/tokens.js +11 -0
- package/build/cjs/src/modules/trades/trades.js +27 -156
- package/build/cjs/src/prebuilt/hashedKinkModelMarketRatesKeys.json +8 -0
- package/build/cjs/src/prebuilt/hashedMarketConfigKeys.json +50 -0
- package/build/cjs/src/prebuilt/hashedMarketValuesKeys.json +15 -0
- package/build/cjs/src/utils/__tests__/subgraph.spec.js +0 -4
- package/build/cjs/src/utils/fees/priceImpact.js +2 -2
- package/build/cjs/src/utils/subgraph.js +16 -6
- package/build/cjs/src/utils/testUtil.js +1 -2
- package/build/cjs/src/utils/tradeHistory.js +137 -0
- package/build/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/build/esm/src/configs/markets.js +7 -0
- package/build/esm/src/configs/tokens.js +11 -0
- package/build/esm/src/modules/trades/trades.js +25 -153
- package/build/esm/src/prebuilt/hashedKinkModelMarketRatesKeys.json +8 -0
- package/build/esm/src/prebuilt/hashedMarketConfigKeys.json +50 -0
- package/build/esm/src/prebuilt/hashedMarketValuesKeys.json +15 -0
- package/build/esm/src/utils/__tests__/subgraph.spec.js +0 -4
- package/build/esm/src/utils/fees/priceImpact.js +1 -1
- package/build/esm/src/utils/subgraph.js +16 -6
- package/build/esm/src/utils/testUtil.js +1 -2
- package/build/esm/src/utils/tradeHistory.js +132 -0
- package/build/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/build/src/abis/index.d.ts +20 -1
- package/build/src/modules/markets/query-builders.d.ts +1 -1
- package/build/src/modules/tokens/tokens.d.ts +2 -2
- package/build/src/modules/trades/trades.d.ts +2 -3
- package/build/src/types/sdk.d.ts +0 -2
- package/build/src/types/tradeHistory.d.ts +3 -3
- package/build/src/utils/subgraph.d.ts +7 -5
- package/build/src/utils/tradeHistory.d.ts +7 -0
- package/package.json +7 -7
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
import type { JsonFragment } from "ethers";
|
|
2
1
|
import { Abi } from "viem";
|
|
2
|
+
/** Copied from ethers to enable compatibility with GMX UI */
|
|
3
|
+
interface JsonFragmentType {
|
|
4
|
+
readonly name?: string;
|
|
5
|
+
readonly indexed?: boolean;
|
|
6
|
+
readonly type?: string;
|
|
7
|
+
readonly internalType?: string;
|
|
8
|
+
readonly components?: ReadonlyArray<JsonFragmentType>;
|
|
9
|
+
}
|
|
10
|
+
interface JsonFragment {
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
readonly type?: string;
|
|
13
|
+
readonly anonymous?: boolean;
|
|
14
|
+
readonly payable?: boolean;
|
|
15
|
+
readonly constant?: boolean;
|
|
16
|
+
readonly stateMutability?: string;
|
|
17
|
+
readonly inputs?: ReadonlyArray<JsonFragmentType>;
|
|
18
|
+
readonly outputs?: ReadonlyArray<JsonFragmentType>;
|
|
19
|
+
readonly gas?: string;
|
|
20
|
+
}
|
|
3
21
|
export type AbiId = "CustomErrors" | "DataStore" | "ERC721" | "ERC20" | "EventEmitter" | "ExchangeRouter" | "GlpManager" | "GlvReader" | "GlvRouter" | "GMT" | "GmxMigrator" | "GovToken" | "MintableBaseToken" | "Multicall" | "OrderBook" | "OrderBookReader" | "OrderExecutor" | "PositionManager" | "PositionRouter" | "Reader" | "ReaderV2" | "ReferralStorage" | "RewardReader" | "RewardRouter" | "RewardTracker" | "Router-v2" | "Router" | "SubaccountRouter" | "SyntheticsReader" | "SyntheticsRouter" | "Timelock" | "Token" | "Treasury" | "UniPool" | "UniswapV2" | "Vault" | "VaultReader" | "VaultV2" | "VaultV2b" | "Vester" | "WETH" | "YieldFarm" | "YieldToken";
|
|
4
22
|
export declare const abis: Record<AbiId, readonly (Abi[number] & JsonFragment)[]>;
|
|
23
|
+
export {};
|
|
@@ -33,7 +33,7 @@ export declare function buildMarketsConfigsRequest(chainId: number, { marketsDat
|
|
|
33
33
|
dataStoreAddress: string;
|
|
34
34
|
}): Promise<import("../../utils/multicall").MulticallRequestConfig<{
|
|
35
35
|
[key: `${string}-dataStore`]: {
|
|
36
|
-
calls: Record<"
|
|
36
|
+
calls: Record<"isDisabled" | "maxLongPoolAmount" | "maxShortPoolAmount" | "maxLongPoolUsdForDeposit" | "maxShortPoolUsdForDeposit" | "longPoolAmountAdjustment" | "shortPoolAmountAdjustment" | "reserveFactorLong" | "reserveFactorShort" | "openInterestReserveFactorLong" | "openInterestReserveFactorShort" | "maxOpenInterestLong" | "maxOpenInterestShort" | "minPositionImpactPoolAmount" | "positionImpactPoolDistributionRate" | "borrowingFactorLong" | "borrowingFactorShort" | "borrowingExponentFactorLong" | "borrowingExponentFactorShort" | "fundingFactor" | "fundingExponentFactor" | "fundingIncreaseFactorPerSecond" | "fundingDecreaseFactorPerSecond" | "thresholdForStableFunding" | "thresholdForDecreaseFunding" | "minFundingFactorPerSecond" | "maxFundingFactorPerSecond" | "maxPnlFactorForTradersLong" | "maxPnlFactorForTradersShort" | "positionFeeFactorForPositiveImpact" | "positionFeeFactorForNegativeImpact" | "positionImpactFactorPositive" | "positionImpactFactorNegative" | "maxPositionImpactFactorPositive" | "maxPositionImpactFactorNegative" | "maxPositionImpactFactorForLiquidations" | "minCollateralFactor" | "minCollateralFactorForOpenInterestLong" | "minCollateralFactorForOpenInterestShort" | "positionImpactExponentFactor" | "swapFeeFactorForPositiveImpact" | "swapFeeFactorForNegativeImpact" | "swapImpactFactorPositive" | "swapImpactFactorNegative" | "swapImpactExponentFactor" | "virtualMarketId" | "virtualLongTokenId" | "virtualShortTokenId", {
|
|
37
37
|
methodName: string;
|
|
38
38
|
params: any[];
|
|
39
39
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TokensData, Token as TToken } from "../../types/tokens";
|
|
2
2
|
import { Module } from "../base";
|
|
3
3
|
type TokensDataResult = {
|
|
4
4
|
tokensData?: TokensData;
|
|
@@ -9,7 +9,7 @@ export declare class Tokens extends Module {
|
|
|
9
9
|
[key: string]: TToken;
|
|
10
10
|
} | undefined;
|
|
11
11
|
get tokensConfig(): {
|
|
12
|
-
[address: string]:
|
|
12
|
+
[address: string]: TToken;
|
|
13
13
|
};
|
|
14
14
|
private getTokenRecentPrices;
|
|
15
15
|
private getTokensBalances;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Address } from "viem";
|
|
2
|
-
import { GmxSdk } from "index";
|
|
1
|
+
import type { Address } from "viem";
|
|
3
2
|
import { MarketsInfoData } from "../../types/markets";
|
|
4
3
|
import { OrderType } from "../../types/orders";
|
|
5
4
|
import { TokensData } from "../../types/tokens";
|
|
6
5
|
import { TradeAction, TradeActionType } from "../../types/tradeHistory";
|
|
6
|
+
import type { GmxSdk } from "../..";
|
|
7
7
|
import { Module } from "../base";
|
|
8
8
|
export type MarketFilterLongShortDirection = "long" | "short" | "swap" | "any";
|
|
9
9
|
export type MarketFilterLongShortItemData = {
|
|
@@ -45,4 +45,3 @@ export declare function fetchTradeActions({ sdk, pageIndex, pageSize, marketsDir
|
|
|
45
45
|
marketsInfoData: MarketsInfoData | undefined;
|
|
46
46
|
tokensData: TokensData | undefined;
|
|
47
47
|
}): Promise<TradeAction[]>;
|
|
48
|
-
export declare function bigNumberify(n?: bigint | string | null | undefined): bigint | undefined;
|
package/build/src/types/sdk.d.ts
CHANGED
|
@@ -12,8 +12,6 @@ export interface GmxSdkConfig {
|
|
|
12
12
|
rpcUrl: string;
|
|
13
13
|
/** GMX Subsquid URL */
|
|
14
14
|
subsquidUrl: string;
|
|
15
|
-
/** GMX Subgraph Synthetics Stats URL */
|
|
16
|
-
subgraphUrl: string;
|
|
17
15
|
/** Custom viem's public and private client */
|
|
18
16
|
publicClient?: PublicClient;
|
|
19
17
|
walletClient?: WalletClient;
|
|
@@ -41,8 +41,8 @@ export type RawTradeAction = {
|
|
|
41
41
|
shouldUnwrapNativeToken?: boolean;
|
|
42
42
|
reason?: string;
|
|
43
43
|
reasonBytes?: BytesLike;
|
|
44
|
+
timestamp: number;
|
|
44
45
|
transaction: {
|
|
45
|
-
timestamp: number;
|
|
46
46
|
hash: string;
|
|
47
47
|
};
|
|
48
48
|
};
|
|
@@ -81,8 +81,8 @@ export type PositionTradeAction = {
|
|
|
81
81
|
reasonBytes?: string | Uint8Array;
|
|
82
82
|
shouldUnwrapNativeToken: boolean;
|
|
83
83
|
liquidationFeeAmount?: bigint;
|
|
84
|
+
timestamp: number;
|
|
84
85
|
transaction: {
|
|
85
|
-
timestamp: number;
|
|
86
86
|
hash: string;
|
|
87
87
|
};
|
|
88
88
|
};
|
|
@@ -102,8 +102,8 @@ export type SwapTradeAction = {
|
|
|
102
102
|
orderKey: string;
|
|
103
103
|
reason?: string;
|
|
104
104
|
reasonBytes?: string | Uint8Array;
|
|
105
|
+
timestamp: number;
|
|
105
106
|
transaction: {
|
|
106
|
-
timestamp: number;
|
|
107
107
|
hash: string;
|
|
108
108
|
};
|
|
109
109
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export type GraphQlFilters = {
|
|
2
|
-
|
|
2
|
+
OR: GraphQlFilters[];
|
|
3
3
|
} | {
|
|
4
|
-
|
|
4
|
+
AND: GraphQlFilters[];
|
|
5
5
|
} | {
|
|
6
6
|
/**
|
|
7
7
|
* `or` must be a single key-value pair in the object.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
OR?: never;
|
|
10
10
|
/**
|
|
11
11
|
* `and` must be a single key-value pair in the object.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
AND?: never;
|
|
14
14
|
/**
|
|
15
15
|
* Key must not start with an `_`. If you want to use nested filtering add `_` to the parent key itself if possible.
|
|
16
16
|
* Otherwise, if for some reason the field name itself starts with an `_`, change these types.
|
|
@@ -18,4 +18,6 @@ export type GraphQlFilters = {
|
|
|
18
18
|
[key: `_${string}`]: never;
|
|
19
19
|
[key: string]: string | number | boolean | undefined | GraphQlFilters | string[] | number[] | GraphQlFilters[] | null;
|
|
20
20
|
};
|
|
21
|
-
export declare function buildFiltersBody(filters: GraphQlFilters
|
|
21
|
+
export declare function buildFiltersBody(filters: GraphQlFilters, options?: {
|
|
22
|
+
enums?: Record<string, string>;
|
|
23
|
+
}): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MarketsInfoData } from "../types/markets";
|
|
2
|
+
import { Token, TokensData } from "../types/tokens";
|
|
3
|
+
import type { PositionTradeAction } from "../types/tradeHistory";
|
|
4
|
+
import type { RawTradeAction } from "../types/tradeHistory";
|
|
5
|
+
import type { SwapTradeAction } from "../types/tradeHistory";
|
|
6
|
+
export declare function createRawTradeActionTransformer(marketsInfoData: MarketsInfoData, wrappedToken: Token, tokensData: TokensData): (value: RawTradeAction, index: number, array: RawTradeAction[]) => SwapTradeAction | PositionTradeAction | undefined;
|
|
7
|
+
export declare function bigNumberify(n?: bigint | string | null | undefined): bigint | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmx-io/sdk",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./build/cjs/src/index.js",
|
|
6
6
|
"module": "./build/esm/src/index.js",
|
|
@@ -9,37 +9,37 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./build/esm/src/index.js",
|
|
11
11
|
"require": "./build/cjs/src/index.js",
|
|
12
|
-
"types": "./build/
|
|
12
|
+
"types": "./build/src/index.d.ts",
|
|
13
13
|
"default": "./build/cjs/src/index.js"
|
|
14
14
|
},
|
|
15
15
|
"./abis/*": {
|
|
16
16
|
"import": "./build/esm/src/abis/*",
|
|
17
17
|
"require": "./build/cjs/src/abis/*",
|
|
18
|
-
"types": "./build/
|
|
18
|
+
"types": "./build/src/abis/*",
|
|
19
19
|
"default": "./build/cjs/src/abis/*"
|
|
20
20
|
},
|
|
21
21
|
"./prebuilt/*": {
|
|
22
22
|
"import": "./build/esm/src/prebuilt/*",
|
|
23
23
|
"require": "./build/cjs/src/prebuilt/*",
|
|
24
|
-
"types": "./build/
|
|
24
|
+
"types": "./build/src/prebuilt/*",
|
|
25
25
|
"default": "./build/cjs/src/prebuilt/*"
|
|
26
26
|
},
|
|
27
27
|
"./utils/*": {
|
|
28
28
|
"import": "./build/esm/src/utils/*",
|
|
29
29
|
"require": "./build/cjs/src/utils/*",
|
|
30
|
-
"types": "./build/
|
|
30
|
+
"types": "./build/src/utils/*",
|
|
31
31
|
"default": "./build/cjs/src/utils/*"
|
|
32
32
|
},
|
|
33
33
|
"./types/*": {
|
|
34
34
|
"import": "./build/esm/src/types/*",
|
|
35
35
|
"require": "./build/cjs/src/types/*",
|
|
36
|
-
"types": "./build/
|
|
36
|
+
"types": "./build/src/types/*",
|
|
37
37
|
"default": "./build/cjs/src/types/*"
|
|
38
38
|
},
|
|
39
39
|
"./configs/*": {
|
|
40
40
|
"import": "./build/esm/src/configs/*",
|
|
41
41
|
"require": "./build/cjs/src/configs/*",
|
|
42
|
-
"types": "./build/
|
|
42
|
+
"types": "./build/src/configs/*",
|
|
43
43
|
"default": "./build/cjs/src/configs/*"
|
|
44
44
|
}
|
|
45
45
|
},
|