@gmx-io/sdk 2.9.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/src/abis/RatioVesterReader.js +45 -0
- package/build/cjs/src/abis/index.js +2 -0
- package/build/cjs/src/clients/v1/modules/oracle.js +15 -0
- package/build/cjs/src/clients/v1/modules/oracle.spec.js +20 -0
- package/build/cjs/src/clients/v1/modules/orders/helpers.js +16 -12
- package/build/cjs/src/clients/v1/modules/orders/helpers.spec.js +21 -0
- package/build/cjs/src/clients/v1/modules/orders/orders.js +4 -0
- package/build/cjs/src/clients/v1/modules/orders/utils.js +1 -0
- package/build/cjs/src/clients/v2/__tests__/subaccount.spec.js +74 -17
- package/build/cjs/src/clients/v2/__tests__/subaccountLifecycle.spec.js +1 -1
- package/build/cjs/src/clients/v2/__tests__/testUtil.js +14 -2
- package/build/cjs/src/clients/v2/index.js +28 -7
- package/build/cjs/src/clients/v2/solana.spec.js +81 -4
- package/build/cjs/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +48 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketConfigKeys.json +782 -0
- package/build/cjs/src/codegen/prebuilt/hashedMarketValuesKeys.json +90 -0
- package/build/cjs/src/configs/contracts.js +10 -0
- package/build/cjs/src/configs/dataStore.js +22 -4
- package/build/cjs/src/configs/express.js +1 -2
- package/build/cjs/src/configs/markets.js +42 -0
- package/build/cjs/src/configs/tokens.js +2 -0
- package/build/cjs/src/test/mockCrossFetch.js +1 -0
- package/build/cjs/src/utils/__tests__/fees.spec.js +52 -0
- package/build/cjs/src/utils/__tests__/gmsolUnits.spec.js +101 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/batchUtils.spec.js +66 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +6 -6
- package/build/cjs/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +40 -0
- package/build/cjs/src/utils/__tests__/orderTransactions/updateOrder.spec.js +4 -2
- package/build/cjs/src/utils/__tests__/tokens.spec.js +63 -0
- package/build/cjs/src/utils/errors/transactionsErrors.js +6 -0
- package/build/cjs/src/utils/fees/index.js +5 -0
- package/build/cjs/src/utils/fees/priceImpact.js +39 -6
- package/build/cjs/src/utils/gmsol/__tests__/fixtures/nativeMath.json +3171 -0
- package/build/cjs/src/utils/gmsol/__tests__/nativeMath.spec.js +213 -0
- package/build/cjs/src/utils/gmsol/constants.js +4 -1
- package/build/cjs/src/utils/gmsol/fees.js +19 -0
- package/build/cjs/src/utils/gmsol/index.js +29 -1
- package/build/cjs/src/utils/gmsol/markets.js +206 -0
- package/build/cjs/src/utils/gmsol/numbers.js +55 -1
- package/build/cjs/src/utils/gmsol/positions.js +152 -0
- package/build/cjs/src/utils/gmsol/units.js +106 -0
- package/build/cjs/src/utils/http/http.js +21 -25
- package/build/cjs/src/utils/http/httpFallback.js +3 -3
- package/build/cjs/src/utils/http/validation.js +9 -1
- package/build/cjs/src/utils/markets/hashKeys.js +8 -0
- package/build/cjs/src/utils/markets/multicall.js +10 -0
- package/build/cjs/src/utils/markets/utils.js +2 -0
- package/build/cjs/src/utils/multichain/__tests__/api.spec.js +49 -0
- package/build/cjs/src/utils/multichain/api.js +29 -2
- package/build/cjs/src/utils/orderTransactions/utils.js +63 -5
- package/build/cjs/src/utils/orders/api.js +66 -3
- package/build/cjs/src/utils/positions/__tests__/liquidationImpact.spec.js +44 -0
- package/build/cjs/src/utils/positions/__tests__/liquidationPrice.spec.js +159 -2
- package/build/cjs/src/utils/positions/__tests__/trackingCollateral.spec.js +395 -0
- package/build/cjs/src/utils/positions/api.js +4 -0
- package/build/cjs/src/utils/positions/utils.js +119 -44
- package/build/cjs/src/utils/prices/api.js +2 -2
- package/build/cjs/src/utils/referrals/api.js +5 -4
- package/build/cjs/src/utils/subaccount/generateSubaccount.js +14 -14
- package/build/cjs/src/utils/subaccount/sdkClient.js +40 -19
- package/build/cjs/src/utils/tokens/utils.js +23 -7
- package/build/cjs/src/utils/trade/__tests__/decrease.spec.js +152 -0
- package/build/cjs/src/utils/trade/__tests__/gmsolTradeMath.spec.js +43 -0
- package/build/cjs/src/utils/trade/decrease.js +113 -33
- package/build/cjs/src/utils/trade/decreaseMarginCheck.js +38 -2
- package/build/cjs/src/utils/trade/decreaseOutputs.js +20 -5
- package/build/cjs/src/utils/trade/increase.js +30 -11
- package/build/cjs/src/utils/trade/increaseMarginCheck.js +14 -35
- package/build/esm/src/abis/RatioVesterReader.js +43 -0
- package/build/esm/src/abis/index.js +2 -0
- package/build/esm/src/clients/v1/modules/oracle.js +15 -0
- package/build/esm/src/clients/v1/modules/oracle.spec.js +18 -0
- package/build/esm/src/clients/v1/modules/orders/helpers.js +17 -13
- package/build/esm/src/clients/v1/modules/orders/helpers.spec.js +21 -0
- package/build/esm/src/clients/v1/modules/orders/orders.js +4 -0
- package/build/esm/src/clients/v1/modules/orders/utils.js +1 -0
- package/build/esm/src/clients/v2/__tests__/subaccount.spec.js +74 -17
- package/build/esm/src/clients/v2/__tests__/subaccountLifecycle.spec.js +2 -2
- package/build/esm/src/clients/v2/__tests__/testUtil.js +13 -2
- package/build/esm/src/clients/v2/index.js +29 -8
- package/build/esm/src/clients/v2/solana.spec.js +79 -2
- package/build/esm/src/codegen/prebuilt/hashedKinkModelMarketRatesKeys.json +48 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketConfigKeys.json +782 -0
- package/build/esm/src/codegen/prebuilt/hashedMarketValuesKeys.json +90 -0
- package/build/esm/src/configs/contracts.js +10 -0
- package/build/esm/src/configs/dataStore.js +14 -0
- package/build/esm/src/configs/express.js +0 -1
- package/build/esm/src/configs/markets.js +42 -0
- package/build/esm/src/configs/tokens.js +2 -0
- package/build/esm/src/test/mockCrossFetch.js +1 -0
- package/build/esm/src/utils/__tests__/fees.spec.js +53 -1
- package/build/esm/src/utils/__tests__/gmsolUnits.spec.js +99 -0
- package/build/esm/src/utils/__tests__/orderTransactions/batchUtils.spec.js +68 -2
- package/build/esm/src/utils/__tests__/orderTransactions/decreaseOrders.spec.js +6 -6
- package/build/esm/src/utils/__tests__/orderTransactions/exchangeRouterMulticall.spec.js +40 -0
- package/build/esm/src/utils/__tests__/orderTransactions/updateOrder.spec.js +5 -3
- package/build/esm/src/utils/__tests__/tokens.spec.js +64 -1
- package/build/esm/src/utils/errors/transactionsErrors.js +6 -0
- package/build/esm/src/utils/fees/index.js +5 -0
- package/build/esm/src/utils/fees/priceImpact.js +36 -5
- package/build/esm/src/utils/gmsol/__tests__/fixtures/nativeMath.json +3171 -0
- package/build/esm/src/utils/gmsol/__tests__/nativeMath.spec.js +208 -0
- package/build/esm/src/utils/gmsol/constants.js +3 -0
- package/build/esm/src/utils/gmsol/fees.js +15 -0
- package/build/esm/src/utils/gmsol/index.js +6 -2
- package/build/esm/src/utils/gmsol/markets.js +193 -0
- package/build/esm/src/utils/gmsol/numbers.js +55 -1
- package/build/esm/src/utils/gmsol/positions.js +148 -0
- package/build/esm/src/utils/gmsol/units.js +97 -0
- package/build/esm/src/utils/http/http.js +21 -25
- package/build/esm/src/utils/http/httpFallback.js +3 -3
- package/build/esm/src/utils/http/validation.js +7 -0
- package/build/esm/src/utils/markets/hashKeys.js +9 -1
- package/build/esm/src/utils/markets/multicall.js +10 -0
- package/build/esm/src/utils/markets/utils.js +2 -0
- package/build/esm/src/utils/multichain/__tests__/api.spec.js +46 -0
- package/build/esm/src/utils/multichain/api.js +29 -2
- package/build/esm/src/utils/orderTransactions/utils.js +59 -5
- package/build/esm/src/utils/orders/api.js +64 -2
- package/build/esm/src/utils/positions/__tests__/liquidationImpact.spec.js +42 -0
- package/build/esm/src/utils/positions/__tests__/liquidationPrice.spec.js +161 -4
- package/build/esm/src/utils/positions/__tests__/trackingCollateral.spec.js +393 -0
- package/build/esm/src/utils/positions/api.js +4 -0
- package/build/esm/src/utils/positions/utils.js +115 -44
- package/build/esm/src/utils/prices/api.js +2 -2
- package/build/esm/src/utils/referrals/api.js +6 -5
- package/build/esm/src/utils/subaccount/generateSubaccount.js +13 -14
- package/build/esm/src/utils/subaccount/sdkClient.js +38 -19
- package/build/esm/src/utils/tokens/utils.js +20 -6
- package/build/esm/src/utils/trade/__tests__/decrease.spec.js +150 -0
- package/build/esm/src/utils/trade/__tests__/gmsolTradeMath.spec.js +43 -0
- package/build/esm/src/utils/trade/decrease.js +115 -35
- package/build/esm/src/utils/trade/decreaseMarginCheck.js +37 -2
- package/build/esm/src/utils/trade/decreaseOutputs.js +19 -5
- package/build/esm/src/utils/trade/increase.js +32 -13
- package/build/esm/src/utils/trade/increaseMarginCheck.js +18 -39
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/src/abis/RatioVesterReader.d.ts +74 -0
- package/build/types/src/abis/index.d.ts +73 -0
- package/build/types/src/clients/v1/modules/oracle.d.ts +6 -1
- package/build/types/src/clients/v1/modules/oracle.spec.d.ts +1 -0
- package/build/types/src/clients/v2/__tests__/testUtil.d.ts +1 -0
- package/build/types/src/clients/v2/index.d.ts +26 -5
- package/build/types/src/codegen/prebuilt/index.d.ts +1045 -125
- package/build/types/src/configs/contracts.d.ts +10 -0
- package/build/types/src/configs/dataStore.d.ts +8 -0
- package/build/types/src/configs/express.d.ts +0 -1
- package/build/types/src/utils/__tests__/gmsolUnits.spec.d.ts +1 -0
- package/build/types/src/utils/errors/parseError.d.ts +1 -1
- package/build/types/src/utils/errors/transactionsErrors.d.ts +6 -0
- package/build/types/src/utils/fees/priceImpact.d.ts +10 -0
- package/build/types/src/utils/gmsol/__tests__/nativeMath.spec.d.ts +1 -0
- package/build/types/src/utils/gmsol/constants.d.ts +4 -0
- package/build/types/src/utils/gmsol/fees.d.ts +6 -0
- package/build/types/src/utils/gmsol/index.d.ts +7 -3
- package/build/types/src/utils/gmsol/markets.d.ts +49 -0
- package/build/types/src/utils/gmsol/numbers.d.ts +10 -0
- package/build/types/src/utils/gmsol/positions.d.ts +7 -0
- package/build/types/src/utils/gmsol/types.d.ts +96 -0
- package/build/types/src/utils/gmsol/units.d.ts +53 -0
- package/build/types/src/utils/http/types.d.ts +1 -0
- package/build/types/src/utils/http/validation.d.ts +1 -0
- package/build/types/src/utils/markets/types.d.ts +5 -2
- package/build/types/src/utils/multichain/api.d.ts +4 -1
- package/build/types/src/utils/orderTransactions/utils.d.ts +19 -4
- package/build/types/src/utils/orders/api.d.ts +2 -1
- package/build/types/src/utils/orders/types.d.ts +24 -0
- package/build/types/src/utils/positions/__tests__/liquidationImpact.spec.d.ts +1 -0
- package/build/types/src/utils/positions/__tests__/trackingCollateral.spec.d.ts +1 -0
- package/build/types/src/utils/positions/types.d.ts +2 -0
- package/build/types/src/utils/positions/utils.d.ts +30 -0
- package/build/types/src/utils/prices/api.d.ts +2 -0
- package/build/types/src/utils/referrals/types.d.ts +4 -0
- package/build/types/src/utils/subaccount/generateSubaccount.d.ts +9 -4
- package/build/types/src/utils/subaccount/sdkClient.d.ts +7 -1
- package/build/types/src/utils/subaccount/types.d.ts +2 -0
- package/build/types/src/utils/tokens/types.d.ts +1 -0
- package/build/types/src/utils/tokens/utils.d.ts +6 -0
- package/build/types/src/utils/trade/__tests__/decrease.spec.d.ts +1 -0
- package/build/types/src/utils/trade/decrease.d.ts +3 -0
- package/build/types/src/utils/trade/decreaseMarginCheck.d.ts +11 -0
- package/build/types/src/utils/trade/decreaseOutputs.d.ts +7 -2
- package/build/types/src/utils/trade/increaseMarginCheck.d.ts +1 -0
- package/package.json +10 -1
|
@@ -29,6 +29,8 @@ export declare const CONTRACTS: {
|
|
|
29
29
|
GmxVester: string;
|
|
30
30
|
GlpVester: string;
|
|
31
31
|
AffiliateVester: string;
|
|
32
|
+
OrphanRatioVester: string;
|
|
33
|
+
RatioVesterReader: string;
|
|
32
34
|
PositionRouter: string;
|
|
33
35
|
UniswapGmxEthPool: string;
|
|
34
36
|
ReferralStorage: string;
|
|
@@ -93,6 +95,8 @@ export declare const CONTRACTS: {
|
|
|
93
95
|
GmxVester: string;
|
|
94
96
|
GlpVester: string;
|
|
95
97
|
AffiliateVester: string;
|
|
98
|
+
OrphanRatioVester: string;
|
|
99
|
+
RatioVesterReader: string;
|
|
96
100
|
PositionRouter: string;
|
|
97
101
|
TraderJoeGmxAvaxPool: string;
|
|
98
102
|
ReferralStorage: string;
|
|
@@ -186,6 +190,8 @@ export declare const CONTRACTS: {
|
|
|
186
190
|
GmxVester: "0x0000000000000000000000000000000000000000";
|
|
187
191
|
GlpVester: "0x0000000000000000000000000000000000000000";
|
|
188
192
|
AffiliateVester: "0x0000000000000000000000000000000000000000";
|
|
193
|
+
OrphanRatioVester: "0x0000000000000000000000000000000000000000";
|
|
194
|
+
RatioVesterReader: "0x0000000000000000000000000000000000000000";
|
|
189
195
|
Router: "0x0000000000000000000000000000000000000000";
|
|
190
196
|
GovToken: "0x0000000000000000000000000000000000000000";
|
|
191
197
|
ES_GMX_IOU: "0x0000000000000000000000000000000000000000";
|
|
@@ -221,6 +227,8 @@ export declare const CONTRACTS: {
|
|
|
221
227
|
GmxVester: "0x0000000000000000000000000000000000000000";
|
|
222
228
|
GlpVester: "0x0000000000000000000000000000000000000000";
|
|
223
229
|
AffiliateVester: "0x0000000000000000000000000000000000000000";
|
|
230
|
+
OrphanRatioVester: "0x0000000000000000000000000000000000000000";
|
|
231
|
+
RatioVesterReader: "0x0000000000000000000000000000000000000000";
|
|
224
232
|
PositionRouter: "0x0000000000000000000000000000000000000000";
|
|
225
233
|
TraderJoeGmxAvaxPool: "0x0000000000000000000000000000000000000000";
|
|
226
234
|
ReferralStorage: string;
|
|
@@ -311,6 +319,8 @@ export declare const CONTRACTS: {
|
|
|
311
319
|
GmxVester: "0x0000000000000000000000000000000000000000";
|
|
312
320
|
GlpVester: "0x0000000000000000000000000000000000000000";
|
|
313
321
|
AffiliateVester: "0x0000000000000000000000000000000000000000";
|
|
322
|
+
OrphanRatioVester: "0x0000000000000000000000000000000000000000";
|
|
323
|
+
RatioVesterReader: "0x0000000000000000000000000000000000000000";
|
|
314
324
|
Router: "0x0000000000000000000000000000000000000000";
|
|
315
325
|
VaultReader: "0x0000000000000000000000000000000000000000";
|
|
316
326
|
Reader: "0x0000000000000000000000000000000000000000";
|
|
@@ -7,6 +7,8 @@ export declare const SWAP_IMPACT_EXPONENT_FACTOR_KEY: string;
|
|
|
7
7
|
export declare const SWAP_FEE_FACTOR_KEY: string;
|
|
8
8
|
export declare const ATOMIC_SWAP_FEE_FACTOR_KEY: string;
|
|
9
9
|
export declare const WITHDRAWAL_FEE_FACTOR_KEY: string;
|
|
10
|
+
export declare const DEPOSIT_FEE_FACTOR_KEY: string;
|
|
11
|
+
export declare const SWAP_FEE_RECEIVER_FACTOR_KEY: string;
|
|
10
12
|
export declare const FEE_RECEIVER_DEPOSIT_FACTOR_KEY: string;
|
|
11
13
|
export declare const BORROWING_FEE_RECEIVER_FACTOR_KEY: string;
|
|
12
14
|
export declare const FEE_RECEIVER_WITHDRAWAL_FACTOR_KEY: string;
|
|
@@ -105,9 +107,12 @@ export declare const BASE_BORROWING_FACTOR: string;
|
|
|
105
107
|
export declare const ABOVE_OPTIMAL_USAGE_BORROWING_FACTOR: string;
|
|
106
108
|
export declare const SUBACCOUNT_EXPIRES_AT: string;
|
|
107
109
|
export declare const MULTICHAIN_BALANCE: string;
|
|
110
|
+
export declare const POSITION_LAST_SRC_CHAIN_ID: string;
|
|
108
111
|
export declare const PRICE_FEED_KEY: string;
|
|
109
112
|
export declare const GASLESS_FEATURE_DISABLED_KEY: string;
|
|
110
113
|
export declare const SIGNAL_UNSTAKE_FEATURE_DISABLED_KEY: string;
|
|
114
|
+
export declare const INCENTIVE_VESTER_DEPOSIT_FEATURE_DISABLED_KEY: string;
|
|
115
|
+
export declare const INCENTIVE_VESTER_CLAIM_FEATURE_DISABLED_KEY: string;
|
|
111
116
|
export declare const GELATO_RELAY_FEE_MULTIPLIER_FACTOR_KEY: string;
|
|
112
117
|
export declare const REQUEST_EXPIRATION_TIME_KEY: string;
|
|
113
118
|
export declare const GMX_SIMULATION_ORIGIN: string;
|
|
@@ -191,8 +196,11 @@ export declare function subaccountIntegrationIdKey(account: string, subaccount:
|
|
|
191
196
|
export declare function subaccountRevocationCounterKey(account: string, subaccount: string): string;
|
|
192
197
|
export declare function subaccountAutoTopUpAmountKey(account: string, subaccount: string): string;
|
|
193
198
|
export declare function multichainBalanceKey(account: string, token: string): string;
|
|
199
|
+
export declare function positionLastSrcChainIdKey(positionKey: string): string;
|
|
194
200
|
export declare function priceFeedKey(token: string): string;
|
|
195
201
|
export declare function gaslessFeatureDisabledKey(module: string): string;
|
|
196
202
|
export declare function signalUnstakeFeatureDisabledKey(rewardRouter: string): string;
|
|
203
|
+
export declare function incentiveVesterDepositFeatureDisabledKey(vester: string): string;
|
|
204
|
+
export declare function incentiveVesterClaimFeatureDisabledKey(vester: string): string;
|
|
197
205
|
export declare function claimTermsKey(distributionId: bigint): string;
|
|
198
206
|
export declare function claimsDisabledKey(distributionId: bigint): string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Token } from "../utils/tokens/types";
|
|
2
|
-
export declare const SUBACCOUNT_MESSAGE = "Generate a GMX 1CT (One-Click Trading) session. Only sign this message on a trusted website.";
|
|
3
2
|
export declare const SUBACCOUNT_DOCS_URL = "https://docs.gmx.io/docs/trading/overview/#express-trading-and-one-click-trading";
|
|
4
3
|
export declare const DEFAULT_SUBACCOUNT_EXPIRY_DURATION: number;
|
|
5
4
|
export declare const DEFAULT_SUBACCOUNT_MAX_ALLOWED_COUNT = 90;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { AbiParameterToPrimitiveType, ContractErrorName, ExtractAbiItem } from "
|
|
|
2
2
|
import { abis } from "../../abis";
|
|
3
3
|
import { CustomErrorName, TxErrorType } from "./transactionsErrors";
|
|
4
4
|
export declare function extractErrorDataFromViemError(error: any): string | undefined;
|
|
5
|
-
export type OrderErrorContext = "simulation" | "gasLimit" | "gasPrice" | "bestNonce" | "sending" | "pending" | "relayer" | "minting" | "execution" | "unknown";
|
|
5
|
+
export type OrderErrorContext = "simulation" | "gasLimit" | "gasPrice" | "bestNonce" | "sending" | "pending" | "pendingWalletBatch" | "relayer" | "minting" | "execution" | "unknown";
|
|
6
6
|
export type ErrorLike = {
|
|
7
7
|
message?: string;
|
|
8
8
|
stack?: string;
|
|
@@ -14,6 +14,7 @@ export declare enum CustomErrorName {
|
|
|
14
14
|
DisabledMarket = "DisabledMarket",
|
|
15
15
|
EmptyDesignatedVesters = "EmptyDesignatedVesters",
|
|
16
16
|
EmptyStakeAmount = "EmptyStakeAmount",
|
|
17
|
+
EmptyVesterWithdrawal = "EmptyVesterWithdrawal",
|
|
17
18
|
EndOfOracleSimulation = "EndOfOracleSimulation",
|
|
18
19
|
ExternalCallFailed = "ExternalCallFailed",
|
|
19
20
|
InsufficientBridgeOutputAmount = "InsufficientBridgeOutputAmount",
|
|
@@ -29,8 +30,10 @@ export declare enum CustomErrorName {
|
|
|
29
30
|
OrderNotFulfillableAtAcceptablePrice = "OrderNotFulfillableAtAcceptablePrice",
|
|
30
31
|
InsufficientSwapOutputAmount = "InsufficientSwapOutputAmount",
|
|
31
32
|
InsufficientStrictTransferAllowance = "InsufficientStrictTransferAllowance",
|
|
33
|
+
InsufficientVesterBacking = "InsufficientVesterBacking",
|
|
32
34
|
InvalidCollateralTokenForMarket = "InvalidCollateralTokenForMarket",
|
|
33
35
|
InvalidDecreaseOrderSize = "InvalidDecreaseOrderSize",
|
|
36
|
+
InvalidDesignatedVester = "InvalidDesignatedVester",
|
|
34
37
|
InvalidOraclePrice = "InvalidOraclePrice",
|
|
35
38
|
LiquidatablePosition = "LiquidatablePosition",
|
|
36
39
|
MarketNotFound = "MarketNotFound",
|
|
@@ -58,13 +61,16 @@ export declare enum CustomErrorName {
|
|
|
58
61
|
TransferNotSignalled = "TransferNotSignalled",
|
|
59
62
|
TransferVesterConfigChanged = "TransferVesterConfigChanged",
|
|
60
63
|
UnableToWithdrawCollateral = "UnableToWithdrawCollateral",
|
|
64
|
+
UnbackedPairAmountLocked = "UnbackedPairAmountLocked",
|
|
61
65
|
UnstakeAmountExceedsStake = "UnstakeAmountExceedsStake",
|
|
62
66
|
UnstakeNotSignalled = "UnstakeNotSignalled",
|
|
63
67
|
UsdDeltaExceedsLongOpenInterest = "UsdDeltaExceedsLongOpenInterest",
|
|
64
68
|
UsdDeltaExceedsPoolValue = "UsdDeltaExceedsPoolValue",
|
|
65
69
|
UsdDeltaExceedsShortOpenInterest = "UsdDeltaExceedsShortOpenInterest",
|
|
66
70
|
VesterAccountFrozen = "VesterAccountFrozen",
|
|
71
|
+
VesterDeactivated = "VesterDeactivated",
|
|
67
72
|
VesterProvisioningNotComplete = "VesterProvisioningNotComplete",
|
|
73
|
+
VestingCapExceeded = "VestingCapExceeded",
|
|
68
74
|
VestingReceiverNotFresh = "VestingReceiverNotFresh",
|
|
69
75
|
VestingSenderHasOpenSession = "VestingSenderHasOpenSession"
|
|
70
76
|
}
|
|
@@ -50,12 +50,22 @@ export declare function getProportionalPendingImpactValues({ sizeInUsd, pendingI
|
|
|
50
50
|
proportionalPendingImpactDeltaAmount: bigint;
|
|
51
51
|
proportionalPendingImpactDeltaUsd: bigint;
|
|
52
52
|
};
|
|
53
|
+
export declare function getPriceImpactDeltaAmount(indexToken: TokenData, priceImpactDeltaUsd: bigint): bigint;
|
|
53
54
|
export declare function getPriceImpactForSwap(marketInfo: MarketInfo, tokenA: TokenData, tokenB: TokenData, usdDeltaTokenA: bigint, usdDeltaTokenB: bigint, opts?: {
|
|
54
55
|
fallbackToZero?: boolean;
|
|
55
56
|
}): {
|
|
56
57
|
priceImpactDeltaUsd: bigint;
|
|
57
58
|
balanceWasImproved: boolean;
|
|
58
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* A positive deposit impact is paid out of the swap impact pool into the market pool, which takes back part of the
|
|
62
|
+
* balance improvement, so the contract prices it again with that rebate included
|
|
63
|
+
* @see https://github.com/gmx-io/gmx-synthetics/blob/973adf75/contracts/pricing/SwapPricingUtils.sol#L122
|
|
64
|
+
*/
|
|
65
|
+
export declare function getPriceImpactForDeposit(marketInfo: MarketInfo, tokenA: TokenData, tokenB: TokenData, usdDeltaTokenA: bigint, usdDeltaTokenB: bigint): {
|
|
66
|
+
priceImpactDeltaUsd: bigint;
|
|
67
|
+
balanceWasImproved: boolean;
|
|
68
|
+
};
|
|
59
69
|
export declare function getNextPoolAmountsParams(p: {
|
|
60
70
|
longToken: TokenData;
|
|
61
71
|
shortToken: TokenData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { GmsolSide } from "./types";
|
|
1
2
|
export declare const GMSOL_PRECISION: bigint;
|
|
2
3
|
export declare const GMSOL_PRECISION_SCALE: bigint;
|
|
3
4
|
export declare const GMSOL_MAX_UNSIGNED: bigint;
|
|
4
5
|
export declare const GMSOL_MAX_SIGNED: bigint;
|
|
5
6
|
export declare const GMSOL_MAX_IMPACT_EXPONENT: bigint;
|
|
7
|
+
export declare const GMSOL_LONG: GmsolSide;
|
|
8
|
+
export declare const GMSOL_SHORT: GmsolSide;
|
|
9
|
+
export declare const GMSOL_SIDES: readonly GmsolSide[];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { TokenData } from "../tokens/types";
|
|
2
|
-
export { GMSOL_PRECISION_SCALE } from "./constants";
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
2
|
+
export { GMSOL_PRECISION, GMSOL_PRECISION_SCALE } from "./constants";
|
|
3
|
+
export { getGmsolOrderFeeDiscountFactor } from "./fees";
|
|
4
|
+
export { getGmsolBorrowingFactorPerSecond, getGmsolMarketStatus, getGmsolNextFunding, getGmsolNextPositionImpactPoolAmount, getGmsolPendingBorrowingFees, getGmsolPoolValue, } from "./markets";
|
|
5
|
+
export { getGmsolFractionalPower, gmsolMath } from "./numbers";
|
|
6
|
+
export { getGmsolPendingPositionFees } from "./positions";
|
|
7
|
+
export type { GmsolFeeDiscountConfig, GmsolFundingParams, GmsolMarketConfig, GmsolMarketPrices, GmsolMarketState, GmsolMarketStatus, GmsolNextFunding, GmsolPendingPositionFees, GmsolPerSide, GmsolPnlFactorKind, GmsolPositionState, GmsolPriceRange, GmsolSide, } from "./types";
|
|
8
|
+
export * from "./units";
|
|
5
9
|
export declare function getGmsolUsdAmount(value: bigint): bigint;
|
|
6
10
|
export declare function getGmsolMidPrice(token: TokenData): bigint;
|
|
7
11
|
/** The impact is settled in the entry size; it never becomes pending collateral. 0 means the order fills no tokens. */
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GmsolMarketPrices, GmsolMarketState, GmsolMarketStatus, GmsolNextFunding, GmsolPnlFactorKind, GmsolPriceRange, GmsolSide } from "./types";
|
|
2
|
+
export declare function getGmsolReservedValue({ market, prices, side, }: {
|
|
3
|
+
market: GmsolMarketState;
|
|
4
|
+
prices: GmsolMarketPrices;
|
|
5
|
+
side: GmsolSide;
|
|
6
|
+
}): bigint;
|
|
7
|
+
export declare function getGmsolPoolValueWithoutPnl({ market, prices, side, maximize, }: {
|
|
8
|
+
market: GmsolMarketState;
|
|
9
|
+
prices: GmsolMarketPrices;
|
|
10
|
+
side: GmsolSide;
|
|
11
|
+
maximize: boolean;
|
|
12
|
+
}): bigint;
|
|
13
|
+
export declare function getGmsolPendingPnl({ market, indexPrice, side, maximize, }: {
|
|
14
|
+
market: GmsolMarketState;
|
|
15
|
+
indexPrice: GmsolPriceRange;
|
|
16
|
+
side: GmsolSide;
|
|
17
|
+
maximize: boolean;
|
|
18
|
+
}): bigint;
|
|
19
|
+
export declare function getGmsolBorrowingFactorPerSecond({ market, prices, side, }: {
|
|
20
|
+
market: GmsolMarketState;
|
|
21
|
+
prices: GmsolMarketPrices;
|
|
22
|
+
side: GmsolSide;
|
|
23
|
+
}): bigint;
|
|
24
|
+
export declare function getGmsolNextCumulativeBorrowingFactor({ market, prices, now, side, }: {
|
|
25
|
+
market: GmsolMarketState;
|
|
26
|
+
prices: GmsolMarketPrices;
|
|
27
|
+
now: number;
|
|
28
|
+
side: GmsolSide;
|
|
29
|
+
}): bigint;
|
|
30
|
+
export declare function getGmsolPendingBorrowingFees({ market, prices, now, side, }: {
|
|
31
|
+
market: GmsolMarketState;
|
|
32
|
+
prices: GmsolMarketPrices;
|
|
33
|
+
now: number;
|
|
34
|
+
side: GmsolSide;
|
|
35
|
+
}): bigint;
|
|
36
|
+
export declare function getGmsolNextPositionImpactPoolAmount(market: GmsolMarketState, now: number): bigint;
|
|
37
|
+
export declare function getGmsolPoolValue({ market, prices, now, pnlFactorKind, maximize, }: {
|
|
38
|
+
market: GmsolMarketState;
|
|
39
|
+
prices: GmsolMarketPrices;
|
|
40
|
+
now: number;
|
|
41
|
+
pnlFactorKind: GmsolPnlFactorKind;
|
|
42
|
+
maximize: boolean;
|
|
43
|
+
}): bigint;
|
|
44
|
+
export declare function getGmsolNextFunding(market: GmsolMarketState, now: number): GmsolNextFunding;
|
|
45
|
+
export declare function getGmsolMarketStatus({ market, prices, now, }: {
|
|
46
|
+
market: GmsolMarketState;
|
|
47
|
+
prices: GmsolMarketPrices;
|
|
48
|
+
now: number;
|
|
49
|
+
}): GmsolMarketStatus;
|
|
@@ -1 +1,11 @@
|
|
|
1
1
|
export declare function getGmsolFractionalPower(base20: bigint, exponent20: bigint): bigint;
|
|
2
|
+
export declare const gmsolMath: {
|
|
3
|
+
toUnsigned(value: bigint, what: string): bigint;
|
|
4
|
+
toSigned(value: bigint, what: string): bigint;
|
|
5
|
+
mulDiv(a: bigint, b: bigint, divisor: bigint, what: string): bigint;
|
|
6
|
+
mulDivCeil(a: bigint, b: bigint, divisor: bigint, what: string): bigint;
|
|
7
|
+
roundUpDiv(value: bigint, divisor: bigint, what: string): bigint;
|
|
8
|
+
applyFactor(value: bigint, factor: bigint, what: string): bigint;
|
|
9
|
+
divToFactor(value: bigint, divisor: bigint, what: string): bigint;
|
|
10
|
+
applyExponentFactor(value: bigint, exponent: bigint, what: string): bigint;
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GmsolMarketPrices, GmsolMarketState, GmsolPendingPositionFees, GmsolPositionState } from "./types";
|
|
2
|
+
export declare function getGmsolPendingPositionFees({ market, prices, now, position, }: {
|
|
3
|
+
market: GmsolMarketState;
|
|
4
|
+
prices: GmsolMarketPrices;
|
|
5
|
+
now: number;
|
|
6
|
+
position: GmsolPositionState;
|
|
7
|
+
}): GmsolPendingPositionFees;
|
|
@@ -7,3 +7,99 @@ export type Decimal = {
|
|
|
7
7
|
coefficient: bigint;
|
|
8
8
|
scale: number;
|
|
9
9
|
};
|
|
10
|
+
export type GmsolSide = 0 | 1;
|
|
11
|
+
export type GmsolPerSide = readonly [long: bigint, short: bigint];
|
|
12
|
+
export type GmsolPriceRange = {
|
|
13
|
+
min: bigint;
|
|
14
|
+
max: bigint;
|
|
15
|
+
};
|
|
16
|
+
export type GmsolMarketPrices = {
|
|
17
|
+
index: GmsolPriceRange;
|
|
18
|
+
long: GmsolPriceRange;
|
|
19
|
+
short: GmsolPriceRange;
|
|
20
|
+
};
|
|
21
|
+
export type GmsolPnlFactorKind = "maxAfterDeposit" | "maxAfterWithdrawal" | "maxForTrader";
|
|
22
|
+
export type GmsolFundingParams = {
|
|
23
|
+
exponent: bigint;
|
|
24
|
+
factor: bigint;
|
|
25
|
+
maxFactorPerSecond: bigint;
|
|
26
|
+
minFactorPerSecond: bigint;
|
|
27
|
+
increaseFactorPerSecond: bigint;
|
|
28
|
+
decreaseFactorPerSecond: bigint;
|
|
29
|
+
thresholdForStableFunding: bigint;
|
|
30
|
+
thresholdForDecreaseFunding: bigint;
|
|
31
|
+
};
|
|
32
|
+
export type GmsolMarketState = {
|
|
33
|
+
name: string;
|
|
34
|
+
marketTokenMint: string;
|
|
35
|
+
longTokenMint: string;
|
|
36
|
+
shortTokenMint: string;
|
|
37
|
+
store: string;
|
|
38
|
+
config: {
|
|
39
|
+
reserveFactor: bigint;
|
|
40
|
+
openInterestReserveFactor: bigint;
|
|
41
|
+
borrowingFeeReceiverFactor: bigint;
|
|
42
|
+
positionImpactDistributeFactor: bigint;
|
|
43
|
+
minPositionImpactPoolAmount: bigint;
|
|
44
|
+
maxPnlFactorForLongDeposit: bigint;
|
|
45
|
+
maxPnlFactorForShortDeposit: bigint;
|
|
46
|
+
maxPnlFactorForLongWithdrawal: bigint;
|
|
47
|
+
maxPnlFactorForShortWithdrawal: bigint;
|
|
48
|
+
maxPnlFactorForLongTrader: bigint;
|
|
49
|
+
maxPnlFactorForShortTrader: bigint;
|
|
50
|
+
};
|
|
51
|
+
skipBorrowingFeeForSmallerSide: boolean;
|
|
52
|
+
ignoreOpenInterestForUsageFactor: boolean;
|
|
53
|
+
borrowingFeeFactor: GmsolPerSide;
|
|
54
|
+
borrowingFeeExponent: GmsolPerSide;
|
|
55
|
+
borrowingFeeOptimalUsageFactor: GmsolPerSide;
|
|
56
|
+
borrowingFeeBaseFactor: GmsolPerSide;
|
|
57
|
+
borrowingFeeAboveOptimalUsageFactor: GmsolPerSide;
|
|
58
|
+
maxOpenInterest: GmsolPerSide;
|
|
59
|
+
funding: GmsolFundingParams;
|
|
60
|
+
primary: GmsolPerSide;
|
|
61
|
+
openInterest: GmsolPerSide;
|
|
62
|
+
openInterestInTokens: GmsolPerSide;
|
|
63
|
+
openInterestByCollateral: readonly [GmsolPerSide, GmsolPerSide];
|
|
64
|
+
positionImpactPoolAmount: bigint;
|
|
65
|
+
borrowingFactor: GmsolPerSide;
|
|
66
|
+
fundingFeeAmountPerSize: readonly [GmsolPerSide, GmsolPerSide];
|
|
67
|
+
claimableFundingAmountPerSize: readonly [GmsolPerSide, GmsolPerSide];
|
|
68
|
+
totalBorrowing: GmsolPerSide;
|
|
69
|
+
priceImpactDistributionClock: number;
|
|
70
|
+
borrowingClock: number;
|
|
71
|
+
fundingClock: number;
|
|
72
|
+
fundingFactorPerSecond: bigint;
|
|
73
|
+
};
|
|
74
|
+
export type GmsolPositionState = {
|
|
75
|
+
store: string;
|
|
76
|
+
marketToken: string;
|
|
77
|
+
collateralToken: string;
|
|
78
|
+
isLong: boolean;
|
|
79
|
+
sizeInUsd: bigint;
|
|
80
|
+
borrowingFactor: bigint;
|
|
81
|
+
fundingFeeAmountPerSize: bigint;
|
|
82
|
+
longTokenClaimableFundingAmountPerSize: bigint;
|
|
83
|
+
shortTokenClaimableFundingAmountPerSize: bigint;
|
|
84
|
+
};
|
|
85
|
+
export type GmsolNextFunding = {
|
|
86
|
+
factor: bigint;
|
|
87
|
+
longsPayShorts: boolean;
|
|
88
|
+
};
|
|
89
|
+
export type GmsolMarketStatus = {
|
|
90
|
+
fundingFactorPerSecond: bigint;
|
|
91
|
+
longsPayShorts: boolean;
|
|
92
|
+
liquidityForLong: bigint;
|
|
93
|
+
liquidityForShort: bigint;
|
|
94
|
+
};
|
|
95
|
+
export type GmsolPendingPositionFees = {
|
|
96
|
+
borrowingFeeValue: bigint;
|
|
97
|
+
fundingFeeAmount: bigint;
|
|
98
|
+
claimableLongTokenAmount: bigint;
|
|
99
|
+
claimableShortTokenAmount: bigint;
|
|
100
|
+
};
|
|
101
|
+
export type GmsolFeeDiscountConfig = {
|
|
102
|
+
maxRank: number;
|
|
103
|
+
byRank: readonly bigint[];
|
|
104
|
+
referredUser: bigint;
|
|
105
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit conversions from GMX SDK values to the inputs of the gmsol SDK (`CreateOrderParams`).
|
|
3
|
+
*
|
|
4
|
+
* The units are set by the gmsol program, not by the npm SDK version. `CreateOrderParams` is unchanged from
|
|
5
|
+
* `@gmsol-labs/gmsol-sdk` 0.9.0-test.2 through 0.11.0 (0.11 only adds the optional `nonce`). Recheck this table only
|
|
6
|
+
* when the gmsol program changes its precision.
|
|
7
|
+
*
|
|
8
|
+
* | Quantity | App (GMX SDK) | gmsol SDK | Conversion |
|
|
9
|
+
* | ------------------------------------------- | ----------------------------------- | ---------------------------------- | -------------------------------- |
|
|
10
|
+
* | USD value (`size`, decrease `min_output`) | USD × 10^30 | USD × 10^20 (u128) | ÷ 10^10, rounding chosen by caller; × 10^10 back (exact) |
|
|
11
|
+
* | Whole-token price (`TokenData.prices`) | USD × 10^30 per 1 whole token | — | ÷ 10^(decimals + 10) in one division -> unit price |
|
|
12
|
+
* | Contract price (`convertToContractPrice`) | USD × 10^30 per smallest unit | unit price: USD × 10^20 per smallest unit (u128) | ÷ 10^10 |
|
|
13
|
+
* | Token amount (`amount`, increase/swap `min_output`) | smallest units (lamports, mint base units) | smallest units (u64) | identity + u64 range check |
|
|
14
|
+
* | Display multiplier (`Token.visualMultiplier`) | display only | never applied | not an input of any helper |
|
|
15
|
+
*
|
|
16
|
+
* `trigger_price` and `acceptable_price` are unit prices. Decimals are the Solana mint's decimals, never the
|
|
17
|
+
* decimals of the Arbitrum token used for oracle prices.
|
|
18
|
+
*
|
|
19
|
+
* Contract: every input is a non-negative `bigint`; decimals is an integer in [0, 30]. Every lossy conversion takes an
|
|
20
|
+
* explicit rounding. A non-zero input that floors to zero is rejected (unrepresentable in gmsol units), as is an
|
|
21
|
+
* output above u128 (USD, prices) or u64 (amounts). Violations throw `RangeError`.
|
|
22
|
+
*
|
|
23
|
+
* Rounding guidance for order builders: round each bound toward the side that is stricter for the user.
|
|
24
|
+
* Acceptable price: "floor" when it is a maximum (long increase, short decrease), "ceil" when it is a minimum
|
|
25
|
+
* (short increase, long decrease). Size: "floor". `convertToContractPrice` always floors, so going through the contract
|
|
26
|
+
* price matches the direct conversion only for "floor"; for "ceil" it can come out one unit lower. Convert a "ceil"
|
|
27
|
+
* bound from the whole-token price with `appTokenPriceToGmsolUnitPrice`, which rounds once.
|
|
28
|
+
*/
|
|
29
|
+
export declare const GMSOL_USD_DECIMALS = 20;
|
|
30
|
+
export declare const MAX_GMSOL_TOKEN_DECIMALS = 30;
|
|
31
|
+
export declare const APP_TO_GMSOL_USD_DIVISOR: bigint;
|
|
32
|
+
export declare const U64_MAX: bigint;
|
|
33
|
+
export declare const U128_MAX: bigint;
|
|
34
|
+
export type GmsolRounding = "floor" | "ceil";
|
|
35
|
+
/** App USD (10^30) -> gmsol USD (10^20). */
|
|
36
|
+
export declare function appUsdToGmsolUsd(usd: bigint, rounding: GmsolRounding): bigint;
|
|
37
|
+
/** gmsol USD (10^20) -> app USD (10^30). Exact. */
|
|
38
|
+
export declare function gmsolUsdToAppUsd(usd: bigint): bigint;
|
|
39
|
+
/** App contract price (USD 10^30 per smallest unit) -> gmsol unit price (USD 10^20 per smallest unit). */
|
|
40
|
+
export declare function appContractPriceToGmsolUnitPrice(contractPrice: bigint, rounding: GmsolRounding): bigint;
|
|
41
|
+
/** App whole-token price (USD 10^30 per whole token) -> gmsol unit price, rounding once. */
|
|
42
|
+
export declare function appTokenPriceToGmsolUnitPrice({ price, decimals, rounding, }: {
|
|
43
|
+
price: bigint;
|
|
44
|
+
decimals: number;
|
|
45
|
+
rounding: GmsolRounding;
|
|
46
|
+
}): bigint;
|
|
47
|
+
/** gmsol unit price -> app whole-token price (USD 10^30 per whole token). Exact. */
|
|
48
|
+
export declare function gmsolUnitPriceToAppTokenPrice({ unitPrice, decimals, }: {
|
|
49
|
+
unitPrice: bigint;
|
|
50
|
+
decimals: number;
|
|
51
|
+
}): bigint;
|
|
52
|
+
/** Token amount in smallest units, checked to fit gmsol's u64. Never pass a display-scaled value. */
|
|
53
|
+
export declare function toGmsolTokenAmount(amount: bigint): bigint;
|
|
@@ -9,6 +9,7 @@ type ApiFieldParams = {
|
|
|
9
9
|
endpoint: string;
|
|
10
10
|
};
|
|
11
11
|
export declare function readApiString({ record, name, endpoint }: ApiFieldParams): string;
|
|
12
|
+
export declare function readApiUnsignedInteger({ record, name, endpoint }: ApiFieldParams): number;
|
|
12
13
|
export declare function readApiUnsignedBigInt({ record, name, endpoint }: ApiFieldParams): bigint;
|
|
13
14
|
export declare function assertApiRecords(value: unknown, endpoint: string): asserts value is Record<string, unknown>[];
|
|
14
15
|
export declare function assertApiFields(record: Record<string, unknown>, fields: readonly ApiFieldSpec[], endpoint: string, index: number): void;
|
|
@@ -24,6 +24,7 @@ export type MarketPoolTokens = {
|
|
|
24
24
|
indexToken: TokenData;
|
|
25
25
|
};
|
|
26
26
|
export type MarketInfo = GmsolMarketConfig & Market & MarketPoolTokens & {
|
|
27
|
+
useV221LiquidationImpact?: boolean;
|
|
27
28
|
isDisabled: boolean;
|
|
28
29
|
longPoolAmount: bigint;
|
|
29
30
|
shortPoolAmount: bigint;
|
|
@@ -110,6 +111,8 @@ export type MarketInfo = GmsolMarketConfig & Market & MarketPoolTokens & {
|
|
|
110
111
|
swapImpactExponentFactor: bigint;
|
|
111
112
|
withdrawalFeeFactorBalanceWasImproved?: bigint;
|
|
112
113
|
withdrawalFeeFactorBalanceWasNotImproved?: bigint;
|
|
114
|
+
depositFeeFactorBalanceWasImproved?: bigint;
|
|
115
|
+
depositFeeFactorBalanceWasNotImproved?: bigint;
|
|
113
116
|
borrowingFactorPerSecondForLongs: bigint;
|
|
114
117
|
borrowingFactorPerSecondForShorts: bigint;
|
|
115
118
|
fundingFactorPerSecond: bigint;
|
|
@@ -141,11 +144,11 @@ export type MarketValues = Pick<MarketInfo, (typeof MARKET_VALUES_KEYS)[number]>
|
|
|
141
144
|
/**
|
|
142
145
|
* Updates seldom
|
|
143
146
|
*/
|
|
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">;
|
|
147
|
+
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" | "depositFeeFactorBalanceWasImproved" | "depositFeeFactorBalanceWasNotImproved" | "virtualMarketId" | "virtualIndexTokenId" | "virtualLongTokenId" | "virtualShortTokenId">;
|
|
145
148
|
export type MarketsData = {
|
|
146
149
|
[marketTokenAddress: string]: Market;
|
|
147
150
|
};
|
|
148
|
-
export type RawMarketInfo = Omit<MarketInfo, "longToken" | "shortToken" | "indexToken" | "claimableFundingAmountLong" | "claimableFundingAmountShort">;
|
|
151
|
+
export type RawMarketInfo = Omit<MarketInfo, "longToken" | "shortToken" | "indexToken" | "claimableFundingAmountLong" | "claimableFundingAmountShort" | "useV221LiquidationImpact">;
|
|
149
152
|
export type RawMarketsInfoData = {
|
|
150
153
|
[marketAddress: string]: RawMarketInfo;
|
|
151
154
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Hex } from "viem";
|
|
2
2
|
import type { AnyChainId, SettlementChainId } from "../../configs/chains";
|
|
3
3
|
import type { IAbstractSigner } from "../signer";
|
|
4
|
+
import type { SignedTokenPermit } from "../tokens/types";
|
|
4
5
|
export type BridgeFeeParams = {
|
|
5
6
|
feeToken: string;
|
|
6
7
|
feeAmount: bigint;
|
|
@@ -28,10 +29,12 @@ export type SameChainDepositRequest = {
|
|
|
28
29
|
amount: bigint;
|
|
29
30
|
/** Receiving GMX account address (typically the same as `signer.address`). */
|
|
30
31
|
account: string;
|
|
32
|
+
/** Signed GMX Router permits for `tokenAddress`, so the deposit needs no approval transaction */
|
|
33
|
+
tokenPermits?: SignedTokenPermit[];
|
|
31
34
|
};
|
|
32
35
|
/**
|
|
33
36
|
* Wallet sits on the settlement chain and funds the GMX account directly via
|
|
34
|
-
* `MultichainTransferRouter.multicall([sendWnt|sendTokens, bridgeIn])
|
|
37
|
+
* `MultichainTransferRouter.multicall([sendWnt|sendTokens, bridgeIn])`, or via ExchangeRouter when it carries permits.
|
|
35
38
|
*/
|
|
36
39
|
export declare function buildSameChainDepositTxn(request: SameChainDepositRequest): BuildTxnResult;
|
|
37
40
|
export declare function getEmptyBridgeFeeParams(): BridgeFeeParams;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Hex } from "viem";
|
|
2
2
|
import { ContractsChainId } from "../../configs/chains";
|
|
3
3
|
import { ExecutionFee } from "../fees/types";
|
|
4
|
-
import { DecreasePositionSwapType, OrderType } from "../orders/types";
|
|
5
|
-
import { ContractPrice, ERC20Address, TokensData } from "../tokens/types";
|
|
4
|
+
import { DecreasePositionSwapType, OrderInfo, OrderType } from "../orders/types";
|
|
5
|
+
import { ContractPrice, ERC20Address, SignedTokenPermit, TokensData } from "../tokens/types";
|
|
6
6
|
import { ExternalSwapQuote } from "../trade/types";
|
|
7
7
|
import { TwapOrderParams } from "../twap/types";
|
|
8
8
|
export type ExchangeRouterCall = {
|
|
@@ -25,6 +25,12 @@ export type UpdateOrderTxnParams = {
|
|
|
25
25
|
};
|
|
26
26
|
export type CancelOrderTxnParams = {
|
|
27
27
|
orderKey: string;
|
|
28
|
+
} & OrderPayoutAddresses;
|
|
29
|
+
/** Where an existing order pays out on execution or cancellation; undefined when the caller didn't load it */
|
|
30
|
+
export type OrderPayoutAddresses = {
|
|
31
|
+
receiver?: string;
|
|
32
|
+
cancellationReceiver?: string;
|
|
33
|
+
callbackContract?: string;
|
|
28
34
|
};
|
|
29
35
|
export type CreateOrderPayload = {
|
|
30
36
|
addresses: {
|
|
@@ -72,7 +78,7 @@ export type UpdateOrderParams = {
|
|
|
72
78
|
decreasePositionSwapType: DecreasePositionSwapType;
|
|
73
79
|
executionFeeTopUp: bigint;
|
|
74
80
|
executionGasLimit?: bigint;
|
|
75
|
-
};
|
|
81
|
+
} & OrderPayoutAddresses;
|
|
76
82
|
export type ExecutionFeeEstimate = {
|
|
77
83
|
executionFee: bigint;
|
|
78
84
|
gasLimit: bigint;
|
|
@@ -210,9 +216,15 @@ export declare function getExternalCallsPayload({ chainId, account, quote, }: {
|
|
|
210
216
|
account: string;
|
|
211
217
|
quote: ExternalSwapQuote;
|
|
212
218
|
}): ExternalCallsPayload;
|
|
213
|
-
|
|
219
|
+
/**
|
|
220
|
+
* Sets the Router allowance inside the same wallet transaction. ExchangeRouter and GlvRouter share this call, and it
|
|
221
|
+
* has to come before the first sendTokens, which spends the allowance.
|
|
222
|
+
*/
|
|
223
|
+
export declare function buildTokenPermitsCall(tokenPermits: SignedTokenPermit[]): ExchangeRouterCall;
|
|
224
|
+
export declare function getBatchOrderMulticallPayload({ chainId, params, tokenPermits, }: {
|
|
214
225
|
chainId: ContractsChainId;
|
|
215
226
|
params: BatchOrderTxnParams;
|
|
227
|
+
tokenPermits?: SignedTokenPermit[];
|
|
216
228
|
}): {
|
|
217
229
|
multicall: ExchangeRouterCall[];
|
|
218
230
|
value: bigint;
|
|
@@ -242,3 +254,6 @@ export declare function getBatchSwapsCount(orderParams: BatchOrderTxnParams | un
|
|
|
242
254
|
export declare function getIsEmptyBatch(orderParams: BatchOrderTxnParams | undefined): boolean;
|
|
243
255
|
export declare function getBatchIsNativePayment(orderParams: BatchOrderTxnParams): boolean;
|
|
244
256
|
export declare function getIsInvalidBatchReceiver(batchParams: BatchOrderTxnParams, signerAddress: string): boolean;
|
|
257
|
+
export declare function getOrderPayoutAddresses(order: OrderPayoutAddresses | undefined): OrderPayoutAddresses;
|
|
258
|
+
export declare function getCancelOrderParams(order: OrderInfo): CancelOrderTxnParams[];
|
|
259
|
+
export declare function getIsBatchPayoutOnlyToAccount(batchParams: BatchOrderTxnParams, account: string): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IHttp, SolanaReadOptions } from "../http/types";
|
|
2
|
-
import { ApiOrderInfo } from "./types";
|
|
2
|
+
import type { ApiOrderInfo } from "./types";
|
|
3
|
+
export declare function parseApiOrders(orders: unknown, endpoint: string): ApiOrderInfo[];
|
|
3
4
|
export declare function fetchApiOrders(ctx: {
|
|
4
5
|
api: IHttp;
|
|
5
6
|
}, params: {
|
|
@@ -39,6 +39,7 @@ export type Order = {
|
|
|
39
39
|
marketAddress: string;
|
|
40
40
|
decreasePositionSwapType: DecreasePositionSwapType;
|
|
41
41
|
receiver: string;
|
|
42
|
+
cancellationReceiver?: string;
|
|
42
43
|
swapPath: string[];
|
|
43
44
|
contractAcceptablePrice: bigint;
|
|
44
45
|
contractTriggerPrice: bigint;
|
|
@@ -57,6 +58,7 @@ export type Order = {
|
|
|
57
58
|
uiFeeReceiver: string;
|
|
58
59
|
uiFeeFactor: bigint | undefined;
|
|
59
60
|
validFromTime: bigint;
|
|
61
|
+
srcChainId: bigint;
|
|
60
62
|
title?: string;
|
|
61
63
|
};
|
|
62
64
|
export type SwapOrderInfo = Order & {
|
|
@@ -132,5 +134,27 @@ export type ApiOrderInfo = {
|
|
|
132
134
|
isFrozen: boolean;
|
|
133
135
|
autoCancel: boolean;
|
|
134
136
|
dataList: string[];
|
|
137
|
+
} & Partial<SolanaApiOrderFields>;
|
|
138
|
+
export type SolanaOrderActionState = "pending" | "completed" | "cancelled";
|
|
139
|
+
export type SolanaOrderCallback = {
|
|
140
|
+
version: number;
|
|
141
|
+
program: string;
|
|
142
|
+
sharedData: string;
|
|
143
|
+
partitionedData: string;
|
|
144
|
+
};
|
|
145
|
+
export type SolanaOrderEscrowTokens = {
|
|
146
|
+
initialCollateralToken: string | undefined;
|
|
147
|
+
finalOutputToken: string | undefined;
|
|
148
|
+
longToken: string | undefined;
|
|
149
|
+
shortToken: string | undefined;
|
|
150
|
+
};
|
|
151
|
+
export type SolanaApiOrderFields = {
|
|
152
|
+
orderAccount: string;
|
|
153
|
+
actionState: SolanaOrderActionState;
|
|
154
|
+
positionAccount: string | undefined;
|
|
155
|
+
rentReceiver: string;
|
|
156
|
+
referrer: string | undefined;
|
|
157
|
+
callback: SolanaOrderCallback | undefined;
|
|
158
|
+
escrowTokens: SolanaOrderEscrowTokens;
|
|
135
159
|
};
|
|
136
160
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|