@gmx-io/sdk 2.9.0 → 2.9.2
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/src/clients/v2/__tests__/subaccount.spec.js +2 -2
- package/build/cjs/src/clients/v2/__tests__/testUtil.js +8 -8
- package/build/cjs/src/clients/v2/index.js +61 -41
- package/build/cjs/src/clients/v2/solana.spec.js +188 -0
- package/build/cjs/src/configs/api.js +4 -0
- package/build/cjs/src/utils/fees/index.js +7 -1
- package/build/cjs/src/utils/fees/priceImpact.js +118 -18
- package/build/cjs/src/utils/gmsol/constants.js +9 -0
- package/build/cjs/src/utils/gmsol/index.js +53 -0
- package/build/cjs/src/utils/gmsol/numbers.js +176 -0
- package/build/cjs/src/utils/gmsol/types.js +2 -0
- package/build/cjs/src/utils/gmxAccountApi/api.js +4 -4
- package/build/cjs/src/utils/http/__tests__/chainPins.spec.js +3 -3
- package/build/cjs/src/utils/http/http.js +3 -4
- package/build/cjs/src/utils/http/httpFallback.js +11 -1
- package/build/cjs/src/utils/http/solana.js +17 -0
- package/build/cjs/src/utils/http/validation.js +21 -1
- package/build/cjs/src/utils/http/validation.spec.js +45 -0
- package/build/cjs/src/utils/markets/__tests__/api.spec.js +53 -0
- package/build/cjs/src/utils/markets/api.js +5 -0
- package/build/cjs/src/utils/markets/utils.js +25 -9
- package/build/cjs/src/utils/orderTransactions/api.js +6 -6
- package/build/cjs/src/utils/orders/api.js +3 -0
- package/build/cjs/src/utils/positions/__tests__/liquidationPrice.spec.js +64 -0
- package/build/cjs/src/utils/positions/api.js +3 -0
- package/build/cjs/src/utils/positions/utils.js +88 -19
- package/build/cjs/src/utils/prices/utils.js +69 -14
- package/build/cjs/src/utils/referrals/api.js +41 -0
- package/build/cjs/src/utils/subaccount/api.js +2 -2
- package/build/cjs/src/utils/swap/swapRouting.js +4 -0
- package/build/cjs/src/utils/swap/swapStats.js +6 -1
- package/build/cjs/src/utils/trade/__tests__/gmsolTradeMath.spec.js +1012 -0
- package/build/cjs/src/utils/trade/decrease.js +266 -56
- package/build/cjs/src/utils/trade/decreaseMarginCheck.js +23 -4
- package/build/cjs/src/utils/trade/increase.js +86 -28
- package/build/cjs/src/utils/trade/increaseMarginCheck.js +51 -9
- package/build/cjs/src/utils/trade/twapIncreaseMarginCheck.js +8 -3
- package/build/esm/src/clients/v2/__tests__/subaccount.spec.js +2 -2
- package/build/esm/src/clients/v2/__tests__/testUtil.js +8 -8
- package/build/esm/src/clients/v2/index.js +39 -19
- package/build/esm/src/clients/v2/solana.spec.js +160 -0
- package/build/esm/src/configs/api.js +5 -1
- package/build/esm/src/utils/fees/index.js +7 -1
- package/build/esm/src/utils/fees/priceImpact.js +111 -12
- package/build/esm/src/utils/gmsol/constants.js +6 -0
- package/build/esm/src/utils/gmsol/index.js +43 -0
- package/build/esm/src/utils/gmsol/numbers.js +172 -0
- package/build/esm/src/utils/gmsol/types.js +1 -0
- package/build/esm/src/utils/gmxAccountApi/api.js +4 -4
- package/build/esm/src/utils/http/__tests__/chainPins.spec.js +3 -3
- package/build/esm/src/utils/http/http.js +3 -4
- package/build/esm/src/utils/http/httpFallback.js +11 -1
- package/build/esm/src/utils/http/solana.js +12 -0
- package/build/esm/src/utils/http/validation.js +18 -0
- package/build/esm/src/utils/http/validation.spec.js +43 -0
- package/build/esm/src/utils/markets/__tests__/api.spec.js +53 -0
- package/build/esm/src/utils/markets/api.js +6 -1
- package/build/esm/src/utils/markets/utils.js +23 -8
- package/build/esm/src/utils/orderTransactions/api.js +6 -6
- package/build/esm/src/utils/orders/api.js +3 -0
- package/build/esm/src/utils/positions/__tests__/liquidationPrice.spec.js +62 -0
- package/build/esm/src/utils/positions/api.js +3 -0
- package/build/esm/src/utils/positions/utils.js +89 -20
- package/build/esm/src/utils/prices/utils.js +70 -15
- package/build/esm/src/utils/referrals/api.js +36 -0
- package/build/esm/src/utils/subaccount/api.js +2 -2
- package/build/esm/src/utils/swap/swapRouting.js +4 -0
- package/build/esm/src/utils/swap/swapStats.js +7 -2
- package/build/esm/src/utils/trade/__tests__/gmsolTradeMath.spec.js +1010 -0
- package/build/esm/src/utils/trade/decrease.js +266 -56
- package/build/esm/src/utils/trade/decreaseMarginCheck.js +23 -4
- package/build/esm/src/utils/trade/increase.js +86 -28
- package/build/esm/src/utils/trade/increaseMarginCheck.js +53 -11
- package/build/esm/src/utils/trade/twapIncreaseMarginCheck.js +8 -3
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/src/clients/v2/index.d.ts +21 -12
- package/build/types/src/clients/v2/solana.spec.d.ts +1 -0
- package/build/types/src/utils/fees/index.d.ts +1 -1
- package/build/types/src/utils/fees/priceImpact.d.ts +7 -0
- package/build/types/src/utils/gmsol/constants.d.ts +5 -0
- package/build/types/src/utils/gmsol/index.d.ts +35 -0
- package/build/types/src/utils/gmsol/numbers.d.ts +1 -0
- package/build/types/src/utils/gmsol/types.d.ts +9 -0
- package/build/types/src/utils/http/http.d.ts +2 -5
- package/build/types/src/utils/http/httpFallback.d.ts +2 -5
- package/build/types/src/utils/http/solana.d.ts +4 -0
- package/build/types/src/utils/http/types.d.ts +17 -4
- package/build/types/src/utils/http/validation.d.ts +8 -0
- package/build/types/src/utils/http/validation.spec.d.ts +1 -0
- package/build/types/src/utils/markets/hashKeys.d.ts +1 -1
- package/build/types/src/utils/markets/types.d.ts +3 -2
- package/build/types/src/utils/markets/utils.d.ts +6 -2
- package/build/types/src/utils/orders/api.d.ts +2 -2
- package/build/types/src/utils/positions/__tests__/liquidationPrice.spec.d.ts +1 -0
- package/build/types/src/utils/positions/api.d.ts +2 -2
- package/build/types/src/utils/positions/types.d.ts +1 -0
- package/build/types/src/utils/positions/utils.d.ts +6 -1
- package/build/types/src/utils/prices/types.d.ts +16 -0
- package/build/types/src/utils/prices/utils.d.ts +3 -11
- package/build/types/src/utils/referrals/api.d.ts +8 -0
- package/build/types/src/utils/referrals/types.d.ts +5 -0
- package/build/types/src/utils/rpc/createViemRpc.d.ts +25 -3
- package/build/types/src/utils/trade/__tests__/gmsolTradeMath.spec.d.ts +1 -0
- package/build/types/src/utils/trade/decrease.d.ts +5 -0
- package/build/types/src/utils/trade/decreaseMarginCheck.d.ts +2 -0
- package/build/types/src/utils/trade/increase.d.ts +2 -0
- package/build/types/src/utils/trade/increaseMarginCheck.d.ts +2 -0
- package/build/types/src/utils/trade/twapIncreaseMarginCheck.d.ts +1 -0
- package/build/types/src/utils/trade/types.d.ts +6 -0
- package/package.json +10 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ContractsChainId } from "../../configs/chains";
|
|
1
|
+
import { ContractsChainId, NetworkId } from "../../configs/chains";
|
|
2
2
|
import { ApyParams, ApyResponse } from "../../utils/apy/types";
|
|
3
3
|
import type { WalletBalance, TokenAllowance, SpenderType, ApproveTokenParams, ApproveTokenResult, Erc20ApproveParams } from "../../utils/balances/api";
|
|
4
4
|
import { BuybackWeeklyStatsResponse } from "../../utils/buyback/types";
|
|
5
5
|
import { type CrossChainDepositPrepareRequest, type CrossChainDepositPrepareResponse, type CrossChainWithdrawPrepareRequest, type CrossChainWithdrawPrepareResponse, type CrossChainWithdrawStatusResponse, type CrossChainWithdrawSubmitRequest, type CrossChainWithdrawSubmitResponse, type ExecuteCrossChainDepositResult } from "../../utils/gmxAccountApi";
|
|
6
|
-
import { IHttp } from "../../utils/http/types";
|
|
6
|
+
import type { IHttp, SolanaReadOptions } from "../../utils/http/types";
|
|
7
7
|
import { FetchJitLiquidityInfoParams, JitLiquidityMap } from "../../utils/jitLiquidity/types";
|
|
8
8
|
import { GetTradingCapacityParams, MarketTickerWithCapacity, MarketWithTiers, TradingCapacity } from "../../utils/markets/types";
|
|
9
9
|
import { buildCrossChainWithdrawBridgeOutParams, type BridgeOutParams, type BuildTxnResult, type SameChainDepositRequest, type SameChainWithdrawRequest } from "../../utils/multichain";
|
|
@@ -48,14 +48,22 @@ export type { IAbstractSigner } from "../../utils/signer";
|
|
|
48
48
|
export { PrivateKeySigner } from "../../utils/signer";
|
|
49
49
|
export { HttpError } from "../../utils/http/http";
|
|
50
50
|
export { HttpClientWithFallback } from "../../utils/http/httpFallback";
|
|
51
|
-
export type { IHttp } from "../../utils/http/types";
|
|
51
|
+
export type { IHttp, HttpResponseMetadata, SolanaReadOptions } from "../../utils/http/types";
|
|
52
|
+
export type { FeeDiscount } from "../../utils/referrals/types";
|
|
52
53
|
export type { FrameMeta, StreamCandlePeriod, StreamConnectionStatus, Subscription, WebSocketCtor } from "../../utils/stream";
|
|
53
54
|
export { getGasPaymentTokens } from "../../configs/express";
|
|
54
55
|
export type { SubaccountStatusRequest, SubaccountStatusResponse, SubaccountApprovalPrepareRequest, SubaccountApprovalPrepareResponse, };
|
|
55
56
|
export type { SdkSubaccountStatus } from "../../utils/subaccount/types";
|
|
57
|
+
type GmxApiSdkOptions = {
|
|
58
|
+
chainId: NetworkId;
|
|
59
|
+
apiUrl?: string;
|
|
60
|
+
api?: IHttp;
|
|
61
|
+
streamUrl?: string;
|
|
62
|
+
webSocketImpl?: WebSocketCtor;
|
|
63
|
+
};
|
|
56
64
|
export declare class GmxApiSdk {
|
|
57
65
|
ctx: {
|
|
58
|
-
chainId:
|
|
66
|
+
chainId: NetworkId;
|
|
59
67
|
api: IHttp;
|
|
60
68
|
};
|
|
61
69
|
private _subaccount;
|
|
@@ -63,13 +71,11 @@ export declare class GmxApiSdk {
|
|
|
63
71
|
private readonly streamUrlOverride?;
|
|
64
72
|
private readonly webSocketImpl?;
|
|
65
73
|
private _streamClient?;
|
|
66
|
-
constructor(
|
|
74
|
+
constructor(options: GmxApiSdkOptions);
|
|
75
|
+
requireEvmContext(): {
|
|
67
76
|
chainId: ContractsChainId;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
streamUrl?: string;
|
|
71
|
-
webSocketImpl?: WebSocketCtor;
|
|
72
|
-
});
|
|
77
|
+
api: IHttp;
|
|
78
|
+
};
|
|
73
79
|
private get subaccountClient();
|
|
74
80
|
get subaccountAddress(): string | undefined;
|
|
75
81
|
get subaccountStatus(): SdkSubaccountStatus | undefined;
|
|
@@ -99,10 +105,13 @@ export declare class GmxApiSdk {
|
|
|
99
105
|
fetchPositionsInfo(params: {
|
|
100
106
|
address: string;
|
|
101
107
|
includeRelatedOrders?: boolean;
|
|
102
|
-
}): Promise<import("../../utils/positions").ApiPositionInfo[]>;
|
|
108
|
+
} & SolanaReadOptions): Promise<import("../../utils/positions").ApiPositionInfo[]>;
|
|
103
109
|
fetchOrders(params: {
|
|
104
110
|
address: string;
|
|
105
|
-
}): Promise<import("../../utils/orders").ApiOrderInfo[]>;
|
|
111
|
+
} & SolanaReadOptions): Promise<import("../../utils/orders").ApiOrderInfo[]>;
|
|
112
|
+
fetchFeeDiscount(params: {
|
|
113
|
+
address: string;
|
|
114
|
+
}): Promise<import("../../utils/referrals/types").FeeDiscount>;
|
|
106
115
|
fetchTrades(params: FetchTradesParams): Promise<TradesListResponse>;
|
|
107
116
|
searchTrades(params: SearchTradesParams): Promise<TradesListResponse>;
|
|
108
117
|
fetchOhlcv(params: OhlcvParams): Promise<OhlcvCandle[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -11,7 +11,7 @@ export declare function getSwapFee(marketInfo: MarketInfo, swapAmount: bigint, b
|
|
|
11
11
|
export declare function getPositionFee(marketInfo: MarketInfo, sizeDeltaUsd: bigint, balanceWasImproved: boolean, referralInfo: {
|
|
12
12
|
totalRebateFactor: bigint;
|
|
13
13
|
discountFactor: bigint;
|
|
14
|
-
} | undefined, uiFeeFactor?: bigint, proDiscountFactor?: bigint): {
|
|
14
|
+
} | undefined, uiFeeFactor?: bigint, proDiscountFactor?: bigint, feeDiscountFactor?: bigint): {
|
|
15
15
|
positionFeeUsd: bigint;
|
|
16
16
|
discountUsd: bigint;
|
|
17
17
|
totalRebateUsd: bigint;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { MarketInfo } from "../markets/types";
|
|
2
2
|
import { TokenData } from "../tokens/types";
|
|
3
3
|
import { TradeFees } from "../trade/types";
|
|
4
|
+
export declare class GmsolPriceImpactError extends Error {
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
4
7
|
export declare function getPriceImpactByAcceptablePrice(p: {
|
|
5
8
|
sizeDeltaUsd: bigint;
|
|
6
9
|
acceptablePrice: bigint;
|
|
@@ -60,6 +63,7 @@ export declare function getNextPoolAmountsParams(p: {
|
|
|
60
63
|
shortPoolAmount: bigint;
|
|
61
64
|
longDeltaUsd: bigint;
|
|
62
65
|
shortDeltaUsd: bigint;
|
|
66
|
+
tradeMath?: MarketInfo["tradeMath"];
|
|
63
67
|
}): {
|
|
64
68
|
longPoolUsd: bigint;
|
|
65
69
|
shortPoolUsd: bigint;
|
|
@@ -78,6 +82,7 @@ export declare function getPriceImpactUsd(p: {
|
|
|
78
82
|
factorNegative: bigint;
|
|
79
83
|
exponentFactorPositive: bigint;
|
|
80
84
|
exponentFactorNegative: bigint;
|
|
85
|
+
tradeMath?: MarketInfo["tradeMath"];
|
|
81
86
|
fallbackToZero?: boolean;
|
|
82
87
|
}): {
|
|
83
88
|
priceImpactDeltaUsd: bigint;
|
|
@@ -92,6 +97,7 @@ export declare function calculateImpactForSameSideRebalance(p: {
|
|
|
92
97
|
hasPositiveImpact: boolean;
|
|
93
98
|
factor: bigint;
|
|
94
99
|
exponentFactor: bigint;
|
|
100
|
+
tradeMath?: MarketInfo["tradeMath"];
|
|
95
101
|
}): bigint;
|
|
96
102
|
/**
|
|
97
103
|
* @see https://github.com/gmx-io/gmx-synthetics/blob/5fd9991ff2c37ae5f24f03bc9c132730b012ebf2/contracts/pricing/PricingUtils.sol
|
|
@@ -103,6 +109,7 @@ export declare function calculateImpactForCrossoverRebalance(p: {
|
|
|
103
109
|
factorNegative: bigint;
|
|
104
110
|
exponentFactorPositive: bigint;
|
|
105
111
|
exponentFactorNegative: bigint;
|
|
112
|
+
tradeMath?: MarketInfo["tradeMath"];
|
|
106
113
|
}): bigint;
|
|
107
114
|
export declare function applyImpactFactor(diff: bigint, factor: bigint, exponent: bigint): bigint;
|
|
108
115
|
export declare function getCappedPriceImpactPercentageFromFees({ fees, isSwap, }: {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TokenData } from "../tokens/types";
|
|
2
|
+
export { GMSOL_PRECISION_SCALE } from "./constants";
|
|
3
|
+
export { getGmsolFractionalPower } from "./numbers";
|
|
4
|
+
export type { GmsolMarketConfig } from "./types";
|
|
5
|
+
export declare function getGmsolUsdAmount(value: bigint): bigint;
|
|
6
|
+
export declare function getGmsolMidPrice(token: TokenData): bigint;
|
|
7
|
+
/** The impact is settled in the entry size; it never becomes pending collateral. 0 means the order fills no tokens. */
|
|
8
|
+
export declare function getGmsolIncreaseSizeDeltaInTokens(p: {
|
|
9
|
+
baseSizeDeltaInTokens: bigint;
|
|
10
|
+
priceImpactDeltaUsd: bigint;
|
|
11
|
+
indexToken: TokenData;
|
|
12
|
+
isLong: boolean;
|
|
13
|
+
}): bigint;
|
|
14
|
+
/** Rent is a refundable deposit. The maximum keeper fee can be spent even on a cancelled execution. */
|
|
15
|
+
export declare function getGmsolExecutionFee(p: {
|
|
16
|
+
maxExecutionLamports: bigint;
|
|
17
|
+
orderRentLamports: bigint;
|
|
18
|
+
escrowRentLamports: bigint;
|
|
19
|
+
solPrice: bigint;
|
|
20
|
+
}): {
|
|
21
|
+
keeperFeeLamports: bigint;
|
|
22
|
+
keeperFeeUsd: bigint;
|
|
23
|
+
refundableRentLamports: bigint;
|
|
24
|
+
refundableRentUsd: bigint;
|
|
25
|
+
requiredLamports: bigint;
|
|
26
|
+
};
|
|
27
|
+
export declare function getGmsolExecutionFeeRefund(p: {
|
|
28
|
+
keeperFeeLamports: bigint;
|
|
29
|
+
refundableRentLamports: bigint;
|
|
30
|
+
executionLamportsSpent: bigint;
|
|
31
|
+
ownerCancelledBeforeExecution: boolean;
|
|
32
|
+
}): {
|
|
33
|
+
keeperCostLamports: bigint;
|
|
34
|
+
refundLamports: bigint;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getGmsolFractionalPower(base20: bigint, exponent20: bigint): bigint;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHttp, ServedResult } from "./types";
|
|
1
|
+
import { FetchJsonOptions, IHttp, ServedResult } from "./types";
|
|
2
2
|
export declare class HttpError extends Error {
|
|
3
3
|
/** HTTP status code */
|
|
4
4
|
statusCode: number;
|
|
@@ -14,10 +14,7 @@ export declare class HttpClient implements IHttp {
|
|
|
14
14
|
readonly url: string;
|
|
15
15
|
private readonly timeoutMs;
|
|
16
16
|
constructor(url: string, timeoutMs?: number);
|
|
17
|
-
fetchJson<TResult>(path: string, opts?:
|
|
18
|
-
query?: Record<string, any>;
|
|
19
|
-
transform?: (result: any) => TResult;
|
|
20
|
-
}): Promise<TResult>;
|
|
17
|
+
fetchJson<TResult>(path: string, opts?: FetchJsonOptions<TResult>): Promise<TResult>;
|
|
21
18
|
postJson<TResult>(path: string, body: unknown, opts?: {
|
|
22
19
|
transform?: (result: any) => TResult;
|
|
23
20
|
}): Promise<TResult>;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { IHttp, ServedResult } from "./types";
|
|
1
|
+
import { FetchJsonOptions, IHttp, ServedResult } from "./types";
|
|
2
2
|
export declare class HttpClientWithFallback implements IHttp {
|
|
3
3
|
private clients;
|
|
4
4
|
private primaryIndex;
|
|
5
5
|
private failureTimestamps;
|
|
6
6
|
constructor(urls: string[], timeoutMs?: number);
|
|
7
7
|
get url(): string;
|
|
8
|
-
fetchJson<TResult>(path: string, opts?:
|
|
9
|
-
query?: Record<string, any>;
|
|
10
|
-
transform?: (result: any) => TResult;
|
|
11
|
-
}): Promise<TResult>;
|
|
8
|
+
fetchJson<TResult>(path: string, opts?: FetchJsonOptions<TResult>): Promise<TResult>;
|
|
12
9
|
postJson<TResult>(path: string, body: unknown, opts?: {
|
|
13
10
|
transform?: (result: any) => TResult;
|
|
14
11
|
}): Promise<TResult>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HttpResponseMetadata, SolanaReadOptions } from "./types";
|
|
2
|
+
export type { SolanaReadOptions } from "./types";
|
|
3
|
+
export declare function parseSolanaSlotHeader(value: string | null): number | undefined;
|
|
4
|
+
export declare function getSolanaResponseHandler(onResponse: SolanaReadOptions["onResponse"]): (({ headers }: HttpResponseMetadata) => void) | undefined;
|
|
@@ -2,12 +2,25 @@ export type ServedResult<TResult> = {
|
|
|
2
2
|
result: TResult;
|
|
3
3
|
client: IHttp;
|
|
4
4
|
};
|
|
5
|
+
export type HttpResponseMetadata = {
|
|
6
|
+
headers: {
|
|
7
|
+
get(name: string): string | null;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type SolanaReadOptions = {
|
|
11
|
+
minContextSlot?: number;
|
|
12
|
+
onResponse?: (response: {
|
|
13
|
+
slot: number | undefined;
|
|
14
|
+
}) => void;
|
|
15
|
+
};
|
|
16
|
+
export type FetchJsonOptions<TResult> = {
|
|
17
|
+
query?: Record<string, any>;
|
|
18
|
+
transform?: (result: any) => TResult;
|
|
19
|
+
onResponse?: (response: HttpResponseMetadata) => void;
|
|
20
|
+
};
|
|
5
21
|
export type IHttp = {
|
|
6
22
|
url: string;
|
|
7
|
-
fetchJson: <TResult>(path: string, opts?:
|
|
8
|
-
query?: Record<string, any>;
|
|
9
|
-
transform?: (result: any) => TResult;
|
|
10
|
-
}) => Promise<TResult>;
|
|
23
|
+
fetchJson: <TResult>(path: string, opts?: FetchJsonOptions<TResult>) => Promise<TResult>;
|
|
11
24
|
postJson: <TResult>(path: string, body: unknown, opts?: {
|
|
12
25
|
transform?: (result: any) => TResult;
|
|
13
26
|
}) => Promise<TResult>;
|
|
@@ -3,5 +3,13 @@ export type ApiFieldSpec = {
|
|
|
3
3
|
name: string;
|
|
4
4
|
type: ApiFieldType;
|
|
5
5
|
};
|
|
6
|
+
type ApiFieldParams = {
|
|
7
|
+
record: Record<string, unknown>;
|
|
8
|
+
name: string;
|
|
9
|
+
endpoint: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function readApiString({ record, name, endpoint }: ApiFieldParams): string;
|
|
12
|
+
export declare function readApiUnsignedBigInt({ record, name, endpoint }: ApiFieldParams): bigint;
|
|
6
13
|
export declare function assertApiRecords(value: unknown, endpoint: string): asserts value is Record<string, unknown>[];
|
|
7
14
|
export declare function assertApiFields(record: Record<string, unknown>, fields: readonly ApiFieldSpec[], endpoint: string, index: number): void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MarketConfig as MarketConfigInput } from "../../configs/markets";
|
|
2
2
|
import type { MarketConfig, MarketValues, RawOpenInterestValues } from "./types";
|
|
3
3
|
export type MarketConfigKeysHash = {
|
|
4
|
-
[K in Exclude<keyof MarketConfig, "virtualIndexTokenId">]: string;
|
|
4
|
+
[K in Exclude<keyof MarketConfig, "virtualIndexTokenId" | "tradeMath" | "minCollateralUsd" | "minPositionSizeUsd">]: string;
|
|
5
5
|
};
|
|
6
6
|
type RawMarketValuesKeys = Pick<MarketValues, "longPoolAmount" | "shortPoolAmount" | "positionImpactPoolAmount" | "swapImpactPoolAmountLong" | "swapImpactPoolAmountShort">;
|
|
7
7
|
export type MarketValuesKeysHash = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GmsolMarketConfig } from "../gmsol/types";
|
|
1
2
|
import type { TokenData } from "../tokens/types";
|
|
2
3
|
export type PnlFactorType = "FOR_DEPOSITS" | "FOR_WITHDRAWALS" | "FOR_TRADERS";
|
|
3
4
|
export type MarketSdkConfig = {
|
|
@@ -22,7 +23,7 @@ export type MarketPoolTokens = {
|
|
|
22
23
|
shortToken: TokenData;
|
|
23
24
|
indexToken: TokenData;
|
|
24
25
|
};
|
|
25
|
-
export type MarketInfo = Market & MarketPoolTokens & {
|
|
26
|
+
export type MarketInfo = GmsolMarketConfig & Market & MarketPoolTokens & {
|
|
26
27
|
isDisabled: boolean;
|
|
27
28
|
longPoolAmount: bigint;
|
|
28
29
|
shortPoolAmount: bigint;
|
|
@@ -140,7 +141,7 @@ export type MarketValues = Pick<MarketInfo, (typeof MARKET_VALUES_KEYS)[number]>
|
|
|
140
141
|
/**
|
|
141
142
|
* Updates seldom
|
|
142
143
|
*/
|
|
143
|
-
export type MarketConfig = Pick<MarketInfo, "isDisabled" | "maxLongPoolUsdForDeposit" | "maxShortPoolUsdForDeposit" | "maxLongPoolAmount" | "maxShortPoolAmount" | "reserveFactorLong" | "reserveFactorShort" | "openInterestReserveFactorLong" | "openInterestReserveFactorShort" | "maxOpenInterestLong" | "maxOpenInterestShort" | "maxCollateralSumLongTokenLong" | "maxCollateralSumLongTokenShort" | "maxCollateralSumShortTokenLong" | "maxCollateralSumShortTokenShort" | "minPositionImpactPoolAmount" | "positionImpactPoolDistributionRate" | "borrowingFactorLong" | "borrowingFactorShort" | "borrowingExponentFactorLong" | "borrowingExponentFactorShort" | "fundingFactor" | "fundingExponentFactor" | "fundingIncreaseFactorPerSecond" | "minFundingIncreaseRatePerSecond" | "fundingDecreaseFactorPerSecond" | "thresholdForDecreaseFunding" | "thresholdForStableFunding" | "minFundingFactorPerSecondLong" | "minFundingFactorPerSecondShort" | "maxFundingFactorPerSecondLong" | "maxFundingFactorPerSecondShort" | "maxPnlFactorForTradersLong" | "maxPnlFactorForTradersShort" | "maxPnlFactorForDepositsLong" | "maxPnlFactorForDepositsShort" | "maxPnlFactorForWithdrawalsLong" | "maxPnlFactorForWithdrawalsShort" | "minCollateralFactor" | "minCollateralFactorForLiquidation" | "minCollateralFactorForOpenInterestLong" | "minCollateralFactorForOpenInterestShort" | "positionFeeFactorForBalanceWasImproved" | "positionFeeFactorForBalanceWasNotImproved" | "positionImpactFactorPositive" | "positionImpactFactorNegative" | "maxPositionImpactFactorPositive" | "maxPositionImpactFactorNegative" | "maxPositionImpactFactorForLiquidations" | "maxLendableImpactFactor" | "maxLendableImpactFactorForWithdrawals" | "maxLendableImpactUsd" | "lentPositionImpactPoolAmount" | "positionImpactExponentFactorPositive" | "positionImpactExponentFactorNegative" | "swapFeeFactorForBalanceWasImproved" | "swapFeeFactorForBalanceWasNotImproved" | "swapImpactFactorPositive" | "swapImpactFactorNegative" | "swapImpactExponentFactor" | "atomicSwapFeeFactor" | "withdrawalFeeFactorBalanceWasImproved" | "withdrawalFeeFactorBalanceWasNotImproved" | "virtualMarketId" | "virtualIndexTokenId" | "virtualLongTokenId" | "virtualShortTokenId">;
|
|
144
|
+
export type MarketConfig = Pick<MarketInfo, keyof GmsolMarketConfig | "isDisabled" | "maxLongPoolUsdForDeposit" | "maxShortPoolUsdForDeposit" | "maxLongPoolAmount" | "maxShortPoolAmount" | "reserveFactorLong" | "reserveFactorShort" | "openInterestReserveFactorLong" | "openInterestReserveFactorShort" | "maxOpenInterestLong" | "maxOpenInterestShort" | "maxCollateralSumLongTokenLong" | "maxCollateralSumLongTokenShort" | "maxCollateralSumShortTokenLong" | "maxCollateralSumShortTokenShort" | "minPositionImpactPoolAmount" | "positionImpactPoolDistributionRate" | "borrowingFactorLong" | "borrowingFactorShort" | "borrowingExponentFactorLong" | "borrowingExponentFactorShort" | "fundingFactor" | "fundingExponentFactor" | "fundingIncreaseFactorPerSecond" | "minFundingIncreaseRatePerSecond" | "fundingDecreaseFactorPerSecond" | "thresholdForDecreaseFunding" | "thresholdForStableFunding" | "minFundingFactorPerSecondLong" | "minFundingFactorPerSecondShort" | "maxFundingFactorPerSecondLong" | "maxFundingFactorPerSecondShort" | "maxPnlFactorForTradersLong" | "maxPnlFactorForTradersShort" | "maxPnlFactorForDepositsLong" | "maxPnlFactorForDepositsShort" | "maxPnlFactorForWithdrawalsLong" | "maxPnlFactorForWithdrawalsShort" | "minCollateralFactor" | "minCollateralFactorForLiquidation" | "minCollateralFactorForOpenInterestLong" | "minCollateralFactorForOpenInterestShort" | "positionFeeFactorForBalanceWasImproved" | "positionFeeFactorForBalanceWasNotImproved" | "positionImpactFactorPositive" | "positionImpactFactorNegative" | "maxPositionImpactFactorPositive" | "maxPositionImpactFactorNegative" | "maxPositionImpactFactorForLiquidations" | "maxLendableImpactFactor" | "maxLendableImpactFactorForWithdrawals" | "maxLendableImpactUsd" | "lentPositionImpactPoolAmount" | "positionImpactExponentFactorPositive" | "positionImpactExponentFactorNegative" | "swapFeeFactorForBalanceWasImproved" | "swapFeeFactorForBalanceWasNotImproved" | "swapImpactFactorPositive" | "swapImpactFactorNegative" | "swapImpactExponentFactor" | "atomicSwapFeeFactor" | "withdrawalFeeFactorBalanceWasImproved" | "withdrawalFeeFactorBalanceWasNotImproved" | "virtualMarketId" | "virtualIndexTokenId" | "virtualLongTokenId" | "virtualShortTokenId">;
|
|
144
145
|
export type MarketsData = {
|
|
145
146
|
[marketTokenAddress: string]: Market;
|
|
146
147
|
};
|
|
@@ -119,18 +119,22 @@ export declare function composeRawMarketsInfoData({ marketsAddresses, marketsDat
|
|
|
119
119
|
}): RawMarketsInfoData;
|
|
120
120
|
export declare function mergeMarketsConfigValues(configs: RawMarketConfig[], values: RawMarketValues[]): RawMarketsInfoData;
|
|
121
121
|
export declare function hydrateMarketInfo({ chainId, rawMarketInfo, tokensData, claimableFundingData, }: {
|
|
122
|
-
chainId
|
|
122
|
+
chainId?: ContractsChainId;
|
|
123
123
|
rawMarketInfo: RawMarketInfo;
|
|
124
124
|
tokensData: TokensData;
|
|
125
125
|
claimableFundingData?: ClaimableFundingData[string];
|
|
126
126
|
}): MarketInfo | undefined;
|
|
127
127
|
export declare function composeFullMarketsInfoData({ chainId, marketsAddresses, rawMarketsInfoData, tokensData, claimableFundingData, }: {
|
|
128
|
-
chainId
|
|
128
|
+
chainId?: ContractsChainId;
|
|
129
129
|
marketsAddresses: string[];
|
|
130
130
|
rawMarketsInfoData: RawMarketsInfoData;
|
|
131
131
|
tokensData: TokensData;
|
|
132
132
|
claimableFundingData?: ClaimableFundingData;
|
|
133
133
|
}): MarketsInfoData;
|
|
134
|
+
export declare function getMarketPositionLimits(market: Pick<MarketInfo, "minCollateralUsd" | "minPositionSizeUsd"> | undefined, defaults?: Pick<MarketInfo, "minCollateralUsd" | "minPositionSizeUsd">): {
|
|
135
|
+
minCollateralUsd: bigint | undefined;
|
|
136
|
+
minPositionSizeUsd: bigint | undefined;
|
|
137
|
+
};
|
|
134
138
|
export declare function getMarketWithTiers(marketInfo: MarketInfo, constants: {
|
|
135
139
|
minCollateralUsd: bigint;
|
|
136
140
|
minPositionSizeUsd: bigint;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IHttp } from "../http/types";
|
|
1
|
+
import type { IHttp, SolanaReadOptions } from "../http/types";
|
|
2
2
|
import { ApiOrderInfo } from "./types";
|
|
3
3
|
export declare function fetchApiOrders(ctx: {
|
|
4
4
|
api: IHttp;
|
|
5
5
|
}, params: {
|
|
6
6
|
address: string;
|
|
7
|
-
}): Promise<ApiOrderInfo[]>;
|
|
7
|
+
} & SolanaReadOptions): Promise<ApiOrderInfo[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IHttp } from "../http/types";
|
|
1
|
+
import type { IHttp, SolanaReadOptions } from "../http/types";
|
|
2
2
|
import { ApiPositionInfo } from "./types";
|
|
3
3
|
export declare function fetchApiPositionsInfo(ctx: {
|
|
4
4
|
api: IHttp;
|
|
5
5
|
}, params: {
|
|
6
6
|
address: string;
|
|
7
7
|
includeRelatedOrders?: boolean;
|
|
8
|
-
}): Promise<ApiPositionInfo[]>;
|
|
8
|
+
} & SolanaReadOptions): Promise<ApiPositionInfo[]>;
|
|
@@ -79,12 +79,14 @@ export declare function getLiquidationPrice(p: {
|
|
|
79
79
|
collateralToken: TokenData;
|
|
80
80
|
marketInfo: MarketInfo;
|
|
81
81
|
pendingFundingFeesUsd: bigint;
|
|
82
|
+
fundingFeeAmount?: bigint;
|
|
82
83
|
pendingBorrowingFeesUsd: bigint;
|
|
83
84
|
pendingImpactAmount: bigint;
|
|
84
85
|
minCollateralUsd: bigint;
|
|
85
86
|
isLong: boolean;
|
|
86
87
|
useMaxPriceImpact?: boolean;
|
|
87
88
|
userReferralInfo: UserReferralInfo | undefined;
|
|
89
|
+
feeDiscountFactor?: bigint;
|
|
88
90
|
}): bigint | undefined;
|
|
89
91
|
export declare function getMinCollateralUsdForLiquidationPrice(p: {
|
|
90
92
|
sizeInUsd: bigint;
|
|
@@ -95,6 +97,7 @@ export declare function getMinCollateralUsdForLiquidationPrice(p: {
|
|
|
95
97
|
pnl: bigint;
|
|
96
98
|
isLong: boolean;
|
|
97
99
|
userReferralInfo: UserReferralInfo | undefined;
|
|
100
|
+
feeDiscountFactor?: bigint;
|
|
98
101
|
}): bigint;
|
|
99
102
|
export declare function getIsPositionBelowMinCollateralForLeverage(position: PositionInfoLoaded, collateralDeltaAmount?: bigint): boolean;
|
|
100
103
|
export declare function getNetPriceImpactDeltaUsdForDecrease({ marketInfo, sizeInUsd, pendingImpactAmount, priceImpactDeltaUsd, sizeDeltaUsd, }: {
|
|
@@ -114,7 +117,7 @@ export declare function getPriceImpactDiffUsd({ totalImpactDeltaUsd, marketInfo,
|
|
|
114
117
|
sizeDeltaUsd: bigint;
|
|
115
118
|
}): bigint;
|
|
116
119
|
export declare function getMinCollateralFactorForPosition(position: PositionInfoLoaded, openInterestDelta: bigint): bigint;
|
|
117
|
-
export declare function getContractPositionDynamicFees({ position, marketInfo, marketFeeState, referralInfo, }: {
|
|
120
|
+
export declare function getContractPositionDynamicFees({ position, marketInfo, marketFeeState, referralInfo, feeDiscountFactor, }: {
|
|
118
121
|
position: {
|
|
119
122
|
sizeInUsd: bigint;
|
|
120
123
|
sizeInTokens: bigint;
|
|
@@ -139,6 +142,7 @@ export declare function getContractPositionDynamicFees({ position, marketInfo, m
|
|
|
139
142
|
claimableFundingAmountPerSizeShortShort: bigint;
|
|
140
143
|
};
|
|
141
144
|
referralInfo?: UserReferralInfo;
|
|
145
|
+
feeDiscountFactor?: bigint;
|
|
142
146
|
}): {
|
|
143
147
|
pendingBorrowingFeesUsd: bigint;
|
|
144
148
|
fundingFeeAmount: bigint;
|
|
@@ -153,6 +157,7 @@ export declare function getPositionInfo(p: {
|
|
|
153
157
|
marketInfo: MarketInfo;
|
|
154
158
|
minCollateralUsd: bigint;
|
|
155
159
|
userReferralInfo?: UserReferralInfo;
|
|
160
|
+
feeDiscountFactor?: bigint;
|
|
156
161
|
showPnlInLeverage?: boolean;
|
|
157
162
|
uiFeeFactor?: bigint;
|
|
158
163
|
}): PositionInfo;
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import type { MarketInfo } from "../markets/types";
|
|
2
|
+
export type AcceptablePriceParams = {
|
|
3
|
+
marketInfo: MarketInfo;
|
|
4
|
+
isIncrease: boolean;
|
|
5
|
+
isLimit: boolean;
|
|
6
|
+
isLong: boolean;
|
|
7
|
+
indexPrice: bigint;
|
|
8
|
+
sizeDeltaUsd: bigint;
|
|
9
|
+
maxNegativePriceImpactBps?: bigint;
|
|
10
|
+
sizeDeltaInTokens?: bigint;
|
|
11
|
+
positionSizeInUsd?: bigint;
|
|
12
|
+
positionSizeInTokens?: bigint;
|
|
13
|
+
};
|
|
14
|
+
export type GmsolAcceptablePriceParams = AcceptablePriceParams & {
|
|
15
|
+
priceImpactDeltaUsd: bigint;
|
|
16
|
+
};
|
|
1
17
|
export type OhlcvCandle = {
|
|
2
18
|
timestamp: number;
|
|
3
19
|
open: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MarketInfo } from "../markets/types";
|
|
2
1
|
import { OrderType } from "../orders/types";
|
|
3
2
|
import { TokenPrices } from "../tokens/types";
|
|
4
3
|
import { TriggerThresholdType } from "../trade/types";
|
|
4
|
+
import type { AcceptablePriceParams } from "./types";
|
|
5
5
|
export declare function getMarkPrice(p: {
|
|
6
6
|
prices: TokenPrices;
|
|
7
7
|
isIncrease: boolean;
|
|
@@ -19,16 +19,7 @@ export declare function getIncreaseEvaluationIndexPrice(p: {
|
|
|
19
19
|
orderType: OrderType | undefined;
|
|
20
20
|
triggerPrice: bigint | undefined;
|
|
21
21
|
}): bigint | undefined;
|
|
22
|
-
export declare function getAcceptablePriceInfo(p: {
|
|
23
|
-
marketInfo: MarketInfo;
|
|
24
|
-
isIncrease: boolean;
|
|
25
|
-
isLimit: boolean;
|
|
26
|
-
isLong: boolean;
|
|
27
|
-
indexPrice: bigint;
|
|
28
|
-
sizeDeltaUsd: bigint;
|
|
29
|
-
maxNegativePriceImpactBps?: bigint;
|
|
30
|
-
sizeDeltaInTokens?: bigint;
|
|
31
|
-
}): {
|
|
22
|
+
export declare function getAcceptablePriceInfo(p: AcceptablePriceParams): {
|
|
32
23
|
acceptablePrice: bigint;
|
|
33
24
|
acceptablePriceDeltaBps: bigint;
|
|
34
25
|
priceImpactDeltaAmount: bigint;
|
|
@@ -54,4 +45,5 @@ export declare function getDefaultAcceptablePriceImpactBps(p: {
|
|
|
54
45
|
sizeDeltaUsd: bigint;
|
|
55
46
|
priceImpactDeltaUsd: bigint;
|
|
56
47
|
acceptablePriceImpactBuffer?: number;
|
|
48
|
+
executionPrice?: bigint;
|
|
57
49
|
}): bigint;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IHttp } from "../http/types";
|
|
2
|
+
import type { FeeDiscount } from "./types";
|
|
3
|
+
export declare function parseFeeDiscount(raw: unknown): FeeDiscount;
|
|
4
|
+
export declare function fetchApiFeeDiscount(ctx: {
|
|
5
|
+
api: IHttp;
|
|
6
|
+
}, params: {
|
|
7
|
+
address: string;
|
|
8
|
+
}): Promise<FeeDiscount>;
|
|
@@ -11,6 +11,11 @@ export type UserReferralInfo = {
|
|
|
11
11
|
discountFactor: bigint;
|
|
12
12
|
error?: Error;
|
|
13
13
|
};
|
|
14
|
+
export type FeeDiscount = {
|
|
15
|
+
userReferralInfo: UserReferralInfo;
|
|
16
|
+
orderFeeDiscountFactor: bigint;
|
|
17
|
+
updatedAt: number | undefined;
|
|
18
|
+
};
|
|
14
19
|
export declare enum RebateDistributionType {
|
|
15
20
|
Rebate = "1",
|
|
16
21
|
Claim = "1000",
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { IRpc, StateOverrideEntry } from "./index";
|
|
2
|
+
type ViemRpcRequest = {
|
|
3
|
+
account: `0x${string}` | undefined;
|
|
4
|
+
to: `0x${string}`;
|
|
5
|
+
data: `0x${string}`;
|
|
6
|
+
value: bigint;
|
|
7
|
+
stateOverride: ReturnType<typeof mapStateOverride>;
|
|
8
|
+
};
|
|
9
|
+
declare function mapStateOverride(entries?: StateOverrideEntry[]): {
|
|
10
|
+
address: `0x${string}`;
|
|
11
|
+
stateDiff: {
|
|
12
|
+
slot: `0x${string}`;
|
|
13
|
+
value: `0x${string}`;
|
|
14
|
+
}[] | undefined;
|
|
15
|
+
balance: bigint | undefined;
|
|
16
|
+
nonce: number | undefined;
|
|
17
|
+
code: `0x${string}` | undefined;
|
|
18
|
+
}[] | undefined;
|
|
19
|
+
export declare function createViemRpc(client: {
|
|
20
|
+
estimateGas(params: ViemRpcRequest): Promise<bigint>;
|
|
21
|
+
call(params: ViemRpcRequest): Promise<{
|
|
22
|
+
data?: string;
|
|
23
|
+
}>;
|
|
24
|
+
}): IRpc;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -22,6 +22,7 @@ export declare function getDecreasePositionAmounts(p: {
|
|
|
22
22
|
acceptablePriceImpactBuffer?: number;
|
|
23
23
|
userReferralInfo: UserReferralInfo | undefined;
|
|
24
24
|
proDiscountFactor?: bigint;
|
|
25
|
+
feeDiscountFactor?: bigint;
|
|
25
26
|
minCollateralUsd: bigint;
|
|
26
27
|
minPositionSizeUsd: bigint;
|
|
27
28
|
uiFeeFactor: bigint;
|
|
@@ -43,6 +44,7 @@ export declare function getIsFullClose(p: {
|
|
|
43
44
|
}): boolean;
|
|
44
45
|
export declare function getMinCollateralUsdForLeverage(position: PositionInfoLoaded, openInterestDelta: bigint): bigint;
|
|
45
46
|
export declare function getMinRequiredCollateralUsdForPosition(p: {
|
|
47
|
+
feeDiscountFactor?: bigint;
|
|
46
48
|
position: PositionInfoLoaded;
|
|
47
49
|
minCollateralUsd: bigint | undefined;
|
|
48
50
|
userReferralInfo: UserReferralInfo | undefined;
|
|
@@ -54,6 +56,7 @@ export declare function getMaxWithdrawAmount(p: {
|
|
|
54
56
|
collateralDecimals: number | undefined;
|
|
55
57
|
userReferralInfo: UserReferralInfo | undefined;
|
|
56
58
|
proDiscountFactor?: bigint;
|
|
59
|
+
feeDiscountFactor?: bigint;
|
|
57
60
|
}): bigint;
|
|
58
61
|
export declare function getIsProfitKeptInPnlToken(p: {
|
|
59
62
|
pnlToken: TokenData;
|
|
@@ -110,6 +113,7 @@ export declare function getNextPositionValuesForDecreaseTrade(p: {
|
|
|
110
113
|
isLong: boolean;
|
|
111
114
|
minCollateralUsd: bigint;
|
|
112
115
|
userReferralInfo: UserReferralInfo | undefined;
|
|
116
|
+
feeDiscountFactor?: bigint;
|
|
113
117
|
priceImpactDiffUsd?: bigint;
|
|
114
118
|
}): NextPositionValues;
|
|
115
119
|
export declare function getDecreaseSwapType(pnlToken: TokenData, collateralToken: TokenData, receiveToken: TokenData): DecreasePositionSwapType;
|
|
@@ -136,6 +140,7 @@ export declare function getOptimalDecreaseAndSwapAmounts(p: {
|
|
|
136
140
|
acceptablePriceImpactBuffer?: number;
|
|
137
141
|
userReferralInfo: UserReferralInfo | undefined;
|
|
138
142
|
proDiscountFactor?: bigint;
|
|
143
|
+
feeDiscountFactor?: bigint;
|
|
139
144
|
minCollateralUsd: bigint;
|
|
140
145
|
minPositionSizeUsd: bigint;
|
|
141
146
|
uiFeeFactor: bigint;
|
|
@@ -25,6 +25,7 @@ export type DecreaseResultingPositionMarginStateParams = {
|
|
|
25
25
|
minPositionSizeUsd: bigint;
|
|
26
26
|
userReferralInfo: UserReferralInfo | undefined;
|
|
27
27
|
proDiscountFactor?: bigint;
|
|
28
|
+
feeDiscountFactor?: bigint;
|
|
28
29
|
indexPriceForEvaluation?: bigint;
|
|
29
30
|
};
|
|
30
31
|
/**
|
|
@@ -44,6 +45,7 @@ export type TriggerDecreaseRemainingPositionMarginStateParams = {
|
|
|
44
45
|
minPositionSizeUsd: bigint;
|
|
45
46
|
userReferralInfo: UserReferralInfo | undefined;
|
|
46
47
|
proDiscountFactor?: bigint;
|
|
48
|
+
feeDiscountFactor?: bigint;
|
|
47
49
|
};
|
|
48
50
|
/**
|
|
49
51
|
* The same gates for a Take-Profit or Stop-Loss at its trigger price: `decreaseAmounts` are its amounts at that
|
|
@@ -20,6 +20,7 @@ type IncreasePositionParams = {
|
|
|
20
20
|
acceptablePriceImpactBuffer?: number;
|
|
21
21
|
userReferralInfo: UserReferralInfo | undefined;
|
|
22
22
|
proDiscountFactor?: bigint;
|
|
23
|
+
feeDiscountFactor?: bigint;
|
|
23
24
|
strategy: "leverageBySize" | "leverageByCollateral" | "independent";
|
|
24
25
|
findSwapPath: FindSwapPath;
|
|
25
26
|
uiFeeFactor: bigint;
|
|
@@ -89,6 +90,7 @@ export declare function getNextPositionValuesForIncreaseTrade(p: {
|
|
|
89
90
|
showPnlInLeverage: boolean;
|
|
90
91
|
minCollateralUsd: bigint;
|
|
91
92
|
userReferralInfo: UserReferralInfo | undefined;
|
|
93
|
+
feeDiscountFactor?: bigint;
|
|
92
94
|
collateralPrice?: bigint;
|
|
93
95
|
}): NextPositionValues;
|
|
94
96
|
export {};
|
|
@@ -28,6 +28,7 @@ export type PositionMarginStateParams = {
|
|
|
28
28
|
isLong: boolean;
|
|
29
29
|
userReferralInfo: UserReferralInfo | undefined;
|
|
30
30
|
proDiscountFactor?: bigint;
|
|
31
|
+
feeDiscountFactor?: bigint;
|
|
31
32
|
shouldValidateMinCollateralUsd?: boolean;
|
|
32
33
|
};
|
|
33
34
|
/**
|
|
@@ -54,6 +55,7 @@ export type IncreaseResultingPositionMarginStateParams = {
|
|
|
54
55
|
minCollateralUsd: bigint;
|
|
55
56
|
userReferralInfo: UserReferralInfo | undefined;
|
|
56
57
|
proDiscountFactor?: bigint;
|
|
58
|
+
feeDiscountFactor?: bigint;
|
|
57
59
|
indexPriceForEvaluation?: bigint;
|
|
58
60
|
};
|
|
59
61
|
export declare function getMarketInfoAtIndexPrice(p: {
|
|
@@ -35,6 +35,7 @@ export type TwapIncreaseSequentialMarginStateParams = TwapIncreaseSequenceParams
|
|
|
35
35
|
minCollateralUsd: bigint;
|
|
36
36
|
userReferralInfo: UserReferralInfo | undefined;
|
|
37
37
|
proDiscountFactor?: bigint;
|
|
38
|
+
feeDiscountFactor?: bigint;
|
|
38
39
|
};
|
|
39
40
|
export type TwapIncreaseSequentialMarginState = {
|
|
40
41
|
numberOfParts: number;
|