@gmx-io/sdk 2.3.2 → 2.6.0-next.0
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/cjs/scripts/generate-synthetics-abis.js +17 -2
- package/build/cjs/src/abis/CustomErrors.js +98 -0
- package/build/cjs/src/abis/CustomErrorsV2_2_1.js +5565 -0
- package/build/cjs/src/abis/ExchangeRouterV2_2_1.js +1462 -0
- package/build/cjs/src/abis/GelatoRelayRouterV2_2_1.js +1945 -0
- package/build/cjs/src/abis/GlvReaderV2_2_1.js +1681 -0
- package/build/cjs/src/abis/MultichainClaimsRouterV2_2_1.js +1281 -0
- package/build/cjs/src/abis/MultichainGlvRouterV2_2_1.js +1176 -0
- package/build/cjs/src/abis/MultichainGmRouterV2_2_1.js +1480 -0
- package/build/cjs/src/abis/MultichainOrderRouterV2_2_1.js +2065 -0
- package/build/cjs/src/abis/MultichainSubaccountRouterV2_2_1.js +2160 -0
- package/build/cjs/src/abis/MultichainTransferRouterV2_2_1.js +1033 -0
- package/build/cjs/src/abis/RelayParamsV2_2_1.js +56 -0
- package/build/cjs/src/abis/RewardRouterV3.js +675 -0
- package/build/cjs/src/abis/SubaccountGelatoRelayRouterV2_2_1.js +2502 -0
- package/build/cjs/src/abis/SyntheticsReaderV2_2_1.js +5279 -0
- package/build/cjs/src/abis/__tests__/fixtures/arbitrumSepoliaReaders.json +8 -0
- package/build/cjs/src/abis/__tests__/getAbi.spec.js +84 -0
- package/build/cjs/src/abis/getAbi.js +42 -0
- package/build/cjs/src/abis/index.js +4 -1
- package/build/cjs/src/clients/v1/modules/orders/orders.js +5 -3
- package/build/cjs/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.js +3 -1
- package/build/cjs/src/clients/v1/modules/orders/transactions/updateOrderTxn.js +21 -25
- package/build/cjs/src/clients/v1/modules/orders/utils.js +6 -7
- package/build/cjs/src/clients/v1/modules/trades/trades.js +4 -3
- package/build/cjs/src/clients/v1/multicall.js +2 -1
- package/build/cjs/src/clients/v2/__tests__/decrease.spec.js +0 -2
- package/build/cjs/src/clients/v2/__tests__/editCancel.spec.js +0 -3
- package/build/cjs/src/clients/v2/__tests__/globalCleanup.js +0 -1
- package/build/cjs/src/clients/v2/__tests__/increase.spec.js +0 -2
- package/build/cjs/src/clients/v2/__tests__/subaccountLifecycle.spec.js +0 -1
- package/build/cjs/src/clients/v2/__tests__/testUtil.js +0 -1
- package/build/cjs/src/configs/__tests__/markets.spec.js +8 -1
- package/build/cjs/src/configs/chains.js +16 -1
- package/build/cjs/src/configs/contracts.js +27 -18
- package/build/cjs/src/configs/dataStore.js +13 -3
- package/build/cjs/src/configs/markets.js +12 -7
- package/build/cjs/src/configs/tokens.js +12 -7
- package/build/cjs/src/utils/__tests__/address.spec.js +50 -0
- package/build/cjs/src/utils/__tests__/numbers.spec.js +24 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +41 -4
- package/build/cjs/src/utils/__tests__/orderTransactions/updateOrder.spec.js +4 -0
- package/build/cjs/src/utils/__tests__/parseError.spec.js +61 -0
- package/build/cjs/src/utils/__tests__/referrals.spec.js +36 -4
- package/build/cjs/src/utils/address/index.js +17 -0
- package/build/cjs/src/utils/address/utils.js +32 -0
- package/build/cjs/src/utils/errors/parseError.js +10 -0
- package/build/cjs/src/utils/errors/transactionsErrors.js +23 -0
- package/build/cjs/src/utils/express/utils/batchOrderUtils.js +14 -9
- package/build/cjs/src/utils/express/utils/bridgeOutUtils.js +52 -17
- package/build/cjs/src/utils/express/utils/referralUtils.js +38 -25
- package/build/cjs/src/utils/express/utils/relayParamsUtils.js +11 -3
- package/build/cjs/src/utils/markets/__tests__/multicall.spec.js +27 -0
- package/build/cjs/src/utils/markets/multicall.js +5 -7
- package/build/cjs/src/utils/multichain/api.js +17 -8
- package/build/cjs/src/utils/numbers/utils.js +7 -1
- package/build/cjs/src/utils/orderTransactions/api.js +3 -4
- package/build/cjs/src/utils/orderTransactions/utils.js +8 -7
- package/build/cjs/src/utils/orders/utils.js +8 -1
- package/build/cjs/src/utils/paxos/__tests__/api.spec.js +23 -3
- package/build/cjs/src/utils/paxos/api.js +6 -0
- package/build/cjs/src/utils/referrals/utils.js +24 -15
- package/build/cjs/src/utils/subaccount/getEmptySubaccountApproval.js +2 -0
- package/build/cjs/src/utils/subaccount/getSubaccountApprovalTypedData.js +37 -15
- package/build/cjs/src/utils/subaccount/hashSubaccountApproval.js +32 -18
- package/build/cjs/src/utils/subaccount/index.js +4 -1
- package/build/cjs/src/utils/subaccount/sdkClient.js +1 -1
- package/build/cjs/src/utils/subaccount/state.js +10 -1
- package/build/cjs/src/utils/swap/preparedSwapData.js +6 -4
- package/build/cjs/src/utils/swap/swapPath.js +1 -1
- package/build/cjs/src/utils/trade/__tests__/decreaseMarginCheck.spec.js +224 -0
- package/build/cjs/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.js +128 -9
- package/build/cjs/src/utils/trade/decrease.js +198 -33
- package/build/cjs/src/utils/trade/decreaseMarginCheck.js +157 -0
- package/build/cjs/src/utils/trade/increaseMarginCheck.js +27 -15
- package/build/cjs/src/utils/trade/index.js +1 -0
- package/build/cjs/src/utils/tradeHistory/utils.js +6 -6
- package/build/esm/scripts/generate-synthetics-abis.js +17 -2
- package/build/esm/src/abis/CustomErrors.js +98 -0
- package/build/esm/src/abis/CustomErrorsV2_2_1.js +5563 -0
- package/build/esm/src/abis/ExchangeRouterV2_2_1.js +1460 -0
- package/build/esm/src/abis/GelatoRelayRouterV2_2_1.js +1943 -0
- package/build/esm/src/abis/GlvReaderV2_2_1.js +1679 -0
- package/build/esm/src/abis/MultichainClaimsRouterV2_2_1.js +1279 -0
- package/build/esm/src/abis/MultichainGlvRouterV2_2_1.js +1174 -0
- package/build/esm/src/abis/MultichainGmRouterV2_2_1.js +1478 -0
- package/build/esm/src/abis/MultichainOrderRouterV2_2_1.js +2063 -0
- package/build/esm/src/abis/MultichainSubaccountRouterV2_2_1.js +2158 -0
- package/build/esm/src/abis/MultichainTransferRouterV2_2_1.js +1031 -0
- package/build/esm/src/abis/RelayParamsV2_2_1.js +54 -0
- package/build/esm/src/abis/RewardRouterV3.js +673 -0
- package/build/esm/src/abis/SubaccountGelatoRelayRouterV2_2_1.js +2500 -0
- package/build/esm/src/abis/SyntheticsReaderV2_2_1.js +5277 -0
- package/build/esm/src/abis/__tests__/fixtures/arbitrumSepoliaReaders.json +8 -0
- package/build/esm/src/abis/__tests__/getAbi.spec.js +79 -0
- package/build/esm/src/abis/getAbi.js +35 -0
- package/build/esm/src/abis/index.js +4 -1
- package/build/esm/src/clients/v1/modules/orders/orders.js +5 -3
- package/build/esm/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.js +3 -1
- package/build/esm/src/clients/v1/modules/orders/transactions/updateOrderTxn.js +21 -25
- package/build/esm/src/clients/v1/modules/orders/utils.js +6 -7
- package/build/esm/src/clients/v1/modules/trades/trades.js +4 -3
- package/build/esm/src/clients/v1/multicall.js +2 -1
- package/build/esm/src/clients/v2/__tests__/decrease.spec.js +0 -2
- package/build/esm/src/clients/v2/__tests__/editCancel.spec.js +0 -3
- package/build/esm/src/clients/v2/__tests__/globalCleanup.js +0 -1
- package/build/esm/src/clients/v2/__tests__/increase.spec.js +0 -2
- package/build/esm/src/clients/v2/__tests__/subaccountLifecycle.spec.js +0 -1
- package/build/esm/src/clients/v2/__tests__/testUtil.js +0 -1
- package/build/esm/src/configs/__tests__/markets.spec.js +9 -2
- package/build/esm/src/configs/chains.js +14 -0
- package/build/esm/src/configs/contracts.js +25 -17
- package/build/esm/src/configs/dataStore.js +8 -0
- package/build/esm/src/configs/markets.js +13 -8
- package/build/esm/src/configs/tokens.js +13 -8
- package/build/esm/src/utils/__tests__/address.spec.js +48 -0
- package/build/esm/src/utils/__tests__/numbers.spec.js +25 -1
- package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +43 -6
- package/build/esm/src/utils/__tests__/orderTransactions/updateOrder.spec.js +5 -1
- package/build/esm/src/utils/__tests__/parseError.spec.js +62 -1
- package/build/esm/src/utils/__tests__/referrals.spec.js +37 -5
- package/build/esm/src/utils/address/index.js +1 -0
- package/build/esm/src/utils/address/utils.js +25 -0
- package/build/esm/src/utils/errors/parseError.js +11 -1
- package/build/esm/src/utils/errors/transactionsErrors.js +23 -0
- package/build/esm/src/utils/express/utils/batchOrderUtils.js +14 -9
- package/build/esm/src/utils/express/utils/bridgeOutUtils.js +53 -18
- package/build/esm/src/utils/express/utils/referralUtils.js +37 -25
- package/build/esm/src/utils/express/utils/relayParamsUtils.js +10 -5
- package/build/esm/src/utils/markets/__tests__/multicall.spec.js +25 -0
- package/build/esm/src/utils/markets/multicall.js +5 -7
- package/build/esm/src/utils/multichain/api.js +15 -7
- package/build/esm/src/utils/numbers/utils.js +5 -0
- package/build/esm/src/utils/orderTransactions/api.js +3 -4
- package/build/esm/src/utils/orderTransactions/utils.js +9 -8
- package/build/esm/src/utils/orders/utils.js +6 -0
- package/build/esm/src/utils/paxos/__tests__/api.spec.js +23 -3
- package/build/esm/src/utils/paxos/api.js +6 -0
- package/build/esm/src/utils/referrals/utils.js +23 -15
- package/build/esm/src/utils/subaccount/getEmptySubaccountApproval.js +2 -0
- package/build/esm/src/utils/subaccount/getSubaccountApprovalTypedData.js +36 -14
- package/build/esm/src/utils/subaccount/hashSubaccountApproval.js +32 -18
- package/build/esm/src/utils/subaccount/index.js +2 -2
- package/build/esm/src/utils/subaccount/sdkClient.js +2 -2
- package/build/esm/src/utils/subaccount/state.js +8 -0
- package/build/esm/src/utils/swap/preparedSwapData.js +6 -4
- package/build/esm/src/utils/swap/swapPath.js +2 -2
- package/build/esm/src/utils/trade/__tests__/decreaseMarginCheck.spec.js +222 -0
- package/build/esm/src/utils/trade/__tests__/getMaxWithdrawAmount.spec.js +129 -10
- package/build/esm/src/utils/trade/decrease.js +195 -32
- package/build/esm/src/utils/trade/decreaseMarginCheck.js +152 -0
- package/build/esm/src/utils/trade/increaseMarginCheck.js +25 -14
- package/build/esm/src/utils/trade/index.js +1 -0
- package/build/esm/src/utils/tradeHistory/utils.js +6 -6
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/scripts/generate-synthetics-abis.d.ts +6 -0
- package/build/types/src/abis/CustomErrors.d.ts +160 -0
- package/build/types/src/abis/CustomErrorsV2_2_1.d.ts +4174 -0
- package/build/types/src/abis/ExchangeRouterV2_2_1.d.ts +1128 -0
- package/build/types/src/abis/GelatoRelayRouterV2_2_1.d.ts +1508 -0
- package/build/types/src/abis/GlvReaderV2_2_1.d.ts +1293 -0
- package/build/types/src/abis/MultichainClaimsRouterV2_2_1.d.ts +985 -0
- package/build/types/src/abis/MultichainGlvRouterV2_2_1.d.ts +906 -0
- package/build/types/src/abis/MultichainGmRouterV2_2_1.d.ts +1142 -0
- package/build/types/src/abis/MultichainOrderRouterV2_2_1.d.ts +1601 -0
- package/build/types/src/abis/MultichainSubaccountRouterV2_2_1.d.ts +1678 -0
- package/build/types/src/abis/MultichainTransferRouterV2_2_1.d.ts +793 -0
- package/build/types/src/abis/RelayParamsV2_2_1.d.ts +118 -0
- package/build/types/src/abis/RewardRouterV3.d.ts +1129 -0
- package/build/types/src/abis/SubaccountGelatoRelayRouterV2_2_1.d.ts +1946 -0
- package/build/types/src/abis/SyntheticsReaderV2_2_1.d.ts +4075 -0
- package/build/types/src/abis/__tests__/getAbi.spec.d.ts +1 -0
- package/build/types/src/abis/getAbi.d.ts +17051 -0
- package/build/types/src/abis/index.d.ts +6700 -4744
- package/build/types/src/clients/v1/modules/orders/transactions/createIncreaseOrderTxn.d.ts +2 -1
- package/build/types/src/clients/v1/modules/orders/transactions/updateOrderTxn.d.ts +8 -3
- package/build/types/src/configs/chains.d.ts +6 -2
- package/build/types/src/configs/contracts.d.ts +6 -0
- package/build/types/src/configs/dataStore.d.ts +4 -0
- package/build/types/src/configs/markets.d.ts +4 -4
- package/build/types/src/utils/__tests__/address.spec.d.ts +1 -0
- package/build/types/src/utils/address/index.d.ts +1 -0
- package/build/types/src/utils/address/utils.d.ts +11 -0
- package/build/types/src/utils/errors/transactionsErrors.d.ts +18 -1
- package/build/types/src/utils/express/types.d.ts +1 -0
- package/build/types/src/utils/express/utils/batchOrderUtils.d.ts +4 -3
- package/build/types/src/utils/express/utils/bridgeOutUtils.d.ts +8 -2
- package/build/types/src/utils/express/utils/referralUtils.d.ts +21 -0
- package/build/types/src/utils/markets/__tests__/multicall.spec.d.ts +1 -0
- package/build/types/src/utils/multichain/api.d.ts +8 -0
- package/build/types/src/utils/numbers/utils.d.ts +1 -0
- package/build/types/src/utils/orderTransactions/api.d.ts +1 -3
- package/build/types/src/utils/orderTransactions/utils.d.ts +5 -2
- package/build/types/src/utils/orders/utils.d.ts +1 -0
- package/build/types/src/utils/paxos/types.d.ts +2 -0
- package/build/types/src/utils/referrals/utils.d.ts +7 -1
- package/build/types/src/utils/subaccount/api.d.ts +1 -0
- package/build/types/src/utils/subaccount/getSubaccountApprovalTypedData.d.ts +4 -0
- package/build/types/src/utils/subaccount/hashSubaccountApproval.d.ts +2 -1
- package/build/types/src/utils/subaccount/index.d.ts +2 -2
- package/build/types/src/utils/subaccount/state.d.ts +2 -1
- package/build/types/src/utils/subaccount/types.d.ts +3 -1
- package/build/types/src/utils/trade/__tests__/decreaseMarginCheck.spec.d.ts +1 -0
- package/build/types/src/utils/trade/decrease.d.ts +18 -0
- package/build/types/src/utils/trade/decreaseMarginCheck.d.ts +52 -0
- package/build/types/src/utils/trade/increaseMarginCheck.d.ts +11 -1
- package/build/types/src/utils/trade/index.d.ts +1 -0
- package/build/types/src/utils/trade/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GmxSdk } from "../../..";
|
|
2
|
-
import { OrderTxnType, OrderType } from "../../../../../utils/orders/types";
|
|
2
|
+
import { DecreasePositionSwapType, OrderTxnType, OrderType } from "../../../../../utils/orders/types";
|
|
3
3
|
import { TokenData, TokenPrices, TokensData } from "../../../../../utils/tokens/types";
|
|
4
4
|
import { DecreaseOrderParams } from "./createDecreaseOrderTxn";
|
|
5
5
|
export type PriceOverrides = {
|
|
@@ -54,6 +54,7 @@ export type SecondaryUpdateOrderParams = SecondaryOrderCommonParams & {
|
|
|
54
54
|
indexToken: TokenData;
|
|
55
55
|
minOutputAmount: bigint;
|
|
56
56
|
autoCancel: boolean;
|
|
57
|
+
decreasePositionSwapType: DecreasePositionSwapType;
|
|
57
58
|
};
|
|
58
59
|
export declare function createIncreaseOrderTxn({ sdk, createIncreaseOrderParams: p, createDecreaseOrderParams, cancelOrderParams, updateOrderParams, }: {
|
|
59
60
|
sdk: GmxSdk;
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { Address } from "viem";
|
|
2
2
|
import type { GmxSdk } from "../../..";
|
|
3
|
+
import { DecreasePositionSwapType, OrderType } from "../../../../../utils/orders/types";
|
|
3
4
|
import { Token } from "../../../../../utils/tokens/types";
|
|
4
5
|
export type UpdateOrderParams = {
|
|
5
6
|
orderKey: string;
|
|
6
|
-
|
|
7
|
+
orderType: OrderType;
|
|
8
|
+
indexToken: Token;
|
|
7
9
|
sizeDeltaUsd: bigint;
|
|
8
10
|
triggerPrice: bigint;
|
|
9
11
|
acceptablePrice: bigint;
|
|
10
12
|
minOutputAmount: bigint;
|
|
13
|
+
decreasePositionSwapType: DecreasePositionSwapType;
|
|
11
14
|
executionFee?: bigint;
|
|
12
15
|
autoCancel: boolean;
|
|
13
16
|
};
|
|
14
17
|
export declare function updateOrderTxn(sdk: GmxSdk, p: UpdateOrderParams): Promise<Address>;
|
|
15
|
-
export declare function createUpdateEncodedPayload({ sdk, orderKey, sizeDeltaUsd, executionFee, indexToken, acceptablePrice, triggerPrice, autoCancel, minOutputAmount, }: {
|
|
18
|
+
export declare function createUpdateEncodedPayload({ sdk, orderKey, orderType, sizeDeltaUsd, executionFee, indexToken, acceptablePrice, triggerPrice, autoCancel, minOutputAmount, decreasePositionSwapType, }: {
|
|
16
19
|
sdk: GmxSdk;
|
|
17
20
|
orderKey: string;
|
|
21
|
+
orderType: OrderType;
|
|
18
22
|
sizeDeltaUsd: bigint;
|
|
19
23
|
executionFee?: bigint;
|
|
20
|
-
indexToken
|
|
24
|
+
indexToken: Token;
|
|
21
25
|
acceptablePrice: bigint;
|
|
22
26
|
triggerPrice: bigint;
|
|
23
27
|
minOutputAmount: bigint;
|
|
24
28
|
autoCancel: boolean;
|
|
29
|
+
decreasePositionSwapType: DecreasePositionSwapType;
|
|
25
30
|
}): string[];
|
|
@@ -12,7 +12,10 @@ export type SettlementChainId = (typeof SETTLEMENT_CHAIN_IDS_DEV)[number];
|
|
|
12
12
|
export type SourceChainId = (typeof SOURCE_CHAIN_IDS)[number];
|
|
13
13
|
export declare const GMX_ACCOUNT_PSEUDO_CHAIN_ID = 0;
|
|
14
14
|
export type GmxAccountPseudoChainId = typeof GMX_ACCOUNT_PSEUDO_CHAIN_ID;
|
|
15
|
+
export declare const SOLANA_NETWORK_ID = -501;
|
|
16
|
+
export type SolanaNetworkId = typeof SOLANA_NETWORK_ID;
|
|
15
17
|
export type AnyChainId = ContractsChainId | SettlementChainId | SourceChainId;
|
|
18
|
+
export type NetworkId = ContractsChainId | SolanaNetworkId;
|
|
16
19
|
declare const CONTRACTS_CHAIN_CONFIGS: {
|
|
17
20
|
readonly 42161: {
|
|
18
21
|
readonly chainId: 42161;
|
|
@@ -190,12 +193,13 @@ declare const SOURCE_CHAIN_CONFIGS: {
|
|
|
190
193
|
};
|
|
191
194
|
export type ContractsChainName = (typeof CONTRACTS_CHAIN_CONFIGS)[keyof typeof CONTRACTS_CHAIN_CONFIGS]["name"];
|
|
192
195
|
export type SourceChainName = (typeof SOURCE_CHAIN_CONFIGS)[keyof typeof SOURCE_CHAIN_CONFIGS]["name"];
|
|
193
|
-
export type ChainName = ContractsChainName | SourceChainName | "Unknown";
|
|
196
|
+
export type ChainName = ContractsChainName | SourceChainName | "Solana" | "Unknown";
|
|
194
197
|
export type ContractsChainSlug = (typeof CONTRACTS_CHAIN_CONFIGS)[keyof typeof CONTRACTS_CHAIN_CONFIGS]["slug"];
|
|
195
198
|
export type SourceChainSlug = (typeof SOURCE_CHAIN_CONFIGS)[keyof typeof SOURCE_CHAIN_CONFIGS]["slug"];
|
|
196
|
-
export type ChainSlug = ContractsChainSlug | SourceChainSlug | "unknown";
|
|
199
|
+
export type ChainSlug = ContractsChainSlug | SourceChainSlug | "solana" | "unknown";
|
|
197
200
|
export declare const megaeth: Chain;
|
|
198
201
|
export declare const VIEM_CHAIN_BY_CHAIN_ID: Record<AnyChainId, Chain>;
|
|
202
|
+
export declare function isSolanaNetwork(networkId: number): networkId is SolanaNetworkId;
|
|
199
203
|
export declare function getChainName(chainId: number): ChainName;
|
|
200
204
|
export declare function getChainSlug(chainId: number): ChainSlug;
|
|
201
205
|
export declare function getChainIdBySlug(slug: string): AnyChainId | undefined;
|
|
@@ -7,6 +7,7 @@ export declare const CONTRACTS: {
|
|
|
7
7
|
Reader: string;
|
|
8
8
|
GlpManager: string;
|
|
9
9
|
RewardRouter: string;
|
|
10
|
+
RewardRouterV3: string;
|
|
10
11
|
GlpRewardRouter: string;
|
|
11
12
|
RewardReader: string;
|
|
12
13
|
GovToken: string;
|
|
@@ -70,6 +71,7 @@ export declare const CONTRACTS: {
|
|
|
70
71
|
Reader: string;
|
|
71
72
|
GlpManager: string;
|
|
72
73
|
RewardRouter: string;
|
|
74
|
+
RewardRouterV3: string;
|
|
73
75
|
GlpRewardRouter: string;
|
|
74
76
|
RewardReader: string;
|
|
75
77
|
GovToken: string;
|
|
@@ -165,6 +167,7 @@ export declare const CONTRACTS: {
|
|
|
165
167
|
VaultReader: "0x0000000000000000000000000000000000000000";
|
|
166
168
|
GlpManager: "0x0000000000000000000000000000000000000000";
|
|
167
169
|
RewardRouter: "0x0000000000000000000000000000000000000000";
|
|
170
|
+
RewardRouterV3: "0x0000000000000000000000000000000000000000";
|
|
168
171
|
RewardReader: "0x0000000000000000000000000000000000000000";
|
|
169
172
|
GlpRewardRouter: "0x0000000000000000000000000000000000000000";
|
|
170
173
|
StakedGmxTracker: "0x0000000000000000000000000000000000000000";
|
|
@@ -197,6 +200,7 @@ export declare const CONTRACTS: {
|
|
|
197
200
|
Reader: "0x0000000000000000000000000000000000000000";
|
|
198
201
|
GlpManager: "0x0000000000000000000000000000000000000000";
|
|
199
202
|
RewardRouter: "0x0000000000000000000000000000000000000000";
|
|
203
|
+
RewardRouterV3: "0x0000000000000000000000000000000000000000";
|
|
200
204
|
RewardReader: "0x0000000000000000000000000000000000000000";
|
|
201
205
|
GlpRewardRouter: "0x0000000000000000000000000000000000000000";
|
|
202
206
|
NATIVE_TOKEN: string;
|
|
@@ -295,6 +299,7 @@ export declare const CONTRACTS: {
|
|
|
295
299
|
Vault: "0x0000000000000000000000000000000000000000";
|
|
296
300
|
PositionRouter: "0x0000000000000000000000000000000000000000";
|
|
297
301
|
RewardRouter: "0x0000000000000000000000000000000000000000";
|
|
302
|
+
RewardRouterV3: "0x0000000000000000000000000000000000000000";
|
|
298
303
|
StakedGmxTracker: "0x0000000000000000000000000000000000000000";
|
|
299
304
|
BonusGmxTracker: "0x0000000000000000000000000000000000000000";
|
|
300
305
|
FeeGmxTracker: "0x0000000000000000000000000000000000000000";
|
|
@@ -318,6 +323,7 @@ type ExtractContractNames<T extends object> = {
|
|
|
318
323
|
[K in keyof T]: keyof T[K];
|
|
319
324
|
}[keyof T];
|
|
320
325
|
export type ContractName = ExtractContractNames<typeof CONTRACTS>;
|
|
326
|
+
export declare function isContractsV2_2_1(chainId: number): boolean;
|
|
321
327
|
export declare function getContract(chainId: ContractsChainId, name: ContractName): Address;
|
|
322
328
|
export declare function tryGetContract(chainId: ContractsChainId, name: ContractName): Address | undefined;
|
|
323
329
|
export {};
|
|
@@ -88,6 +88,7 @@ export declare const MAX_ALLOWED_SUBACCOUNT_ACTION_COUNT: string;
|
|
|
88
88
|
export declare const SUBACCOUNT_ACTION_COUNT: string;
|
|
89
89
|
export declare const SUBACCOUNT_ORDER_ACTION: string;
|
|
90
90
|
export declare const SUBACCOUNT_INTEGRATION_ID: string;
|
|
91
|
+
export declare const SUBACCOUNT_REVOCATION_COUNTER: string;
|
|
91
92
|
export declare const SUBACCOUNT_AUTO_TOP_UP_AMOUNT: string;
|
|
92
93
|
export declare const GLV_MAX_MARKET_TOKEN_BALANCE_USD: string;
|
|
93
94
|
export declare const MIN_COLLATERAL_FACTOR_FOR_LIQUIDATION_KEY: string;
|
|
@@ -106,6 +107,7 @@ export declare const SUBACCOUNT_EXPIRES_AT: string;
|
|
|
106
107
|
export declare const MULTICHAIN_BALANCE: string;
|
|
107
108
|
export declare const PRICE_FEED_KEY: string;
|
|
108
109
|
export declare const GASLESS_FEATURE_DISABLED_KEY: string;
|
|
110
|
+
export declare const SIGNAL_UNSTAKE_FEATURE_DISABLED_KEY: string;
|
|
109
111
|
export declare const GELATO_RELAY_FEE_MULTIPLIER_FACTOR_KEY: string;
|
|
110
112
|
export declare const REQUEST_EXPIRATION_TIME_KEY: string;
|
|
111
113
|
export declare const GMX_SIMULATION_ORIGIN: string;
|
|
@@ -186,9 +188,11 @@ export declare function maxLendableImpactFactorKey(market: string): string;
|
|
|
186
188
|
export declare function maxLendableImpactFactorForWithdrawalsKey(market: string): string;
|
|
187
189
|
export declare function maxLendableImpactUsdKey(market: string): string;
|
|
188
190
|
export declare function subaccountIntegrationIdKey(account: string, subaccount: string): string;
|
|
191
|
+
export declare function subaccountRevocationCounterKey(account: string, subaccount: string): string;
|
|
189
192
|
export declare function subaccountAutoTopUpAmountKey(account: string, subaccount: string): string;
|
|
190
193
|
export declare function multichainBalanceKey(account: string, token: string): string;
|
|
191
194
|
export declare function priceFeedKey(token: string): string;
|
|
192
195
|
export declare function gaslessFeatureDisabledKey(module: string): string;
|
|
196
|
+
export declare function signalUnstakeFeatureDisabledKey(rewardRouter: string): string;
|
|
193
197
|
export declare function claimTermsKey(distributionId: bigint): string;
|
|
194
198
|
export declare function claimsDisabledKey(distributionId: bigint): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ERC20Address, NativeTokenSupportedAddress, Token } from "../utils/tokens/types";
|
|
2
|
-
import { ContractsChainId } from "./chains";
|
|
2
|
+
import { ContractsChainId, NetworkId } from "./chains";
|
|
3
3
|
export declare const SWAP_GRAPH_MAX_MARKETS_PER_TOKEN = 5;
|
|
4
4
|
export declare const UI_MAX_LEVERAGE_BY_MARKET: Record<string, number>;
|
|
5
5
|
export type MarketConfig = {
|
|
@@ -11,9 +11,9 @@ export type MarketConfig = {
|
|
|
11
11
|
export type MarketsConfigMap = Record<string, MarketConfig>;
|
|
12
12
|
export declare const MARKETS: Record<ContractsChainId, MarketsConfigMap>;
|
|
13
13
|
export type MarketLabel = `${string}/USD [${string}-${string}]`;
|
|
14
|
-
export declare function getMarketsByChainId(chainId:
|
|
15
|
-
export declare function getMarketByLabel(chainId:
|
|
16
|
-
export declare const fixTokenSymbolFromMarketLabel: (chainId:
|
|
14
|
+
export declare function getMarketsByChainId(chainId: NetworkId): Record<string, MarketConfig>;
|
|
15
|
+
export declare function getMarketByLabel(chainId: NetworkId, label: MarketLabel): MarketConfig;
|
|
16
|
+
export declare const fixTokenSymbolFromMarketLabel: (chainId: NetworkId, symbol: string) => string;
|
|
17
17
|
export declare function isMarketTokenAddress(chainId: number, marketTokenAddress: string): boolean;
|
|
18
18
|
export declare function getTokenAddressByMarket<T extends "long" | "short" | "index">(chainId: number, marketTokenAddress: string, tokenType: T): T extends "index" ? NativeTokenSupportedAddress | ERC20Address : ERC20Address;
|
|
19
19
|
export declare function getMarketIndexToken(chainId: number, marketTokenAddress: string): Token;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./utils";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Addresses in shared code are EVM hex or Solana base58. Base58 has no `0` in its alphabet, so it never matches.
|
|
3
|
+
* Base58 is case-sensitive, so it must never be checksummed, lowercased or compared through viem.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isEvmAddress(address: string): boolean;
|
|
6
|
+
/** Checksums an EVM address and keeps any other address as it is. */
|
|
7
|
+
export declare function normalizeAddress(address: string): string;
|
|
8
|
+
/** Compares EVM hex case-insensitively and any other address exactly. Empty input does not match. */
|
|
9
|
+
export declare function isSameAddress(a: string | undefined, b: string | undefined): boolean;
|
|
10
|
+
/** A map or set key: lowercased for EVM hex (addresses and hashes), unchanged for base58. */
|
|
11
|
+
export declare function getAddressKey(address: string): string;
|
|
@@ -12,6 +12,8 @@ export type ErrorPattern = {
|
|
|
12
12
|
};
|
|
13
13
|
export declare enum CustomErrorName {
|
|
14
14
|
DisabledMarket = "DisabledMarket",
|
|
15
|
+
EmptyDesignatedVesters = "EmptyDesignatedVesters",
|
|
16
|
+
EmptyStakeAmount = "EmptyStakeAmount",
|
|
15
17
|
EndOfOracleSimulation = "EndOfOracleSimulation",
|
|
16
18
|
ExternalCallFailed = "ExternalCallFailed",
|
|
17
19
|
InsufficientBridgeOutputAmount = "InsufficientBridgeOutputAmount",
|
|
@@ -26,6 +28,7 @@ export declare enum CustomErrorName {
|
|
|
26
28
|
InsufficientReserveForOpenInterest = "InsufficientReserveForOpenInterest",
|
|
27
29
|
OrderNotFulfillableAtAcceptablePrice = "OrderNotFulfillableAtAcceptablePrice",
|
|
28
30
|
InsufficientSwapOutputAmount = "InsufficientSwapOutputAmount",
|
|
31
|
+
InsufficientStrictTransferAllowance = "InsufficientStrictTransferAllowance",
|
|
29
32
|
InvalidCollateralTokenForMarket = "InvalidCollateralTokenForMarket",
|
|
30
33
|
InvalidDecreaseOrderSize = "InvalidDecreaseOrderSize",
|
|
31
34
|
InvalidOraclePrice = "InvalidOraclePrice",
|
|
@@ -37,6 +40,8 @@ export declare enum CustomErrorName {
|
|
|
37
40
|
MaxPoolUsdForDepositExceeded = "MaxPoolUsdForDepositExceeded",
|
|
38
41
|
MaxPriceAgeExceeded = "MaxPriceAgeExceeded",
|
|
39
42
|
MaxRelayFeeSwapExceeded = "MaxRelayFeeSwapExceeded",
|
|
43
|
+
MaxUnstakeRequestsExceeded = "MaxUnstakeRequestsExceeded",
|
|
44
|
+
MaxUnstakeRequestsOnTransfer = "MaxUnstakeRequestsOnTransfer",
|
|
40
45
|
MinPositionSize = "MinPositionSize",
|
|
41
46
|
NegativeExecutionPrice = "NegativeExecutionPrice",
|
|
42
47
|
OrderNotFound = "OrderNotFound",
|
|
@@ -45,11 +50,23 @@ export declare enum CustomErrorName {
|
|
|
45
50
|
PnlFactorExceededForLongs = "PnlFactorExceededForLongs",
|
|
46
51
|
PnlFactorExceededForShorts = "PnlFactorExceededForShorts",
|
|
47
52
|
PriceImpactLargerThanOrderSize = "PriceImpactLargerThanOrderSize",
|
|
53
|
+
SelfVestingTransfer = "SelfVestingTransfer",
|
|
54
|
+
StakingReceiverNotFresh = "StakingReceiverNotFresh",
|
|
55
|
+
StakingSenderHasPairAmounts = "StakingSenderHasPairAmounts",
|
|
56
|
+
StakingSenderHasVestedTokens = "StakingSenderHasVestedTokens",
|
|
48
57
|
SwapPriceImpactExceedsAmountIn = "SwapPriceImpactExceedsAmountIn",
|
|
58
|
+
TransferNotSignalled = "TransferNotSignalled",
|
|
59
|
+
TransferVesterConfigChanged = "TransferVesterConfigChanged",
|
|
49
60
|
UnableToWithdrawCollateral = "UnableToWithdrawCollateral",
|
|
61
|
+
UnstakeAmountExceedsStake = "UnstakeAmountExceedsStake",
|
|
62
|
+
UnstakeNotSignalled = "UnstakeNotSignalled",
|
|
50
63
|
UsdDeltaExceedsLongOpenInterest = "UsdDeltaExceedsLongOpenInterest",
|
|
51
64
|
UsdDeltaExceedsPoolValue = "UsdDeltaExceedsPoolValue",
|
|
52
|
-
UsdDeltaExceedsShortOpenInterest = "UsdDeltaExceedsShortOpenInterest"
|
|
65
|
+
UsdDeltaExceedsShortOpenInterest = "UsdDeltaExceedsShortOpenInterest",
|
|
66
|
+
VesterAccountFrozen = "VesterAccountFrozen",
|
|
67
|
+
VesterProvisioningNotComplete = "VesterProvisioningNotComplete",
|
|
68
|
+
VestingReceiverNotFresh = "VestingReceiverNotFresh",
|
|
69
|
+
VestingSenderHasOpenSession = "VestingSenderHasOpenSession"
|
|
53
70
|
}
|
|
54
71
|
export declare function getIsUserRejectedError(errorType: TxErrorType): boolean;
|
|
55
72
|
export declare function getIsUserError(errorType: TxErrorType): boolean;
|
|
@@ -29,7 +29,7 @@ export declare function buildBatchOrderCalldata({ chainId, batchParams, relayPar
|
|
|
29
29
|
}): ExpressTxnData & {
|
|
30
30
|
relayRouterAddress: string;
|
|
31
31
|
};
|
|
32
|
-
export declare function getBatchParamsLists(batchParams: BatchOrderTxnParams): {
|
|
32
|
+
export declare function getBatchParamsLists(chainId: ContractsChainId, batchParams: BatchOrderTxnParams): {
|
|
33
33
|
createOrderParamsList: {
|
|
34
34
|
addresses: {
|
|
35
35
|
receiver: string;
|
|
@@ -59,14 +59,15 @@ export declare function getBatchParamsLists(batchParams: BatchOrderTxnParams): {
|
|
|
59
59
|
dataList: string[];
|
|
60
60
|
}[];
|
|
61
61
|
updateOrderParamsList: {
|
|
62
|
+
autoCancel: boolean;
|
|
63
|
+
executionFeeIncrease: bigint;
|
|
64
|
+
decreasePositionSwapType?: import("../../orders").DecreasePositionSwapType | undefined;
|
|
62
65
|
key: string;
|
|
63
66
|
sizeDeltaUsd: bigint;
|
|
64
67
|
acceptablePrice: import("../../tokens").ContractPrice;
|
|
65
68
|
triggerPrice: import("../../tokens").ContractPrice;
|
|
66
69
|
minOutputAmount: bigint;
|
|
67
70
|
validFromTime: bigint;
|
|
68
|
-
autoCancel: boolean;
|
|
69
|
-
executionFeeIncrease: bigint;
|
|
70
71
|
}[];
|
|
71
72
|
cancelOrderKeys: string[];
|
|
72
73
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContractsChainId, SourceChainId } from "../../../configs/chains";
|
|
2
|
-
import type
|
|
2
|
+
import { type BridgeOutParams } from "../../multichain/api";
|
|
3
3
|
import type { IAbstractSigner } from "../../signer";
|
|
4
4
|
import { getGelatoRelayRouterDomain } from "./relayParamsUtils";
|
|
5
5
|
import type { ExpressTxnData, RawRelayParamsPayload, RelayParamsPayload } from "../types";
|
|
@@ -32,15 +32,21 @@ export type BridgeOutTypedData = {
|
|
|
32
32
|
provider: string;
|
|
33
33
|
data: string;
|
|
34
34
|
relayParams: string;
|
|
35
|
+
account?: string;
|
|
36
|
+
bridgeFeeToken?: string;
|
|
37
|
+
bridgeFeeAmount?: bigint;
|
|
38
|
+
bridgeFeeSwapPath?: string[];
|
|
39
|
+
bridgeFeeMinOutputAmount?: bigint;
|
|
35
40
|
};
|
|
36
41
|
};
|
|
37
42
|
/**
|
|
38
43
|
* EIP-712 typed-data describing a `MultichainTransferRouter.bridgeOut` call.
|
|
39
44
|
* Single source of truth shared by SDK signing helpers and server-side prepare flows.
|
|
40
45
|
*/
|
|
41
|
-
export declare function getBridgeOutTypedData({ chainId, srcChainId, params, relayParams, }: {
|
|
46
|
+
export declare function getBridgeOutTypedData({ chainId, srcChainId, params, relayParams, account, }: {
|
|
42
47
|
chainId: ContractsChainId;
|
|
43
48
|
srcChainId: SourceChainId;
|
|
44
49
|
params: BridgeOutParams;
|
|
45
50
|
relayParams: RelayParamsPayload;
|
|
51
|
+
account: string;
|
|
46
52
|
}): BridgeOutTypedData;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import type { ContractsChainId, SourceChainId } from "../../../configs/chains";
|
|
2
2
|
import type { IAbstractSigner } from "../../signer";
|
|
3
3
|
import type { RelayParamsPayload } from "../types";
|
|
4
|
+
export declare function getReferralCodeTypedData({ primaryType, chainId, srcChainId, relayParams, referralCode, account, }: {
|
|
5
|
+
primaryType: "SetTraderReferralCode" | "RegisterCode";
|
|
6
|
+
chainId: ContractsChainId;
|
|
7
|
+
srcChainId: SourceChainId;
|
|
8
|
+
relayParams: RelayParamsPayload;
|
|
9
|
+
referralCode: string;
|
|
10
|
+
account: string;
|
|
11
|
+
}): {
|
|
12
|
+
domain: import("../../signer").TypedDataDomain;
|
|
13
|
+
types: {
|
|
14
|
+
[x: string]: {
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
message: {
|
|
20
|
+
referralCode: string;
|
|
21
|
+
relayParams: string;
|
|
22
|
+
account?: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
4
25
|
export declare function signSetTraderReferralCode({ signer, relayParams, referralCode, chainId, srcChainId, }: {
|
|
5
26
|
signer: IAbstractSigner;
|
|
6
27
|
relayParams: RelayParamsPayload;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { type Hex } from "viem";
|
|
2
2
|
import type { AnyChainId, SettlementChainId } from "../../configs/chains";
|
|
3
3
|
import type { IAbstractSigner } from "../signer";
|
|
4
|
+
export type BridgeFeeParams = {
|
|
5
|
+
feeToken: string;
|
|
6
|
+
feeAmount: bigint;
|
|
7
|
+
feeSwapPath: string[];
|
|
8
|
+
minOutputAmount: bigint;
|
|
9
|
+
};
|
|
4
10
|
export type BridgeOutParams = {
|
|
5
11
|
token: string;
|
|
6
12
|
amount: bigint;
|
|
7
13
|
minAmountOut: bigint;
|
|
8
14
|
provider: string;
|
|
9
15
|
data: string;
|
|
16
|
+
bridgeFee?: BridgeFeeParams;
|
|
10
17
|
};
|
|
11
18
|
export type BuildTxnResult = {
|
|
12
19
|
to: Hex;
|
|
@@ -27,6 +34,7 @@ export type SameChainDepositRequest = {
|
|
|
27
34
|
* `MultichainTransferRouter.multicall([sendWnt|sendTokens, bridgeIn])`.
|
|
28
35
|
*/
|
|
29
36
|
export declare function buildSameChainDepositTxn(request: SameChainDepositRequest): BuildTxnResult;
|
|
37
|
+
export declare function getEmptyBridgeFeeParams(): BridgeFeeParams;
|
|
30
38
|
export declare function buildSameChainWithdrawBridgeOutParams(params: {
|
|
31
39
|
tokenAddress: string;
|
|
32
40
|
amount: bigint;
|
|
@@ -109,6 +109,7 @@ export declare function formatBalanceAmount(amount: bigint, tokenDecimals: numbe
|
|
|
109
109
|
isStable?: boolean;
|
|
110
110
|
signed?: boolean;
|
|
111
111
|
}): string;
|
|
112
|
+
export declare function truncateToBalanceDisplayDecimals(amount: bigint, tokenDecimals: number, isStable?: boolean): bigint;
|
|
112
113
|
export declare function formatFactor(factor: bigint): string;
|
|
113
114
|
export declare function numberWithCommasParts(x: BigNumberish, { showDollar }?: {
|
|
114
115
|
showDollar?: boolean;
|
|
@@ -98,7 +98,6 @@ export type PrepareOrderError = {
|
|
|
98
98
|
};
|
|
99
99
|
export type PrepareOrderResponse = {
|
|
100
100
|
requestId: string;
|
|
101
|
-
idempotencyKey?: string;
|
|
102
101
|
payloadType: "transaction" | "typed-data";
|
|
103
102
|
mode: TransactionMode;
|
|
104
103
|
payload: Record<string, any>;
|
|
@@ -114,7 +113,6 @@ export type SubmitOrderRequest = {
|
|
|
114
113
|
signature?: string;
|
|
115
114
|
from?: string;
|
|
116
115
|
eip712Data?: Record<string, any>;
|
|
117
|
-
idempotencyKey?: string;
|
|
118
116
|
};
|
|
119
117
|
export type SubmitOrderResponse = {
|
|
120
118
|
requestId: string;
|
|
@@ -129,7 +127,6 @@ export type SubmitOrderResponse = {
|
|
|
129
127
|
};
|
|
130
128
|
export type OrderStatusRequest = {
|
|
131
129
|
requestId?: string;
|
|
132
|
-
idempotencyKey?: string;
|
|
133
130
|
};
|
|
134
131
|
export type OrderStatusResponse = {
|
|
135
132
|
requestId: string;
|
|
@@ -172,6 +169,7 @@ export type PrepareCancelOrderRequest = {
|
|
|
172
169
|
export type CollateralOperation = "deposit" | "withdraw";
|
|
173
170
|
export type PrepareCollateralRequest = {
|
|
174
171
|
operation: CollateralOperation;
|
|
172
|
+
/** Use position.contractKey, the bytes32 contract hash. */
|
|
175
173
|
positionKey: string;
|
|
176
174
|
amount: bigint;
|
|
177
175
|
slippage?: number;
|
|
@@ -69,6 +69,7 @@ export type UpdateOrderParams = {
|
|
|
69
69
|
minOutputAmount: bigint;
|
|
70
70
|
autoCancel: boolean;
|
|
71
71
|
validFromTime: bigint;
|
|
72
|
+
decreasePositionSwapType: DecreasePositionSwapType;
|
|
72
73
|
executionFeeTopUp: bigint;
|
|
73
74
|
executionGasLimit?: bigint;
|
|
74
75
|
};
|
|
@@ -84,6 +85,7 @@ export type UpdateOrderPayload = {
|
|
|
84
85
|
minOutputAmount: bigint;
|
|
85
86
|
autoCancel: boolean;
|
|
86
87
|
validFromTime: bigint;
|
|
88
|
+
decreasePositionSwapType: DecreasePositionSwapType;
|
|
87
89
|
executionFeeTopUp: bigint;
|
|
88
90
|
};
|
|
89
91
|
export type TokenTransfersParams = {
|
|
@@ -208,7 +210,8 @@ export declare function getExternalCallsPayload({ chainId, account, quote, }: {
|
|
|
208
210
|
account: string;
|
|
209
211
|
quote: ExternalSwapQuote;
|
|
210
212
|
}): ExternalCallsPayload;
|
|
211
|
-
export declare function getBatchOrderMulticallPayload({ params }: {
|
|
213
|
+
export declare function getBatchOrderMulticallPayload({ chainId, params, }: {
|
|
214
|
+
chainId: ContractsChainId;
|
|
212
215
|
params: BatchOrderTxnParams;
|
|
213
216
|
}): {
|
|
214
217
|
multicall: ExchangeRouterCall[];
|
|
@@ -230,7 +233,7 @@ export declare function buildCancelOrderMulticall({ params }: {
|
|
|
230
233
|
multicall: ExchangeRouterCall[];
|
|
231
234
|
value: bigint;
|
|
232
235
|
};
|
|
233
|
-
export declare function encodeExchangeRouterMulticall(multicall: ExchangeRouterCall[]): {
|
|
236
|
+
export declare function encodeExchangeRouterMulticall(chainId: ContractsChainId, multicall: ExchangeRouterCall[]): {
|
|
234
237
|
encodedMulticall: Hex[];
|
|
235
238
|
callData: Hex;
|
|
236
239
|
};
|
|
@@ -35,4 +35,5 @@ export declare function isOrderForPositionByData(order: OrderInfo, { account, ma
|
|
|
35
35
|
collateralAddress: string;
|
|
36
36
|
isLong: boolean;
|
|
37
37
|
}): order is PositionOrderInfo;
|
|
38
|
+
export declare function getOrderPositionKey(order: OrderInfo): string;
|
|
38
39
|
export declare function getOrderTradeboxKey(order: OrderInfo): string;
|
|
@@ -4,6 +4,8 @@ export type TransitOrderStatus = "PENDING_BRIDGE" | "PROCESSING" | "PROCESSED" |
|
|
|
4
4
|
export type TransitFeeTierResponse = {
|
|
5
5
|
feeTier: TransitFeeTier;
|
|
6
6
|
zeroFeeCapacity: bigint;
|
|
7
|
+
isZeroFeeAvailable: boolean;
|
|
8
|
+
zeroFeeExpectedReopenAt: number | undefined;
|
|
7
9
|
};
|
|
8
10
|
export type TransitTokenMetadata = {
|
|
9
11
|
chain_id: string;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export declare const MAX_REFERRAL_CODE_LENGTH = 20;
|
|
2
2
|
import { Hash } from "viem";
|
|
3
|
+
export declare const REFERRAL_CODE_REGEX: RegExp;
|
|
4
|
+
export declare function isReferralCodeHex(value: string | null | undefined): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Codes registered through the UI are letters, digits and `_` right-padded with zeros. The contract accepts any
|
|
7
|
+
* bytes32, so anything else (e.g. left-padded addresses, hashes, other text) is returned as the original hex.
|
|
8
|
+
*/
|
|
3
9
|
export declare function decodeReferralCode(hexCode?: Hash): string;
|
|
4
|
-
export declare function encodeReferralCode(code: string):
|
|
10
|
+
export declare function encodeReferralCode(code: string): string;
|
|
@@ -13,6 +13,8 @@ export type SubaccountApprovalTypedData = {
|
|
|
13
13
|
message: Record<string, any>;
|
|
14
14
|
primaryType: string;
|
|
15
15
|
};
|
|
16
|
+
export declare const SUBACCOUNT_APPROVAL_TYPES: SubaccountApprovalTypedData["types"];
|
|
17
|
+
export declare const SUBACCOUNT_APPROVAL_TYPES_V2_2_1: SubaccountApprovalTypedData["types"];
|
|
16
18
|
export declare function getSubaccountApprovalTypedData(params: {
|
|
17
19
|
chainId: ContractsChainId;
|
|
18
20
|
subaccountAddress: string;
|
|
@@ -20,5 +22,7 @@ export declare function getSubaccountApprovalTypedData(params: {
|
|
|
20
22
|
expiresAt: bigint;
|
|
21
23
|
maxAllowedCount: bigint;
|
|
22
24
|
nonce: bigint;
|
|
25
|
+
account: string;
|
|
26
|
+
revocationCounter: bigint;
|
|
23
27
|
signingChainId?: number;
|
|
24
28
|
}): SubaccountApprovalTypedData;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ContractsChainId } from "../../configs/chains";
|
|
2
|
+
export declare function hashSubaccountApproval(chainId: ContractsChainId, approval: Record<string, any>): string;
|
|
@@ -2,7 +2,7 @@ export * from "./types";
|
|
|
2
2
|
export { generateSubaccount, decryptSubaccountPrivateKey, createSubaccountSignerFromConfig, type GeneratedSubaccount, } from "./generateSubaccount";
|
|
3
3
|
export { hashSubaccountApproval } from "./hashSubaccountApproval";
|
|
4
4
|
export { getEmptySubaccountApproval } from "./getEmptySubaccountApproval";
|
|
5
|
-
export { getSubaccountApprovalTypedData, type SubaccountApprovalTypedData } from "./getSubaccountApprovalTypedData";
|
|
6
|
-
export { isEmptySubaccountApproval, isSameSubaccountApproval, isSubaccountApprovalExpired, isSubaccountApprovalNonceExpired, isSubaccountApprovalSynced, isSubaccountStatusUsable, parseSubaccountStatus, shouldRefreshExplicitSubaccountApproval, toSignedSubaccountApproval, } from "./state";
|
|
5
|
+
export { getSubaccountApprovalTypedData, SUBACCOUNT_APPROVAL_TYPES, SUBACCOUNT_APPROVAL_TYPES_V2_2_1, type SubaccountApprovalTypedData, } from "./getSubaccountApprovalTypedData";
|
|
6
|
+
export { isEmptySubaccountApproval, isSameSubaccountApproval, isSubaccountApprovalExpired, isSubaccountApprovalNonceExpired, isSubaccountApprovalRevoked, isSubaccountApprovalSynced, isSubaccountStatusUsable, parseSubaccountStatus, shouldRefreshExplicitSubaccountApproval, toSignedSubaccountApproval, } from "./state";
|
|
7
7
|
export { fetchSubaccountStatus, prepareSubaccountApproval, signSubaccountApproval } from "./api";
|
|
8
8
|
export type { SubaccountStatusRequest, SubaccountStatusResponse, SubaccountApprovalPrepareRequest, SubaccountApprovalPrepareResponse, } from "./api";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { SubaccountApprovalPrepareResponse, SubaccountStatusResponse } from "./api";
|
|
2
|
-
import type { SdkSubaccountApproval, SdkSubaccountStatus, SignedSubaccountApproval, StoredSubaccountApproval } from "./types";
|
|
2
|
+
import type { SdkSubaccountApproval, SdkSubaccountStatus, SignedSubaccountApproval, StoredSubaccountApproval, SubaccountApproval } from "./types";
|
|
3
3
|
export declare function parseSubaccountStatus(status: SubaccountStatusResponse): SdkSubaccountStatus;
|
|
4
4
|
export declare function isSubaccountStatusUsable(status: SdkSubaccountStatus | undefined): boolean;
|
|
5
5
|
export declare function isEmptySubaccountApproval(approval: SdkSubaccountApproval): boolean;
|
|
6
6
|
export declare function isSameSubaccountApproval(a: SdkSubaccountApproval, b: SdkSubaccountApproval): boolean;
|
|
7
7
|
export declare function shouldRefreshExplicitSubaccountApproval(approval: SdkSubaccountApproval, status: SdkSubaccountStatus | undefined, pendingApproval: StoredSubaccountApproval | undefined): boolean;
|
|
8
8
|
export declare function isSubaccountApprovalNonceExpired(approval: SdkSubaccountApproval, status: SdkSubaccountStatus): boolean;
|
|
9
|
+
export declare function isSubaccountApprovalRevoked(approval: SubaccountApproval, revocationCounter: bigint): boolean;
|
|
9
10
|
export declare function isSubaccountApprovalSynced(approval: SdkSubaccountApproval, status: SdkSubaccountStatus): boolean;
|
|
10
11
|
export declare function isSubaccountApprovalExpired(approval: SdkSubaccountApproval): boolean;
|
|
11
12
|
export declare function toSignedSubaccountApproval(prepared: SubaccountApprovalPrepareResponse, signature: string): SignedSubaccountApproval;
|
|
@@ -8,6 +8,7 @@ export type SubaccountOnchainData = {
|
|
|
8
8
|
approvalNonce: bigint;
|
|
9
9
|
multichainApprovalNonce: bigint;
|
|
10
10
|
integrationId: string | undefined;
|
|
11
|
+
revocationCounter: bigint;
|
|
11
12
|
};
|
|
12
13
|
export type SubaccountSerializedConfig = {
|
|
13
14
|
privateKey: string;
|
|
@@ -24,6 +25,8 @@ export type SubaccountApproval = {
|
|
|
24
25
|
desChainId: bigint;
|
|
25
26
|
deadline: bigint;
|
|
26
27
|
integrationId: string;
|
|
28
|
+
revocationCounter?: bigint;
|
|
29
|
+
eip6492SignatureWrapperHash?: string;
|
|
27
30
|
};
|
|
28
31
|
export type SignedSubaccountApproval = SubaccountApproval & {
|
|
29
32
|
signature: string;
|
|
@@ -60,7 +63,6 @@ export type Subaccount = {
|
|
|
60
63
|
export type SubaccountValidations = {
|
|
61
64
|
isExpired: boolean;
|
|
62
65
|
isActionsExceeded: boolean;
|
|
63
|
-
isNonceExpired: boolean;
|
|
64
66
|
isApprovalInvalid: boolean;
|
|
65
67
|
isValid: boolean;
|
|
66
68
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -21,6 +21,7 @@ export declare function getDecreasePositionAmounts(p: {
|
|
|
21
21
|
fixedAcceptablePriceImpactBps?: bigint;
|
|
22
22
|
acceptablePriceImpactBuffer?: number;
|
|
23
23
|
userReferralInfo: UserReferralInfo | undefined;
|
|
24
|
+
proDiscountFactor?: bigint;
|
|
24
25
|
minCollateralUsd: bigint;
|
|
25
26
|
minPositionSizeUsd: bigint;
|
|
26
27
|
uiFeeFactor: bigint;
|
|
@@ -30,6 +31,7 @@ export declare function getDecreasePositionAmounts(p: {
|
|
|
30
31
|
isSetAcceptablePriceImpactEnabled: boolean;
|
|
31
32
|
receiveToken?: TokenData;
|
|
32
33
|
forceDecreaseSwapType?: DecreasePositionSwapType;
|
|
34
|
+
isTwap?: boolean;
|
|
33
35
|
}): DecreasePositionAmounts;
|
|
34
36
|
export declare function getIsFullClose(p: {
|
|
35
37
|
position: PositionInfoLoaded;
|
|
@@ -51,6 +53,18 @@ export declare function getMaxWithdrawAmount(p: {
|
|
|
51
53
|
collateralPrice: bigint | undefined;
|
|
52
54
|
collateralDecimals: number | undefined;
|
|
53
55
|
userReferralInfo: UserReferralInfo | undefined;
|
|
56
|
+
proDiscountFactor?: bigint;
|
|
57
|
+
}): bigint;
|
|
58
|
+
export declare function getIsProfitKeptInPnlToken(p: {
|
|
59
|
+
pnlToken: TokenData;
|
|
60
|
+
collateralToken: TokenData;
|
|
61
|
+
decreaseSwapType: DecreasePositionSwapType;
|
|
62
|
+
isProfitSwapReverted?: boolean;
|
|
63
|
+
}): boolean;
|
|
64
|
+
export declare function getCollateralDeltaAmountAfterPriceImpactDiff(p: {
|
|
65
|
+
collateralDeltaAmount: bigint;
|
|
66
|
+
priceImpactDiffUsd: bigint;
|
|
67
|
+
collateralToken: TokenData;
|
|
54
68
|
}): bigint;
|
|
55
69
|
export declare function payForCollateralCost(p: {
|
|
56
70
|
initialCostUsd: bigint;
|
|
@@ -63,6 +77,7 @@ export declare function payForCollateralCost(p: {
|
|
|
63
77
|
remainingCollateralAmount: bigint;
|
|
64
78
|
paidOutputAmount: bigint;
|
|
65
79
|
paidRemainingCollateralAmount: bigint;
|
|
80
|
+
unpaidCostAmount: bigint;
|
|
66
81
|
};
|
|
67
82
|
export declare function estimateCollateralCost(baseUsd: bigint, collateralToken: TokenData, collateralPrice: bigint): {
|
|
68
83
|
amount: bigint;
|
|
@@ -95,6 +110,7 @@ export declare function getNextPositionValuesForDecreaseTrade(p: {
|
|
|
95
110
|
isLong: boolean;
|
|
96
111
|
minCollateralUsd: bigint;
|
|
97
112
|
userReferralInfo: UserReferralInfo | undefined;
|
|
113
|
+
priceImpactDiffUsd?: bigint;
|
|
98
114
|
}): NextPositionValues;
|
|
99
115
|
export declare function getDecreaseSwapType(pnlToken: TokenData, collateralToken: TokenData, receiveToken: TokenData): DecreasePositionSwapType;
|
|
100
116
|
export declare function isThirdTokenDecreaseSwap(pnlToken: TokenData, collateralToken: TokenData, receiveToken: TokenData): boolean;
|
|
@@ -119,6 +135,7 @@ export declare function getOptimalDecreaseAndSwapAmounts(p: {
|
|
|
119
135
|
fixedAcceptablePriceImpactBps?: bigint;
|
|
120
136
|
acceptablePriceImpactBuffer?: number;
|
|
121
137
|
userReferralInfo: UserReferralInfo | undefined;
|
|
138
|
+
proDiscountFactor?: bigint;
|
|
122
139
|
minCollateralUsd: bigint;
|
|
123
140
|
minPositionSizeUsd: bigint;
|
|
124
141
|
uiFeeFactor: bigint;
|
|
@@ -126,6 +143,7 @@ export declare function getOptimalDecreaseAndSwapAmounts(p: {
|
|
|
126
143
|
isSetAcceptablePriceImpactEnabled: boolean;
|
|
127
144
|
receiveToken: TokenData;
|
|
128
145
|
forceDecreaseSwapType?: DecreasePositionSwapType;
|
|
146
|
+
isTwap?: boolean;
|
|
129
147
|
findSwapPath: FindSwapPath;
|
|
130
148
|
findSwapPathFromPnl: FindSwapPath;
|
|
131
149
|
marketsInfoData: MarketsInfoData | undefined;
|