@gmx-io/sdk 2.2.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/src/abis/TransitStation.js +2222 -0
- package/build/cjs/src/abis/index.js +2 -0
- package/build/cjs/src/clients/v2/index.js +54 -27
- package/build/cjs/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +32 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +272 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +60 -0
- package/build/cjs/src/configs/markets.js +28 -0
- package/build/cjs/src/configs/tokens.js +9 -0
- package/build/cjs/src/test/mock.js +32 -4
- package/build/cjs/src/utils/markets/utils.js +45 -1
- package/build/cjs/src/utils/paxos/__tests__/api.spec.js +128 -0
- package/build/cjs/src/utils/paxos/api.js +129 -0
- package/build/cjs/src/utils/paxos/types.js +2 -0
- package/build/cjs/src/utils/trade/__tests__/increaseMarginCheck.spec.js +14 -35
- package/build/cjs/src/utils/trade/__tests__/twapIncreaseMarginCheck.spec.js +368 -0
- package/build/cjs/src/utils/trade/increaseMarginCheck.js +27 -13
- package/build/cjs/src/utils/trade/twapIncreaseMarginCheck.js +180 -0
- package/build/cjs/src/utils/twap/index.js +13 -4
- package/build/cjs/src/utils/usdgBoostApr/api.js +7 -0
- package/build/cjs/src/utils/usdgBoostApr/types.js +2 -0
- package/build/cjs/src/utils/whitelists/api.js +9 -0
- package/build/cjs/src/utils/whitelists/types.js +2 -0
- package/build/esm/src/abis/TransitStation.js +2220 -0
- package/build/esm/src/abis/index.js +2 -0
- package/build/esm/src/clients/v2/index.js +27 -0
- package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +32 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +272 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +60 -0
- package/build/esm/src/configs/markets.js +28 -0
- package/build/esm/src/configs/tokens.js +9 -0
- package/build/esm/src/test/mock.js +27 -0
- package/build/esm/src/utils/markets/utils.js +44 -1
- package/build/esm/src/utils/paxos/__tests__/api.spec.js +126 -0
- package/build/esm/src/utils/paxos/api.js +120 -0
- package/build/esm/src/utils/paxos/types.js +1 -0
- package/build/esm/src/utils/trade/__tests__/increaseMarginCheck.spec.js +15 -36
- package/build/esm/src/utils/trade/__tests__/twapIncreaseMarginCheck.spec.js +366 -0
- package/build/esm/src/utils/trade/increaseMarginCheck.js +24 -11
- package/build/esm/src/utils/trade/twapIncreaseMarginCheck.js +172 -0
- package/build/esm/src/utils/twap/index.js +10 -3
- package/build/esm/src/utils/usdgBoostApr/api.js +3 -0
- package/build/esm/src/utils/usdgBoostApr/types.js +1 -0
- package/build/esm/src/utils/whitelists/api.js +5 -0
- package/build/esm/src/utils/whitelists/types.js +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/src/abis/TransitStation.d.ts +1710 -0
- package/build/types/src/abis/index.d.ts +1709 -0
- package/build/types/src/clients/v2/index.d.ts +20 -0
- package/build/types/src/codegen/prebuilt/index.d.ts +364 -0
- package/build/types/src/test/mock.d.ts +5 -0
- package/build/types/src/utils/markets/utils.d.ts +3 -0
- package/build/types/src/utils/paxos/__tests__/api.spec.d.ts +1 -0
- package/build/types/src/utils/paxos/api.d.ts +24 -0
- package/build/types/src/utils/paxos/types.d.ts +139 -0
- package/build/types/src/utils/trade/__tests__/twapIncreaseMarginCheck.spec.d.ts +1 -0
- package/build/types/src/utils/trade/increaseMarginCheck.d.ts +15 -7
- package/build/types/src/utils/trade/twapIncreaseMarginCheck.d.ts +50 -0
- package/build/types/src/utils/trade/types.d.ts +2 -0
- package/build/types/src/utils/twap/index.d.ts +2 -0
- package/build/types/src/utils/usdgBoostApr/api.d.ts +5 -0
- package/build/types/src/utils/usdgBoostApr/types.d.ts +19 -0
- package/build/types/src/utils/whitelists/api.d.ts +7 -0
- package/build/types/src/utils/whitelists/types.d.ts +6 -0
- package/package.json +10 -1
|
@@ -5,7 +5,8 @@ export declare enum PositionMarginFailureReason {
|
|
|
5
5
|
MinCollateral = "min collateral",
|
|
6
6
|
NonPositiveRemainingMargin = "< 0",
|
|
7
7
|
MinCollateralForLeverage = "min collateral for leverage",
|
|
8
|
-
InsufficientCollateralUsd = "insufficient collateral usd"
|
|
8
|
+
InsufficientCollateralUsd = "insufficient collateral usd",
|
|
9
|
+
MaxAllowedLeverage = "max allowed leverage"
|
|
9
10
|
}
|
|
10
11
|
export declare function getIsMaxLeverageMarginReason(reason: PositionMarginFailureReason | undefined): boolean;
|
|
11
12
|
export type PositionMarginState = {
|
|
@@ -34,16 +35,17 @@ export type PositionMarginStateParams = {
|
|
|
34
35
|
* after an increase.
|
|
35
36
|
*/
|
|
36
37
|
export declare function getResultingPositionMarginState(p: PositionMarginStateParams): PositionMarginState;
|
|
38
|
+
export type IncreasePositionState = {
|
|
39
|
+
sizeInUsd: bigint;
|
|
40
|
+
sizeInTokens: bigint;
|
|
41
|
+
collateralAmount: bigint;
|
|
42
|
+
pendingImpactAmount: bigint;
|
|
43
|
+
};
|
|
37
44
|
export type IncreaseResultingPositionMarginStateParams = {
|
|
38
45
|
marketInfo: MarketInfo;
|
|
39
46
|
collateralToken: TokenData;
|
|
40
47
|
isLong: boolean;
|
|
41
|
-
existingPosition:
|
|
42
|
-
sizeInUsd: bigint;
|
|
43
|
-
sizeInTokens: bigint;
|
|
44
|
-
collateralAmount: bigint;
|
|
45
|
-
pendingImpactAmount: bigint;
|
|
46
|
-
} | undefined;
|
|
48
|
+
existingPosition: IncreasePositionState | undefined;
|
|
47
49
|
sizeDeltaUsd: bigint;
|
|
48
50
|
sizeDeltaInTokens: bigint;
|
|
49
51
|
collateralDeltaAmount: bigint;
|
|
@@ -52,6 +54,11 @@ export type IncreaseResultingPositionMarginStateParams = {
|
|
|
52
54
|
proDiscountFactor?: bigint;
|
|
53
55
|
indexPriceForEvaluation?: bigint;
|
|
54
56
|
};
|
|
57
|
+
export type IncreaseResultingPositionState = {
|
|
58
|
+
marginState: PositionMarginState;
|
|
59
|
+
position: IncreasePositionState;
|
|
60
|
+
marketInfo: MarketInfo;
|
|
61
|
+
};
|
|
55
62
|
/**
|
|
56
63
|
* Mirrors the post-increase gates of `IncreasePositionUtils.increasePosition` from the gmx-synthetics
|
|
57
64
|
* build deployed on Arbitrum (release_2.2.1 @ 23c9d160: release-v2.2c plus MarketUtils.getPositivePnl
|
|
@@ -59,3 +66,4 @@ export type IncreaseResultingPositionMarginStateParams = {
|
|
|
59
66
|
* then `validatePosition` on the resulting position.
|
|
60
67
|
*/
|
|
61
68
|
export declare function getIncreaseResultingPositionMarginState(p: IncreaseResultingPositionMarginStateParams): PositionMarginState | undefined;
|
|
69
|
+
export declare function getIncreaseResultingPositionState(p: IncreaseResultingPositionMarginStateParams): IncreaseResultingPositionState | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MarketInfo, MarketsInfoData } from "../markets/types";
|
|
2
|
+
import { UserReferralInfo } from "../referrals/types";
|
|
3
|
+
import { TokenData } from "../tokens/types";
|
|
4
|
+
import { IncreasePositionState, PositionMarginState } from "./increaseMarginCheck";
|
|
5
|
+
import { IncreasePositionAmounts } from "./types";
|
|
6
|
+
export type TwapIncreaseSequenceParams = {
|
|
7
|
+
numberOfParts: number;
|
|
8
|
+
partDelaysSeconds: number[];
|
|
9
|
+
partGrossCollateralUsds: bigint[];
|
|
10
|
+
};
|
|
11
|
+
export type TwapIncreaseAggregateAmounts = {
|
|
12
|
+
sizeDeltaUsd: bigint;
|
|
13
|
+
pendingFeesUsd: bigint;
|
|
14
|
+
};
|
|
15
|
+
export type TwapIncreasePartAmounts = {
|
|
16
|
+
partSizeDeltaUsd: bigint;
|
|
17
|
+
pendingFeesUsd: bigint;
|
|
18
|
+
};
|
|
19
|
+
export type TwapIncreasePartsCollateralParams = {
|
|
20
|
+
marketsInfoData: MarketsInfoData;
|
|
21
|
+
swapPath: string[];
|
|
22
|
+
initialCollateralToken: TokenData;
|
|
23
|
+
collateralToken: TokenData;
|
|
24
|
+
initialCollateralAmountPerPart: bigint;
|
|
25
|
+
numberOfParts: number;
|
|
26
|
+
uiFeeFactor: bigint;
|
|
27
|
+
wrappedNativeTokenAddress: string;
|
|
28
|
+
};
|
|
29
|
+
export type TwapIncreaseSequentialMarginStateParams = TwapIncreaseSequenceParams & TwapIncreasePartAmounts & {
|
|
30
|
+
marketInfo: MarketInfo;
|
|
31
|
+
collateralToken: TokenData;
|
|
32
|
+
isLong: boolean;
|
|
33
|
+
existingPosition: IncreasePositionState | undefined;
|
|
34
|
+
uiFeeFactor: bigint;
|
|
35
|
+
minCollateralUsd: bigint;
|
|
36
|
+
userReferralInfo: UserReferralInfo | undefined;
|
|
37
|
+
proDiscountFactor?: bigint;
|
|
38
|
+
};
|
|
39
|
+
export type TwapIncreaseSequentialMarginState = {
|
|
40
|
+
numberOfParts: number;
|
|
41
|
+
failingPartIndex: number | undefined;
|
|
42
|
+
isFailingPartEligibleNow: boolean;
|
|
43
|
+
marginState: PositionMarginState;
|
|
44
|
+
contractMarginState: PositionMarginState;
|
|
45
|
+
};
|
|
46
|
+
export declare function getTwapIncreaseAggregateAmounts(increaseAmounts: IncreasePositionAmounts): TwapIncreaseAggregateAmounts;
|
|
47
|
+
export declare function getTwapIncreasePartAmounts({ sizeDeltaUsd, pendingFeesUsd }: TwapIncreaseAggregateAmounts, numberOfParts: number): TwapIncreasePartAmounts;
|
|
48
|
+
export declare function getTwapIncreasePartsGrossCollateralUsd(p: TwapIncreasePartsCollateralParams): bigint[] | undefined;
|
|
49
|
+
export declare function getTwapIncreaseSequentialMarginState(p: TwapIncreaseSequentialMarginStateParams): TwapIncreaseSequentialMarginState | undefined;
|
|
50
|
+
export declare function getIsTwapIncreaseSequenceSafe(state: TwapIncreaseSequentialMarginState | undefined): boolean;
|
|
@@ -127,6 +127,8 @@ export type DepositAmounts = {
|
|
|
127
127
|
glvTokenUsd: bigint;
|
|
128
128
|
shortTokenAmount: bigint;
|
|
129
129
|
shortTokenUsd: bigint;
|
|
130
|
+
initialShortTokenAmount?: bigint;
|
|
131
|
+
shortTokenSwapPathStats?: SwapPathStats;
|
|
130
132
|
swapFeeUsd: bigint;
|
|
131
133
|
uiFeeUsd: bigint;
|
|
132
134
|
swapPriceImpactDeltaUsd: bigint;
|
|
@@ -4,7 +4,9 @@ export * from "./types";
|
|
|
4
4
|
export { UI_FEE_SOURCE_UI, UI_FEE_SOURCE_API } from "./uiFeeReceiver";
|
|
5
5
|
export declare function getIsValidTwapParams(duration: TwapDuration, numberOfParts: number): boolean;
|
|
6
6
|
export declare function getTwapDurationInSeconds(duration: TwapDuration): number;
|
|
7
|
+
export declare function getTwapPartDelaySeconds(duration: TwapDuration, numberOfParts: number, partIndex: number): number;
|
|
7
8
|
export declare function getTwapValidFromTime(duration: TwapDuration, numberOfParts: number, partIndex: number): bigint;
|
|
9
|
+
export declare function getTwapPartDelaysSeconds(duration: TwapDuration, numberOfParts: number): number[];
|
|
8
10
|
export declare function changeTwapNumberOfPartsValue(value: number): number;
|
|
9
11
|
export declare function getTwapOrderKey({ twapId, orderType, pool, isLong, collateralTokenSymbol, swapPath, account, initialCollateralToken, }: {
|
|
10
12
|
twapId: string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type UsdgPoolBoostApr = {
|
|
2
|
+
marketAddress: string;
|
|
3
|
+
boostApr: number;
|
|
4
|
+
lastRoundTimestamp: number;
|
|
5
|
+
};
|
|
6
|
+
export type UsdgGlvBoostApr = {
|
|
7
|
+
glvAddress: string;
|
|
8
|
+
boostApr: number;
|
|
9
|
+
gmRate: number;
|
|
10
|
+
premium: number | null;
|
|
11
|
+
lastRoundTimestamp: number;
|
|
12
|
+
};
|
|
13
|
+
export type UsdgBoostAprResponse = {
|
|
14
|
+
status: "not_started";
|
|
15
|
+
} | {
|
|
16
|
+
status: "active";
|
|
17
|
+
pools: UsdgPoolBoostApr[];
|
|
18
|
+
glv: UsdgGlvBoostApr | null;
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmx-io/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -155,6 +155,9 @@
|
|
|
155
155
|
],
|
|
156
156
|
"utils/gas/*": [
|
|
157
157
|
"./build/types/src/utils/gas/*.d.ts"
|
|
158
|
+
],
|
|
159
|
+
"utils/twap/uiFeeReceiver": [
|
|
160
|
+
"./build/types/src/utils/twap/uiFeeReceiver.d.ts"
|
|
158
161
|
]
|
|
159
162
|
}
|
|
160
163
|
},
|
|
@@ -488,6 +491,12 @@
|
|
|
488
491
|
"import": "./build/esm/src/utils/gas/*.js",
|
|
489
492
|
"require": "./build/cjs/src/utils/gas/*.js",
|
|
490
493
|
"default": "./build/cjs/src/utils/gas/*.js"
|
|
494
|
+
},
|
|
495
|
+
"./utils/twap/uiFeeReceiver": {
|
|
496
|
+
"types": "./build/types/src/utils/twap/uiFeeReceiver.d.ts",
|
|
497
|
+
"import": "./build/esm/src/utils/twap/uiFeeReceiver.js",
|
|
498
|
+
"require": "./build/cjs/src/utils/twap/uiFeeReceiver.js",
|
|
499
|
+
"default": "./build/cjs/src/utils/twap/uiFeeReceiver.js"
|
|
491
500
|
}
|
|
492
501
|
},
|
|
493
502
|
"scripts": {
|