@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.
- package/README.md +25 -7
- package/build/scripts/prebuild/index.js +2 -0
- package/build/scripts/prebuild/prebuildKinkModelMarketRatesKeys.d.ts +1 -0
- package/build/scripts/prebuild/prebuildKinkModelMarketRatesKeys.js +44 -0
- package/build/src/abis/ExchangeRouter.json +203 -0
- package/build/src/abis/GlvReader.json +0 -10
- package/build/src/abis/GlvRouter.json +96 -2
- package/build/src/abis/RewardRouter.json +323 -68
- package/build/src/abis/SubaccountRouter.json +10 -0
- package/build/src/abis/SyntheticsReader.json +196 -64
- package/build/src/configs/batch.js +1 -13
- package/build/src/configs/chains.d.ts +0 -1
- package/build/src/configs/chains.js +1 -7
- package/build/src/configs/contracts.d.ts +2 -1
- package/build/src/configs/contracts.js +27 -66
- package/build/src/configs/dataStore.d.ts +4 -1
- package/build/src/configs/dataStore.js +5 -2
- package/build/src/configs/factors.d.ts +0 -12
- package/build/src/configs/factors.js +0 -12
- package/build/src/configs/markets.js +147 -0
- package/build/src/configs/tokens.d.ts +5 -2
- package/build/src/configs/tokens.js +297 -221
- package/build/src/modules/markets/index.js +2 -3
- package/build/src/modules/markets/markets.spec.js +0 -6
- package/build/src/modules/markets/types.d.ts +8 -0
- package/build/src/modules/oracle.js +1 -16
- package/build/src/modules/orders/orders.d.ts +2 -1
- package/build/src/modules/orders/orders.js +4 -3
- package/build/src/modules/orders/transactions/cancelOrdersTxn.js +1 -1
- package/build/src/modules/orders/transactions/createDecreaseOrderTxn.js +1 -0
- package/build/src/modules/orders/transactions/createIncreaseOrderTxn.d.ts +1 -0
- package/build/src/modules/orders/transactions/createIncreaseOrderTxn.js +3 -1
- package/build/src/modules/orders/transactions/createSwapOrderTxn.js +1 -0
- package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.d.ts +1 -1
- package/build/src/modules/orders/transactions/updateOrderTxn.d.ts +3 -1
- package/build/src/modules/orders/transactions/updateOrderTxn.js +7 -5
- package/build/src/modules/orders/utils.js +1 -1
- package/build/src/modules/positions/positions.d.ts +1 -1
- package/build/src/modules/positions/positions.js +10 -86
- package/build/src/modules/trades/trades.js +1 -2
- package/build/src/modules/utils/utils.js +3 -8
- package/build/src/prebuilt/hashedKinkModelMarketRatesKeys.json +760 -0
- package/build/src/prebuilt/hashedMarketConfigKeys.json +1050 -0
- package/build/src/prebuilt/hashedMarketValuesKeys.json +315 -0
- package/build/src/prebuilt/index.d.ts +8 -2
- package/build/src/prebuilt/index.js +3 -1
- package/build/src/prebuilt/index.ts +19 -2
- package/build/src/types/amounts.d.ts +1 -1
- package/build/src/types/fees.d.ts +1 -2
- package/build/src/types/orders.d.ts +2 -2
- package/build/src/types/positions.d.ts +2 -2
- package/build/src/types/sdk.d.ts +4 -4
- package/build/src/types/syntheticsEvents.d.ts +3 -3
- package/build/src/types/tokens.d.ts +4 -0
- package/build/src/types/trade.d.ts +1 -1
- package/build/src/utils/fees/executionFee.d.ts +1 -5
- package/build/src/utils/fees/executionFee.js +3 -12
- package/build/src/utils/objects.d.ts +0 -5
- package/build/src/utils/objects.js +0 -17
- package/build/src/utils/orders.js +0 -8
- package/build/src/utils/simulateExecuteOrder.js +8 -21
- package/build/src/utils/testUtil.d.ts +2 -3
- package/build/src/utils/testUtil.js +2 -3
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/build/src/configs/subgraph.d.ts +0 -3
- package/build/src/configs/subgraph.js +0 -3
- package/build/src/utils/slidingWindowFallbackSwitcher.d.ts +0 -24
- package/build/src/utils/slidingWindowFallbackSwitcher.js +0 -40
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { decodeErrorResult, encodeFunctionData, withRetry } from "viem";
|
|
2
2
|
import CustomErrors from "../abis/CustomErrors.json";
|
|
3
|
-
import DataStore from "../abis/DataStore.json";
|
|
4
3
|
import ExchangeRouter from "../abis/ExchangeRouter.json";
|
|
5
4
|
import Multicall from "../abis/Multicall.json";
|
|
6
5
|
import { getContract } from "../configs/contracts";
|
|
7
|
-
import { NONCE_KEY, orderKey } from "../configs/dataStore";
|
|
8
6
|
import { convertTokenAddress } from "../configs/tokens";
|
|
9
7
|
import { convertToContractPrice, getTokenData } from "./tokens";
|
|
10
8
|
import { extractError } from "./contracts";
|
|
@@ -15,26 +13,15 @@ export async function simulateExecuteOrder(sdk, p) {
|
|
|
15
13
|
if (!account) {
|
|
16
14
|
throw new Error("Account is not defined");
|
|
17
15
|
}
|
|
18
|
-
const dataStoreAddress = getContract(chainId, "DataStore");
|
|
19
16
|
const multicallAddress = getContract(chainId, "Multicall");
|
|
20
17
|
const exchangeRouterAddress = getContract(chainId, "ExchangeRouter");
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}),
|
|
28
|
-
client.readContract({
|
|
29
|
-
address: multicallAddress,
|
|
30
|
-
abi: Multicall.abi,
|
|
31
|
-
functionName: "getCurrentBlockTimestamp",
|
|
32
|
-
args: [],
|
|
33
|
-
}),
|
|
34
|
-
]);
|
|
18
|
+
const blockTimestamp = await client.readContract({
|
|
19
|
+
address: multicallAddress,
|
|
20
|
+
abi: Multicall.abi,
|
|
21
|
+
functionName: "getCurrentBlockTimestamp",
|
|
22
|
+
args: [],
|
|
23
|
+
});
|
|
35
24
|
const blockNumber = await client.getBlockNumber();
|
|
36
|
-
const nextNonce = nonce + 1n;
|
|
37
|
-
const nextKey = orderKey(dataStoreAddress, nextNonce);
|
|
38
25
|
const { primaryTokens, primaryPrices } = getSimulationPrices(chainId, p.tokensData, p.primaryPriceOverrides);
|
|
39
26
|
const priceTimestamp = blockTimestamp + 10n;
|
|
40
27
|
const simulationPriceParams = {
|
|
@@ -49,8 +36,8 @@ export async function simulateExecuteOrder(sdk, p) {
|
|
|
49
36
|
let encodedFunctionData;
|
|
50
37
|
encodedFunctionData = encodeFunctionData({
|
|
51
38
|
abi: routerAbi,
|
|
52
|
-
functionName: "
|
|
53
|
-
args: [
|
|
39
|
+
functionName: "simulateExecuteLatestOrder",
|
|
40
|
+
args: [simulationPriceParams],
|
|
54
41
|
});
|
|
55
42
|
simulationPayloadData.push(encodedFunctionData);
|
|
56
43
|
try {
|
|
@@ -568,8 +568,7 @@ export declare const arbitrumSdkConfig: {
|
|
|
568
568
|
watchEvent: <const TAbiEvent_2 extends import("abitype").AbiEvent | undefined = undefined, const TAbiEvents_2 extends readonly unknown[] | readonly import("abitype").AbiEvent[] | undefined = TAbiEvent_2 extends import("abitype").AbiEvent ? [TAbiEvent_2] : undefined, TStrict_6 extends boolean | undefined = undefined>(args: import("viem").WatchEventParameters<TAbiEvent_2, TAbiEvents_2, TStrict_6, import("viem").HttpTransport>) => import("viem").WatchEventReturnType;
|
|
569
569
|
watchPendingTransactions: (args: import("viem").WatchPendingTransactionsParameters<import("viem").HttpTransport>) => import("viem").WatchPendingTransactionsReturnType;
|
|
570
570
|
} & import("viem").TestActions>;
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
};
|
|
571
|
+
subsquidUrl: string;
|
|
572
|
+
subgraphUrl: string;
|
|
574
573
|
};
|
|
575
574
|
export declare const arbitrumSdk: GmxSdk;
|
|
@@ -14,8 +14,7 @@ export const arbitrumSdkConfig = {
|
|
|
14
14
|
oracleUrl: "https://arbitrum-api.gmxinfra.io",
|
|
15
15
|
rpcUrl: "https://arb1.arbitrum.io/rpc",
|
|
16
16
|
walletClient: client,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
17
|
+
subsquidUrl: "https://gmx.squids.live/gmx-synthetics-arbitrum:live/api/graphql",
|
|
18
|
+
subgraphUrl: "https://subgraph.satsuma-prod.com/3b2ced13c8d9/gmx/synthetics-arbitrum-stats/api",
|
|
20
19
|
};
|
|
21
20
|
export const arbitrumSdk = new GmxSdk(arbitrumSdkConfig);
|