@gmx-io/sdk 1.5.0-alpha-9 → 1.5.0-alpha-10
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/subsquid-codegen.js +1 -1
- package/build/cjs/src/clients/v2/__tests__/data.spec.js +85 -0
- package/build/cjs/src/clients/v2/__tests__/decrease.spec.js +471 -0
- package/build/cjs/src/clients/v2/__tests__/editCancel.spec.js +259 -0
- package/build/cjs/src/clients/v2/__tests__/errors.spec.js +261 -0
- package/build/cjs/src/clients/v2/__tests__/increase.spec.js +764 -0
- package/build/cjs/src/clients/v2/__tests__/subaccount.spec.js +74 -0
- package/build/cjs/src/clients/v2/__tests__/swap.spec.js +192 -0
- package/build/cjs/src/clients/v2/__tests__/testUtil.js +136 -0
- package/build/cjs/src/clients/v2/index.js +162 -27
- package/build/cjs/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +48 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +342 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +90 -0
- package/build/cjs/src/codegen/subsquid.js +323 -1
- package/build/cjs/src/configs/chains.js +11 -1
- package/build/cjs/src/configs/contracts.js +7 -7
- package/build/cjs/src/configs/markets.js +56 -2
- package/build/cjs/src/configs/tokens.js +63 -132
- package/build/cjs/src/test/mock.js +1 -1
- package/build/cjs/src/utils/__tests__/markets.spec.js +10 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +2 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +2 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -0
- package/build/cjs/src/utils/__tests__/positions.spec.js +59 -7
- package/build/cjs/src/utils/__tests__/uiFeeReceiver.spec.js +34 -0
- package/build/cjs/src/utils/balances/api.js +65 -0
- package/build/cjs/src/utils/buyback/api.js +7 -0
- package/build/cjs/src/utils/buyback/types.js +2 -0
- package/build/cjs/src/utils/errors/index.js +1 -0
- package/build/cjs/src/utils/errors/isIgnoredEstimateGasError.js +23 -0
- package/build/cjs/src/utils/express/index.js +18 -0
- package/build/cjs/src/utils/express/types.js +2 -0
- package/build/cjs/src/utils/express/utils/batchOrderUtils.js +218 -0
- package/build/cjs/src/utils/express/utils/bridgeOutUtils.js +73 -0
- package/build/cjs/src/utils/express/utils/estimateExpressParams.js +244 -0
- package/build/cjs/src/utils/express/utils/expressParamsUtils.js +22 -0
- package/build/cjs/src/utils/express/utils/fetchGelatoGasTankBalance.js +13 -0
- package/build/cjs/src/utils/express/utils/gelatoRelayUtils.js +77 -0
- package/build/cjs/src/utils/express/utils/globalExpressParams.js +40 -0
- package/build/cjs/src/utils/express/utils/index.js +27 -0
- package/build/cjs/src/utils/express/utils/oracleParamsUtils.js +49 -0
- package/build/cjs/src/utils/express/utils/referralUtils.js +35 -0
- package/build/cjs/src/utils/express/utils/relayParamsUtils.js +208 -0
- package/build/cjs/src/utils/fees/priceImpact.js +1 -2
- package/build/cjs/src/utils/http/http.js +86 -13
- package/build/cjs/src/utils/markets/utils.js +8 -0
- package/build/cjs/src/utils/metrics/index.js +7 -0
- package/build/cjs/src/utils/numbers/utils.js +29 -27
- package/build/cjs/src/utils/orderTransactions/api.js +88 -0
- package/build/cjs/src/utils/orderTransactions/index.js +2 -0
- package/build/cjs/src/utils/orderTransactions/simulation.js +141 -0
- package/build/cjs/src/utils/orderTransactions/utils.js +4 -1
- package/build/cjs/src/utils/orderTransactions/validateTypedData.js +100 -0
- package/build/cjs/src/utils/positions/utils.js +5 -19
- package/build/cjs/src/utils/rpc/createViemRpc.js +39 -0
- package/build/cjs/src/utils/rpc/index.js +5 -0
- package/build/cjs/src/utils/signer/index.js +5 -0
- package/build/cjs/src/utils/signer/privateKeySigner.js +42 -0
- package/build/cjs/src/utils/subaccount/api.js +22 -0
- package/build/cjs/src/utils/subaccount/generateSubaccount.js +19 -0
- package/build/cjs/src/utils/subaccount/getEmptySubaccountApproval.js +24 -0
- package/build/cjs/src/utils/subaccount/getSubaccountApprovalTypedData.js +51 -0
- package/build/cjs/src/utils/subaccount/hashSubaccountApproval.js +28 -0
- package/build/cjs/src/utils/subaccount/index.js +30 -0
- package/build/cjs/src/utils/subaccount/types.js +2 -0
- package/build/cjs/src/utils/swap/swapPath.js +4 -1
- package/build/cjs/src/utils/trade/types.js +1 -1
- package/build/cjs/src/utils/tradeHistory/utils.js +14 -28
- package/build/cjs/src/utils/twap/index.js +4 -1
- package/build/cjs/src/utils/twap/uiFeeReceiver.js +23 -7
- package/build/esm/scripts/subsquid-codegen.js +1 -1
- package/build/esm/src/clients/v2/__tests__/data.spec.js +83 -0
- package/build/esm/src/clients/v2/__tests__/decrease.spec.js +469 -0
- package/build/esm/src/clients/v2/__tests__/editCancel.spec.js +257 -0
- package/build/esm/src/clients/v2/__tests__/errors.spec.js +259 -0
- package/build/esm/src/clients/v2/__tests__/increase.spec.js +762 -0
- package/build/esm/src/clients/v2/__tests__/subaccount.spec.js +72 -0
- package/build/esm/src/clients/v2/__tests__/swap.spec.js +190 -0
- package/build/esm/src/clients/v2/__tests__/testUtil.js +124 -0
- package/build/esm/src/clients/v2/index.js +136 -4
- package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +48 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +342 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +90 -0
- package/build/esm/src/codegen/subsquid.js +321 -0
- package/build/esm/src/configs/chains.js +11 -1
- package/build/esm/src/configs/contracts.js +7 -7
- package/build/esm/src/configs/markets.js +55 -1
- package/build/esm/src/configs/tokens.js +62 -130
- package/build/esm/src/test/mock.js +1 -1
- package/build/esm/src/utils/__tests__/markets.spec.js +10 -0
- package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +2 -0
- package/build/esm/src/utils/__tests__/orderTransactions/increaseOrders.spec.js +2 -0
- package/build/esm/src/utils/__tests__/orderTransactions/swapOrders.spec.js +1 -0
- package/build/esm/src/utils/__tests__/positions.spec.js +60 -8
- package/build/esm/src/utils/__tests__/uiFeeReceiver.spec.js +35 -1
- package/build/esm/src/utils/balances/api.js +56 -0
- package/build/esm/src/utils/buyback/api.js +3 -0
- package/build/esm/src/utils/buyback/types.js +1 -0
- package/build/esm/src/utils/errors/index.js +1 -0
- package/build/esm/src/utils/errors/isIgnoredEstimateGasError.js +19 -0
- package/build/esm/src/utils/express/index.js +2 -0
- package/build/esm/src/utils/express/types.js +1 -0
- package/build/esm/src/utils/express/utils/batchOrderUtils.js +210 -0
- package/build/esm/src/utils/express/utils/bridgeOutUtils.js +69 -0
- package/build/esm/src/utils/express/utils/estimateExpressParams.js +238 -0
- package/build/esm/src/utils/express/utils/expressParamsUtils.js +16 -0
- package/build/esm/src/utils/express/utils/fetchGelatoGasTankBalance.js +9 -0
- package/build/esm/src/utils/express/utils/gelatoRelayUtils.js +71 -0
- package/build/esm/src/utils/express/utils/globalExpressParams.js +36 -0
- package/build/esm/src/utils/express/utils/index.js +11 -0
- package/build/esm/src/utils/express/utils/oracleParamsUtils.js +42 -0
- package/build/esm/src/utils/express/utils/referralUtils.js +30 -0
- package/build/esm/src/utils/express/utils/relayParamsUtils.js +198 -0
- package/build/esm/src/utils/fees/priceImpact.js +1 -2
- package/build/esm/src/utils/http/http.js +84 -12
- package/build/esm/src/utils/markets/utils.js +8 -0
- package/build/esm/src/utils/metrics/index.js +4 -0
- package/build/esm/src/utils/numbers/utils.js +25 -24
- package/build/esm/src/utils/orderTransactions/api.js +77 -0
- package/build/esm/src/utils/orderTransactions/index.js +2 -0
- package/build/esm/src/utils/orderTransactions/simulation.js +136 -0
- package/build/esm/src/utils/orderTransactions/utils.js +4 -1
- package/build/esm/src/utils/orderTransactions/validateTypedData.js +95 -0
- package/build/esm/src/utils/positions/utils.js +5 -19
- package/build/esm/src/utils/rpc/createViemRpc.js +35 -0
- package/build/esm/src/utils/rpc/index.js +1 -0
- package/build/esm/src/utils/signer/index.js +1 -0
- package/build/esm/src/utils/signer/privateKeySigner.js +38 -0
- package/build/esm/src/utils/subaccount/api.js +16 -0
- package/build/esm/src/utils/subaccount/generateSubaccount.js +15 -0
- package/build/esm/src/utils/subaccount/getEmptySubaccountApproval.js +20 -0
- package/build/esm/src/utils/subaccount/getSubaccountApprovalTypedData.js +47 -0
- package/build/esm/src/utils/subaccount/hashSubaccountApproval.js +24 -0
- package/build/esm/src/utils/subaccount/index.js +6 -0
- package/build/esm/src/utils/subaccount/types.js +1 -0
- package/build/esm/src/utils/swap/swapPath.js +5 -2
- package/build/esm/src/utils/trade/types.js +1 -1
- package/build/esm/src/utils/tradeHistory/utils.js +13 -26
- package/build/esm/src/utils/twap/index.js +1 -0
- package/build/esm/src/utils/twap/uiFeeReceiver.js +20 -6
- package/build/types/src/clients/v2/__tests__/data.spec.d.ts +1 -0
- package/build/types/src/clients/v2/__tests__/decrease.spec.d.ts +1 -0
- package/build/types/src/clients/v2/__tests__/editCancel.spec.d.ts +1 -0
- package/build/types/src/clients/v2/__tests__/errors.spec.d.ts +1 -0
- package/build/types/src/clients/v2/__tests__/increase.spec.d.ts +1 -0
- package/build/types/src/clients/v2/__tests__/subaccount.spec.d.ts +1 -0
- package/build/types/src/clients/v2/__tests__/swap.spec.d.ts +1 -0
- package/build/types/src/clients/v2/__tests__/testUtil.d.ts +25 -0
- package/build/types/src/clients/v2/index.d.ts +59 -1
- package/build/types/src/codegen/prebuilt/index.d.ts +480 -0
- package/build/types/src/codegen/subsquid.d.ts +1276 -44
- package/build/types/src/configs/chains.d.ts +10 -1
- package/build/types/src/configs/contracts.d.ts +6 -6
- package/build/types/src/configs/markets.d.ts +5 -0
- package/build/types/src/configs/tokens.d.ts +6 -1
- package/build/types/src/utils/balances/api.d.ts +39 -0
- package/build/types/src/utils/buyback/api.d.ts +5 -0
- package/build/types/src/utils/buyback/types.d.ts +15 -0
- package/build/types/src/utils/chains/types.d.ts +1 -0
- package/build/types/src/utils/errors/index.d.ts +1 -0
- package/build/types/src/utils/errors/isIgnoredEstimateGasError.d.ts +2 -0
- package/build/types/src/utils/express/index.d.ts +2 -0
- package/build/types/src/utils/express/types.d.ts +95 -0
- package/build/types/src/utils/express/utils/batchOrderUtils.d.ts +98 -0
- package/build/types/src/utils/express/utils/bridgeOutUtils.d.ts +21 -0
- package/build/types/src/utils/express/utils/estimateExpressParams.d.ts +37 -0
- package/build/types/src/utils/express/utils/expressParamsUtils.d.ts +19 -0
- package/build/types/src/utils/express/utils/fetchGelatoGasTankBalance.d.ts +5 -0
- package/build/types/src/utils/express/utils/gelatoRelayUtils.d.ts +25 -0
- package/build/types/src/utils/express/utils/globalExpressParams.d.ts +31 -0
- package/build/types/src/utils/express/utils/index.d.ts +11 -0
- package/build/types/src/utils/express/utils/oracleParamsUtils.d.ts +10 -0
- package/build/types/src/utils/express/utils/referralUtils.d.ts +17 -0
- package/build/types/src/utils/express/utils/relayParamsUtils.d.ts +63 -0
- package/build/types/src/utils/http/http.d.ts +16 -1
- package/build/types/src/utils/http/types.d.ts +3 -0
- package/build/types/src/utils/metrics/index.d.ts +4 -0
- package/build/types/src/utils/numbers/utils.d.ts +2 -5
- package/build/types/src/utils/orderTransactions/api.d.ts +158 -0
- package/build/types/src/utils/orderTransactions/index.d.ts +2 -0
- package/build/types/src/utils/orderTransactions/simulation.d.ts +26 -0
- package/build/types/src/utils/orderTransactions/validateTypedData.d.ts +6 -0
- package/build/types/src/utils/positions/utils.d.ts +1 -9
- package/build/types/src/utils/rpc/createViemRpc.d.ts +3 -0
- package/build/types/src/utils/rpc/index.d.ts +26 -0
- package/build/types/src/utils/signer/index.d.ts +23 -0
- package/build/types/src/utils/signer/privateKeySigner.d.ts +19 -0
- package/build/types/src/utils/subaccount/api.d.ts +50 -0
- package/build/types/src/utils/subaccount/generateSubaccount.d.ts +8 -0
- package/build/types/src/utils/subaccount/getEmptySubaccountApproval.d.ts +9 -0
- package/build/types/src/utils/subaccount/getSubaccountApprovalTypedData.d.ts +24 -0
- package/build/types/src/utils/subaccount/hashSubaccountApproval.d.ts +1 -0
- package/build/types/src/utils/subaccount/index.d.ts +7 -0
- package/build/types/src/utils/subaccount/types.d.ts +55 -0
- package/build/types/src/utils/tokens/types.d.ts +0 -1
- package/build/types/src/utils/trade/types.d.ts +1 -1
- package/build/types/src/utils/tradeHistory/utils.d.ts +0 -1
- package/build/types/src/utils/twap/index.d.ts +1 -0
- package/build/types/src/utils/twap/types.d.ts +2 -0
- package/build/types/src/utils/twap/uiFeeReceiver.d.ts +10 -2
- package/package.json +40 -3
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ContractsChainId, SourceChainId } from "../../../configs/chains";
|
|
2
|
+
import { ExternalCallsPayload } from "../../orderTransactions";
|
|
3
|
+
import type { TypedDataDomain } from "../../signer";
|
|
4
|
+
import type { SignedTokenPermit, TokenData } from "../../tokens/types";
|
|
5
|
+
import type { ExternalSwapQuote, FindSwapPath, SwapAmounts } from "../../trade/types";
|
|
6
|
+
import type { GasPaymentParams, RawRelayParamsPayload, RelayFeePayload, RelayParamsPayload } from "../types";
|
|
7
|
+
export declare function getExpressContractAddress(chainId: ContractsChainId, { isSubaccount, isMultichain, scope, }: {
|
|
8
|
+
isSubaccount?: boolean;
|
|
9
|
+
isMultichain?: boolean;
|
|
10
|
+
scope?: "glv" | "gm" | "transfer" | "claims" | "order" | "subaccount";
|
|
11
|
+
}): string;
|
|
12
|
+
export declare function getGelatoRelayRouterDomain(chainId: SourceChainId | ContractsChainId, relayRouterAddress: string): TypedDataDomain;
|
|
13
|
+
export declare function getRelayerFeeParams({ chainId, account, gasPaymentToken, relayerFeeToken, relayerFeeAmount, totalRelayerFeeTokenAmount, gasPaymentTokenAsCollateralAmount, transactionExternalCalls, feeExternalSwapQuote, findFeeSwapPath, }: {
|
|
14
|
+
chainId: ContractsChainId;
|
|
15
|
+
account: string;
|
|
16
|
+
relayerFeeAmount: bigint;
|
|
17
|
+
totalRelayerFeeTokenAmount: bigint;
|
|
18
|
+
relayerFeeToken: TokenData;
|
|
19
|
+
gasPaymentToken: TokenData;
|
|
20
|
+
gasPaymentTokenAsCollateralAmount: bigint;
|
|
21
|
+
findFeeSwapPath: FindSwapPath | undefined;
|
|
22
|
+
feeExternalSwapQuote: ExternalSwapQuote | undefined;
|
|
23
|
+
transactionExternalCalls: ExternalCallsPayload | undefined;
|
|
24
|
+
}): {
|
|
25
|
+
feeParams: RelayFeePayload;
|
|
26
|
+
externalCalls: ExternalCallsPayload;
|
|
27
|
+
feeExternalSwapGasLimit: bigint;
|
|
28
|
+
gasPaymentParams: GasPaymentParams;
|
|
29
|
+
} | undefined;
|
|
30
|
+
export declare function getBestSwapStrategy({ internalSwapAmounts, externalSwapQuote, }: {
|
|
31
|
+
internalSwapAmounts: SwapAmounts | undefined;
|
|
32
|
+
externalSwapQuote: ExternalSwapQuote | undefined;
|
|
33
|
+
}): {
|
|
34
|
+
amountIn: bigint;
|
|
35
|
+
amountOut: bigint;
|
|
36
|
+
externalSwapQuote: ExternalSwapQuote;
|
|
37
|
+
swapPath?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
amountIn: bigint;
|
|
40
|
+
amountOut: bigint;
|
|
41
|
+
swapPath: string[];
|
|
42
|
+
externalSwapQuote?: undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
export declare function getBestInternalSwapStrategy(internalSwapAmounts: SwapAmounts | undefined, externalSwapQuote: ExternalSwapQuote | undefined): {
|
|
45
|
+
amountIn: bigint;
|
|
46
|
+
amountOut: bigint;
|
|
47
|
+
externalSwapQuote: ExternalSwapQuote;
|
|
48
|
+
swapPath?: undefined;
|
|
49
|
+
} | {
|
|
50
|
+
amountIn: bigint;
|
|
51
|
+
amountOut: bigint;
|
|
52
|
+
swapPath: string[];
|
|
53
|
+
externalSwapQuote?: undefined;
|
|
54
|
+
} | undefined;
|
|
55
|
+
export declare function getRawRelayerParams({ chainId, gasPaymentTokenAddress, relayerFeeTokenAddress, feeParams, externalCalls, tokenPermits, }: {
|
|
56
|
+
chainId: ContractsChainId;
|
|
57
|
+
gasPaymentTokenAddress: string;
|
|
58
|
+
relayerFeeTokenAddress: string;
|
|
59
|
+
feeParams: RelayFeePayload;
|
|
60
|
+
externalCalls: ExternalCallsPayload;
|
|
61
|
+
tokenPermits: SignedTokenPermit[];
|
|
62
|
+
}): RawRelayParamsPayload;
|
|
63
|
+
export declare function hashRelayParams(relayParams: RelayParamsPayload): string;
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { IHttp } from "./types";
|
|
2
|
+
export declare class HttpError extends Error {
|
|
3
|
+
/** HTTP status code */
|
|
4
|
+
statusCode: number;
|
|
5
|
+
/** Structured error code from API (e.g. "INTERNAL_ERROR", "VALIDATION_ERROR") */
|
|
6
|
+
code?: string;
|
|
7
|
+
/** Distributed trace ID for correlating with server logs */
|
|
8
|
+
traceId?: string;
|
|
9
|
+
/** Full parsed response body */
|
|
10
|
+
body?: Record<string, any>;
|
|
11
|
+
constructor(statusCode: number, message: string, body?: Record<string, any>);
|
|
12
|
+
}
|
|
2
13
|
export declare class HttpClient implements IHttp {
|
|
3
14
|
readonly url: string;
|
|
4
|
-
|
|
15
|
+
private readonly timeoutMs;
|
|
16
|
+
constructor(url: string, timeoutMs?: number);
|
|
5
17
|
fetchJson<TResult>(path: string, opts?: {
|
|
6
18
|
query?: Record<string, any>;
|
|
7
19
|
transform?: (result: any) => TResult;
|
|
8
20
|
}): Promise<TResult>;
|
|
21
|
+
postJson<TResult>(path: string, body: unknown, opts?: {
|
|
22
|
+
transform?: (result: any) => TResult;
|
|
23
|
+
}): Promise<TResult>;
|
|
9
24
|
}
|
|
@@ -23,6 +23,7 @@ export type NonZero<T extends number | bigint> = T & {
|
|
|
23
23
|
export declare function isNonZero<T extends number | bigint>(value: T): value is NonZero<T>;
|
|
24
24
|
export declare function safeDivide<T extends number | bigint>(a: T, b: NonZero<T>): T;
|
|
25
25
|
export declare function expandDecimals(n: BigNumberish, decimals: number): bigint;
|
|
26
|
+
export declare function toBigInt(value: BigNumberish | undefined | null): bigint | undefined;
|
|
26
27
|
export declare function basisPointsToFloat(basisPoints: bigint): bigint;
|
|
27
28
|
export declare function getBasisPoints(numerator: bigint, denominator: bigint, shouldRoundUp?: boolean): bigint;
|
|
28
29
|
export declare function roundUpMagnitudeDivision(a: bigint, b: bigint): bigint;
|
|
@@ -81,6 +82,7 @@ export declare function formatRatePercentage(rate?: bigint, opts?: {
|
|
|
81
82
|
}): string;
|
|
82
83
|
export declare function formatUsdPrice(price?: bigint, opts?: Parameters<typeof formatUsd>[1]): string | undefined;
|
|
83
84
|
export declare function formatPercentageDisplay(percentage: number, hideThreshold?: number): string;
|
|
85
|
+
export declare function formatNumberHuman(n: number, showDollar?: boolean, displayDecimals?: number): string;
|
|
84
86
|
export declare function formatAmountHuman(amount: BigNumberish | undefined, tokenDecimals: number, showDollar?: boolean, displayDecimals?: number): string;
|
|
85
87
|
export declare function formatBalanceAmount(amount: bigint, tokenDecimals: number, tokenSymbol?: string, { showZero, toExponential, isStable, signed, }?: {
|
|
86
88
|
showZero?: boolean;
|
|
@@ -113,11 +115,6 @@ export declare function roundWithDecimals(value: BigNumberish, opts: {
|
|
|
113
115
|
decimals: number;
|
|
114
116
|
}): bigint;
|
|
115
117
|
export declare function toBigNumberWithDecimals(value: string, decimals: number): bigint;
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
* @deprecated Use BigInt instead
|
|
119
|
-
*/
|
|
120
|
-
export declare function bigNumberify(n?: BigNumberish | null | undefined): bigint | undefined;
|
|
121
118
|
export declare const parseValue: (value: string, tokenDecimals: number) => bigint | undefined;
|
|
122
119
|
export declare function roundUpDivision(a: bigint, b: bigint): bigint;
|
|
123
120
|
export declare function roundToTwoDecimals(n: number): number;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { ContractsChainId } from "../../configs/chains";
|
|
2
|
+
import { IHttp } from "../http/types";
|
|
3
|
+
import type { IAbstractSigner } from "../signer";
|
|
4
|
+
export type OrderKind = "increase" | "decrease" | "swap";
|
|
5
|
+
export type SimpleOrderType = "market" | "limit" | "stop-market" | "take-profit" | "stop-loss" | "twap";
|
|
6
|
+
export type TransactionMode = "express" | "classic";
|
|
7
|
+
export type PrepareOrderRequest = {
|
|
8
|
+
kind: OrderKind;
|
|
9
|
+
symbol?: string;
|
|
10
|
+
direction?: "long" | "short";
|
|
11
|
+
orderType: SimpleOrderType;
|
|
12
|
+
size?: bigint;
|
|
13
|
+
triggerPrice?: bigint;
|
|
14
|
+
slippage?: number;
|
|
15
|
+
collateralToken?: string;
|
|
16
|
+
collateralToPay?: {
|
|
17
|
+
amount: bigint;
|
|
18
|
+
token: string;
|
|
19
|
+
};
|
|
20
|
+
receiveToken?: string;
|
|
21
|
+
keepLeverage?: boolean;
|
|
22
|
+
manualSwapPath?: string[];
|
|
23
|
+
acceptablePriceImpactBps?: bigint;
|
|
24
|
+
executionFeeBufferBps?: number;
|
|
25
|
+
twapConfig?: {
|
|
26
|
+
duration: number;
|
|
27
|
+
parts: number;
|
|
28
|
+
frequency?: number;
|
|
29
|
+
};
|
|
30
|
+
tpsl?: {
|
|
31
|
+
type: "take-profit" | "stop-loss";
|
|
32
|
+
triggerPrice: bigint;
|
|
33
|
+
size?: bigint;
|
|
34
|
+
}[];
|
|
35
|
+
gasPaymentToken?: string;
|
|
36
|
+
mode: TransactionMode;
|
|
37
|
+
from: string;
|
|
38
|
+
subaccountAddress?: string;
|
|
39
|
+
subaccountApproval?: Record<string, any>;
|
|
40
|
+
};
|
|
41
|
+
export type OrderEstimates = {
|
|
42
|
+
positionPriceImpactDeltaUsd: bigint;
|
|
43
|
+
swapPriceImpactDeltaUsd: bigint;
|
|
44
|
+
executionFeeAmount: bigint;
|
|
45
|
+
acceptablePrice: bigint;
|
|
46
|
+
sizeDeltaUsd: bigint;
|
|
47
|
+
positionFeeUsd: bigint;
|
|
48
|
+
borrowingFeeUsd: bigint;
|
|
49
|
+
fundingFeeUsd: bigint;
|
|
50
|
+
};
|
|
51
|
+
export type PrepareOrderResponse = {
|
|
52
|
+
requestId: string;
|
|
53
|
+
idempotencyKey?: string;
|
|
54
|
+
payloadType: "transaction" | "typed-data";
|
|
55
|
+
mode: TransactionMode;
|
|
56
|
+
payload: Record<string, any>;
|
|
57
|
+
estimates?: OrderEstimates;
|
|
58
|
+
expiresAt?: number;
|
|
59
|
+
warnings?: string[];
|
|
60
|
+
traceId?: string;
|
|
61
|
+
};
|
|
62
|
+
export type SubmitOrderRequest = {
|
|
63
|
+
mode: TransactionMode;
|
|
64
|
+
requestId?: string;
|
|
65
|
+
signature?: string;
|
|
66
|
+
from?: string;
|
|
67
|
+
eip712Data?: Record<string, any>;
|
|
68
|
+
idempotencyKey?: string;
|
|
69
|
+
};
|
|
70
|
+
export type SubmitOrderResponse = {
|
|
71
|
+
requestId: string;
|
|
72
|
+
status: "accepted" | "pending" | "submitted" | "executed" | "failed" | "reverted" | "expired";
|
|
73
|
+
txHash?: string;
|
|
74
|
+
taskId?: string;
|
|
75
|
+
error?: {
|
|
76
|
+
code: string;
|
|
77
|
+
message: string;
|
|
78
|
+
};
|
|
79
|
+
traceId?: string;
|
|
80
|
+
};
|
|
81
|
+
export type OrderStatusRequest = {
|
|
82
|
+
requestId?: string;
|
|
83
|
+
idempotencyKey?: string;
|
|
84
|
+
};
|
|
85
|
+
export type OrderStatusResponse = {
|
|
86
|
+
requestId: string;
|
|
87
|
+
status: "accepted" | "pending" | "submitted" | "executed" | "failed" | "reverted" | "expired";
|
|
88
|
+
txHash?: string;
|
|
89
|
+
createdTxnHash?: string;
|
|
90
|
+
executionTxnHash?: string;
|
|
91
|
+
orderKeys?: string[];
|
|
92
|
+
cancellationReason?: string;
|
|
93
|
+
taskId?: string;
|
|
94
|
+
error?: {
|
|
95
|
+
code: string;
|
|
96
|
+
message: string;
|
|
97
|
+
};
|
|
98
|
+
createdAt?: string;
|
|
99
|
+
updatedAt?: string;
|
|
100
|
+
traceId?: string;
|
|
101
|
+
};
|
|
102
|
+
export type PrepareEditOrderRequest = {
|
|
103
|
+
orderIds: string[];
|
|
104
|
+
newSize?: bigint;
|
|
105
|
+
newTriggerPrice?: bigint;
|
|
106
|
+
newAcceptablePrice?: bigint;
|
|
107
|
+
newAutoCancel?: boolean;
|
|
108
|
+
executionFeeTopUp?: bigint;
|
|
109
|
+
mode: TransactionMode;
|
|
110
|
+
from: string;
|
|
111
|
+
subaccountAddress?: string;
|
|
112
|
+
subaccountApproval?: Record<string, any>;
|
|
113
|
+
};
|
|
114
|
+
export type PrepareCancelOrderRequest = {
|
|
115
|
+
orderId?: string;
|
|
116
|
+
orderIds?: string[];
|
|
117
|
+
all?: boolean;
|
|
118
|
+
mode: TransactionMode;
|
|
119
|
+
from: string;
|
|
120
|
+
subaccountAddress?: string;
|
|
121
|
+
subaccountApproval?: Record<string, any>;
|
|
122
|
+
};
|
|
123
|
+
export type CollateralOperation = "deposit" | "withdraw";
|
|
124
|
+
export type PrepareCollateralRequest = {
|
|
125
|
+
operation: CollateralOperation;
|
|
126
|
+
positionKey: string;
|
|
127
|
+
amount: bigint;
|
|
128
|
+
slippage?: number;
|
|
129
|
+
executionFeeBufferBps?: number;
|
|
130
|
+
gasPaymentToken?: string;
|
|
131
|
+
mode: TransactionMode;
|
|
132
|
+
from: string;
|
|
133
|
+
subaccountAddress?: string;
|
|
134
|
+
subaccountApproval?: Record<string, any>;
|
|
135
|
+
};
|
|
136
|
+
export declare function prepareOrder(ctx: {
|
|
137
|
+
api: IHttp;
|
|
138
|
+
}, request: PrepareOrderRequest): Promise<PrepareOrderResponse>;
|
|
139
|
+
export declare function submitOrder(ctx: {
|
|
140
|
+
api: IHttp;
|
|
141
|
+
}, request: SubmitOrderRequest): Promise<SubmitOrderResponse>;
|
|
142
|
+
export declare function prepareEditOrder(ctx: {
|
|
143
|
+
api: IHttp;
|
|
144
|
+
}, request: PrepareEditOrderRequest): Promise<PrepareOrderResponse>;
|
|
145
|
+
export declare function prepareCancelOrder(ctx: {
|
|
146
|
+
api: IHttp;
|
|
147
|
+
}, request: PrepareCancelOrderRequest): Promise<PrepareOrderResponse>;
|
|
148
|
+
export declare function prepareCollateral(ctx: {
|
|
149
|
+
api: IHttp;
|
|
150
|
+
}, request: PrepareCollateralRequest): Promise<PrepareOrderResponse>;
|
|
151
|
+
export declare function fetchOrderStatus(ctx: {
|
|
152
|
+
api: IHttp;
|
|
153
|
+
}, request: OrderStatusRequest): Promise<OrderStatusResponse>;
|
|
154
|
+
export declare function signPreparedOrder(prepared: PrepareOrderResponse, signer: IAbstractSigner, chainId?: ContractsChainId, accountAddress?: string): Promise<string>;
|
|
155
|
+
export declare function executeExpressOrder(ctx: {
|
|
156
|
+
api: IHttp;
|
|
157
|
+
chainId?: ContractsChainId;
|
|
158
|
+
}, request: PrepareOrderRequest, signer: IAbstractSigner, accountAddress?: string): Promise<SubmitOrderResponse>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ContractsChainId } from "../../configs/chains";
|
|
2
|
+
import type { IRpc } from "../rpc";
|
|
3
|
+
import type { TokenPrices, TokensData } from "../tokens/types";
|
|
4
|
+
import type { BatchOrderTxnParams } from "./utils";
|
|
5
|
+
export type SimulationPriceOverrides = {
|
|
6
|
+
[address: string]: TokenPrices | undefined;
|
|
7
|
+
};
|
|
8
|
+
export type SimulateOrderParams = {
|
|
9
|
+
chainId: ContractsChainId;
|
|
10
|
+
rpc: IRpc;
|
|
11
|
+
account: string;
|
|
12
|
+
tokensData: TokensData;
|
|
13
|
+
batchParams: BatchOrderTxnParams;
|
|
14
|
+
priceOverrides?: SimulationPriceOverrides;
|
|
15
|
+
/** Pre-fetched block timestamp. If not provided, will be fetched via rpc. */
|
|
16
|
+
blockTimestamp?: bigint;
|
|
17
|
+
};
|
|
18
|
+
export declare function fetchBlockTimestamp(rpc: IRpc, chainId: ContractsChainId): Promise<bigint>;
|
|
19
|
+
/**
|
|
20
|
+
* Simulates order execution by calling ExchangeRouter.multicall with
|
|
21
|
+
* the order payload + simulateExecuteLatestOrder via eth_call.
|
|
22
|
+
*
|
|
23
|
+
* A successful simulation reverts with EndOfOracleSimulation.
|
|
24
|
+
* Any other revert is a real error and is thrown.
|
|
25
|
+
*/
|
|
26
|
+
export declare function simulateOrderExecution(params: SimulateOrderParams): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContractsChainId } from "../../configs/chains";
|
|
2
|
+
import type { TypedDataDomain, TypedDataTypes } from "../signer";
|
|
3
|
+
export declare function validateOrderTypedData(domain: TypedDataDomain, types: TypedDataTypes, message: Record<string, any>, chainId: ContractsChainId, signerAddress: string,
|
|
4
|
+
/** For subaccount orders, the main account (owner) is a valid receiver */
|
|
5
|
+
accountAddress?: string): void;
|
|
6
|
+
export declare function validateSubaccountApprovalTypedData(domain: TypedDataDomain, message: Record<string, any>, chainId: ContractsChainId, signerAddress: string, expectedSubaccountAddress: string): void;
|
|
@@ -31,23 +31,15 @@ export declare function getPositionPendingFeesUsd(p: {
|
|
|
31
31
|
pendingBorrowingFeesUsd: bigint;
|
|
32
32
|
}): bigint;
|
|
33
33
|
export declare function getPositionNetValue(p: {
|
|
34
|
-
totalPendingImpactDeltaUsd: bigint;
|
|
35
|
-
priceImpactDiffUsd: bigint;
|
|
36
34
|
collateralUsd: bigint;
|
|
37
35
|
pendingFundingFeesUsd: bigint;
|
|
38
36
|
pendingBorrowingFeesUsd: bigint;
|
|
39
37
|
pnl: bigint;
|
|
40
|
-
closingFeeUsd: bigint;
|
|
41
|
-
uiFeeUsd: bigint;
|
|
42
38
|
}): bigint;
|
|
43
|
-
export declare function getPositionPnlAfterFees({ pnl, pendingBorrowingFeesUsd, pendingFundingFeesUsd,
|
|
39
|
+
export declare function getPositionPnlAfterFees({ pnl, pendingBorrowingFeesUsd, pendingFundingFeesUsd, }: {
|
|
44
40
|
pnl: bigint;
|
|
45
41
|
pendingBorrowingFeesUsd: bigint;
|
|
46
42
|
pendingFundingFeesUsd: bigint;
|
|
47
|
-
closingFeeUsd: bigint;
|
|
48
|
-
uiFeeUsd: bigint;
|
|
49
|
-
totalPendingImpactDeltaUsd: bigint;
|
|
50
|
-
priceImpactDiffUsd: bigint;
|
|
51
43
|
}): bigint;
|
|
52
44
|
export declare function getLeverage(p: {
|
|
53
45
|
sizeInUsd: bigint;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { createViemRpc } from "./createViemRpc";
|
|
2
|
+
export type StateOverrideEntry = {
|
|
3
|
+
address: string;
|
|
4
|
+
stateDiff?: {
|
|
5
|
+
slot: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}[];
|
|
8
|
+
balance?: bigint;
|
|
9
|
+
nonce?: number;
|
|
10
|
+
code?: string;
|
|
11
|
+
};
|
|
12
|
+
export type RpcCallParams = {
|
|
13
|
+
to: string;
|
|
14
|
+
data: string;
|
|
15
|
+
from?: string;
|
|
16
|
+
value?: bigint;
|
|
17
|
+
gas?: bigint;
|
|
18
|
+
stateOverride?: StateOverrideEntry[];
|
|
19
|
+
};
|
|
20
|
+
export type RpcEstimateGasParams = RpcCallParams & {
|
|
21
|
+
stateOverride?: StateOverrideEntry[];
|
|
22
|
+
};
|
|
23
|
+
export interface IRpc {
|
|
24
|
+
estimateGas(params: RpcEstimateGasParams): Promise<bigint>;
|
|
25
|
+
call(params: RpcCallParams): Promise<string>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type TypedDataDomain = {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
chainId: number;
|
|
5
|
+
verifyingContract: string;
|
|
6
|
+
};
|
|
7
|
+
export type TypedDataTypes = Record<string, {
|
|
8
|
+
name: string;
|
|
9
|
+
type: string;
|
|
10
|
+
}[]>;
|
|
11
|
+
export interface IAbstractSigner {
|
|
12
|
+
readonly address: string;
|
|
13
|
+
signTypedData(domain: TypedDataDomain, types: TypedDataTypes, value: Record<string, any>): Promise<string>;
|
|
14
|
+
signMessage(message: string): Promise<string>;
|
|
15
|
+
sendTransaction?(tx: {
|
|
16
|
+
to: string;
|
|
17
|
+
data: string;
|
|
18
|
+
value?: bigint;
|
|
19
|
+
}): Promise<string | {
|
|
20
|
+
hash: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
export { PrivateKeySigner } from "./privateKeySigner";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Chain } from "viem";
|
|
2
|
+
import type { IAbstractSigner, TypedDataDomain, TypedDataTypes } from "./index";
|
|
3
|
+
export declare class PrivateKeySigner implements IAbstractSigner {
|
|
4
|
+
readonly address: string;
|
|
5
|
+
private account;
|
|
6
|
+
private _chain?;
|
|
7
|
+
private _rpcUrl?;
|
|
8
|
+
constructor(privateKey: `0x${string}`, options?: {
|
|
9
|
+
rpcUrl?: string;
|
|
10
|
+
chain?: Chain;
|
|
11
|
+
});
|
|
12
|
+
signTypedData(domain: TypedDataDomain, types: TypedDataTypes, value: Record<string, any>): Promise<string>;
|
|
13
|
+
signMessage(message: string): Promise<string>;
|
|
14
|
+
sendTransaction(tx: {
|
|
15
|
+
to: string;
|
|
16
|
+
data: string;
|
|
17
|
+
value?: bigint;
|
|
18
|
+
}): Promise<string>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ContractsChainId } from "../../configs/chains";
|
|
2
|
+
import { IHttp } from "../http/types";
|
|
3
|
+
import type { IAbstractSigner } from "../signer";
|
|
4
|
+
export type SubaccountStatusRequest = {
|
|
5
|
+
account: string;
|
|
6
|
+
subaccountAddress: string;
|
|
7
|
+
};
|
|
8
|
+
export type SubaccountStatusResponse = {
|
|
9
|
+
active: boolean;
|
|
10
|
+
maxAllowedCount: string;
|
|
11
|
+
currentActionsCount: string;
|
|
12
|
+
remainingActions: string;
|
|
13
|
+
expiresAt: string;
|
|
14
|
+
approvalNonce: string;
|
|
15
|
+
multichainApprovalNonce: string;
|
|
16
|
+
integrationId: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type SubaccountApprovalPrepareRequest = {
|
|
19
|
+
account: string;
|
|
20
|
+
subaccountAddress: string;
|
|
21
|
+
shouldAdd?: boolean;
|
|
22
|
+
expiresAt: string;
|
|
23
|
+
maxAllowedCount: string;
|
|
24
|
+
};
|
|
25
|
+
export type SubaccountApprovalPrepareResponse = {
|
|
26
|
+
domain: {
|
|
27
|
+
name: string;
|
|
28
|
+
version: string;
|
|
29
|
+
chainId: number;
|
|
30
|
+
verifyingContract: string;
|
|
31
|
+
};
|
|
32
|
+
types: Record<string, {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
}[]>;
|
|
36
|
+
message: Record<string, any>;
|
|
37
|
+
primaryType: string;
|
|
38
|
+
relayRouterAddress: string;
|
|
39
|
+
nonce: string;
|
|
40
|
+
};
|
|
41
|
+
export declare function fetchSubaccountStatus(ctx: {
|
|
42
|
+
api: IHttp;
|
|
43
|
+
}, request: SubaccountStatusRequest): Promise<SubaccountStatusResponse>;
|
|
44
|
+
export declare function prepareSubaccountApproval(ctx: {
|
|
45
|
+
api: IHttp;
|
|
46
|
+
}, request: SubaccountApprovalPrepareRequest): Promise<SubaccountApprovalPrepareResponse>;
|
|
47
|
+
export declare function signSubaccountApproval(prepared: SubaccountApprovalPrepareResponse, signer: IAbstractSigner, options?: {
|
|
48
|
+
chainId?: ContractsChainId;
|
|
49
|
+
expectedSubaccountAddress?: string;
|
|
50
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IAbstractSigner } from "../signer";
|
|
2
|
+
import { PrivateKeySigner } from "../signer";
|
|
3
|
+
export type GeneratedSubaccount = {
|
|
4
|
+
address: string;
|
|
5
|
+
signer: PrivateKeySigner;
|
|
6
|
+
privateKey: `0x${string}`;
|
|
7
|
+
};
|
|
8
|
+
export declare function generateSubaccount(mainSigner: IAbstractSigner): Promise<GeneratedSubaccount>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContractsChainId } from "../../configs/chains";
|
|
2
|
+
import type { SubaccountApproval } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Returns a subaccount approval with zeroed-out fields.
|
|
5
|
+
* Used as a placeholder for gas estimation when no real approval is available.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getEmptySubaccountApproval(chainId: ContractsChainId, subaccountAddress: string): SubaccountApproval & {
|
|
8
|
+
signature: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ContractsChainId } from "../../configs/chains";
|
|
2
|
+
export type SubaccountApprovalTypedData = {
|
|
3
|
+
domain: {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
chainId: number;
|
|
7
|
+
verifyingContract: string;
|
|
8
|
+
};
|
|
9
|
+
types: Record<string, {
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
}[]>;
|
|
13
|
+
message: Record<string, any>;
|
|
14
|
+
primaryType: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function getSubaccountApprovalTypedData(params: {
|
|
17
|
+
chainId: ContractsChainId;
|
|
18
|
+
subaccountAddress: string;
|
|
19
|
+
shouldAdd: boolean;
|
|
20
|
+
expiresAt: bigint;
|
|
21
|
+
maxAllowedCount: bigint;
|
|
22
|
+
nonce: bigint;
|
|
23
|
+
signingChainId?: number;
|
|
24
|
+
}): SubaccountApprovalTypedData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashSubaccountApproval(approval: Record<string, any>): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export { generateSubaccount, type GeneratedSubaccount } from "./generateSubaccount";
|
|
3
|
+
export { hashSubaccountApproval } from "./hashSubaccountApproval";
|
|
4
|
+
export { getEmptySubaccountApproval } from "./getEmptySubaccountApproval";
|
|
5
|
+
export { getSubaccountApprovalTypedData, type SubaccountApprovalTypedData, } from "./getSubaccountApprovalTypedData";
|
|
6
|
+
export { fetchSubaccountStatus, prepareSubaccountApproval, signSubaccountApproval, } from "./api";
|
|
7
|
+
export type { SubaccountStatusRequest, SubaccountStatusResponse, SubaccountApprovalPrepareRequest, SubaccountApprovalPrepareResponse, } from "./api";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AnyChainId, ContractsChainId } from "../../configs/chains";
|
|
2
|
+
import type { IAbstractSigner } from "../signer";
|
|
3
|
+
export type SubaccountOnchainData = {
|
|
4
|
+
active: boolean;
|
|
5
|
+
maxAllowedCount: bigint;
|
|
6
|
+
currentActionsCount: bigint;
|
|
7
|
+
expiresAt: bigint;
|
|
8
|
+
approvalNonce: bigint;
|
|
9
|
+
multichainApprovalNonce: bigint;
|
|
10
|
+
integrationId: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
export type SubaccountSerializedConfig = {
|
|
13
|
+
privateKey: string;
|
|
14
|
+
address: string;
|
|
15
|
+
isNew?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type SubaccountApproval = {
|
|
18
|
+
subaccount: string;
|
|
19
|
+
nonce: bigint;
|
|
20
|
+
shouldAdd: boolean;
|
|
21
|
+
expiresAt: bigint;
|
|
22
|
+
maxAllowedCount: bigint;
|
|
23
|
+
actionType: string;
|
|
24
|
+
desChainId: bigint;
|
|
25
|
+
deadline: bigint;
|
|
26
|
+
integrationId: string;
|
|
27
|
+
};
|
|
28
|
+
export type SignedSubaccountApproval = SubaccountApproval & {
|
|
29
|
+
signature: string;
|
|
30
|
+
signedAt: number;
|
|
31
|
+
signatureChainId: AnyChainId;
|
|
32
|
+
subaccountRouterAddress: string;
|
|
33
|
+
};
|
|
34
|
+
export type Subaccount = {
|
|
35
|
+
address: string;
|
|
36
|
+
chainId: ContractsChainId;
|
|
37
|
+
signerChainId: AnyChainId;
|
|
38
|
+
signer: IAbstractSigner;
|
|
39
|
+
signedApproval: SignedSubaccountApproval;
|
|
40
|
+
onchainData: SubaccountOnchainData;
|
|
41
|
+
};
|
|
42
|
+
export type SubaccountValidations = {
|
|
43
|
+
isExpired: boolean;
|
|
44
|
+
isActionsExceeded: boolean;
|
|
45
|
+
isNonceExpired: boolean;
|
|
46
|
+
isApprovalInvalid: boolean;
|
|
47
|
+
isValid: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type SubaccountSession = {
|
|
50
|
+
address: string;
|
|
51
|
+
approval?: {
|
|
52
|
+
message: Record<string, any>;
|
|
53
|
+
signature: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -232,7 +232,7 @@ export type FindSwapPath = (usdIn: bigint, opts?: {
|
|
|
232
232
|
}) => SwapPathStats | undefined;
|
|
233
233
|
export type TradeFeesType = "swap" | "increase" | "decrease" | "edit";
|
|
234
234
|
export declare enum ExternalSwapAggregator {
|
|
235
|
-
|
|
235
|
+
KyberSwap = "kyberSwap",
|
|
236
236
|
BotanixStaking = "botanixStaking"
|
|
237
237
|
}
|
|
238
238
|
export type ExternalSwapQuote = {
|
|
@@ -3,4 +3,3 @@ import type { MarketsInfoData } from "../markets/types";
|
|
|
3
3
|
import { Token, TokensData } from "../tokens/types";
|
|
4
4
|
import type { PositionTradeAction, SwapTradeAction } from "./types";
|
|
5
5
|
export declare function createRawTradeActionTransformer(marketsInfoData: MarketsInfoData, wrappedToken: Token, tokensData: TokensData): (value: SubsquidTradeAction, index: number, array: SubsquidTradeAction[]) => SwapTradeAction | PositionTradeAction | undefined;
|
|
6
|
-
export declare function bigNumberify(n?: bigint | string | null | undefined): bigint | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OrderType } from "../orders/types";
|
|
2
2
|
import { TwapDuration } from "./types";
|
|
3
3
|
export * from "./types";
|
|
4
|
+
export { UI_FEE_SOURCE_UI, UI_FEE_SOURCE_API } from "./uiFeeReceiver";
|
|
4
5
|
export declare function getIsValidTwapParams(duration: TwapDuration, numberOfParts: number): boolean;
|
|
5
6
|
export declare function getTwapDurationInSeconds(duration: TwapDuration): number;
|
|
6
7
|
export declare function getTwapValidFromTime(duration: TwapDuration, numberOfParts: number, partIndex: number): bigint;
|
|
@@ -5,6 +5,8 @@ export type TwapDuration = {
|
|
|
5
5
|
export type TwapOrderParams = {
|
|
6
6
|
duration: TwapDuration;
|
|
7
7
|
numberOfParts: number;
|
|
8
|
+
/** Source byte for uiFeeReceiver (e.g. UI_FEE_SOURCE_API). Default: UI_FEE_SOURCE_UI ("00"). */
|
|
9
|
+
source?: string;
|
|
8
10
|
};
|
|
9
11
|
export type TwapPartParams = TwapOrderParams & {
|
|
10
12
|
partIndex: number;
|