@gmx-io/sdk 0.0.6 → 0.0.8
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/build/src/configs/dataStore.js +1 -1
- package/build/src/configs/tokens.d.ts +1 -1
- package/build/src/index.d.ts +14 -14
- package/build/src/index.js +18 -18
- package/build/src/modules/accounts/accounts.js +2 -2
- package/build/src/modules/accounts/accounts.spec.js +1 -1
- package/build/src/modules/markets/index.js +8 -8
- package/build/src/modules/markets/markets.spec.js +1 -1
- package/build/src/modules/markets/query-builders.d.ts +2 -2
- package/build/src/modules/markets/query-builders.js +9 -9
- package/build/src/modules/markets/types.d.ts +3 -3
- package/build/src/modules/oracle.d.ts +1 -1
- package/build/src/modules/oracle.js +1 -1
- package/build/src/modules/orders/orders.d.ts +6 -6
- package/build/src/modules/orders/orders.js +4 -4
- package/build/src/modules/orders/orders.spec.js +1 -1
- package/build/src/modules/orders/transactions/cancelOrdersTxn.js +2 -2
- package/build/src/modules/orders/transactions/createDecreaseOrderTxn.d.ts +2 -2
- package/build/src/modules/orders/transactions/createDecreaseOrderTxn.js +7 -7
- package/build/src/modules/orders/transactions/createIncreaseOrderTxn.d.ts +2 -2
- package/build/src/modules/orders/transactions/createIncreaseOrderTxn.js +8 -8
- package/build/src/modules/orders/transactions/createSwapOrderTxn.d.ts +2 -2
- package/build/src/modules/orders/transactions/createSwapOrderTxn.js +7 -7
- package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.js +2 -2
- package/build/src/modules/orders/transactions/updateOrderTxn.d.ts +1 -1
- package/build/src/modules/orders/transactions/updateOrderTxn.js +3 -3
- package/build/src/modules/orders/utils.d.ts +8 -8
- package/build/src/modules/orders/utils.js +9 -9
- package/build/src/modules/positions/positions.d.ts +4 -4
- package/build/src/modules/positions/positions.js +14 -14
- package/build/src/modules/positions/positions.spec.js +1 -1
- package/build/src/modules/tokens/tokens.d.ts +1 -1
- package/build/src/modules/tokens/tokens.js +5 -5
- package/build/src/modules/tokens/tokens.spec.js +1 -1
- package/build/src/modules/trades/trades.d.ts +4 -4
- package/build/src/modules/trades/trades.js +10 -10
- package/build/src/modules/trades/trades.spec.js +1 -1
- package/build/src/prebuilt/index.d.ts +1 -1
- package/build/src/types/fees.d.ts +1 -1
- package/build/src/types/trade.d.ts +1 -1
- package/build/src/utils/callContract.js +2 -2
- package/build/src/utils/fees/executionFee.d.ts +3 -3
- package/build/src/utils/fees/executionFee.js +6 -6
- package/build/src/utils/fees/index.d.ts +3 -3
- package/build/src/utils/fees/index.js +3 -3
- package/build/src/utils/fees/priceImpact.d.ts +2 -2
- package/build/src/utils/fees/priceImpact.js +5 -5
- package/build/src/utils/marketKeysAndConfigs.d.ts +1 -1
- package/build/src/utils/marketKeysAndConfigs.js +2 -2
- package/build/src/utils/markets.d.ts +3 -3
- package/build/src/utils/markets.js +2 -2
- package/build/src/utils/multicall.js +1 -1
- package/build/src/utils/numbers.js +1 -1
- package/build/src/utils/orders.d.ts +3 -3
- package/build/src/utils/orders.js +1 -1
- package/build/src/utils/positions.d.ts +3 -3
- package/build/src/utils/positions.js +1 -1
- package/build/src/utils/prices.d.ts +3 -3
- package/build/src/utils/prices.js +2 -2
- package/build/src/utils/simulateExecuteOrder.d.ts +2 -2
- package/build/src/utils/simulateExecuteOrder.js +7 -7
- package/build/src/utils/swapStats.d.ts +2 -2
- package/build/src/utils/swapStats.js +1 -1
- package/build/src/utils/testUtil.js +1 -1
- package/build/src/utils/tokens.d.ts +2 -2
- package/build/src/utils/tokens.js +1 -1
- package/build/src/utils/trade.d.ts +1 -1
- package/build/src/utils/trade.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hashData, hashString } from "utils/hash";
|
|
1
|
+
import { hashData, hashString } from "../utils/hash";
|
|
2
2
|
export const POSITION_IMPACT_FACTOR_KEY = hashString("POSITION_IMPACT_FACTOR");
|
|
3
3
|
export const MAX_POSITION_IMPACT_FACTOR_KEY = hashString("MAX_POSITION_IMPACT_FACTOR");
|
|
4
4
|
export const POSITION_IMPACT_EXPONENT_FACTOR_KEY = hashString("POSITION_IMPACT_EXPONENT_FACTOR");
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Abi, Address, PublicClient, WalletClient } from "viem";
|
|
2
|
-
import { Accounts } from "modules/accounts/accounts";
|
|
3
|
-
import { Markets } from "modules/markets";
|
|
4
|
-
import { Orders } from "modules/orders/orders";
|
|
5
|
-
import { Positions } from "modules/positions/positions";
|
|
6
|
-
import { Tokens } from "modules/tokens/tokens";
|
|
7
|
-
import { Trades } from "modules/trades/trades";
|
|
8
|
-
import { Oracle } from "modules/oracle";
|
|
9
|
-
import type { GmxSdkConfig } from "types/sdk";
|
|
10
|
-
import type { IncreasePositionAmounts } from "types/amounts";
|
|
11
|
-
import type { GasLimitsConfig } from "types/fees";
|
|
12
|
-
import type { DecreasePositionAmounts, SwapAmounts, TradeFeesType } from "types/trade";
|
|
13
|
-
import { CallContractOpts } from "utils/callContract";
|
|
14
|
-
import { MulticallRequestConfig } from "utils/multicall";
|
|
2
|
+
import { Accounts } from "./modules/accounts/accounts";
|
|
3
|
+
import { Markets } from "./modules/markets";
|
|
4
|
+
import { Orders } from "./modules/orders/orders";
|
|
5
|
+
import { Positions } from "./modules/positions/positions";
|
|
6
|
+
import { Tokens } from "./modules/tokens/tokens";
|
|
7
|
+
import { Trades } from "./modules/trades/trades";
|
|
8
|
+
import { Oracle } from "./modules/oracle";
|
|
9
|
+
import type { GmxSdkConfig } from "./types/sdk";
|
|
10
|
+
import type { IncreasePositionAmounts } from "./types/amounts";
|
|
11
|
+
import type { GasLimitsConfig } from "./types/fees";
|
|
12
|
+
import type { DecreasePositionAmounts, SwapAmounts, TradeFeesType } from "./types/trade";
|
|
13
|
+
import { CallContractOpts } from "./utils/callContract";
|
|
14
|
+
import { MulticallRequestConfig } from "./utils/multicall";
|
|
15
15
|
export declare class GmxSdk {
|
|
16
16
|
config: GmxSdkConfig;
|
|
17
17
|
readonly markets: Markets;
|
|
@@ -41,6 +41,6 @@ export declare class GmxSdk {
|
|
|
41
41
|
swapAmounts?: SwapAmounts;
|
|
42
42
|
decreaseAmounts?: DecreasePositionAmounts;
|
|
43
43
|
increaseAmounts?: IncreasePositionAmounts;
|
|
44
|
-
}): Promise<import("types/fees").ExecutionFee | undefined>;
|
|
44
|
+
}): Promise<import("./types/fees").ExecutionFee | undefined>;
|
|
45
45
|
getGasPrice(): Promise<bigint | undefined>;
|
|
46
46
|
}
|
package/build/src/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { createPublicClient, createWalletClient, http, withRetry, } from "viem";
|
|
2
|
-
import { Accounts } from "modules/accounts/accounts";
|
|
3
|
-
import { Markets } from "modules/markets";
|
|
4
|
-
import { Orders } from "modules/orders/orders";
|
|
5
|
-
import { Positions } from "modules/positions/positions";
|
|
6
|
-
import { Tokens } from "modules/tokens/tokens";
|
|
7
|
-
import { Trades } from "modules/trades/trades";
|
|
8
|
-
import { Oracle } from "modules/oracle";
|
|
9
|
-
import { BATCH_CONFIGS } from "configs/batch";
|
|
10
|
-
import { getContract } from "configs/contracts";
|
|
11
|
-
import { EXECUTION_FEE_CONFIG_V2, GAS_PRICE_PREMIUM_MAP, getChain, MAX_PRIORITY_FEE_PER_GAS_MAP } from "configs/chains";
|
|
12
|
-
import { decreaseOrderGasLimitKey, depositGasLimitKey, ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1, ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR, ESTIMATED_GAS_FEE_PER_ORACLE_PRICE, GLV_DEPOSIT_GAS_LIMIT, GLV_PER_MARKET_GAS_LIMIT, GLV_WITHDRAWAL_GAS_LIMIT, increaseOrderGasLimitKey, shiftGasLimitKey, singleSwapGasLimitKey, swapOrderGasLimitKey, withdrawalGasLimitKey, } from "configs/dataStore";
|
|
13
|
-
import DataStore from "abis/DataStore.json";
|
|
14
|
-
import { bigMath } from "utils/bigmath";
|
|
15
|
-
import { callContract } from "utils/callContract";
|
|
16
|
-
import { estimateOrderOraclePriceCount } from "utils/fees/estimateOraclePriceCount";
|
|
17
|
-
import { estimateExecuteDecreaseOrderGasLimit, estimateExecuteIncreaseOrderGasLimit, estimateExecuteSwapOrderGasLimit, getExecutionFee, } from "utils/fees/executionFee";
|
|
18
|
-
import { getSwapCount } from "utils/trade";
|
|
19
|
-
import { MAX_TIMEOUT, Multicall } from "utils/multicall";
|
|
2
|
+
import { Accounts } from "./modules/accounts/accounts";
|
|
3
|
+
import { Markets } from "./modules/markets";
|
|
4
|
+
import { Orders } from "./modules/orders/orders";
|
|
5
|
+
import { Positions } from "./modules/positions/positions";
|
|
6
|
+
import { Tokens } from "./modules/tokens/tokens";
|
|
7
|
+
import { Trades } from "./modules/trades/trades";
|
|
8
|
+
import { Oracle } from "./modules/oracle";
|
|
9
|
+
import { BATCH_CONFIGS } from "./configs/batch";
|
|
10
|
+
import { getContract } from "./configs/contracts";
|
|
11
|
+
import { EXECUTION_FEE_CONFIG_V2, GAS_PRICE_PREMIUM_MAP, getChain, MAX_PRIORITY_FEE_PER_GAS_MAP } from "./configs/chains";
|
|
12
|
+
import { decreaseOrderGasLimitKey, depositGasLimitKey, ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1, ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR, ESTIMATED_GAS_FEE_PER_ORACLE_PRICE, GLV_DEPOSIT_GAS_LIMIT, GLV_PER_MARKET_GAS_LIMIT, GLV_WITHDRAWAL_GAS_LIMIT, increaseOrderGasLimitKey, shiftGasLimitKey, singleSwapGasLimitKey, swapOrderGasLimitKey, withdrawalGasLimitKey, } from "./configs/dataStore";
|
|
13
|
+
import DataStore from "./abis/DataStore.json";
|
|
14
|
+
import { bigMath } from "./utils/bigmath";
|
|
15
|
+
import { callContract } from "./utils/callContract";
|
|
16
|
+
import { estimateOrderOraclePriceCount } from "./utils/fees/estimateOraclePriceCount";
|
|
17
|
+
import { estimateExecuteDecreaseOrderGasLimit, estimateExecuteIncreaseOrderGasLimit, estimateExecuteSwapOrderGasLimit, getExecutionFee, } from "./utils/fees/executionFee";
|
|
18
|
+
import { getSwapCount } from "./utils/trade";
|
|
19
|
+
import { MAX_TIMEOUT, Multicall } from "./utils/multicall";
|
|
20
20
|
export class GmxSdk {
|
|
21
21
|
constructor(config) {
|
|
22
22
|
this.config = config;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getContract } from "configs/contracts";
|
|
1
|
+
import { getContract } from "../../configs/contracts";
|
|
2
2
|
import { Module } from "../base";
|
|
3
|
-
import GovToken from "abis/GovToken.json";
|
|
3
|
+
import GovToken from "../../abis/GovToken.json";
|
|
4
4
|
export class Accounts extends Module {
|
|
5
5
|
get govTokenAddress() {
|
|
6
6
|
let govTokenAddress;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { zeroAddress } from "viem";
|
|
2
|
-
import { getContract } from "configs/contracts";
|
|
3
|
-
import { getSubgraphUrl } from "configs/subgraph";
|
|
4
|
-
import { convertTokenAddress, getToken } from "configs/tokens";
|
|
5
|
-
import SyntheticsReader from "abis/SyntheticsReader.json";
|
|
6
|
-
import { TIMEZONE_OFFSET_SEC } from "utils/common";
|
|
7
|
-
import graphqlFetcher from "utils/graphqlFetcher";
|
|
8
|
-
import { getMarketDivisor, getMarketFullName } from "utils/markets";
|
|
9
|
-
import { getByKey } from "utils/objects";
|
|
2
|
+
import { getContract } from "../../configs/contracts";
|
|
3
|
+
import { getSubgraphUrl } from "../../configs/subgraph";
|
|
4
|
+
import { convertTokenAddress, getToken } from "../../configs/tokens";
|
|
5
|
+
import SyntheticsReader from "../../abis/SyntheticsReader.json";
|
|
6
|
+
import { TIMEZONE_OFFSET_SEC } from "../../utils/common";
|
|
7
|
+
import graphqlFetcher from "../../utils/graphqlFetcher";
|
|
8
|
+
import { getMarketDivisor, getMarketFullName } from "../../utils/markets";
|
|
9
|
+
import { getByKey } from "../../utils/objects";
|
|
10
10
|
import { Module } from "../base";
|
|
11
11
|
import { buildClaimableFundingDataRequest, buildMarketsConfigsRequest, buildMarketsValuesRequest, } from "./query-builders";
|
|
12
12
|
export class Markets extends Module {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GmxSdk } from "../../index";
|
|
2
|
-
import { arbitrumSdk, arbitrumSdkConfig } from "utils/testUtil";
|
|
2
|
+
import { arbitrumSdk, arbitrumSdkConfig } from "../../utils/testUtil";
|
|
3
3
|
describe("Markets", () => {
|
|
4
4
|
describe("getMarkets", () => {
|
|
5
5
|
it("should be able to get markets", async () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MarketsData } from "types/markets";
|
|
2
|
-
import { TokensData } from "types/tokens";
|
|
1
|
+
import { MarketsData } from "../../types/markets";
|
|
2
|
+
import { TokensData } from "../../types/tokens";
|
|
3
3
|
export declare function buildClaimableFundingDataRequest({ marketsAddresses, marketsData, chainId, account, }: {
|
|
4
4
|
marketsAddresses: string[] | undefined;
|
|
5
5
|
marketsData: MarketsData | undefined;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { getContractMarketPrices } from "utils/markets";
|
|
2
|
-
import { getByKey } from "utils/objects";
|
|
3
|
-
import DataStore from "abis/DataStore.json";
|
|
4
|
-
import SyntheticsReader from "abis/SyntheticsReader.json";
|
|
5
|
-
import { CLAIMABLE_FUNDING_AMOUNT, MAX_PNL_FACTOR_FOR_TRADERS_KEY } from "configs/dataStore";
|
|
6
|
-
import { HASHED_MARKET_CONFIG_KEYS, HASHED_MARKET_VALUES_KEYS } from "prebuilt";
|
|
7
|
-
import { hashDataMap } from "utils/hash";
|
|
8
|
-
import { getContract } from "configs/contracts";
|
|
9
|
-
import { hashMarketConfigKeys, hashMarketValuesKeys } from "utils/marketKeysAndConfigs";
|
|
1
|
+
import { getContractMarketPrices } from "../../utils/markets";
|
|
2
|
+
import { getByKey } from "../../utils/objects";
|
|
3
|
+
import DataStore from "../../abis/DataStore.json";
|
|
4
|
+
import SyntheticsReader from "../../abis/SyntheticsReader.json";
|
|
5
|
+
import { CLAIMABLE_FUNDING_AMOUNT, MAX_PNL_FACTOR_FOR_TRADERS_KEY } from "../../configs/dataStore";
|
|
6
|
+
import { HASHED_MARKET_CONFIG_KEYS, HASHED_MARKET_VALUES_KEYS } from "../../prebuilt";
|
|
7
|
+
import { hashDataMap } from "../../utils/hash";
|
|
8
|
+
import { getContract } from "../../configs/contracts";
|
|
9
|
+
import { hashMarketConfigKeys, hashMarketValuesKeys } from "../../utils/marketKeysAndConfigs";
|
|
10
10
|
export function buildClaimableFundingDataRequest({ marketsAddresses, marketsData, chainId, account, }) {
|
|
11
11
|
if (!marketsAddresses) {
|
|
12
12
|
return {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MarketInfo, MarketsData, MarketsInfoData } from "types/markets";
|
|
2
|
-
import { TokensData } from "types/tokens";
|
|
3
|
-
import { MulticallRequestConfig } from "utils/multicall";
|
|
1
|
+
import { MarketInfo, MarketsData, MarketsInfoData } from "../../types/markets";
|
|
2
|
+
import { TokensData } from "../../types/tokens";
|
|
3
|
+
import { MulticallRequestConfig } from "../../utils/multicall";
|
|
4
4
|
export type MarketsResult = {
|
|
5
5
|
marketsData?: MarketsData;
|
|
6
6
|
marketsAddresses?: string[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MarketFilterLongShortItemData } from "
|
|
2
|
-
import { MarketInfo, MarketsInfoData } from "types/markets";
|
|
3
|
-
import { OrdersInfoData, OrderType } from "types/orders";
|
|
4
|
-
import { SidecarLimitOrderEntryValid, SidecarSlTpOrderEntryValid } from "types/sidecarOrders";
|
|
5
|
-
import { TokenData, TokensData } from "types/tokens";
|
|
6
|
-
import { DecreasePositionAmounts, IncreasePositionAmounts, SwapAmounts } from "types/trade";
|
|
1
|
+
import { MarketFilterLongShortItemData } from "../trades/trades";
|
|
2
|
+
import { MarketInfo, MarketsInfoData } from "../../types/markets";
|
|
3
|
+
import { OrdersInfoData, OrderType } from "../../types/orders";
|
|
4
|
+
import { SidecarLimitOrderEntryValid, SidecarSlTpOrderEntryValid } from "../../types/sidecarOrders";
|
|
5
|
+
import { TokenData, TokensData } from "../../types/tokens";
|
|
6
|
+
import { DecreasePositionAmounts, IncreasePositionAmounts, SwapAmounts } from "../../types/trade";
|
|
7
7
|
import { Module } from "../base";
|
|
8
8
|
import { WrapOrUnwrapParams } from "./transactions/createWrapOrUnwrapTxn";
|
|
9
9
|
export declare class Orders extends Module {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getWrappedToken } from "configs/tokens";
|
|
2
|
-
import { OrderType } from "types/orders";
|
|
3
|
-
import { getByKey } from "utils/objects";
|
|
4
|
-
import { getOrderInfo, isOrderForPositionByData, isVisibleOrder } from "utils/orders";
|
|
1
|
+
import { getWrappedToken } from "../../configs/tokens";
|
|
2
|
+
import { OrderType } from "../../types/orders";
|
|
3
|
+
import { getByKey } from "../../utils/objects";
|
|
4
|
+
import { getOrderInfo, isOrderForPositionByData, isVisibleOrder } from "../../utils/orders";
|
|
5
5
|
import { createDecreaseOrderTxn } from "./transactions/createDecreaseOrderTxn";
|
|
6
6
|
import { createIncreaseOrderTxn } from "./transactions/createIncreaseOrderTxn";
|
|
7
7
|
import { buildGetOrdersMulticall, getExecutionFeeAmountForEntry, matchByMarket, parseGetOrdersResponse } from "./utils";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ExchangeRouter from "abis/ExchangeRouter.json";
|
|
2
|
-
import { getContract } from "configs/contracts";
|
|
1
|
+
import ExchangeRouter from "../../../abis/ExchangeRouter.json";
|
|
2
|
+
import { getContract } from "../../../configs/contracts";
|
|
3
3
|
import { encodeFunctionData } from "viem";
|
|
4
4
|
export async function cancelOrdersTxn(sdk, p) {
|
|
5
5
|
const multicall = createCancelEncodedPayload(p.orderKeys);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GmxSdk } from "../../../index";
|
|
2
|
-
import type { DecreasePositionSwapType, OrderType } from "types/orders";
|
|
3
|
-
import type { Token, TokensData } from "types/tokens";
|
|
2
|
+
import type { DecreasePositionSwapType, OrderType } from "../../../types/orders";
|
|
3
|
+
import type { Token, TokensData } from "../../../types/tokens";
|
|
4
4
|
export type DecreaseOrderParams = {
|
|
5
5
|
account: string;
|
|
6
6
|
marketAddress: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getContract } from "configs/contracts";
|
|
2
|
-
import ExchangeRouter from "abis/ExchangeRouter.json";
|
|
3
|
-
import { convertTokenAddress, NATIVE_TOKEN_ADDRESS } from "configs/tokens";
|
|
4
|
-
import { isMarketOrderType } from "utils/orders";
|
|
5
|
-
import { convertToContractPrice } from "utils/tokens";
|
|
6
|
-
import { applySlippageToMinOut, applySlippageToPrice } from "utils/trade";
|
|
1
|
+
import { getContract } from "../../../configs/contracts";
|
|
2
|
+
import ExchangeRouter from "../../../abis/ExchangeRouter.json";
|
|
3
|
+
import { convertTokenAddress, NATIVE_TOKEN_ADDRESS } from "../../../configs/tokens";
|
|
4
|
+
import { isMarketOrderType } from "../../../utils/orders";
|
|
5
|
+
import { convertToContractPrice } from "../../../utils/tokens";
|
|
6
|
+
import { applySlippageToMinOut, applySlippageToPrice } from "../../../utils/trade";
|
|
7
7
|
import { encodeFunctionData, zeroAddress, zeroHash } from "viem";
|
|
8
|
-
import { simulateExecuteOrder } from "utils/simulateExecuteOrder";
|
|
8
|
+
import { simulateExecuteOrder } from "../../../utils/simulateExecuteOrder";
|
|
9
9
|
export async function createDecreaseOrderTxn(sdk, params) {
|
|
10
10
|
const chainId = sdk.chainId;
|
|
11
11
|
const ps = Array.isArray(params) ? params : [params];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GmxSdk } from "index";
|
|
2
|
-
import { OrderTxnType, OrderType } from "types/orders";
|
|
3
|
-
import { TokenData, TokenPrices, TokensData } from "types/tokens";
|
|
2
|
+
import { OrderTxnType, OrderType } from "../../../types/orders";
|
|
3
|
+
import { TokenData, TokenPrices, TokensData } from "../../../types/tokens";
|
|
4
4
|
import { DecreaseOrderParams } from "./createDecreaseOrderTxn";
|
|
5
5
|
export type PriceOverrides = {
|
|
6
6
|
[address: string]: TokenPrices | undefined;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import ExchangeRouter from "abis/ExchangeRouter.json";
|
|
2
|
-
import { getContract } from "configs/contracts";
|
|
3
|
-
import { convertTokenAddress, NATIVE_TOKEN_ADDRESS } from "configs/tokens";
|
|
1
|
+
import ExchangeRouter from "../../../abis/ExchangeRouter.json";
|
|
2
|
+
import { getContract } from "../../../configs/contracts";
|
|
3
|
+
import { convertTokenAddress, NATIVE_TOKEN_ADDRESS } from "../../../configs/tokens";
|
|
4
4
|
import concat from "lodash/concat";
|
|
5
|
-
import { DecreasePositionSwapType } from "types/orders";
|
|
6
|
-
import { isMarketOrderType } from "utils/orders";
|
|
7
|
-
import { convertToContractPrice } from "utils/tokens";
|
|
8
|
-
import { applySlippageToMinOut, applySlippageToPrice } from "utils/trade";
|
|
5
|
+
import { DecreasePositionSwapType } from "../../../types/orders";
|
|
6
|
+
import { isMarketOrderType } from "../../../utils/orders";
|
|
7
|
+
import { convertToContractPrice } from "../../../utils/tokens";
|
|
8
|
+
import { applySlippageToMinOut, applySlippageToPrice } from "../../../utils/trade";
|
|
9
9
|
import { encodeFunctionData, zeroAddress, zeroHash } from "viem";
|
|
10
10
|
import { createCancelEncodedPayload } from "./cancelOrdersTxn";
|
|
11
11
|
import { createDecreaseEncodedPayload } from "./createDecreaseOrderTxn";
|
|
12
12
|
import { createUpdateEncodedPayload } from "./updateOrderTxn";
|
|
13
|
-
import { simulateExecuteOrder } from "utils/simulateExecuteOrder";
|
|
13
|
+
import { simulateExecuteOrder } from "../../../utils/simulateExecuteOrder";
|
|
14
14
|
export async function createIncreaseOrderTxn({ sdk, createIncreaseOrderParams: p, createDecreaseOrderParams, cancelOrderParams, updateOrderParams, }) {
|
|
15
15
|
const isNativePayment = p.initialCollateralAddress === NATIVE_TOKEN_ADDRESS;
|
|
16
16
|
const chainId = sdk.chainId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OrderType } from "types/orders";
|
|
2
|
-
import { TokensData } from "types/tokens";
|
|
1
|
+
import { OrderType } from "../../../types/orders";
|
|
2
|
+
import { TokensData } from "../../../types/tokens";
|
|
3
3
|
import type { GmxSdk } from "../../..";
|
|
4
4
|
export type SwapOrderParams = {
|
|
5
5
|
fromTokenAddress: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { encodeFunctionData, zeroAddress, zeroHash } from "viem";
|
|
2
|
-
import ExchangeRouter from "abis/ExchangeRouter.json";
|
|
3
|
-
import { getContract } from "configs/contracts";
|
|
4
|
-
import { NATIVE_TOKEN_ADDRESS, convertTokenAddress } from "configs/tokens";
|
|
5
|
-
import { DecreasePositionSwapType, OrderType } from "types/orders";
|
|
6
|
-
import { isMarketOrderType } from "utils/orders";
|
|
7
|
-
import { applySlippageToMinOut } from "utils/trade";
|
|
8
|
-
import { simulateExecuteOrder } from "utils/simulateExecuteOrder";
|
|
2
|
+
import ExchangeRouter from "../../../abis/ExchangeRouter.json";
|
|
3
|
+
import { getContract } from "../../../configs/contracts";
|
|
4
|
+
import { NATIVE_TOKEN_ADDRESS, convertTokenAddress } from "../../../configs/tokens";
|
|
5
|
+
import { DecreasePositionSwapType, OrderType } from "../../../types/orders";
|
|
6
|
+
import { isMarketOrderType } from "../../../utils/orders";
|
|
7
|
+
import { applySlippageToMinOut } from "../../../utils/trade";
|
|
8
|
+
import { simulateExecuteOrder } from "../../../utils/simulateExecuteOrder";
|
|
9
9
|
export async function createSwapOrderTxn(sdk, p) {
|
|
10
10
|
const { encodedPayload, totalWntAmount } = await getParams(sdk, p);
|
|
11
11
|
const { encodedPayload: simulationEncodedPayload, totalWntAmount: sumaltionTotalWntAmount } = await getParams(sdk, p);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import WETH from "abis/WETH.json";
|
|
2
|
-
import { getWrappedToken } from "configs/tokens";
|
|
1
|
+
import WETH from "../../../abis/WETH.json";
|
|
2
|
+
import { getWrappedToken } from "../../../configs/tokens";
|
|
3
3
|
export function createWrapOrUnwrapTxn(sdk, p) {
|
|
4
4
|
const wrappedToken = getWrappedToken(sdk.chainId);
|
|
5
5
|
if (p.isWrap) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import ExchangeRouter from "abis/ExchangeRouter.json";
|
|
2
|
-
import { getContract } from "configs/contracts";
|
|
3
|
-
import { convertToContractPrice } from "utils/tokens";
|
|
1
|
+
import ExchangeRouter from "../../../abis/ExchangeRouter.json";
|
|
2
|
+
import { getContract } from "../../../configs/contracts";
|
|
3
|
+
import { convertToContractPrice } from "../../../utils/tokens";
|
|
4
4
|
import { encodeFunctionData } from "viem";
|
|
5
5
|
export function updateOrderTxn(sdk, p) {
|
|
6
6
|
const { orderKey, sizeDeltaUsd, triggerPrice, acceptablePrice, minOutputAmount, executionFee, indexToken } = p;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { GmxSdk } from "../../index";
|
|
2
|
-
import { MarketFilterLongShortDirection, MarketFilterLongShortItemData } from "
|
|
3
|
-
import { GasLimitsConfig } from "types/fees";
|
|
4
|
-
import { MarketsInfoData } from "types/markets";
|
|
5
|
-
import { DecreasePositionSwapType, Order } from "types/orders";
|
|
6
|
-
import { SidecarLimitOrderEntry, SidecarSlTpOrderEntry } from "types/sidecarOrders";
|
|
7
|
-
import { TokensData } from "types/tokens";
|
|
8
|
-
import { MulticallResult } from "utils/multicall";
|
|
2
|
+
import { MarketFilterLongShortDirection, MarketFilterLongShortItemData } from "../trades/trades";
|
|
3
|
+
import { GasLimitsConfig } from "../../types/fees";
|
|
4
|
+
import { MarketsInfoData } from "../../types/markets";
|
|
5
|
+
import { DecreasePositionSwapType, Order } from "../../types/orders";
|
|
6
|
+
import { SidecarLimitOrderEntry, SidecarSlTpOrderEntry } from "../../types/sidecarOrders";
|
|
7
|
+
import { TokensData } from "../../types/tokens";
|
|
8
|
+
import { MulticallResult } from "../../utils/multicall";
|
|
9
9
|
import { Address } from "viem";
|
|
10
|
-
export declare const getOrderExecutionFee: (sdk: GmxSdk, swapsCount: number, decreasePositionSwapType: DecreasePositionSwapType | undefined, gasLimits: GasLimitsConfig | undefined, tokensData: TokensData | undefined, gasPrice: bigint | undefined) => import("types/fees").ExecutionFee | undefined;
|
|
10
|
+
export declare const getOrderExecutionFee: (sdk: GmxSdk, swapsCount: number, decreasePositionSwapType: DecreasePositionSwapType | undefined, gasLimits: GasLimitsConfig | undefined, tokensData: TokensData | undefined, gasPrice: bigint | undefined) => import("../../types/fees").ExecutionFee | undefined;
|
|
11
11
|
export declare const getExecutionFeeAmountForEntry: (sdk: GmxSdk, entry: SidecarSlTpOrderEntry | SidecarLimitOrderEntry, gasLimits: GasLimitsConfig, tokensData: TokensData, gasPrice: bigint | undefined) => bigint | undefined;
|
|
12
12
|
export declare function matchByMarket({ order, nonSwapRelevantDefinedFiltersLowercased, hasNonSwapRelevantDefinedMarkets, pureDirectionFilters, hasPureDirectionFilters, swapRelevantDefinedMarketsLowercased, hasSwapRelevantDefinedMarkets, marketsInfoData, chainId, }: {
|
|
13
13
|
order: ReturnType<typeof parseGetOrdersResponse>["orders"][number];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import DataStore from "abis/DataStore.json";
|
|
2
|
-
import SyntheticsReader from "abis/SyntheticsReader.json";
|
|
3
|
-
import { getContract } from "configs/contracts";
|
|
4
|
-
import { accountOrderListKey } from "configs/dataStore";
|
|
5
|
-
import { getWrappedToken } from "configs/tokens";
|
|
6
|
-
import { estimateOrderOraclePriceCount } from "utils/fees/estimateOraclePriceCount";
|
|
7
|
-
import { estimateExecuteDecreaseOrderGasLimit, getExecutionFee } from "utils/fees/executionFee";
|
|
8
|
-
import { isIncreaseOrderType, isLimitOrderType, isSwapOrderType, isTriggerDecreaseOrderType } from "utils/orders";
|
|
9
|
-
import { getSwapPathOutputAddresses } from "utils/swapStats";
|
|
1
|
+
import DataStore from "../../abis/DataStore.json";
|
|
2
|
+
import SyntheticsReader from "../../abis/SyntheticsReader.json";
|
|
3
|
+
import { getContract } from "../../configs/contracts";
|
|
4
|
+
import { accountOrderListKey } from "../../configs/dataStore";
|
|
5
|
+
import { getWrappedToken } from "../../configs/tokens";
|
|
6
|
+
import { estimateOrderOraclePriceCount } from "../../utils/fees/estimateOraclePriceCount";
|
|
7
|
+
import { estimateExecuteDecreaseOrderGasLimit, getExecutionFee } from "../../utils/fees/executionFee";
|
|
8
|
+
import { isIncreaseOrderType, isLimitOrderType, isSwapOrderType, isTriggerDecreaseOrderType } from "../../utils/orders";
|
|
9
|
+
import { getSwapPathOutputAddresses } from "../../utils/swapStats";
|
|
10
10
|
import { isAddressEqual } from "viem";
|
|
11
11
|
export const getOrderExecutionFee = (sdk, swapsCount, decreasePositionSwapType, gasLimits, tokensData, gasPrice) => {
|
|
12
12
|
if (!gasLimits || !tokensData || gasPrice === undefined)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MarketsData, MarketsInfoData } from "types/markets";
|
|
2
|
-
import { PositionsData, PositionsInfoData } from "types/positions";
|
|
3
|
-
import { TokensData } from "types/tokens";
|
|
1
|
+
import { MarketsData, MarketsInfoData } from "../../types/markets";
|
|
2
|
+
import { PositionsData, PositionsInfoData } from "../../types/positions";
|
|
3
|
+
import { TokensData } from "../../types/tokens";
|
|
4
4
|
import { Module } from "../base";
|
|
5
|
-
import { OrderInfo } from "types/orders";
|
|
5
|
+
import { OrderInfo } from "../../types/orders";
|
|
6
6
|
type PositionsResult = {
|
|
7
7
|
positionsData?: PositionsData;
|
|
8
8
|
allPossiblePositionsKeys?: string[];
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { zeroAddress, zeroHash } from "viem";
|
|
2
|
-
import DataStore from "abis/DataStore.json";
|
|
3
|
-
import ReferralStorage from "abis/ReferralStorage.json";
|
|
4
|
-
import SyntheticsReader from "abis/SyntheticsReader.json";
|
|
5
|
-
import { getContract } from "configs/contracts";
|
|
6
|
-
import { hashedPositionKey, MAX_AUTO_CANCEL_ORDERS_KEY, MIN_COLLATERAL_USD_KEY, MIN_POSITION_SIZE_USD_KEY, uiFeeFactorKey, } from "configs/dataStore";
|
|
7
|
-
import { getContractMarketPrices, getMaxAllowedLeverageByMinCollateralFactor } from "utils/markets";
|
|
8
|
-
import { getByKey } from "utils/objects";
|
|
9
|
-
import { getEntryPrice, getLeverage, getLiquidationPrice, getPositionKey, getPositionNetValue, getPositionPnlUsd, parsePositionKey, } from "utils/positions";
|
|
2
|
+
import DataStore from "../../abis/DataStore.json";
|
|
3
|
+
import ReferralStorage from "../../abis/ReferralStorage.json";
|
|
4
|
+
import SyntheticsReader from "../../abis/SyntheticsReader.json";
|
|
5
|
+
import { getContract } from "../../configs/contracts";
|
|
6
|
+
import { hashedPositionKey, MAX_AUTO_CANCEL_ORDERS_KEY, MIN_COLLATERAL_USD_KEY, MIN_POSITION_SIZE_USD_KEY, uiFeeFactorKey, } from "../../configs/dataStore";
|
|
7
|
+
import { getContractMarketPrices, getMaxAllowedLeverageByMinCollateralFactor } from "../../utils/markets";
|
|
8
|
+
import { getByKey } from "../../utils/objects";
|
|
9
|
+
import { getEntryPrice, getLeverage, getLiquidationPrice, getPositionKey, getPositionNetValue, getPositionPnlUsd, parsePositionKey, } from "../../utils/positions";
|
|
10
10
|
import { Module } from "../base";
|
|
11
|
-
import { getPositionFee, getPriceImpactForPosition } from "utils/fees";
|
|
12
|
-
import { basisPointsToFloat, getBasisPoints } from "utils/numbers";
|
|
13
|
-
import { getPositionPendingFeesUsd } from "utils/positions";
|
|
14
|
-
import { getMarkPrice } from "utils/prices";
|
|
15
|
-
import { decodeReferralCode } from "utils/referrals";
|
|
16
|
-
import { convertToTokenAmount, convertToUsd } from "utils/tokens";
|
|
11
|
+
import { getPositionFee, getPriceImpactForPosition } from "../../utils/fees";
|
|
12
|
+
import { basisPointsToFloat, getBasisPoints } from "../../utils/numbers";
|
|
13
|
+
import { getPositionPendingFeesUsd } from "../../utils/positions";
|
|
14
|
+
import { getMarkPrice } from "../../utils/prices";
|
|
15
|
+
import { decodeReferralCode } from "../../utils/referrals";
|
|
16
|
+
import { convertToTokenAmount, convertToUsd } from "../../utils/tokens";
|
|
17
17
|
export class Positions extends Module {
|
|
18
18
|
constructor() {
|
|
19
19
|
super(...arguments);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getContract } from "configs/contracts";
|
|
2
|
-
import { NATIVE_TOKEN_ADDRESS, getToken, getTokensMap, getV2Tokens, getWrappedToken } from "configs/tokens";
|
|
3
|
-
import Multicall from "abis/Multicall.json";
|
|
4
|
-
import Token from "abis/Token.json";
|
|
1
|
+
import { getContract } from "../../configs/contracts";
|
|
2
|
+
import { NATIVE_TOKEN_ADDRESS, getToken, getTokensMap, getV2Tokens, getWrappedToken } from "../../configs/tokens";
|
|
3
|
+
import Multicall from "../../abis/Multicall.json";
|
|
4
|
+
import Token from "../../abis/Token.json";
|
|
5
5
|
import { Module } from "../base";
|
|
6
|
-
import { parseContractPrice } from "utils/tokens";
|
|
6
|
+
import { parseContractPrice } from "../../utils/tokens";
|
|
7
7
|
export class Tokens extends Module {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GmxSdk } from "../..";
|
|
2
|
-
import { arbitrumSdk, arbitrumSdkConfig } from "utils/testUtil";
|
|
2
|
+
import { arbitrumSdk, arbitrumSdkConfig } from "../../utils/testUtil";
|
|
3
3
|
describe("Tokens", () => {
|
|
4
4
|
it("should be able to fetch tokens", async () => {
|
|
5
5
|
const response = await arbitrumSdk.oracle.getTokens();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MarketsInfoData } from "types/markets";
|
|
2
|
-
import { OrderType } from "types/orders";
|
|
3
|
-
import { TokensData } from "types/tokens";
|
|
4
|
-
import { TradeAction, TradeActionType } from "types/tradeHistory";
|
|
1
|
+
import { MarketsInfoData } from "../../types/markets";
|
|
2
|
+
import { OrderType } from "../../types/orders";
|
|
3
|
+
import { TokensData } from "../../types/tokens";
|
|
4
|
+
import { TradeAction, TradeActionType } from "../../types/tradeHistory";
|
|
5
5
|
import { Address } from "viem";
|
|
6
6
|
import { Module } from "../base";
|
|
7
7
|
import { GmxSdk } from "index";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { getSubgraphUrl } from "configs/subgraph";
|
|
2
|
-
import { getWrappedToken } from "configs/tokens";
|
|
1
|
+
import { getSubgraphUrl } from "../../configs/subgraph";
|
|
2
|
+
import { getWrappedToken } from "../../configs/tokens";
|
|
3
3
|
import merge from "lodash/merge";
|
|
4
|
-
import { OrderType } from "types/orders";
|
|
5
|
-
import { TradeActionType } from "types/tradeHistory";
|
|
6
|
-
import graphqlFetcher from "utils/graphqlFetcher";
|
|
7
|
-
import { getByKey } from "utils/objects";
|
|
8
|
-
import { isIncreaseOrderType, isLimitOrderType, isSwapOrderType, isTriggerDecreaseOrderType } from "utils/orders";
|
|
9
|
-
import { buildFiltersBody } from "utils/subgraph";
|
|
10
|
-
import { getSwapPathOutputAddresses } from "utils/swapStats";
|
|
11
|
-
import { parseContractPrice } from "utils/tokens";
|
|
4
|
+
import { OrderType } from "../../types/orders";
|
|
5
|
+
import { TradeActionType } from "../../types/tradeHistory";
|
|
6
|
+
import graphqlFetcher from "../../utils/graphqlFetcher";
|
|
7
|
+
import { getByKey } from "../../utils/objects";
|
|
8
|
+
import { isIncreaseOrderType, isLimitOrderType, isSwapOrderType, isTriggerDecreaseOrderType } from "../../utils/orders";
|
|
9
|
+
import { buildFiltersBody } from "../../utils/subgraph";
|
|
10
|
+
import { getSwapPathOutputAddresses } from "../../utils/swapStats";
|
|
11
|
+
import { parseContractPrice } from "../../utils/tokens";
|
|
12
12
|
import { getAddress } from "viem";
|
|
13
13
|
import { Module } from "../base";
|
|
14
14
|
export class Trades extends Module {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarketConfigMulticallRequestConfig, MarketValuesMulticallRequestConfig } from "modules/markets/types";
|
|
1
|
+
import { MarketConfigMulticallRequestConfig, MarketValuesMulticallRequestConfig } from "../modules/markets/types";
|
|
2
2
|
type HashedMarketValuesKeys = Omit<Record<keyof MarketValuesMulticallRequestConfig[`${string}-dataStore`]["calls"], string>, "claimableFundingAmountLong" | "claimableFundingAmountShort">;
|
|
3
3
|
declare const HASHED_MARKET_VALUES_KEYS: {
|
|
4
4
|
[chainId: number]: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { encodeFunctionData, withRetry } from "viem";
|
|
2
|
-
import { GAS_PRICE_BUFFER_MAP, GAS_PRICE_PREMIUM_MAP, getChain, MAX_FEE_PER_GAS_MAP, MAX_PRIORITY_FEE_PER_GAS_MAP, } from "configs/chains";
|
|
3
|
-
import { BASIS_POINTS_DIVISOR_BIGINT } from "configs/factors";
|
|
2
|
+
import { GAS_PRICE_BUFFER_MAP, GAS_PRICE_PREMIUM_MAP, getChain, MAX_FEE_PER_GAS_MAP, MAX_PRIORITY_FEE_PER_GAS_MAP, } from "../configs/chains";
|
|
3
|
+
import { BASIS_POINTS_DIVISOR_BIGINT } from "../configs/factors";
|
|
4
4
|
import { bigMath } from "./bigmath";
|
|
5
5
|
export async function getGasPrice(client, chainId) {
|
|
6
6
|
let maxFeePerGas = MAX_FEE_PER_GAS_MAP[chainId];
|